Rollup merge of #109641 - compiler-errors:dont-elaborate-non-obl, r=oli-obk
Don't elaborate non-obligations into obligations It's suspicious to elaborate a `PolyTraitRef` or `Predicate` into an `Obligation`, since the former does not have a param-env associated with it, but the latter does. This is a footgun that, while not being misused *currently* in the compiler, easily could be misused by someone less familiar with the elaborator's inner workings. This PR just changes the API -- ideally, the elaborator wouldn't even have to deal with obligations if we're not elaborating obligations, but that would require a bit more abstraction than I could be bothered with today.
This commit is contained in:
commit
6535e66fa5
20 changed files with 112 additions and 131 deletions
|
|
@ -124,9 +124,9 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
|||
|
||||
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds().iter())
|
||||
.filter(|p| !p.is_global())
|
||||
.filter_map(|obligation| {
|
||||
.filter_map(|pred| {
|
||||
// Note that we do not want to deal with qualified predicates here.
|
||||
match obligation.predicate.kind().no_bound_vars() {
|
||||
match pred.kind().no_bound_vars() {
|
||||
Some(ty::PredicateKind::Clause(ty::Clause::Trait(pred))) if pred.def_id() != sized_trait => {
|
||||
Some(pred)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2106,7 +2106,6 @@ pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool {
|
|||
traits::impossible_predicates(
|
||||
cx.tcx,
|
||||
traits::elaborate_predicates(cx.tcx, predicates)
|
||||
.map(|o| o.predicate)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue