Skip to content

Commit 83c5b4e

Browse files
committed
Avoid output dependency on std spans
1 parent 8d316a5 commit 83c5b4e

File tree

4 files changed

+60
-67
lines changed

4 files changed

+60
-67
lines changed

src/test/ui/issues/issue-21950.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
use std::ops::Add;
1+
trait Add<Rhs=Self> {
2+
type Output;
3+
}
4+
5+
impl Add for i32 {
6+
type Output = i32;
7+
}
28

39
fn main() {
4-
let x = &10 as
5-
&dyn Add;
6-
//~^ ERROR E0393
7-
//~| ERROR E0191
10+
let x = &10 as &dyn Add;
11+
//~^ ERROR E0393
12+
//~| ERROR E0191
813
}

src/test/ui/issues/issue-21950.stderr

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
error[E0393]: the type parameter `Rhs` must be explicitly specified
2-
--> $DIR/issue-21950.rs:5:18
2+
--> $DIR/issue-21950.rs:10:25
33
|
4-
LL | &dyn Add;
5-
| ^^^ help: set the type parameter to the desired type: `Add<Rhs>`
6-
|
7-
::: $SRC_DIR/libcore/ops/arith.rs:LL:COL
8-
|
9-
LL | / pub trait Add<Rhs = Self> {
10-
LL | | /// The resulting type after applying the `+` operator.
11-
LL | | #[stable(feature = "rust1", since = "1.0.0")]
4+
LL | / trait Add<Rhs=Self> {
125
LL | | type Output;
13-
... |
14-
LL | | fn add(self, rhs: Rhs) -> Self::Output;
156
LL | | }
167
| |_- type parameter `Rhs` must be specified for this
8+
...
9+
LL | let x = &10 as &dyn Add;
10+
| ^^^ help: set the type parameter to the desired type: `Add<Rhs>`
1711
|
1812
= note: because of the default `Self` reference, type parameters must be specified on object types
1913

20-
error[E0191]: the value of the associated type `Output` (from trait `std::ops::Add`) must be specified
21-
--> $DIR/issue-21950.rs:5:18
14+
error[E0191]: the value of the associated type `Output` (from trait `Add`) must be specified
15+
--> $DIR/issue-21950.rs:10:25
2216
|
23-
LL | &dyn Add;
24-
| ^^^ help: specify the associated type: `Add<Output = Type>`
17+
LL | type Output;
18+
| ------------ `Output` defined here
19+
...
20+
LL | let x = &10 as &dyn Add;
21+
| ^^^ help: specify the associated type: `Add<Output = Type>`
2522

2623
error: aborting due to 2 previous errors
2724

src/test/ui/issues/issue-22560.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
use std::ops::{Add, Sub};
1+
trait Add<Rhs=Self> {
2+
type Output;
3+
}
24

3-
type Test = dyn Add +
4-
//~^ ERROR E0393
5-
//~| ERROR E0191
6-
Sub;
7-
//~^ ERROR E0393
8-
//~| ERROR E0225
5+
trait Sub<Rhs=Self> {
6+
type Output;
7+
}
8+
9+
type Test = dyn Add + Sub;
10+
//~^ ERROR E0393
11+
//~| ERROR E0191
12+
//~| ERROR E0393
13+
//~| ERROR E0225
914

1015
fn main() { }

src/test/ui/issues/issue-22560.stderr

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,51 @@
11
error[E0393]: the type parameter `Rhs` must be explicitly specified
2-
--> $DIR/issue-22560.rs:6:13
2+
--> $DIR/issue-22560.rs:9:23
33
|
4-
LL | Sub;
5-
| ^^^ help: set the type parameter to the desired type: `Sub<Rhs>`
6-
|
7-
::: $SRC_DIR/libcore/ops/arith.rs:LL:COL
8-
|
9-
LL | / pub trait Sub<Rhs = Self> {
10-
LL | | /// The resulting type after applying the `-` operator.
11-
LL | | #[stable(feature = "rust1", since = "1.0.0")]
4+
LL | / trait Sub<Rhs=Self> {
125
LL | | type Output;
13-
... |
14-
LL | | fn sub(self, rhs: Rhs) -> Self::Output;
156
LL | | }
167
| |_- type parameter `Rhs` must be specified for this
8+
LL |
9+
LL | type Test = dyn Add + Sub;
10+
| ^^^ help: set the type parameter to the desired type: `Sub<Rhs>`
1711
|
1812
= note: because of the default `Self` reference, type parameters must be specified on object types
1913

2014
error[E0393]: the type parameter `Rhs` must be explicitly specified
21-
--> $DIR/issue-22560.rs:3:17
22-
|
23-
LL | type Test = dyn Add +
24-
| ^^^ help: set the type parameter to the desired type: `Add<Rhs>`
25-
|
26-
::: $SRC_DIR/libcore/ops/arith.rs:LL:COL
15+
--> $DIR/issue-22560.rs:9:17
2716
|
28-
LL | / pub trait Add<Rhs = Self> {
29-
LL | | /// The resulting type after applying the `+` operator.
30-
LL | | #[stable(feature = "rust1", since = "1.0.0")]
17+
LL | / trait Add<Rhs=Self> {
3118
LL | | type Output;
32-
... |
33-
LL | | fn add(self, rhs: Rhs) -> Self::Output;
3419
LL | | }
3520
| |_- type parameter `Rhs` must be specified for this
21+
...
22+
LL | type Test = dyn Add + Sub;
23+
| ^^^ help: set the type parameter to the desired type: `Add<Rhs>`
3624
|
3725
= note: because of the default `Self` reference, type parameters must be specified on object types
3826

3927
error[E0225]: only auto traits can be used as additional traits in a trait object
40-
--> $DIR/issue-22560.rs:6:13
28+
--> $DIR/issue-22560.rs:9:23
4129
|
42-
LL | type Test = dyn Add +
43-
| ---
44-
| |
30+
LL | type Test = dyn Add + Sub;
31+
| --- ^^^
32+
| | |
33+
| | additional non-auto trait
34+
| | trait alias used in trait object type (additional use)
4535
| first non-auto trait
4636
| trait alias used in trait object type (first use)
47-
...
48-
LL | Sub;
49-
| ^^^
50-
| |
51-
| additional non-auto trait
52-
| trait alias used in trait object type (additional use)
5337

54-
error[E0191]: the value of the associated types `Output` (from trait `std::ops::Add`), `Output` (from trait `std::ops::Sub`) must be specified
55-
--> $DIR/issue-22560.rs:3:13
38+
error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified
39+
--> $DIR/issue-22560.rs:9:13
5640
|
57-
LL | type Test = dyn Add +
58-
| _____________^
59-
LL | |
60-
LL | |
61-
LL | | Sub;
62-
| |_______________^ associated types `Output`, `Output` must be specified
41+
LL | type Output;
42+
| ------------ `Output` defined here
43+
...
44+
LL | type Output;
45+
| ------------ `Output` defined here
46+
...
47+
LL | type Test = dyn Add + Sub;
48+
| ^^^^^^^^^^^^^ associated types `Output`, `Output` must be specified
6349

6450
error: aborting due to 4 previous errors
6551

0 commit comments

Comments
 (0)