@@ -1844,6 +1844,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1844
1844
field,
1845
1845
expr_t,
1846
1846
expr,
1847
+ None ,
1847
1848
) ;
1848
1849
}
1849
1850
err. emit ( ) ;
@@ -1870,9 +1871,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1870
1871
} ;
1871
1872
let expr_snippet =
1872
1873
self . tcx . sess . source_map ( ) . span_to_snippet ( expr. span ) . unwrap_or ( String :: new ( ) ) ;
1873
- if expr_is_call && expr_snippet. starts_with ( "(" ) && expr_snippet. ends_with ( ")" ) {
1874
- let after_open = expr. span . lo ( ) + rustc_span:: BytePos ( 1 ) ;
1875
- let before_close = expr. span . hi ( ) - rustc_span:: BytePos ( 1 ) ;
1874
+ let is_wrapped = expr_snippet. starts_with ( "(" ) && expr_snippet. ends_with ( ")" ) ;
1875
+ let after_open = expr. span . lo ( ) + rustc_span:: BytePos ( 1 ) ;
1876
+ let before_close = expr. span . hi ( ) - rustc_span:: BytePos ( 1 ) ;
1877
+
1878
+ if expr_is_call && is_wrapped {
1876
1879
err. multipart_suggestion (
1877
1880
"remove wrapping parentheses to call the method" ,
1878
1881
vec ! [
@@ -1882,12 +1885,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1882
1885
Applicability :: MachineApplicable ,
1883
1886
) ;
1884
1887
} else if !self . expr_in_place ( expr. hir_id ) {
1888
+ // Suggest call parentheses inside the wrapping parentheses
1889
+ let span = if is_wrapped {
1890
+ expr. span . with_lo ( after_open) . with_hi ( before_close)
1891
+ } else {
1892
+ expr. span
1893
+ } ;
1885
1894
self . suggest_method_call (
1886
1895
& mut err,
1887
1896
"use parentheses to call the method" ,
1888
1897
field,
1889
1898
expr_t,
1890
1899
expr,
1900
+ Some ( span) ,
1891
1901
) ;
1892
1902
} else {
1893
1903
err. help ( "methods are immutable and cannot be assigned to" ) ;
0 commit comments