Leak check in impossible_predicates to avoid monomorphizing impossible instances
This commit is contained in:
parent
2ae9916816
commit
377dbc96a6
3 changed files with 91 additions and 3 deletions
|
@ -0,0 +1,40 @@
|
|||
//@ build-pass
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
trait Foo {}
|
||||
impl Foo for fn(&'static ()) {}
|
||||
|
||||
trait Bar {
|
||||
type Assoc: Default;
|
||||
}
|
||||
impl<T: Foo> Bar for T {
|
||||
type Assoc = usize;
|
||||
}
|
||||
impl Bar for fn(&()) {
|
||||
type Assoc = ();
|
||||
}
|
||||
|
||||
fn needs_foo<T: Foo>() -> usize {
|
||||
needs_bar::<T>()
|
||||
}
|
||||
|
||||
fn needs_bar<T: Bar>() -> <T as Bar>::Assoc {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
trait Evil<T> {
|
||||
fn bad(&self)
|
||||
where
|
||||
T: Foo,
|
||||
{
|
||||
needs_foo::<T>();
|
||||
}
|
||||
}
|
||||
|
||||
impl Evil<fn(&())> for () {}
|
||||
|
||||
fn main() {
|
||||
let x: &dyn Evil<fn(&())> = &();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue