diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-23 00:16:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-23 00:16:21 +0100 |
| commit | e780b89959c7bfd7ab5a860f517209535884a39d (patch) | |
| tree | 1265e5dc06d11b8fcf63da2faa57567b9a484bd1 /compiler | |
| parent | 88ed69c0359253643195a3f38540d8442f2c7c9e (diff) | |
| parent | c45463ec8b2675df903b2436d4baf959d801aa08 (diff) | |
| download | rust-e780b89959c7bfd7ab5a860f517209535884a39d.tar.gz rust-e780b89959c7bfd7ab5a860f517209535884a39d.zip | |
Rollup merge of #137415 - chenyukang:yukang-fix-137345-invalid-sugg, r=estebank
Remove invalid suggestion of into_iter for extern macro Fixes #137345 #109082 is closed due to performance issue, do we have any other solution for this kind of issue?
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/method/suggest.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 8dd8398ba24..8438a92219e 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -905,11 +905,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else if self.impl_into_iterator_should_be_iterator(rcvr_ty, span, unsatisfied_predicates) { err.span_label(span, format!("`{rcvr_ty}` is not an iterator")); - err.multipart_suggestion_verbose( - "call `.into_iter()` first", - vec![(span.shrink_to_lo(), format!("into_iter()."))], - Applicability::MaybeIncorrect, - ); + if !span.in_external_macro(self.tcx.sess.source_map()) { + err.multipart_suggestion_verbose( + "call `.into_iter()` first", + vec![(span.shrink_to_lo(), format!("into_iter()."))], + Applicability::MaybeIncorrect, + ); + } return err.emit(); } else if !unsatisfied_predicates.is_empty() && matches!(rcvr_ty.kind(), ty::Param(_)) { // We special case the situation where we are looking for `_` in |
