about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/messages.ftl
diff options
context:
space:
mode:
authorxtex <xtexchooser@duck.com>2025-03-30 10:00:45 +0800
committerxtex <xtexchooser@duck.com>2025-04-03 17:35:51 +0800
commitfdefffecb2a1c2b89dfc2c5ad041c02144adda81 (patch)
tree0760f1131f3f0930047e6a3cc8a011a818a3cdb6 /compiler/rustc_hir_analysis/messages.ftl
parent365806089020f60a50391133a1430c40bc86963c (diff)
downloadrust-fdefffecb2a1c2b89dfc2c5ad041c02144adda81.tar.gz
rust-fdefffecb2a1c2b89dfc2c5ad041c02144adda81.zip
compiler: report error when trait object type param reference self
Fixes #139082.

Emits an error when `Self` is found in the projection bounds of a trait
object. In type aliases, `Self` has no meaning, so `type A = &'static
dyn B` where `trait B = Fn() -> Self` will expands to `type A = &'static
Fn() -> Self` which is illegal, causing the region solver to bail out
when hitting the uninferred Self.

Bug: #139082
Signed-off-by: xtex <xtexchooser@duck.com>
Diffstat (limited to 'compiler/rustc_hir_analysis/messages.ftl')
-rw-r--r--compiler/rustc_hir_analysis/messages.ftl3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl
index 194f2cd04e4..2f7c3cb3c7d 100644
--- a/compiler/rustc_hir_analysis/messages.ftl
+++ b/compiler/rustc_hir_analysis/messages.ftl
@@ -486,6 +486,9 @@ hir_analysis_self_in_impl_self =
     `Self` is not valid in the self type of an impl block
     .note = replace `Self` with a different type
 
+hir_analysis_self_in_type_alias = `Self` is not allowed in type aliases
+    .label = `Self` is only available in impls, traits, and concrete type definitions
+
 hir_analysis_self_ty_not_captured = `impl Trait` must mention the `Self` type of the trait in `use<...>`
     .label = `Self` type parameter is implicitly captured by this `impl Trait`
     .note = currently, all type parameters are required to be mentioned in the precise captures list