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

Commit 346cf3b

Browse files
committed
Auto merge of rust-lang#137003 - compiler-errors:check-preds-post-mono, r=<try>
Check preds post mono (round 2) r? `@ghost`
2 parents a567209 + 193b93c commit 346cf3b

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

compiler/rustc_monomorphize/src/mono_checks/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! checks in a way that is friendly to incremental compilation.
44
55
use rustc_middle::query::Providers;
6-
use rustc_middle::ty::{Instance, TyCtxt};
6+
use rustc_middle::ty::{Instance, InstanceKind, TyCtxt};
77

88
mod abi_check;
99
mod move_check;
@@ -12,6 +12,11 @@ fn check_mono_item<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
1212
let body = tcx.instance_mir(instance.def);
1313
abi_check::check_feature_dependent_abi(tcx, instance, body);
1414
move_check::check_moves(tcx, instance, body);
15+
if let InstanceKind::Item(def_id) = instance.def {
16+
if tcx.instantiate_and_check_impossible_predicates((def_id, instance.args)) {
17+
tcx.dcx().span_err(tcx.def_span(def_id), "post-mono");
18+
}
19+
}
1520
}
1621

1722
pub(super) fn provide(providers: &mut Providers) {

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,11 @@ where
870870
continue;
871871
}
872872

873+
// Skip RPITITs, since the AFIDT feature means that they are always implied.
874+
if cx.is_impl_trait_in_trait(associated_type_def_id) {
875+
continue;
876+
}
877+
873878
requirements
874879
.extend(cx.item_bounds(associated_type_def_id).iter_instantiated(cx, trait_ref.args));
875880
}

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,11 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>(
703703
/// used during analysis.
704704
pub fn impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, predicates: Vec<ty::Clause<'tcx>>) -> bool {
705705
debug!("impossible_predicates(predicates={:?})", predicates);
706-
let (infcx, param_env) =
707-
tcx.infer_ctxt().build_with_typing_env(ty::TypingEnv::fully_monomorphized());
706+
let (infcx, param_env) = tcx
707+
.infer_ctxt()
708+
.with_next_trait_solver(true)
709+
.build_with_typing_env(ty::TypingEnv::fully_monomorphized());
710+
708711
let ocx = ObligationCtxt::new(&infcx);
709712
let predicates = ocx.normalize(&ObligationCause::dummy(), param_env, predicates);
710713
for predicate in predicates {
@@ -717,13 +720,6 @@ pub fn impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, predicates: Vec<ty::Clause
717720
return true;
718721
}
719722

720-
// Leak check for any higher-ranked trait mismatches.
721-
// We only need to do this in the old solver, since the new solver already
722-
// leak-checks.
723-
if !infcx.next_trait_solver() && infcx.leak_check(ty::UniverseIndex::ROOT, None).is_err() {
724-
return true;
725-
}
726-
727723
false
728724
}
729725

0 commit comments

Comments
 (0)