Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 76ee6fc

Browse files
committed
Auto merge of rust-lang#122312 - matthiaskrgr:rollup-0p8y7gg, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - 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#122277 (BorrowedCursor docs clarification) - 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) - rust-lang#122302 (docs: Correct ptr/ref verbiage in SliceIndex docs.) - rust-lang#122304 (fix metadata for dyn-star in new solver) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3b1717c + 16ffeb2 commit 76ee6fc

File tree

99 files changed

+204
-169
lines changed

Some content is hidden

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

99 files changed

+204
-169
lines changed

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 2 additions & 6 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 6 additions & 5 deletions
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

Lines changed: 6 additions & 10 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 13 additions & 3 deletions
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 2 additions & 4 deletions
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
}

0 commit comments

Comments
 (0)