diff options
| author | Michael Goulet <michael@errs.io> | 2025-03-06 12:22:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-06 12:22:13 -0500 |
| commit | aab7b145d0e1c0d297fe2b678e327daffb62e909 (patch) | |
| tree | fd8e3a30affebcd3f950548874d943f6c692b1ad /compiler/rustc_hir_analysis/src | |
| parent | cc5d90cbad746560c2e1a6a71777c096f7a7c575 (diff) | |
| parent | 09e584671b439dc8a9d57cc900cc26668a69ddea (diff) | |
| download | rust-aab7b145d0e1c0d297fe2b678e327daffb62e909.tar.gz rust-aab7b145d0e1c0d297fe2b678e327daffb62e909.zip | |
Rollup merge of #137565 - compiler-errors:macro-ex, r=estebank
Try to point of macro expansion from resolver and method errors if it involves macro var In the case that a macro caller passes an identifier into a macro generating a path or method expression, point out that identifier in the context of the *macro* so it's a bit more clear how the macro is involved in causing the error. r? ``````````@estebank`````````` or reassign
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/errors.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index f3e1e89812c..e04d6e2c2ae 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -82,6 +82,8 @@ pub(crate) struct AssocItemNotFound<'a> { pub label: Option<AssocItemNotFoundLabel<'a>>, #[subdiagnostic] pub sugg: Option<AssocItemNotFoundSugg<'a>>, + #[label(hir_analysis_within_macro)] + pub within_macro_span: Option<Span>, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index d51fd7f7e78..ace5e34b382 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -151,6 +151,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { qself: &qself_str, label: None, sugg: None, + // Try to get the span of the identifier within the path's syntax context + // (if that's different). + within_macro_span: assoc_name.span.within_macro(span, tcx.sess.source_map()), }; if is_dummy { |
