Skip to content

Avoid reporting overflow in is_impossible_method #100705

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

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,16 @@ fn is_impossible_method<'tcx>(
});

tcx.infer_ctxt().ignoring_regions().enter(|ref infcx| {
let mut fulfill_ctxt = <dyn TraitEngine<'_>>::new(tcx);
fulfill_ctxt.register_predicate_obligations(infcx, predicates_for_trait);
!fulfill_ctxt.select_all_or_error(infcx).is_empty()
for obligation in predicates_for_trait {
// Ignore overflow error, to be conservative.
if let Ok(result) = infcx.evaluate_obligation(&obligation)
&& !result.may_apply()
{
return true;
}
}

false
})
}

Expand Down
19 changes: 19 additions & 0 deletions src/test/rustdoc/issue-100620.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pub trait Bar<S> {}

pub trait Qux<T> {}

pub trait Foo<T, S> {
fn bar()
where
T: Bar<S>,
{
}
}

pub struct Concrete;

impl<S> Foo<(), S> for Concrete {}

impl<T, S> Bar<S> for T where S: Qux<T> {}

impl<T, S> Qux<T> for S where T: Bar<S> {}