Skip to content

Commit c82043e

Browse files
Suppress redundant/wrong error when RTN bound fails to resolve
1 parent 5f955e4 commit c82043e

File tree

5 files changed

+14
-26
lines changed

5 files changed

+14
-26
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

+9
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
558558
Err(guar) => Ty::new_error(tcx, guar),
559559
}
560560
}
561+
hir::QPath::Resolved(
562+
_,
563+
hir::Path { res: Res::Err, segments: [.., item_segment], .. },
564+
) if item_segment.args.is_some_and(|args| {
565+
matches!(args.parenthesized, hir::GenericArgsParentheses::ReturnTypeNotation)
566+
}) =>
567+
{
568+
Ty::new_error_with_message(tcx, hir_ty.span, "bad resolution for RTN")
569+
}
561570
_ => self.lower_ty(hir_ty),
562571
}
563572
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn not_a_method()
66
where
77
function(..): Send,
88
//~^ ERROR expected associated function, found function `function`
9-
//~| ERROR return type notation not allowed in this position yet
109
{
1110
}
1211

@@ -26,7 +25,6 @@ fn maybe_method_overlaps<T: Tr>()
2625
where
2726
method(..): Send,
2827
//~^ ERROR cannot find associated function `method` in this scope
29-
//~| ERROR return type notation not allowed in this position yet
3028
{
3129
}
3230

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

+4-16
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,24 @@ LL | function(..): Send,
55
| ^^^^^^^^^^^^ not a associated function
66

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

1313
error[E0802]: cannot find associated function `method` in this scope
14-
--> $DIR/not-a-method.rs:27:5
14+
--> $DIR/not-a-method.rs:26:5
1515
|
1616
LL | method(..): Send,
1717
| ^^^^^^ not found in this scope
1818

1919
error[E0412]: cannot find type `method` in this scope
20-
--> $DIR/not-a-method.rs:36:5
20+
--> $DIR/not-a-method.rs:34:5
2121
|
2222
LL | method(): Send,
2323
| ^^^^^^ not found in this scope
2424

25-
error: return type notation not allowed in this position yet
26-
--> $DIR/not-a-method.rs:7:5
27-
|
28-
LL | function(..): Send,
29-
| ^^^^^^^^^^^^
30-
31-
error: return type notation not allowed in this position yet
32-
--> $DIR/not-a-method.rs:27:5
33-
|
34-
LL | method(..): Send,
35-
| ^^^^^^^^^^
36-
37-
error: aborting due to 6 previous errors
25+
error: aborting due to 4 previous errors
3826

3927
Some errors have detailed explanations: E0412, E0573, E0801, E0802.
4028
For more information about an error, try `rustc --explain E0412`.

tests/ui/error-codes/E0801.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ fn test()
44
where
55
test(..): Send,
66
//~^ ERROR expected associated function, found function `test`
7-
//~| ERROR return type notation not allowed in this position yet
87
{
98
}
109

tests/ui/error-codes/E0801.stderr

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0801]: expected associated function, found function `test`
44
LL | test(..): Send,
55
| ^^^^^^^^ not a associated function
66

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
7+
error: aborting due to 1 previous error
148

159
For more information about this error, try `rustc --explain E0801`.

0 commit comments

Comments
 (0)