@@ -645,15 +645,15 @@ impl EarlyLintPass for AnonymousParameters {
645
645
match arg. pat . kind {
646
646
ast:: PatKind :: Ident ( _, ident, None ) => {
647
647
if ident. name == kw:: Invalid {
648
- let ty_snip = cx. sess . source_map ( ) . span_to_snippet ( arg. ty . span ) ;
648
+ cx. struct_span_lint ( ANONYMOUS_PARAMETERS , arg. pat . span , |lint| {
649
+ let ty_snip = cx. sess . source_map ( ) . span_to_snippet ( arg. ty . span ) ;
649
650
650
- let ( ty_snip, appl) = if let Ok ( snip) = ty_snip {
651
- ( snip, Applicability :: MachineApplicable )
652
- } else {
653
- ( "<type>" . to_owned ( ) , Applicability :: HasPlaceholders )
654
- } ;
651
+ let ( ty_snip, appl) = if let Ok ( snip) = ty_snip {
652
+ ( snip, Applicability :: MachineApplicable )
653
+ } else {
654
+ ( "<type>" . to_owned ( ) , Applicability :: HasPlaceholders )
655
+ } ;
655
656
656
- cx. struct_span_lint ( ANONYMOUS_PARAMETERS , arg. pat . span , |lint| {
657
657
lint. build (
658
658
"anonymous parameters are deprecated and will be \
659
659
removed in the next edition.",
@@ -869,8 +869,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
869
869
if attr:: contains_name ( & it. attrs , sym:: no_mangle) {
870
870
// Const items do not refer to a particular location in memory, and therefore
871
871
// don't have anything to attach a symbol to
872
- let msg = "const items should never be `#[no_mangle]`" ;
873
872
cx. struct_span_lint ( NO_MANGLE_CONST_ITEMS , it. span , |lint| {
873
+ let msg = "const items should never be `#[no_mangle]`" ;
874
874
let mut err = lint. build ( msg) ;
875
875
876
876
// account for "pub const" (#45562)
@@ -910,11 +910,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
910
910
fn check_expr ( & mut self , cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr < ' _ > ) {
911
911
use rustc_target:: spec:: abi:: Abi :: RustIntrinsic ;
912
912
913
- let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
914
- consider instead using an UnsafeCell";
915
913
match get_transmute_from_to ( cx, expr) . map ( |( ty1, ty2) | ( & ty1. kind , & ty2. kind ) ) {
916
914
Some ( ( & ty:: Ref ( _, _, from_mt) , & ty:: Ref ( _, _, to_mt) ) ) => {
917
915
if to_mt == hir:: Mutability :: Mut && from_mt == hir:: Mutability :: Not {
916
+ let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
917
+ consider instead using an UnsafeCell";
918
918
cx. struct_span_lint ( MUTABLE_TRANSMUTES , expr. span , |lint| {
919
919
lint. build ( msg) . emit ( )
920
920
} ) ;
@@ -1335,12 +1335,12 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
1335
1335
let suggestion = "use `..=` for an inclusive range" ;
1336
1336
if parenthesise {
1337
1337
self . node_id = Some ( pat. id ) ;
1338
- let end = expr_to_string ( & end) ;
1339
- let replace = match start {
1340
- Some ( start) => format ! ( "&({}..={})" , expr_to_string( & start) , end) ,
1341
- None => format ! ( "&(..={})" , end) ,
1342
- } ;
1343
1338
cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , pat. span , |lint| {
1339
+ let end = expr_to_string ( & end) ;
1340
+ let replace = match start {
1341
+ Some ( start) => format ! ( "&({}..={})" , expr_to_string( & start) , end) ,
1342
+ None => format ! ( "&(..={})" , end) ,
1343
+ } ;
1344
1344
lint. build ( msg)
1345
1345
. span_suggestion (
1346
1346
pat. span ,
0 commit comments