Skip to content

Commit 10c2316

Browse files
committed
Auto merge of #72905 - JohnTitor:rollup-phtyo5i, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #72775 (Return early to avoid ICE) - #72795 (Add a test for `$:ident` in proc macro input) - #72822 (remove trivial calls to mk_const) - #72825 (Clarify errors and warnings about the transition to the new asm!) - #72827 (changed *nix to Unix-like) - #72880 (Clean up E0637 explanation) - #72886 (Remove allow missing_debug_implementations for MaybeUninit) - #72889 (rustc: Remove the `--passive-segments` LLD flag on wasm) - #72891 (Add associated consts MIN/MAX for Wrapping<Int>) - #72893 (test miri-unleash TLS accesses) Failed merges: r? @ghost
2 parents ad4bc33 + b7ec7bd commit 10c2316

File tree

32 files changed

+238
-87
lines changed

32 files changed

+238
-87
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ or reading the [rustc dev guide][rustcguidebuild].
2323

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

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

2929
* `g++` 5.1 or later or `clang++` 3.5 or later

src/libcore/macros/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ pub(crate) mod builtin {
13151315
#[unstable(
13161316
feature = "llvm_asm",
13171317
issue = "70173",
1318-
reason = "LLVM-style inline assembly will never be stabilized, prefer using asm! instead"
1318+
reason = "prefer using the new asm! syntax instead"
13191319
)]
13201320
#[rustc_builtin_macro]
13211321
#[macro_export]

src/libcore/mem/maybe_uninit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ use crate::mem::ManuallyDrop;
214214
/// remain `#[repr(transparent)]`. That said, `MaybeUninit<T>` will *always* guarantee that it has
215215
/// the same size, alignment, and ABI as `T`; it's just that the way `MaybeUninit` implements that
216216
/// guarantee may evolve.
217-
#[allow(missing_debug_implementations)]
218217
#[stable(feature = "maybe_uninit", since = "1.36.0")]
219218
// Lang item so we can wrap other types in it. This is useful for generators.
220219
#[lang = "maybe_uninit"]

src/libcore/num/wrapping.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,10 @@ Basic usage:
337337
#![feature(wrapping_int_impl)]
338338
use std::num::Wrapping;
339339
340-
assert_eq!(<Wrapping<", stringify!($t), ">>::min_value(), ",
341-
"Wrapping(", stringify!($t), "::min_value()));
340+
assert_eq!(<Wrapping<", stringify!($t), ">>::MIN, Wrapping(", stringify!($t), "::MIN));
342341
```"),
343342
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
344-
#[inline]
345-
pub const fn min_value() -> Self {
346-
Wrapping(<$t>::min_value())
347-
}
343+
pub const MIN: Self = Self(<$t>::MIN);
348344
}
349345

350346
doc_comment! {
@@ -358,14 +354,10 @@ Basic usage:
358354
#![feature(wrapping_int_impl)]
359355
use std::num::Wrapping;
360356
361-
assert_eq!(<Wrapping<", stringify!($t), ">>::max_value(), ",
362-
"Wrapping(", stringify!($t), "::max_value()));
357+
assert_eq!(<Wrapping<", stringify!($t), ">>::MAX, Wrapping(", stringify!($t), "::MAX));
363358
```"),
364359
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
365-
#[inline]
366-
pub const fn max_value() -> Self {
367-
Wrapping(<$t>::max_value())
368-
}
360+
pub const MAX: Self = Self(<$t>::MAX);
369361
}
370362

371363
doc_comment! {

src/librustc_builtin_macros/asm.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ fn parse_args<'a>(
3333

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

3841
// Find the span of the "asm!" so that we can offer an automatic suggestion
3942
let asm_span = sp.from_inner(InnerSpan::new(0, 4));

src/librustc_codegen_ssa/back/linker.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1010,9 +1010,6 @@ impl<'a> WasmLd<'a> {
10101010
// sharing memory and instantiating the module multiple times. As a
10111011
// result if it were exported then we'd just have no sharing.
10121012
//
1013-
// * `--passive-segments` - all memory segments should be passive to
1014-
// prevent each module instantiation from reinitializing memory.
1015-
//
10161013
// * `--export=__wasm_init_memory` - when using `--passive-segments` the
10171014
// linker will synthesize this function, and so we need to make sure
10181015
// that our usage of `--export` below won't accidentally cause this
@@ -1026,7 +1023,6 @@ impl<'a> WasmLd<'a> {
10261023
cmd.arg("--shared-memory");
10271024
cmd.arg("--max-memory=1073741824");
10281025
cmd.arg("--import-memory");
1029-
cmd.arg("--passive-segments");
10301026
cmd.arg("--export=__wasm_init_memory");
10311027
cmd.arg("--export=__wasm_init_tls");
10321028
cmd.arg("--export=__tls_size");

src/librustc_error_codes/error_codes/E0637.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
An underscore `_` character has been used as the identifier for a lifetime.
22

3-
Erroneous example:
3+
Erroneous code example:
4+
45
```compile_fail,E0106,E0637
56
fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
67
//^^ `'_` is a reserved lifetime name
@@ -11,13 +12,15 @@ fn longest<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
1112
}
1213
}
1314
```
15+
1416
`'_`, cannot be used as a lifetime identifier because it is a reserved for the
1517
anonymous lifetime. To fix this, use a lowercase letter such as 'a, or a series
1618
of lowercase letters such as `'foo`. For more information, see [the
1719
book][bk-no]. For more information on using the anonymous lifetime in rust
1820
nightly, see [the nightly book][bk-al].
1921

2022
Corrected example:
23+
2124
```
2225
fn longest<'a>(str1: &'a str, str2: &'a str) -> &'a str {
2326
if str1.len() > str2.len() {

src/librustc_middle/mir/interpret/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,12 @@ impl fmt::Display for UnsupportedOpInfo {
523523
match self {
524524
Unsupported(ref msg) => write!(f, "{}", msg),
525525
ReadForeignStatic(did) => {
526-
write!(f, "cannot read from foreign (extern) static {:?}", did)
526+
write!(f, "cannot read from foreign (extern) static ({:?})", did)
527527
}
528528
NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did),
529529
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",),
530530
ReadBytesAsPointer => write!(f, "unable to turn bytes into a pointer"),
531-
ThreadLocalStatic(did) => write!(f, "accessing thread local static {:?}", did),
531+
ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did),
532532
}
533533
}
534534
}

src/librustc_middle/ty/structural_impls.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,11 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> {
10191019
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
10201020
let ty = self.ty.fold_with(folder);
10211021
let val = self.val.fold_with(folder);
1022-
folder.tcx().mk_const(ty::Const { ty, val })
1022+
if ty != self.ty || val != self.val {
1023+
folder.tcx().mk_const(ty::Const { ty, val })
1024+
} else {
1025+
*self
1026+
}
10231027
}
10241028

10251029
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {

src/librustc_mir/transform/check_consts/ops.rs

-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ use super::ConstCx;
1212

1313
/// An operation that is not *always* allowed in a const context.
1414
pub trait NonConstOp: std::fmt::Debug {
15-
/// Whether this operation can be evaluated by miri.
16-
const IS_SUPPORTED_IN_MIRI: bool = true;
17-
1815
/// Returns the `Symbol` corresponding to the feature gate that would enable this operation,
1916
/// or `None` if such a feature gate does not exist.
2017
fn feature_gate() -> Option<Symbol> {
@@ -356,8 +353,6 @@ impl NonConstOp for StaticAccess {
356353
#[derive(Debug)]
357354
pub struct ThreadLocalAccess;
358355
impl NonConstOp for ThreadLocalAccess {
359-
const IS_SUPPORTED_IN_MIRI: bool = false;
360-
361356
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
362357
struct_span_err!(
363358
ccx.tcx.sess,

src/librustc_mir/transform/check_consts/validation.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,7 @@ impl Validator<'mir, 'tcx> {
244244
return;
245245
}
246246

247-
// If an operation is supported in miri it can be turned on with
248-
// `-Zunleash-the-miri-inside-of-you`.
249-
let is_unleashable = O::IS_SUPPORTED_IN_MIRI;
250-
251-
if is_unleashable && self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
247+
if self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
252248
self.tcx.sess.miri_unleashed_feature(span, O::feature_gate());
253249
return;
254250
}

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19091909

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

1912+
// Do not check on infer_types to avoid panic in evaluate_obligation.
1913+
if self_ty.has_infer_types() {
1914+
return;
1915+
}
1916+
let self_ty = self.tcx.erase_regions(&self_ty);
1917+
19121918
let impls_future = self.tcx.type_implements_trait((
19131919
future_trait,
19141920
self_ty,

src/librustc_trait_selection/traits/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -540,13 +540,6 @@ fn type_implements_trait<'tcx>(
540540
trait_def_id, ty, params, param_env
541541
);
542542

543-
// Do not check on infer_types to avoid panic in evaluate_obligation.
544-
if ty.has_infer_types() {
545-
return false;
546-
}
547-
548-
let ty = tcx.erase_regions(&ty);
549-
550543
let trait_ref = ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(ty, params) };
551544

552545
let obligation = Obligation {

src/test/ui/asm/rustfix-asm.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ fn main() {
88
let x = 1;
99
let y: i32;
1010
llvm_asm!("" :: "r" (x));
11-
//~^ ERROR legacy asm! syntax is no longer supported
11+
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
1212
llvm_asm!("" : "=r" (y));
13-
//~^ ERROR legacy asm! syntax is no longer supported
13+
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
1414
let _ = y;
1515
}
1616
}

src/test/ui/asm/rustfix-asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ fn main() {
88
let x = 1;
99
let y: i32;
1010
asm!("" :: "r" (x));
11-
//~^ ERROR legacy asm! syntax is no longer supported
11+
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
1212
asm!("" : "=r" (y));
13-
//~^ ERROR legacy asm! syntax is no longer supported
13+
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
1414
let _ = y;
1515
}
1616
}

src/test/ui/asm/rustfix-asm.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
error: legacy asm! syntax is no longer supported
1+
error: the legacy LLVM-style asm! syntax is no longer supported
22
--> $DIR/rustfix-asm.rs:10:9
33
|
44
LL | asm!("" :: "r" (x));
55
| ----^^^^^^^^^^^^^^^^
66
| |
77
| help: replace with: `llvm_asm!`
8+
|
9+
= note: consider migrating to the new asm! syntax specified in RFC 2873
10+
= note: alternatively, switch to llvm_asm! to keep your code working as it is
811

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

1723
error: aborting due to 2 previous errors
1824

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
// compile-flags: -Zunleash-the-miri-inside-of-you
22
// only-x86_64
3-
#![feature(llvm_asm)]
3+
#![feature(asm,llvm_asm)]
44
#![allow(const_err)]
55

66
fn main() {}
77

88
// Make sure we catch executing inline assembly.
9-
static TEST_BAD: () = {
9+
static TEST_BAD1: () = {
1010
unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
1111
//~^ ERROR could not evaluate static initializer
1212
//~| NOTE inline assembly is not supported
1313
//~| NOTE in this expansion of llvm_asm!
1414
//~| NOTE in this expansion of llvm_asm!
1515
};
16+
17+
// Make sure we catch executing inline assembly.
18+
static TEST_BAD2: () = {
19+
unsafe { asm!("nop"); }
20+
//~^ ERROR could not evaluate static initializer
21+
//~| NOTE inline assembly is not supported
22+
};

src/test/ui/consts/miri_unleashed/inline_asm.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,26 @@ LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
66
|
77
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
88

9+
error[E0080]: could not evaluate static initializer
10+
--> $DIR/inline_asm.rs:19:14
11+
|
12+
LL | unsafe { asm!("nop"); }
13+
| ^^^^^^^^^^^^ inline assembly is not supported
14+
915
warning: skipping const checks
1016
|
1117
help: skipping check that does not even have a feature gate
1218
--> $DIR/inline_asm.rs:10:14
1319
|
1420
LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
1521
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
help: skipping check that does not even have a feature gate
23+
--> $DIR/inline_asm.rs:19:14
24+
|
25+
LL | unsafe { asm!("nop"); }
26+
| ^^^^^^^^^^^^
1627
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1728

18-
error: aborting due to previous error; 1 warning emitted
29+
error: aborting due to 2 previous errors; 1 warning emitted
1930

2031
For more information about this error, try `rustc --explain E0080`.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// compile-flags: -Zunleash-the-miri-inside-of-you
2+
#![feature(thread_local)]
3+
#![allow(const_err)]
4+
5+
use std::thread;
6+
7+
#[thread_local]
8+
static A: u8 = 0;
9+
10+
// Make sure we catch accessing thread-local storage.
11+
static TEST_BAD: () = {
12+
unsafe { let _val = A; }
13+
//~^ ERROR could not evaluate static initializer
14+
//~| NOTE cannot access thread local static
15+
};
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0080]: could not evaluate static initializer
2+
--> $DIR/tls.rs:12:25
3+
|
4+
LL | unsafe { let _val = A; }
5+
| ^ cannot access thread local static (DefId(0:4 ~ tls[317d]::A[0]))
6+
7+
warning: skipping const checks
8+
|
9+
help: skipping check that does not even have a feature gate
10+
--> $DIR/tls.rs:12:25
11+
|
12+
LL | unsafe { let _val = A; }
13+
| ^
14+
15+
error: aborting due to previous error; 1 warning emitted
16+
17+
For more information about this error, try `rustc --explain E0080`.

src/test/ui/feature-gates/feature-gate-asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ fn main() {
55
asm!("");
66
//~^ ERROR inline assembly is not stable enough
77
llvm_asm!("");
8-
//~^ ERROR LLVM-style inline assembly will never be stabilized
8+
//~^ ERROR prefer using the new asm! syntax instead
99
}
1010
}

src/test/ui/feature-gates/feature-gate-asm.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | asm!("");
77
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
88
= help: add `#![feature(asm)]` to the crate attributes to enable
99

10-
error[E0658]: use of unstable library feature 'llvm_asm': LLVM-style inline assembly will never be stabilized, prefer using asm! instead
10+
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
1111
--> $DIR/feature-gate-asm.rs:7:9
1212
|
1313
LL | llvm_asm!("");

src/test/ui/feature-gates/feature-gate-asm2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ fn main() {
55
println!("{:?}", asm!(""));
66
//~^ ERROR inline assembly is not stable enough
77
println!("{:?}", llvm_asm!(""));
8-
//~^ ERROR LLVM-style inline assembly will never be stabilized
8+
//~^ ERROR prefer using the new asm! syntax instead
99
}
1010
}

src/test/ui/feature-gates/feature-gate-asm2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | println!("{:?}", asm!(""));
77
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
88
= help: add `#![feature(asm)]` to the crate attributes to enable
99

10-
error[E0658]: use of unstable library feature 'llvm_asm': LLVM-style inline assembly will never be stabilized, prefer using asm! instead
10+
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
1111
--> $DIR/feature-gate-asm2.rs:7:26
1212
|
1313
LL | println!("{:?}", llvm_asm!(""));

src/test/ui/proc-macro/auxiliary/test-macros.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@ pub fn print_attr(_: TokenStream, input: TokenStream) -> TokenStream {
108108

109109
#[proc_macro_derive(Print, attributes(print_helper))]
110110
pub fn print_derive(input: TokenStream) -> TokenStream {
111-
print_helper(input, "DERIVE")
111+
print_helper(input, "DERIVE");
112+
TokenStream::new()
112113
}

0 commit comments

Comments
 (0)