@@ -645,15 +645,15 @@ impl EarlyLintPass for AnonymousParameters {
645645 match arg. pat . kind {
646646 ast:: PatKind :: Ident ( _, ident, None ) => {
647647 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 ) ;
649650
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+ } ;
655656
656- cx. struct_span_lint ( ANONYMOUS_PARAMETERS , arg. pat . span , |lint| {
657657 lint. build (
658658 "anonymous parameters are deprecated and will be \
659659 removed in the next edition.",
@@ -869,8 +869,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
869869 if attr:: contains_name ( & it. attrs , sym:: no_mangle) {
870870 // Const items do not refer to a particular location in memory, and therefore
871871 // don't have anything to attach a symbol to
872- let msg = "const items should never be `#[no_mangle]`" ;
873872 cx. struct_span_lint ( NO_MANGLE_CONST_ITEMS , it. span , |lint| {
873+ let msg = "const items should never be `#[no_mangle]`" ;
874874 let mut err = lint. build ( msg) ;
875875
876876 // account for "pub const" (#45562)
@@ -910,11 +910,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
910910 fn check_expr ( & mut self , cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr < ' _ > ) {
911911 use rustc_target:: spec:: abi:: Abi :: RustIntrinsic ;
912912
913- let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
914- consider instead using an UnsafeCell";
915913 match get_transmute_from_to ( cx, expr) . map ( |( ty1, ty2) | ( & ty1. kind , & ty2. kind ) ) {
916914 Some ( ( & ty:: Ref ( _, _, from_mt) , & ty:: Ref ( _, _, to_mt) ) ) => {
917915 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";
918918 cx. struct_span_lint ( MUTABLE_TRANSMUTES , expr. span , |lint| {
919919 lint. build ( msg) . emit ( )
920920 } ) ;
@@ -1335,12 +1335,12 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
13351335 let suggestion = "use `..=` for an inclusive range" ;
13361336 if parenthesise {
13371337 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- } ;
13431338 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+ } ;
13441344 lint. build ( msg)
13451345 . span_suggestion (
13461346 pat. span ,
0 commit comments