forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI Test for issue rust-lang#125143
- Loading branch information
1 parent
4ee2fce
commit c4210bb
Showing
2 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
struct X; | ||
|
||
// Test that the error correctly differentiate between the two unnamed lifetimes | ||
impl std::ops::Add<&X> for &X { | ||
type Output = X; | ||
|
||
fn add(self, _rhs: Self) -> Self::Output { | ||
X | ||
} | ||
} | ||
//~^^^^ ERROR method not compatible with trait | ||
|
||
// Test that the error correctly differentiate between named and the unnamed lifetimes | ||
impl<'a> std::ops::Mul<&'a X> for &X { | ||
type Output = X; | ||
|
||
fn mul(self, _rhs: Self) -> Self::Output { | ||
X | ||
} | ||
} | ||
//~^^^^ ERROR method not compatible with trait | ||
|
||
// Test that the error correctly differentiate between named and the unnamed lifetimes | ||
impl<'a> std::ops::Sub<&X> for &'a X { | ||
type Output = X; | ||
|
||
fn sub(self, _rhs: Self) -> Self::Output { | ||
X | ||
} | ||
} | ||
//~^^^^ ERROR method not compatible with trait | ||
|
||
// This should pass since the lifetime subtyping will pass typecheck | ||
impl<'a, 'b> std::ops::Div<&'a X> for &'b X where 'a : 'b { | ||
type Output = X; | ||
|
||
fn div(self, _rhs: Self) -> Self::Output { | ||
X | ||
} | ||
} | ||
|
||
fn main() {} |
60 changes: 60 additions & 0 deletions
60
tests/ui/inference/unnamed-lifetime-span-mixup-125143.stderr
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,60 @@ | ||
error[E0308]: method not compatible with trait | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:7:5 | ||
| | ||
LL | fn add(self, _rhs: Self) -> Self::Output { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ||
| | ||
= note: expected signature `fn(&X, &X) -> X` | ||
found signature `fn(&X, &X) -> X` | ||
note: the anonymous lifetime as defined here... | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:4:20 | ||
| | ||
LL | impl std::ops::Add<&X> for &X { | ||
| ^ | ||
note: ...does not necessarily outlive the anonymous lifetime as defined here | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:4:28 | ||
| | ||
LL | impl std::ops::Add<&X> for &X { | ||
| ^ | ||
|
||
error[E0308]: method not compatible with trait | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:17:5 | ||
| | ||
LL | fn mul(self, _rhs: Self) -> Self::Output { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ||
| | ||
= note: expected signature `fn(&X, &'a X) -> X` | ||
found signature `fn(&X, &X) -> X` | ||
note: the lifetime `'a` as defined here... | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:14:6 | ||
| | ||
LL | impl<'a> std::ops::Mul<&'a X> for &X { | ||
| ^^ | ||
note: ...does not necessarily outlive the anonymous lifetime as defined here | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:14:35 | ||
| | ||
LL | impl<'a> std::ops::Mul<&'a X> for &X { | ||
| ^ | ||
|
||
error[E0308]: method not compatible with trait | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:27:5 | ||
| | ||
LL | fn sub(self, _rhs: Self) -> Self::Output { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ||
| | ||
= note: expected signature `fn(&'a X, &X) -> X` | ||
found signature `fn(&'a X, &'a X) -> X` | ||
note: the anonymous lifetime as defined here... | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:24:24 | ||
| | ||
LL | impl<'a> std::ops::Sub<&X> for &'a X { | ||
| ^ | ||
note: ...does not necessarily outlive the lifetime `'a` as defined here | ||
--> $DIR/unnamed-lifetime-span-mixup-125143.rs:24:6 | ||
| | ||
LL | impl<'a> std::ops::Sub<&X> for &'a X { | ||
| ^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |