Skip to content

Commit 0e1db1a

Browse files
committed
---
yaml --- r: 232453 b: refs/heads/try c: c8b6d5b h: refs/heads/master i: 232451: 1b64ffc v: v3
1 parent 457fddb commit 0e1db1a

File tree

19 files changed

+336
-302
lines changed

19 files changed

+336
-302
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: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 6d992728c331128810704d16d8026aa4fa2e0c87
4+
refs/heads/try: c8b6d5b23cc8b2d43ece9f06252c7e98280fb8e5
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc/middle/ty.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,10 +3312,10 @@ impl<'tcx, 'container> AdtDefData<'tcx, 'container> {
33123312
variants: Vec<VariantDefData<'tcx, 'container>>) -> Self {
33133313
let mut flags = AdtFlags::NO_ADT_FLAGS;
33143314
let attrs = tcx.get_attrs(did);
3315-
if attrs.iter().any(|item| item.check_name("fundamental")) {
3315+
if attr::contains_name(&attrs, "fundamental") {
33163316
flags = flags | AdtFlags::IS_FUNDAMENTAL;
33173317
}
3318-
if attrs.iter().any(|item| item.check_name("simd")) {
3318+
if tcx.lookup_simd(did) {
33193319
flags = flags | AdtFlags::IS_SIMD;
33203320
}
33213321
if Some(did) == tcx.lang_items.phantom_data() {
@@ -6116,6 +6116,7 @@ impl<'tcx> ctxt<'tcx> {
61166116
/// Determine whether an item is annotated with `#[simd]`
61176117
pub fn lookup_simd(&self, did: DefId) -> bool {
61186118
self.has_attr(did, "simd")
6119+
|| self.lookup_repr_hints(did).contains(&attr::ReprSimd)
61196120
}
61206121

61216122
/// Obtain the representation annotation for a struct definition.

branches/try/src/librustc_trans/trans/adt.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
615615
attr::ReprPacked => {
616616
cx.tcx().sess.bug("range_to_inttype: found ReprPacked on an enum");
617617
}
618+
attr::ReprSimd => {
619+
cx.tcx().sess.bug("range_to_inttype: found ReprSimd on an enum");
620+
}
618621
}
619622
for &ity in attempts {
620623
if bounds_usable(cx, ity, bounds) {

branches/try/src/librustc_typeck/check/_match.rs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -528,31 +528,60 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx ast::Pat,
528528
let tcx = pcx.fcx.ccx.tcx;
529529

530530
let def = tcx.def_map.borrow().get(&pat.id).unwrap().full_def();
531-
let variant = match fcx.def_struct_variant(def) {
532-
Some((_, variant)) => variant,
533-
None => {
531+
let (adt_def, variant) = match def {
532+
def::DefTrait(_) => {
534533
let name = pprust::path_to_string(path);
535-
span_err!(tcx.sess, pat.span, E0163,
536-
"`{}` does not name a struct or a struct variant", name);
534+
span_err!(tcx.sess, pat.span, E0168,
535+
"use of trait `{}` in a struct pattern", name);
537536
fcx.write_error(pat.id);
538537

539538
for field in fields {
540-
check_pat(pcx, &field.node.pat, tcx.types.err);
539+
check_pat(pcx, &*field.node.pat, tcx.types.err);
541540
}
542541
return;
542+
},
543+
_ => {
544+
let def_type = tcx.lookup_item_type(def.def_id());
545+
match def_type.ty.sty {
546+
ty::TyStruct(struct_def, _) =>
547+
(struct_def, struct_def.struct_variant()),
548+
ty::TyEnum(enum_def, _)
549+
if def == def::DefVariant(enum_def.did, def.def_id(), true) =>
550+
(enum_def, enum_def.variant_of_def(def)),
551+
_ => {
552+
let name = pprust::path_to_string(path);
553+
span_err!(tcx.sess, pat.span, E0163,
554+
"`{}` does not name a struct or a struct variant", name);
555+
fcx.write_error(pat.id);
556+
557+
for field in fields {
558+
check_pat(pcx, &*field.node.pat, tcx.types.err);
559+
}
560+
return;
561+
}
562+
}
543563
}
544564
};
545565

546-
let pat_ty = pcx.fcx.instantiate_type(def.def_id(), path);
547-
let item_substs = match pat_ty.sty {
548-
ty::TyStruct(_, substs) | ty::TyEnum(_, substs) => substs,
549-
_ => tcx.sess.span_bug(pat.span, "struct variant is not an ADT")
550-
};
566+
instantiate_path(pcx.fcx,
567+
&path.segments,
568+
adt_def.type_scheme(tcx),
569+
&adt_def.predicates(tcx),
570+
None,
571+
def,
572+
pat.span,
573+
pat.id);
574+
575+
let pat_ty = fcx.node_ty(pat.id);
551576
demand::eqtype(fcx, pat.span, expected, pat_ty);
552-
check_struct_pat_fields(pcx, pat.span, fields, variant, &item_substs, etc);
553577

554-
fcx.write_ty(pat.id, pat_ty);
555-
fcx.write_substs(pat.id, ty::ItemSubsts { substs: item_substs.clone() });
578+
let item_substs = fcx
579+
.item_substs()
580+
.get(&pat.id)
581+
.map(|substs| substs.substs.clone())
582+
.unwrap_or_else(|| Substs::empty());
583+
584+
check_struct_pat_fields(pcx, pat.span, fields, variant, &item_substs, etc);
556585
}
557586

558587
pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,

0 commit comments

Comments
 (0)