Fix impl type parameter suggestion involving consts
This commit is contained in:
parent
1bb94fbbeb
commit
4c72efc816
4 changed files with 60 additions and 13 deletions
|
@ -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
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue