This commit modifies resolve to prevent conflicts with typedef names in the same
method that conflits are prevented with enum names. This is a breaking change
due to the differing semantics in resolve, and any errors generated on behalf of
this change require that a conflicting typedef, module, or structure to be
renamed so they do not conflict.
[breaking-change]
Closes #6936
fn new() -> TypeMap<'tcx> {
TypeMap {
unique_id_interner: Interner::new(),
- type_to_metadata: FnvHashMap::new(),
- unique_id_to_metadata: FnvHashMap::new(),
- type_to_unique_id: FnvHashMap::new(),
+ type_to_metadata: FnvHashMap(),
+ unique_id_to_metadata: FnvHashMap(),
+ type_to_unique_id: FnvHashMap(),
}
}
llcontext: llcontext,
builder: builder,
current_debug_location: Cell::new(UnknownLocation),
- created_files: RefCell::new(FnvHashMap::new()),
- created_enum_disr_types: RefCell::new(DefIdMap::new()),
+ created_files: RefCell::new(FnvHashMap()),
+ created_enum_disr_types: RefCell::new(DefIdMap()),
type_map: RefCell::new(TypeMap::new()),
- namespace_map: RefCell::new(FnvHashMap::new()),
- composite_types_completed: RefCell::new(FnvHashSet::new()),
+ namespace_map: RefCell::new(FnvHashMap()),
+ composite_types_completed: RefCell::new(FnvHashSet()),
};
}
}
let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1);
// Return type -- llvm::DIBuilder wants this at index 0
- match fn_decl.output {
- ast::Return(ref ret_ty) if ret_ty.node == ast::TyTup(vec![]) =>
- signature.push(ptr::null_mut()),
- _ => {
- assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
-
- let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
- let return_type = monomorphize::apply_param_substs(cx.tcx(),
- param_substs,
- &return_type);
- signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
- }
+ assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
+ let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
+ let return_type = monomorphize::apply_param_substs(cx.tcx(),
+ param_substs,
+ &return_type);
+ if ty::type_is_nil(return_type) {
+ signature.push(ptr::null_mut())
+ } else {
+ signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
}
// Arguments types
fn_metadata: DISubprogram,
fn_ast_id: ast::NodeId)
-> NodeMap<DIScope> {
- let mut scope_map = NodeMap::new();
+ let mut scope_map = NodeMap();
let def_map = &cx.tcx().def_map;
implied_output_region,
lifetimes_for_params,
&**output)),
- ast::NoReturn(_) => ty::FnDiverging
+ ast::DefaultReturn(..) => ty::FnConverging(ty::mk_nil(this.tcx())),
+ ast::NoReturn(..) => ty::FnDiverging
};
(ty::BareFnTy {
let expected_ret_ty = expected_sig.map(|e| e.output);
+ let is_infer = match decl.output {
+ ast::Return(ref output) if output.node == ast::TyInfer => true,
+ ast::DefaultReturn(..) => true,
+ _ => false
+ };
+
let output_ty = match decl.output {
- ast::Return(ref output) if output.node == ast::TyInfer && expected_ret_ty.is_some() =>
+ _ if is_infer && expected_ret_ty.is_some() =>
expected_ret_ty.unwrap(),
- ast::Return(ref output) if output.node == ast::TyInfer =>
- ty::FnConverging(this.ty_infer(output.span)),
+ _ if is_infer =>
+ ty::FnConverging(this.ty_infer(decl.output.span())),
ast::Return(ref output) =>
ty::FnConverging(ast_ty_to_ty(this, &rb, &**output)),
- ast::NoReturn(_) => ty::FnDiverging
+ ast::DefaultReturn(..) => unreachable!(),
+ ast::NoReturn(..) => ty::FnDiverging
};
debug!("ty_of_closure: input_tys={}", input_tys.repr(this.tcx()));
let mut builtin_bounds = ty::empty_builtin_bounds();
let mut region_bounds = Vec::new();
let mut trait_bounds = Vec::new();
- let mut trait_def_ids = DefIdMap::new();
+ let mut trait_def_ids = DefIdMap();
for ast_bound in ast_bounds.iter() {
match *ast_bound {
ast::TraitTyParamBound(ref b, ast::TraitBoundModifier::None) => {
rcvr_ty_generics.repr(ccx.tcx));
let tcx = ccx.tcx;
- let mut seen_methods = FnvHashSet::new();
+ let mut seen_methods = FnvHashSet();
for m in ms {
if !seen_methods.insert(m.pe_ident().repr(tcx)) {
tcx.sess.span_err(m.span, "duplicate method in trait impl");
let tcx = ccx.tcx;
// Write the type of each of the members and check for duplicate fields.
- let mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap::new();
+ let mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap();
let field_tys = struct_def.fields.iter().map(|f| {
let result = convert_field(ccx, &scheme.generics, f, local_def(id));
let output = match decl.output {
ast::Return(ref ty) =>
ty::FnConverging(ast_ty_to_ty(ccx, &rb, &**ty)),
- ast::NoReturn(_) =>
+ ast::DefaultReturn(..) =>
+ ty::FnConverging(ty::mk_nil(ccx.tcx)),
+ ast::NoReturn(..) =>
ty::FnDiverging
};