about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-09-10 20:29:05 +0200
committerGitHub <noreply@github.com>2025-09-10 20:29:05 +0200
commitfc6beb3034c766dff3ccc534b011bb9141cc9ee7 (patch)
tree954de8b29da99f821aad3412990d247a7cd7beff /compiler/rustc_ast_lowering
parente79630da0b16a4514f34f6283bbfc17f2e239605 (diff)
parent3ab7b397bbd27d220d1eebc1b21963235dd26711 (diff)
downloadrust-fc6beb3034c766dff3ccc534b011bb9141cc9ee7.tar.gz
rust-fc6beb3034c766dff3ccc534b011bb9141cc9ee7.zip
Rollup merge of #145879 - Bryanskiy:supertraits-2, r=lcnr
default auto traits: use default supertraits instead of `Self: Trait` bounds on associated items

First commit: the motivation has been discussed [here](https://github.com/rust-lang/rust/pull/144679).

Second commit:  the only new places where new implicit `DefaultAutoTrait` bounds are generated are supertraits and trait object so `?Trait` syntax should be extended to these places only.

r? `@lcnr`
Diffstat (limited to 'compiler/rustc_ast_lowering')
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 72f20a95ff0..4e2243e8787 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -2101,17 +2101,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                 {
                     return;
                 }
-                if self.tcx.features().more_maybe_bounds() {
-                    return;
-                }
             }
             RelaxedBoundPolicy::Forbidden(reason) => {
-                if self.tcx.features().more_maybe_bounds() {
-                    return;
-                }
-
                 match reason {
                     RelaxedBoundForbiddenReason::TraitObjectTy => {
+                        if self.tcx.features().more_maybe_bounds() {
+                            return;
+                        }
+
                         self.dcx().span_err(
                             span,
                             "relaxed bounds are not permitted in trait object types",
@@ -2119,6 +2116,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                         return;
                     }
                     RelaxedBoundForbiddenReason::SuperTrait => {
+                        if self.tcx.features().more_maybe_bounds() {
+                            return;
+                        }
+
                         let mut diag = self.dcx().struct_span_err(
                             span,
                             "relaxed bounds are not permitted in supertrait bounds",