parent
b224dfe1a6
commit
f2973f63a3
8 changed files with 13 additions and 14 deletions
|
@ -149,7 +149,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) {
|
||||||
}
|
}
|
||||||
ExprCall(ref callee, _) => {
|
ExprCall(ref callee, _) => {
|
||||||
match v.tcx.def_map.borrow().find(&callee.id) {
|
match v.tcx.def_map.borrow().find(&callee.id) {
|
||||||
Some(&DefStruct(..)) => {} // OK.
|
Some(&DefStruct(..)) |
|
||||||
Some(&DefVariant(..)) => {} // OK.
|
Some(&DefVariant(..)) => {} // OK.
|
||||||
_ => {
|
_ => {
|
||||||
span_err!(v.tcx.sess, e.span, E0015,
|
span_err!(v.tcx.sess, e.span, E0015,
|
||||||
|
|
|
@ -757,7 +757,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
||||||
DefStatic(..) =>
|
DefStatic(..) =>
|
||||||
cx.tcx.sess.span_bug(pat_span, "static pattern should've been rewritten"),
|
cx.tcx.sess.span_bug(pat_span, "static pattern should've been rewritten"),
|
||||||
DefVariant(_, id, _) if *constructor != Variant(id) => None,
|
DefVariant(_, id, _) if *constructor != Variant(id) => None,
|
||||||
DefVariant(..) | DefFn(..) | DefStruct(..) => {
|
DefVariant(..) | DefStruct(..) => {
|
||||||
Some(match args {
|
Some(match args {
|
||||||
&Some(ref args) => args.iter().map(|p| &**p).collect(),
|
&Some(ref args) => args.iter().map(|p| &**p).collect(),
|
||||||
&None => Vec::from_elem(arity, &DUMMY_WILD_PAT)
|
&None => Vec::from_elem(arity, &DUMMY_WILD_PAT)
|
||||||
|
|
|
@ -1083,7 +1083,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
||||||
if_ok!(self.cat_pattern(subcmt, &**subpat, |x,y,z| op(x,y,z)));
|
if_ok!(self.cat_pattern(subcmt, &**subpat, |x,y,z| op(x,y,z)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(&def::DefFn(..)) |
|
|
||||||
Some(&def::DefStruct(..)) => {
|
Some(&def::DefStruct(..)) => {
|
||||||
for (i, subpat) in subpats.iter().enumerate() {
|
for (i, subpat) in subpats.iter().enumerate() {
|
||||||
let subpat_ty = if_ok!(self.pat_ty(&**subpat)); // see (*2)
|
let subpat_ty = if_ok!(self.pat_ty(&**subpat)); // see (*2)
|
||||||
|
|
|
@ -931,15 +931,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
|
||||||
maybe_did.unwrap_or(did)
|
maybe_did.unwrap_or(did)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Tuple struct constructors across crates are identified as
|
|
||||||
// DefFn types, so we explicitly handle that case here.
|
|
||||||
Some(&def::DefFn(did, _, _)) if !is_local(did) => {
|
|
||||||
match csearch::get_tuple_struct_definition_if_ctor(
|
|
||||||
&self.tcx.sess.cstore, did) {
|
|
||||||
Some(did) => guard(did),
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1824,6 +1824,11 @@ impl<'a> Resolver<'a> {
|
||||||
child_name_bindings.define_value(def, DUMMY_SP, is_exported);
|
child_name_bindings.define_value(def, DUMMY_SP, is_exported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DefFn(ctor_id, _, true) => {
|
||||||
|
child_name_bindings.define_value(
|
||||||
|
csearch::get_tuple_struct_definition_if_ctor(&self.session.cstore, ctor_id)
|
||||||
|
.map_or(def, |_| DefStruct(ctor_id)), DUMMY_SP, is_public);
|
||||||
|
}
|
||||||
DefFn(..) | DefStaticMethod(..) | DefStatic(..) => {
|
DefFn(..) | DefStaticMethod(..) | DefStatic(..) => {
|
||||||
debug!("(building reduced graph for external \
|
debug!("(building reduced graph for external \
|
||||||
crate) building value (fn/static) {}", final_ident);
|
crate) building value (fn/static) {}", final_ident);
|
||||||
|
|
|
@ -698,7 +698,6 @@ fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: uint) -> bool {
|
||||||
}
|
}
|
||||||
ast::PatEnum(..) | ast::PatIdent(_, _, None) => {
|
ast::PatEnum(..) | ast::PatIdent(_, _, None) => {
|
||||||
match tcx.def_map.borrow().find(&pat.id) {
|
match tcx.def_map.borrow().find(&pat.id) {
|
||||||
Some(&def::DefFn(..)) |
|
|
||||||
Some(&def::DefStruct(..)) => true,
|
Some(&def::DefStruct(..)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
@ -1646,7 +1645,6 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(def::DefFn(..)) |
|
|
||||||
Some(def::DefStruct(..)) => {
|
Some(def::DefStruct(..)) => {
|
||||||
match *sub_pats {
|
match *sub_pats {
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -19,6 +19,8 @@ pub enum Unit {
|
||||||
Argument(Struct)
|
Argument(Struct)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct TupleStruct(pub uint, pub &'static str);
|
||||||
|
|
||||||
// used by the cfail test
|
// used by the cfail test
|
||||||
|
|
||||||
pub struct StructWithFields {
|
pub struct StructWithFields {
|
||||||
|
|
|
@ -16,17 +16,21 @@ static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::UnitVariant;
|
||||||
static s3: xcrate_unit_struct::Unit =
|
static s3: xcrate_unit_struct::Unit =
|
||||||
xcrate_unit_struct::Argument(xcrate_unit_struct::Struct);
|
xcrate_unit_struct::Argument(xcrate_unit_struct::Struct);
|
||||||
static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(s1);
|
static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(s1);
|
||||||
|
static s5: xcrate_unit_struct::TupleStruct = xcrate_unit_struct::TupleStruct(20, "foo");
|
||||||
|
|
||||||
fn f1(_: xcrate_unit_struct::Struct) {}
|
fn f1(_: xcrate_unit_struct::Struct) {}
|
||||||
fn f2(_: xcrate_unit_struct::Unit) {}
|
fn f2(_: xcrate_unit_struct::Unit) {}
|
||||||
|
fn f3(_: xcrate_unit_struct::TupleStruct) {}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
f1(xcrate_unit_struct::Struct);
|
f1(xcrate_unit_struct::Struct);
|
||||||
f2(xcrate_unit_struct::UnitVariant);
|
f2(xcrate_unit_struct::UnitVariant);
|
||||||
f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct));
|
f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct));
|
||||||
|
f3(xcrate_unit_struct::TupleStruct(10, "bar"));
|
||||||
|
|
||||||
f1(s1);
|
f1(s1);
|
||||||
f2(s2);
|
f2(s2);
|
||||||
f2(s3);
|
f2(s3);
|
||||||
f2(s4);
|
f2(s4);
|
||||||
|
f3(s5);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue