-
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.
- Loading branch information
1 parent
f82eb4d
commit 59a3c4e
Showing
2 changed files
with
48 additions
and
2 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,45 @@ | ||
//@ needs-sanitizer-cfi | ||
//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi | ||
//@ no-prefer-dynamic | ||
//@ only-x86_64-unknown-linux-gnu | ||
//@ build-pass | ||
|
||
// See comment below for why this test exists. | ||
|
||
trait Tr<U> { | ||
type Projection; | ||
} | ||
|
||
impl<F, U> Tr<U> for F | ||
where | ||
F: Fn() -> U | ||
{ | ||
type Projection = U; | ||
} | ||
|
||
fn test<B: Tr<U>, U>(b: B) -> B::Projection | ||
{ | ||
todo!() | ||
} | ||
|
||
fn main() { | ||
fn rpit_fn() -> impl Sized {} | ||
|
||
// When CFI runs, it tries to to compute the signature of the call. This | ||
// ends up giving us a signature of: | ||
// `fn test::<rpit_fn, ()>() -> <rpit_fn as Tr<()>>::Projection`, | ||
// where `rpit_fn` is the ZST FnDef for the function. However, we were | ||
// previously using a Reveal::UserFacing param-env. This means that the | ||
// `<rpit_fn as Tr<()>>::Projection` return type is impossible to normalize, | ||
// since it would require proving `rpit_fn: Fn() -> ()`, but we cannot | ||
// prove that the `impl Sized` opaque is `()` with a user-facing param-env. | ||
// This leads to a normalization error, and then an ICE. | ||
// | ||
// Side-note: | ||
// So why is the second generic of `test` "`()`", and not the | ||
// `impl Sized` since we inferred it from the return type of | ||
// `rpit_fn` during typeck? Well, that's because we're using the generics | ||
// from the terminator of the MIR, which has already had the RevealAll pass | ||
// done on it. | ||
let _ = test(rpit_fn); | ||
} |