mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Rollup merge of #96868 - nrc:turbo-stable, r=jhpratt,nbdd0121,nagisa
Stabilize explicit_generic_args_with_impl_trait This is a stabilisation PR for `explicit_generic_args_with_impl_trait`. * [tracking issue](https://github.com/rust-lang/rust/issues/83701) - [Stabilisation report](https://github.com/rust-lang/rust/issues/83701#issuecomment-1109949897) - [FCP entered](https://github.com/rust-lang/rust/issues/83701#issuecomment-1120285703) * [implementation PR](https://github.com/rust-lang/rust/pull/86176) * [Reference PR](https://github.com/rust-lang/reference/pull/1212) * There is no mention of using the turbofish operator in the book (other than an entry in the operator list in the appendix), so there is no documentation to change/add there, unless we felt like we should add a section on using turbofish, but that seems orthogonal to `explicit_generic_args_with_impl_trait`
This commit is contained in:
commit
f1f44b9e4d
@ -1,9 +1,11 @@
|
|||||||
|
#### Note: this error code is no longer emitted by the compiler.
|
||||||
|
|
||||||
An explicit generic argument was provided when calling a function that
|
An explicit generic argument was provided when calling a function that
|
||||||
uses `impl Trait` in argument position.
|
uses `impl Trait` in argument position.
|
||||||
|
|
||||||
Erroneous code example:
|
Erroneous code example:
|
||||||
|
|
||||||
```compile_fail,E0632
|
```ignore (no longer an error)
|
||||||
fn foo<T: Copy>(a: T, b: impl Clone) {}
|
fn foo<T: Copy>(a: T, b: impl Clone) {}
|
||||||
|
|
||||||
foo::<i32>(0i32, "abc".to_string());
|
foo::<i32>(0i32, "abc".to_string());
|
||||||
|
@ -95,12 +95,6 @@ typeck-expected-return-type = expected `{$expected}` because of return type
|
|||||||
typeck-unconstrained-opaque-type = unconstrained opaque type
|
typeck-unconstrained-opaque-type = unconstrained opaque type
|
||||||
.note = `{$name}` must be used in combination with a concrete type within the same module
|
.note = `{$name}` must be used in combination with a concrete type within the same module
|
||||||
|
|
||||||
typeck-explicit-generic-args-with-impl-trait =
|
|
||||||
cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
|
||||||
.label = explicit generic argument not allowed
|
|
||||||
.note = see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
|
|
||||||
.help = add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
typeck-missing-type-params =
|
typeck-missing-type-params =
|
||||||
the type {$parameterCount ->
|
the type {$parameterCount ->
|
||||||
[one] parameter
|
[one] parameter
|
||||||
|
@ -142,6 +142,8 @@ declare_features! (
|
|||||||
(accepted, dyn_trait, "1.27.0", Some(44662), None),
|
(accepted, dyn_trait, "1.27.0", Some(44662), None),
|
||||||
/// Allows integer match exhaustiveness checking (RFC 2591).
|
/// Allows integer match exhaustiveness checking (RFC 2591).
|
||||||
(accepted, exhaustive_integer_patterns, "1.33.0", Some(50907), None),
|
(accepted, exhaustive_integer_patterns, "1.33.0", Some(50907), None),
|
||||||
|
/// Allows explicit generic arguments specification with `impl Trait` present.
|
||||||
|
(accepted, explicit_generic_args_with_impl_trait, "1.63.0", Some(83701), None),
|
||||||
/// Allows arbitrary expressions in key-value attributes at parse time.
|
/// Allows arbitrary expressions in key-value attributes at parse time.
|
||||||
(accepted, extended_key_value_attributes, "1.54.0", Some(78835), None),
|
(accepted, extended_key_value_attributes, "1.54.0", Some(78835), None),
|
||||||
/// Allows resolving absolute paths as paths from other crates.
|
/// Allows resolving absolute paths as paths from other crates.
|
||||||
|
@ -383,8 +383,6 @@ declare_features! (
|
|||||||
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),
|
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),
|
||||||
/// Allows exhaustive pattern matching on types that contain uninhabited types.
|
/// Allows exhaustive pattern matching on types that contain uninhabited types.
|
||||||
(active, exhaustive_patterns, "1.13.0", Some(51085), None),
|
(active, exhaustive_patterns, "1.13.0", Some(51085), None),
|
||||||
/// Allows explicit generic arguments specification with `impl Trait` present.
|
|
||||||
(active, explicit_generic_args_with_impl_trait, "1.56.0", Some(83701), None),
|
|
||||||
/// Allows defining `extern type`s.
|
/// Allows defining `extern type`s.
|
||||||
(active, extern_types, "1.23.0", Some(43467), None),
|
(active, extern_types, "1.23.0", Some(43467), None),
|
||||||
/// Allows the use of `#[ffi_const]` on foreign functions.
|
/// Allows the use of `#[ffi_const]` on foreign functions.
|
||||||
|
@ -3,7 +3,7 @@ use crate::astconv::{
|
|||||||
AstConv, CreateSubstsForGenericArgsCtxt, ExplicitLateBound, GenericArgCountMismatch,
|
AstConv, CreateSubstsForGenericArgsCtxt, ExplicitLateBound, GenericArgCountMismatch,
|
||||||
GenericArgCountResult, GenericArgPosition,
|
GenericArgCountResult, GenericArgPosition,
|
||||||
};
|
};
|
||||||
use crate::errors::{AssocTypeBindingNotAllowed, ExplicitGenericArgsWithImplTrait};
|
use crate::errors::AssocTypeBindingNotAllowed;
|
||||||
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
||||||
use rustc_ast::ast::ParamKindOrd;
|
use rustc_ast::ast::ParamKindOrd;
|
||||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, MultiSpan};
|
use rustc_errors::{struct_span_err, Applicability, Diagnostic, MultiSpan};
|
||||||
@ -397,8 +397,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
is_method_call: IsMethodCall,
|
is_method_call: IsMethodCall,
|
||||||
) -> GenericArgCountResult {
|
) -> GenericArgCountResult {
|
||||||
let empty_args = hir::GenericArgs::none();
|
let empty_args = hir::GenericArgs::none();
|
||||||
let suppress_mismatch = Self::check_impl_trait(tcx, seg, generics);
|
|
||||||
|
|
||||||
let gen_args = seg.args.unwrap_or(&empty_args);
|
let gen_args = seg.args.unwrap_or(&empty_args);
|
||||||
let gen_pos = if is_method_call == IsMethodCall::Yes {
|
let gen_pos = if is_method_call == IsMethodCall::Yes {
|
||||||
GenericArgPosition::MethodCall
|
GenericArgPosition::MethodCall
|
||||||
@ -406,10 +404,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
GenericArgPosition::Value
|
GenericArgPosition::Value
|
||||||
};
|
};
|
||||||
let has_self = generics.parent.is_none() && generics.has_self;
|
let has_self = generics.parent.is_none() && generics.has_self;
|
||||||
let infer_args = seg.infer_args || suppress_mismatch;
|
|
||||||
|
|
||||||
Self::check_generic_arg_count(
|
Self::check_generic_arg_count(
|
||||||
tcx, span, def_id, seg, generics, gen_args, gen_pos, has_self, infer_args,
|
tcx,
|
||||||
|
span,
|
||||||
|
def_id,
|
||||||
|
seg,
|
||||||
|
generics,
|
||||||
|
gen_args,
|
||||||
|
gen_pos,
|
||||||
|
has_self,
|
||||||
|
seg.infer_args,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,19 +436,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
let param_counts = gen_params.own_counts();
|
let param_counts = gen_params.own_counts();
|
||||||
|
|
||||||
// Subtracting from param count to ensure type params synthesized from `impl Trait`
|
// Subtracting from param count to ensure type params synthesized from `impl Trait`
|
||||||
// cannot be explicitly specified even with `explicit_generic_args_with_impl_trait`
|
// cannot be explicitly specified.
|
||||||
// feature enabled.
|
let synth_type_param_count = gen_params
|
||||||
let synth_type_param_count = if tcx.features().explicit_generic_args_with_impl_trait {
|
.params
|
||||||
gen_params
|
.iter()
|
||||||
.params
|
.filter(|param| {
|
||||||
.iter()
|
matches!(param.kind, ty::GenericParamDefKind::Type { synthetic: true, .. })
|
||||||
.filter(|param| {
|
})
|
||||||
matches!(param.kind, ty::GenericParamDefKind::Type { synthetic: true, .. })
|
.count();
|
||||||
})
|
|
||||||
.count()
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
let named_type_param_count =
|
let named_type_param_count =
|
||||||
param_counts.types - has_self as usize - synth_type_param_count;
|
param_counts.types - has_self as usize - synth_type_param_count;
|
||||||
let infer_lifetimes =
|
let infer_lifetimes =
|
||||||
@ -611,40 +611,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Report error if there is an explicit type parameter when using `impl Trait`.
|
|
||||||
pub(crate) fn check_impl_trait(
|
|
||||||
tcx: TyCtxt<'_>,
|
|
||||||
seg: &hir::PathSegment<'_>,
|
|
||||||
generics: &ty::Generics,
|
|
||||||
) -> bool {
|
|
||||||
if seg.infer_args || tcx.features().explicit_generic_args_with_impl_trait {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let impl_trait = generics.has_impl_trait();
|
|
||||||
|
|
||||||
if impl_trait {
|
|
||||||
let spans = seg
|
|
||||||
.args()
|
|
||||||
.args
|
|
||||||
.iter()
|
|
||||||
.filter_map(|arg| match arg {
|
|
||||||
GenericArg::Infer(_) | GenericArg::Type(_) | GenericArg::Const(_) => {
|
|
||||||
Some(arg.span())
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
tcx.sess.emit_err(ExplicitGenericArgsWithImplTrait {
|
|
||||||
spans,
|
|
||||||
is_nightly_build: tcx.sess.is_nightly_build().then_some(()),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_trait
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Emits an error regarding forbidden type binding associations
|
/// Emits an error regarding forbidden type binding associations
|
||||||
pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span) {
|
pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span) {
|
||||||
tcx.sess.emit_err(AssocTypeBindingNotAllowed { span });
|
tcx.sess.emit_err(AssocTypeBindingNotAllowed { span });
|
||||||
|
@ -241,17 +241,6 @@ pub struct UnconstrainedOpaqueType {
|
|||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
|
||||||
#[error(code = "E0632", slug = "typeck-explicit-generic-args-with-impl-trait")]
|
|
||||||
#[note]
|
|
||||||
pub struct ExplicitGenericArgsWithImplTrait {
|
|
||||||
#[primary_span]
|
|
||||||
#[label]
|
|
||||||
pub spans: Vec<Span>,
|
|
||||||
#[help]
|
|
||||||
pub is_nightly_build: Option<()>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MissingTypeParams {
|
pub struct MissingTypeParams {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub def_span: Span,
|
pub def_span: Span,
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
# `explicit_generic_args_with_impl_trait`
|
|
||||||
|
|
||||||
The tracking issue for this feature is: [#83701]
|
|
||||||
|
|
||||||
[#83701]: https://github.com/rust-lang/rust/issues/83701
|
|
||||||
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
The `explicit_generic_args_with_impl_trait` feature gate lets you specify generic arguments even
|
|
||||||
when `impl Trait` is used in argument position.
|
|
||||||
|
|
||||||
A simple example is:
|
|
||||||
|
|
||||||
```rust
|
|
||||||
#![feature(explicit_generic_args_with_impl_trait)]
|
|
||||||
|
|
||||||
fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
foo::<str>("".to_string());
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This is currently rejected:
|
|
||||||
|
|
||||||
```text
|
|
||||||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
|
||||||
--> src/main.rs:6:11
|
|
||||||
|
|
|
||||||
6 | foo::<str>("".to_string());
|
|
||||||
| ^^^ explicit generic argument not allowed
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
However it would compile if `explicit_generic_args_with_impl_trait` is enabled.
|
|
||||||
|
|
||||||
Note that the synthetic type parameters from `impl Trait` are still implicit and you
|
|
||||||
cannot explicitly specify these:
|
|
||||||
|
|
||||||
```rust,compile_fail
|
|
||||||
#![feature(explicit_generic_args_with_impl_trait)]
|
|
||||||
|
|
||||||
fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
|
||||||
fn bar<T: ?Sized, F: AsRef<T>>(_f: F) {}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
bar::<str, _>("".to_string()); // Okay
|
|
||||||
bar::<str, String>("".to_string()); // Okay
|
|
||||||
|
|
||||||
foo::<str>("".to_string()); // Okay
|
|
||||||
foo::<str, String>("".to_string()); // Error, you cannot specify `impl Trait` explicitly
|
|
||||||
}
|
|
||||||
```
|
|
@ -1,12 +0,0 @@
|
|||||||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
|
||||||
--> $DIR/impl-trait-with-const-arguments.rs:18:20
|
|
||||||
|
|
|
||||||
LL | assert_eq!(f::<4usize>(Usizable), 20usize);
|
|
||||||
| ^^^^^^ explicit generic argument not allowed
|
|
||||||
|
|
|
||||||
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
|
|
||||||
= help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0632`.
|
|
@ -1,3 +1,5 @@
|
|||||||
|
// check-pass
|
||||||
|
|
||||||
trait Usizer {
|
trait Usizer {
|
||||||
fn m(self) -> usize;
|
fn m(self) -> usize;
|
||||||
}
|
}
|
||||||
@ -16,5 +18,4 @@ impl Usizer for Usizable {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(f::<4usize>(Usizable), 20usize);
|
assert_eq!(f::<4usize>(Usizable), 20usize);
|
||||||
//~^ ERROR cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
|
||||||
}
|
}
|
@ -1,5 +1,3 @@
|
|||||||
#![feature(explicit_generic_args_with_impl_trait)]
|
|
||||||
|
|
||||||
fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0107]: this function takes 1 generic argument but 2 generic arguments were supplied
|
error[E0107]: this function takes 1 generic argument but 2 generic arguments were supplied
|
||||||
--> $DIR/explicit-generic-args-for-impl.rs:6:5
|
--> $DIR/explicit-generic-args-for-impl.rs:4:5
|
||||||
|
|
|
|
||||||
LL | foo::<str, String>("".to_string());
|
LL | foo::<str, String>("".to_string());
|
||||||
| ^^^ ------ help: remove this generic argument
|
| ^^^ ------ help: remove this generic argument
|
||||||
@ -7,7 +7,7 @@ LL | foo::<str, String>("".to_string());
|
|||||||
| expected 1 generic argument
|
| expected 1 generic argument
|
||||||
|
|
|
|
||||||
note: function defined here, with 1 generic parameter: `T`
|
note: function defined here, with 1 generic parameter: `T`
|
||||||
--> $DIR/explicit-generic-args-for-impl.rs:3:4
|
--> $DIR/explicit-generic-args-for-impl.rs:1:4
|
||||||
|
|
|
|
||||||
LL | fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
LL | fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
||||||
| ^^^ -
|
| ^^^ -
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
|
|
||||||
#![feature(explicit_generic_args_with_impl_trait)]
|
|
||||||
|
|
||||||
fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
// gate-test-explicit_generic_args_with_impl_trait
|
|
||||||
|
|
||||||
fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
foo::<str>("".to_string()); //~ ERROR E0632
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
|
||||||
--> $DIR/feature-gate.rs:6:11
|
|
||||||
|
|
|
||||||
LL | foo::<str>("".to_string());
|
|
||||||
| ^^^ explicit generic argument not allowed
|
|
||||||
|
|
|
||||||
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
|
|
||||||
= help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0632`.
|
|
@ -1,7 +1,5 @@
|
|||||||
// check-pass
|
// check-pass
|
||||||
|
|
||||||
#![feature(explicit_generic_args_with_impl_trait)]
|
|
||||||
|
|
||||||
fn f<T: ?Sized>(_: impl AsRef<T>, _: impl AsRef<T>) {}
|
fn f<T: ?Sized>(_: impl AsRef<T>, _: impl AsRef<T>) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![feature(explicit_generic_args_with_impl_trait)]
|
|
||||||
|
|
||||||
fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
|
fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
|
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
|
||||||
--> $DIR/not-enough-args.rs:6:5
|
--> $DIR/not-enough-args.rs:4:5
|
||||||
|
|
|
|
||||||
LL | f::<[u8]>("a", b"a");
|
LL | f::<[u8]>("a", b"a");
|
||||||
| ^ ---- supplied 1 generic argument
|
| ^ ---- supplied 1 generic argument
|
||||||
@ -7,7 +7,7 @@ LL | f::<[u8]>("a", b"a");
|
|||||||
| expected 2 generic arguments
|
| expected 2 generic arguments
|
||||||
|
|
|
|
||||||
note: function defined here, with 2 generic parameters: `T`, `U`
|
note: function defined here, with 2 generic parameters: `T`, `U`
|
||||||
--> $DIR/not-enough-args.rs:3:4
|
--> $DIR/not-enough-args.rs:1:4
|
||||||
|
|
|
|
||||||
LL | fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
|
LL | fn f<T: ?Sized, U: ?Sized>(_: impl AsRef<T>, _: impl AsRef<U>) {}
|
||||||
| ^ - -
|
| ^ - -
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
use std::fmt::Debug;
|
|
||||||
|
|
||||||
fn foo<T>(x: impl Debug) { }
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
foo::<String>('a'); //~ ERROR cannot provide explicit generic arguments
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
|
||||||
--> $DIR/universal-issue-48703.rs:6:11
|
|
||||||
|
|
|
||||||
LL | foo::<String>('a');
|
|
||||||
| ^^^^^^ explicit generic argument not allowed
|
|
||||||
|
|
|
||||||
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
|
|
||||||
= help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0632`.
|
|
@ -1,17 +0,0 @@
|
|||||||
use std::any::Any;
|
|
||||||
pub struct EventHandler {
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EventHandler
|
|
||||||
{
|
|
||||||
pub fn handle_event<T: Any>(&mut self, _efunc: impl FnMut(T)) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TestEvent(i32);
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let mut evt = EventHandler {};
|
|
||||||
evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
|
|
||||||
//~^ ERROR cannot provide explicit generic arguments
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
|
|
||||||
--> $DIR/universal-turbofish-in-method-issue-50950.rs:14:24
|
|
||||||
|
|
|
||||||
LL | evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
|
|
||||||
| ^^^^^^^^^ ^^^^^^^^^^^^^ explicit generic argument not allowed
|
|
||||||
| |
|
|
||||||
| explicit generic argument not allowed
|
|
||||||
|
|
|
||||||
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
|
|
||||||
= help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0632`.
|
|
@ -5,6 +5,6 @@ fn foo<const N: usize>(_: impl std::fmt::Display) -> [usize; N] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = foo("foo"); //<- Do not suggest `foo::<N>("foo");`!
|
let _ = foo("foo");
|
||||||
//~^ ERROR: type annotations needed for `[usize; _]`
|
//~^ ERROR: type annotations needed for `[usize; _]`
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
error[E0282]: type annotations needed for `[usize; _]`
|
error[E0282]: type annotations needed for `[usize; _]`
|
||||||
--> $DIR/issue-83606.rs:8:9
|
--> $DIR/issue-83606.rs:8:9
|
||||||
|
|
|
|
||||||
LL | let _ = foo("foo"); //<- Do not suggest `foo::<N>("foo");`!
|
LL | let _ = foo("foo");
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
help: consider giving this pattern a type, where the the value of const parameter `N` is specified
|
help: consider giving this pattern a type, where the the value of const parameter `N` is specified
|
||||||
|
|
|
|
||||||
LL | let _: [usize; _] = foo("foo"); //<- Do not suggest `foo::<N>("foo");`!
|
LL | let _: [usize; _] = foo("foo");
|
||||||
| ++++++++++++
|
| ++++++++++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
Loading…
Reference in New Issue
Block a user