Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cc61dc8

Browse files
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](#127655 (comment)), 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 #27336 by removing the feature gate (so there's no way to silence the lint even on nightly) CC #36887
2 parents 176e545 + 9d9b55c commit cc61dc8

File tree

12 files changed

+115
-30
lines changed

12 files changed

+115
-30
lines changed

‎compiler/rustc_feature/src/removed.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ declare_features! (
8282
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
8383
(removed, custom_derive, "1.32.0", Some(29644),
8484
Some("subsumed by `#[proc_macro_derive]`")),
85+
/// Allows default type parameters to influence type inference.
86+
(removed, default_type_parameter_fallback, "CURRENT_RUSTC_VERSION", Some(27336),
87+
Some("never properly implemented; requires significant design work")),
8588
/// Allows using `#[doc(keyword = "...")]`.
8689
(removed, doc_keyword, "1.28.0", Some(51315),
8790
Some("merged into `#![feature(rustdoc_internals)]`")),

‎compiler/rustc_feature/src/unstable.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ declare_features! (
431431
(unstable, custom_test_frameworks, "1.30.0", Some(50297)),
432432
/// Allows declarative macros 2.0 (`macro`).
433433
(unstable, decl_macro, "1.17.0", Some(39412)),
434-
/// Allows default type parameters to influence type inference.
435-
(unstable, default_type_parameter_fallback, "1.3.0", Some(27336)),
436434
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
437435
(unstable, deprecated_safe, "1.61.0", Some(94978)),
438436
/// Allows having using `suggestion` in the `#[deprecated]` attribute.

‎compiler/rustc_hir_analysis/src/collect/generics_of.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
338338
if default.is_some() {
339339
match allow_defaults {
340340
Defaults::Allowed => {}
341-
Defaults::FutureCompatDisallowed
342-
if tcx.features().default_type_parameter_fallback => {}
343341
Defaults::FutureCompatDisallowed => {
344342
tcx.node_span_lint(
345343
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,

‎compiler/rustc_lint_defs/src/builtin.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ declare_lint! {
12671267
Deny,
12681268
"type parameter default erroneously allowed in invalid location",
12691269
@future_incompatible = FutureIncompatibleInfo {
1270-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1270+
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
12711271
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
12721272
};
12731273
}

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

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎tests/ui/impl-trait/where-allowed.stderr‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,25 @@ error: aborting due to 50 previous errors
433433

434434
Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666.
435435
For more information about an error, try `rustc --explain E0053`.
436+
Future incompatibility report: Future breakage diagnostic:
437+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
438+
--> $DIR/where-allowed.rs:239:7
439+
|
440+
LL | impl <T = impl Debug> T {}
441+
| ^^^^^^^^^^^^^^
442+
|
443+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
444+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
445+
= note: `#[deny(invalid_type_param_default)]` on by default
446+
447+
Future breakage diagnostic:
448+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
449+
--> $DIR/where-allowed.rs:246:36
450+
|
451+
LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
452+
| ^^^^^^^^^^^^^^
453+
|
454+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
455+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
456+
= note: `#[deny(invalid_type_param_default)]` on by default
457+

‎tests/ui/issues/issue-26812.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#![feature(default_type_parameter_fallback)]
2-
31
fn avg<T=T::Item>(_: T) {}
42
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
3+
//~| ERROR defaults for type parameters
4+
//~| WARN previously accepted
55

66
fn main() {}

‎tests/ui/issues/issue-26812.stderr‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
error[E0128]: generic parameters with a default cannot use forward declared identifiers
2-
--> $DIR/issue-26812.rs:3:10
2+
--> $DIR/issue-26812.rs:1:10
33
|
44
LL | fn avg<T=T::Item>(_: T) {}
55
| ^^^^^^^ defaulted generic parameters cannot be forward declared
66

7-
error: aborting due to 1 previous error
7+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
8+
--> $DIR/issue-26812.rs:1:8
9+
|
10+
LL | fn avg<T=T::Item>(_: T) {}
11+
| ^^^^^^^^^
12+
|
13+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
14+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
15+
= note: `#[deny(invalid_type_param_default)]` on by default
16+
17+
error: aborting due to 2 previous errors
818

919
For more information about this error, try `rustc --explain E0128`.
20+
Future incompatibility report: Future breakage diagnostic:
21+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
22+
--> $DIR/issue-26812.rs:1:8
23+
|
24+
LL | fn avg<T=T::Item>(_: T) {}
25+
| ^^^^^^^^^
26+
|
27+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
28+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
29+
= note: `#[deny(invalid_type_param_default)]` on by default
30+

‎tests/ui/lifetimes/unusual-rib-combinations.stderr‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,14 @@ error: aborting due to 8 previous errors
7272

7373
Some errors have detailed explanations: E0106, E0214, E0308, E0770.
7474
For more information about an error, try `rustc --explain E0106`.
75+
Future incompatibility report: Future breakage diagnostic:
76+
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
77+
--> $DIR/unusual-rib-combinations.rs:15:6
78+
|
79+
LL | fn c<T = u8()>() {}
80+
| ^^^^^^^^
81+
|
82+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
83+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
84+
= note: `#[deny(invalid_type_param_default)]` on by default
85+

‎tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ LL | foo::<T, U>();
1212
error: aborting due to 1 previous error
1313

1414
For more information about this error, try `rustc --explain E0282`.
15+
Future incompatibility report: Future breakage diagnostic:
16+
warning: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
17+
--> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:3:11
18+
|
19+
LL | fn foo<T, U = u64>() -> (T, U) {
20+
| ^^^^^^^
21+
|
22+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
23+
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
24+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /