forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#135466 - compiler-errors:leak-check-impossi…
…ble, r=lcnr Leak check in `impossible_predicates` to avoid monomorphizing impossible instances Fixes rust-lang#135462 r? lcnr
- Loading branch information
Showing
3 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tests/ui/traits/trait-upcasting/impossible-method-modulo-binders-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//@ build-pass | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
// Regression test for #135462. | ||
#![allow(coherence_leak_check)] | ||
|
||
type A = fn(&'static ()); | ||
type B = fn(&()); | ||
|
||
trait Bound<P: WithAssoc>: From<GetAssoc<P>> { | ||
} | ||
impl Bound<B> for String {} | ||
|
||
trait Trt<T> { | ||
fn __(&self, x: T) where T: Bound<A> { | ||
T::from(()); | ||
} | ||
} | ||
|
||
impl<T, S> Trt<T> for S {} | ||
|
||
type GetAssoc<T> = <T as WithAssoc>::Ty; | ||
|
||
trait WithAssoc { | ||
type Ty; | ||
} | ||
|
||
impl WithAssoc for B { | ||
type Ty = String; | ||
} | ||
|
||
impl WithAssoc for A { | ||
type Ty = (); | ||
} | ||
|
||
fn main() { | ||
let x: &'static dyn Trt<String> = &(); | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/ui/traits/trait-upcasting/impossible-method-modulo-binders.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(&())> = &(); | ||
} |