-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that we never try to monomorphize the upcasting of impossible …
…dyn types
- Loading branch information
1 parent
8a460d3
commit 041296d
Showing
2 changed files
with
46 additions
and
4 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
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,24 @@ | ||
#![feature(trait_upcasting)] | ||
|
||
trait Supertrait<T> { | ||
fn method(&self) {} | ||
} | ||
impl<T> Supertrait<T> for () {} | ||
|
||
trait WithAssoc { | ||
type Assoc; | ||
} | ||
trait Trait<P: WithAssoc>: Supertrait<P::Assoc> + Supertrait<()> {} | ||
|
||
fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> { | ||
x | ||
} | ||
|
||
fn call<P>(x: &dyn Trait<P>) { | ||
x.method(); | ||
} | ||
|
||
fn main() { | ||
println!("{:p}", upcast::<()> as *const ()); | ||
println!("{:p}", call::<()> as *const ()); | ||
} |