diff options
| author | mibac138 <5672750+mibac138@users.noreply.github.com> | 2021-05-06 14:33:23 +0200 |
|---|---|---|
| committer | mibac138 <5672750+mibac138@users.noreply.github.com> | 2021-05-07 18:29:25 +0200 |
| commit | 4c72efc8167405ca1cc3002266a9bf15f70dafb3 (patch) | |
| tree | 8442191074b8b2a1bffc030044ca565f3fb044be /compiler/rustc_resolve/src | |
| parent | 1bb94fbbeb703806817a09806365e26a18f5daa4 (diff) | |
| download | rust-4c72efc8167405ca1cc3002266a9bf15f70dafb3.tar.gz rust-4c72efc8167405ca1cc3002266a9bf15f70dafb3.zip | |
Fix impl type parameter suggestion involving consts
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index a4bf19aab95..28d636ef1b2 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -6,7 +6,10 @@ use crate::{CrateLint, Module, ModuleKind, ModuleOrUniformRoot}; use crate::{PathResult, PathSource, Segment}; use rustc_ast::visit::FnKind; -use rustc_ast::{self as ast, Expr, ExprKind, Item, ItemKind, NodeId, Path, Ty, TyKind}; +use rustc_ast::{ + self as ast, Expr, ExprKind, GenericParam, GenericParamKind, Item, ItemKind, NodeId, Path, Ty, + TyKind, +}; use rustc_ast_pretty::pprust::path_segment_to_string; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; @@ -1635,6 +1638,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { let (span, sugg) = if let [.., param] = &generics.params[..] { let span = if let [.., bound] = ¶m.bounds[..] { bound.span() + } else if let GenericParam { + kind: GenericParamKind::Const { ty, kw_span: _, default }, .. + } = param { + default.as_ref().map(|def| def.value.span).unwrap_or(ty.span) } else { param.ident.span }; |
