diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-07-12 13:47:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-12 13:47:09 -0700 |
| commit | 4bfc10617a7c7bf1d1fdb08618997838ef828504 (patch) | |
| tree | 751abf6172678623e07f9482f181362842b8302a /compiler/rustc_lint/src | |
| parent | 20cf4eb3b0815dff6f2c4c34fe6a8b843cb5ae4e (diff) | |
| parent | 2c8bbeebf1c630d06e44fa131d1cb0908b5ad56c (diff) | |
| download | rust-4bfc10617a7c7bf1d1fdb08618997838ef828504.tar.gz rust-4bfc10617a7c7bf1d1fdb08618997838ef828504.zip | |
Rollup merge of #127631 - compiler-errors:yeet-fully-norm, r=lcnr
Remove `fully_normalize` Yeet this function and replace it w/ some `ObligationCtxt` instead. It wasn't called very often anyways. r? lcnr
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 5ee73dbfdc6..fdb71ad41a7 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -5,8 +5,7 @@ use rustc_middle::ty::print::{PrintTraitPredicateExt as _, TraitPredPrintModifie use rustc_middle::ty::{self, fold::BottomUpFolder, Ty, TypeFoldable}; use rustc_session::{declare_lint, declare_lint_pass}; use rustc_span::{symbol::kw, Span}; -use rustc_trait_selection::traits; -use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; +use rustc_trait_selection::traits::{self, ObligationCtxt}; use crate::{LateContext, LateLintPass, LintContext}; @@ -130,24 +129,26 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { .iter_instantiated_copied(cx.tcx, proj.projection_term.args) { let assoc_pred = assoc_pred.fold_with(proj_replacer); - let Ok(assoc_pred) = traits::fully_normalize( - infcx, + + let ocx = ObligationCtxt::new(infcx); + let assoc_pred = + ocx.normalize(&traits::ObligationCause::dummy(), cx.param_env, assoc_pred); + if !ocx.select_all_or_error().is_empty() { + // Can't normalize for some reason...? + continue; + } + + ocx.register_obligation(traits::Obligation::new( + cx.tcx, traits::ObligationCause::dummy(), cx.param_env, assoc_pred, - ) else { - continue; - }; + )); // If that predicate doesn't hold modulo regions (but passed during type-check), // then we must've taken advantage of the hack in `project_and_unify_types` where // we replace opaques with inference vars. Emit a warning! - if !infcx.predicate_must_hold_modulo_regions(&traits::Obligation::new( - cx.tcx, - traits::ObligationCause::dummy(), - cx.param_env, - assoc_pred, - )) { + if !ocx.select_all_or_error().is_empty() { // If it's a trait bound and an opaque that doesn't satisfy it, // then we can emit a suggestion to add the bound. let add_bound = match (proj_term.kind(), assoc_pred.kind().skip_binder()) { |
