Skip to content

Commit 3f55461

Browse files
committed
Auto merge of #63262 - pietroalbini:beta-rollup, r=pietroalbini
[beta] Rollup backports Cherry picked: * Updated RELEASES.md for 1.37.0 #63147 * Require a value for configure --debuginfo-level #62906 * Make the parser TokenStream more resilient after mismatched delimiter recovery #62887 * ci: move .azure-pipelines to src/ci/azure-pipelines #63242 Rolled up: * [BETA] Update cargo #62911 * [beta] Backport #61207 #63254 r? @ghost
2 parents 61d1607 + 775ffd9 commit 3f55461

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1794
-41
lines changed

RELEASES.md

+118
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,121 @@
1+
Version 1.37.0 (2019-08-15)
2+
==========================
3+
4+
Language
5+
--------
6+
- `#[must_use]` will now warn if the type is contained in a [tuple][61100],
7+
[`Box`][62228], or an [array][62235] and unused.
8+
- [You can now use the `cfg` and `cfg_attr` attributes on
9+
generic parameters.][61547]
10+
- [You can now use enum variants through type alias.][61682] e.g. You can
11+
write the following:
12+
```rust
13+
type MyOption = Option<u8>;
14+
15+
fn increment_or_zero(x: MyOption) -> u8 {
16+
match x {
17+
MyOption::Some(y) => y + 1,
18+
MyOption::None => 0,
19+
}
20+
}
21+
```
22+
- [You can now use `_` as an identifier for consts.][61347] e.g. You can write
23+
`const _: u32 = 5;`.
24+
- [You can now use `#[repr(align(X)]` on enums.][61229]
25+
- [The `?`/_"Kleene"_ macro operator is now available in the
26+
2015 edition.][60932]
27+
28+
Compiler
29+
--------
30+
- [You can now enable Profile-Guided Optimization with the `-C profile-generate`
31+
and `-C profile-use` flags.][61268] For more information on how to use profile
32+
guided optimization, please refer to the [rustc book][rustc-book-pgo].
33+
- [The `rust-lldb` wrapper script should now work again.][61827]
34+
35+
Libraries
36+
---------
37+
- [`mem::MaybeUninit<T>` is now ABI-compatible with `T`.][61802]
38+
39+
Stabilized APIs
40+
---------------
41+
- [`BufReader::buffer`]
42+
- [`BufWriter::buffer`]
43+
- [`Cell::from_mut`]
44+
- [`Cell<[T]>::as_slice_of_cells`][`Cell<slice>::as_slice_of_cells`]
45+
- [`DoubleEndedIterator::nth_back`]
46+
- [`Option::xor`]
47+
- [`Wrapping::reverse_bits`]
48+
- [`i128::reverse_bits`]
49+
- [`i16::reverse_bits`]
50+
- [`i32::reverse_bits`]
51+
- [`i64::reverse_bits`]
52+
- [`i8::reverse_bits`]
53+
- [`isize::reverse_bits`]
54+
- [`slice::copy_within`]
55+
- [`u128::reverse_bits`]
56+
- [`u16::reverse_bits`]
57+
- [`u32::reverse_bits`]
58+
- [`u64::reverse_bits`]
59+
- [`u8::reverse_bits`]
60+
- [`usize::reverse_bits`]
61+
62+
Cargo
63+
-----
64+
- [`Cargo.lock` files are now included by default when publishing executable crates
65+
with executables.][cargo/7026]
66+
- [You can now specify `default-run="foo"` in `[package]` to specify the
67+
default executable to use for `cargo run`.][cargo/7056]
68+
69+
Misc
70+
----
71+
72+
Compatibility Notes
73+
-------------------
74+
- [Using `...` for inclusive range patterns will now warn by default.][61342]
75+
Please transition your code to using the `..=` syntax for inclusive
76+
ranges instead.
77+
- [Using a trait object without the `dyn` will now warn by default.][61203]
78+
Please transition your code to use `dyn Trait` for trait objects instead.
79+
80+
[62228]: https://github.com/rust-lang/rust/pull/62228/
81+
[62235]: https://github.com/rust-lang/rust/pull/62235/
82+
[61802]: https://github.com/rust-lang/rust/pull/61802/
83+
[61827]: https://github.com/rust-lang/rust/pull/61827/
84+
[61547]: https://github.com/rust-lang/rust/pull/61547/
85+
[61682]: https://github.com/rust-lang/rust/pull/61682/
86+
[61268]: https://github.com/rust-lang/rust/pull/61268/
87+
[61342]: https://github.com/rust-lang/rust/pull/61342/
88+
[61347]: https://github.com/rust-lang/rust/pull/61347/
89+
[61100]: https://github.com/rust-lang/rust/pull/61100/
90+
[61203]: https://github.com/rust-lang/rust/pull/61203/
91+
[61229]: https://github.com/rust-lang/rust/pull/61229/
92+
[60932]: https://github.com/rust-lang/rust/pull/60932/
93+
[cargo/7026]: https://github.com/rust-lang/cargo/pull/7026/
94+
[cargo/7056]: https://github.com/rust-lang/cargo/pull/7056/
95+
[`BufReader::buffer`]: https://doc.rust-lang.org/std/io/struct.BufReader.html#method.buffer
96+
[`BufWriter::buffer`]: https://doc.rust-lang.org/std/io/struct.BufWriter.html#method.buffer
97+
[`Cell::from_mut`]: https://doc.rust-lang.org/std/cell/struct.Cell.html#method.from_mut
98+
[`Cell<slice>::as_slice_of_cells`]: https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_slice_of_cells
99+
[`DoubleEndedIterator::nth_back`]: https://doc.rust-lang.org/std/iter/trait.DoubleEndedIterator.html#method.nth_back
100+
[`Option::xor`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.xor
101+
[`RefCell::try_borrow_unguarded`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.try_borrow_unguarded
102+
[`Wrapping::reverse_bits`]: https://doc.rust-lang.org/std/num/struct.Wrapping.html#method.reverse_bits
103+
[`i128::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i128.html#method.reverse_bits
104+
[`i16::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i16.html#method.reverse_bits
105+
[`i32::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i32.html#method.reverse_bits
106+
[`i64::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i64.html#method.reverse_bits
107+
[`i8::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i8.html#method.reverse_bits
108+
[`isize::reverse_bits`]: https://doc.rust-lang.org/std/primitive.isize.html#method.reverse_bits
109+
[`slice::copy_within`]: https://doc.rust-lang.org/std/primitive.slice.html#method.copy_within
110+
[`u128::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u128.html#method.reverse_bits
111+
[`u16::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u16.html#method.reverse_bits
112+
[`u32::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u32.html#method.reverse_bits
113+
[`u64::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u64.html#method.reverse_bits
114+
[`u8::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u8.html#method.reverse_bits
115+
[`usize::reverse_bits`]: https://doc.rust-lang.org/std/primitive.usize.html#method.reverse_bits
116+
[rustc-book-pgo]: https://doc.rust-lang.org/rustc/profile-guided-optimization.html
117+
118+
1119
Version 1.36.0 (2019-07-04)
2120
==========================
3121

src/bootstrap/configure.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ def v(*args):
7676
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
7777
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")
7878
o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata")
79-
o("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code")
80-
o("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler")
81-
o("debuginfo-level-std", "rust.debuginfo-level-std", "debuginfo level for the standard library")
82-
o("debuginfo-level-tools", "rust.debuginfo-level-tools", "debuginfo level for the tools")
83-
o("debuginfo-level-tests", "rust.debuginfo-level-tests", "debuginfo level for the test suites run with compiletest")
79+
v("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code")
80+
v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler")
81+
v("debuginfo-level-std", "rust.debuginfo-level-std", "debuginfo level for the standard library")
82+
v("debuginfo-level-tools", "rust.debuginfo-level-tools", "debuginfo level for the tools")
83+
v("debuginfo-level-tests", "rust.debuginfo-level-tests", "debuginfo level for the test suites run with compiletest")
8484
v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file")
8585

8686
v("prefix", "install.prefix", "set installation prefix")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
5050
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
5151
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
5252
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
53-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.debuginfo-level-std=1"
53+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1"
5454

5555
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
5656
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"

src/librustc/middle/resolve_lifetime.rs

+62-33
Original file line numberDiff line numberDiff line change
@@ -2117,48 +2117,77 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21172117
// First (determined here), if `self` is by-reference, then the
21182118
// implied output region is the region of the self parameter.
21192119
if has_self {
2120-
// Look for `self: &'a Self` - also desugared from `&'a self`,
2121-
// and if that matches, use it for elision and return early.
2122-
let is_self_ty = |res: Res| {
2123-
if let Res::SelfTy(..) = res {
2124-
return true;
2125-
}
2126-
2127-
// Can't always rely on literal (or implied) `Self` due
2128-
// to the way elision rules were originally specified.
2129-
let impl_self = impl_self.map(|ty| &ty.node);
2130-
if let Some(&hir::TyKind::Path(hir::QPath::Resolved(None, ref path))) = impl_self {
2131-
match path.res {
2132-
// Whitelist the types that unambiguously always
2133-
// result in the same type constructor being used
2134-
// (it can't differ between `Self` and `self`).
2135-
Res::Def(DefKind::Struct, _)
2136-
| Res::Def(DefKind::Union, _)
2137-
| Res::Def(DefKind::Enum, _)
2138-
| Res::PrimTy(_) => {
2139-
return res == path.res
2120+
struct SelfVisitor<'a> {
2121+
map: &'a NamedRegionMap,
2122+
impl_self: Option<&'a hir::TyKind>,
2123+
lifetime: Set1<Region>,
2124+
}
2125+
2126+
impl SelfVisitor<'_> {
2127+
// Look for `self: &'a Self` - also desugared from `&'a self`,
2128+
// and if that matches, use it for elision and return early.
2129+
fn is_self_ty(&self, res: Res) -> bool {
2130+
if let Res::SelfTy(..) = res {
2131+
return true;
2132+
}
2133+
2134+
// Can't always rely on literal (or implied) `Self` due
2135+
// to the way elision rules were originally specified.
2136+
if let Some(&hir::TyKind::Path(hir::QPath::Resolved(None, ref path))) =
2137+
self.impl_self
2138+
{
2139+
match path.res {
2140+
// Whitelist the types that unambiguously always
2141+
// result in the same type constructor being used
2142+
// (it can't differ between `Self` and `self`).
2143+
Res::Def(DefKind::Struct, _)
2144+
| Res::Def(DefKind::Union, _)
2145+
| Res::Def(DefKind::Enum, _)
2146+
| Res::PrimTy(_) => {
2147+
return res == path.res
2148+
}
2149+
_ => {}
21402150
}
2141-
_ => {}
21422151
}
2152+
2153+
false
21432154
}
2155+
}
21442156

2145-
false
2146-
};
2157+
impl<'a> Visitor<'a> for SelfVisitor<'a> {
2158+
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'a> {
2159+
NestedVisitorMap::None
2160+
}
21472161

2148-
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = inputs[0].node {
2149-
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node {
2150-
if is_self_ty(path.res) {
2151-
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
2152-
let scope = Scope::Elision {
2153-
elide: Elide::Exact(lifetime),
2154-
s: self.scope,
2155-
};
2156-
self.with(scope, |_, this| this.visit_ty(output));
2157-
return;
2162+
fn visit_ty(&mut self, ty: &'a hir::Ty) {
2163+
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.node {
2164+
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node
2165+
{
2166+
if self.is_self_ty(path.res) {
2167+
if let Some(lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
2168+
self.lifetime.insert(*lifetime);
2169+
}
2170+
}
21582171
}
21592172
}
2173+
intravisit::walk_ty(self, ty)
21602174
}
21612175
}
2176+
2177+
let mut visitor = SelfVisitor {
2178+
map: self.map,
2179+
impl_self: impl_self.map(|ty| &ty.node),
2180+
lifetime: Set1::Empty,
2181+
};
2182+
visitor.visit_ty(&inputs[0]);
2183+
if let Set1::One(lifetime) = visitor.lifetime {
2184+
let scope = Scope::Elision {
2185+
elide: Elide::Exact(lifetime),
2186+
s: self.scope,
2187+
};
2188+
self.with(scope, |_, this| this.visit_ty(output));
2189+
return;
2190+
}
21622191
}
21632192

21642193
// Second, if there was exactly one lifetime (either a substitution or a

src/libsyntax/parse/parser.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -7716,14 +7716,27 @@ impl<'a> Parser<'a> {
77167716
let ret = f(self);
77177717
let last_token = if self.token_cursor.stack.len() == prev {
77187718
&mut self.token_cursor.frame.last_token
7719+
} else if self.token_cursor.stack.get(prev).is_none() {
7720+
// This can happen due to a bad interaction of two unrelated recovery mechanisms with
7721+
// mismatched delimiters *and* recovery lookahead on the likely typo `pub ident(`
7722+
// (#62881).
7723+
return Ok((ret?, TokenStream::new(vec![])));
77197724
} else {
77207725
&mut self.token_cursor.stack[prev].last_token
77217726
};
77227727

77237728
// Pull out the tokens that we've collected from the call to `f` above.
77247729
let mut collected_tokens = match *last_token {
77257730
LastToken::Collecting(ref mut v) => mem::replace(v, Vec::new()),
7726-
LastToken::Was(_) => panic!("our vector went away?"),
7731+
LastToken::Was(ref was) => {
7732+
let msg = format!("our vector went away? - found Was({:?})", was);
7733+
debug!("collect_tokens: {}", msg);
7734+
self.sess.span_diagnostic.delay_span_bug(self.token.span, &msg);
7735+
// This can happen due to a bad interaction of two unrelated recovery mechanisms
7736+
// with mismatched delimiters *and* recovery lookahead on the likely typo
7737+
// `pub ident(` (#62895, different but similar to the case above).
7738+
return Ok((ret?, TokenStream::new(vec![])));
7739+
}
77277740
};
77287741

77297742
// If we're not at EOF our current token wasn't actually consumed by

src/test/ui/parser/issue-62881.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {}
2+
3+
fn f() -> isize { fn f() -> isize {} pub f<
4+
//~^ ERROR missing `fn` or `struct` for function or struct definition
5+
//~| ERROR mismatched types
6+
//~ ERROR this file contains an un-closed delimiter

src/test/ui/parser/issue-62881.stderr

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error: this file contains an un-closed delimiter
2+
--> $DIR/issue-62881.rs:6:53
3+
|
4+
LL | fn f() -> isize { fn f() -> isize {} pub f<
5+
| - un-closed delimiter
6+
...
7+
LL |
8+
| ^
9+
10+
error: missing `fn` or `struct` for function or struct definition
11+
--> $DIR/issue-62881.rs:3:41
12+
|
13+
LL | fn f() -> isize { fn f() -> isize {} pub f<
14+
| ^
15+
16+
error[E0308]: mismatched types
17+
--> $DIR/issue-62881.rs:3:29
18+
|
19+
LL | fn f() -> isize { fn f() -> isize {} pub f<
20+
| - ^^^^^ expected isize, found ()
21+
| |
22+
| this function's body doesn't return
23+
|
24+
= note: expected type `isize`
25+
found type `()`
26+
27+
error: aborting due to 3 previous errors
28+
29+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/parser/issue-62895.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn main() {}
2+
3+
fn v() -> isize { //~ ERROR mismatched types
4+
mod _ { //~ ERROR expected identifier
5+
pub fn g() -> isizee { //~ ERROR cannot find type `isizee` in this scope
6+
mod _ { //~ ERROR expected identifier
7+
pub g() -> is //~ ERROR missing `fn` for function definition
8+
(), w20);
9+
}
10+
(), w20); //~ ERROR expected item, found `;`
11+
}

src/test/ui/parser/issue-62895.stderr

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error: expected identifier, found reserved identifier `_`
2+
--> $DIR/issue-62895.rs:4:5
3+
|
4+
LL | mod _ {
5+
| ^ expected identifier, found reserved identifier
6+
7+
error: expected identifier, found reserved identifier `_`
8+
--> $DIR/issue-62895.rs:6:5
9+
|
10+
LL | mod _ {
11+
| ^ expected identifier, found reserved identifier
12+
13+
error: missing `fn` for function definition
14+
--> $DIR/issue-62895.rs:7:4
15+
|
16+
LL | pub g() -> is
17+
| ^^^^
18+
help: add `fn` here to parse `g` as a public function
19+
|
20+
LL | pub fn g() -> is
21+
| ^^
22+
23+
error: expected item, found `;`
24+
--> $DIR/issue-62895.rs:10:9
25+
|
26+
LL | (), w20);
27+
| ^ help: remove this semicolon
28+
29+
error[E0412]: cannot find type `isizee` in this scope
30+
--> $DIR/issue-62895.rs:5:15
31+
|
32+
LL | pub fn g() -> isizee {
33+
| ^^^^^^ help: a primitive type with a similar name exists: `isize`
34+
35+
error[E0308]: mismatched types
36+
--> $DIR/issue-62895.rs:3:11
37+
|
38+
LL | fn v() -> isize {
39+
| - ^^^^^ expected isize, found ()
40+
| |
41+
| this function's body doesn't return
42+
|
43+
= note: expected type `isize`
44+
found type `()`
45+
46+
error: aborting due to 6 previous errors
47+
48+
Some errors have detailed explanations: E0308, E0412.
49+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)