Skip to content

Commit e7751e4

Browse files
authored
Auto merge of #34720 - Manishearth:rollup, r=Manishearth
Rollup of 9 pull requests - Successful merges: #34097, #34456, #34610, #34612, #34659, #34688, #34691, #34699, #34700 - Failed merges:
2 parents 3fa1cdf + 5389ccc commit e7751e4

File tree

8 files changed

+84
-90
lines changed

8 files changed

+84
-90
lines changed

src/doc/book/conditional-compilation.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ they get set in the [`[features]` section][features] of your `Cargo.toml`:
4141
# no features by default
4242
default = []
4343

44-
# The “secure-password” feature depends on the bcrypt package.
45-
secure-password = ["bcrypt"]
44+
# Add feature "foo" here, then you can use it.
45+
# Our "foo" feature depends on nothing else.
46+
foo = []
4647
```
4748

4849
When you do this, Cargo passes along a flag to `rustc`:

src/doc/book/getting-started.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ an Internet connection to run the commands in this section, as we’ll be
1111
downloading Rust from the Internet.
1212

1313
We’ll be showing off a number of commands using a terminal, and those lines all
14-
start with `$`. We don't need to type in the `$`s, they are there to indicate
14+
start with `$`. You don't need to type in the `$`s, they are there to indicate
1515
the start of each command. We’ll see many tutorials and examples around the web
1616
that follow this convention: `$` for commands run as our regular user, and `#`
1717
for commands we should be running as an administrator.
@@ -159,9 +159,11 @@ You should see the version number, commit hash, and commit date.
159159
If you do, Rust has been installed successfully! Congrats!
160160

161161
If you don't and you're on Windows, check that Rust is in your %PATH% system
162-
variable. If it isn't, run the installer again, select "Change" on the "Change,
163-
repair, or remove installation" page and ensure "Add to PATH" is installed on
164-
the local hard drive.
162+
variable: `$ echo %PATH%`. If it isn't, run the installer again, select "Change"
163+
on the "Change, repair, or remove installation" page and ensure "Add to PATH" is
164+
installed on the local hard drive. If you need to configure your path manually,
165+
you can find the Rust executables in a directory like
166+
`"C:\Program Files\Rust stable GNU 1.x\bin"`.
165167

166168
Rust does not do its own linking, and so you’ll need to have a linker
167169
installed. Doing so will depend on your specific system, consult its
@@ -339,15 +341,16 @@ On Windows, you'd enter:
339341

340342
```bash
341343
$ dir
342-
main.exe main.rs
344+
main.exe
345+
main.rs
343346
```
344347

345348
This shows we have two files: the source code, with an `.rs` extension, and the
346349
executable (`main.exe` on Windows, `main` everywhere else). All that's left to
347350
do from here is run the `main` or `main.exe` file, like this:
348351

349352
```bash
350-
$ ./main # or main.exe on Windows
353+
$ ./main # or .\main.exe on Windows
351354
```
352355

353356
If *main.rs* were your "Hello, world!" program, this would print `Hello,

src/liballoc/rc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
#![allow(deprecated)]
1212

13-
//! Thread-local reference-counted boxes (the `Rc<T>` type).
13+
//! Unsynchronized reference-counted boxes (the `Rc<T>` type) which are usable
14+
//! only within a single thread.
1415
//!
1516
//! The `Rc<T>` type provides shared ownership of an immutable value.
1617
//! Destruction is deterministic, and will occur as soon as the last owner is

src/libcore/iter/traits.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,16 @@ pub trait Extend<A> {
371371
/// Basic usage:
372372
///
373373
/// ```
374-
/// let numbers = vec![1, 2, 3];
374+
/// let numbers = vec![1, 2, 3, 4, 5, 6];
375375
///
376376
/// let mut iter = numbers.iter();
377377
///
378378
/// assert_eq!(Some(&1), iter.next());
379-
/// assert_eq!(Some(&3), iter.next_back());
380-
/// assert_eq!(Some(&2), iter.next_back());
379+
/// assert_eq!(Some(&6), iter.next_back());
380+
/// assert_eq!(Some(&5), iter.next_back());
381+
/// assert_eq!(Some(&2), iter.next());
382+
/// assert_eq!(Some(&3), iter.next());
383+
/// assert_eq!(Some(&4), iter.next());
381384
/// assert_eq!(None, iter.next());
382385
/// assert_eq!(None, iter.next_back());
383386
/// ```
@@ -395,13 +398,16 @@ pub trait DoubleEndedIterator: Iterator {
395398
/// Basic usage:
396399
///
397400
/// ```
398-
/// let numbers = vec![1, 2, 3];
401+
/// let numbers = vec![1, 2, 3, 4, 5, 6];
399402
///
400403
/// let mut iter = numbers.iter();
401404
///
402405
/// assert_eq!(Some(&1), iter.next());
403-
/// assert_eq!(Some(&3), iter.next_back());
404-
/// assert_eq!(Some(&2), iter.next_back());
406+
/// assert_eq!(Some(&6), iter.next_back());
407+
/// assert_eq!(Some(&5), iter.next_back());
408+
/// assert_eq!(Some(&2), iter.next());
409+
/// assert_eq!(Some(&3), iter.next());
410+
/// assert_eq!(Some(&4), iter.next());
405411
/// assert_eq!(None, iter.next());
406412
/// assert_eq!(None, iter.next_back());
407413
/// ```

src/libstd/io/error.rs

+24
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,30 @@ impl Error {
214214
}
215215

216216
/// Creates a new instance of an `Error` from a particular OS error code.
217+
///
218+
/// # Examples
219+
///
220+
/// On Linux:
221+
///
222+
/// ```
223+
/// # if cfg!(target_os = "linux") {
224+
/// use std::io;
225+
///
226+
/// let error = io::Error::from_raw_os_error(98);
227+
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
228+
/// # }
229+
/// ```
230+
///
231+
/// On Windows:
232+
///
233+
/// ```
234+
/// # if cfg!(windows) {
235+
/// use std::io;
236+
///
237+
/// let error = io::Error::from_raw_os_error(10048);
238+
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
239+
/// # }
240+
/// ```
217241
#[stable(feature = "rust1", since = "1.0.0")]
218242
pub fn from_raw_os_error(code: i32) -> Error {
219243
Error { repr: Repr::Os(code) }

src/libstd/path.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1529,8 +1529,7 @@ impl Path {
15291529

15301530
/// The final component of the path, if it is a normal file.
15311531
///
1532-
/// If the path terminates in `.`, `..`, or consists solely of a root of
1533-
/// prefix, `file_name` will return `None`.
1532+
/// If the path terminates in `..`, `file_name` will return `None`.
15341533
///
15351534
/// # Examples
15361535
///
@@ -1543,6 +1542,17 @@ impl Path {
15431542
///
15441543
/// assert_eq!(Some(os_str), path.file_name());
15451544
/// ```
1545+
///
1546+
/// # Other examples
1547+
///
1548+
/// ```
1549+
/// use std::path::Path;
1550+
/// use std::ffi::OsStr;
1551+
///
1552+
/// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name());
1553+
/// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name());
1554+
/// assert_eq!(None, Path::new("foo.txt/..").file_name());
1555+
/// ```
15461556
#[stable(feature = "rust1", since = "1.0.0")]
15471557
pub fn file_name(&self) -> Option<&OsStr> {
15481558
self.components().next_back().and_then(|p| {

src/libstd/sys/common/net.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,19 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
152152
init();
153153

154154
let c_host = CString::new(host)?;
155+
let hints = c::addrinfo {
156+
ai_flags: 0,
157+
ai_family: 0,
158+
ai_socktype: c::SOCK_STREAM,
159+
ai_protocol: 0,
160+
ai_addrlen: 0,
161+
ai_addr: ptr::null_mut(),
162+
ai_canonname: ptr::null_mut(),
163+
ai_next: ptr::null_mut()
164+
};
155165
let mut res = ptr::null_mut();
156166
unsafe {
157-
cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), ptr::null(),
167+
cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints,
158168
&mut res))?;
159169
Ok(LookupHost { original: res, cur: res })
160170
}

src/libsyntax/parse/parser.rs

+11-72
Original file line numberDiff line numberDiff line change
@@ -495,64 +495,6 @@ impl<'a> Parser<'a> {
495495
}
496496
}
497497

498-
/// Check for erroneous `ident { }`; if matches, signal error and
499-
/// recover (without consuming any expected input token). Returns
500-
/// true if and only if input was consumed for recovery.
501-
pub fn check_for_erroneous_unit_struct_expecting(&mut self,
502-
expected: &[token::Token])
503-
-> bool {
504-
if self.token == token::OpenDelim(token::Brace)
505-
&& expected.iter().all(|t| *t != token::OpenDelim(token::Brace))
506-
&& self.look_ahead(1, |t| *t == token::CloseDelim(token::Brace)) {
507-
// matched; signal non-fatal error and recover.
508-
let span = self.span;
509-
self.span_err(span, "unit-like struct construction is written with no trailing `{ }`");
510-
self.eat(&token::OpenDelim(token::Brace));
511-
self.eat(&token::CloseDelim(token::Brace));
512-
true
513-
} else {
514-
false
515-
}
516-
}
517-
518-
/// Commit to parsing a complete expression `e` expected to be
519-
/// followed by some token from the set edible + inedible. Recover
520-
/// from anticipated input errors, discarding erroneous characters.
521-
pub fn commit_expr(&mut self, e: &Expr, edible: &[token::Token],
522-
inedible: &[token::Token]) -> PResult<'a, ()> {
523-
debug!("commit_expr {:?}", e);
524-
if let ExprKind::Path(..) = e.node {
525-
// might be unit-struct construction; check for recoverableinput error.
526-
let expected = edible.iter()
527-
.cloned()
528-
.chain(inedible.iter().cloned())
529-
.collect::<Vec<_>>();
530-
self.check_for_erroneous_unit_struct_expecting(&expected[..]);
531-
}
532-
self.expect_one_of(edible, inedible)
533-
}
534-
535-
pub fn commit_expr_expecting(&mut self, e: &Expr, edible: token::Token) -> PResult<'a, ()> {
536-
self.commit_expr(e, &[edible], &[])
537-
}
538-
539-
/// Commit to parsing a complete statement `s`, which expects to be
540-
/// followed by some token from the set edible + inedible. Check
541-
/// for recoverable input errors, discarding erroneous characters.
542-
pub fn commit_stmt(&mut self, edible: &[token::Token],
543-
inedible: &[token::Token]) -> PResult<'a, ()> {
544-
if self.last_token
545-
.as_ref()
546-
.map_or(false, |t| t.is_ident() || t.is_path()) {
547-
let expected = edible.iter()
548-
.cloned()
549-
.chain(inedible.iter().cloned())
550-
.collect::<Vec<_>>();
551-
self.check_for_erroneous_unit_struct_expecting(&expected);
552-
}
553-
self.expect_one_of(edible, inedible)
554-
}
555-
556498
/// returns the span of expr, if it was not interpolated or the span of the interpolated token
557499
fn interpolated_or_expr_span(&self,
558500
expr: PResult<'a, P<Expr>>)
@@ -1247,7 +1189,7 @@ impl<'a> Parser<'a> {
12471189
let default = if self.check(&token::Eq) {
12481190
self.bump();
12491191
let expr = self.parse_expr()?;
1250-
self.commit_expr_expecting(&expr, token::Semi)?;
1192+
self.expect(&token::Semi)?;
12511193
Some(expr)
12521194
} else {
12531195
self.expect(&token::Semi)?;
@@ -2195,8 +2137,7 @@ impl<'a> Parser<'a> {
21952137
let mut trailing_comma = false;
21962138
while self.token != token::CloseDelim(token::Paren) {
21972139
es.push(self.parse_expr()?);
2198-
self.commit_expr(&es.last().unwrap(), &[],
2199-
&[token::Comma, token::CloseDelim(token::Paren)])?;
2140+
self.expect_one_of(&[], &[token::Comma, token::CloseDelim(token::Paren)])?;
22002141
if self.check(&token::Comma) {
22012142
trailing_comma = true;
22022143

@@ -2407,9 +2348,8 @@ impl<'a> Parser<'a> {
24072348
}
24082349
}
24092350

2410-
match self.commit_expr(&fields.last().unwrap().expr,
2411-
&[token::Comma],
2412-
&[token::CloseDelim(token::Brace)]) {
2351+
match self.expect_one_of(&[token::Comma],
2352+
&[token::CloseDelim(token::Brace)]) {
24132353
Ok(()) => {}
24142354
Err(mut e) => {
24152355
e.emit();
@@ -2662,7 +2602,7 @@ impl<'a> Parser<'a> {
26622602
self.bump();
26632603
let ix = self.parse_expr()?;
26642604
hi = self.span.hi;
2665-
self.commit_expr_expecting(&ix, token::CloseDelim(token::Bracket))?;
2605+
self.expect(&token::CloseDelim(token::Bracket))?;
26662606
let index = self.mk_index(e, ix);
26672607
e = self.mk_expr(lo, hi, index, ThinVec::new())
26682608
}
@@ -3329,8 +3269,7 @@ impl<'a> Parser<'a> {
33293269
let lo = self.last_span.lo;
33303270
let discriminant = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL,
33313271
None)?;
3332-
if let Err(mut e) = self.commit_expr_expecting(&discriminant,
3333-
token::OpenDelim(token::Brace)) {
3272+
if let Err(mut e) = self.expect(&token::OpenDelim(token::Brace)) {
33343273
if self.token == token::Token::Semi {
33353274
e.span_note(match_span, "did you mean to remove this `match` keyword?");
33363275
}
@@ -3376,7 +3315,7 @@ impl<'a> Parser<'a> {
33763315
&& self.token != token::CloseDelim(token::Brace);
33773316

33783317
if require_comma {
3379-
self.commit_expr(&expr, &[token::Comma], &[token::CloseDelim(token::Brace)])?;
3318+
self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)])?;
33803319
} else {
33813320
self.eat(&token::Comma);
33823321
}
@@ -4118,7 +4057,7 @@ impl<'a> Parser<'a> {
41184057
_ => { // all other kinds of statements:
41194058
let mut hi = span.hi;
41204059
if classify::stmt_ends_with_semi(&node) {
4121-
self.commit_stmt(&[token::Semi], &[])?;
4060+
self.expect(&token::Semi)?;
41224061
hi = self.last_span.hi;
41234062
}
41244063

@@ -4196,7 +4135,7 @@ impl<'a> Parser<'a> {
41964135
if classify::expr_requires_semi_to_be_stmt(&e) {
41974136
// Just check for errors and recover; do not eat semicolon yet.
41984137
if let Err(mut e) =
4199-
self.commit_stmt(&[], &[token::Semi, token::CloseDelim(token::Brace)])
4138+
self.expect_one_of(&[], &[token::Semi, token::CloseDelim(token::Brace)])
42004139
{
42014140
e.emit();
42024141
self.recover_stmt();
@@ -4863,7 +4802,7 @@ impl<'a> Parser<'a> {
48634802
let typ = self.parse_ty_sum()?;
48644803
self.expect(&token::Eq)?;
48654804
let expr = self.parse_expr()?;
4866-
self.commit_expr_expecting(&expr, token::Semi)?;
4805+
self.expect(&token::Semi)?;
48674806
(name, ast::ImplItemKind::Const(typ, expr))
48684807
} else {
48694808
let (name, inner_attrs, node) = self.parse_impl_method(&vis)?;
@@ -5287,7 +5226,7 @@ impl<'a> Parser<'a> {
52875226
let ty = self.parse_ty_sum()?;
52885227
self.expect(&token::Eq)?;
52895228
let e = self.parse_expr()?;
5290-
self.commit_expr_expecting(&e, token::Semi)?;
5229+
self.expect(&token::Semi)?;
52915230
let item = match m {
52925231
Some(m) => ItemKind::Static(ty, m, e),
52935232
None => ItemKind::Const(ty, e),

0 commit comments

Comments
 (0)