diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/main_shim.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/context.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/base.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/eval_queries.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/machine.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/builtin_attrs.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/consts.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/pretty.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_monomorphize/src/collector.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/entry.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs | 5 |
12 files changed, 46 insertions, 45 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/main_shim.rs b/compiler/rustc_codegen_cranelift/src/main_shim.rs index 6535c3a367b..1abfded8b11 100644 --- a/compiler/rustc_codegen_cranelift/src/main_shim.rs +++ b/compiler/rustc_codegen_cranelift/src/main_shim.rs @@ -115,14 +115,12 @@ pub(crate) fn maybe_create_entry_wrapper( termination_trait, ) .unwrap(); - let report = Instance::resolve( + let report = Instance::expect_resolve( tcx, ParamEnv::reveal_all(), report.def_id, tcx.mk_args(&[GenericArg::from(main_ret_ty)]), ) - .unwrap() - .unwrap() .polymorphize(tcx); let report_name = tcx.symbol_name(report).name; @@ -142,14 +140,12 @@ pub(crate) fn maybe_create_entry_wrapper( } } else if is_main_fn { let start_def_id = tcx.require_lang_item(LangItem::Start, None); - let start_instance = Instance::resolve( + let start_instance = Instance::expect_resolve( tcx, ParamEnv::reveal_all(), start_def_id, tcx.mk_args(&[main_ret_ty.into()]), ) - .unwrap() - .unwrap() .polymorphize(tcx); let start_func_id = import_function(tcx, m, start_instance); diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs index bc3d62f2679..8f643c7db72 100644 --- a/compiler/rustc_codegen_gcc/src/context.rs +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -473,14 +473,12 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> { let tcx = self.tcx; let func = match tcx.lang_items().eh_personality() { Some(def_id) if !wants_msvc_seh(self.sess()) => { - let instance = ty::Instance::resolve( + let instance = ty::Instance::expect_resolve( tcx, ty::ParamEnv::reveal_all(), def_id, ty::List::empty(), - ) - .unwrap() - .unwrap(); + ); let symbol_name = tcx.symbol_name(instance).name; let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty()); diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index d1f32087908..37c690a0128 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -558,11 +558,12 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { let tcx = self.tcx; let llfn = match tcx.lang_items().eh_personality() { - Some(def_id) if name.is_none() => self.get_fn_addr( - ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, ty::List::empty()) - .unwrap() - .unwrap(), - ), + Some(def_id) if name.is_none() => self.get_fn_addr(ty::Instance::expect_resolve( + tcx, + ty::ParamEnv::reveal_all(), + def_id, + ty::List::empty(), + )), _ => { let name = name.unwrap_or("rust_eh_personality"); if let Some(llfn) = self.get_declared_value(name) { diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 1a3c70cedd0..5cba14a5dda 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -467,16 +467,12 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let (start_fn, start_ty, args) = if let EntryFnType::Main { sigpipe } = entry_type { let start_def_id = cx.tcx().require_lang_item(LangItem::Start, None); - let start_fn = cx.get_fn_addr( - ty::Instance::resolve( - cx.tcx(), - ty::ParamEnv::reveal_all(), - start_def_id, - cx.tcx().mk_args(&[main_ret_ty.into()]), - ) - .unwrap() - .unwrap(), - ); + let start_fn = cx.get_fn_addr(ty::Instance::expect_resolve( + cx.tcx(), + ty::ParamEnv::reveal_all(), + start_def_id, + cx.tcx().mk_args(&[main_ret_ty.into()]), + )); let i8_ty = cx.type_i8(); let arg_sigpipe = bx.const_u8(sigpipe); diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 9e4e7911c3a..8ee3a0cc967 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -67,7 +67,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( trace!( "eval_body_using_ecx: pushing stack frame for global: {}{}", with_no_trimmed_paths!(ecx.tcx.def_path_str(cid.instance.def_id())), - cid.promoted.map_or_else(String::new, |p| format!("::promoted[{p:?}]")) + cid.promoted.map_or_else(String::new, |p| format!("::{p:?}")) ); ecx.push_stack_frame( diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 6736fc749c0..f104b836716 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -243,14 +243,12 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> { } else if Some(def_id) == self.tcx.lang_items().panic_fmt() { // For panic_fmt, call const_panic_fmt instead. let const_def_id = self.tcx.require_lang_item(LangItem::ConstPanicFmt, None); - let new_instance = ty::Instance::resolve( + let new_instance = ty::Instance::expect_resolve( *self.tcx, ty::ParamEnv::reveal_all(), const_def_id, instance.args, - ) - .unwrap() - .unwrap(); + ); return Ok(Some(new_instance)); } else if Some(def_id) == self.tcx.lang_items().align_offset_fn() { diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 0d51e1e46e0..38848b22cb2 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -389,7 +389,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), // Entry point: - gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)), + gated!(unix_sigpipe, Normal, template!(NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)), ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true), ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, @only_local: true), ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true), diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index 9731d86fb17..5feee3c3ba1 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -7,6 +7,7 @@ use rustc_target::abi::{HasDataLayout, Size}; use crate::mir::interpret::{alloc_range, AllocId, ConstAllocation, ErrorHandled, Scalar}; use crate::mir::{pretty_print_const_value, Promoted}; +use crate::ty::print::with_no_trimmed_paths; use crate::ty::GenericArgsRef; use crate::ty::ScalarInt; use crate::ty::{self, print::pretty_print_const, Ty, TyCtxt}; @@ -489,9 +490,18 @@ impl<'tcx> Display for Const<'tcx> { Const::Ty(c) => pretty_print_const(c, fmt, true), Const::Val(val, ty) => pretty_print_const_value(val, ty, fmt), // FIXME(valtrees): Correctly print mir constants. - Const::Unevaluated(..) => { - fmt.write_str("_")?; - Ok(()) + Const::Unevaluated(c, _ty) => { + ty::tls::with(move |tcx| { + let c = tcx.lift(c).unwrap(); + // Matches `GlobalId` printing. + let instance = + with_no_trimmed_paths!(tcx.def_path_str_with_args(c.def, c.args)); + write!(fmt, "{instance}")?; + if let Some(promoted) = c.promoted { + write!(fmt, "::{promoted:?}")?; + } + Ok(()) + }) } } } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 18069547a7e..090b84ff08f 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -496,7 +496,7 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io: _ => tcx.is_closure_like(def_id), }; match (kind, body.source.promoted) { - (_, Some(i)) => write!(w, "{i:?} in ")?, + (_, Some(_)) => write!(w, "const ")?, // promoteds are the closest to consts (DefKind::Const | DefKind::AssocConst, _) => write!(w, "const ")?, (DefKind::Static(hir::Mutability::Not), _) => write!(w, "static ")?, (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: // see notes on #41697 elsewhere write!(w, "{}", tcx.def_path_str(def_id))? } + if let Some(p) = body.source.promoted { + write!(w, "::{p:?}")?; + } if body.source.promoted.is_none() && is_function { write!(w, "(")?; diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 32f823a5ac6..a18448eabf3 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1339,14 +1339,12 @@ impl<'v> RootCollector<'_, 'v> { main_ret_ty.no_bound_vars().unwrap(), ); - let start_instance = Instance::resolve( + let start_instance = Instance::expect_resolve( self.tcx, ty::ParamEnv::reveal_all(), start_def_id, self.tcx.mk_args(&[main_ret_ty.into()]), - ) - .unwrap() - .unwrap(); + ); self.output.push(create_fn_mono_item(self.tcx, start_instance, DUMMY_SP)); } diff --git a/compiler/rustc_passes/src/entry.rs b/compiler/rustc_passes/src/entry.rs index 5246389248e..0bab13037e4 100644 --- a/compiler/rustc_passes/src/entry.rs +++ b/compiler/rustc_passes/src/entry.rs @@ -156,13 +156,13 @@ fn sigpipe(tcx: TyCtxt<'_>, def_id: DefId) -> u8 { (Some(sym::inherit), None) => sigpipe::INHERIT, (Some(sym::sig_ign), None) => sigpipe::SIG_IGN, (Some(sym::sig_dfl), None) => sigpipe::SIG_DFL, - (_, Some(_)) => { - // Keep going so that `fn emit_malformed_attribute()` can print - // an excellent error message + (Some(_), None) => { + tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span }); sigpipe::DEFAULT } _ => { - tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span }); + // Keep going so that `fn emit_malformed_attribute()` can print + // an excellent error message sigpipe::DEFAULT } } diff --git a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs index ed839d14dc7..a45c1c34410 100644 --- a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs @@ -542,13 +542,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { | ty::Coroutine(..) | ty::CoroutineWitness(..) | ty::Never - | ty::Foreign(..) => tcx.types.unit, + | ty::Foreign(..) + | ty::Dynamic(_, _, ty::DynStar) => tcx.types.unit, ty::Error(e) => Ty::new_error(tcx, *e), ty::Str | ty::Slice(_) => tcx.types.usize, - ty::Dynamic(_, _, _) => { + ty::Dynamic(_, _, ty::Dyn) => { let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, None); tcx.type_of(dyn_metadata) .instantiate(tcx, &[ty::GenericArg::from(goal.predicate.self_ty())]) |
