Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] another round of backports for 1.42 #69748

Merged
merged 8 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.24"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9975aefa63997ef75ca9cf013ff1bb81487aaa0b622c21053afd3b92979a7af"
checksum = "438ac08ddc5efe81452f984a9e33ba425b00b31d1f48e6acd9e2210aa28cc52e"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down
98 changes: 98 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,100 @@
Version 1.42.0 (2020-03-12)
==========================

Language
--------
- [You can now use the slice pattern syntax with subslices.][67712] e.g.
```rust
fn foo(words: &[&str]) {
match words {
["Hello", "World", "!", ..] => println!("Hello World!"),
["Foo", "Bar", ..] => println!("Baz"),
rest => println!("{:?}", rest),
}
}
```
- [You can now use `#[repr(transparent)]` on univariant `enum`s.][68122] Meaning
that you can create an enum that has the exact layout and ABI of the type
it contains.
- [There are some *syntax-only* changes:][67131]
- `default` is syntactically allowed before items in `trait` definitions.
- Items in `impl`s (i.e. `const`s, `type`s, and `fn`s) may syntactically
leave out their bodies in favor of `;`.
- Bounds on associated types in `impl`s are now syntactically allowed
(e.g. `type Foo: Ord;`).
- `...` (the C-variadic type) may occur syntactically directly as the type of
any function parameter.

These are still rejected *semantically*, so you will likely receive an error
but these changes can be seen and parsed by procedural macros and
conditional compilation.

Compiler
--------
- [Added tier 2\* support for `armv7a-none-eabi`.][68253]
- [Added tier 2 support for `riscv64gc-unknown-linux-gnu`.][68339]
- [`Option::{expect,unwrap}` and
`Result::{expect, expect_err, unwrap, unwrap_err}` now produce panic messages
pointing to the location where they were called, rather than
`core`'s internals. ][67887]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.

Libraries
---------
- [`iter::Empty<T>` now implements `Send` and `Sync` for any `T`.][68348]
- [`Pin::{map_unchecked, map_unchecked_mut}` no longer require the return type
to implement `Sized`.][67935]
- [`io::Cursor` now derives `PartialEq` and `Eq`.][67233]
- [`Layout::new` is now `const`.][66254]
- [Added Standard Library support for `riscv64gc-unknown-linux-gnu`.][66899]


Stabilized APIs
---------------
- [`CondVar::wait_while`]
- [`CondVar::wait_timeout_while`]
- [`DebugMap::key`]
- [`DebugMap::value`]
- [`ManuallyDrop::take`]
- [`matches!`]
- [`ptr::slice_from_raw_parts_mut`]
- [`ptr::slice_from_raw_parts`]

Cargo
-----
- [You no longer need to include `extern crate proc_macro;` to be able to
`use proc_macro;` in the `2018` edition.][cargo/7700]

Compatibility Notes
-------------------
- [`Error::description` has been deprecated, and its use will now produce a
warning.][66919] It's recommended to use `Display`/`to_string` instead.

[68253]: https://github.com/rust-lang/rust/pull/68253/
[68348]: https://github.com/rust-lang/rust/pull/68348/
[67935]: https://github.com/rust-lang/rust/pull/67935/
[68339]: https://github.com/rust-lang/rust/pull/68339/
[68122]: https://github.com/rust-lang/rust/pull/68122/
[67712]: https://github.com/rust-lang/rust/pull/67712/
[67887]: https://github.com/rust-lang/rust/pull/67887/
[67131]: https://github.com/rust-lang/rust/pull/67131/
[67233]: https://github.com/rust-lang/rust/pull/67233/
[66899]: https://github.com/rust-lang/rust/pull/66899/
[66919]: https://github.com/rust-lang/rust/pull/66919/
[66254]: https://github.com/rust-lang/rust/pull/66254/
[cargo/7700]: https://github.com/rust-lang/cargo/pull/7700
[`DebugMap::key`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.key
[`DebugMap::value`]: https://doc.rust-lang.org/stable/std/fmt/struct.DebugMap.html#method.value
[`ManuallyDrop::take`]: https://doc.rust-lang.org/stable/std/mem/struct.ManuallyDrop.html#method.take
[`matches!`]: https://doc.rust-lang.org/stable/std/macro.matches.html
[`ptr::slice_from_raw_parts_mut`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts_mut.html
[`ptr::slice_from_raw_parts`]: https://doc.rust-lang.org/stable/std/ptr/fn.slice_from_raw_parts.html
[`CondVar::wait_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_while
[`CondVar::wait_timeout_while`]: https://doc.rust-lang.org/stable/std/sync/struct.Condvar.html#method.wait_timeout_while


Version 1.41.1 (2020-02-27)
===========================

Expand All @@ -8,6 +105,7 @@ Version 1.41.1 (2020-02-27)
[69225]: https://github.com/rust-lang/rust/issues/69225
[69145]: https://github.com/rust-lang/rust/pull/69145


Version 1.41.0 (2020-01-30)
===========================

Expand Down
11 changes: 5 additions & 6 deletions src/librustc_errors/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,11 @@ impl<'a> DiagnosticBuilder<'a> {

let handler = self.0.handler;

// We need to use `ptr::read` because `DiagnosticBuilder` implements `Drop`.
let diagnostic;
unsafe {
diagnostic = std::ptr::read(&self.0.diagnostic);
std::mem::forget(self);
};
// We must use `Level::Cancelled` for `dummy` to avoid an ICE about an
// unused diagnostic.
let dummy = Diagnostic::new(Level::Cancelled, "");
let diagnostic = std::mem::replace(&mut self.0.diagnostic, dummy);

// Logging here is useful to help track down where in logs an error was
// actually emitted.
debug!("buffer: diagnostic={:?}", diagnostic);
Expand Down
18 changes: 4 additions & 14 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,12 @@ impl Handler {
}

/// Stash a given diagnostic with the given `Span` and `StashKey` as the key for later stealing.
/// If the diagnostic with this `(span, key)` already exists, this will result in an ICE.
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
let mut inner = self.inner.borrow_mut();
if let Some(mut old_diag) = inner.stashed_diagnostics.insert((span, key), diag) {
// We are removing a previously stashed diagnostic which should not happen.
old_diag.level = Bug;
old_diag.note(&format!(
"{}:{}: already existing stashed diagnostic with (span = {:?}, key = {:?})",
file!(),
line!(),
span,
key
));
inner.emit_diag_at_span(old_diag, span);
panic!(ExplicitBug);
}
// FIXME(Centril, #69537): Consider reintroducing panic on overwriting a stashed diagnostic
// if/when we have a more robust macro-friendly replacement for `(span, key)` as a key.
// See the PR for a discussion.
inner.stashed_diagnostics.insert((span, key), diag);
}

/// Steal a previously stashed diagnostic with the given `Span` and `StashKey` as the key.
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty_span: Span,
) {
if variant.recovered {
self.set_tainted_by_errors();
return;
}
let mut err = self.type_error_struct_with_diag(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
}

fn ty_infer(&self, _: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> {
self.tcx().sess.delay_span_bug(span, "bad placeholder type");
placeholder_type_error(self.tcx(), span, &[], vec![span], false);
self.tcx().types.err
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Regression test for issue #68794
#
# Verify that no text relocations are accidentally introduced by linking a
# minimal rust staticlib.
#
# The test links a rust static library into a shared library, and checks that
# the linker doesn't have to flag the resulting file as containing TEXTRELs.

-include ../tools.mk

# only-linux

all:
$(RUSTC) foo.rs
$(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \
$(EXTRACFLAGS) $(EXTRACXXFLAGS)
readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void foo();

int main() {
foo();
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![crate_type = "staticlib"]

#[no_mangle]
pub extern "C" fn foo(x: u32) {
// using the println! makes it so that enough code from the standard
// library is included (see issue #68794)
println!("foo: {}", x);
}
1 change: 1 addition & 0 deletions src/test/ui/did_you_mean/bad-assoc-ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type D = (u8, u8)::AssocTy;
type E = _::AssocTy;
//~^ ERROR missing angle brackets in associated item path
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
//~| ERROR the type placeholder `_` is not allowed within types on item signatures

type F = &'static (u8)::AssocTy;
//~^ ERROR missing angle brackets in associated item path
Expand Down
26 changes: 16 additions & 10 deletions src/test/ui/did_you_mean/bad-assoc-ty.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ LL | type E = _::AssocTy;
| ^^^^^^^^^^ help: try: `<_>::AssocTy`

error: missing angle brackets in associated item path
--> $DIR/bad-assoc-ty.rs:21:19
--> $DIR/bad-assoc-ty.rs:22:19
|
LL | type F = &'static (u8)::AssocTy;
| ^^^^^^^^^^^^^ help: try: `<(u8)>::AssocTy`

error: missing angle brackets in associated item path
--> $DIR/bad-assoc-ty.rs:27:10
--> $DIR/bad-assoc-ty.rs:28:10
|
LL | type G = dyn 'static + (Send)::AssocTy;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<dyn 'static + (Send)>::AssocTy`

error: missing angle brackets in associated item path
--> $DIR/bad-assoc-ty.rs:44:10
--> $DIR/bad-assoc-ty.rs:45:10
|
LL | type I = ty!()::AssocTy;
| ^^^^^^^^^^^^^^ help: try: `<ty!()>::AssocTy`

error: missing angle brackets in associated item path
--> $DIR/bad-assoc-ty.rs:37:19
--> $DIR/bad-assoc-ty.rs:38:19
|
LL | ($ty: ty) => ($ty::AssocTy);
| ^^^^^^^^^^^^ help: try: `<$ty>::AssocTy`
Expand Down Expand Up @@ -85,26 +85,32 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa
LL | type E = _::AssocTy;
| ^ not allowed in type signatures

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/bad-assoc-ty.rs:17:10
|
LL | type E = _::AssocTy;
| ^ not allowed in type signatures

error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:21:19
--> $DIR/bad-assoc-ty.rs:22:19
|
LL | type F = &'static (u8)::AssocTy;
| ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`

error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:27:10
--> $DIR/bad-assoc-ty.rs:28:10
|
LL | type G = dyn 'static + (Send)::AssocTy;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy`

error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:33:10
--> $DIR/bad-assoc-ty.rs:34:10
|
LL | type H = Fn(u8) -> (u8)::Output;
| ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output`

error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:37:19
--> $DIR/bad-assoc-ty.rs:38:19
|
LL | ($ty: ty) => ($ty::AssocTy);
| ^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`
Expand All @@ -113,12 +119,12 @@ LL | type J = ty!(u8);
| ------- in this macro invocation

error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:44:10
--> $DIR/bad-assoc-ty.rs:45:10
|
LL | type I = ty!()::AssocTy;
| ^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`

error: aborting due to 19 previous errors
error: aborting due to 20 previous errors

Some errors have detailed explanations: E0121, E0223.
For more information about an error, try `rustc --explain E0121`.
17 changes: 17 additions & 0 deletions src/test/ui/issues/issue-69396-const-no-type-in-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
macro_rules! suite {
( $( $fn:ident; )* ) => {
$(
const A = "A".$fn();
//~^ ERROR the name `A` is defined multiple times
//~| ERROR missing type for `const` item
//~| ERROR the type placeholder `_` is not allowed within types
)*
}
}

suite! {
len;
is_empty;
}

fn main() {}
48 changes: 48 additions & 0 deletions src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
error[E0428]: the name `A` is defined multiple times
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:13
|
LL | const A = "A".$fn();
| ^^^^^^^^^^^^^^^^^^^^
| |
| `A` redefined here
| previous definition of the value `A` here
...
LL | / suite! {
LL | | len;
LL | | is_empty;
LL | | }
| |_- in this macro invocation
|
= note: `A` must be defined only once in the value namespace of this module

error: missing type for `const` item
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:19
|
LL | const A = "A".$fn();
| ^ help: provide a type for the item: `A: usize`
...
LL | / suite! {
LL | | len;
LL | | is_empty;
LL | | }
| |_- in this macro invocation

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/issue-69396-const-no-type-in-macro.rs:4:19
|
LL | const A = "A".$fn();
| ^
| |
| not allowed in type signatures
| help: replace `_` with the correct type: `bool`
...
LL | / suite! {
LL | | len;
LL | | is_empty;
LL | | }
| |_- in this macro invocation

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0121, E0428.
For more information about an error, try `rustc --explain E0121`.
2 changes: 2 additions & 0 deletions src/test/ui/self/self-infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ struct S;

impl S {
fn f(self: _) {} //~ERROR the type placeholder `_` is not allowed within types on item sig
//~^ ERROR the type placeholder `_` is not allowed within types on item sig
fn g(self: &_) {} //~ERROR the type placeholder `_` is not allowed within types on item sig
//~^ ERROR the type placeholder `_` is not allowed within types on item sig
}

fn main() {}
Loading