diff options
| author | varkor <github@varkor.com> | 2020-01-25 22:28:31 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2020-02-22 00:28:49 +0000 |
| commit | 33143fd756f3765daa00809da2d1f66b5d3ac9fc (patch) | |
| tree | 41bae057f318f7cf6bd8255dcc7769487f045be5 | |
| parent | 104131c9d487c943d962f4d88490aa7bcf2fa2de (diff) | |
| download | rust-33143fd756f3765daa00809da2d1f66b5d3ac9fc.tar.gz rust-33143fd756f3765daa00809da2d1f66b5d3ac9fc.zip | |
Be explicit about whether `GenericArgCountMismatch` arose from a fatal error
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 8 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 16 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index ae8dbfe9c39..42613532655 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -134,7 +134,8 @@ enum GenericArgPosition { /// A marker denoting that the generic arguments that were /// provided did not match the respective generic parameters. -pub struct GenericArgCountMismatch; +/// The field indicates whether a fatal error was reported (`Some`), or just a lint (`None`). +pub struct GenericArgCountMismatch(pub Option<ErrorReported>); impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { pub fn ast_region_to_region( @@ -320,7 +321,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let mut explicit_lifetimes = Ok(()); if !infer_lifetimes { if let Some(span_late) = def.has_late_bound_regions { - explicit_lifetimes = Err(GenericArgCountMismatch); let msg = "cannot specify lifetime arguments explicitly \ if late bound lifetime parameters are present"; let note = "the late bound lifetime parameter is introduced here"; @@ -328,10 +328,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { if position == GenericArgPosition::Value && arg_counts.lifetimes != param_counts.lifetimes { + explicit_lifetimes = Err(GenericArgCountMismatch(Some(ErrorReported))); let mut err = tcx.sess.struct_span_err(span, msg); err.span_note(span_late, note); err.emit(); } else { + explicit_lifetimes = Err(GenericArgCountMismatch(None)); let mut multispan = MultiSpan::from_span(span); multispan.push_span_label(span_late, note.to_string()); tcx.struct_span_lint_hir( @@ -405,7 +407,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } err.emit(); - Err(GenericArgCountMismatch) + Err(GenericArgCountMismatch(Some(ErrorReported))) }; let mut arg_count_correct = explicit_lifetimes; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 426ba0ddaaa..daedeafbcc3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -5452,11 +5452,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // parameter internally, but we don't allow users to specify the // parameter's value explicitly, so we have to do some error- // checking here. - let suppress_errors = AstConv::check_generic_arg_count_for_call( - tcx, span, &generics, &seg, false, // `is_method_call` - ) - .is_err(); - if suppress_errors { + if let Err(GenericArgCountMismatch(Some(ErrorReported))) = + AstConv::check_generic_arg_count_for_call( + tcx, span, &generics, &seg, false, // `is_method_call` + ) + { infer_args_for_err.insert(index); self.set_tainted_by_errors(); // See issue #53251. } @@ -5521,7 +5521,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &[][..], has_self, self_ty, - if infer_args_for_err.is_empty() { Ok(()) } else { Err(GenericArgCountMismatch) }, + if infer_args_for_err.is_empty() { + Ok(()) + } else { + Err(GenericArgCountMismatch(Some(ErrorReported))) + }, // Provide the generic args, and whether types should be inferred. |def_id| { if let Some(&PathSeg(_, index)) = |
