about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2025-06-04 14:45:32 +0200
committerMara Bos <m-ou.se@m-ou.se>2025-06-04 15:42:58 +0200
commitda2e33b4065c3356260a0c1671a945a3bf0a2f35 (patch)
tree8f728c81c948d9ad8516de2310ec83723abe16df
parentd9a739363878a06633eb912e44f02a3c5d6ba08c (diff)
downloadrust-da2e33b4065c3356260a0c1671a945a3bf0a2f35.tar.gz
rust-da2e33b4065c3356260a0c1671a945a3bf0a2f35.zip
Don't refer to 'this tail expression' in expansion.
The user has no clue what tail expression the compiler is talking
about: it is an implementation detail of the macro that it uses a block
with tail expression.
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs4
-rw-r--r--tests/ui/never_type/feature-gate-never_type_fallback.stderr6
2 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
index c4f1f7d712a..9c301373cf9 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
@@ -3841,7 +3841,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
                     .expr_ty_adjusted_opt(inner_expr)
                     .unwrap_or(Ty::new_misc_error(tcx));
                 let span = inner_expr.span;
-                if Some(span) != err.span.primary_span() {
+                if Some(span) != err.span.primary_span()
+                    && !span.in_external_macro(tcx.sess.source_map())
+                {
                     err.span_label(
                         span,
                         if ty.references_error() {
diff --git a/tests/ui/never_type/feature-gate-never_type_fallback.stderr b/tests/ui/never_type/feature-gate-never_type_fallback.stderr
index cbb670ea708..8dbd43e121b 100644
--- a/tests/ui/never_type/feature-gate-never_type_fallback.stderr
+++ b/tests/ui/never_type/feature-gate-never_type_fallback.stderr
@@ -2,10 +2,8 @@ error[E0277]: the trait bound `(): T` is not satisfied
   --> $DIR/feature-gate-never_type_fallback.rs:10:9
    |
 LL |     foo(panic!())
-   |     --- ^^^^^^^^
-   |     |   |
-   |     |   the trait `T` is not implemented for `()`
-   |     |   this tail expression is of type `()`
+   |     --- ^^^^^^^^ the trait `T` is not implemented for `()`
+   |     |
    |     required by a bound introduced by this call
    |
 help: this trait has no implementations, consider adding one