1
Fork 0

Adjust #[no_mangle]-related checks and lints for impl items

This commit is contained in:
hyd-dev 2021-08-08 02:10:57 +08:00
parent c84beefd83
commit 0bb2ea653e
No known key found for this signature in database
GPG key ID: 74FA7FD5B8DA14B8
13 changed files with 573 additions and 56 deletions

View file

@ -391,9 +391,14 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
_: Span,
id: hir::HirId,
) {
let attrs = cx.tcx.hir().attrs(id);
match &fk {
FnKind::Method(ident, ..) => match method_context(cx, id) {
FnKind::Method(ident, sig, ..) => match method_context(cx, id) {
MethodLateContext::PlainImpl => {
if sig.header.abi != Abi::Rust && cx.sess().contains_name(attrs, sym::no_mangle)
{
return;
}
self.check_snake_case(cx, "method", ident);
}
MethodLateContext::TraitAutoImpl => {
@ -402,7 +407,6 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
_ => (),
},
FnKind::ItemFn(ident, _, header, _) => {
let attrs = cx.tcx.hir().attrs(id);
// Skip foreign-ABI #[no_mangle] functions (Issue #31924)
if header.abi != Abi::Rust && cx.sess().contains_name(attrs, sym::no_mangle) {
return;