about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-27 08:46:55 +0200
committerGitHub <noreply@github.com>2023-03-27 08:46:55 +0200
commit6535e66fa545acaa3c0fe015b83a2e502c10119a (patch)
tree8d982b4a968c7447561287a1ad00324ba8f0cf1c /compiler/rustc_lint/src
parent2b7dc94535e2b4f922091ee1834e21a7d18ba4bf (diff)
parent1ce4b37900cf0c7f5e146b866b5a8fae2b93f9fc (diff)
downloadrust-6535e66fa545acaa3c0fe015b83a2e502c10119a.tar.gz
rust-6535e66fa545acaa3c0fe015b83a2e502c10119a.zip
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.
Diffstat (limited to 'compiler/rustc_lint/src')
-rw-r--r--compiler/rustc_lint/src/unused.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs
index faca61fc29b..42e59f92840 100644
--- a/compiler/rustc_lint/src/unused.rs
+++ b/compiler/rustc_lint/src/unused.rs
@@ -258,11 +258,11 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
                         cx.tcx,
                         cx.tcx.explicit_item_bounds(def).iter().cloned(),
                     )
-                    .find_map(|obligation| {
+                    .find_map(|(pred, _span)| {
                         // We only look at the `DefId`, so it is safe to skip the binder here.
                         if let ty::PredicateKind::Clause(ty::Clause::Trait(
                             ref poly_trait_predicate,
-                        )) = obligation.predicate.kind().skip_binder()
+                        )) = pred.kind().skip_binder()
                         {
                             let def_id = poly_trait_predicate.trait_ref.def_id;