Skip to content

Commit c3c9961

Browse files
committed
---
yaml --- r: 121535 b: refs/heads/master c: f8e06c4 h: refs/heads/master i: 121533: 12f375b 121531: 55ed371 121527: 0a9125e 121519: fb34608 121503: 9e86512 121471: 71c83e0 v: v3
1 parent cbe7239 commit c3c9961

File tree

28 files changed

+63
-287
lines changed

28 files changed

+63
-287
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 389fae2ca85dc83da8deb70cc7c5acc50e87e684
2+
refs/heads/master: f8e06c49650afd7c9ef749baa72cb8da59880f96
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: bab614f5fa725d248afc5f0530c835f37998ce8f
55
refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f

trunk/src/compiletest/runtest.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
320320

321321
let config = &mut config;
322322
let DebuggerCommands { commands, check_lines, .. } = parse_debugger_commands(testfile, "gdb");
323-
let mut cmds = commands.connect("\n").to_string();
323+
let mut cmds = commands.connect("\n");
324324

325325
// compile test file (it shoud have 'compile-flags:-g' in the header)
326326
let compiler_run_result = compile_test(config, props, testfile);
@@ -1035,10 +1035,7 @@ fn compose_and_run_compiler(
10351035
make_compile_args(config,
10361036
&aux_props,
10371037
crate_type.append(
1038-
extra_link_args.iter()
1039-
.map(|x| x.to_string())
1040-
.collect::<Vec<_>>()
1041-
.as_slice()),
1038+
extra_link_args.as_slice()),
10421039
|a,b| {
10431040
let f = make_lib_name(a, b, testfile);
10441041
ThisDirectory(f.dir_path())

trunk/src/doc/guide.md

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -106,184 +106,4 @@ call ourselves), and we can help you out. Other great resources include our
106106

107107
## Hello, world!
108108

109-
Now that you have Rust installed, let's write your first Rust program. It's
110-
traditional to make your first program in any new language one that prints the
111-
text "Hello, world!" to the screen. The nice thing about starting with such a
112-
simple program is that you can verify that your compiler isn't just installed,
113-
but also working properly. And printing information to the screen is a pretty
114-
common thing to do.
115-
116-
The first thing that we need to do is make a file to put our code in. I like
117-
to make a projects directory in my home directory, and keep all my projects
118-
there. Rust does not care where your code lives.
119-
120-
This actually leads to one other concern we should address: this tutorial will
121-
assume that you have basic familiarity with the command-line. Rust does not
122-
require that you know a whole ton about the command line, but until the
123-
language is in a more finished state, IDE support is spotty. Rust makes no
124-
specific demands on your editing tooling, or where your code lives.
125-
126-
With that said, let's make a directory in our projects directory. Note that you
127-
don't need to type in the `$`s, they just indicate the start of each command:
128-
129-
```{bash}
130-
$ mkdir ~/projects
131-
$ cd ~/projects
132-
$ mkdir hello_world
133-
$ cd hello_world
134-
```
135-
136-
If you're on Windows and not using PowerShell, the `~` may not work. Consult
137-
the documentation for your shell for more details.
138-
139-
Let's make a new source file next. I'm going to use the syntax `editor
140-
filename` to represent editing a file in these examples, but you should use
141-
whatever method you want. We'll call our file `hello_world.rs`:
142-
143-
```{bash}
144-
$ editor hello_world.rs
145-
```
146-
147-
Rust files always end in a `.rs` extension. If you're using more than one word
148-
in your file name, use an underscore. `hello_world.rs` versus `goodbye.rs`.
149-
150-
Now that you've got your file open, type this in:
151-
152-
```
153-
fn main() {
154-
println!("Hello, world");
155-
}
156-
```
157-
158-
Save the file, and then type this into your terminal window:
159-
160-
```{bash}
161-
$ rustc hello_world.rs
162-
$ ./hello_world # on Windows, this is ./hello_world.exe
163-
Hello, world
164-
```
165-
166-
Success! Let's go over what just happened in detail.
167-
168-
```
169-
fn main() {
170-
171-
}
172-
```
173-
174-
These two lines define a **function** in Rust. The `main` function is special:
175-
it's the beginning of every Rust program. The first line says "I'm declaring a
176-
function named `main`, which takes no arguments and returns nothing." If there
177-
were arguments, they would go inside the parentheses (`(` and `)`), and because
178-
we aren't returning anything from this function, we've dropped that notation
179-
entirely. We'll get to it later.
180-
181-
You'll also note that the function is wrapped in curly braces (`{` and `}`).
182-
Rust requires these around all function bodies. It is also considered good
183-
style to put the curly brace on the same line as the function declaration, with
184-
one space in between.
185-
186-
Next up is this line:
187-
188-
```
189-
println!("Hello, world");
190-
```
191-
192-
This line does all of the work in our little program. There are a number of
193-
details that are important here. The first is that it's indented with four
194-
spaces, not tabs. Please configure your editor of choice to insert four spaces
195-
with the tab key. We provide some sample configurations for various editors
196-
[here](https://github.com/rust-lang/rust/tree/master/src/etc).
197-
198-
The second point is the `println!()` part. This is calling a Rust **macro**,
199-
which is how metaprogramming is done in Rust. If it were a function instead, it
200-
would look like this: `println()`. For our purposes, we don't need to worry
201-
about this difference. Just know that sometimes, you'll see a `!`, and that
202-
means that you're calling a macro instead of a normal function.
203-
204-
Next, `"Hello, world"` is a **string**. Strings are a surprisingly
205-
complicated topic in a systems programming language, and this is a **staticly
206-
allocated** string. We will talk more about different kinds of allocation
207-
later. We pass this string as an argument to `println!`, which prints the
208-
string to the screen. Easy enough!
209-
210-
Finally, the line ends with a semicolon (`;`). Rust is an **expression
211-
oriented** language, which means that most things are expressions. The `;` is
212-
used to indicate that this expression is over, and the next one is ready to
213-
begin. Most lines of Rust code end with a `;`. We will cover this in-depth
214-
later in the tutorial.
215-
216-
Finally, actually **compiling** and **running** our program. We can compile
217-
with our compiler, `rustc`, by passing it the name of our source file:
218-
219-
```{bash}
220-
$ rustc hello_world.rs
221-
```
222-
223-
This is similar to `gcc` or `clang`, if you come from a C or C++ background. Rust
224-
will output a binary executable. You can see it with `ls`:
225-
226-
```{bash}
227-
$ ls
228-
hello_world hello_world.rs
229-
```
230-
231-
Or on Windows:
232-
233-
```{bash}
234-
$ dir
235-
hello_world.exe hello_world.rs
236-
```
237-
238-
There are now two files: our source code, with the `.rs`, and the executable.
239-
We ran the executable like this:
240-
241-
```{bash}
242-
$ ./hello_world # or ./hello_world.exe on Windows
243-
```
244-
245-
This prints out our `Hello, world!` text to our terminal.
246-
247-
If you come from a dynamically typed language like Ruby, Python, or JavaScript,
248-
you may not be used to these two steps being separate. Rust is an
249-
**ahead-of-time compiled language**, which means that you can compile a
250-
program, give it to someone else, and they don't need to have Rust installed.
251-
If you give someone a `.rb` or `.py` or `.js` file, they need to have
252-
Ruby/Python/JavaScript installed, but you just need one command to both compile
253-
and run your program. Everything is a tradeoff in language design, and Rust has
254-
made its choice.
255-
256-
Congratulations! You have officially written a Rust program. That makes you a
257-
Rust programmer! Welcome.
258-
259-
Next, I'd like to introduce you to another tool, Cargo, which is used to write
260-
real-world Rust programs. Just using `rustc` is nice for simple things, but as
261-
your project grows, you'll want something to help you manage all of the options
262-
that it has, and to make it easy to share your code with other people and
263-
projects.
264-
265109
## Hello, Cargo!
266-
267-
268-
269-
270-
271-
272-
273-
274-
275-
276-
277-
278-
279-
280-
281-
282-
283-
284-
285-
286-
287-
288-
289-

trunk/src/libgetopts/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
//! }
5050
//!
5151
//! fn main() {
52-
//! let args: Vec<String> = os::args().iter()
53-
//! .map(|x| x.to_string())
54-
//! .collect();
52+
//! let args: Vec<String> = os::args();
5553
//!
5654
//! let program = args.get(0).clone();
5755
//!

trunk/src/librustc/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ pub fn sanitize(s: &str) -> String {
659659
if result.len() > 0u &&
660660
result.as_slice()[0] != '_' as u8 &&
661661
! char::is_XID_start(result.as_slice()[0] as char) {
662-
return format!("_{}", result.as_slice()).to_string();
662+
return format!("_{}", result.as_slice());
663663
}
664664

665665
return result;

trunk/src/librustc/driver/config.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
650650
}
651651

652652
let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m));
653-
let target = match matches.opt_str("target") {
654-
Some(supplied_target) => supplied_target.to_string(),
655-
None => driver::host_triple().to_string(),
656-
};
653+
let target = matches.opt_str("target").unwrap_or(
654+
driver::host_triple().to_string());
657655
let opt_level = {
658656
if (debugging_opts & NO_OPT) != 0 {
659657
No
@@ -705,10 +703,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
705703
Path::new(s.as_slice())
706704
}).collect();
707705

708-
let cfg = parse_cfgspecs(matches.opt_strs("cfg")
709-
.move_iter()
710-
.map(|x| x.to_string())
711-
.collect());
706+
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
712707
let test = matches.opt_present("test");
713708
let write_dependency_info = (matches.opt_present("dep-info"),
714709
matches.opt_str("dep-info")

trunk/src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl pprust::PpAnn for IdentifiedAnnotation {
595595
}
596596
pprust::NodeBlock(blk) => {
597597
try!(pp::space(&mut s.s));
598-
s.synth_comment((format!("block {}", blk.id)).to_string())
598+
s.synth_comment(format!("block {}", blk.id))
599599
}
600600
pprust::NodeExpr(expr) => {
601601
try!(pp::space(&mut s.s));
@@ -604,7 +604,7 @@ impl pprust::PpAnn for IdentifiedAnnotation {
604604
}
605605
pprust::NodePat(pat) => {
606606
try!(pp::space(&mut s.s));
607-
s.synth_comment((format!("pat {}", pat.id)).to_string())
607+
s.synth_comment(format!("pat {}", pat.id))
608608
}
609609
}
610610
}
@@ -752,7 +752,7 @@ fn print_flowgraph<W:io::Writer>(analysis: CrateAnalysis,
752752
let cfg = cfg::CFG::new(ty_cx, &*block);
753753
let lcfg = LabelledCFG { ast_map: &ty_cx.map,
754754
cfg: &cfg,
755-
name: format!("block{}", block.id).to_string(), };
755+
name: format!("block{}", block.id), };
756756
debug!("cfg: {:?}", cfg);
757757
let r = dot::render(&lcfg, &mut out);
758758
return expand_err_details(r);

trunk/src/librustc/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ mod rustc {
137137
}
138138

139139
pub fn main() {
140-
let args = std::os::args().iter()
141-
.map(|x| x.to_string())
142-
.collect::<Vec<_>>();
140+
let args = std::os::args();
143141
std::os::set_exit_status(driver::main_args(args.as_slice()));
144142
}

trunk/src/librustc/lib/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ impl TypeNames {
18941894

18951895
pub fn types_to_str(&self, tys: &[Type]) -> String {
18961896
let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect();
1897-
format!("[{}]", strs.connect(",").to_string())
1897+
format!("[{}]", strs.connect(","))
18981898
}
18991899

19001900
pub fn val_to_str(&self, val: ValueRef) -> String {

trunk/src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,11 @@ impl<'a> PluginMetadataReader<'a> {
441441
};
442442
let macros = decoder::get_exported_macros(library.metadata.as_slice());
443443
let registrar = decoder::get_plugin_registrar_fn(library.metadata.as_slice()).map(|id| {
444-
decoder::get_symbol(library.metadata.as_slice(), id).to_string()
444+
decoder::get_symbol(library.metadata.as_slice(), id)
445445
});
446446
let pc = PluginMetadata {
447447
lib: library.dylib.clone(),
448-
macros: macros.move_iter().map(|x| x.to_string()).collect(),
448+
macros: macros,
449449
registrar_symbol: registrar,
450450
};
451451
if should_link && existing_match(&self.env, &info.crate_id, None).is_none() {

trunk/src/librustc/middle/borrowck/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -801,37 +801,34 @@ impl DataFlowOperator for LoanDataFlowOperator {
801801

802802
impl Repr for Loan {
803803
fn repr(&self, tcx: &ty::ctxt) -> String {
804-
(format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
804+
format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
805805
self.index,
806806
self.loan_path.repr(tcx),
807807
self.kind,
808808
self.gen_scope,
809809
self.kill_scope,
810-
self.restricted_paths.repr(tcx))).to_string()
810+
self.restricted_paths.repr(tcx))
811811
}
812812
}
813813

814814
impl Repr for LoanPath {
815815
fn repr(&self, tcx: &ty::ctxt) -> String {
816816
match self {
817817
&LpVar(id) => {
818-
(format!("$({})", tcx.map.node_to_str(id))).to_string()
818+
format!("$({})", tcx.map.node_to_str(id))
819819
}
820820

821821
&LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => {
822822
let s = tcx.map.node_to_str(var_id);
823-
let s = format!("$({} captured by id={})", s, closure_expr_id);
824-
s.to_string()
823+
format!("$({} captured by id={})", s, closure_expr_id)
825824
}
826825

827826
&LpExtend(ref lp, _, LpDeref(_)) => {
828-
(format!("{}.*", lp.repr(tcx))).to_string()
827+
format!("{}.*", lp.repr(tcx))
829828
}
830829

831830
&LpExtend(ref lp, _, LpInterior(ref interior)) => {
832-
(format!("{}.{}",
833-
lp.repr(tcx),
834-
interior.repr(tcx))).to_string()
831+
format!("{}.{}", lp.repr(tcx), interior.repr(tcx))
835832
}
836833
}
837834
}

trunk/src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl Repr for ty::ParamBounds {
629629
for t in self.trait_bounds.iter() {
630630
res.push(t.repr(tcx));
631631
}
632-
res.connect("+").to_string()
632+
res.connect("+")
633633
}
634634
}
635635

trunk/src/librustdoc/html/markdown.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
228228
};
229229

230230
// Transform the contents of the header into a hyphenated string
231-
let id = (s.as_slice().words().map(|s| {
231+
let id = s.as_slice().words().map(|s| {
232232
match s.to_ascii_opt() {
233233
Some(s) => s.to_lower().into_str(),
234234
None => s.to_string()
235235
}
236-
}).collect::<Vec<String>>().connect("-")).to_string();
236+
}).collect::<Vec<String>>().connect("-");
237237

238238
// This is a terrible hack working around how hoedown gives us rendered
239239
// html for text rather than the raw text.
@@ -252,7 +252,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
252252

253253
let sec = match opaque.toc_builder {
254254
Some(ref mut builder) => {
255-
builder.push(level as u32, s.to_string(), id.clone())
255+
builder.push(level as u32, s.clone(), id.clone())
256256
}
257257
None => {""}
258258
};

0 commit comments

Comments
 (0)