-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 #131482 - compiler-errors:struct-res, r=lcnr
structurally resolve adts and tuples expectations too r? lcnr
- Loading branch information
Showing
2 changed files
with
34 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,32 @@ | ||
//@ compile-flags: -Znext-solver | ||
//@ check-pass | ||
|
||
// Makes sure we structurally normalize before trying to use expectation to guide | ||
// coercion in adt and tuples. | ||
|
||
use std::any::Any; | ||
|
||
trait Coerce { | ||
type Assoc; | ||
} | ||
|
||
struct TupleGuidance; | ||
impl Coerce for TupleGuidance { | ||
type Assoc = (&'static dyn Any,); | ||
} | ||
|
||
struct AdtGuidance; | ||
impl Coerce for AdtGuidance { | ||
type Assoc = Adt<&'static dyn Any>; | ||
} | ||
|
||
struct Adt<T> { | ||
f: T, | ||
} | ||
|
||
fn foo<'a, T: Coerce>(_: T::Assoc) {} | ||
|
||
fn main() { | ||
foo::<TupleGuidance>((&0u32,)); | ||
foo::<AdtGuidance>(Adt { f: &0u32 }); | ||
} |