-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking issue for future-incompatibility lint patterns_in_fns_without_body #35203
Copy link
Copy link
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Idea
Code using patterns in parameters of foreign functions, function pointers or trait methods without body is not accepted by the compiler.
Previously some simple patterns like
&ident,&&identormut identwere allowed in these positions, now they aren't. Such patterns weren't properly type checked, e.g.type A = fn(&arg: u8);compiled despiteu8not being a reference.What are these errors for?
Full patterns don't make sense in functions without bodies, but simple identifiers may be useful for documenting argument purposes even if they aren't actually used -
type Callback = fn(useful_name: u8).By restricting patterns in body-less function signatures to
ident: TYPEwe can make argument names optional and accept simply aTYPEin argument position (type T = fn(u8)) without introducing parsing ambiguities.How to fix this warning/error
Remove
&ormutfrom the pattern and make the function parameter a single identifier or_.Current status
mut IDENT