*/
use astconv::{self, AstConv, ty_of_arg, ast_ty_to_ty, ast_region_to_region};
-use middle::def;
+use lint;
+use middle::def::Def;
use middle::def_id::DefId;
use constrained_type_params as ctp;
use middle::lang_items::SizedTraitLangItem;
if let hir::TyPath(None, _) = ast_ty.node {
let path_res = *tcx.def_map.borrow().get(&ast_ty.id).unwrap();
match path_res.base_def {
- def::DefSelfTy(Some(def_id), None) => {
+ Def::SelfTy(Some(def_id), None) => {
path_res.depth == 0 && def_id == tcx.map.local_def_id(param_id)
}
- def::DefTyParam(_, _, def_id, _) => {
+ Def::TyParam(_, _, def_id, _) => {
path_res.depth == 0 && def_id == tcx.map.local_def_id(param_id)
}
_ => {
did: did,
name: name,
disr_val: disr_val,
- fields: fields
+ fields: fields,
+ kind: VariantKind::from_variant_data(def),
}
}
let parent = tcx.map.get_parent(param.id);
+ if space != TypeSpace && default.is_some() {
+ if !tcx.sess.features.borrow().default_type_parameter_fallback {
+ tcx.sess.add_lint(
+ lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
+ param.id,
+ param.span,
+ format!("defaults for type parameters are only allowed on type definitions, \
+ like `struct` or `enum`"));
+ }
+ }
+
let def = ty::TypeParameterDef {
space: space,
index: index,