]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #21269 - alexcrichton:issue-6936, r=pnkfelix
authorbors <bors@rust-lang.org>
Mon, 19 Jan 2015 15:44:41 +0000 (15:44 +0000)
committerbors <bors@rust-lang.org>
Mon, 19 Jan 2015 15:44:41 +0000 (15:44 +0000)
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

1  2 
src/librustc_trans/trans/debuginfo.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/collect.rs

index ea66b97bbf968e30d5186f7026f68720f9acfc82,5ffaa9486b3638f71d3b515639e4f08f18eaef69..2f01f0328e28c21fb7ee45124db52cd07f6959af
@@@ -271,9 -271,9 +271,9 @@@ impl<'tcx> TypeMap<'tcx> 
      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(),
          }
      }
  
@@@ -672,11 -672,11 +672,11 @@@ impl<'tcx> CrateDebugContext<'tcx> 
              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()),
          };
      }
  }
@@@ -1450,15 -1450,18 +1450,15 @@@ pub fn create_function_debug_context<'a
          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
@@@ -3225,7 -3228,7 +3225,7 @@@ fn create_scope_map(cx: &CrateContext
                      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;
  
index c2b34acc6c8cc30f47dcac7a8da8967b9d72a4a8,37487cbfc7edad08cca67c94a158d0c673e001bf..42b12c158664ae2247d1e2a60744bda4f08ad8fc
@@@ -1359,8 -1359,7 +1359,8 @@@ fn ty_of_method_or_bare_fn<'a, 'tcx>(th
                                                                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 {
@@@ -1487,21 -1486,14 +1487,21 @@@ pub fn ty_of_closure<'tcx>
  
      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()));
@@@ -1719,7 -1711,7 +1719,7 @@@ pub fn partition_bounds<'a>(tcx: &ty::c
      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) => {
index 25ba7ccdbc4d93f92f07fad03fff836fbca9025e,d1d81eba329e6281be076d35cea0752b213b423b..80c0a72db838768499d7a7d5bea23b56a02de3d3
@@@ -449,7 -449,7 +449,7 @@@ fn convert_methods<'a,'tcx,'i,I>(ccx: &
             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");
@@@ -737,7 -737,7 +737,7 @@@ fn convert_struct<'a, 'tcx>(ccx: &Colle
      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));
  
@@@ -1488,9 -1488,7 +1488,9 @@@ fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx
      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
      };