Skip to content

Commit 077c8ba

Browse files
committed
stabilize gai
1 parent 9c0bcb5 commit 077c8ba

File tree

58 files changed

+104
-252
lines changed

Some content is hidden

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

58 files changed

+104
-252
lines changed

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
@@ -222,6 +222,8 @@ declare_features! (
222222
(accepted, format_args_capture, "1.58.0", Some(67984)),
223223
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
224224
(accepted, generic_associated_types, "1.65.0", Some(44265)),
225+
/// Infer generic args for both consts and types.
226+
(accepted, generic_arg_infer, "CURRENT_RUSTC_VERSION", Some(85077)),
225227
/// Allows attributes on lifetime/type formal parameters in generics (RFC 1327).
226228
(accepted, generic_param_attrs, "1.27.0", Some(48848)),
227229
/// Allows the `#[global_allocator]` attribute.

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/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
}

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

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

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

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -46,57 +46,6 @@ LL - static REF_STATIK: &[u8; _] = &[1];
4646
LL + static REF_STATIK: &[u8; 1] = &[1];
4747
|
4848

49-
error[E0658]: using `_` for array lengths is unstable
50-
--> $DIR/suggest-array-length.rs:13:20
51-
|
52-
LL | let foo: [i32; _] = [1, 2, 3];
53-
| ^ help: consider specifying the array length: `3`
54-
|
55-
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
56-
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
57-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
58-
59-
error[E0658]: using `_` for array lengths is unstable
60-
--> $DIR/suggest-array-length.rs:15:20
61-
|
62-
LL | let bar: [i32; _] = [0; 3];
63-
| ^ help: consider specifying the array length: `3`
64-
|
65-
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
66-
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
67-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
68-
69-
error[E0658]: using `_` for array lengths is unstable
70-
--> $DIR/suggest-array-length.rs:17:25
71-
|
72-
LL | let ref_foo: &[i32; _] = &[1, 2, 3];
73-
| ^ help: consider specifying the array length: `3`
74-
|
75-
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
76-
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
77-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
78-
79-
error[E0658]: using `_` for array lengths is unstable
80-
--> $DIR/suggest-array-length.rs:19:25
81-
|
82-
LL | let ref_bar: &[i32; _] = &[0; 3];
83-
| ^ help: consider specifying the array length: `3`
84-
|
85-
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
86-
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
87-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
88-
89-
error[E0658]: using `_` for array lengths is unstable
90-
--> $DIR/suggest-array-length.rs:21:35
91-
|
92-
LL | let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3];
93-
| ^ help: consider specifying the array length: `3`
94-
|
95-
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
96-
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
97-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
98-
99-
error: aborting due to 9 previous errors
49+
error: aborting due to 4 previous errors
10050

101-
Some errors have detailed explanations: E0121, E0658.
102-
For more information about an error, try `rustc --explain E0121`.
51+
For more information about this error, try `rustc --explain E0121`.

tests/ui/async-await/issues/issue-95307.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
pub trait C {
77
async fn new() -> [u8; _];
88
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions
9-
//~| ERROR using `_` for array lengths is unstable
109
}
1110

1211
fn main() {}

tests/ui/async-await/issues/issue-95307.stderr

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
44
LL | async fn new() -> [u8; _];
55
| ^ not allowed in type signatures
66

7-
error[E0658]: using `_` for array lengths is unstable
8-
--> $DIR/issue-95307.rs:7:28
9-
|
10-
LL | async fn new() -> [u8; _];
11-
| ^
12-
|
13-
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
14-
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
15-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
16-
17-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
188

19-
Some errors have detailed explanations: E0121, E0658.
20-
For more information about an error, try `rustc --explain E0121`.
9+
For more information about this error, try `rustc --explain E0121`.

tests/ui/closures/binder/forbid_ambig_const_infers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(generic_arg_infer, closure_lifetime_binder)]
1+
#![feature(closure_lifetime_binder)]
22

33
struct Foo<const N: usize>([u32; N]);
44

tests/ui/closures/binder/forbid_ambig_type_infers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(generic_arg_infer, closure_lifetime_binder)]
1+
#![feature(closure_lifetime_binder)]
22

33
struct Foo<T>(T);
44

tests/ui/closures/binder/forbid_const_infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(generic_arg_infer, closure_lifetime_binder)]
1+
#![feature(closure_lifetime_binder)]
22

33
fn main() {
44
let c = for<'a> |b: &'a [u32; _]| -> u32 { b[0] };

tests/ui/const-generics/generic_arg_infer/array-repeat-expr-lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ check-pass
22

3-
#![feature(generic_arg_infer)]
43
#![crate_type = "lib"]
54

65
// Test that encoding the hallucinated `DefId` for the `_` const argument doesn't

tests/ui/const-generics/generic_arg_infer/array-repeat-expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ run-pass
22

33
// To avoid having to `or` gate `_` as an expr.
4-
#![feature(generic_arg_infer)]
54

65
fn foo() -> [u8; 3] {
76
let x: [u8; _] = [0; _];

tests/ui/const-generics/generic_arg_infer/dont-use-defaults.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ run-pass
2-
#![feature(generic_arg_infer)]
32

43
// test that we dont use defaults to aide in type inference
54

tests/ui/const-generics/generic_arg_infer/in-signature.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_type = "rlib"]
2-
#![feature(generic_arg_infer)]
32

43
struct Foo<const N: usize>;
54
struct Bar<T, const N: usize>(T);

0 commit comments

Comments
 (0)