about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorBryanskiy <ivakin.kir@gmail.com>2025-08-24 21:29:26 +0300
committerBryanskiy <ivakin.kir@gmail.com>2025-09-10 15:08:08 +0300
commit3ab7b397bbd27d220d1eebc1b21963235dd26711 (patch)
treec1fb5eea0054a90677bb1c5596ffd36363aef965 /compiler
parentbd089e1e6e52256c0535f19f58b4b6fe9609b70c (diff)
downloadrust-3ab7b397bbd27d220d1eebc1b21963235dd26711.tar.gz
rust-3ab7b397bbd27d220d1eebc1b21963235dd26711.zip
Permit `more_maybe_bounds` in supertraits and trait objects only
Diffstat (limited to 'compiler')
-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",