mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Rollup merge of #127655 - RalfJung:invalid_type_param_default, r=compiler-errors
turn `invalid_type_param_default` into a `FutureReleaseErrorReportInDeps` `````@rust-lang/types````` I assume the plan is still to disallow this? It has been a future-compat lint for a long time, seems ripe to go for hard error. However, turns out that outright removing it right now would lead to [tons of crater regressions](https://github.com/rust-lang/rust/pull/127655#issuecomment-2228285460), so for now this PR just makes this future-compat lint show up in cargo's reports, so people are warned when they use a dependency that is affected by this. Fixes https://github.com/rust-lang/rust/issues/27336 by removing the feature gate (so there's no way to silence the lint even on nightly) CC https://github.com/rust-lang/rust/issues/36887
This commit is contained in:
commit
cc61dc8b2d
@ -82,6 +82,9 @@ declare_features! (
|
|||||||
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
|
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
|
||||||
(removed, custom_derive, "1.32.0", Some(29644),
|
(removed, custom_derive, "1.32.0", Some(29644),
|
||||||
Some("subsumed by `#[proc_macro_derive]`")),
|
Some("subsumed by `#[proc_macro_derive]`")),
|
||||||
|
/// Allows default type parameters to influence type inference.
|
||||||
|
(removed, default_type_parameter_fallback, "CURRENT_RUSTC_VERSION", Some(27336),
|
||||||
|
Some("never properly implemented; requires significant design work")),
|
||||||
/// Allows using `#[doc(keyword = "...")]`.
|
/// Allows using `#[doc(keyword = "...")]`.
|
||||||
(removed, doc_keyword, "1.28.0", Some(51315),
|
(removed, doc_keyword, "1.28.0", Some(51315),
|
||||||
Some("merged into `#![feature(rustdoc_internals)]`")),
|
Some("merged into `#![feature(rustdoc_internals)]`")),
|
||||||
|
@ -431,8 +431,6 @@ declare_features! (
|
|||||||
(unstable, custom_test_frameworks, "1.30.0", Some(50297)),
|
(unstable, custom_test_frameworks, "1.30.0", Some(50297)),
|
||||||
/// Allows declarative macros 2.0 (`macro`).
|
/// Allows declarative macros 2.0 (`macro`).
|
||||||
(unstable, decl_macro, "1.17.0", Some(39412)),
|
(unstable, decl_macro, "1.17.0", Some(39412)),
|
||||||
/// Allows default type parameters to influence type inference.
|
|
||||||
(unstable, default_type_parameter_fallback, "1.3.0", Some(27336)),
|
|
||||||
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
|
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
|
||||||
(unstable, deprecated_safe, "1.61.0", Some(94978)),
|
(unstable, deprecated_safe, "1.61.0", Some(94978)),
|
||||||
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
|
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
|
||||||
|
@ -338,8 +338,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||||||
if default.is_some() {
|
if default.is_some() {
|
||||||
match allow_defaults {
|
match allow_defaults {
|
||||||
Defaults::Allowed => {}
|
Defaults::Allowed => {}
|
||||||
Defaults::FutureCompatDisallowed
|
|
||||||
if tcx.features().default_type_parameter_fallback => {}
|
|
||||||
Defaults::FutureCompatDisallowed => {
|
Defaults::FutureCompatDisallowed => {
|
||||||
tcx.node_span_lint(
|
tcx.node_span_lint(
|
||||||
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
|
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
|
||||||
|
@ -1267,7 +1267,7 @@ declare_lint! {
|
|||||||
Deny,
|
Deny,
|
||||||
"type parameter default erroneously allowed in invalid location",
|
"type parameter default erroneously allowed in invalid location",
|
||||||
@future_incompatible = FutureIncompatibleInfo {
|
@future_incompatible = FutureIncompatibleInfo {
|
||||||
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
|
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
|
||||||
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
|
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
|
||||||
--> $DIR/feature-gate-default_type_parameter_fallback.rs:3:8
|
|
||||||
|
|
|
||||||
LL | fn avg<T=i32>(_: T) {}
|
|
||||||
| ^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
|
||||||
= note: `#[deny(invalid_type_param_default)]` on by default
|
|
||||||
|
|
||||||
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
|
||||||
--> $DIR/feature-gate-default_type_parameter_fallback.rs:8:6
|
|
||||||
|
|
|
||||||
LL | impl<T=i32> S<T> {}
|
|
||||||
| ^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
@ -433,3 +433,25 @@ error: aborting due to 50 previous errors
|
|||||||
|
|
||||||
Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666.
|
Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666.
|
||||||
For more information about an error, try `rustc --explain E0053`.
|
For more information about an error, try `rustc --explain E0053`.
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/where-allowed.rs:239:7
|
||||||
|
|
|
||||||
|
LL | impl <T = impl Debug> T {}
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/where-allowed.rs:246:36
|
||||||
|
|
|
||||||
|
LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![feature(default_type_parameter_fallback)]
|
|
||||||
|
|
||||||
fn avg<T=T::Item>(_: T) {}
|
fn avg<T=T::Item>(_: T) {}
|
||||||
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
|
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
|
||||||
|
//~| ERROR defaults for type parameters
|
||||||
|
//~| WARN previously accepted
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,9 +1,30 @@
|
|||||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||||
--> $DIR/issue-26812.rs:3:10
|
--> $DIR/issue-26812.rs:1:10
|
||||||
|
|
|
|
||||||
LL | fn avg<T=T::Item>(_: T) {}
|
LL | fn avg<T=T::Item>(_: T) {}
|
||||||
| ^^^^^^^ defaulted generic parameters cannot be forward declared
|
| ^^^^^^^ defaulted generic parameters cannot be forward declared
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/issue-26812.rs:1:8
|
||||||
|
|
|
||||||
|
LL | fn avg<T=T::Item>(_: T) {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0128`.
|
For more information about this error, try `rustc --explain E0128`.
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/issue-26812.rs:1:8
|
||||||
|
|
|
||||||
|
LL | fn avg<T=T::Item>(_: T) {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
||||||
|
@ -72,3 +72,14 @@ error: aborting due to 8 previous errors
|
|||||||
|
|
||||||
Some errors have detailed explanations: E0106, E0214, E0308, E0770.
|
Some errors have detailed explanations: E0106, E0214, E0308, E0770.
|
||||||
For more information about an error, try `rustc --explain E0106`.
|
For more information about an error, try `rustc --explain E0106`.
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/unusual-rib-combinations.rs:15:6
|
||||||
|
|
|
||||||
|
LL | fn c<T = u8()>() {}
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
||||||
|
@ -12,3 +12,13 @@ LL | foo::<T, U>();
|
|||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0282`.
|
For more information about this error, try `rustc --explain E0282`.
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
warning: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:3:11
|
||||||
|
|
|
||||||
|
LL | fn foo<T, U = u64>() -> (T, U) {
|
||||||
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
|
||||||
|
43
tests/ui/type/default_type_parameter_in_fn_or_impl.stderr
Normal file
43
tests/ui/type/default_type_parameter_in_fn_or_impl.stderr
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8
|
||||||
|
|
|
||||||
|
LL | fn avg<T=i32>(_: T) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6
|
||||||
|
|
|
||||||
|
LL | impl<T=i32> S<T> {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Future incompatibility report: Future breakage diagnostic:
|
||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8
|
||||||
|
|
|
||||||
|
LL | fn avg<T=i32>(_: T) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
||||||
|
Future breakage diagnostic:
|
||||||
|
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
|
--> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6
|
||||||
|
|
|
||||||
|
LL | impl<T=i32> S<T> {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||||
|
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||||
|
|
Loading…
Reference in New Issue
Block a user