Skip to content
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
18 changes: 17 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
half_open_range_patterns_in_slices,
"half-open range patterns in slices are unstable"
);
gate_all!(associated_const_equality, "associated const equality is incomplete");
gate_all!(yeet_expr, "`do yeet` expression is experimental");
gate_all!(const_closures, "const closures are experimental");
gate_all!(builtin_syntax, "`builtin #` syntax is unstable");
Expand All @@ -518,6 +517,23 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
gate_all!(postfix_match, "postfix match is experimental");
gate_all!(mut_ref, "mutable by-reference bindings are experimental");
gate_all!(min_generic_const_args, "unbraced const blocks as const args are experimental");
// associated_const_equality is stabilized as part of min_generic_const_args
if let Some(spans) = spans.get(&sym::associated_const_equality) {
for span in spans {
if !visitor.features.min_generic_const_args()
&& !span.allows_unstable(sym::min_generic_const_args)
{
#[allow(rustc::untranslatable_diagnostic)]
feature_err(
&visitor.sess,
sym::min_generic_const_args,
*span,
"associated const equality is incomplete",
)
.emit();
}
}
}
gate_all!(global_registration, "global registration is experimental");
gate_all!(return_type_notation, "return type notation is experimental");
gate_all!(pin_ergonomics, "pinned reference syntax is experimental");
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fn push_debuginfo_type_name<'tcx>(
.map(|bound| {
let ExistentialProjection { def_id: item_def_id, term, .. } =
tcx.instantiate_bound_regions_with_erased(bound);
// FIXME(associated_const_equality): allow for consts here
// FIXME(mgca): allow for consts here
(item_def_id, term.expect_type())
})
.collect();
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ declare_features! (
(removed, allocator, "1.0.0", None, None),
/// Allows a test to fail without failing the whole suite.
(removed, allow_fail, "1.60.0", Some(46488), Some("removed due to no clear use cases"), 93416),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
(removed, associated_const_equality, "CURRENT_RUSTC_VERSION", Some(92827),
Some("merged into `min_generic_const_args`")),
(removed, await_macro, "1.38.0", Some(50547),
Some("subsumed by `.await` syntax"), 62293),
/// Allows using the `box $expr` syntax.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,6 @@ declare_features! (
(unstable, asm_goto_with_outputs, "1.85.0", Some(119364)),
/// Allows the `may_unwind` option in inline assembly.
(unstable, asm_unwind, "1.58.0", Some(93334)),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
(unstable, associated_const_equality, "1.58.0", Some(92827)),
/// Allows associated type defaults.
(unstable, associated_type_defaults, "1.2.0", Some(29661)),
/// Allows implementing `AsyncDrop`.
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
AttributeKind::TypeConst(_)
)
{
if tcx.features().min_generic_const_args()
|| tcx.features().associated_const_equality()
{
if tcx.features().min_generic_const_args() {
let mut err = self.dcx().struct_span_err(
constraint.span,
"use of trait associated const without `#[type_const]`",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// `trait_object_dummy_self`, so check for that.
let references_self = match pred.skip_binder().term.kind() {
ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
// FIXME(associated_const_equality): We should walk the const instead of not doing anything
// FIXME(mgca): We should walk the const instead of not doing anything
ty::TermKind::Const(_) => false,
};

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
None
};

// FIXME(associated_const_equality): This has quite a few false positives and negatives.
// FIXME(mgca): This has quite a few false positives and negatives.
let wrap_in_braces_sugg = if let Some(constraint) = constraint
&& let Some(hir_ty) = constraint.ty()
&& let ty = self.lower_ty(hir_ty)
&& (ty.is_enum() || ty.references_error())
&& tcx.features().associated_const_equality()
&& tcx.features().min_generic_const_args()
{
Some(errors::AssocKindMismatchWrapInBracesSugg {
lo: hir_ty.span.shrink_to_lo(),
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,6 @@ impl<'tcx> rustc_type_ir::inherent::Features<TyCtxt<'tcx>> for &'tcx rustc_featu
self.coroutine_clone()
}

fn associated_const_equality(self) -> bool {
self.associated_const_equality()
}

fn feature_bound_holds_in_crate(self, symbol: Symbol) -> bool {
// We don't consider feature bounds to hold in the crate when `staged_api` feature is
// enabled, even if it is enabled through `#[feature]`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ where
.map(|(pred, _)| pred),
));

// FIXME(associated_const_equality): Also add associated consts to
// FIXME(mgca): Also add associated consts to
// the requirements here.
for associated_type_def_id in cx.associated_type_def_ids(trait_ref.def_id) {
// associated types that require `Self: Sized` do not show up in the built-in
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_type_ir/src/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,6 @@ pub trait Features<I: Interner>: Copy {

fn coroutine_clone(self) -> bool;

fn associated_const_equality(self) -> bool;

fn feature_bound_holds_in_crate(self, symbol: I::Symbol) -> bool;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![deny(clippy::trait_duplication_in_bounds)]
#![expect(incomplete_features)]
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]

trait AssocConstTrait {
#[type_const]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![deny(clippy::trait_duplication_in_bounds)]
#![expect(incomplete_features)]
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]

trait AssocConstTrait {
#[type_const]
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ impl<'db, 'a> TyLoweringContext<'db, 'a> {
TermKind::Ty(ty) => {
ty.walk().any(|arg| arg == dummy_self_ty.into())
}
// FIXME(associated_const_equality): We should walk the const instead of not doing anything
// FIXME(mgca): We should walk the const instead of not doing anything
TermKind::Const(_) => false,
};

Expand Down
2 changes: 1 addition & 1 deletion tests/crashes/mgca/ace-with-const-ctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// readded once fixed.
// Previous issue (before mgca): https://github.com/rust-lang/rust/issues/105952
#![crate_name = "foo"]
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]
pub enum ParseMode {
Raw,
}
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/associated-constant-not-allowed-102467.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// It ensures that the expected error is displayed.

#![expect(incomplete_features)]
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]

trait T {
type A: S<C<X = 0i32> = 34>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![expect(incomplete_features)]
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]

pub fn accept(_: impl Trait<K = 0>) {}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-consts/assoc-const-eq-ambiguity.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// We used to say "ambiguous associated type" on ambiguous associated consts.
// Ensure that we now use the correct label.

#![feature(associated_const_equality, min_generic_const_args, unsized_const_params)]
#![feature(min_generic_const_args, unsized_const_params)]
#![allow(incomplete_features)]

trait Trait0: Parent0<i32> + Parent0<u32> {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Check that we eventually catch types of assoc const bounds
// (containing late-bound vars) that are ill-formed.
#![feature(
associated_const_equality,
min_generic_const_args,
adt_const_params,
unsized_const_params,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: higher-ranked subtype error
--> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:22:13
--> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:21:13
|
LL | K = const { () }
| ^^^^^^^^^^^^

error: higher-ranked subtype error
--> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:22:13
--> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:21:13
|
LL | K = const { () }
| ^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//@ check-pass

#![feature(
associated_const_equality,
min_generic_const_args,
adt_const_params,
unsized_const_params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// issue: <https://github.com/rust-lang/rust/issues/108220>
//@ check-pass
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]

pub trait TraitA<T> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Detect and reject escaping late-bound generic params in
// the type of assoc consts used in an equality bound.
#![feature(
associated_const_equality,
min_generic_const_args,
unsized_const_params,
generic_const_parameter_types,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: the type of the associated constant `K` cannot capture late-bound generic parameters
--> $DIR/assoc-const-eq-esc-bound-var-in-ty.rs:16:35
--> $DIR/assoc-const-eq-esc-bound-var-in-ty.rs:15:35
|
LL | fn take(_: impl for<'r> Trait<'r, K = const { &() }>) {}
| -- ^ its type cannot capture the late-bound lifetime parameter `'r`
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/associated-consts/assoc-const-eq-missing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(associated_const_equality)]
#![allow(unused)]
#![feature(min_generic_const_args)]
#![allow(incomplete_features, unused)]

pub trait Foo {
const N: usize;
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-consts/assoc-const-eq-param-in-ty.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Regression test for issue #108271.
// Detect and reject generic params in the type of assoc consts used in an equality bound.
#![feature(
associated_const_equality,
min_generic_const_args,
adt_const_params,
unsized_const_params,
Expand Down
22 changes: 11 additions & 11 deletions tests/ui/associated-consts/assoc-const-eq-param-in-ty.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:23:29
--> $DIR/assoc-const-eq-param-in-ty.rs:22:29
|
LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
| -- the lifetime parameter `'r` is defined here
Expand All @@ -10,7 +10,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }>
= note: `K` has type `&'r [A; Q]`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:23:29
--> $DIR/assoc-const-eq-param-in-ty.rs:22:29
|
LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
| - the type parameter `A` is defined here
Expand All @@ -21,7 +21,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }>
= note: `K` has type `&'r [A; Q]`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:23:29
--> $DIR/assoc-const-eq-param-in-ty.rs:22:29
|
LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
| - the const parameter `Q` is defined here
Expand All @@ -32,7 +32,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }>
= note: `K` has type `&'r [A; Q]`

error: the type of the associated constant `SELF` must not depend on `impl Trait`
--> $DIR/assoc-const-eq-param-in-ty.rs:40:26
--> $DIR/assoc-const-eq-param-in-ty.rs:39:26
|
LL | fn take1(_: impl Project<SELF = const {}>) {}
| -------------^^^^------------
Expand All @@ -41,7 +41,7 @@ LL | fn take1(_: impl Project<SELF = const {}>) {}
| the `impl Trait` is specified here

error: the type of the associated constant `SELF` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:45:21
--> $DIR/assoc-const-eq-param-in-ty.rs:44:21
|
LL | fn take2<P: Project<SELF = const {}>>(_: P) {}
| - ^^^^ its type must not depend on the type parameter `P`
Expand All @@ -51,7 +51,7 @@ LL | fn take2<P: Project<SELF = const {}>>(_: P) {}
= note: `SELF` has type `P`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:54:52
--> $DIR/assoc-const-eq-param-in-ty.rs:53:52
|
LL | trait Iface<'r>: ConstParamTy_ {
| -- the lifetime parameter `'r` is defined here
Expand All @@ -62,15 +62,15 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
= note: `K` has type `&'r [Self; Q]`

error: the type of the associated constant `K` must not depend on `Self`
--> $DIR/assoc-const-eq-param-in-ty.rs:54:52
--> $DIR/assoc-const-eq-param-in-ty.rs:53:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
| ^ its type must not depend on `Self`
|
= note: `K` has type `&'r [Self; Q]`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:54:52
--> $DIR/assoc-const-eq-param-in-ty.rs:53:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
| - ^ its type must not depend on the const parameter `Q`
Expand All @@ -80,7 +80,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
= note: `K` has type `&'r [Self; Q]`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:54:52
--> $DIR/assoc-const-eq-param-in-ty.rs:53:52
|
LL | trait Iface<'r>: ConstParamTy_ {
| -- the lifetime parameter `'r` is defined here
Expand All @@ -92,7 +92,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: the type of the associated constant `K` must not depend on `Self`
--> $DIR/assoc-const-eq-param-in-ty.rs:54:52
--> $DIR/assoc-const-eq-param-in-ty.rs:53:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
| ^ its type must not depend on `Self`
Expand All @@ -101,7 +101,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:54:52
--> $DIR/assoc-const-eq-param-in-ty.rs:53:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
| - ^ its type must not depend on the const parameter `Q`
Expand Down
1 change: 0 additions & 1 deletion tests/ui/associated-consts/assoc-const-eq-supertraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//@ check-pass

#![feature(
associated_const_equality,
min_generic_const_args,
adt_const_params,
unsized_const_params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//@ check-pass

#![feature(associated_const_equality, min_generic_const_args, unsized_const_params)]
#![feature(min_generic_const_args, unsized_const_params)]
#![allow(incomplete_features)]

trait Trait: SuperTrait {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/associated-consts/assoc-const-ty-mismatch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(associated_const_equality)]
#![allow(unused)]
#![feature(min_generic_const_args)]
#![allow(incomplete_features, unused)]

pub trait Foo {
const N: usize;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-consts/assoc-const.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ run-pass
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]
#![allow(unused, incomplete_features)]

pub trait Foo {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-consts/equality-unused-issue-126729.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ check-pass

#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
#![deny(dead_code)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-consts/issue-102335-const.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(associated_const_equality, min_generic_const_args)]
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]

trait T {
Expand Down
Loading
Loading