Skip to content

Commit 6a57490

Browse files
committed
Auto merge of rust-lang#127655 - RalfJung:invalid_type_param_default, r=<try>
WIP: make invalid_type_param_default a hard error Cc rust-lang#36887 `@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. This should be cratered. (But I can also make it `FutureReleaseErrorReportInDeps` first if you prefer.)
2 parents b286722 + 4282f48 commit 6a57490

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

Diff for: compiler/rustc_hir_analysis/src/collect/generics_of.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
230230
enum Defaults {
231231
Allowed,
232232
// See #36887
233+
#[allow(dead_code)] // FIXME remove if the PR moves forward
233234
FutureCompatDisallowed,
234235
Deny,
235236
}
@@ -262,7 +263,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
262263
| ItemKind::OpaqueTy(..)
263264
| ItemKind::Union(..) => (None, Defaults::Allowed),
264265
ItemKind::Const(..) => (None, Defaults::Deny),
265-
_ => (None, Defaults::FutureCompatDisallowed),
266+
_ => (None, Defaults::Deny),
266267
}
267268
}
268269

@@ -274,7 +275,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
274275
(None, Defaults::Deny)
275276
}
276277

277-
_ => (None, Defaults::FutureCompatDisallowed),
278+
_ => (None, Defaults::Deny),
278279
};
279280

280281
let has_self = opt_self.is_some();

Diff for: tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
fn avg<T=i32>(_: T) {}
44
//~^ ERROR defaults for type parameters are only allowed
5-
//~| WARN this was previously accepted
65

76
struct S<T>(T);
87
impl<T=i32> S<T> {}
98
//~^ ERROR defaults for type parameters are only allowed
10-
//~| WARN this was previously accepted
119

1210
fn main() {}

Diff for: tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
33
|
44
LL | fn avg<T=i32>(_: T) {}
55
| ^^^^^
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
106

117
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
12-
--> $DIR/feature-gate-default_type_parameter_fallback.rs:8:6
8+
--> $DIR/feature-gate-default_type_parameter_fallback.rs:7:6
139
|
1410
LL | impl<T=i32> S<T> {}
1511
| ^^^^^
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>
1912

2013
error: aborting due to 2 previous errors
2114

0 commit comments

Comments
 (0)