Don't call a type uncallable if its signature has errors in it

This commit is contained in:
Michael Goulet 2023-07-11 15:37:09 +00:00
parent 8164cdb9ee
commit c0c2d39668
3 changed files with 25 additions and 0 deletions

View File

@ -581,6 +581,14 @@ fn report_invalid_callee(
callee_ty: Ty<'tcx>, callee_ty: Ty<'tcx>,
arg_exprs: &'tcx [hir::Expr<'tcx>], arg_exprs: &'tcx [hir::Expr<'tcx>],
) -> ErrorGuaranteed { ) -> ErrorGuaranteed {
// Callee probe fails when APIT references errors, so suppress those
// errors here.
if let Some((_, _, args)) = self.extract_callable_info(callee_ty)
&& let Err(err) = args.error_reported()
{
return err;
}
let mut unit_variant = None; let mut unit_variant = None;
if let hir::ExprKind::Path(qpath) = &callee_expr.kind if let hir::ExprKind::Path(qpath) = &callee_expr.kind
&& let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _) && let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)

View File

@ -0,0 +1,8 @@
type Foo = Bar;
//~^ ERROR cannot find type `Bar` in this scope
fn check(f: impl FnOnce(Foo), val: Foo) {
f(val);
}
fn main() {}

View File

@ -0,0 +1,9 @@
error[E0412]: cannot find type `Bar` in this scope
--> $DIR/apit-with-error-type-in-sig.rs:1:12
|
LL | type Foo = Bar;
| ^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0412`.