Auto merge of #28857 - nrc:lowering, r=nikomatsakis

r? @nikomatsakis
This commit is contained in:
bors 2015-10-09 08:53:45 +00:00
commit c14609035d
39 changed files with 1603 additions and 889 deletions

View file

@ -9,7 +9,5 @@
// except according to those terms.
fn main() {
for
&1 //~ ERROR refutable pattern in `for` loop binding
in [1].iter() {}
for &1 in [1].iter() {} //~ ERROR refutable pattern in `for` loop binding
}

View file

@ -16,4 +16,17 @@ fn main() -> (){
for n in 0..1 {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
if let Some(n) = None {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
if false {
} else if let Some(n) = None {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
while let Some(n) = None {
println!("{}", f!()); //~ ERROR unresolved name `n`
}
}

View file

@ -13,10 +13,8 @@
fn main() {
let values: Vec<u8> = vec![1,2,3,4,5,6,7,8];
for
[x,y,z]
//~^ ERROR refutable pattern in `for` loop binding: `[]` not covered
in values.chunks(3).filter(|&xs| xs.len() == 3) {
for [x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) {
//~^ ERROR refutable pattern in `for` loop binding: `[]` not covered
println!("y={}", y);
}
}

View file

@ -8,11 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we get an expansion stack for `for` loops.
// Check that placement in respects unsafe code checks.
// error-pattern:in this expansion of for loop expansion
#![feature(box_heap)]
#![feature(placement_in_syntax)]
fn main() {
for t in &foo {
}
use std::boxed::HEAP;
let p: *const i32 = &42;
let _ = in HEAP { *p }; //~ ERROR requires unsafe
let p: *const _ = &HEAP;
let _ = in *p { 42 }; //~ ERROR requires unsafe
}

View file

@ -0,0 +1,27 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Check that placement in respects unstable code checks.
#![feature(placement_in_syntax)]
#![feature(core)]
extern crate core;
fn main() {
use std::boxed::HEAP; //~ ERROR use of unstable library feature
let _ = in HEAP { //~ ERROR use of unstable library feature
::core::raw::Slice { //~ ERROR use of unstable library feature
data: &42, //~ ERROR use of unstable library feature
len: 1 //~ ERROR use of unstable library feature
}
};
}

View file

@ -31,7 +31,7 @@ use rustc::middle::ty;
use rustc::session::config::{self, basic_options, build_configuration, Input, Options};
use rustc::session::build_session;
use rustc_driver::driver;
use rustc_front::lowering::lower_crate;
use rustc_front::lowering::{lower_crate, LoweringContext};
use rustc_resolve::MakeGlobMap;
use libc::c_void;
@ -223,12 +223,13 @@ fn compile_program(input: &str, sysroot: PathBuf)
.expect("phase_2 returned `None`");
let krate = driver::assign_node_ids(&sess, krate);
let mut hir_forest = ast_map::Forest::new(lower_crate(&krate));
let lcx = LoweringContext::new(&sess, Some(&krate));
let mut hir_forest = ast_map::Forest::new(lower_crate(&lcx, &krate));
let arenas = ty::CtxtArenas::new();
let ast_map = driver::make_map(&sess, &mut hir_forest);
driver::phase_3_run_analysis_passes(
sess, ast_map, &arenas, id, MakeGlobMap::No, |tcx, analysis| {
&sess, ast_map, &arenas, id, MakeGlobMap::No, |tcx, analysis| {
let trans = driver::phase_4_translate_to_llvm(tcx, analysis);
@ -246,7 +247,7 @@ fn compile_program(input: &str, sysroot: PathBuf)
let modp = llmod as usize;
(modp, deps)
}).1
})
}).unwrap();
match handle.join() {

View file

@ -339,8 +339,27 @@ fn main() { // foo
if let SomeEnum::Strings(..) = s7 {
println!("hello!");
}
for i in 0..5 {
foo_foo(i);
}
if let Some(x) = None {
foo_foo(x);
}
if false {
} else if let Some(y) = None {
foo_foo(y);
}
while let Some(z) = None {
foo_foo(z);
}
}
fn foo_foo(_: i32) {}
impl Iterator for nofields {
type Item = (usize, usize);