File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -1874,15 +1874,16 @@ impl<'a> LoweringContext<'a> {
1874
1874
if let Ok ( snippet) = self . sess . source_map ( ) . span_to_snippet ( data. span ) {
1875
1875
// Do not suggest going from `Trait()` to `Trait<>`
1876
1876
if data. inputs . len ( ) > 0 {
1877
- let split = snippet. find ( '(' ) . unwrap ( ) ;
1878
- let trait_name = & snippet[ 0 ..split] ;
1879
- let args = & snippet[ split + 1 .. snippet. len ( ) - 1 ] ;
1880
- err. span_suggestion (
1881
- data. span ,
1882
- "use angle brackets instead" ,
1883
- format ! ( "{}<{}>" , trait_name, args) ,
1884
- Applicability :: MaybeIncorrect ,
1885
- ) ;
1877
+ if let Some ( split) = snippet. find ( '(' ) {
1878
+ let trait_name = & snippet[ 0 ..split] ;
1879
+ let args = & snippet[ split + 1 .. snippet. len ( ) - 1 ] ;
1880
+ err. span_suggestion (
1881
+ data. span ,
1882
+ "use angle brackets instead" ,
1883
+ format ! ( "{}<{}>" , trait_name, args) ,
1884
+ Applicability :: MaybeIncorrect ,
1885
+ ) ;
1886
+ }
1886
1887
}
1887
1888
} ;
1888
1889
err. emit ( ) ;
You can’t perform that action at this time.
0 commit comments