diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/demand.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/expr.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/fn_ctxt/checks.rs | 19 |
4 files changed, 16 insertions, 16 deletions
diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index e164eff7550..3b644099ecf 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -470,7 +470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return None; }; - let self_ty = self.typeck_results.borrow().node_type(method_expr[0].hir_id); + let self_ty = self.typeck_results.borrow().expr_ty(&method_expr[0]); let self_ty = format!("{:?}", self_ty); let name = method_path.ident.name; let is_as_ref_able = (self_ty.starts_with("&std::option::Option") diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index f3aa40b9ad1..a8c9c699ceb 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -1517,7 +1517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } else { self.check_expr_has_type_or_error(base_expr, adt_ty, |_| { - let base_ty = self.typeck_results.borrow().node_type(base_expr.hir_id); + let base_ty = self.typeck_results.borrow().expr_ty(*base_expr); let same_adt = match (adt_ty.kind(), base_ty.kind()) { (ty::Adt(adt, _), ty::Adt(base_adt, _)) if adt == base_adt => true, _ => false, diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 5cb1fe8cd94..2c81745836c 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -313,15 +313,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) => { // A reborrow has no effect before a dereference. } - // Catch cases which have Deref(None) - // having them slip to bug! causes ICE - // see #94291 for more info - (&[Adjustment { kind: Adjust::Deref(None), .. }], _) => { - self.tcx.sess.delay_span_bug( - DUMMY_SP, - &format!("Can't compose Deref(None) expressions"), - ) - } // FIXME: currently we never try to compose autoderefs // and ReifyFnPointer/UnsafeFnPointer, but we could. _ => bug!( diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index f5d110903e6..3dfee99b835 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -133,7 +133,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expected_arg_count = formal_input_tys.len(); // expected_count, arg_count, error_code, sugg_unit, sugg_tuple_wrap_args - let mut error: Option<(usize, usize, &str, bool, Option<FnArgsAsTuple<'_>>)> = None; + let mut arg_count_error: Option<(usize, usize, &str, bool, Option<FnArgsAsTuple<'_>>)> = + None; // If the arguments should be wrapped in a tuple (ex: closures), unwrap them here let (formal_input_tys, expected_input_tys) = if tuple_arguments == TupleArguments { @@ -143,7 +144,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::Tuple(arg_types) => { // Argument length differs if arg_types.len() != provided_args.len() { - error = Some((arg_types.len(), provided_args.len(), "E0057", false, None)); + arg_count_error = + Some((arg_types.len(), provided_args.len(), "E0057", false, None)); } let expected_input_tys = match expected_input_tys.get(0) { Some(&ty) => match ty.kind() { @@ -174,7 +176,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if supplied_arg_count >= expected_arg_count { (formal_input_tys.to_vec(), expected_input_tys) } else { - error = Some((expected_arg_count, supplied_arg_count, "E0060", false, None)); + arg_count_error = + Some((expected_arg_count, supplied_arg_count, "E0060", false, None)); (self.err_args(supplied_arg_count), vec![]) } } else { @@ -198,7 +201,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let sugg_tuple_wrap_args = self.suggested_tuple_wrap(expected_input_tys, provided_args); - error = Some(( + arg_count_error = Some(( expected_arg_count, supplied_arg_count, "E0061", @@ -231,6 +234,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // This is more complicated than just checking type equality, as arguments could be coerced // This version writes those types back so further type checking uses the narrowed types let demand_compatible = |idx, final_arg_types: &mut Vec<Option<(Ty<'tcx>, Ty<'tcx>)>>| { + // Do not check argument compatibility if the number of args do not match + if arg_count_error.is_some() { + return; + } + let formal_input_ty: Ty<'tcx> = formal_input_tys[idx]; let expected_input_ty: Ty<'tcx> = expected_input_tys[idx]; let provided_arg = &provided_args[idx]; @@ -328,7 +336,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // If there was an error in parameter count, emit that here - if let Some((expected_count, arg_count, err_code, sugg_unit, sugg_tuple_wrap_args)) = error + if let Some((expected_count, arg_count, err_code, sugg_unit, sugg_tuple_wrap_args)) = + arg_count_error { let (span, start_span, args, ctor_of) = match &call_expr.kind { hir::ExprKind::Call( |
