Skip to content

Commit ffc7900

Browse files
committed
Auto merge of rust-lang#122303 - matthiaskrgr:rollup-ieokhnz, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#121754 ([bootstrap] Move the `split-debuginfo` setting to the per-target section) - rust-lang#122205 (ensure that sysroot is properly set for cross-targets) - rust-lang#122275 (disable OOM test in Miri) - rust-lang#122276 (io::Read trait: make it more clear when we are adressing implementations vs callers) - rust-lang#122286 (use Instance::expect_resolve() instead of unwraping Instance::resolve()) - rust-lang#122290 (MIR printing: print the path of uneval'd const) - rust-lang#122293 (diagnostics: Do not suggest using `#[unix_sigpipe]` without a value) - rust-lang#122297 (bootstrap: document what the triples in 'Build' mean) r? `@ghost` `@rustbot` modify labels: rollup
2 parents af69f4c + c770ce4 commit ffc7900

File tree

98 files changed

+230
-186
lines changed

Some content is hidden

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

98 files changed

+230
-186
lines changed

compiler/rustc_codegen_cranelift/src/main_shim.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,12 @@ pub(crate) fn maybe_create_entry_wrapper(
115115
termination_trait,
116116
)
117117
.unwrap();
118-
let report = Instance::resolve(
118+
let report = Instance::expect_resolve(
119119
tcx,
120120
ParamEnv::reveal_all(),
121121
report.def_id,
122122
tcx.mk_args(&[GenericArg::from(main_ret_ty)]),
123123
)
124-
.unwrap()
125-
.unwrap()
126124
.polymorphize(tcx);
127125

128126
let report_name = tcx.symbol_name(report).name;
@@ -142,14 +140,12 @@ pub(crate) fn maybe_create_entry_wrapper(
142140
}
143141
} else if is_main_fn {
144142
let start_def_id = tcx.require_lang_item(LangItem::Start, None);
145-
let start_instance = Instance::resolve(
143+
let start_instance = Instance::expect_resolve(
146144
tcx,
147145
ParamEnv::reveal_all(),
148146
start_def_id,
149147
tcx.mk_args(&[main_ret_ty.into()]),
150148
)
151-
.unwrap()
152-
.unwrap()
153149
.polymorphize(tcx);
154150
let start_func_id = import_function(tcx, m, start_instance);
155151

compiler/rustc_codegen_gcc/src/context.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -473,14 +473,12 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
473473
let tcx = self.tcx;
474474
let func = match tcx.lang_items().eh_personality() {
475475
Some(def_id) if !wants_msvc_seh(self.sess()) => {
476-
let instance = ty::Instance::resolve(
476+
let instance = ty::Instance::expect_resolve(
477477
tcx,
478478
ty::ParamEnv::reveal_all(),
479479
def_id,
480480
ty::List::empty(),
481-
)
482-
.unwrap()
483-
.unwrap();
481+
);
484482

485483
let symbol_name = tcx.symbol_name(instance).name;
486484
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());

compiler/rustc_codegen_llvm/src/context.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,12 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
558558

559559
let tcx = self.tcx;
560560
let llfn = match tcx.lang_items().eh_personality() {
561-
Some(def_id) if name.is_none() => self.get_fn_addr(
562-
ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, ty::List::empty())
563-
.unwrap()
564-
.unwrap(),
565-
),
561+
Some(def_id) if name.is_none() => self.get_fn_addr(ty::Instance::expect_resolve(
562+
tcx,
563+
ty::ParamEnv::reveal_all(),
564+
def_id,
565+
ty::List::empty(),
566+
)),
566567
_ => {
567568
let name = name.unwrap_or("rust_eh_personality");
568569
if let Some(llfn) = self.get_declared_value(name) {

compiler/rustc_codegen_ssa/src/base.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,12 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
467467

468468
let (start_fn, start_ty, args) = if let EntryFnType::Main { sigpipe } = entry_type {
469469
let start_def_id = cx.tcx().require_lang_item(LangItem::Start, None);
470-
let start_fn = cx.get_fn_addr(
471-
ty::Instance::resolve(
472-
cx.tcx(),
473-
ty::ParamEnv::reveal_all(),
474-
start_def_id,
475-
cx.tcx().mk_args(&[main_ret_ty.into()]),
476-
)
477-
.unwrap()
478-
.unwrap(),
479-
);
470+
let start_fn = cx.get_fn_addr(ty::Instance::expect_resolve(
471+
cx.tcx(),
472+
ty::ParamEnv::reveal_all(),
473+
start_def_id,
474+
cx.tcx().mk_args(&[main_ret_ty.into()]),
475+
));
480476

481477
let i8_ty = cx.type_i8();
482478
let arg_sigpipe = bx.const_u8(sigpipe);

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
6767
trace!(
6868
"eval_body_using_ecx: pushing stack frame for global: {}{}",
6969
with_no_trimmed_paths!(ecx.tcx.def_path_str(cid.instance.def_id())),
70-
cid.promoted.map_or_else(String::new, |p| format!("::promoted[{p:?}]"))
70+
cid.promoted.map_or_else(String::new, |p| format!("::{p:?}"))
7171
);
7272

7373
ecx.push_stack_frame(

compiler/rustc_const_eval/src/const_eval/machine.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,12 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
243243
} else if Some(def_id) == self.tcx.lang_items().panic_fmt() {
244244
// For panic_fmt, call const_panic_fmt instead.
245245
let const_def_id = self.tcx.require_lang_item(LangItem::ConstPanicFmt, None);
246-
let new_instance = ty::Instance::resolve(
246+
let new_instance = ty::Instance::expect_resolve(
247247
*self.tcx,
248248
ty::ParamEnv::reveal_all(),
249249
const_def_id,
250250
instance.args,
251-
)
252-
.unwrap()
253-
.unwrap();
251+
);
254252

255253
return Ok(Some(new_instance));
256254
} else if Some(def_id) == self.tcx.lang_items().align_offset_fn() {

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
389389
),
390390

391391
// Entry point:
392-
gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
392+
gated!(unix_sigpipe, Normal, template!(NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
393393
ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true),
394394
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
395395
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true),

compiler/rustc_middle/src/mir/consts.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_target::abi::{HasDataLayout, Size};
77

88
use crate::mir::interpret::{alloc_range, AllocId, ConstAllocation, ErrorHandled, Scalar};
99
use crate::mir::{pretty_print_const_value, Promoted};
10+
use crate::ty::print::with_no_trimmed_paths;
1011
use crate::ty::GenericArgsRef;
1112
use crate::ty::ScalarInt;
1213
use crate::ty::{self, print::pretty_print_const, Ty, TyCtxt};
@@ -489,9 +490,18 @@ impl<'tcx> Display for Const<'tcx> {
489490
Const::Ty(c) => pretty_print_const(c, fmt, true),
490491
Const::Val(val, ty) => pretty_print_const_value(val, ty, fmt),
491492
// FIXME(valtrees): Correctly print mir constants.
492-
Const::Unevaluated(..) => {
493-
fmt.write_str("_")?;
494-
Ok(())
493+
Const::Unevaluated(c, _ty) => {
494+
ty::tls::with(move |tcx| {
495+
let c = tcx.lift(c).unwrap();
496+
// Matches `GlobalId` printing.
497+
let instance =
498+
with_no_trimmed_paths!(tcx.def_path_str_with_args(c.def, c.args));
499+
write!(fmt, "{instance}")?;
500+
if let Some(promoted) = c.promoted {
501+
write!(fmt, "::{promoted:?}")?;
502+
}
503+
Ok(())
504+
})
495505
}
496506
}
497507
}

compiler/rustc_middle/src/mir/pretty.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
496496
_ => tcx.is_closure_like(def_id),
497497
};
498498
match (kind, body.source.promoted) {
499-
(_, Some(i)) => write!(w, "{i:?} in ")?,
499+
(_, Some(_)) => write!(w, "const ")?, // promoteds are the closest to consts
500500
(DefKind::Const | DefKind::AssocConst, _) => write!(w, "const ")?,
501501
(DefKind::Static(hir::Mutability::Not), _) => write!(w, "static ")?,
502502
(DefKind::Static(hir::Mutability::Mut), _) => write!(w, "static mut ")?,
@@ -509,6 +509,9 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
509509
// see notes on #41697 elsewhere
510510
write!(w, "{}", tcx.def_path_str(def_id))?
511511
}
512+
if let Some(p) = body.source.promoted {
513+
write!(w, "::{p:?}")?;
514+
}
512515

513516
if body.source.promoted.is_none() && is_function {
514517
write!(w, "(")?;

compiler/rustc_monomorphize/src/collector.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1339,14 +1339,12 @@ impl<'v> RootCollector<'_, 'v> {
13391339
main_ret_ty.no_bound_vars().unwrap(),
13401340
);
13411341

1342-
let start_instance = Instance::resolve(
1342+
let start_instance = Instance::expect_resolve(
13431343
self.tcx,
13441344
ty::ParamEnv::reveal_all(),
13451345
start_def_id,
13461346
self.tcx.mk_args(&[main_ret_ty.into()]),
1347-
)
1348-
.unwrap()
1349-
.unwrap();
1347+
);
13501348

13511349
self.output.push(create_fn_mono_item(self.tcx, start_instance, DUMMY_SP));
13521350
}

compiler/rustc_passes/src/entry.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ fn sigpipe(tcx: TyCtxt<'_>, def_id: DefId) -> u8 {
156156
(Some(sym::inherit), None) => sigpipe::INHERIT,
157157
(Some(sym::sig_ign), None) => sigpipe::SIG_IGN,
158158
(Some(sym::sig_dfl), None) => sigpipe::SIG_DFL,
159-
(_, Some(_)) => {
160-
// Keep going so that `fn emit_malformed_attribute()` can print
161-
// an excellent error message
159+
(Some(_), None) => {
160+
tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span });
162161
sigpipe::DEFAULT
163162
}
164163
_ => {
165-
tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span });
164+
// Keep going so that `fn emit_malformed_attribute()` can print
165+
// an excellent error message
166166
sigpipe::DEFAULT
167167
}
168168
}

config.example.toml

+26-14
Original file line numberDiff line numberDiff line change
@@ -543,23 +543,15 @@
543543
# FIXME(#61117): Some tests fail when this option is enabled.
544544
#debuginfo-level-tests = 0
545545

546-
# Should rustc be build with split debuginfo? Default is platform dependent.
547-
# Valid values are the same as those accepted by `-C split-debuginfo`
548-
# (`off`/`unpacked`/`packed`).
546+
# Should rustc and the standard library be built with split debuginfo? Default
547+
# is platform dependent.
549548
#
550-
# On Linux, split debuginfo is disabled by default.
549+
# This field is deprecated, use `target.<triple>.split-debuginfo` instead.
551550
#
552-
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
553-
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
554-
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
555-
# no clear benefit, and also makes it more difficult for debuggers to find
556-
# debug info. The compiler currently defaults to running `dsymutil` to preserve
557-
# its historical default, but when compiling the compiler itself, we skip it by
558-
# default since we know it's safe to do so in that case.
551+
# The value specified here is only used when targeting the `build.build` triple,
552+
# and is overridden by `target.<triple>.split-debuginfo` if specified.
559553
#
560-
# On Windows platforms, packed debuginfo is the only supported option,
561-
# producing a `.pdb` file.
562-
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
554+
#split-debuginfo = see target.<triple>.split-debuginfo
563555

564556
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
565557
#backtrace = true
@@ -769,6 +761,26 @@
769761
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
770762
#linker = "cc" (path)
771763

764+
# Should rustc and the standard library be built with split debuginfo? Default
765+
# is platform dependent.
766+
#
767+
# Valid values are the same as those accepted by `-C split-debuginfo`
768+
# (`off`/`unpacked`/`packed`).
769+
#
770+
# On Linux, split debuginfo is disabled by default.
771+
#
772+
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
773+
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
774+
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
775+
# no clear benefit, and also makes it more difficult for debuggers to find
776+
# debug info. The compiler currently defaults to running `dsymutil` to preserve
777+
# its historical default, but when compiling the compiler itself, we skip it by
778+
# default since we know it's safe to do so in that case.
779+
#
780+
# On Windows platforms, packed debuginfo is the only supported option,
781+
# producing a `.pdb` file.
782+
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
783+
772784
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
773785
# against. Note that if this is specified we don't compile LLVM at all for this
774786
# target.

library/std/src/io/mod.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,9 @@ pub trait Read {
692692
/// Callers have to ensure that no unchecked out-of-bounds accesses are possible even if
693693
/// `n > buf.len()`.
694694
///
695-
/// No guarantees are provided about the contents of `buf` when this
696-
/// function is called, so implementations cannot rely on any property of the
697-
/// contents of `buf` being true. It is recommended that *implementations*
698-
/// only write data to `buf` instead of reading its contents.
695+
/// *Implementations* of this method can make no assumptions about the contents of `buf` when
696+
/// this function is called. It is recommended that implementations only write data to `buf`
697+
/// instead of reading its contents.
699698
///
700699
/// Correspondingly, however, *callers* of this method in unsafe code must not assume
701700
/// any guarantees about how the implementation uses `buf`. The trait is safe to implement,
@@ -901,12 +900,10 @@ pub trait Read {
901900
/// This function reads as many bytes as necessary to completely fill the
902901
/// specified buffer `buf`.
903902
///
904-
/// No guarantees are provided about the contents of `buf` when this
905-
/// function is called, so implementations cannot rely on any property of the
906-
/// contents of `buf` being true. It is recommended that implementations
907-
/// only write data to `buf` instead of reading its contents. The
908-
/// documentation on [`read`] has a more detailed explanation on this
909-
/// subject.
903+
/// *Implementations* of this method can make no assumptions about the contents of `buf` when
904+
/// this function is called. It is recommended that implementations only write data to `buf`
905+
/// instead of reading its contents. The documentation on [`read`] has a more detailed
906+
/// explanation of this subject.
910907
///
911908
/// # Errors
912909
///

library/std/src/io/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@ fn read_buf_full_read() {
694694
}
695695

696696
#[test]
697+
// Miri does not support signalling OOM
698+
#[cfg_attr(miri, ignore)]
697699
// 64-bit only to be sure the allocator will fail fast on an impossible to satsify size
698700
#[cfg(target_pointer_width = "64")]
699701
fn try_oom_error() {

src/bootstrap/src/core/build_steps/test.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2580,6 +2580,12 @@ impl Step for Crate {
25802580
// we're working with automatically.
25812581
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
25822582

2583+
// During cross compilations, sysroot for the target may not be available.
2584+
// Ensure that it is prepared.
2585+
if builder.config.build != target {
2586+
builder.ensure(compile::Rustc::new(compiler, target));
2587+
}
2588+
25832589
let mut cargo = builder::Cargo::new(
25842590
builder,
25852591
compiler,

src/bootstrap/src/core/builder.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1730,15 +1730,16 @@ impl<'a> Builder<'a> {
17301730
},
17311731
);
17321732

1733+
let split_debuginfo = self.config.split_debuginfo(target);
17331734
let split_debuginfo_is_stable = target.contains("linux")
17341735
|| target.contains("apple")
1735-
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
1736-
|| (target.is_windows() && self.config.rust_split_debuginfo == SplitDebuginfo::Off);
1736+
|| (target.is_msvc() && split_debuginfo == SplitDebuginfo::Packed)
1737+
|| (target.is_windows() && split_debuginfo == SplitDebuginfo::Off);
17371738

17381739
if !split_debuginfo_is_stable {
17391740
rustflags.arg("-Zunstable-options");
17401741
}
1741-
match self.config.rust_split_debuginfo {
1742+
match split_debuginfo {
17421743
SplitDebuginfo::Packed => rustflags.arg("-Csplit-debuginfo=packed"),
17431744
SplitDebuginfo::Unpacked => rustflags.arg("-Csplit-debuginfo=unpacked"),
17441745
SplitDebuginfo::Off => rustflags.arg("-Csplit-debuginfo=off"),

0 commit comments

Comments
 (0)