Skip to content

Don't refer to 'this tail expression' in expansion. #142024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 2 additions & 4 deletions tests/ui/never_type/feature-gate-never_type_fallback.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 `()`
Comment on lines -5 to -8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: what's slightly amusing is that the Reference calls the tail expr of an block expr the "final operand"

The syntax for a block is [...] then an optional expression, called the final operand, and finally a }.
-- https://doc.rust-lang.org/reference/expressions/block-expr.html#r-expr.block.inner-attributes

| --- ^^^^^^^^ the trait `T` is not implemented for `()`
| |
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
Expand Down
Loading