"detect private items in public interfaces not caught by the old implementation"
}
+declare_lint! {
+ pub INVALID_TYPE_PARAM_DEFAULT,
+ Warn,
+ "type parameter default erroneously allowed in invalid location"
+}
+
/// Does nothing as a lint pass, but registers some `Lint`s
/// which are used by other parts of the compiler.
#[derive(Copy, Clone)]
TRIVIAL_CASTS,
TRIVIAL_NUMERIC_CASTS,
PRIVATE_IN_PUBLIC,
+ INVALID_TYPE_PARAM_DEFAULT,
CONST_ERR
)
}
UNUSED_MUT, UNREACHABLE_CODE, UNUSED_MUST_USE,
UNUSED_UNSAFE, PATH_STATEMENTS, UNUSED_ATTRIBUTES);
- add_lint_group!(sess, "future_incompatible",
- PRIVATE_IN_PUBLIC);
+ add_lint_group!(sess, FUTURE_INCOMPATIBLE,
+ PRIVATE_IN_PUBLIC, INVALID_TYPE_PARAM_DEFAULT);
// We have one lint pass defined specially
store.register_late_pass(sess, false, box lint::GatherNodeLevels);
*/
use astconv::{self, AstConv, ty_of_arg, ast_ty_to_ty, ast_region_to_region};
+use lint;
use middle::def;
use middle::def_id::DefId;
use constrained_type_params as ctp;
use syntax::ast;
use syntax::attr;
use syntax::codemap::Span;
-use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax::parse::token::special_idents;
use syntax::ptr::P;
use rustc_front::hir;
if space != TypeSpace && default.is_some() {
if !tcx.sess.features.borrow().default_type_parameter_fallback {
- emit_feature_err(&tcx.sess.parse_sess.span_diagnostic,
- "default_type_parameter_fallback",
- param.span,
- GateIssue::Language,
- "other than on a `struct` or `enum` definition, \
- defaults for type parameters are experimental \
- and known to be buggy");
+ tcx.sess.add_lint(
+ lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
+ param.id,
+ param.span,
+ format!("defaults for type parameters are only allowed \
+ on `struct` or `enum` definitions (see issue #27336)"));
}
}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(future_incompatible)]
+#![allow(dead_code)]
+
+fn avg<T=i32>(_: T) {}
+//~^ ERROR defaults for type parameters are only allowed
+//~| NOTE HARD ERROR
+fn main() {}