about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-03 14:23:58 +0000
committerbors <bors@rust-lang.org>2022-09-03 14:23:58 +0000
commitae0030beb0398cabb2626fe326d6b2e8286c70b9 (patch)
tree051d21dce710e448c1b6358241f5f6879dcf7fec /compiler
parent47d1cdb0bcac8e417071ce1929d261efe2399ae2 (diff)
parent01da61a9bf1e1e7079bee0609ed944646c99c2a0 (diff)
downloadrust-ae0030beb0398cabb2626fe326d6b2e8286c70b9.tar.gz
rust-ae0030beb0398cabb2626fe326d6b2e8286c70b9.zip
Auto merge of #101378 - matthiaskrgr:rollup-s1awa47, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #101335 (rustdoc: remove old CSS selector that causes weird spacing)
 - #101347 (ffx component run should provide a collection)
 - #101364 (Shrink suggestion span of argument mismatch error)
 - #101365 (remove redundant clones)

Failed merges:

 - #101349 (rustdoc: remove `.impl-items { flex-basis }` CSS, not in flex container)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_parse/src/parser/attr_wrapper.rs2
-rw-r--r--compiler/rustc_typeck/src/check/fn_ctxt/checks.rs23
2 files changed, 18 insertions, 7 deletions
diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs
index f353ee6df9b..2e58605cf19 100644
--- a/compiler/rustc_parse/src/parser/attr_wrapper.rs
+++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs
@@ -52,7 +52,7 @@ impl AttrWrapper {
     // Prepend `self.attrs` to `attrs`.
     // FIXME: require passing an NT to prevent misuse of this method
     pub(crate) fn prepend_to_nt_inner(self, attrs: &mut AttrVec) {
-        let mut self_attrs = self.attrs.clone();
+        let mut self_attrs = self.attrs;
         std::mem::swap(attrs, &mut self_attrs);
         attrs.extend(self_attrs);
     }
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
index 7ff4aef2d25..ce0e59d0622 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
@@ -1056,11 +1056,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         };
         if let Some(suggestion_text) = suggestion_text {
             let source_map = self.sess().source_map();
-            let mut suggestion = format!(
-                "{}(",
-                source_map.span_to_snippet(full_call_span).unwrap_or_else(|_| fn_def_id
-                    .map_or("".to_string(), |fn_def_id| tcx.item_name(fn_def_id).to_string()))
-            );
+            let (mut suggestion, suggestion_span) =
+                if let Some(call_span) = full_call_span.find_ancestor_inside(error_span) {
+                    ("(".to_string(), call_span.shrink_to_hi().to(error_span.shrink_to_hi()))
+                } else {
+                    (
+                        format!(
+                            "{}(",
+                            source_map.span_to_snippet(full_call_span).unwrap_or_else(|_| {
+                                fn_def_id.map_or("".to_string(), |fn_def_id| {
+                                    tcx.item_name(fn_def_id).to_string()
+                                })
+                            })
+                        ),
+                        error_span,
+                    )
+                };
             let mut needs_comma = false;
             for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
                 if needs_comma {
@@ -1088,7 +1099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             }
             suggestion += ")";
             err.span_suggestion_verbose(
-                error_span,
+                suggestion_span,
                 &suggestion_text,
                 suggestion,
                 Applicability::HasPlaceholders,