Skip to content

Commit 1023dfe

Browse files
committed
---
yaml --- r: 36364 b: refs/heads/master c: dbfa054 h: refs/heads/master
1 parent 47e4ace commit 1023dfe

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
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a17a7c9f7572685df59e287c48450ccb09e8313a
2+
refs/heads/master: dbfa05411bad5d31cb594a02ddbf5333dcb0ad5a

trunk/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 {

trunk/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)