From 43ceeb220455e1e41f05ebfd4d7763e07ab53ac0 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 29 Oct 2019 16:19:16 +0100 Subject: [PATCH 1/4] save-analysis: Account for async desugaring in async fn return types --- src/librustc_save_analysis/dump_visitor.rs | 27 ++++++++++++++++++---- src/test/ui/save-analysis/issue-65590.rs | 21 +++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/save-analysis/issue-65590.rs diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 71d1f6b118301..584523b5146c2 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -300,7 +300,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { } if let ast::FunctionRetTy::Ty(ref ret_ty) = sig.decl.output { - v.visit_ty(ret_ty); + // In async functions, return types are desugared and redefined + // as an `impl Trait` existential type. Because of this, to match + // the definition paths when resolving nested types we need to + // start walking from the newly-created definition. + match sig.header.asyncness.node { + ast::IsAsync::Async { return_impl_trait_id, .. } => { + v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty)) + } + _ => v.visit_ty(ret_ty) + } } // walk the fn body @@ -369,6 +378,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { &mut self, item: &'l ast::Item, decl: &'l ast::FnDecl, + header: &'l ast::FnHeader, ty_params: &'l ast::Generics, body: &'l ast::Block, ) { @@ -391,7 +401,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { // FIXME: Opaque type desugaring prevents us from easily // processing trait bounds. See `visit_ty` for more details. } else { - v.visit_ty(&ret_ty); + // In async functions, return types are desugared and redefined + // as an `impl Trait` existential type. Because of this, to match + // the definition paths when resolving nested types we need to + // start walking from the newly-created definition. + match header.asyncness.node { + ast::IsAsync::Async { return_impl_trait_id, .. } => { + v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty)) + } + _ => v.visit_ty(ret_ty) + } } } @@ -1315,8 +1334,8 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { ); } } - Fn(ref decl, .., ref ty_params, ref body) => { - self.process_fn(item, &decl, ty_params, &body) + Fn(ref decl, ref header, ref ty_params, ref body) => { + self.process_fn(item, &decl, &header, ty_params, &body) } Static(ref typ, _, ref expr) => self.process_static_or_const_item(item, typ, expr), Const(ref typ, ref expr) => self.process_static_or_const_item(item, &typ, &expr), diff --git a/src/test/ui/save-analysis/issue-65590.rs b/src/test/ui/save-analysis/issue-65590.rs new file mode 100644 index 0000000000000..27874f8655e56 --- /dev/null +++ b/src/test/ui/save-analysis/issue-65590.rs @@ -0,0 +1,21 @@ +// check-pass +// compile-flags: -Zsave-analysis +// edition:2018 + +// Async desugaring for return types in (associated) functions introduces a +// separate definition internally, which we need to take into account +// (or else we ICE). +trait Trait { type Assoc; } +struct Struct; + +async fn foobar() -> T::Assoc { + unimplemented!() +} + +impl Struct { + async fn foo(&self) -> T::Assoc { + unimplemented!() + } +} + +fn main() {} From a541c36481192e5df9904c18195a3ee936c21626 Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Mon, 28 Oct 2019 00:57:25 +0100 Subject: [PATCH 2/4] changing non-empty glob must import something to a lint --- src/librustc_resolve/resolve_imports.rs | 5 +++-- src/test/ui/imports/reexports.rs | 9 ++++++-- src/test/ui/imports/reexports.stderr | 28 +++++++++++++++---------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 360343169bc3d..c387adebbf7f1 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -972,8 +972,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> { if !is_prelude && max_vis.get() != ty::Visibility::Invisible && // Allow empty globs. !max_vis.get().is_at_least(directive.vis.get(), &*self) { - let msg = "A non-empty glob must import something with the glob's visibility"; - self.r.session.span_err(directive.span, msg); + let msg = + "glob import doesn't reexport anything because no candidate is public enough"; + self.r.session.buffer_lint(UNUSED_IMPORTS, directive.id, directive.span, msg); } return None; } diff --git a/src/test/ui/imports/reexports.rs b/src/test/ui/imports/reexports.rs index b0a591b08ac89..d76cc41be4e55 100644 --- a/src/test/ui/imports/reexports.rs +++ b/src/test/ui/imports/reexports.rs @@ -1,16 +1,21 @@ +#![warn(unused_imports)] + mod a { fn foo() {} mod foo {} mod a { pub use super::foo; //~ ERROR cannot be re-exported - pub use super::*; //~ ERROR must import something with the glob's visibility + pub use super::*; + //~^ WARNING glob import doesn't reexport anything because no candidate is public enough } } mod b { pub fn foo() {} - mod foo { pub struct S; } + mod foo { + pub struct S; + } pub mod a { pub use super::foo; // This is OK since the value `foo` is visible enough. diff --git a/src/test/ui/imports/reexports.stderr b/src/test/ui/imports/reexports.stderr index af2c97e77b9d7..4388e2c276b8e 100644 --- a/src/test/ui/imports/reexports.stderr +++ b/src/test/ui/imports/reexports.stderr @@ -1,34 +1,40 @@ error[E0364]: `foo` is private, and cannot be re-exported - --> $DIR/reexports.rs:6:17 + --> $DIR/reexports.rs:8:17 | LL | pub use super::foo; | ^^^^^^^^^^ | note: consider marking `foo` as `pub` in the imported module - --> $DIR/reexports.rs:6:17 + --> $DIR/reexports.rs:8:17 | LL | pub use super::foo; | ^^^^^^^^^^ -error: A non-empty glob must import something with the glob's visibility - --> $DIR/reexports.rs:7:17 - | -LL | pub use super::*; - | ^^^^^^^^ - error[E0603]: module `foo` is private - --> $DIR/reexports.rs:28:15 + --> $DIR/reexports.rs:33:15 | LL | use b::a::foo::S; | ^^^ error[E0603]: module `foo` is private - --> $DIR/reexports.rs:29:15 + --> $DIR/reexports.rs:34:15 | LL | use b::b::foo::S as T; | ^^^ -error: aborting due to 4 previous errors +warning: glob import doesn't reexport anything because no candidate is public enough + --> $DIR/reexports.rs:9:17 + | +LL | pub use super::*; + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/reexports.rs:1:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors Some errors have detailed explanations: E0364, E0603. For more information about an error, try `rustc --explain E0364`. From 559ebafa24e1c696a9b35663a2e75db0aadca715 Mon Sep 17 00:00:00 2001 From: Erin Power Date: Sat, 28 Sep 2019 20:10:39 +0200 Subject: [PATCH 3/4] Updated RELEASES.md for 1.39.0 --- RELEASES.md | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index e6512bb6f6de9..6daf7a13b6bdc 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,127 @@ +Version 1.39.0 (2019-11-07) +=========================== + +Language +-------- +- [You can now create `async` functions and blocks with `async fn`, `async move {}`, and + `async {}` respectively, and you can now call `.await` on async expressions.][63209] +- [You can now use certain attributes on function, closure, and function pointer + parameters.][64010] These attributes include `cfg`, `cfg_attr`, `allow`, `warn`, + `deny`, `forbid` as well as inert helper attributes used by procedural macro + attributes applied to items. e.g. + ```rust + fn len( + #[cfg(windows)] slice: &[u16], + #[cfg(not(windows))] slice: &[u8], + ) -> usize { + slice.len() + } + ``` +- [You can now take shared references to bind-by-move patterns in the `if` guards + of `match` arms.][63118] e.g. + ```rust + fn main() { + let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]); + + match array { + nums + // ---- `nums` is bound by move. + if nums.iter().sum::() == 10 + // ^------ `.iter()` implicitly takes a reference to `nums`. + => { + drop(nums); + // ----------- Legal as `nums` was bound by move and so we have ownership. + } + _ => unreachable!(), + } + } + ``` + + + +Compiler +-------- +- [Added tier 3\* support for the `i686-unknown-uefi` target.][64334] +- [Added tier 3 support for the `sparc64-unknown-openbsd` target.][63595] +- [rustc will now trim code snippets in diagnostics to fit in your terminal.][63402] + **Note** Cargo currently doesn't use this feature. Refer to + [cargo#7315][cargo/7315] to track this feature's progress. +- [You can now pass `--show-output` argument to test binaries to print the + output of successful tests.][62600] + + +\* Refer to Rust's [platform support page][forge-platform-support] for more +information on Rust's tiered platform support. + +Libraries +--------- +- [`Vec::new` and `String::new` are now `const` functions.][64028] +- [`LinkedList::new` is now a `const` function.][63684] +- [`str::len`, `[T]::len` and `str::as_bytes` are now `const` functions.][63770] +- [The `abs`, `wrapping_abs`, and `overflowing_abs` numeric functions are + now `const`.][63786] + +Stabilized APIs +--------------- +- [`Pin::into_inner`] +- [`Instant::checked_duration_since`] +- [`Instant::saturating_duration_since`] + +Cargo +----- +- [You can now publish git dependencies if supplied with a `version`.][cargo/7237] +- [The `--all` flag has been renamed to `--workspace`.][cargo/7241] Using + `--all` is now deprecated. + +Misc +---- +- [You can now pass `-Clinker` to rustdoc to control the linker used + for compiling doctests.][63834] + +Compatibility Notes +------------------- +- [Code that was previously accepted by the old borrow checker, but rejected by + the NLL borrow checker is now a hard error in Rust 2018.][63565] This was + previously a warning, and will also become a hard error in the Rust 2015 + edition in the 1.40.0 release. +- [`rustdoc` now requires `rustc` to be installed and in the same directory to + run tests.][63827] This should improve performance when running a large + amount of doctests. +- [The `try!` macro will now issue a deprecation warning.][62672] It is + recommended to use the `?` operator instead. +- [`asinh(-0.0)` now correctly returns `-0.0`.][63698] Previously this + returned `0.0`. + +[62600]: https://github.com/rust-lang/rust/pull/62600/ +[62672]: https://github.com/rust-lang/rust/pull/62672/ +[63118]: https://github.com/rust-lang/rust/pull/63118/ +[63209]: https://github.com/rust-lang/rust/pull/63209/ +[63402]: https://github.com/rust-lang/rust/pull/63402/ +[63565]: https://github.com/rust-lang/rust/pull/63565/ +[63595]: https://github.com/rust-lang/rust/pull/63595/ +[63684]: https://github.com/rust-lang/rust/pull/63684/ +[63698]: https://github.com/rust-lang/rust/pull/63698/ +[63770]: https://github.com/rust-lang/rust/pull/63770/ +[63786]: https://github.com/rust-lang/rust/pull/63786/ +[63827]: https://github.com/rust-lang/rust/pull/63827/ +[63834]: https://github.com/rust-lang/rust/pull/63834/ +[63927]: https://github.com/rust-lang/rust/pull/63927/ +[63933]: https://github.com/rust-lang/rust/pull/63933/ +[63934]: https://github.com/rust-lang/rust/pull/63934/ +[63938]: https://github.com/rust-lang/rust/pull/63938/ +[63940]: https://github.com/rust-lang/rust/pull/63940/ +[63941]: https://github.com/rust-lang/rust/pull/63941/ +[63945]: https://github.com/rust-lang/rust/pull/63945/ +[64010]: https://github.com/rust-lang/rust/pull/64010/ +[64028]: https://github.com/rust-lang/rust/pull/64028/ +[64334]: https://github.com/rust-lang/rust/pull/64334/ +[cargo/7237]: https://github.com/rust-lang/cargo/pull/7237/ +[cargo/7241]: https://github.com/rust-lang/cargo/pull/7241/ +[cargo/7315]: https://github.com/rust-lang/cargo/pull/7315/ +[`Pin::into_inner`]: https://doc.rust-lang.org/std/pin/struct.Pin.html#method.into_inner +[`Instant::checked_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.checked_duration_since +[`Instant::saturating_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.saturating_duration_since + Version 1.38.0 (2019-09-26) ========================== From 710e468c0da3e7fbaeb05bf7ecf653c59537d3c8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 1 Nov 2019 22:00:34 -0400 Subject: [PATCH 4/4] This disables the asmjs builder for beta This builder is just a test builder, so the artifacts we produce should be unaffected. Unfortunately, the mozilla-games S3 bucket appears to have gone offline or at least is giving us forbidden errors, so the asmjs builder isn't able to build anymore. --- src/ci/azure-pipelines/auto.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ci/azure-pipelines/auto.yml b/src/ci/azure-pipelines/auto.yml index 5f7761297095c..e81b7ef5986e6 100644 --- a/src/ci/azure-pipelines/auto.yml +++ b/src/ci/azure-pipelines/auto.yml @@ -124,8 +124,6 @@ jobs: IMAGE: dist-x86_64-netbsd DEPLOY: 1 - asmjs: - IMAGE: asmjs i686-gnu: IMAGE: i686-gnu i686-gnu-nopt: