Skip to content

Commit

Permalink
Auto merge of rust-lang#72905 - JohnTitor:rollup-phtyo5i, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - rust-lang#72775 (Return early to avoid ICE)
 - rust-lang#72795 (Add a test for `$:ident` in proc macro input)
 - rust-lang#72822 (remove trivial calls to mk_const)
 - rust-lang#72825 (Clarify errors and warnings about the transition to the new asm!)
 - rust-lang#72827 (changed *nix to Unix-like)
 - rust-lang#72880 (Clean up E0637 explanation)
 - rust-lang#72886 (Remove allow missing_debug_implementations for MaybeUninit)
 - rust-lang#72889 (rustc: Remove the `--passive-segments` LLD flag on wasm)
 - rust-lang#72891 (Add associated consts MIN/MAX for Wrapping<Int>)
 - rust-lang#72893 (test miri-unleash TLS accesses)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jun 2, 2020
2 parents ad4bc33 + b7ec7bd commit 10c2316
Show file tree
Hide file tree
Showing 32 changed files with 238 additions and 87 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ or reading the [rustc dev guide][rustcguidebuild].

[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html

### Building on *nix
### Building on Unix-like system
1. Make sure you have installed the dependencies:

* `g++` 5.1 or later or `clang++` 3.5 or later
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ pub(crate) mod builtin {
#[unstable(
feature = "llvm_asm",
issue = "70173",
reason = "LLVM-style inline assembly will never be stabilized, prefer using asm! instead"
reason = "prefer using the new asm! syntax instead"
)]
#[rustc_builtin_macro]
#[macro_export]
Expand Down
1 change: 0 additions & 1 deletion src/libcore/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ use crate::mem::ManuallyDrop;
/// remain `#[repr(transparent)]`. That said, `MaybeUninit<T>` will *always* guarantee that it has
/// the same size, alignment, and ABI as `T`; it's just that the way `MaybeUninit` implements that
/// guarantee may evolve.
#[allow(missing_debug_implementations)]
#[stable(feature = "maybe_uninit", since = "1.36.0")]
// Lang item so we can wrap other types in it. This is useful for generators.
#[lang = "maybe_uninit"]
Expand Down
16 changes: 4 additions & 12 deletions src/libcore/num/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,10 @@ Basic usage:
#![feature(wrapping_int_impl)]
use std::num::Wrapping;
assert_eq!(<Wrapping<", stringify!($t), ">>::min_value(), ",
"Wrapping(", stringify!($t), "::min_value()));
assert_eq!(<Wrapping<", stringify!($t), ">>::MIN, Wrapping(", stringify!($t), "::MIN));
```"),
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[inline]
pub const fn min_value() -> Self {
Wrapping(<$t>::min_value())
}
pub const MIN: Self = Self(<$t>::MIN);
}

doc_comment! {
Expand All @@ -358,14 +354,10 @@ Basic usage:
#![feature(wrapping_int_impl)]
use std::num::Wrapping;
assert_eq!(<Wrapping<", stringify!($t), ">>::max_value(), ",
"Wrapping(", stringify!($t), "::max_value()));
assert_eq!(<Wrapping<", stringify!($t), ">>::MAX, Wrapping(", stringify!($t), "::MAX));
```"),
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[inline]
pub const fn max_value() -> Self {
Wrapping(<$t>::max_value())
}
pub const MAX: Self = Self(<$t>::MAX);
}

doc_comment! {
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_builtin_macros/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ fn parse_args<'a>(

// Detect use of the legacy llvm_asm! syntax (which used to be called asm!)
if p.look_ahead(1, |t| *t == token::Colon || *t == token::ModSep) {
let mut err = ecx.struct_span_err(sp, "legacy asm! syntax is no longer supported");
let mut err =
ecx.struct_span_err(sp, "the legacy LLVM-style asm! syntax is no longer supported");
err.note("consider migrating to the new asm! syntax specified in RFC 2873");
err.note("alternatively, switch to llvm_asm! to keep your code working as it is");

// Find the span of the "asm!" so that we can offer an automatic suggestion
let asm_span = sp.from_inner(InnerSpan::new(0, 4));
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,9 +1010,6 @@ impl<'a> WasmLd<'a> {
// sharing memory and instantiating the module multiple times. As a
// result if it were exported then we'd just have no sharing.
//
// * `--passive-segments` - all memory segments should be passive to
// prevent each module instantiation from reinitializing memory.
//
// * `--export=__wasm_init_memory` - when using `--passive-segments` the
// linker will synthesize this function, and so we need to make sure
// that our usage of `--export` below won't accidentally cause this
Expand All @@ -1026,7 +1023,6 @@ impl<'a> WasmLd<'a> {
cmd.arg("--shared-memory");
cmd.arg("--max-memory=1073741824");
cmd.arg("--import-memory");
cmd.arg("--passive-segments");
cmd.arg("--export=__wasm_init_memory");
cmd.arg("--export=__wasm_init_tls");
cmd.arg("--export=__tls_size");
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_error_codes/error_codes/E0637.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
An underscore `_` character has been used as the identifier for a lifetime.

Erroneous example:
Erroneous code example:

```compile_fail,E0106,E0637
fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
//^^ `'_` is a reserved lifetime name
Expand All @@ -11,13 +12,15 @@ fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
}
}
```

`'_`, cannot be used as a lifetime identifier because it is a reserved for the
anonymous lifetime. To fix this, use a lowercase letter such as 'a, or a series
of lowercase letters such as `'foo`. For more information, see [the
book][bk-no]. For more information on using the anonymous lifetime in rust
nightly, see [the nightly book][bk-al].

Corrected example:

```
fn longest<'a>(str1: &'a str, str2: &'a str) -> &'a str {
if str1.len() > str2.len() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,12 @@ impl fmt::Display for UnsupportedOpInfo {
match self {
Unsupported(ref msg) => write!(f, "{}", msg),
ReadForeignStatic(did) => {
write!(f, "cannot read from foreign (extern) static {:?}", did)
write!(f, "cannot read from foreign (extern) static ({:?})", did)
}
NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did),
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",),
ReadBytesAsPointer => write!(f, "unable to turn bytes into a pointer"),
ThreadLocalStatic(did) => write!(f, "accessing thread local static {:?}", did),
ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did),
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_middle/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,11 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let ty = self.ty.fold_with(folder);
let val = self.val.fold_with(folder);
folder.tcx().mk_const(ty::Const { ty, val })
if ty != self.ty || val != self.val {
folder.tcx().mk_const(ty::Const { ty, val })
} else {
*self
}
}

fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
Expand Down
5 changes: 0 additions & 5 deletions src/librustc_mir/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ use super::ConstCx;

/// An operation that is not *always* allowed in a const context.
pub trait NonConstOp: std::fmt::Debug {
/// Whether this operation can be evaluated by miri.
const IS_SUPPORTED_IN_MIRI: bool = true;

/// Returns the `Symbol` corresponding to the feature gate that would enable this operation,
/// or `None` if such a feature gate does not exist.
fn feature_gate() -> Option<Symbol> {
Expand Down Expand Up @@ -356,8 +353,6 @@ impl NonConstOp for StaticAccess {
#[derive(Debug)]
pub struct ThreadLocalAccess;
impl NonConstOp for ThreadLocalAccess {
const IS_SUPPORTED_IN_MIRI: bool = false;

fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
struct_span_err!(
ccx.tcx.sess,
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,7 @@ impl Validator<'mir, 'tcx> {
return;
}

// If an operation is supported in miri it can be turned on with
// `-Zunleash-the-miri-inside-of-you`.
let is_unleashable = O::IS_SUPPORTED_IN_MIRI;

if is_unleashable && self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
if self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
self.tcx.sess.miri_unleashed_feature(span, O::feature_gate());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {

let self_ty = self.resolve_vars_if_possible(&trait_ref.self_ty());

// Do not check on infer_types to avoid panic in evaluate_obligation.
if self_ty.has_infer_types() {
return;
}
let self_ty = self.tcx.erase_regions(&self_ty);

let impls_future = self.tcx.type_implements_trait((
future_trait,
self_ty,
Expand Down
7 changes: 0 additions & 7 deletions src/librustc_trait_selection/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,6 @@ fn type_implements_trait<'tcx>(
trait_def_id, ty, params, param_env
);

// Do not check on infer_types to avoid panic in evaluate_obligation.
if ty.has_infer_types() {
return false;
}

let ty = tcx.erase_regions(&ty);

let trait_ref = ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(ty, params) };

let obligation = Obligation {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/asm/rustfix-asm.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ fn main() {
let x = 1;
let y: i32;
llvm_asm!("" :: "r" (x));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
llvm_asm!("" : "=r" (y));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
let _ = y;
}
}
4 changes: 2 additions & 2 deletions src/test/ui/asm/rustfix-asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ fn main() {
let x = 1;
let y: i32;
asm!("" :: "r" (x));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
asm!("" : "=r" (y));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
let _ = y;
}
}
10 changes: 8 additions & 2 deletions src/test/ui/asm/rustfix-asm.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
error: legacy asm! syntax is no longer supported
error: the legacy LLVM-style asm! syntax is no longer supported
--> $DIR/rustfix-asm.rs:10:9
|
LL | asm!("" :: "r" (x));
| ----^^^^^^^^^^^^^^^^
| |
| help: replace with: `llvm_asm!`
|
= note: consider migrating to the new asm! syntax specified in RFC 2873
= note: alternatively, switch to llvm_asm! to keep your code working as it is

error: legacy asm! syntax is no longer supported
error: the legacy LLVM-style asm! syntax is no longer supported
--> $DIR/rustfix-asm.rs:12:9
|
LL | asm!("" : "=r" (y));
| ----^^^^^^^^^^^^^^^^
| |
| help: replace with: `llvm_asm!`
|
= note: consider migrating to the new asm! syntax specified in RFC 2873
= note: alternatively, switch to llvm_asm! to keep your code working as it is

error: aborting due to 2 previous errors

11 changes: 9 additions & 2 deletions src/test/ui/consts/miri_unleashed/inline_asm.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
// only-x86_64
#![feature(llvm_asm)]
#![feature(asm,llvm_asm)]
#![allow(const_err)]

fn main() {}

// Make sure we catch executing inline assembly.
static TEST_BAD: () = {
static TEST_BAD1: () = {
unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
//~^ ERROR could not evaluate static initializer
//~| NOTE inline assembly is not supported
//~| NOTE in this expansion of llvm_asm!
//~| NOTE in this expansion of llvm_asm!
};

// Make sure we catch executing inline assembly.
static TEST_BAD2: () = {
unsafe { asm!("nop"); }
//~^ ERROR could not evaluate static initializer
//~| NOTE inline assembly is not supported
};
13 changes: 12 additions & 1 deletion src/test/ui/consts/miri_unleashed/inline_asm.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@ LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: could not evaluate static initializer
--> $DIR/inline_asm.rs:19:14
|
LL | unsafe { asm!("nop"); }
| ^^^^^^^^^^^^ inline assembly is not supported

warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/inline_asm.rs:10:14
|
LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/inline_asm.rs:19:14
|
LL | unsafe { asm!("nop"); }
| ^^^^^^^^^^^^
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0080`.
17 changes: 17 additions & 0 deletions src/test/ui/consts/miri_unleashed/tls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(thread_local)]
#![allow(const_err)]

use std::thread;

#[thread_local]
static A: u8 = 0;

// Make sure we catch accessing thread-local storage.
static TEST_BAD: () = {
unsafe { let _val = A; }
//~^ ERROR could not evaluate static initializer
//~| NOTE cannot access thread local static
};

fn main() {}
17 changes: 17 additions & 0 deletions src/test/ui/consts/miri_unleashed/tls.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0080]: could not evaluate static initializer
--> $DIR/tls.rs:12:25
|
LL | unsafe { let _val = A; }
| ^ cannot access thread local static (DefId(0:4 ~ tls[317d]::A[0]))

warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/tls.rs:12:25
|
LL | unsafe { let _val = A; }
| ^

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0080`.
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ fn main() {
asm!("");
//~^ ERROR inline assembly is not stable enough
llvm_asm!("");
//~^ ERROR LLVM-style inline assembly will never be stabilized
//~^ ERROR prefer using the new asm! syntax instead
}
}
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | asm!("");
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
= help: add `#![feature(asm)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'llvm_asm': LLVM-style inline assembly will never be stabilized, prefer using asm! instead
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
--> $DIR/feature-gate-asm.rs:7:9
|
LL | llvm_asm!("");
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ fn main() {
println!("{:?}", asm!(""));
//~^ ERROR inline assembly is not stable enough
println!("{:?}", llvm_asm!(""));
//~^ ERROR LLVM-style inline assembly will never be stabilized
//~^ ERROR prefer using the new asm! syntax instead
}
}
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | println!("{:?}", asm!(""));
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
= help: add `#![feature(asm)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'llvm_asm': LLVM-style inline assembly will never be stabilized, prefer using asm! instead
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
--> $DIR/feature-gate-asm2.rs:7:26
|
LL | println!("{:?}", llvm_asm!(""));
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/proc-macro/auxiliary/test-macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ pub fn print_attr(_: TokenStream, input: TokenStream) -> TokenStream {

#[proc_macro_derive(Print, attributes(print_helper))]
pub fn print_derive(input: TokenStream) -> TokenStream {
print_helper(input, "DERIVE")
print_helper(input, "DERIVE");
TokenStream::new()
}
Loading

0 comments on commit 10c2316

Please sign in to comment.