Skip to content

Commit da476f1

Browse files
committed
Auto merge of #150640 - AprilNEA:mgca-merge-associated-const-equality, r=BoxyUwU
Merge `associated_const_equality` feature gate into MGCA Tracking Issues: #132980 #92827 Merge `associated_const_equality`(ACE) feature gate into `min_generic_const_args`(MGCA). - Replaces `features().associated_const_equality()` checks with `features().min_generic_const_args()` - Updates the parser to gate associated const equality under `min_generic_const_args` - Moves `associated_const_equality` to the removed features list - Removes the `associated_const_equality` method from the `Features` trait - Updates all affected tests and tools (rust-analyzer, clippy) Closes #150617 r? `@BoxyUwU`
2 parents 7c04f5d + 4421270 commit da476f1

File tree

66 files changed

+166
-162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+166
-162
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
505505
half_open_range_patterns_in_slices,
506506
"half-open range patterns in slices are unstable"
507507
);
508-
gate_all!(associated_const_equality, "associated const equality is incomplete");
509508
gate_all!(yeet_expr, "`do yeet` expression is experimental");
510509
gate_all!(const_closures, "const closures are experimental");
511510
gate_all!(builtin_syntax, "`builtin #` syntax is unstable");
@@ -518,6 +517,23 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
518517
gate_all!(postfix_match, "postfix match is experimental");
519518
gate_all!(mut_ref, "mutable by-reference bindings are experimental");
520519
gate_all!(min_generic_const_args, "unbraced const blocks as const args are experimental");
520+
// associated_const_equality is stabilized as part of min_generic_const_args
521+
if let Some(spans) = spans.get(&sym::associated_const_equality) {
522+
for span in spans {
523+
if !visitor.features.min_generic_const_args()
524+
&& !span.allows_unstable(sym::min_generic_const_args)
525+
{
526+
#[allow(rustc::untranslatable_diagnostic)]
527+
feature_err(
528+
&visitor.sess,
529+
sym::min_generic_const_args,
530+
*span,
531+
"associated const equality is incomplete",
532+
)
533+
.emit();
534+
}
535+
}
536+
}
521537
gate_all!(global_registration, "global registration is experimental");
522538
gate_all!(return_type_notation, "return type notation is experimental");
523539
gate_all!(pin_ergonomics, "pinned reference syntax is experimental");

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ fn push_debuginfo_type_name<'tcx>(
260260
.map(|bound| {
261261
let ExistentialProjection { def_id: item_def_id, term, .. } =
262262
tcx.instantiate_bound_regions_with_erased(bound);
263-
// FIXME(associated_const_equality): allow for consts here
263+
// FIXME(mgca): allow for consts here
264264
(item_def_id, term.expect_type())
265265
})
266266
.collect();

compiler/rustc_feature/src/removed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ declare_features! (
6060
(removed, allocator, "1.0.0", None, None),
6161
/// Allows a test to fail without failing the whole suite.
6262
(removed, allow_fail, "1.60.0", Some(46488), Some("removed due to no clear use cases"), 93416),
63+
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
64+
(removed, associated_const_equality, "CURRENT_RUSTC_VERSION", Some(92827),
65+
Some("merged into `min_generic_const_args`")),
6366
(removed, await_macro, "1.38.0", Some(50547),
6467
Some("subsumed by `.await` syntax"), 62293),
6568
/// Allows using the `box $expr` syntax.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,6 @@ declare_features! (
363363
(unstable, asm_goto_with_outputs, "1.85.0", Some(119364)),
364364
/// Allows the `may_unwind` option in inline assembly.
365365
(unstable, asm_unwind, "1.58.0", Some(93334)),
366-
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
367-
(unstable, associated_const_equality, "1.58.0", Some(92827)),
368366
/// Allows associated type defaults.
369367
(unstable, associated_type_defaults, "1.2.0", Some(29661)),
370368
/// Allows implementing `AsyncDrop`.

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
610610
AttributeKind::TypeConst(_)
611611
)
612612
{
613-
if tcx.features().min_generic_const_args()
614-
|| tcx.features().associated_const_equality()
615-
{
613+
if tcx.features().min_generic_const_args() {
616614
let mut err = self.dcx().struct_span_err(
617615
constraint.span,
618616
"use of trait associated const without `#[type_const]`",

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
239239
// `trait_object_dummy_self`, so check for that.
240240
let references_self = match pred.skip_binder().term.kind() {
241241
ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
242-
// FIXME(associated_const_equality): We should walk the const instead of not doing anything
242+
// FIXME(mgca): We should walk the const instead of not doing anything
243243
ty::TermKind::Const(_) => false,
244244
};
245245

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
359359
None
360360
};
361361

362-
// FIXME(associated_const_equality): This has quite a few false positives and negatives.
362+
// FIXME(mgca): This has quite a few false positives and negatives.
363363
let wrap_in_braces_sugg = if let Some(constraint) = constraint
364364
&& let Some(hir_ty) = constraint.ty()
365365
&& let ty = self.lower_ty(hir_ty)
366366
&& (ty.is_enum() || ty.references_error())
367-
&& tcx.features().associated_const_equality()
367+
&& tcx.features().min_generic_const_args()
368368
{
369369
Some(errors::AssocKindMismatchWrapInBracesSugg {
370370
lo: hir_ty.span.shrink_to_lo(),

compiler/rustc_middle/src/ty/context.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,10 +907,6 @@ impl<'tcx> rustc_type_ir::inherent::Features<TyCtxt<'tcx>> for &'tcx rustc_featu
907907
self.coroutine_clone()
908908
}
909909

910-
fn associated_const_equality(self) -> bool {
911-
self.associated_const_equality()
912-
}
913-
914910
fn feature_bound_holds_in_crate(self, symbol: Symbol) -> bool {
915911
// We don't consider feature bounds to hold in the crate when `staged_api` feature is
916912
// enabled, even if it is enabled through `#[feature]`.

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ where
868868
.map(|(pred, _)| pred),
869869
));
870870

871-
// FIXME(associated_const_equality): Also add associated consts to
871+
// FIXME(mgca): Also add associated consts to
872872
// the requirements here.
873873
for associated_type_def_id in cx.associated_type_def_ids(trait_ref.def_id) {
874874
// associated types that require `Self: Sized` do not show up in the built-in

compiler/rustc_type_ir/src/inherent.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,6 @@ pub trait Features<I: Interner>: Copy {
646646

647647
fn coroutine_clone(self) -> bool;
648648

649-
fn associated_const_equality(self) -> bool;
650-
651649
fn feature_bound_holds_in_crate(self, symbol: I::Symbol) -> bool;
652650
}
653651

0 commit comments

Comments
 (0)