Skip to content

Commit c2276c3

Browse files
committed
---
yaml --- r: 135163 b: refs/heads/snap-stage3 c: bb58079 h: refs/heads/master i: 135161: 35cf182 135159: d29b530 v: v3
1 parent 7f76b1d commit c2276c3

34 files changed

+315
-443
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 74090504219e4e37c1a6d9fdd8600f44b51c7b04
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 496b68d485698ae230be5a06aadf5fbbbcc0fd83
4+
refs/heads/snap-stage3: bb5807919a4b26ba017d2e2f14f2cc9b3d87a278
55
refs/heads/try: 14378ea357c06c23607ca61ade44f60a7a64a1c7
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/etc/licenseck.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"test/bench/shootout-chameneos-redux.rs", # BSD
4747
"test/bench/shootout-fannkuch-redux.rs", # BSD
4848
"test/bench/shootout-fasta.rs", # BSD
49-
"test/bench/shootout-fasta-redux.rs", # BSD
5049
"test/bench/shootout-k-nucleotide.rs", # BSD
5150
"test/bench/shootout-mandelbrot.rs", # BSD
5251
"test/bench/shootout-meteor.rs", # BSD

branches/snap-stage3/src/librustc/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
226226
// baz! should not use this definition unless foo is enabled.
227227

228228
krate = time(time_passes, "configuration 1", krate, |krate|
229-
syntax::config::strip_unconfigured_items(sess.diagnostic(), krate));
229+
syntax::config::strip_unconfigured_items(krate));
230230

231231
let mut addl_plugins = Some(addl_plugins);
232232
let Plugins { macros, registrars }
@@ -307,7 +307,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
307307

308308
// strip again, in case expansion added anything with a #[cfg].
309309
krate = time(time_passes, "configuration 2", krate, |krate|
310-
syntax::config::strip_unconfigured_items(sess.diagnostic(), krate));
310+
syntax::config::strip_unconfigured_items(krate));
311311

312312
krate = time(time_passes, "maybe building test harness", krate, |krate|
313313
syntax::test::modify_for_testing(&sess.parse_sess,

branches/snap-stage3/src/librustc/middle/resolve.rs

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,16 +2945,53 @@ impl<'a> Resolver<'a> {
29452945
match *name_bindings.type_def.borrow() {
29462946
None => {}
29472947
Some(ref ty) => {
2948-
let msg = format!("import `{}` conflicts with type in \
2949-
this module",
2950-
token::get_name(name).get());
2951-
self.session.span_err(import_span, msg.as_slice());
2952-
match ty.type_span {
2953-
None => {}
2954-
Some(span) => {
2955-
self.session
2956-
.span_note(span,
2957-
"conflicting type here")
2948+
match ty.module_def {
2949+
None => {
2950+
let msg = format!("import `{}` conflicts with type in \
2951+
this module",
2952+
token::get_name(name).get());
2953+
self.session.span_err(import_span, msg.as_slice());
2954+
match ty.type_span {
2955+
None => {}
2956+
Some(span) => {
2957+
self.session
2958+
.span_note(span,
2959+
"note conflicting type here")
2960+
}
2961+
}
2962+
}
2963+
Some(ref module_def) => {
2964+
match module_def.kind.get() {
2965+
ImplModuleKind => {
2966+
match ty.type_span {
2967+
None => { /* this can't ever happen */ }
2968+
Some(span) => {
2969+
let msg = format!("inherent implementations \
2970+
are only allowed on types \
2971+
defined in the current module");
2972+
self.session
2973+
.span_err(span, msg.as_slice());
2974+
self.session
2975+
.span_note(import_span,
2976+
"import from other module here")
2977+
}
2978+
}
2979+
}
2980+
_ => {
2981+
let msg = format!("import `{}` conflicts with existing \
2982+
submodule",
2983+
token::get_name(name).get());
2984+
self.session.span_err(import_span, msg.as_slice());
2985+
match ty.type_span {
2986+
None => {}
2987+
Some(span) => {
2988+
self.session
2989+
.span_note(span,
2990+
"note conflicting module here")
2991+
}
2992+
}
2993+
}
2994+
}
29582995
}
29592996
}
29602997
}
@@ -4610,6 +4647,30 @@ impl<'a> Resolver<'a> {
46104647
});
46114648
});
46124649
});
4650+
4651+
// Check that the current type is indeed a type, if we have an anonymous impl
4652+
if opt_trait_reference.is_none() {
4653+
match self_type.node {
4654+
// TyPath is the only thing that we handled in `build_reduced_graph_for_item`,
4655+
// where we created a module with the name of the type in order to implement
4656+
// an anonymous trait. In the case that the path does not resolve to an actual
4657+
// type, the result will be that the type name resolves to a module but not
4658+
// a type (shadowing any imported modules or types with this name), leading
4659+
// to weird user-visible bugs. So we ward this off here. See #15060.
4660+
TyPath(ref path, _, path_id) => {
4661+
match self.def_map.borrow().find(&path_id) {
4662+
// FIXME: should we catch other options and give more precise errors?
4663+
Some(&DefMod(_)) => {
4664+
self.resolve_error(path.span, "inherent implementations are not \
4665+
allowed for types not defined in \
4666+
the current module.");
4667+
}
4668+
_ => {}
4669+
}
4670+
}
4671+
_ => { }
4672+
}
4673+
}
46134674
}
46144675

46154676
fn check_trait_item(&self, ident: Ident, span: Span) {

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,7 @@ pub fn trans_closure(ccx: &CrateContext,
17911791
body: &ast::Block,
17921792
llfndecl: ValueRef,
17931793
param_substs: &param_substs,
1794-
fn_ast_id: ast::NodeId,
1794+
id: ast::NodeId,
17951795
_attributes: &[ast::Attribute],
17961796
arg_types: Vec<ty::t>,
17971797
output_type: ty::t,
@@ -1811,7 +1811,7 @@ pub fn trans_closure(ccx: &CrateContext,
18111811
let arena = TypedArena::new();
18121812
let fcx = new_fn_ctxt(ccx,
18131813
llfndecl,
1814-
fn_ast_id,
1814+
id,
18151815
has_env,
18161816
output_type,
18171817
param_substs,
@@ -1820,9 +1820,7 @@ pub fn trans_closure(ccx: &CrateContext,
18201820
let mut bcx = init_function(&fcx, false, output_type);
18211821

18221822
// cleanup scope for the incoming arguments
1823-
let fn_cleanup_debug_loc =
1824-
debuginfo::get_cleanup_debug_loc_for_ast_node(fn_ast_id, body.span, true);
1825-
let arg_scope = fcx.push_custom_cleanup_scope_with_debug_loc(fn_cleanup_debug_loc);
1823+
let arg_scope = fcx.push_custom_cleanup_scope();
18261824

18271825
let block_ty = node_id_type(bcx, body.id);
18281826

@@ -1971,9 +1969,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
19711969
ctor_ty: ty::t,
19721970
disr: ty::Disr,
19731971
args: callee::CallArgs,
1974-
dest: expr::Dest,
1975-
call_info: Option<NodeInfo>)
1976-
-> Result<'blk, 'tcx> {
1972+
dest: expr::Dest) -> Result<'blk, 'tcx> {
19771973

19781974
let ccx = bcx.fcx.ccx;
19791975
let tcx = ccx.tcx();
@@ -2003,13 +1999,8 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
20031999
match args {
20042000
callee::ArgExprs(exprs) => {
20052001
let fields = exprs.iter().map(|x| &**x).enumerate().collect::<Vec<_>>();
2006-
bcx = expr::trans_adt(bcx,
2007-
result_ty,
2008-
disr,
2009-
fields.as_slice(),
2010-
None,
2011-
expr::SaveIn(llresult),
2012-
call_info);
2002+
bcx = expr::trans_adt(bcx, result_ty, disr, fields.as_slice(),
2003+
None, expr::SaveIn(llresult));
20132004
}
20142005
_ => ccx.sess().bug("expected expr as arguments for variant/struct tuple constructor")
20152006
}
@@ -2019,9 +2010,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
20192010
// drop the temporary we made
20202011
let bcx = match dest {
20212012
expr::SaveIn(_) => bcx,
2022-
expr::Ignore => {
2023-
glue::drop_ty(bcx, llresult, result_ty, call_info)
2024-
}
2013+
expr::Ignore => glue::drop_ty(bcx, llresult, result_ty)
20252014
};
20262015

20272016
Result::new(bcx, llresult)

branches/snap-stage3/src/librustc/middle/trans/callee.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,8 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
714714
fcx.pop_custom_cleanup_scope(arg_cleanup_scope);
715715

716716
let ctor_ty = callee_ty.subst(bcx.tcx(), &substs);
717-
return base::trans_named_tuple_constructor(bcx,
718-
ctor_ty,
719-
disr,
720-
args,
721-
dest.unwrap(),
722-
call_info);
717+
return base::trans_named_tuple_constructor(bcx, ctor_ty, disr,
718+
args, dest.unwrap());
723719
}
724720
};
725721

@@ -839,7 +835,7 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
839835
match (dest, opt_llretslot) {
840836
(Some(expr::Ignore), Some(llretslot)) => {
841837
// drop the value if it is not being saved.
842-
bcx = glue::drop_ty(bcx, llretslot, ret_ty, call_info);
838+
bcx = glue::drop_ty(bcx, llretslot, ret_ty);
843839
call_lifetime_end(bcx, llretslot);
844840
}
845841
_ => {}

0 commit comments

Comments
 (0)