mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Rework find_super_trait_path to protect against cycles
This commit is contained in:
parent
c200025794
commit
3e106c77ff
5 changed files with 74 additions and 23 deletions
|
@ -622,6 +622,44 @@ fn test() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coerce_unsize_super_trait_cycle() {
|
||||
assert_snapshot!(
|
||||
infer_with_mismatches(r#"
|
||||
#[lang = "unsize"]
|
||||
pub trait Unsize<T> {}
|
||||
#[lang = "coerce_unsized"]
|
||||
pub trait CoerceUnsized<T> {}
|
||||
|
||||
impl<T: Unsize<U>, U> CoerceUnsized<&U> for &T {}
|
||||
|
||||
trait A {}
|
||||
trait B: C + A {}
|
||||
trait C: B {}
|
||||
trait D: C
|
||||
|
||||
struct S;
|
||||
impl A for S {}
|
||||
impl B for S {}
|
||||
impl C for S {}
|
||||
impl D for S {}
|
||||
|
||||
fn test() {
|
||||
let obj: &dyn D = &S;
|
||||
let obj: &dyn A = obj;
|
||||
}
|
||||
"#, true),
|
||||
@r###"
|
||||
[292; 348) '{ ...obj; }': ()
|
||||
[302; 305) 'obj': &dyn D
|
||||
[316; 318) '&S': &S
|
||||
[317; 318) 'S': S
|
||||
[328; 331) 'obj': &dyn A
|
||||
[342; 345) 'obj': &dyn D
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn coerce_unsize_generic() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue