Skip to content

Commit e9b96c0

Browse files
Split out RTN resolver errors into new error codes
1 parent 360f7d7 commit e9b96c0

File tree

10 files changed

+99
-9
lines changed

10 files changed

+99
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Something other than an associated function has been used when one was
2+
expected.
3+
4+
Erroneous code example:
5+
6+
```compile_fail,E0801
7+
#![feature(return_type_notation)]
8+
9+
const FOO: i32 = 0;
10+
11+
fn test()
12+
where
13+
FOO(..): Send,
14+
{
15+
}
16+
```
17+
18+
In the given example, within the where clause `FOO(..): Send`, `FOO` resolves
19+
to a const when only trait methods are supported with return-type notation.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
An associated function of the given name is not in scope.
2+
3+
Erroneous code examples:
4+
5+
```compile_fail,E0802
6+
#![feature(return_type_notation)]
7+
8+
type Trait {}
9+
10+
fn test<T: Trait>()
11+
where
12+
T::method(..): Send,
13+
{
14+
}
15+
```
16+
17+
To fix this error, please verify you didn't misspell the associate function
18+
name, or double-check if you forgot to declare the parameter in the list of
19+
generics.

compiler/rustc_error_codes/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ E0797: 0797,
540540
E0798: 0798,
541541
E0799: 0799,
542542
E0800: 0800,
543+
E0801: 0801,
544+
E0802: 0802,
543545
);
544546
)
545547
}

compiler/rustc_resolve/src/late.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ impl<'a> PathSource<'a> {
475475
},
476476
_ => "value",
477477
},
478-
PathSource::ReturnTypeNotation | PathSource::Delegation => "function",
478+
PathSource::Delegation => "function",
479+
PathSource::ReturnTypeNotation => "associated function",
479480
PathSource::PreciseCapturingArg(..) => "type or const parameter",
480481
}
481482
}
@@ -573,10 +574,12 @@ impl<'a> PathSource<'a> {
573574
(PathSource::Expr(..), false) | (PathSource::Delegation, false) => E0425,
574575
(PathSource::Pat | PathSource::TupleStruct(..), true) => E0532,
575576
(PathSource::Pat | PathSource::TupleStruct(..), false) => E0531,
576-
(PathSource::TraitItem(..), true) | (PathSource::ReturnTypeNotation, true) => E0575,
577-
(PathSource::TraitItem(..), false) | (PathSource::ReturnTypeNotation, false) => E0576,
577+
(PathSource::TraitItem(..), true) => E0575,
578+
(PathSource::TraitItem(..), false) => E0576,
578579
(PathSource::PreciseCapturingArg(..), true) => E0799,
579580
(PathSource::PreciseCapturingArg(..), false) => E0800,
581+
(PathSource::ReturnTypeNotation, true) => E0801,
582+
(PathSource::ReturnTypeNotation, false) => E0802,
580583
}
581584
}
582585
}

tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn function() {}
55
fn not_a_method()
66
where
77
function(..): Send,
8-
//~^ ERROR expected function, found function `function`
8+
//~^ ERROR expected associated function, found function `function`
99
//~| ERROR return type notation not allowed in this position yet
1010
{
1111
}
@@ -25,7 +25,7 @@ trait Tr {
2525
fn maybe_method_overlaps<T: Tr>()
2626
where
2727
method(..): Send,
28-
//~^ ERROR cannot find function `method` in this scope
28+
//~^ ERROR cannot find associated function `method` in this scope
2929
//~| ERROR return type notation not allowed in this position yet
3030
{
3131
}

tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
error[E0575]: expected function, found function `function`
1+
error[E0801]: expected associated function, found function `function`
22
--> $DIR/not-a-method.rs:7:5
33
|
44
LL | function(..): Send,
5-
| ^^^^^^^^^^^^ not a function
5+
| ^^^^^^^^^^^^ not a associated function
66

77
error[E0573]: expected type, found function `function`
88
--> $DIR/not-a-method.rs:15:5
99
|
1010
LL | function(): Send,
1111
| ^^^^^^^^^^ not a type
1212

13-
error[E0576]: cannot find function `method` in this scope
13+
error[E0802]: cannot find associated function `method` in this scope
1414
--> $DIR/not-a-method.rs:27:5
1515
|
1616
LL | method(..): Send,
@@ -36,5 +36,5 @@ LL | method(..): Send,
3636

3737
error: aborting due to 6 previous errors
3838

39-
Some errors have detailed explanations: E0412, E0573, E0575, E0576.
39+
Some errors have detailed explanations: E0412, E0573, E0801, E0802.
4040
For more information about an error, try `rustc --explain E0412`.

tests/ui/error-codes/E0801.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(return_type_notation)]
2+
3+
fn test()
4+
where
5+
test(..): Send,
6+
//~^ ERROR expected associated function, found function `test`
7+
//~| ERROR return type notation not allowed in this position yet
8+
{
9+
}
10+
11+
fn main() {}

tests/ui/error-codes/E0801.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0801]: expected associated function, found function `test`
2+
--> $DIR/E0801.rs:5:5
3+
|
4+
LL | test(..): Send,
5+
| ^^^^^^^^ not a associated function
6+
7+
error: return type notation not allowed in this position yet
8+
--> $DIR/E0801.rs:5:5
9+
|
10+
LL | test(..): Send,
11+
| ^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0801`.

tests/ui/error-codes/E0802.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(return_type_notation)]
2+
3+
trait Trait {}
4+
5+
fn test<T: Trait>()
6+
where
7+
T::method(..): Send,
8+
//~^ ERROR associated function `method` not found for `T`
9+
{
10+
}
11+
12+
fn main() {}

tests/ui/error-codes/E0802.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0220]: associated function `method` not found for `T`
2+
--> $DIR/E0802.rs:7:8
3+
|
4+
LL | T::method(..): Send,
5+
| ^^^^^^ associated function `method` not found
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0220`.

0 commit comments

Comments
 (0)