Turn invalid_type_param_default
into a lint again
This commit is contained in:
parent
d73a0fef38
commit
26d5c0e20c
@ -130,6 +130,12 @@
|
||||
"detect private items in public interfaces not caught by the old implementation"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
pub INVALID_TYPE_PARAM_DEFAULT,
|
||||
Deny,
|
||||
"type parameter default erroneously allowed in invalid location"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
pub RENAMED_AND_REMOVED_LINTS,
|
||||
Warn,
|
||||
@ -224,6 +230,7 @@ fn get_lints(&self) -> LintArray {
|
||||
TRIVIAL_CASTS,
|
||||
TRIVIAL_NUMERIC_CASTS,
|
||||
PRIVATE_IN_PUBLIC,
|
||||
INVALID_TYPE_PARAM_DEFAULT,
|
||||
CONST_ERR,
|
||||
RENAMED_AND_REMOVED_LINTS,
|
||||
RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
|
||||
|
@ -196,6 +196,10 @@ macro_rules! add_lint_group {
|
||||
id: LintId::of(SAFE_EXTERN_STATICS),
|
||||
reference: "issue #36247 <https://github.com/rust-lang/rust/issues/36247>",
|
||||
},
|
||||
FutureIncompatibleInfo {
|
||||
id: LintId::of(INVALID_TYPE_PARAM_DEFAULT),
|
||||
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
|
||||
},
|
||||
FutureIncompatibleInfo {
|
||||
id: LintId::of(EXTRA_REQUIREMENT_IN_IMPL),
|
||||
reference: "issue #37166 <https://github.com/rust-lang/rust/issues/37166>",
|
||||
@ -251,8 +255,6 @@ macro_rules! add_lint_group {
|
||||
"converted into hard error, see https://github.com/rust-lang/rust/issues/33685");
|
||||
store.register_removed("inaccessible_extern_crate",
|
||||
"converted into hard error, see https://github.com/rust-lang/rust/issues/36886");
|
||||
store.register_removed("invalid_type_param_default",
|
||||
"converted into hard error, see https://github.com/rust-lang/rust/issues/36887");
|
||||
store.register_removed("super_or_self_in_global_path",
|
||||
"converted into hard error, see https://github.com/rust-lang/rust/issues/36888");
|
||||
store.register_removed("overlapping_inherent_impls",
|
||||
|
@ -54,6 +54,7 @@
|
||||
*/
|
||||
|
||||
use astconv::{AstConv, Bounds};
|
||||
use lint;
|
||||
use constrained_type_params as ctp;
|
||||
use middle::lang_items::SizedTraitLangItem;
|
||||
use middle::const_val::ConstVal;
|
||||
@ -896,8 +897,12 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
if !allow_defaults && p.default.is_some() {
|
||||
if !tcx.sess.features.borrow().default_type_parameter_fallback {
|
||||
tcx.sess.span_err(p.span, "defaults for type parameters are only allowed in \
|
||||
`struct`, `enum`, `type`, or `trait` definitions.");
|
||||
tcx.sess.add_lint(
|
||||
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
|
||||
p.id,
|
||||
p.span,
|
||||
format!("defaults for type parameters are only allowed in `struct`, \
|
||||
`enum`, `type`, or `trait` definitions."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,16 @@
|
||||
|
||||
// gate-test-default_type_parameter_fallback
|
||||
|
||||
#![deny(invalid_type_param_default)]
|
||||
#![allow(unused)]
|
||||
|
||||
fn avg<T=i32>(_: T) {}
|
||||
//~^ ERROR defaults for type parameters are only allowed
|
||||
//~| WARN this was previously accepted
|
||||
|
||||
struct S<T>(T);
|
||||
impl<T=i32> S<T> {}
|
||||
//~^ ERROR defaults for type parameters are only allowed
|
||||
//~| WARN this was previously accepted
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user