Skip to content

Commit 4a0969e

Browse files
committed
Auto merge of #140682 - GuillaumeGomez:rollup-6xjf6zn, r=GuillaumeGomez
Rollup of 11 pull requests Successful merges: - #140080 (mir-opt: Use one MirPatch in MatchBranchSimplification) - #140115 (mir-opt: execute MatchBranchSimplification after GVN) - #140357 (bypass linker configuration and cross target check on `x check`) - #140374 (Resolve instance for SymFn in global/naked asm) - #140559 (Removing rustc_type_ir in the rustc_infer codebase) - #140605 (`fn check_opaque_type_parameter_valid` defer error) - #140636 (implement `PanicTracker` to track `t` panics) - #140661 (Make `-Zfixed-x18` into a target modifier) - #140670 (calculate step duration in a panic-safe way) - #140672 (Deeply normalize in the new solver in WF) - #140676 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2e6882a + 2a882f7 commit 4a0969e

File tree

75 files changed

+520
-280
lines changed

Some content is hidden

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

75 files changed

+520
-280
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4515,6 +4515,7 @@ dependencies = [
45154515
"rustc_session",
45164516
"rustc_span",
45174517
"rustc_transmute",
4518+
"rustc_type_ir",
45184519
"smallvec",
45194520
"thin-vec",
45204521
"tracing",

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,13 @@ impl<'tcx> InferCtxt<'tcx> {
267267
return Ty::new_error(self.tcx, e);
268268
}
269269

270-
if let Err(guar) = check_opaque_type_parameter_valid(
270+
if let Err(err) = check_opaque_type_parameter_valid(
271271
self,
272272
opaque_type_key,
273273
instantiated_ty.span,
274274
DefiningScopeKind::MirBorrowck,
275275
) {
276-
return Ty::new_error(self.tcx, guar);
276+
return Ty::new_error(self.tcx, err.report(self));
277277
}
278278

279279
let definition_ty = instantiated_ty

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
12821282
intrinsic.name,
12831283
);
12841284
}
1285-
return Err(Instance::new(instance.def_id(), instance.args));
1285+
return Err(Instance::new_raw(instance.def_id(), instance.args));
12861286
}
12871287
}
12881288

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
399399
}
400400

401401
// Fall back to default body
402-
_ => return Err(Instance::new(instance.def_id(), instance.args)),
402+
_ => return Err(Instance::new_raw(instance.def_id(), instance.args)),
403403
};
404404

405405
if !fn_abi.ret.is_ignore() {

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn make_dummy_instance<'tcx>(tcx: TyCtxt<'tcx>, local_def_id: LocalDefId) -> ty:
157157
let def_id = local_def_id.to_def_id();
158158

159159
// Make a dummy instance that fills in all generics with placeholders.
160-
ty::Instance::new(
160+
ty::Instance::new_raw(
161161
def_id,
162162
ty::GenericArgs::for_item(tcx, def_id, |param, _| {
163163
if let ty::GenericParamDefKind::Lifetime = param.kind {

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
613613
_ => {
614614
debug!("unknown intrinsic '{}' -- falling back to default body", name);
615615
// Call the fallback body instead of generating the intrinsic code
616-
return Err(ty::Instance::new(instance.def_id(), instance.args));
616+
return Err(ty::Instance::new_raw(instance.def_id(), instance.args));
617617
}
618618
};
619619

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ pub(crate) fn symbol_name_for_instance_in_crate<'tcx>(
612612
ExportedSymbol::Generic(def_id, args) => {
613613
rustc_symbol_mangling::symbol_name_for_instance_in_crate(
614614
tcx,
615-
Instance::new(def_id, args),
615+
Instance::new_raw(def_id, args),
616616
instantiating_crate,
617617
)
618618
}
@@ -660,7 +660,7 @@ fn calling_convention_for_symbol<'tcx>(
660660
None
661661
}
662662
ExportedSymbol::NonGeneric(def_id) => Some(Instance::mono(tcx, def_id)),
663-
ExportedSymbol::Generic(def_id, args) => Some(Instance::new(def_id, args)),
663+
ExportedSymbol::Generic(def_id, args) => Some(Instance::new_raw(def_id, args)),
664664
// DropGlue always use the Rust calling convention and thus follow the target's default
665665
// symbol decoration scheme.
666666
ExportedSymbol::DropGlue(..) => None,

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,13 @@ where
457457
rustc_hir::InlineAsmOperand::SymFn { expr } => {
458458
let ty = cx.tcx().typeck(item_id.owner_id).expr_ty(expr);
459459
let instance = match ty.kind() {
460-
&ty::FnDef(def_id, args) => Instance::new(def_id, args),
460+
&ty::FnDef(def_id, args) => Instance::expect_resolve(
461+
cx.tcx(),
462+
ty::TypingEnv::fully_monomorphized(),
463+
def_id,
464+
args,
465+
expr.span,
466+
),
461467
_ => span_bug!(*op_sp, "asm sym is not a function"),
462468
};
463469

compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ fn inline_to_global_operand<'a, 'tcx, Cx: LayoutOf<'tcx, LayoutOfResult = TyAndL
9595
);
9696

9797
let instance = match mono_type.kind() {
98-
&ty::FnDef(def_id, args) => Instance::new(def_id, args),
98+
&ty::FnDef(def_id, args) => {
99+
Instance::expect_resolve(cx.tcx(), cx.typing_env(), def_id, args, value.span)
100+
}
99101
_ => bug!("asm sym is not a function"),
100102
};
101103

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
7676
)
7777
}
7878

79+
/// Convenience function to *deeply* normalize during wfcheck. In the old solver,
80+
/// this just dispatches to [`WfCheckingCtxt::normalize`], but in the new solver
81+
/// this calls `deeply_normalize` and reports errors if they are encountered.
82+
///
83+
/// This function should be called in favor of `normalize` in cases where we will
84+
/// then check the well-formedness of the type, since we only use the normalized
85+
/// signature types for implied bounds when checking regions.
86+
// FIXME(-Znext-solver): This should be removed when we compute implied outlives
87+
// bounds using the unnormalized signature of the function we're checking.
88+
fn deeply_normalize<T>(&self, span: Span, loc: Option<WellFormedLoc>, value: T) -> T
89+
where
90+
T: TypeFoldable<TyCtxt<'tcx>>,
91+
{
92+
if self.infcx.next_trait_solver() {
93+
match self.ocx.deeply_normalize(
94+
&ObligationCause::new(span, self.body_def_id, ObligationCauseCode::WellFormed(loc)),
95+
self.param_env,
96+
value.clone(),
97+
) {
98+
Ok(value) => value,
99+
Err(errors) => {
100+
self.infcx.err_ctxt().report_fulfillment_errors(errors);
101+
value
102+
}
103+
}
104+
} else {
105+
self.normalize(span, loc, value)
106+
}
107+
}
108+
79109
fn register_wf_obligation(&self, span: Span, loc: Option<WellFormedLoc>, term: ty::Term<'tcx>) {
80110
let cause = traits::ObligationCause::new(
81111
span,
@@ -297,7 +327,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
297327
{
298328
let res = enter_wf_checking_ctxt(tcx, item.span, def_id, |wfcx| {
299329
let ty = tcx.type_of(def_id).instantiate_identity();
300-
let item_ty = wfcx.normalize(hir_ty.span, Some(WellFormedLoc::Ty(def_id)), ty);
330+
let item_ty =
331+
wfcx.deeply_normalize(hir_ty.span, Some(WellFormedLoc::Ty(def_id)), ty);
301332
wfcx.register_wf_obligation(
302333
hir_ty.span,
303334
Some(WellFormedLoc::Ty(def_id)),
@@ -1073,7 +1104,7 @@ fn check_associated_item(
10731104
match item.kind {
10741105
ty::AssocKind::Const { .. } => {
10751106
let ty = tcx.type_of(item.def_id).instantiate_identity();
1076-
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
1107+
let ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
10771108
wfcx.register_wf_obligation(span, loc, ty.into());
10781109
check_sized_if_body(
10791110
wfcx,
@@ -1102,7 +1133,7 @@ fn check_associated_item(
11021133
}
11031134
if item.defaultness(tcx).has_value() {
11041135
let ty = tcx.type_of(item.def_id).instantiate_identity();
1105-
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
1136+
let ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
11061137
wfcx.register_wf_obligation(span, loc, ty.into());
11071138
}
11081139
Ok(())
@@ -1149,7 +1180,7 @@ fn check_type_defn<'tcx>(
11491180
let field_id = field.did.expect_local();
11501181
let hir::FieldDef { ty: hir_ty, .. } =
11511182
tcx.hir_node_by_def_id(field_id).expect_field();
1152-
let ty = wfcx.normalize(
1183+
let ty = wfcx.deeply_normalize(
11531184
hir_ty.span,
11541185
None,
11551186
tcx.type_of(field.did).instantiate_identity(),
@@ -1310,7 +1341,7 @@ fn check_item_type(
13101341

13111342
enter_wf_checking_ctxt(tcx, ty_span, item_id, |wfcx| {
13121343
let ty = tcx.type_of(item_id).instantiate_identity();
1313-
let item_ty = wfcx.normalize(ty_span, Some(WellFormedLoc::Ty(item_id)), ty);
1344+
let item_ty = wfcx.deeply_normalize(ty_span, Some(WellFormedLoc::Ty(item_id)), ty);
13141345

13151346
let forbid_unsized = match unsized_handling {
13161347
UnsizedHandling::Forbid => true,
@@ -1375,7 +1406,7 @@ fn check_impl<'tcx>(
13751406
// other `Foo` impls are incoherent.
13761407
tcx.ensure_ok().coherent_trait(trait_ref.def_id)?;
13771408
let trait_span = hir_trait_ref.path.span;
1378-
let trait_ref = wfcx.normalize(
1409+
let trait_ref = wfcx.deeply_normalize(
13791410
trait_span,
13801411
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
13811412
trait_ref,
@@ -1435,7 +1466,7 @@ fn check_impl<'tcx>(
14351466
}
14361467
None => {
14371468
let self_ty = tcx.type_of(item.owner_id).instantiate_identity();
1438-
let self_ty = wfcx.normalize(
1469+
let self_ty = wfcx.deeply_normalize(
14391470
item.span,
14401471
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
14411472
self_ty,
@@ -1640,7 +1671,7 @@ fn check_fn_or_method<'tcx>(
16401671

16411672
sig.inputs_and_output =
16421673
tcx.mk_type_list_from_iter(sig.inputs_and_output.iter().enumerate().map(|(idx, ty)| {
1643-
wfcx.normalize(
1674+
wfcx.deeply_normalize(
16441675
arg_span(idx),
16451676
Some(WellFormedLoc::Param {
16461677
function: def_id,

0 commit comments

Comments
 (0)