Implement RFC 1058

This commit is contained in:
Simonas Kazlauskas 2015-07-11 14:34:57 +03:00
parent 072d07ce9f
commit 7a90865db5
20 changed files with 110 additions and 77 deletions

View file

@ -53,7 +53,7 @@
#![feature(rustc_private)]
#![feature(scoped_tls)]
#![feature(slice_bytes)]
#![feature(slice_extras)]
#![feature(slice_splits)]
#![feature(slice_patterns)]
#![feature(slice_position_elem)]
#![feature(staged_api)]

View file

@ -688,7 +688,7 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &ty::ctxt<'tcx>, id: ast::NodeI
-> csearch::FoundAst<'tcx> {
debug!("Looking up item: {}", id);
let item_doc = lookup_item(id, cdata.data());
let path = item_path(item_doc).init().to_vec();
let path = item_path(item_doc).split_last().unwrap().1.to_vec();
match decode_inlined_item(cdata, tcx, path, item_doc) {
Ok(ii) => csearch::FoundAst::Found(ii),
Err(path) => {

View file

@ -696,12 +696,12 @@ fn is_useful(cx: &MatchCheckCtxt,
Some(constructor) => {
let matrix = rows.iter().filter_map(|r| {
if pat_is_binding_or_wild(&cx.tcx.def_map, raw_pat(r[0])) {
Some(r.tail().to_vec())
Some(r[1..].to_vec())
} else {
None
}
}).collect();
match is_useful(cx, &matrix, v.tail(), witness) {
match is_useful(cx, &matrix, &v[1..], witness) {
UsefulWithWitness(pats) => {
let arity = constructor_arity(cx, &constructor, left_ty);
let wild_pats = vec![DUMMY_WILD_PAT; arity];

View file

@ -1495,7 +1495,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
parameters: new_parameters
};
let mut new_segs = Vec::new();
new_segs.push_all(path.segments.init());
new_segs.push_all(path.segments.split_last().unwrap().1);
new_segs.push(new_seg);
ast::Path {
span: path.span,

View file

@ -2571,7 +2571,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
for &i in &ty_params {
new_substs.types.get_mut_slice(TypeSpace)[i] = tcx.types.err;
}
for &ty in fields.init() {
for &ty in fields.split_last().unwrap().1 {
if ty.subst(tcx, &new_substs).references_error() {
return Err(Unimplemented);
}