Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f91fd0c

Browse files
Remove generic_associated_types_extended feature gate
1 parent 8575f8f commit f91fd0c

24 files changed

+300
-124
lines changed

compiler/rustc_feature/src/removed.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ declare_features! (
119119
(removed, generator_clone, "1.65.0", Some(95360), Some("renamed to `coroutine_clone`")),
120120
/// Allows defining generators.
121121
(removed, generators, "1.21.0", Some(43122), Some("renamed to `coroutines`")),
122+
/// An extension to the `generic_associated_types` feature, allowing incomplete features.
123+
(removed, generic_associated_types_extended, "CURRENT_RUSTC_VERSION", Some(95451),
124+
Some(
125+
"feature needs overhaul and reimplementation pending \
126+
better implied higher-ranked implied bounds support"
127+
)
128+
),
122129
/// Allows `impl Trait` in bindings (`let`, `const`, `static`).
123130
(removed, impl_trait_in_bindings, "1.55.0", Some(63065),
124131
Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")),

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,6 @@ declare_features! (
497497
(unstable, gen_blocks, "1.75.0", Some(117078)),
498498
/// Infer generic args for both consts and types.
499499
(unstable, generic_arg_infer, "1.55.0", Some(85077)),
500-
/// An extension to the `generic_associated_types` feature, allowing incomplete features.
501-
(incomplete, generic_associated_types_extended, "1.61.0", Some(95451)),
502500
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers
503501
(incomplete, generic_const_exprs, "1.56.0", Some(76560)),
504502
/// Allows generic parameters and where-clauses on free & associated const items.

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,7 @@ pub fn dyn_compatibility_violations_for_assoc_item(
329329
.collect(),
330330
// Associated types can only be dyn-compatible if they have `Self: Sized` bounds.
331331
ty::AssocKind::Type => {
332-
if !tcx.features().generic_associated_types_extended()
333-
&& !tcx.generics_of(item.def_id).is_own_empty()
334-
&& !item.is_impl_trait_in_trait()
335-
{
332+
if !tcx.generics_of(item.def_id).is_own_empty() && !item.is_impl_trait_in_trait() {
336333
vec![DynCompatibilityViolation::GAT(item.name, item.ident(tcx).span)]
337334
} else {
338335
// We will permit associated types if they are explicitly mentioned in the trait object.

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::traits::select::OverflowError;
1414
use rustc_middle::traits::{BuiltinImplSource, ImplSource, ImplSourceUserDefinedData};
1515
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
1616
use rustc_middle::ty::fold::TypeFoldable;
17-
use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt};
17+
use rustc_middle::ty::visit::TypeVisitableExt;
1818
use rustc_middle::ty::{self, Term, Ty, TyCtxt, TypingMode, Upcast};
1919
use rustc_middle::{bug, span_bug};
2020
use rustc_span::symbol::sym;
@@ -179,35 +179,11 @@ pub(super) fn poly_project_and_unify_term<'cx, 'tcx>(
179179
) -> ProjectAndUnifyResult<'tcx> {
180180
let infcx = selcx.infcx;
181181
let r = infcx.commit_if_ok(|_snapshot| {
182-
let old_universe = infcx.universe();
183182
let placeholder_predicate = infcx.enter_forall_and_leak_universe(obligation.predicate);
184-
let new_universe = infcx.universe();
185183

186184
let placeholder_obligation = obligation.with(infcx.tcx, placeholder_predicate);
187185
match project_and_unify_term(selcx, &placeholder_obligation) {
188186
ProjectAndUnifyResult::MismatchedProjectionTypes(e) => Err(e),
189-
ProjectAndUnifyResult::Holds(obligations)
190-
if old_universe != new_universe
191-
&& selcx.tcx().features().generic_associated_types_extended() =>
192-
{
193-
// If the `generic_associated_types_extended` feature is active, then we ignore any
194-
// obligations references lifetimes from any universe greater than or equal to the
195-
// universe just created. Otherwise, we can end up with something like `for<'a> I: 'a`,
196-
// which isn't quite what we want. Ideally, we want either an implied
197-
// `for<'a where I: 'a> I: 'a` or we want to "lazily" check these hold when we
198-
// instantiate concrete regions. There is design work to be done here; until then,
199-
// however, this allows experimenting potential GAT features without running into
200-
// well-formedness issues.
201-
let new_obligations = obligations
202-
.into_iter()
203-
.filter(|obligation| {
204-
let mut visitor = MaxUniverse::new();
205-
obligation.predicate.visit_with(&mut visitor);
206-
visitor.max_universe() < new_universe
207-
})
208-
.collect();
209-
Ok(ProjectAndUnifyResult::Holds(new_obligations))
210-
}
211187
other => Ok(other),
212188
}
213189
});

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
626626
for assoc_type in assoc_types {
627627
let defs: &ty::Generics = tcx.generics_of(assoc_type);
628628

629-
if !defs.own_params.is_empty() && !tcx.features().generic_associated_types_extended() {
629+
if !defs.own_params.is_empty() {
630630
tcx.dcx().span_delayed_bug(
631631
obligation.cause.span,
632632
"GATs in trait object shouldn't have been considered",

tests/crashes/131538.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-generic_associated_types_extended.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-generic_associated_types_extended.stderr

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/ui/generic-associated-types/extended/lending_iterator.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
//@ revisions: base extended
2-
//@[base] check-fail
3-
//@[extended] check-pass
4-
5-
#![cfg_attr(extended, feature(generic_associated_types_extended))]
6-
#![cfg_attr(extended, allow(incomplete_features))]
1+
//@ known-bug: #133805
72

83
pub trait FromLendingIterator<A>: Sized {
94
fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
105
}
116

127
impl<A> FromLendingIterator<A> for Vec<A> {
138
fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self {
14-
//[base]~^ impl has stricter
159
let mut v = vec![];
1610
while let Some(item) = iter.next() {
1711
v.push(item);
@@ -32,7 +26,6 @@ pub trait LendingIterator {
3226
Self: for<'q> LendingIterator<Item<'q> = A>,
3327
{
3428
<B as FromLendingIterator<A>>::from_iter(self)
35-
//[base]~^ ERROR: does not live long enough
3629
}
3730
}
3831

tests/ui/generic-associated-types/extended/lending_iterator.base.stderr renamed to tests/ui/generic-associated-types/extended/lending_iterator.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0276]: impl has stricter requirements than trait
2-
--> $DIR/lending_iterator.rs:13:45
2+
--> $DIR/lending_iterator.rs:8:45
33
|
44
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
55
| ------------------------------------------------------------------------ definition of `from_iter` from trait
@@ -8,7 +8,7 @@ LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) ->
88
| ^^^^^^^^^^^^ impl has extra requirement `I: 'x`
99

1010
error: `Self` does not live long enough
11-
--> $DIR/lending_iterator.rs:34:9
11+
--> $DIR/lending_iterator.rs:28:9
1212
|
1313
LL | <B as FromLendingIterator<A>>::from_iter(self)
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)