-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate projection bounds and predicates #73905
Changes from all commits
0eb87ed
a7ead3b
d297147
f958e6c
87f2f42
b3057f4
5b279c8
1b07991
d4d9e7f
0a76584
2bdf723
042464f
0dda415
21eccbb
8787090
582ccec
f52b2d8
bc08b79
cfee495
34e5a49
596d6c4
0dfa6ff
ed32482
6c4feb6
e297652
d08ab94
e674cf0
e42c979
852073a
27534b3
1db284e
022c148
c9eeb60
69fc6d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
//! the end of the file for details. | ||
|
||
use super::combine::CombineFields; | ||
use super::{HigherRankedType, InferCtxt, PlaceholderMap}; | ||
use super::{HigherRankedType, InferCtxt}; | ||
|
||
use crate::infer::CombinedSnapshot; | ||
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; | ||
|
@@ -33,7 +33,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> { | |
self.infcx.commit_if_ok(|_| { | ||
// First, we instantiate each bound region in the supertype with a | ||
// fresh placeholder region. | ||
let (b_prime, _) = self.infcx.replace_bound_vars_with_placeholders(&b); | ||
let b_prime = self.infcx.replace_bound_vars_with_placeholders(&b); | ||
|
||
// Next, we instantiate each bound region in the subtype | ||
// with a fresh region variable. These region variables -- | ||
|
@@ -66,10 +66,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { | |
/// the [rustc dev guide]. | ||
/// | ||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html | ||
pub fn replace_bound_vars_with_placeholders<T>( | ||
&self, | ||
binder: &ty::Binder<T>, | ||
) -> (T, PlaceholderMap<'tcx>) | ||
pub fn replace_bound_vars_with_placeholders<T>(&self, binder: &ty::Binder<T>) -> T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be another diff worth splitting into a separate PR since it's small and self-contained from what I can see. |
||
where | ||
T: TypeFoldable<'tcx>, | ||
{ | ||
|
@@ -122,7 +119,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { | |
next_universe, binder, result, map, | ||
); | ||
|
||
(result, map) | ||
result | ||
} | ||
|
||
/// See `infer::region_constraints::RegionConstraintCollector::leak_check`. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ use crate::traits::{Obligation, ObligationCause, PredicateObligation}; | |
use rustc_data_structures::fx::FxHashSet; | ||
use rustc_middle::ty::outlives::Component; | ||
use rustc_middle::ty::{self, ToPredicate, TyCtxt, WithConstness}; | ||
use rustc_span::Span; | ||
|
||
pub fn anonymize_predicate<'tcx>( | ||
tcx: TyCtxt<'tcx>, | ||
|
@@ -94,7 +93,11 @@ pub fn elaborate_predicates<'tcx>( | |
tcx: TyCtxt<'tcx>, | ||
predicates: impl Iterator<Item = ty::Predicate<'tcx>>, | ||
) -> Elaborator<'tcx> { | ||
let obligations = predicates.map(|predicate| predicate_obligation(predicate, None)).collect(); | ||
let obligations = predicates | ||
.map(|predicate| { | ||
predicate_obligation(predicate, ty::ParamEnv::empty(), ObligationCause::dummy()) | ||
}) | ||
.collect(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably audit the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like only the predicates from the obligations returned by |
||
elaborate_obligations(tcx, obligations) | ||
} | ||
|
||
|
@@ -109,15 +112,10 @@ pub fn elaborate_obligations<'tcx>( | |
|
||
fn predicate_obligation<'tcx>( | ||
predicate: ty::Predicate<'tcx>, | ||
span: Option<Span>, | ||
param_env: ty::ParamEnv<'tcx>, | ||
cause: ObligationCause<'tcx>, | ||
) -> PredicateObligation<'tcx> { | ||
let cause = if let Some(span) = span { | ||
ObligationCause::dummy_with_span(span) | ||
} else { | ||
ObligationCause::dummy() | ||
}; | ||
|
||
Obligation { cause, param_env: ty::ParamEnv::empty(), recursion_depth: 0, predicate } | ||
Obligation { cause, param_env, recursion_depth: 0, predicate } | ||
} | ||
|
||
impl Elaborator<'tcx> { | ||
|
@@ -133,10 +131,11 @@ impl Elaborator<'tcx> { | |
// Get predicates declared on the trait. | ||
let predicates = tcx.super_predicates_of(data.def_id()); | ||
|
||
let obligations = predicates.predicates.iter().map(|&(pred, span)| { | ||
let obligations = predicates.predicates.iter().map(|&(pred, _)| { | ||
predicate_obligation( | ||
pred.subst_supertrait(tcx, &ty::Binder::bind(data.trait_ref)), | ||
Some(span), | ||
obligation.param_env, | ||
obligation.cause.clone(), | ||
) | ||
}); | ||
debug!("super_predicates: data={:?}", data); | ||
|
@@ -233,7 +232,13 @@ impl Elaborator<'tcx> { | |
}) | ||
.map(|predicate_kind| predicate_kind.to_predicate(tcx)) | ||
.filter(|&predicate| visited.insert(predicate)) | ||
.map(|predicate| predicate_obligation(predicate, None)), | ||
.map(|predicate| { | ||
predicate_obligation( | ||
predicate, | ||
obligation.param_env, | ||
obligation.cause.clone(), | ||
) | ||
}), | ||
); | ||
} | ||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change to this file? Might be better as a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current example doesn't have the right error code any more.