Skip to content

Commit 7217c22

Browse files
Update trait_duplication_in_bounds.rs ui test to add regression for ##9961
1 parent 169e2ab commit 7217c22

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

tests/ui/trait_duplication_in_bounds.fixed

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,33 @@ fn bad_trait_object(arg0: &(dyn Any + Send)) {
118118
unimplemented!();
119119
}
120120

121-
fn main() {}
121+
trait Proj {
122+
type S;
123+
}
124+
125+
impl Proj for () {
126+
type S = ();
127+
}
128+
129+
impl Proj for i32 {
130+
type S = i32;
131+
}
132+
133+
trait Base<T> {
134+
fn is_base(&self);
135+
}
136+
137+
trait Derived<B: Proj>: Base<B::S> + Base<()> {
138+
fn is_derived(&self);
139+
}
140+
141+
fn f<P: Proj>(obj: &dyn Derived<P>) {
142+
obj.is_derived();
143+
Base::<P::S>::is_base(obj);
144+
Base::<()>::is_base(obj);
145+
}
146+
147+
fn main() {
148+
let _x: fn(_) = f::<()>;
149+
let _x: fn(_) = f::<i32>;
150+
}

tests/ui/trait_duplication_in_bounds.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,33 @@ fn bad_trait_object(arg0: &(dyn Any + Send + Send)) {
118118
unimplemented!();
119119
}
120120

121-
fn main() {}
121+
trait Proj {
122+
type S;
123+
}
124+
125+
impl Proj for () {
126+
type S = ();
127+
}
128+
129+
impl Proj for i32 {
130+
type S = i32;
131+
}
132+
133+
trait Base<T> {
134+
fn is_base(&self);
135+
}
136+
137+
trait Derived<B: Proj>: Base<B::S> + Base<()> {
138+
fn is_derived(&self);
139+
}
140+
141+
fn f<P: Proj>(obj: &dyn Derived<P>) {
142+
obj.is_derived();
143+
Base::<P::S>::is_base(obj);
144+
Base::<()>::is_base(obj);
145+
}
146+
147+
fn main() {
148+
let _x: fn(_) = f::<()>;
149+
let _x: fn(_) = f::<i32>;
150+
}

0 commit comments

Comments
 (0)