Skip to content

Commit

Permalink
Suppress redundant/wrong error when RTN bound fails to resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Oct 4, 2024
1 parent 5f955e4 commit c82043e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
9 changes: 9 additions & 0 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
Err(guar) => Ty::new_error(tcx, guar),
}
}
hir::QPath::Resolved(
_,
hir::Path { res: Res::Err, segments: [.., item_segment], .. },
) if item_segment.args.is_some_and(|args| {
matches!(args.parenthesized, hir::GenericArgsParentheses::ReturnTypeNotation)
}) =>
{
Ty::new_error_with_message(tcx, hir_ty.span, "bad resolution for RTN")
}
_ => self.lower_ty(hir_ty),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ fn not_a_method()
where
function(..): Send,
//~^ ERROR expected associated function, found function `function`
//~| ERROR return type notation not allowed in this position yet
{
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,24 @@ LL | function(..): Send,
| ^^^^^^^^^^^^ not a associated function

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

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

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

error: return type notation not allowed in this position yet
--> $DIR/not-a-method.rs:7:5
|
LL | function(..): Send,
| ^^^^^^^^^^^^

error: return type notation not allowed in this position yet
--> $DIR/not-a-method.rs:27:5
|
LL | method(..): Send,
| ^^^^^^^^^^

error: aborting due to 6 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0412, E0573, E0801, E0802.
For more information about an error, try `rustc --explain E0412`.
1 change: 0 additions & 1 deletion tests/ui/error-codes/E0801.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ fn test()
where
test(..): Send,
//~^ ERROR expected associated function, found function `test`
//~| ERROR return type notation not allowed in this position yet
{
}

Expand Down
8 changes: 1 addition & 7 deletions tests/ui/error-codes/E0801.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ error[E0801]: expected associated function, found function `test`
LL | test(..): Send,
| ^^^^^^^^ not a associated function

error: return type notation not allowed in this position yet
--> $DIR/E0801.rs:5:5
|
LL | test(..): Send,
| ^^^^^^^^

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

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

0 comments on commit c82043e

Please sign in to comment.