Skip to content

Commit 64a2736

Browse files
committed
---
yaml --- r: 171898 b: refs/heads/beta c: dbfa054 h: refs/heads/master v: v3
1 parent e01102f commit 64a2736

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
@@ -31,5 +31,5 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b5571ed71a5879c0495a982506258d5d267744ed
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: a17a7c9f7572685df59e287c48450ccb09e8313a
34+
refs/heads/beta: dbfa05411bad5d31cb594a02ddbf5333dcb0ad5a
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/beta/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/beta/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)