@@ -18,7 +18,6 @@ use crate::errors::{
18
18
UnexpectedConstParamDeclaration , UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets ,
19
19
UseEqInstead , WrapType ,
20
20
} ;
21
-
22
21
use crate :: fluent_generated as fluent;
23
22
use crate :: parser;
24
23
use crate :: parser:: attr:: InnerAttrPolicy ;
@@ -772,8 +771,10 @@ impl<'a> Parser<'a> {
772
771
&& let ast:: AttrKind :: Normal ( attr_kind) = & attr. kind
773
772
&& let [ segment] = & attr_kind. item . path . segments [ ..]
774
773
&& segment. ident . name == sym:: cfg
774
+ && let Some ( args_span) = attr_kind. item . args . span ( )
775
775
&& let Ok ( next_attr) = snapshot. parse_attribute ( InnerAttrPolicy :: Forbidden ( None ) )
776
776
&& let ast:: AttrKind :: Normal ( next_attr_kind) = next_attr. kind
777
+ && let Some ( next_attr_args_span) = next_attr_kind. item . args . span ( )
777
778
&& let [ next_segment] = & next_attr_kind. item . path . segments [ ..]
778
779
&& segment. ident . name == sym:: cfg
779
780
&& let Ok ( next_expr) = snapshot. parse_expr ( )
@@ -787,23 +788,14 @@ impl<'a> Parser<'a> {
787
788
let margin = self . sess . source_map ( ) . span_to_margin ( next_expr. span ) . unwrap_or ( 0 ) ;
788
789
let sugg = vec ! [
789
790
( attr. span. with_hi( segment. span( ) . hi( ) ) , "if cfg!" . to_string( ) ) ,
790
- (
791
- attr_kind. item. args. span( ) . unwrap( ) . shrink_to_hi( ) . with_hi( attr. span. hi( ) ) ,
792
- " {" . to_string( ) ,
793
- ) ,
791
+ ( args_span. shrink_to_hi( ) . with_hi( attr. span. hi( ) ) , " {" . to_string( ) ) ,
794
792
( expr. span. shrink_to_lo( ) , " " . to_string( ) ) ,
795
793
(
796
794
next_attr. span. with_hi( next_segment. span( ) . hi( ) ) ,
797
795
"} else if cfg!" . to_string( ) ,
798
796
) ,
799
797
(
800
- next_attr_kind
801
- . item
802
- . args
803
- . span( )
804
- . unwrap( )
805
- . shrink_to_hi( )
806
- . with_hi( next_attr. span. hi( ) ) ,
798
+ next_attr_args_span. shrink_to_hi( ) . with_hi( next_attr. span. hi( ) ) ,
807
799
" {" . to_string( ) ,
808
800
) ,
809
801
( next_expr. span. shrink_to_lo( ) , " " . to_string( ) ) ,
0 commit comments