Skip to content

Commit 5242afe

Browse files
committed
Auto merge of #66011 - Mark-Simulacrum:beta-backport, r=pietroalbini
[beta] backport rollup * save-analysis: Account for async desugaring in async fn return types #65936 * resolve: Turn the "non-empty glob must import something" error into a lint #65539 * Updated RELEASES.md for 1.39.0 #64878 (squashed)
2 parents f6404c5 + 710e468 commit 5242afe

File tree

7 files changed

+195
-21
lines changed

7 files changed

+195
-21
lines changed

RELEASES.md

+124
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,127 @@
1+
Version 1.39.0 (2019-11-07)
2+
===========================
3+
4+
Language
5+
--------
6+
- [You can now create `async` functions and blocks with `async fn`, `async move {}`, and
7+
`async {}` respectively, and you can now call `.await` on async expressions.][63209]
8+
- [You can now use certain attributes on function, closure, and function pointer
9+
parameters.][64010] These attributes include `cfg`, `cfg_attr`, `allow`, `warn`,
10+
`deny`, `forbid` as well as inert helper attributes used by procedural macro
11+
attributes applied to items. e.g.
12+
```rust
13+
fn len(
14+
#[cfg(windows)] slice: &[u16],
15+
#[cfg(not(windows))] slice: &[u8],
16+
) -> usize {
17+
slice.len()
18+
}
19+
```
20+
- [You can now take shared references to bind-by-move patterns in the `if` guards
21+
of `match` arms.][63118] e.g.
22+
```rust
23+
fn main() {
24+
let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]);
25+
26+
match array {
27+
nums
28+
// ---- `nums` is bound by move.
29+
if nums.iter().sum::<u8>() == 10
30+
// ^------ `.iter()` implicitly takes a reference to `nums`.
31+
=> {
32+
drop(nums);
33+
// ----------- Legal as `nums` was bound by move and so we have ownership.
34+
}
35+
_ => unreachable!(),
36+
}
37+
}
38+
```
39+
40+
41+
42+
Compiler
43+
--------
44+
- [Added tier 3\* support for the `i686-unknown-uefi` target.][64334]
45+
- [Added tier 3 support for the `sparc64-unknown-openbsd` target.][63595]
46+
- [rustc will now trim code snippets in diagnostics to fit in your terminal.][63402]
47+
**Note** Cargo currently doesn't use this feature. Refer to
48+
[cargo#7315][cargo/7315] to track this feature's progress.
49+
- [You can now pass `--show-output` argument to test binaries to print the
50+
output of successful tests.][62600]
51+
52+
53+
\* Refer to Rust's [platform support page][forge-platform-support] for more
54+
information on Rust's tiered platform support.
55+
56+
Libraries
57+
---------
58+
- [`Vec::new` and `String::new` are now `const` functions.][64028]
59+
- [`LinkedList::new` is now a `const` function.][63684]
60+
- [`str::len`, `[T]::len` and `str::as_bytes` are now `const` functions.][63770]
61+
- [The `abs`, `wrapping_abs`, and `overflowing_abs` numeric functions are
62+
now `const`.][63786]
63+
64+
Stabilized APIs
65+
---------------
66+
- [`Pin::into_inner`]
67+
- [`Instant::checked_duration_since`]
68+
- [`Instant::saturating_duration_since`]
69+
70+
Cargo
71+
-----
72+
- [You can now publish git dependencies if supplied with a `version`.][cargo/7237]
73+
- [The `--all` flag has been renamed to `--workspace`.][cargo/7241] Using
74+
`--all` is now deprecated.
75+
76+
Misc
77+
----
78+
- [You can now pass `-Clinker` to rustdoc to control the linker used
79+
for compiling doctests.][63834]
80+
81+
Compatibility Notes
82+
-------------------
83+
- [Code that was previously accepted by the old borrow checker, but rejected by
84+
the NLL borrow checker is now a hard error in Rust 2018.][63565] This was
85+
previously a warning, and will also become a hard error in the Rust 2015
86+
edition in the 1.40.0 release.
87+
- [`rustdoc` now requires `rustc` to be installed and in the same directory to
88+
run tests.][63827] This should improve performance when running a large
89+
amount of doctests.
90+
- [The `try!` macro will now issue a deprecation warning.][62672] It is
91+
recommended to use the `?` operator instead.
92+
- [`asinh(-0.0)` now correctly returns `-0.0`.][63698] Previously this
93+
returned `0.0`.
94+
95+
[62600]: https://github.com/rust-lang/rust/pull/62600/
96+
[62672]: https://github.com/rust-lang/rust/pull/62672/
97+
[63118]: https://github.com/rust-lang/rust/pull/63118/
98+
[63209]: https://github.com/rust-lang/rust/pull/63209/
99+
[63402]: https://github.com/rust-lang/rust/pull/63402/
100+
[63565]: https://github.com/rust-lang/rust/pull/63565/
101+
[63595]: https://github.com/rust-lang/rust/pull/63595/
102+
[63684]: https://github.com/rust-lang/rust/pull/63684/
103+
[63698]: https://github.com/rust-lang/rust/pull/63698/
104+
[63770]: https://github.com/rust-lang/rust/pull/63770/
105+
[63786]: https://github.com/rust-lang/rust/pull/63786/
106+
[63827]: https://github.com/rust-lang/rust/pull/63827/
107+
[63834]: https://github.com/rust-lang/rust/pull/63834/
108+
[63927]: https://github.com/rust-lang/rust/pull/63927/
109+
[63933]: https://github.com/rust-lang/rust/pull/63933/
110+
[63934]: https://github.com/rust-lang/rust/pull/63934/
111+
[63938]: https://github.com/rust-lang/rust/pull/63938/
112+
[63940]: https://github.com/rust-lang/rust/pull/63940/
113+
[63941]: https://github.com/rust-lang/rust/pull/63941/
114+
[63945]: https://github.com/rust-lang/rust/pull/63945/
115+
[64010]: https://github.com/rust-lang/rust/pull/64010/
116+
[64028]: https://github.com/rust-lang/rust/pull/64028/
117+
[64334]: https://github.com/rust-lang/rust/pull/64334/
118+
[cargo/7237]: https://github.com/rust-lang/cargo/pull/7237/
119+
[cargo/7241]: https://github.com/rust-lang/cargo/pull/7241/
120+
[cargo/7315]: https://github.com/rust-lang/cargo/pull/7315/
121+
[`Pin::into_inner`]: https://doc.rust-lang.org/std/pin/struct.Pin.html#method.into_inner
122+
[`Instant::checked_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.checked_duration_since
123+
[`Instant::saturating_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.saturating_duration_since
124+
1125
Version 1.38.0 (2019-09-26)
2126
==========================
3127

src/ci/azure-pipelines/auto.yml

-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ jobs:
124124
IMAGE: dist-x86_64-netbsd
125125
DEPLOY: 1
126126

127-
asmjs:
128-
IMAGE: asmjs
129127
i686-gnu:
130128
IMAGE: i686-gnu
131129
i686-gnu-nopt:

src/librustc_resolve/resolve_imports.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
972972
if !is_prelude &&
973973
max_vis.get() != ty::Visibility::Invisible && // Allow empty globs.
974974
!max_vis.get().is_at_least(directive.vis.get(), &*self) {
975-
let msg = "A non-empty glob must import something with the glob's visibility";
976-
self.r.session.span_err(directive.span, msg);
975+
let msg =
976+
"glob import doesn't reexport anything because no candidate is public enough";
977+
self.r.session.buffer_lint(UNUSED_IMPORTS, directive.id, directive.span, msg);
977978
}
978979
return None;
979980
}

src/librustc_save_analysis/dump_visitor.rs

+23-4
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
300300
}
301301

302302
if let ast::FunctionRetTy::Ty(ref ret_ty) = sig.decl.output {
303-
v.visit_ty(ret_ty);
303+
// In async functions, return types are desugared and redefined
304+
// as an `impl Trait` existential type. Because of this, to match
305+
// the definition paths when resolving nested types we need to
306+
// start walking from the newly-created definition.
307+
match sig.header.asyncness.node {
308+
ast::IsAsync::Async { return_impl_trait_id, .. } => {
309+
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
310+
}
311+
_ => v.visit_ty(ret_ty)
312+
}
304313
}
305314

306315
// walk the fn body
@@ -369,6 +378,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
369378
&mut self,
370379
item: &'l ast::Item,
371380
decl: &'l ast::FnDecl,
381+
header: &'l ast::FnHeader,
372382
ty_params: &'l ast::Generics,
373383
body: &'l ast::Block,
374384
) {
@@ -391,7 +401,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
391401
// FIXME: Opaque type desugaring prevents us from easily
392402
// processing trait bounds. See `visit_ty` for more details.
393403
} else {
394-
v.visit_ty(&ret_ty);
404+
// In async functions, return types are desugared and redefined
405+
// as an `impl Trait` existential type. Because of this, to match
406+
// the definition paths when resolving nested types we need to
407+
// start walking from the newly-created definition.
408+
match header.asyncness.node {
409+
ast::IsAsync::Async { return_impl_trait_id, .. } => {
410+
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
411+
}
412+
_ => v.visit_ty(ret_ty)
413+
}
395414
}
396415
}
397416

@@ -1315,8 +1334,8 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
13151334
);
13161335
}
13171336
}
1318-
Fn(ref decl, .., ref ty_params, ref body) => {
1319-
self.process_fn(item, &decl, ty_params, &body)
1337+
Fn(ref decl, ref header, ref ty_params, ref body) => {
1338+
self.process_fn(item, &decl, &header, ty_params, &body)
13201339
}
13211340
Static(ref typ, _, ref expr) => self.process_static_or_const_item(item, typ, expr),
13221341
Const(ref typ, ref expr) => self.process_static_or_const_item(item, &typ, &expr),

src/test/ui/imports/reexports.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
#![warn(unused_imports)]
2+
13
mod a {
24
fn foo() {}
35
mod foo {}
46

57
mod a {
68
pub use super::foo; //~ ERROR cannot be re-exported
7-
pub use super::*; //~ ERROR must import something with the glob's visibility
9+
pub use super::*;
10+
//~^ WARNING glob import doesn't reexport anything because no candidate is public enough
811
}
912
}
1013

1114
mod b {
1215
pub fn foo() {}
13-
mod foo { pub struct S; }
16+
mod foo {
17+
pub struct S;
18+
}
1419

1520
pub mod a {
1621
pub use super::foo; // This is OK since the value `foo` is visible enough.

src/test/ui/imports/reexports.stderr

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
error[E0364]: `foo` is private, and cannot be re-exported
2-
--> $DIR/reexports.rs:6:17
2+
--> $DIR/reexports.rs:8:17
33
|
44
LL | pub use super::foo;
55
| ^^^^^^^^^^
66
|
77
note: consider marking `foo` as `pub` in the imported module
8-
--> $DIR/reexports.rs:6:17
8+
--> $DIR/reexports.rs:8:17
99
|
1010
LL | pub use super::foo;
1111
| ^^^^^^^^^^
1212

13-
error: A non-empty glob must import something with the glob's visibility
14-
--> $DIR/reexports.rs:7:17
15-
|
16-
LL | pub use super::*;
17-
| ^^^^^^^^
18-
1913
error[E0603]: module `foo` is private
20-
--> $DIR/reexports.rs:28:15
14+
--> $DIR/reexports.rs:33:15
2115
|
2216
LL | use b::a::foo::S;
2317
| ^^^
2418

2519
error[E0603]: module `foo` is private
26-
--> $DIR/reexports.rs:29:15
20+
--> $DIR/reexports.rs:34:15
2721
|
2822
LL | use b::b::foo::S as T;
2923
| ^^^
3024

31-
error: aborting due to 4 previous errors
25+
warning: glob import doesn't reexport anything because no candidate is public enough
26+
--> $DIR/reexports.rs:9:17
27+
|
28+
LL | pub use super::*;
29+
| ^^^^^^^^
30+
|
31+
note: lint level defined here
32+
--> $DIR/reexports.rs:1:9
33+
|
34+
LL | #![warn(unused_imports)]
35+
| ^^^^^^^^^^^^^^
36+
37+
error: aborting due to 3 previous errors
3238

3339
Some errors have detailed explanations: E0364, E0603.
3440
For more information about an error, try `rustc --explain E0364`.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-pass
2+
// compile-flags: -Zsave-analysis
3+
// edition:2018
4+
5+
// Async desugaring for return types in (associated) functions introduces a
6+
// separate definition internally, which we need to take into account
7+
// (or else we ICE).
8+
trait Trait { type Assoc; }
9+
struct Struct;
10+
11+
async fn foobar<T: Trait>() -> T::Assoc {
12+
unimplemented!()
13+
}
14+
15+
impl Struct {
16+
async fn foo<T: Trait>(&self) -> T::Assoc {
17+
unimplemented!()
18+
}
19+
}
20+
21+
fn main() {}

0 commit comments

Comments
 (0)