Skip to content

Commit 5e656ba

Browse files
committed
Auto merge of rust-lang#106070 - matthiaskrgr:rollup-jv9ctkl, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#105978 (Mark `proc_macro_decls_static` as always used) - rust-lang#106051 (Allow building std with cranelift) - rust-lang#106056 (Make `sess.bug` much less noisy) - rust-lang#106057 (Give a more helpful error for "trimmed_def_paths constructed") - rust-lang#106058 (Fix the issue number in comment for as_local_call_operand) - rust-lang#106059 (Avoid running the `Profile` step twice on `x setup`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents daccb3d + fa1e34f commit 5e656ba

File tree

14 files changed

+45
-12
lines changed

14 files changed

+45
-12
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4129,6 +4129,7 @@ dependencies = [
41294129
"rustc_ast",
41304130
"rustc_attr",
41314131
"rustc_data_structures",
4132+
"rustc_error_messages",
41324133
"rustc_errors",
41334134
"rustc_feature",
41344135
"rustc_graphviz",

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

+2
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
262262
// use proc_macro::bridge::client::ProcMacro;
263263
//
264264
// #[rustc_proc_macro_decls]
265+
// #[used]
265266
// #[allow(deprecated)]
266267
// static DECLS: &[ProcMacro] = &[
267268
// ProcMacro::custom_derive($name_trait1, &[], ::$name1);
@@ -364,6 +365,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
364365
)
365366
.map(|mut i| {
366367
i.attrs.push(cx.attr_word(sym::rustc_proc_macro_decls, span));
368+
i.attrs.push(cx.attr_word(sym::used, span));
367369
i.attrs.push(cx.attr_nested_word(sym::allow, sym::deprecated, span));
368370
i
369371
});

compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ fn codegen_msvc_try<'ll>(
567567
// module.
568568
//
569569
// When modifying, make sure that the type_name string exactly matches
570-
// the one used in src/libpanic_unwind/seh.rs.
570+
// the one used in library/panic_unwind/src/seh.rs.
571571
let type_info_vtable = bx.declare_global("??_7type_info@@6B@", bx.type_i8p());
572572
let type_name = bx.const_bytes(b"rust_panic\0");
573573
let type_info =

compiler/rustc_driver/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1199,10 +1199,13 @@ static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send +
11991199
};
12001200

12011201
// Invoke the default handler, which prints the actual panic message and optionally a backtrace
1202-
(*DEFAULT_HOOK)(info);
1202+
// Don't do this for `ExplicitBug`, which has an unhelpful message and backtrace.
1203+
if !info.payload().is::<rustc_errors::ExplicitBug>() {
1204+
(*DEFAULT_HOOK)(info);
12031205

1204-
// Separate the output with an empty line
1205-
eprintln!();
1206+
// Separate the output with an empty line
1207+
eprintln!();
1208+
}
12061209

12071210
// Print the ICE message
12081211
report_ice(info, BUG_REPORT_URL);

compiler/rustc_error_messages/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<S: Into<String>> From<S> for DiagnosticMessage {
381381
}
382382
}
383383

384-
/// A workaround for "good path" ICEs when formatting types in disables lints.
384+
/// A workaround for "good path" ICEs when formatting types in disabled lints.
385385
///
386386
/// Delays formatting until `.into(): DiagnosticMessage` is used.
387387
pub struct DelayDm<F>(pub F);

compiler/rustc_middle/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ rustc_ast = { path = "../rustc_ast" }
1818
rustc_attr = { path = "../rustc_attr" }
1919
rustc_data_structures = { path = "../rustc_data_structures" }
2020
rustc_errors = { path = "../rustc_errors" }
21+
# Used for intra-doc links
22+
rustc_error_messages = { path = "../rustc_error_messages" }
2123
rustc_feature = { path = "../rustc_feature" }
2224
rustc_graphviz = { path = "../rustc_graphviz" }
2325
rustc_hir = { path = "../rustc_hir" }

compiler/rustc_middle/src/ty/print/pretty.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2883,13 +2883,19 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
28832883
/// `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere.
28842884
///
28852885
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
2886+
///
2887+
/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths`].
28862888
fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
28872889
let mut map: FxHashMap<DefId, Symbol> = FxHashMap::default();
28882890

28892891
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {
2892+
// Trimming paths is expensive and not optimized, since we expect it to only be used for error reporting.
2893+
//
28902894
// For good paths causing this bug, the `rustc_middle::ty::print::with_no_trimmed_paths`
28912895
// wrapper can be used to suppress this query, in exchange for full paths being formatted.
2892-
tcx.sess.delay_good_path_bug("trimmed_def_paths constructed");
2896+
tcx.sess.delay_good_path_bug(
2897+
"trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging",
2898+
);
28932899
}
28942900

28952901
let unique_symbols_rev: &mut FxHashMap<(Namespace, Symbol), Option<DefId>> =

compiler/rustc_mir_build/src/build/expr/as_operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7272
/// will actually provide a pointer to the interior of the box, and not move the `dyn Debug`
7373
/// value to the stack.
7474
///
75-
/// See #68034 for more details.
75+
/// See #68304 for more details.
7676
pub(crate) fn as_local_call_operand(
7777
&mut self,
7878
block: BasicBlock,

src/bootstrap/builder.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,10 @@ impl<'a> Builder<'a> {
18641864
};
18651865

18661866
if let Some(limit) = limit {
1867-
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
1867+
if stage == 0 || self.config.default_codegen_backend().unwrap_or_default() == "llvm"
1868+
{
1869+
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={}", limit));
1870+
}
18681871
}
18691872
}
18701873

src/bootstrap/compile.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,15 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
321321
""
322322
};
323323

324+
let mut features = String::new();
325+
326+
// Cranelift doesn't support `asm`.
327+
if stage != 0 && builder.config.default_codegen_backend().unwrap_or_default() == "cranelift" {
328+
features += " compiler-builtins-no-asm";
329+
}
330+
324331
if builder.no_std(target) == Some(true) {
325-
let mut features = "compiler-builtins-mem".to_string();
332+
features += " compiler-builtins-mem";
326333
if !target.starts_with("bpf") {
327334
features.push_str(compiler_builtins_c_feature);
328335
}
@@ -335,7 +342,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
335342
.arg("--features")
336343
.arg(features);
337344
} else {
338-
let mut features = builder.std_features(target);
345+
features += &builder.std_features(target);
339346
features.push_str(compiler_builtins_c_feature);
340347

341348
cargo
@@ -754,7 +761,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
754761
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
755762
.env("CFG_VERSION", builder.rust_version());
756763

757-
if let Some(backend) = builder.config.rust_codegen_backends.get(0) {
764+
if let Some(backend) = builder.config.default_codegen_backend() {
758765
cargo.env("CFG_DEFAULT_CODEGEN_BACKEND", backend);
759766
}
760767

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,10 @@ impl Config {
16111611
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
16121612
}
16131613

1614+
pub fn default_codegen_backend(&self) -> Option<Interned<String>> {
1615+
self.rust_codegen_backends.get(0).cloned()
1616+
}
1617+
16141618
/// Returns the commit to download, or `None` if we shouldn't download CI artifacts.
16151619
fn download_ci_rustc_commit(&self, download_rustc: Option<StringOrBool>) -> Option<String> {
16161620
// If `download-rustc` is not set, default to rebuilding.

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl Build {
796796
/// Gets the space-separated set of activated features for the standard
797797
/// library.
798798
fn std_features(&self, target: TargetSelection) -> String {
799-
let mut features = "panic-unwind".to_string();
799+
let mut features = " panic-unwind".to_string();
800800

801801
match self.config.llvm_libunwind(target) {
802802
LlvmLibunwind::InTree => features.push_str(" llvm-libunwind"),

src/bootstrap/setup.rs

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ impl Step for Profile {
9696
}
9797

9898
fn make_run(run: RunConfig<'_>) {
99+
if run.builder.config.dry_run() {
100+
return;
101+
}
102+
99103
// for Profile, `run.paths` will have 1 and only 1 element
100104
// this is because we only accept at most 1 path from user input.
101105
// If user calls `x.py setup` without arguments, the interactive TUI

src/test/ui/proc-macro/quote-debug.stdout

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const _: () =
4242
{
4343
extern crate proc_macro;
4444
#[rustc_proc_macro_decls]
45+
#[used]
4546
#[allow(deprecated)]
4647
static _DECLS: &[proc_macro::bridge::client::ProcMacro] = &[];
4748
};

0 commit comments

Comments
 (0)