Skip to content

Commit 081d24a

Browse files
committed
stabilize gai
1 parent 9c0bcb5 commit 081d24a

File tree

63 files changed

+106
-350
lines changed

Some content is hidden

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

63 files changed

+106
-350
lines changed

compiler/rustc_ast_lowering/messages.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ ast_lowering_template_modifier = template modifier
172172
173173
ast_lowering_this_not_async = this is not `async`
174174
175-
ast_lowering_underscore_array_length_unstable =
176-
using `_` for array lengths is unstable
177-
178175
ast_lowering_underscore_expr_lhs_assign =
179176
in expressions, `_` can only be used on the left-hand side of an assignment
180177
.label = `_` not allowed here

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use rustc_data_structures::sorted_map::SortedMap;
5050
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5151
use rustc_data_structures::sync::spawn;
5252
use rustc_data_structures::tagged_ptr::TaggedRef;
53-
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
53+
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
5454
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5555
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
5656
use rustc_hir::{
@@ -61,7 +61,7 @@ use rustc_index::{Idx, IndexSlice, IndexVec};
6161
use rustc_macros::extension;
6262
use rustc_middle::span_bug;
6363
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
64-
use rustc_session::parse::{add_feature_diagnostics, feature_err};
64+
use rustc_session::parse::add_feature_diagnostics;
6565
use rustc_span::symbol::{Ident, Symbol, kw, sym};
6666
use rustc_span::{DUMMY_SP, DesugaringKind, Span};
6767
use smallvec::{SmallVec, smallvec};
@@ -2068,15 +2068,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20682068
// `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
20692069
match c.value.peel_parens().kind {
20702070
ExprKind::Underscore => {
2071-
if !self.tcx.features().generic_arg_infer() {
2072-
feature_err(
2073-
&self.tcx.sess,
2074-
sym::generic_arg_infer,
2075-
c.value.span,
2076-
fluent_generated::ast_lowering_underscore_array_length_unstable,
2077-
)
2078-
.stash(c.value.span, StashKey::UnderscoreForArrayLengths);
2079-
}
20802071
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span), ());
20812072
self.arena.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
20822073
}

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ declare_features! (
220220
(accepted, fn_must_use, "1.27.0", Some(43302)),
221221
/// Allows capturing variables in scope using format_args!
222222
(accepted, format_args_capture, "1.58.0", Some(67984)),
223+
/// Infer generic args for both consts and types.
224+
(accepted, generic_arg_infer, "CURRENT_RUSTC_VERSION", Some(85077)),
223225
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
224226
(accepted, generic_associated_types, "1.65.0", Some(44265)),
225227
/// Allows attributes on lifetime/type formal parameters in generics (RFC 1327).

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,6 @@ declare_features! (
514514
(unstable, frontmatter, "1.88.0", Some(136889)),
515515
/// Allows defining gen blocks and `gen fn`.
516516
(unstable, gen_blocks, "1.75.0", Some(117078)),
517-
/// Infer generic args for both consts and types.
518-
(unstable, generic_arg_infer, "1.55.0", Some(85077)),
519517
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers
520518
(incomplete, generic_const_exprs, "1.56.0", Some(76560)),
521519
/// Allows generic parameters and where-clauses on free & associated const items.

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,6 @@ fn infer_placeholder_type<'tcx>(
452452
if let Some(ty) = node.ty() {
453453
visitor.visit_ty_unambig(ty);
454454
}
455-
// If we have just one span, let's try to steal a const `_` feature error.
456-
let try_steal_span = if !tcx.features().generic_arg_infer() && visitor.spans.len() == 1
457-
{
458-
visitor.spans.first().copied()
459-
} else {
460-
None
461-
};
462455
// If we didn't find any infer tys, then just fallback to `span`.
463456
if visitor.spans.is_empty() {
464457
visitor.spans.push(span);
@@ -489,15 +482,7 @@ fn infer_placeholder_type<'tcx>(
489482
}
490483
}
491484

492-
if let Some(try_steal_span) = try_steal_span {
493-
cx.dcx().try_steal_replace_and_emit_err(
494-
try_steal_span,
495-
StashKey::UnderscoreForArrayLengths,
496-
diag,
497-
)
498-
} else {
499-
diag.emit()
500-
}
485+
diag.emit()
501486
});
502487
Ty::new_error(tcx, guar)
503488
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::ty::{
88
self, GenericArgsRef, GenericParamDef, GenericParamDefKind, IsSuggestable, Ty,
99
};
1010
use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS;
11-
use rustc_span::{kw, sym};
11+
use rustc_span::kw;
1212
use smallvec::SmallVec;
1313
use tracing::{debug, instrument};
1414

@@ -258,19 +258,6 @@ pub fn lower_generic_args<'tcx: 'a, 'a>(
258258
GenericParamDefKind::Const { .. },
259259
_,
260260
) => {
261-
if let GenericParamDefKind::Const { .. } = param.kind
262-
&& let GenericArg::Infer(inf) = arg
263-
&& !tcx.features().generic_arg_infer()
264-
{
265-
rustc_session::parse::feature_err(
266-
tcx.sess,
267-
sym::generic_arg_infer,
268-
inf.span,
269-
"const arguments cannot yet be inferred with `_`",
270-
)
271-
.emit();
272-
}
273-
274261
// We lower to an infer even when the feature gate is not enabled
275262
// as it is useful for diagnostics to be able to see a `ConstKind::Infer`
276263
args.push(ctx.provided_kind(&args, param, arg));

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
#![feature(f16)]
154154
#![feature(freeze_impls)]
155155
#![feature(fundamental)]
156-
#![feature(generic_arg_infer)]
157156
#![feature(if_let_guard)]
158157
#![feature(intra_doc_pointers)]
159158
#![feature(intrinsics)]

src/tools/clippy/tests/ui/single_range_in_vec_init.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@no-rustfix: overlapping suggestions
33
#![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::useless_vec, unused)]
44
#![warn(clippy::single_range_in_vec_init)]
5-
#![feature(generic_arg_infer)]
65

76
#[macro_use]
87
extern crate proc_macros;

tests/crashes/111419.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ known-bug: #111419
22
#![allow(incomplete_features)]
3-
#![feature(generic_const_exprs, generic_arg_infer)]
3+
#![feature(generic_const_exprs)]
44

55
pub trait Example<const X: usize, const Y: usize, const Z: usize = { X + Y }>
66
where

tests/ui/array-slice-vec/suggest-array-length.fixed

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,9 @@ fn main() {
1010
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
1111
static REF_STATIK: &[u8; 1] = &[1];
1212
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
13-
let foo: [i32; 3] = [1, 2, 3];
14-
//~^ ERROR using `_` for array lengths is unstable
15-
let bar: [i32; 3] = [0; 3];
16-
//~^ ERROR using `_` for array lengths is unstable
17-
let ref_foo: &[i32; 3] = &[1, 2, 3];
18-
//~^ ERROR using `_` for array lengths is unstable
19-
let ref_bar: &[i32; 3] = &[0; 3];
20-
//~^ ERROR using `_` for array lengths is unstable
21-
let multiple_ref_foo: &&[i32; 3] = &&[1, 2, 3];
22-
//~^ ERROR using `_` for array lengths is unstable
13+
let foo: [i32; _] = [1, 2, 3];
14+
let bar: [i32; _] = [0; 3];
15+
let ref_foo: &[i32; _] = &[1, 2, 3];
16+
let ref_bar: &[i32; _] = &[0; 3];
17+
let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3];
2318
}

0 commit comments

Comments
 (0)