Skip to content

Commit 8dce0b1

Browse files
committed
Auto merge of rust-lang#136614 - workingjubilee:rollup-vm143qj, r=workingjubilee
Rollup of 9 pull requests Successful merges: - rust-lang#135439 (Make `-O` mean `OptLevel::Aggressive`) - rust-lang#136193 (Implement pattern type ffi checks) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - rust-lang#136315 (Use short ty string for binop and unop errors) - rust-lang#136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - rust-lang#136530 (Implement `x perf` directly in bootstrap) - rust-lang#136580 (Couple of changes to run rustc in miri) - rust-lang#136589 (Enable "jump to def" feature on rustc docs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 942db67 + 932bb59 commit 8dce0b1

File tree

49 files changed

+3890
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3890
-479
lines changed

Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -3287,13 +3287,6 @@ dependencies = [
32873287
"tikv-jemalloc-sys",
32883288
]
32893289

3290-
[[package]]
3291-
name = "rustc-perf-wrapper"
3292-
version = "0.1.0"
3293-
dependencies = [
3294-
"clap",
3295-
]
3296-
32973290
[[package]]
32983291
name = "rustc-rayon"
32993292
version = "0.5.1"

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ members = [
4545
"src/tools/rustdoc-gui-test",
4646
"src/tools/opt-dist",
4747
"src/tools/coverage-dump",
48-
"src/tools/rustc-perf-wrapper",
4948
"src/tools/wasm-component-ld",
5049
"src/tools/features-status-dump",
5150
]

compiler/rustc_codegen_cranelift/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fn build_isa(sess: &Session) -> Arc<dyn TargetIsa + 'static> {
290290
flags_builder.set("opt_level", "none").unwrap();
291291
}
292292
OptLevel::Less
293-
| OptLevel::Default
293+
| OptLevel::More
294294
| OptLevel::Size
295295
| OptLevel::SizeMin
296296
| OptLevel::Aggressive => {

compiler/rustc_codegen_gcc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {
476476
Some(level) => match level {
477477
OptLevel::No => OptimizationLevel::None,
478478
OptLevel::Less => OptimizationLevel::Limited,
479-
OptLevel::Default => OptimizationLevel::Standard,
479+
OptLevel::More => OptimizationLevel::Standard,
480480
OptLevel::Aggressive => OptimizationLevel::Aggressive,
481481
OptLevel::Size | OptLevel::SizeMin => OptimizationLevel::Limited,
482482
},

compiler/rustc_codegen_llvm/src/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn to_llvm_opt_settings(cfg: config::OptLevel) -> (llvm::CodeGenOptLevel, llvm::
138138
match cfg {
139139
No => (llvm::CodeGenOptLevel::None, llvm::CodeGenOptSizeNone),
140140
Less => (llvm::CodeGenOptLevel::Less, llvm::CodeGenOptSizeNone),
141-
Default => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeNone),
141+
More => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeNone),
142142
Aggressive => (llvm::CodeGenOptLevel::Aggressive, llvm::CodeGenOptSizeNone),
143143
Size => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeDefault),
144144
SizeMin => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeAggressive),
@@ -150,7 +150,7 @@ fn to_pass_builder_opt_level(cfg: config::OptLevel) -> llvm::PassBuilderOptLevel
150150
match cfg {
151151
No => llvm::PassBuilderOptLevel::O0,
152152
Less => llvm::PassBuilderOptLevel::O1,
153-
Default => llvm::PassBuilderOptLevel::O2,
153+
More => llvm::PassBuilderOptLevel::O2,
154154
Aggressive => llvm::PassBuilderOptLevel::O3,
155155
Size => llvm::PassBuilderOptLevel::Os,
156156
SizeMin => llvm::PassBuilderOptLevel::Oz,

compiler/rustc_codegen_ssa/src/back/linker.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<'a> GccLinker<'a> {
410410
let opt_level = match self.sess.opts.optimize {
411411
config::OptLevel::No => "O0",
412412
config::OptLevel::Less => "O1",
413-
config::OptLevel::Default | config::OptLevel::Size | config::OptLevel::SizeMin => "O2",
413+
config::OptLevel::More | config::OptLevel::Size | config::OptLevel::SizeMin => "O2",
414414
config::OptLevel::Aggressive => "O3",
415415
};
416416

@@ -685,7 +685,7 @@ impl<'a> Linker for GccLinker<'a> {
685685

686686
// GNU-style linkers support optimization with -O. GNU ld doesn't
687687
// need a numeric argument, but other linkers do.
688-
if self.sess.opts.optimize == config::OptLevel::Default
688+
if self.sess.opts.optimize == config::OptLevel::More
689689
|| self.sess.opts.optimize == config::OptLevel::Aggressive
690690
{
691691
self.link_arg("-O1");
@@ -1213,7 +1213,7 @@ impl<'a> Linker for EmLinker<'a> {
12131213
self.cc_arg(match self.sess.opts.optimize {
12141214
OptLevel::No => "-O0",
12151215
OptLevel::Less => "-O1",
1216-
OptLevel::Default => "-O2",
1216+
OptLevel::More => "-O2",
12171217
OptLevel::Aggressive => "-O3",
12181218
OptLevel::Size => "-Os",
12191219
OptLevel::SizeMin => "-Oz",
@@ -1384,7 +1384,7 @@ impl<'a> Linker for WasmLd<'a> {
13841384
self.link_arg(match self.sess.opts.optimize {
13851385
OptLevel::No => "-O0",
13861386
OptLevel::Less => "-O1",
1387-
OptLevel::Default => "-O2",
1387+
OptLevel::More => "-O2",
13881388
OptLevel::Aggressive => "-O3",
13891389
// Currently LLD doesn't support `Os` and `Oz`, so pass through `O2`
13901390
// instead.
@@ -1451,7 +1451,7 @@ impl<'a> WasmLd<'a> {
14511451
let opt_level = match self.sess.opts.optimize {
14521452
config::OptLevel::No => "O0",
14531453
config::OptLevel::Less => "O1",
1454-
config::OptLevel::Default => "O2",
1454+
config::OptLevel::More => "O2",
14551455
config::OptLevel::Aggressive => "O3",
14561456
// wasm-ld only handles integer LTO opt levels. Use O2
14571457
config::OptLevel::Size | config::OptLevel::SizeMin => "O2",
@@ -1525,7 +1525,7 @@ impl<'a> Linker for L4Bender<'a> {
15251525
fn optimize(&mut self) {
15261526
// GNU-style linkers support optimization with -O. GNU ld doesn't
15271527
// need a numeric argument, but other linkers do.
1528-
if self.sess.opts.optimize == config::OptLevel::Default
1528+
if self.sess.opts.optimize == config::OptLevel::More
15291529
|| self.sess.opts.optimize == config::OptLevel::Aggressive
15301530
{
15311531
self.link_arg("-O1");
@@ -1929,7 +1929,7 @@ impl<'a> Linker for LlbcLinker<'a> {
19291929
match self.sess.opts.optimize {
19301930
OptLevel::No => "-O0",
19311931
OptLevel::Less => "-O1",
1932-
OptLevel::Default => "-O2",
1932+
OptLevel::More => "-O2",
19331933
OptLevel::Aggressive => "-O3",
19341934
OptLevel::Size => "-Os",
19351935
OptLevel::SizeMin => "-Oz",
@@ -2006,7 +2006,7 @@ impl<'a> Linker for BpfLinker<'a> {
20062006
self.link_arg(match self.sess.opts.optimize {
20072007
OptLevel::No => "-O0",
20082008
OptLevel::Less => "-O1",
2009-
OptLevel::Default => "-O2",
2009+
OptLevel::More => "-O2",
20102010
OptLevel::Aggressive => "-O3",
20112011
OptLevel::Size => "-Os",
20122012
OptLevel::SizeMin => "-Oz",

compiler/rustc_codegen_ssa/src/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl ModuleConfig {
236236
// Copy what clang does by turning on loop vectorization at O2 and
237237
// slp vectorization at O3.
238238
vectorize_loop: !sess.opts.cg.no_vectorize_loops
239-
&& (sess.opts.optimize == config::OptLevel::Default
239+
&& (sess.opts.optimize == config::OptLevel::More
240240
|| sess.opts.optimize == config::OptLevel::Aggressive),
241241
vectorize_slp: !sess.opts.cg.no_vectorize_slp
242242
&& sess.opts.optimize == config::OptLevel::Aggressive,
@@ -260,7 +260,7 @@ impl ModuleConfig {
260260
MergeFunctions::Trampolines | MergeFunctions::Aliases => {
261261
use config::OptLevel::*;
262262
match sess.opts.optimize {
263-
Aggressive | Default | SizeMin | Size => true,
263+
Aggressive | More | SizeMin | Size => true,
264264
Less | No => false,
265265
}
266266
}

compiler/rustc_codegen_ssa/src/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1054,12 +1054,12 @@ pub(crate) fn provide(providers: &mut Providers) {
10541054
config::OptLevel::No => return config::OptLevel::No,
10551055
// If globally optimise-speed is already specified, just use that level.
10561056
config::OptLevel::Less => return config::OptLevel::Less,
1057-
config::OptLevel::Default => return config::OptLevel::Default,
1057+
config::OptLevel::More => return config::OptLevel::More,
10581058
config::OptLevel::Aggressive => return config::OptLevel::Aggressive,
10591059
// If globally optimize-for-size has been requested, use -O2 instead (if optimize(size)
10601060
// are present).
1061-
config::OptLevel::Size => config::OptLevel::Default,
1062-
config::OptLevel::SizeMin => config::OptLevel::Default,
1061+
config::OptLevel::Size => config::OptLevel::More,
1062+
config::OptLevel::SizeMin => config::OptLevel::More,
10631063
};
10641064

10651065
let defids = tcx.collect_and_partition_mono_items(cratenum).all_mono_items;

compiler/rustc_data_structures/src/memmap.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::io;
33
use std::ops::{Deref, DerefMut};
44

55
/// A trivial wrapper for [`memmap2::Mmap`] (or `Vec<u8>` on WASM).
6-
#[cfg(not(target_arch = "wasm32"))]
6+
#[cfg(not(any(miri, target_arch = "wasm32")))]
77
pub struct Mmap(memmap2::Mmap);
88

9-
#[cfg(target_arch = "wasm32")]
9+
#[cfg(any(miri, target_arch = "wasm32"))]
1010
pub struct Mmap(Vec<u8>);
1111

12-
#[cfg(not(target_arch = "wasm32"))]
12+
#[cfg(not(any(miri, target_arch = "wasm32")))]
1313
impl Mmap {
1414
/// # Safety
1515
///
@@ -29,7 +29,7 @@ impl Mmap {
2929
}
3030
}
3131

32-
#[cfg(target_arch = "wasm32")]
32+
#[cfg(any(miri, target_arch = "wasm32"))]
3333
impl Mmap {
3434
#[inline]
3535
pub unsafe fn map(mut file: File) -> io::Result<Self> {
@@ -56,13 +56,13 @@ impl AsRef<[u8]> for Mmap {
5656
}
5757
}
5858

59-
#[cfg(not(target_arch = "wasm32"))]
59+
#[cfg(not(any(miri, target_arch = "wasm32")))]
6060
pub struct MmapMut(memmap2::MmapMut);
6161

62-
#[cfg(target_arch = "wasm32")]
62+
#[cfg(any(miri, target_arch = "wasm32"))]
6363
pub struct MmapMut(Vec<u8>);
6464

65-
#[cfg(not(target_arch = "wasm32"))]
65+
#[cfg(not(any(miri, target_arch = "wasm32")))]
6666
impl MmapMut {
6767
#[inline]
6868
pub fn map_anon(len: usize) -> io::Result<Self> {
@@ -82,7 +82,7 @@ impl MmapMut {
8282
}
8383
}
8484

85-
#[cfg(target_arch = "wasm32")]
85+
#[cfg(any(miri, target_arch = "wasm32"))]
8686
impl MmapMut {
8787
#[inline]
8888
pub fn map_anon(len: usize) -> io::Result<Self> {

compiler/rustc_data_structures/src/stack.rs

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ const STACK_PER_RECURSION: usize = 16 * 1024 * 1024; // 16MB
1717
///
1818
/// Should not be sprinkled around carelessly, as it causes a little bit of overhead.
1919
#[inline]
20+
#[cfg(not(miri))]
2021
pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
2122
stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)
2223
}
24+
25+
/// Grows the stack on demand to prevent stack overflow. Call this in strategic locations
26+
/// to "break up" recursive calls. E.g. almost any call to `visit_expr` or equivalent can benefit
27+
/// from this.
28+
///
29+
/// Should not be sprinkled around carelessly, as it causes a little bit of overhead.
30+
#[cfg(miri)]
31+
#[inline]
32+
pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
33+
f()
34+
}

compiler/rustc_driver_impl/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ pub mod pretty;
8989
#[macro_use]
9090
mod print;
9191
mod session_diagnostics;
92-
#[cfg(all(unix, any(target_env = "gnu", target_os = "macos")))]
92+
#[cfg(all(not(miri), unix, any(target_env = "gnu", target_os = "macos")))]
9393
mod signal_handler;
9494

95-
#[cfg(not(all(unix, any(target_env = "gnu", target_os = "macos"))))]
95+
#[cfg(not(all(not(miri), unix, any(target_env = "gnu", target_os = "macos"))))]
9696
mod signal_handler {
9797
/// On platforms which don't support our signal handler's requirements,
9898
/// simply use the default signal handler provided by std.
@@ -1474,7 +1474,7 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
14741474
/// Install our usual `ctrlc` handler, which sets [`rustc_const_eval::CTRL_C_RECEIVED`].
14751475
/// Making this handler optional lets tools can install a different handler, if they wish.
14761476
pub fn install_ctrlc_handler() {
1477-
#[cfg(not(target_family = "wasm"))]
1477+
#[cfg(all(not(miri), not(target_family = "wasm")))]
14781478
ctrlc::set_handler(move || {
14791479
// Indicate that we have been signaled to stop, then give the rest of the compiler a bit of
14801480
// time to check CTRL_C_RECEIVED and run its own shutdown logic, but after a short amount

compiler/rustc_errors/src/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ impl HumanEmitter {
17651765

17661766
let column_width = if let Some(width) = self.diagnostic_width {
17671767
width.saturating_sub(code_offset)
1768-
} else if self.ui_testing {
1768+
} else if self.ui_testing || cfg!(miri) {
17691769
DEFAULT_COLUMN_WIDTH
17701770
} else {
17711771
termize::dimensions()

compiler/rustc_interface/src/passes.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,9 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
827827
if tcx.sess.opts.unstable_opts.input_stats {
828828
rustc_passes::input_stats::print_hir_stats(tcx);
829829
}
830-
#[cfg(debug_assertions)]
830+
// When using rustdoc's "jump to def" feature, it enters this code and `check_crate`
831+
// is not defined. So we need to cfg it out.
832+
#[cfg(all(not(doc), debug_assertions))]
831833
rustc_passes::hir_id_validator::check_crate(tcx);
832834
let sess = tcx.sess;
833835
sess.time("misc_checking_1", || {

compiler/rustc_lint/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,6 @@ lint_improper_ctypes_only_phantomdata = composed only of `PhantomData`
390390
391391
lint_improper_ctypes_opaque = opaque types have no C equivalent
392392
393-
lint_improper_ctypes_pat_help = consider using the base type instead
394-
395-
lint_improper_ctypes_pat_reason = pattern types have no C equivalent
396393
lint_improper_ctypes_slice_help = consider using a raw pointer instead
397394
398395
lint_improper_ctypes_slice_reason = slices have no C equivalent

compiler/rustc_lint/src/foreign_modules.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,7 @@ fn structurally_same_type_impl<'tcx>(
241241
if let ty::Adt(def, args) = *ty.kind() {
242242
let is_transparent = def.repr().transparent();
243243
let is_non_null = types::nonnull_optimization_guaranteed(tcx, def);
244-
debug!(
245-
"non_transparent_ty({:?}) -- type is transparent? {}, type is non-null? {}",
246-
ty, is_transparent, is_non_null
247-
);
244+
debug!(?ty, is_transparent, is_non_null);
248245
if is_transparent && !is_non_null {
249246
debug_assert_eq!(def.variants().len(), 1);
250247
let v = &def.variant(FIRST_VARIANT);
@@ -378,14 +375,14 @@ fn structurally_same_type_impl<'tcx>(
378375

379376
// An Adt and a primitive or pointer type. This can be FFI-safe if non-null
380377
// enum layout optimisation is being applied.
381-
(Adt(..), _) if is_primitive_or_pointer(b) => {
378+
(Adt(..) | Pat(..), _) if is_primitive_or_pointer(b) => {
382379
if let Some(a_inner) = types::repr_nullable_ptr(tcx, typing_env, a, ckind) {
383380
a_inner == b
384381
} else {
385382
false
386383
}
387384
}
388-
(_, Adt(..)) if is_primitive_or_pointer(a) => {
385+
(_, Adt(..) | Pat(..)) if is_primitive_or_pointer(a) => {
389386
if let Some(b_inner) = types::repr_nullable_ptr(tcx, typing_env, b, ckind) {
390387
b_inner == a
391388
} else {

compiler/rustc_lint/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#![feature(rustc_attrs)]
3434
#![feature(rustdoc_internals)]
3535
#![feature(trait_upcasting)]
36+
#![feature(try_blocks)]
3637
#![warn(unreachable_pub)]
3738
// tidy-alphabetical-end
3839

0 commit comments

Comments
 (0)