Skip to content

Commit a85920c

Browse files
committed
---
yaml --- r: 170804 b: refs/heads/try c: dbfa054 h: refs/heads/master v: v3
1 parent f38f60b commit a85920c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 73a25f55ad748b4d3516417c711b99ce446591af
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
5-
refs/heads/try: a17a7c9f7572685df59e287c48450ccb09e8313a
5+
refs/heads/try: dbfa05411bad5d31cb594a02ddbf5333dcb0ad5a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,10 @@ impl<'tcx> Generics<'tcx> {
17791779
!self.regions.is_empty_in(space)
17801780
}
17811781

1782+
pub fn is_empty(&self) -> bool {
1783+
self.types.is_empty() && self.regions.is_empty()
1784+
}
1785+
17821786
pub fn to_bounds(&self, tcx: &ty::ctxt<'tcx>, substs: &Substs<'tcx>)
17831787
-> GenericBounds<'tcx> {
17841788
GenericBounds {

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,18 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
103103
ast::PatEnum(..) | ast::PatIdent(..) if pat_is_const(&tcx.def_map, pat) => {
104104
let const_did = tcx.def_map.borrow()[pat.id].clone().def_id();
105105
let const_scheme = ty::lookup_item_type(tcx, const_did);
106-
fcx.write_ty(pat.id, const_scheme.ty);
107-
demand::suptype(fcx, pat.span, expected, const_scheme.ty);
106+
assert!(const_scheme.generics.is_empty());
107+
let const_ty = pcx.fcx.instantiate_type_scheme(pat.span,
108+
&Substs::empty(),
109+
&const_scheme.ty);
110+
fcx.write_ty(pat.id, const_ty);
111+
112+
// FIXME(#20489) -- we should limit the types here to scalars or something!
113+
114+
// As with PatLit, what we really want here is that there
115+
// exist a LUB, but for the cases that can occur, subtype
116+
// is good enough.
117+
demand::suptype(fcx, pat.span, expected, const_ty);
108118
}
109119
ast::PatIdent(bm, ref path, ref sub) if pat_is_binding(&tcx.def_map, pat) => {
110120
let typ = fcx.local_ty(pat.span, pat.id);

0 commit comments

Comments
 (0)