mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Add suggestion for removing invalid path separator ::
in function definition.
for example: `fn invalid_path_separator::<T>() {}` fixes: #130791
This commit is contained in:
parent
1b5aa96d60
commit
d0165956fe
@ -415,6 +415,9 @@ parse_invalid_meta_item = expected unsuffixed literal, found `{$token}`
|
|||||||
|
|
||||||
parse_invalid_offset_of = offset_of expects dot-separated field and variant names
|
parse_invalid_offset_of = offset_of expects dot-separated field and variant names
|
||||||
|
|
||||||
|
parse_invalid_path_sep_in_fn_definition = invalid path separator in function definition
|
||||||
|
.suggestion = remove invalid path separator
|
||||||
|
|
||||||
parse_invalid_unicode_escape = invalid unicode character escape
|
parse_invalid_unicode_escape = invalid unicode character escape
|
||||||
.label = invalid escape
|
.label = invalid escape
|
||||||
.help = unicode escape must {$surrogate ->
|
.help = unicode escape must {$surrogate ->
|
||||||
|
@ -1755,6 +1755,14 @@ pub(crate) struct MissingFnParams {
|
|||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_invalid_path_sep_in_fn_definition)]
|
||||||
|
pub(crate) struct InvalidPathSepInFnDefinition {
|
||||||
|
#[primary_span]
|
||||||
|
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(parse_missing_trait_in_trait_impl)]
|
#[diag(parse_missing_trait_in_trait_impl)]
|
||||||
pub(crate) struct MissingTraitInTraitImpl {
|
pub(crate) struct MissingTraitInTraitImpl {
|
||||||
|
@ -269,6 +269,13 @@ impl<'a> Parser<'a> {
|
|||||||
/// | ( < lifetimes , typaramseq ( , )? > )
|
/// | ( < lifetimes , typaramseq ( , )? > )
|
||||||
/// where typaramseq = ( typaram ) | ( typaram , typaramseq )
|
/// where typaramseq = ( typaram ) | ( typaram , typaramseq )
|
||||||
pub(super) fn parse_generics(&mut self) -> PResult<'a, ast::Generics> {
|
pub(super) fn parse_generics(&mut self) -> PResult<'a, ast::Generics> {
|
||||||
|
// invalid path separator `::` in function definition
|
||||||
|
// for example `fn invalid_path_separator::<T>() {}`
|
||||||
|
if self.eat_noexpect(&token::PathSep) {
|
||||||
|
self.dcx()
|
||||||
|
.emit_err(errors::InvalidPathSepInFnDefinition { span: self.prev_token.span });
|
||||||
|
}
|
||||||
|
|
||||||
let span_lo = self.token.span;
|
let span_lo = self.token.span;
|
||||||
let (params, span) = if self.eat_lt() {
|
let (params, span) = if self.eat_lt() {
|
||||||
let params = self.parse_generic_params()?;
|
let params = self.parse_generic_params()?;
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
//@ run-rustfix
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn invalid_path_separator<T>() {}
|
||||||
|
//~^ ERROR invalid path separator in function definition
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,7 @@
|
|||||||
|
//@ run-rustfix
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn invalid_path_separator::<T>() {}
|
||||||
|
//~^ ERROR invalid path separator in function definition
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,14 @@
|
|||||||
|
error: invalid path separator in function definition
|
||||||
|
--> $DIR/invalid-path-sep-in-fn-definition-issue-130791.rs:4:26
|
||||||
|
|
|
||||||
|
LL | fn invalid_path_separator::<T>() {}
|
||||||
|
| ^^
|
||||||
|
|
|
||||||
|
help: remove invalid path separator
|
||||||
|
|
|
||||||
|
LL - fn invalid_path_separator::<T>() {}
|
||||||
|
LL + fn invalid_path_separator<T>() {}
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user