1
Fork 0

Changed lint to check for std::fmt::Pointer and transmute

The lint checks arguments in calls to `transmute` or functions that have
`Pointer` as a trait bound and displays a warning if the argument is a function
reference. Also checks for `std::fmt::Pointer::fmt` to handle formatting macros
although it doesn't depend on the exact expansion of the macro or formatting
internals. `std::fmt::Pointer` and `std::fmt::Pointer::fmt` were also added as
diagnostic items and symbols.
This commit is contained in:
Ayrton 2020-10-06 09:51:10 -04:00
parent 3214de7359
commit 511fe048b4
7 changed files with 355 additions and 199 deletions

View file

@ -2645,9 +2645,10 @@ declare_lint! {
reference: "issue #76200 <https://github.com/rust-lang/rust/issues/76200>",
edition: None,
};
}
declare_lint! {
pub FUNCTION_REFERENCES,
pub FUNCTION_ITEM_REFERENCES,
Warn,
"suggest casting functions to pointers when attempting to take references",
}
@ -2767,7 +2768,7 @@ declare_lint_pass! {
CONST_EVALUATABLE_UNCHECKED,
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
UNINHABITED_STATIC,
FUNCTION_REFERENCES,
FUNCTION_ITEM_REFERENCES,
]
}