diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 6574267f18511..027d83685ac36 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -22,29 +22,6 @@ error: bitshift exceeds the type's number of bits | ``` -## invalid-type-param-default - -This lint detects type parameter default erroneously allowed in invalid location. Some -example code that triggers this lint: - -```rust,ignore -fn foo(t: T) {} -``` - -This will produce: - -```text -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions. - --> src/main.rs:4:8 - | -4 | fn foo(t: T) {} - | ^ - | - = note: `#[deny(invalid_type_param_default)]` on by default - = 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 -``` - ## legacy-constructor-visibility [RFC 1506](https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md) modified some diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 6d9a6bb77dd55..dd058764293bf 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -139,12 +139,6 @@ declare_lint! { "detect public re-exports of private extern crates" } -declare_lint! { - pub INVALID_TYPE_PARAM_DEFAULT, - Deny, - "type parameter default erroneously allowed in invalid location" -} - declare_lint! { pub RENAMED_AND_REMOVED_LINTS, Warn, @@ -420,7 +414,6 @@ declare_lint_pass! { PRIVATE_IN_PUBLIC, EXPORTED_PRIVATE_DEPENDENCIES, PUB_USE_OF_PRIVATE_EXTERN_CRATE, - INVALID_TYPE_PARAM_DEFAULT, CONST_ERR, RENAMED_AND_REMOVED_LINTS, SAFE_EXTERN_STATICS, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 78bc164ba1a0f..dc86373dc9ff8 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -326,11 +326,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #36247 ", edition: None, }, - FutureIncompatibleInfo { - id: LintId::of(INVALID_TYPE_PARAM_DEFAULT), - reference: "issue #36887 ", - edition: None, - }, FutureIncompatibleInfo { id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP), reference: "issue #37872 ", @@ -488,6 +483,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/57742"); store.register_removed("incoherent_fundamental_impls", "converted into hard error, see https://github.com/rust-lang/rust/issues/46205"); + store.register_removed("invalid_type_param_default", + "converted into hard error, see https://github.com/rust-lang/rust/issues/36887"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 15687eaa943e1..57b1c1061f0cb 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -17,7 +17,6 @@ use crate::astconv::{AstConv, Bounds, SizedByDefault}; use crate::constrained_generic_params as cgp; use crate::check::intrinsic::intrisic_operation_unsafety; -use crate::lint; use crate::middle::resolve_lifetime as rl; use crate::middle::weak_lang_items; use rustc::mir::mono::Linkage; @@ -1014,9 +1013,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { if !allow_defaults && default.is_some() { if !tcx.features().default_type_parameter_fallback { - tcx.lint_hir( - lint::builtin::INVALID_TYPE_PARAM_DEFAULT, - param.hir_id, + tcx.sess.span_err( param.span, &format!( "defaults for type parameters are only allowed in \ diff --git a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs index 33038e24bc62b..4c18a95a6ad49 100644 --- a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs +++ b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs @@ -1,12 +1,8 @@ -#![allow(unused)] - -fn avg(_: T) {} +fn avg(_: T) {} //~^ ERROR defaults for type parameters are only allowed -//~| WARN this was previously accepted struct S(T); -impl S {} +impl S {} //~^ ERROR defaults for type parameters are only allowed -//~| WARN this was previously accepted fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr index f13803b80f308..4680e78d7450b 100644 --- a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr +++ b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr @@ -1,21 +1,14 @@ 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 + --> $DIR/feature-gate-default_type_parameter_fallback.rs:1:8 | -LL | fn avg(_: T) {} +LL | fn avg(_: T) {} | ^ - | - = note: `#[deny(invalid_type_param_default)]` on by default - = 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 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 + --> $DIR/feature-gate-default_type_parameter_fallback.rs:5:6 | -LL | impl S {} +LL | impl S {} | ^ - | - = 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 error: aborting due to 2 previous errors