]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_resolve/src/macros.rs
Rollup merge of #103543 - ehuss:update-books, r=ehuss
[rust.git] / compiler / rustc_resolve / src / macros.rs
index 71264ffc877ded9682e7f9b34b44371827cbfb33..9526296f9511530119db79663bd07f0f61099300 100644 (file)
@@ -697,21 +697,15 @@ pub(crate) fn finalize_macro_resolutions(&mut self) {
                     let mut suggestion = None;
                     let (span, label) = if let PathResult::Failed { span, label, .. } = path_res {
                         // try to suggest if it's not a macro, maybe a function
-                        if let PathResult::NonModule(partial_res) =  self.resolve_path(
-                            &path,
-                            Some(ValueNS),
-                            &parent_scope,
-                            Some(Finalize::new(ast::CRATE_NODE_ID, path_span)),
-                            None,
-                        ) && partial_res.unresolved_segments() == 0 {
+                        if let PathResult::NonModule(partial_res) = self.maybe_resolve_path(&path, Some(ValueNS), &parent_scope)
+                            && partial_res.unresolved_segments() == 0 {
                             let sm = self.session.source_map();
-                            let span = sm.span_extend_while(span, |c| c == '!').unwrap_or(span);
-                            let code = sm.span_to_snippet(span).unwrap();
-                            suggestion = Some(
-                                    (vec![(span, code.trim_end_matches('!').to_string())],
+                            let exclamation_span = sm.next_point(span);
+                            suggestion = Some((
+                                vec![(exclamation_span, "".to_string())],
                                     format!("{} is not a macro, but a {}, try to remove `!`", Segment::names_to_string(&path), partial_res.base_res().descr()),
-                                    Applicability::MaybeIncorrect)
-                                );
+                                    Applicability::MaybeIncorrect
+                                ));
                         }
                         (span, label)
                     } else {