Rollup merge of #141610 - BoxyUwU:stabilize_generic_arg_infer, r=lcnr,traviscross

Stabilize `feature(generic_arg_infer)`

Fixes rust-lang/rust#85077

r? lcnr

cc ````@rust-lang/project-const-generics````
This commit is contained in:
Jakub Beránek 2025-06-18 18:06:49 +02:00 committed by GitHub
commit 0093ca5c76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 116 additions and 377 deletions

View file

@ -172,9 +172,6 @@ ast_lowering_template_modifier = template modifier
ast_lowering_this_not_async = this is not `async`
ast_lowering_underscore_array_length_unstable =
using `_` for array lengths is unstable
ast_lowering_underscore_expr_lhs_assign =
in expressions, `_` can only be used on the left-hand side of an assignment
.label = `_` not allowed here

View file

@ -48,7 +48,7 @@ use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::spawn;
use rustc_data_structures::tagged_ptr::TaggedRef;
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
use rustc_hir::lints::DelayedLint;
@ -60,7 +60,7 @@ use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_macros::extension;
use rustc_middle::span_bug;
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_session::parse::{add_feature_diagnostics, feature_err};
use rustc_session::parse::add_feature_diagnostics;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, DesugaringKind, Span};
use smallvec::SmallVec;
@ -2109,15 +2109,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
match c.value.peel_parens().kind {
ExprKind::Underscore => {
if !self.tcx.features().generic_arg_infer() {
feature_err(
&self.tcx.sess,
sym::generic_arg_infer,
c.value.span,
fluent_generated::ast_lowering_underscore_array_length_unstable,
)
.stash(c.value.span, StashKey::UnderscoreForArrayLengths);
}
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span), ());
self.arena.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
}

View file

@ -220,6 +220,8 @@ declare_features! (
(accepted, fn_must_use, "1.27.0", Some(43302)),
/// Allows capturing variables in scope using format_args!
(accepted, format_args_capture, "1.58.0", Some(67984)),
/// Infer generic args for both consts and types.
(accepted, generic_arg_infer, "CURRENT_RUSTC_VERSION", Some(85077)),
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
(accepted, generic_associated_types, "1.65.0", Some(44265)),
/// Allows attributes on lifetime/type formal parameters in generics (RFC 1327).

View file

@ -520,8 +520,6 @@ declare_features! (
(unstable, frontmatter, "1.88.0", Some(136889)),
/// Allows defining gen blocks and `gen fn`.
(unstable, gen_blocks, "1.75.0", Some(117078)),
/// Infer generic args for both consts and types.
(unstable, generic_arg_infer, "1.55.0", Some(85077)),
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers
(incomplete, generic_const_exprs, "1.56.0", Some(76560)),
/// Allows generic parameters and where-clauses on free & associated const items.

View file

@ -452,13 +452,6 @@ fn infer_placeholder_type<'tcx>(
if let Some(ty) = node.ty() {
visitor.visit_ty_unambig(ty);
}
// If we have just one span, let's try to steal a const `_` feature error.
let try_steal_span = if !tcx.features().generic_arg_infer() && visitor.spans.len() == 1
{
visitor.spans.first().copied()
} else {
None
};
// If we didn't find any infer tys, then just fallback to `span`.
if visitor.spans.is_empty() {
visitor.spans.push(span);
@ -489,15 +482,7 @@ fn infer_placeholder_type<'tcx>(
}
}
if let Some(try_steal_span) = try_steal_span {
cx.dcx().try_steal_replace_and_emit_err(
try_steal_span,
StashKey::UnderscoreForArrayLengths,
diag,
)
} else {
diag.emit()
}
diag.emit()
});
Ty::new_error(tcx, guar)
}

View file

@ -8,7 +8,7 @@ use rustc_middle::ty::{
self, GenericArgsRef, GenericParamDef, GenericParamDefKind, IsSuggestable, Ty,
};
use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS;
use rustc_span::{kw, sym};
use rustc_span::kw;
use smallvec::SmallVec;
use tracing::{debug, instrument};
@ -258,19 +258,6 @@ pub fn lower_generic_args<'tcx: 'a, 'a>(
GenericParamDefKind::Const { .. },
_,
) => {
if let GenericParamDefKind::Const { .. } = param.kind
&& let GenericArg::Infer(inf) = arg
&& !tcx.features().generic_arg_infer()
{
rustc_session::parse::feature_err(
tcx.sess,
sym::generic_arg_infer,
inf.span,
"const arguments cannot yet be inferred with `_`",
)
.emit();
}
// We lower to an infer even when the feature gate is not enabled
// as it is useful for diagnostics to be able to see a `ConstKind::Infer`
args.push(ctx.provided_kind(&args, param, arg));

View file

@ -153,7 +153,6 @@
#![feature(f16)]
#![feature(freeze_impls)]
#![feature(fundamental)]
#![feature(generic_arg_infer)]
#![feature(if_let_guard)]
#![feature(intra_doc_pointers)]
#![feature(intrinsics)]

View file

@ -2,7 +2,6 @@
//@no-rustfix: overlapping suggestions
#![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::useless_vec, unused)]
#![warn(clippy::single_range_in_vec_init)]
#![feature(generic_arg_infer)]
#[macro_use]
extern crate proc_macros;

View file

@ -1,5 +1,5 @@
error: an array of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:26:5
--> tests/ui/single_range_in_vec_init.rs:25:5
|
LL | [0..200];
| ^^^^^^^^
@ -18,7 +18,7 @@ LL + [0; 200];
|
error: a `Vec` of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:28:5
--> tests/ui/single_range_in_vec_init.rs:27:5
|
LL | vec![0..200];
| ^^^^^^^^^^^^
@ -35,7 +35,7 @@ LL + vec![0; 200];
|
error: an array of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:30:5
--> tests/ui/single_range_in_vec_init.rs:29:5
|
LL | [0u8..200];
| ^^^^^^^^^^
@ -52,7 +52,7 @@ LL + [0u8; 200];
|
error: an array of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:32:5
--> tests/ui/single_range_in_vec_init.rs:31:5
|
LL | [0usize..200];
| ^^^^^^^^^^^^^
@ -69,7 +69,7 @@ LL + [0usize; 200];
|
error: an array of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:34:5
--> tests/ui/single_range_in_vec_init.rs:33:5
|
LL | [0..200usize];
| ^^^^^^^^^^^^^
@ -86,7 +86,7 @@ LL + [0; 200usize];
|
error: a `Vec` of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:36:5
--> tests/ui/single_range_in_vec_init.rs:35:5
|
LL | vec![0u8..200];
| ^^^^^^^^^^^^^^
@ -103,7 +103,7 @@ LL + vec![0u8; 200];
|
error: a `Vec` of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:38:5
--> tests/ui/single_range_in_vec_init.rs:37:5
|
LL | vec![0usize..200];
| ^^^^^^^^^^^^^^^^^
@ -120,7 +120,7 @@ LL + vec![0usize; 200];
|
error: a `Vec` of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:40:5
--> tests/ui/single_range_in_vec_init.rs:39:5
|
LL | vec![0..200usize];
| ^^^^^^^^^^^^^^^^^
@ -137,7 +137,7 @@ LL + vec![0; 200usize];
|
error: an array of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:43:5
--> tests/ui/single_range_in_vec_init.rs:42:5
|
LL | [0..200isize];
| ^^^^^^^^^^^^^
@ -149,7 +149,7 @@ LL + (0..200isize).collect::<std::vec::Vec<isize>>();
|
error: a `Vec` of `Range` that is only one element
--> tests/ui/single_range_in_vec_init.rs:45:5
--> tests/ui/single_range_in_vec_init.rs:44:5
|
LL | vec![0..200isize];
| ^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,6 @@
//@ known-bug: #111419
#![allow(incomplete_features)]
#![feature(generic_const_exprs, generic_arg_infer)]
#![feature(generic_const_exprs)]
pub trait Example<const X: usize, const Y: usize, const Z: usize = { X + Y }>
where

View file

@ -10,14 +10,9 @@ fn main() {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
static REF_STATIK: &[u8; 1] = &[1];
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
let foo: [i32; 3] = [1, 2, 3];
//~^ ERROR using `_` for array lengths is unstable
let bar: [i32; 3] = [0; 3];
//~^ ERROR using `_` for array lengths is unstable
let ref_foo: &[i32; 3] = &[1, 2, 3];
//~^ ERROR using `_` for array lengths is unstable
let ref_bar: &[i32; 3] = &[0; 3];
//~^ ERROR using `_` for array lengths is unstable
let multiple_ref_foo: &&[i32; 3] = &&[1, 2, 3];
//~^ ERROR using `_` for array lengths is unstable
let foo: [i32; _] = [1, 2, 3];
let bar: [i32; _] = [0; 3];
let ref_foo: &[i32; _] = &[1, 2, 3];
let ref_bar: &[i32; _] = &[0; 3];
let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3];
}

View file

@ -11,13 +11,8 @@ fn main() {
static REF_STATIK: &[u8; _] = &[1];
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
let foo: [i32; _] = [1, 2, 3];
//~^ ERROR using `_` for array lengths is unstable
let bar: [i32; _] = [0; 3];
//~^ ERROR using `_` for array lengths is unstable
let ref_foo: &[i32; _] = &[1, 2, 3];
//~^ ERROR using `_` for array lengths is unstable
let ref_bar: &[i32; _] = &[0; 3];
//~^ ERROR using `_` for array lengths is unstable
let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3];
//~^ ERROR using `_` for array lengths is unstable
}

View file

@ -46,57 +46,6 @@ LL - static REF_STATIK: &[u8; _] = &[1];
LL + static REF_STATIK: &[u8; 1] = &[1];
|
error[E0658]: using `_` for array lengths is unstable
--> $DIR/suggest-array-length.rs:13:20
|
LL | let foo: [i32; _] = [1, 2, 3];
| ^ help: consider specifying the array length: `3`
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 4 previous errors
error[E0658]: using `_` for array lengths is unstable
--> $DIR/suggest-array-length.rs:15:20
|
LL | let bar: [i32; _] = [0; 3];
| ^ help: consider specifying the array length: `3`
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: using `_` for array lengths is unstable
--> $DIR/suggest-array-length.rs:17:25
|
LL | let ref_foo: &[i32; _] = &[1, 2, 3];
| ^ help: consider specifying the array length: `3`
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: using `_` for array lengths is unstable
--> $DIR/suggest-array-length.rs:19:25
|
LL | let ref_bar: &[i32; _] = &[0; 3];
| ^ help: consider specifying the array length: `3`
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: using `_` for array lengths is unstable
--> $DIR/suggest-array-length.rs:21:35
|
LL | let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3];
| ^ help: consider specifying the array length: `3`
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0121, E0658.
For more information about an error, try `rustc --explain E0121`.
For more information about this error, try `rustc --explain E0121`.

View file

@ -6,7 +6,6 @@
pub trait C {
async fn new() -> [u8; _];
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions
//~| ERROR using `_` for array lengths is unstable
}
fn main() {}

View file

@ -4,17 +4,6 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
LL | async fn new() -> [u8; _];
| ^ not allowed in type signatures
error[E0658]: using `_` for array lengths is unstable
--> $DIR/issue-95307.rs:7:28
|
LL | async fn new() -> [u8; _];
| ^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0121, E0658.
For more information about an error, try `rustc --explain E0121`.
For more information about this error, try `rustc --explain E0121`.

View file

@ -1,4 +1,4 @@
#![feature(generic_arg_infer, closure_lifetime_binder)]
#![feature(closure_lifetime_binder)]
struct Foo<const N: usize>([u32; N]);

View file

@ -1,4 +1,4 @@
#![feature(generic_arg_infer, closure_lifetime_binder)]
#![feature(closure_lifetime_binder)]
struct Foo<T>(T);

View file

@ -1,4 +1,4 @@
#![feature(generic_arg_infer, closure_lifetime_binder)]
#![feature(closure_lifetime_binder)]
fn main() {
let c = for<'a> |b: &'a [u32; _]| -> u32 { b[0] };

View file

@ -1,4 +1,4 @@
#![feature(generic_arg_infer, associated_const_equality, generic_const_items)]
#![feature(associated_const_equality, generic_const_items)]
#![expect(incomplete_features)]
// Regression test for #133066 where we would try to evaluate `<() as Foo>::ASSOC<_>` even

View file

@ -1,6 +1,5 @@
//@ check-pass
#![feature(generic_arg_infer)]
#![crate_type = "lib"]
// Test that encoding the hallucinated `DefId` for the `_` const argument doesn't

View file

@ -1,7 +1,6 @@
//@ run-pass
// To avoid having to `or` gate `_` as an expr.
#![feature(generic_arg_infer)]
fn foo() -> [u8; 3] {
let x: [u8; _] = [0; _];

View file

@ -1,7 +1,4 @@
//@ run-pass
#![feature(generic_arg_infer)]
// test that we dont use defaults to aide in type inference
struct Foo<const N: usize = 2>;
impl<const N: usize> Foo<N> {

View file

@ -1,5 +1,4 @@
#![crate_type = "rlib"]
#![feature(generic_arg_infer)]
struct Foo<const N: usize>;
struct Bar<T, const N: usize>(T);

View file

@ -1,5 +1,5 @@
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
--> $DIR/in-signature.rs:7:21
--> $DIR/in-signature.rs:6:21
|
LL | fn arr_fn() -> [u8; _] {
| -----^-
@ -8,7 +8,7 @@ LL | fn arr_fn() -> [u8; _] {
| help: replace with the correct return type: `[u8; 3]`
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
--> $DIR/in-signature.rs:12:24
--> $DIR/in-signature.rs:11:24
|
LL | fn ty_fn() -> Bar<i32, _> {
| ---------^-
@ -17,7 +17,7 @@ LL | fn ty_fn() -> Bar<i32, _> {
| help: replace with the correct return type: `Bar<i32, 3>`
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
--> $DIR/in-signature.rs:17:25
--> $DIR/in-signature.rs:16:25
|
LL | fn ty_fn_mixed() -> Bar<_, _> {
| ----^--^-
@ -27,7 +27,7 @@ LL | fn ty_fn_mixed() -> Bar<_, _> {
| help: replace with the correct return type: `Bar<i32, 3>`
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
--> $DIR/in-signature.rs:22:20
--> $DIR/in-signature.rs:21:20
|
LL | const ARR_CT: [u8; _] = [0; 3];
| ^ not allowed in type signatures
@ -39,7 +39,7 @@ LL + const ARR_CT: [u8; 3] = [0; 3];
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
--> $DIR/in-signature.rs:24:25
--> $DIR/in-signature.rs:23:25
|
LL | static ARR_STATIC: [u8; _] = [0; 3];
| ^ not allowed in type signatures
@ -51,7 +51,7 @@ LL + static ARR_STATIC: [u8; 3] = [0; 3];
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
--> $DIR/in-signature.rs:26:23
--> $DIR/in-signature.rs:25:23
|
LL | const TY_CT: Bar<i32, _> = Bar::<i32, 3>(0);
| ^ not allowed in type signatures
@ -63,7 +63,7 @@ LL + const TY_CT: Bar<i32, 3> = Bar::<i32, 3>(0);
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
--> $DIR/in-signature.rs:28:28
--> $DIR/in-signature.rs:27:28
|
LL | static TY_STATIC: Bar<i32, _> = Bar::<i32, 3>(0);
| ^ not allowed in type signatures
@ -75,7 +75,7 @@ LL + static TY_STATIC: Bar<i32, 3> = Bar::<i32, 3>(0);
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
--> $DIR/in-signature.rs:30:24
--> $DIR/in-signature.rs:29:24
|
LL | const TY_CT_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
| ^ ^ not allowed in type signatures
@ -89,7 +89,7 @@ LL + const TY_CT_MIXED: Bar<i32, 3> = Bar::<i32, 3>(0);
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
--> $DIR/in-signature.rs:32:29
--> $DIR/in-signature.rs:31:29
|
LL | static TY_STATIC_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
| ^ ^ not allowed in type signatures
@ -103,19 +103,19 @@ LL + static TY_STATIC_MIXED: Bar<i32, 3> = Bar::<i32, 3>(0);
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types
--> $DIR/in-signature.rs:51:23
--> $DIR/in-signature.rs:50:23
|
LL | type Assoc = [u8; _];
| ^ not allowed in type signatures
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types
--> $DIR/in-signature.rs:55:27
--> $DIR/in-signature.rs:54:27
|
LL | type Assoc = Bar<i32, _>;
| ^ not allowed in type signatures
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types
--> $DIR/in-signature.rs:59:22
--> $DIR/in-signature.rs:58:22
|
LL | type Assoc = Bar<_, _>;
| ^ ^ not allowed in type signatures
@ -123,19 +123,19 @@ LL | type Assoc = Bar<_, _>;
| not allowed in type signatures
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
--> $DIR/in-signature.rs:35:21
--> $DIR/in-signature.rs:34:21
|
LL | const ARR: [u8; _];
| ^ not allowed in type signatures
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
--> $DIR/in-signature.rs:39:25
--> $DIR/in-signature.rs:38:25
|
LL | const ARR: Bar<i32, _>;
| ^ not allowed in type signatures
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
--> $DIR/in-signature.rs:43:20
--> $DIR/in-signature.rs:42:20
|
LL | const ARR: Bar<_, _>;
| ^ ^ not allowed in type signatures

View file

@ -1,5 +1,3 @@
#![feature(generic_arg_infer)]
struct All<'a, T, const N: usize> {
v: &'a T,
}

View file

@ -1,17 +1,17 @@
error: expected identifier, found reserved identifier `_`
--> $DIR/infer-arg-test.rs:7:17
--> $DIR/infer-arg-test.rs:5:17
|
LL | struct BadInfer<_>;
| ^ expected identifier, found reserved identifier
error: expected identifier, found reserved identifier `_`
--> $DIR/infer-arg-test.rs:13:17
--> $DIR/infer-arg-test.rs:11:17
|
LL | fn bad_infer_fn<_>() {}
| ^ expected identifier, found reserved identifier
error[E0392]: type parameter `_` is never used
--> $DIR/infer-arg-test.rs:7:17
--> $DIR/infer-arg-test.rs:5:17
|
LL | struct BadInfer<_>;
| ^ unused type parameter
@ -20,7 +20,7 @@ LL | struct BadInfer<_>;
= help: if you intended `_` to be a const parameter, use `const _: /* Type */` instead
error[E0107]: struct takes 2 generic arguments but 3 generic arguments were supplied
--> $DIR/infer-arg-test.rs:18:10
--> $DIR/infer-arg-test.rs:16:10
|
LL | let a: All<_, _, _>;
| ^^^ --- help: remove the unnecessary generic argument
@ -28,7 +28,7 @@ LL | let a: All<_, _, _>;
| expected 2 generic arguments
|
note: struct defined here, with 2 generic parameters: `T`, `N`
--> $DIR/infer-arg-test.rs:3:8
--> $DIR/infer-arg-test.rs:1:8
|
LL | struct All<'a, T, const N: usize> {
| ^^^ - --------------

View file

@ -1,5 +1,4 @@
//@ check-pass
#![feature(generic_arg_infer)]
struct Foo<const N: bool, const M: u8>;
struct Bar<const N: u8, const M: u32>;

View file

@ -1,5 +1,4 @@
#![feature(portable_simd)]
#![feature(generic_arg_infer)]
use std::simd::Mask;
fn main() {

View file

@ -1,5 +1,5 @@
error[E0284]: type annotations needed for `Mask<_, _>`
--> $DIR/issue-91614.rs:6:9
--> $DIR/issue-91614.rs:5:9
|
LL | let y = Mask::<_, _>::splat(false);
| ^ ------------ type must be known at this point
@ -12,7 +12,7 @@ LL | let y: Mask<_, N> = Mask::<_, _>::splat(false);
| ++++++++++++
error[E0284]: type annotations needed for `Mask<_, _>`
--> $DIR/issue-91614.rs:6:9
--> $DIR/issue-91614.rs:5:9
|
LL | let y = Mask::<_, _>::splat(false);
| ^ -------------------------- type must be known at this point

View file

@ -1,53 +0,0 @@
error[E0658]: const arguments cannot yet be inferred with `_`
--> $DIR/parend_infer.rs:24:16
|
LL | let c: Foo<_> = Foo::<1>;
| ^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const arguments cannot yet be inferred with `_`
--> $DIR/parend_infer.rs:26:16
|
LL | let c: Foo<(_)> = Foo::<1>;
| ^^^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const arguments cannot yet be inferred with `_`
--> $DIR/parend_infer.rs:28:16
|
LL | let c: Foo<(((_)))> = Foo::<1>;
| ^^^^^^^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: using `_` for array lengths is unstable
--> $DIR/parend_infer.rs:17:17
|
LL | let b: [u8; (_)] = [1; (((((_)))))];
| ^^^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: using `_` for array lengths is unstable
--> $DIR/parend_infer.rs:17:28
|
LL | let b: [u8; (_)] = [1; (((((_)))))];
| ^^^^^^^^^^^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,6 +1,4 @@
//@[gate] check-pass
//@ revisions: gate nogate
#![cfg_attr(gate, feature(generic_arg_infer))]
//@ check-pass
struct Foo<const N: usize>;
@ -15,16 +13,11 @@ fn main() {
// AST Exprs similarly preserve parens for pretty printing reasons.
#[rustfmt::skip]
let b: [u8; (_)] = [1; (((((_)))))];
//[nogate]~^ error: using `_` for array lengths is unstable
//[nogate]~| error: using `_` for array lengths is unstable
let b: [u8; 2] = b;
// This is the same case as AST types as the parser doesn't distinguish between const
// and type args when they share syntax
let c: Foo<_> = Foo::<1>;
//[nogate]~^ error: const arguments cannot yet be inferred with `_`
let c: Foo<(_)> = Foo::<1>;
//[nogate]~^ error: const arguments cannot yet be inferred with `_`
let c: Foo<(((_)))> = Foo::<1>;
//[nogate]~^ error: const arguments cannot yet be inferred with `_`
}

View file

@ -1,4 +1,4 @@
#![feature(generic_const_exprs, generic_arg_infer)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// minimized repro for #105205

View file

@ -3,7 +3,7 @@
//@ edition:2021
//@ check-pass
#![feature(generic_const_exprs, generic_arg_infer)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
#![allow(unused)]
@ -41,17 +41,13 @@ where
DigitalFilter::Ba(zpk)
}
pub fn zpk2tf_st<const N: usize>(
_z: &Arr<f32, N>,
_p: &Arr<f32, N>,
) -> BaFormatFilter<{ N + 1 }>
pub fn zpk2tf_st<const N: usize>(_z: &Arr<f32, N>, _p: &Arr<f32, N>) -> BaFormatFilter<{ N + 1 }>
where
[(); N + 1]: Sized,
{
BaFormatFilter {}
}
fn main() {
iirfilter_st_copy::<4, 2>([10., 50.,]);
iirfilter_st_copy::<4, 2>([10., 50.]);
}

View file

@ -1,9 +1,4 @@
#![feature(
adt_const_params,
unsized_const_params,
generic_const_parameter_types,
generic_arg_infer
)]
#![feature(adt_const_params, unsized_const_params, generic_const_parameter_types)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy_;

View file

@ -1,11 +1,11 @@
error: anonymous constants with inferred types are not yet supported
--> $DIR/bad_inference.rs:17:25
--> $DIR/bad_inference.rs:12:25
|
LL | let a = foo::<_, _, { [12_u8; 2] }>();
| ^^^^^^^^^^^^^^
error: anonymous constants with inferred types are not yet supported
--> $DIR/bad_inference.rs:21:34
--> $DIR/bad_inference.rs:16:34
|
LL | let b: [u8; 2] = foo::<_, _, { [12; _] }>();
| ^^^^^^^^^^^

View file

@ -1,11 +1,6 @@
//@ check-pass
#![feature(
adt_const_params,
unsized_const_params,
generic_const_parameter_types,
generic_arg_infer
)]
#![feature(adt_const_params, unsized_const_params, generic_const_parameter_types)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy_;

View file

@ -1,6 +1,6 @@
//@ check-pass
#![feature(adt_const_params, generic_arg_infer, generic_const_parameter_types)]
#![feature(adt_const_params, generic_const_parameter_types)]
#![expect(incomplete_features)]
struct Bar<const N: usize, const M: [u8; N]>;

View file

@ -1,11 +1,6 @@
//@ check-pass
#![feature(
adt_const_params,
unsized_const_params,
generic_const_parameter_types,
generic_arg_infer
)]
#![feature(adt_const_params, unsized_const_params, generic_const_parameter_types)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy_;

View file

@ -16,17 +16,6 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
LL + #![feature(adt_const_params)]
|
error[E0658]: const arguments cannot yet be inferred with `_`
--> $DIR/issue-62878.rs:10:11
|
LL | foo::<_, { [1] }>();
| ^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0658, E0770.
For more information about an error, try `rustc --explain E0658`.
For more information about this error, try `rustc --explain E0770`.

View file

@ -1,5 +1,5 @@
//@ revisions: full min
#![cfg_attr(full, feature(adt_const_params, generic_arg_infer))]
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
fn foo<const N: usize, const A: [u8; N]>() {}
@ -8,5 +8,4 @@ fn foo<const N: usize, const A: [u8; N]>() {}
fn main() {
foo::<_, { [1] }>();
//[min]~^ ERROR: const arguments cannot yet be inferred with `_`
}

View file

@ -1,4 +1,3 @@
#![feature(generic_arg_infer)]
//@ run-pass
fn foo<const N: usize, const K: usize>(_data: [u32; N]) -> [u32; K] {

View file

@ -1,33 +0,0 @@
error[E0658]: using `_` for array lengths is unstable
--> $DIR/feature-gate-generic_arg_infer.rs:13:18
|
LL | let _y: [u8; _] = [0; 3];
| ^ help: consider specifying the array length: `3`
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const arguments cannot yet be inferred with `_`
--> $DIR/feature-gate-generic_arg_infer.rs:18:20
|
LL | let _x = foo::<_>([1, 2]);
| ^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: using `_` for array lengths is unstable
--> $DIR/feature-gate-generic_arg_infer.rs:11:27
|
LL | let _x: [u8; 3] = [0; _];
| ^
|
= note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information
= help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,21 +0,0 @@
//@ [feature] run-pass
//@ revisions: normal feature
#![cfg_attr(feature, feature(generic_arg_infer))]
fn foo<const N: usize>(_: [u8; N]) -> [u8; N] {
[0; N]
}
fn bar() {
let _x: [u8; 3] = [0; _];
//[normal]~^ ERROR: using `_` for array lengths is unstable
let _y: [u8; _] = [0; 3];
//[normal]~^ ERROR: using `_` for array lengths is unstable
}
fn main() {
let _x = foo::<_>([1, 2]);
//[normal]~^ ERROR: const arguments cannot yet be inferred with `_`
bar();
}

View file

@ -56,14 +56,14 @@ fn ice() {
let arr = [0; 5];
//~^ ERROR requires `copy` lang_item
let _ = arr[2];
//~^ ERROR cannot index into a value of type `[{integer}; 5]`
//~^ ERROR: cannot index into a value of type `[{integer}; 5]`
// Use phantomdata
let _ = MyPhantomData::<(), i32>;
// Use Foo
let _: () = Foo;
//~^ ERROR mismatched types
//~^ ERROR: mismatched types
}
// use `start`

View file

@ -4,7 +4,6 @@
#![allow(dead_code)]
#![feature(generic_arg_infer)]
trait Test {
fn foo(&self) { }

View file

@ -1,7 +1,5 @@
//@ revisions: full generic_arg
// can't run rustfix because it doesn't handle multipart suggestions correctly
// we need the above to avoid ast borrowck failure in recovered code
#![cfg_attr(generic_arg, feature(generic_arg_infer))]
struct S<'a, T> {
a: &'a T,
@ -10,8 +8,7 @@ struct S<'a, T> {
fn foo<'a, 'b>(start: &'a usize, end: &'a usize) {
let _x = (*start..*end).map(|x| S { a: start, b: end }).collect::<Vec<S<_, 'a>>>();
//[generic_arg]~^ ERROR placeholder provided when a lifetime was expected
//[full]~^^ ERROR placeholder provided when a lifetime was expected
//~^ ERROR placeholder provided when a lifetime was expected
}
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0747]: placeholder provided when a lifetime was expected
--> $DIR/issue-14303-fncall.rs:10:77
|
LL | let _x = (*start..*end).map(|x| S { a: start, b: end }).collect::<Vec<S<_, 'a>>>();
| ^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0747`.

View file

@ -1,7 +1,6 @@
//@ check-pass
#![allow(unused_variables)]
#![feature(generic_arg_infer)]
struct Zeroes;
impl Into<&'static [usize; 3]> for Zeroes {

View file

@ -1,5 +1,3 @@
#![feature(generic_arg_infer)]
// Test when deferring repeat expr copy checks to end of typechecking whether elements
// that are const items allow for repeat counts to go uninferred without an error being
// emitted if they would later wind up inferred by integer fallback.

View file

@ -1,5 +1,5 @@
error[E0284]: type annotations needed for `[String; _]`
--> $DIR/copy-check-const-element-uninferred-count.rs:64:9
--> $DIR/copy-check-const-element-uninferred-count.rs:62:9
|
LL | let a = [const { String::new() }; _];
| ^ ---------------------------- type must be known at this point

View file

@ -1,5 +1,3 @@
#![feature(generic_arg_infer)]
// Test when deferring repeat expr copy checks to end of typechecking whether they're
// checked before integer fallback occurs or not. We accomplish this by having a repeat
// count that can only be inferred after integer fallback has occured. This test will

View file

@ -1,5 +1,5 @@
error[E0282]: type annotations needed for `[Foo<{integer}>; _]`
--> $DIR/copy-check-deferred-after-fallback.rs:39:9
--> $DIR/copy-check-deferred-after-fallback.rs:37:9
|
LL | let b = [Foo(PhantomData); _];
| ^ ---------------- type must be known at this point

View file

@ -1,5 +1,4 @@
//@ check-pass
#![feature(generic_arg_infer)]
// Test when deferring repeat expr checks to end of typechecking whether they're
// checked before integer fallback occurs. We accomplish this by having the repeat

View file

@ -1,5 +1,3 @@
#![feature(generic_arg_infer)]
struct Foo<const N: usize>;
impl Clone for Foo<1> {

View file

@ -1,5 +1,5 @@
error[E0282]: type annotations needed for `[Foo<_>; 2]`
--> $DIR/copy-check-inference-side-effects.rs:17:9
--> $DIR/copy-check-inference-side-effects.rs:15:9
|
LL | let a /* : [Foo<?x>; 2] */ = [Foo::<_>; 2];
| ^
@ -13,7 +13,7 @@ LL | let a: [Foo<N>; 2] /* : [Foo<?x>; 2] */ = [Foo::<_>; 2];
| +++++++++++++
error[E0282]: type annotations needed for `[String; _]`
--> $DIR/copy-check-inference-side-effects.rs:27:9
--> $DIR/copy-check-inference-side-effects.rs:25:9
|
LL | let b /* : [String; ?x] */ = ["string".to_string(); _];
| ^ -------------------- type must be known at this point

View file

@ -1,5 +1,3 @@
#![feature(generic_arg_infer)]
// Test that we enforce repeat expr element types are `Copy` even
// when the repeat count is only inferred at a later point in type
// checking.

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/copy-check-when-count-inferred-later.rs:8:14
--> $DIR/copy-check-when-count-inferred-later.rs:6:14
|
LL | let a = [String::new(); _];
| ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`

View file

@ -1,5 +1,4 @@
//@ check-pass
#![feature(generic_arg_infer)]
fn main() {
let a: [_; 1] = [String::new(); _];

View file

@ -1,5 +1,3 @@
#![feature(generic_arg_infer)]
struct Foo<const N: usize>;
impl Clone for Foo<1> {

View file

@ -1,5 +1,5 @@
error[E0282]: type annotations needed for `&[Foo<_>; _]`
--> $DIR/no-conservative-copy-impl-requirement.rs:17:9
--> $DIR/no-conservative-copy-impl-requirement.rs:15:9
|
LL | let x = &[Foo::<_>; _];
| ^ -------- type must be known at this point

View file

@ -4,7 +4,6 @@
//! Make sure that monomorphization-time const errors from `static_assert` take priority over the
//! error from simd_extract. Basically this checks that if a const fails to evaluate in some
//! function, we don't bother codegen'ing the function.
#![feature(generic_arg_infer)]
#![feature(core_intrinsics)]
#![feature(repr_simd)]

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation panicked: assertion failed: LANE < 4
--> $DIR/const-err-trumps-simd-err.rs:18:13
--> $DIR/const-err-trumps-simd-err.rs:17:13
|
LL | const { assert!(LANE < 4); } // the error should be here...
| ^^^^^^^^^^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here
note: erroneous constant encountered
--> $DIR/const-err-trumps-simd-err.rs:18:5
--> $DIR/const-err-trumps-simd-err.rs:17:5
|
LL | const { assert!(LANE < 4); } // the error should be here...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the above error was encountered while instantiating `fn get_elem::<4>`
--> $DIR/const-err-trumps-simd-err.rs:24:5
--> $DIR/const-err-trumps-simd-err.rs:23:5
|
LL | get_elem::<4>(int8x4_t([0, 0, 0, 0]));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,3 @@
//@ revisions: full generic_arg
#![cfg_attr(generic_arg, feature(generic_arg_infer))]
// When the type of a method call's receiver is unknown, the span should point
// to the receiver (and not the entire call, as was previously the case before
// the fix of which this tests).

View file

@ -0,0 +1,23 @@
error[E0282]: type annotations needed
--> $DIR/issue-42234-unknown-receiver-type.rs:6:24
|
LL | let x: Option<_> = None;
| ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
LL | x.unwrap().method_that_could_exist_on_some_type();
| ---------- type must be known at this point
|
help: consider specifying the generic argument
|
LL | let x: Option<_> = None::<T>;
| +++++
error[E0282]: type annotations needed
--> $DIR/issue-42234-unknown-receiver-type.rs:12:10
|
LL | .sum::<_>()
| ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0282`.

View file

@ -1,5 +1,4 @@
#![feature(const_trait_impl)]
#![feature(generic_arg_infer)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

View file

@ -1,35 +1,35 @@
error: `~const` is not allowed here
--> $DIR/tilde-const-and-const-params.rs:9:15
--> $DIR/tilde-const-and-const-params.rs:8:15
|
LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
| ^^^^^^
|
note: this function is not `const`, so it cannot have `~const` trait bounds
--> $DIR/tilde-const-and-const-params.rs:9:8
--> $DIR/tilde-const-and-const-params.rs:8:8
|
LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
| ^^^
error: `~const` is not allowed here
--> $DIR/tilde-const-and-const-params.rs:27:11
--> $DIR/tilde-const-and-const-params.rs:26:11
|
LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
| ^^^^^^
|
note: this function is not `const`, so it cannot have `~const` trait bounds
--> $DIR/tilde-const-and-const-params.rs:27:4
--> $DIR/tilde-const-and-const-params.rs:26:4
|
LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
| ^^^
error[E0277]: the trait bound `A: const Add42` is not satisfied
--> $DIR/tilde-const-and-const-params.rs:27:61
--> $DIR/tilde-const-and-const-params.rs:26:61
|
LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
| ^
error[E0277]: the trait bound `A: const Add42` is not satisfied
--> $DIR/tilde-const-and-const-params.rs:9:44
--> $DIR/tilde-const-and-const-params.rs:8:44
|
LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
| ^