Skip to content

Commit a0c7739

Browse files
committed
make invalid_type_param_default lint show up in cargo future-compat reports
and remove the feature gate that silenced the lint
1 parent b286722 commit a0c7739

File tree

7 files changed

+47
-26
lines changed

7 files changed

+47
-26
lines changed

compiler/rustc_feature/src/removed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ declare_features! (
7575
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
7676
(removed, custom_derive, "1.32.0", Some(29644),
7777
Some("subsumed by `#[proc_macro_derive]`")),
78+
/// Allows default type parameters to influence type inference.
79+
(removed, default_type_parameter_fallback, "CURRENT_RUSTC_VERSION", Some(27336),
80+
Some("never properly implemented; requires significant design work")),
7881
/// Allows using `#[doc(keyword = "...")]`.
7982
(removed, doc_keyword, "1.28.0", Some(51315),
8083
Some("merged into `#![feature(rustdoc_internals)]`")),

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ declare_features! (
428428
(unstable, custom_test_frameworks, "1.30.0", Some(50297)),
429429
/// Allows declarative macros 2.0 (`macro`).
430430
(unstable, decl_macro, "1.17.0", Some(39412)),
431-
/// Allows default type parameters to influence type inference.
432-
(unstable, default_type_parameter_fallback, "1.3.0", Some(27336)),
433431
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
434432
(unstable, deprecated_safe, "1.61.0", Some(94978)),
435433
/// Allows having using `suggestion` in the `#[deprecated]` attribute.

compiler/rustc_hir_analysis/src/collect/generics_of.rs

-2
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
323323
if default.is_some() {
324324
match allow_defaults {
325325
Defaults::Allowed => {}
326-
Defaults::FutureCompatDisallowed
327-
if tcx.features().default_type_parameter_fallback => {}
328326
Defaults::FutureCompatDisallowed => {
329327
tcx.node_span_lint(
330328
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,

compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ declare_lint! {
12411241
Deny,
12421242
"type parameter default erroneously allowed in invalid location",
12431243
@future_incompatible = FutureIncompatibleInfo {
1244-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1244+
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
12451245
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
12461246
};
12471247
}

tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
2+
--> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8
3+
|
4+
LL | fn avg<T=i32>(_: T) {}
5+
| ^^^^^
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
9+
= note: `#[deny(invalid_type_param_default)]` on by default
10+
11+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
12+
--> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6
13+
|
14+
LL | impl<T=i32> S<T> {}
15+
| ^^^^^
16+
|
17+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
19+
20+
error: aborting due to 2 previous errors
21+
22+
Future incompatibility report: Future breakage diagnostic:
23+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
24+
--> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8
25+
|
26+
LL | fn avg<T=i32>(_: T) {}
27+
| ^^^^^
28+
|
29+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
30+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
31+
= note: `#[deny(invalid_type_param_default)]` on by default
32+
33+
Future breakage diagnostic:
34+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
35+
--> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6
36+
|
37+
LL | impl<T=i32> S<T> {}
38+
| ^^^^^
39+
|
40+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
41+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
42+
= note: `#[deny(invalid_type_param_default)]` on by default
43+

0 commit comments

Comments
 (0)