Check if E0530 is tuple variant
or tuple struct
to emit suggestion
This commit is contained in:
parent
51504dbf01
commit
ea46e7a47e
3 changed files with 17 additions and 11 deletions
|
@ -900,9 +900,10 @@ impl<'a> Resolver<'a> {
|
||||||
name,
|
name,
|
||||||
participle,
|
participle,
|
||||||
article,
|
article,
|
||||||
shadowed_binding_descr,
|
shadowed_binding,
|
||||||
shadowed_binding_span,
|
shadowed_binding_span,
|
||||||
} => {
|
} => {
|
||||||
|
let shadowed_binding_descr = shadowed_binding.descr();
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
self.session,
|
self.session,
|
||||||
span,
|
span,
|
||||||
|
@ -915,13 +916,18 @@ impl<'a> Resolver<'a> {
|
||||||
span,
|
span,
|
||||||
format!("cannot be named the same as {} {}", article, shadowed_binding_descr),
|
format!("cannot be named the same as {} {}", article, shadowed_binding_descr),
|
||||||
);
|
);
|
||||||
err.span_suggestion(
|
match shadowed_binding {
|
||||||
span,
|
Res::Def(DefKind::Ctor(CtorOf::Variant | CtorOf::Struct, CtorKind::Fn), _) => {
|
||||||
"try specify the pattern arguments",
|
err.span_suggestion(
|
||||||
format!("{}(..)", name),
|
span,
|
||||||
Applicability::Unspecified,
|
"try specify the pattern arguments",
|
||||||
)
|
format!("{}(..)", name),
|
||||||
.emit();
|
Applicability::Unspecified,
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
let msg =
|
let msg =
|
||||||
format!("the {} `{}` is {} here", shadowed_binding_descr, name, participle);
|
format!("the {} `{}` is {} here", shadowed_binding_descr, name, participle);
|
||||||
err.span_label(shadowed_binding_span, msg);
|
err.span_label(shadowed_binding_span, msg);
|
||||||
|
|
|
@ -2849,7 +2849,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
name: ident.name,
|
name: ident.name,
|
||||||
participle: if binding.is_import() { "imported" } else { "defined" },
|
participle: if binding.is_import() { "imported" } else { "defined" },
|
||||||
article: binding.res().article(),
|
article: binding.res().article(),
|
||||||
shadowed_binding_descr: binding.res().descr(),
|
shadowed_binding: binding.res(),
|
||||||
shadowed_binding_span: binding.span,
|
shadowed_binding_span: binding.span,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -2865,7 +2865,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
name: ident.name,
|
name: ident.name,
|
||||||
participle: "defined",
|
participle: "defined",
|
||||||
article: res.article(),
|
article: res.article(),
|
||||||
shadowed_binding_descr: res.descr(),
|
shadowed_binding: res,
|
||||||
shadowed_binding_span: self.r.opt_span(def_id).expect("const parameter defined outside of local crate"),
|
shadowed_binding_span: self.r.opt_span(def_id).expect("const parameter defined outside of local crate"),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -234,7 +234,7 @@ enum ResolutionError<'a> {
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
participle: &'static str,
|
participle: &'static str,
|
||||||
article: &'static str,
|
article: &'static str,
|
||||||
shadowed_binding_descr: &'static str,
|
shadowed_binding: Res,
|
||||||
shadowed_binding_span: Span,
|
shadowed_binding_span: Span,
|
||||||
},
|
},
|
||||||
/// Error E0128: generic parameters with a default cannot use forward-declared identifiers.
|
/// Error E0128: generic parameters with a default cannot use forward-declared identifiers.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue