Skip to content

Commit

Permalink
Auto merge of #66011 - Mark-Simulacrum:beta-backport, r=pietroalbini
Browse files Browse the repository at this point in the history
[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)
  • Loading branch information
bors committed Nov 2, 2019
2 parents f6404c5 + 710e468 commit 5242afe
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 21 deletions.
124 changes: 124 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -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::<u8>() == 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)
==========================

Expand Down
2 changes: 0 additions & 2 deletions src/ci/azure-pipelines/auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ jobs:
IMAGE: dist-x86_64-netbsd
DEPLOY: 1

asmjs:
IMAGE: asmjs
i686-gnu:
IMAGE: i686-gnu
i686-gnu-nopt:
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
27 changes: 23 additions & 4 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
) {
Expand All @@ -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)
}
}
}

Expand Down Expand Up @@ -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),
Expand Down
9 changes: 7 additions & 2 deletions src/test/ui/imports/reexports.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
28 changes: 17 additions & 11 deletions src/test/ui/imports/reexports.stderr
Original file line number Diff line number Diff line change
@@ -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`.
21 changes: 21 additions & 0 deletions src/test/ui/save-analysis/issue-65590.rs
Original file line number Diff line number Diff line change
@@ -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: Trait>() -> T::Assoc {
unimplemented!()
}

impl Struct {
async fn foo<T: Trait>(&self) -> T::Assoc {
unimplemented!()
}
}

fn main() {}

0 comments on commit 5242afe

Please sign in to comment.