Touch up and rebase previous commits

* Added `// no-pretty-expanded` to pretty-print a test, but not run it through
  the `expanded` variant.
* Removed #[deriving] and other expanded attributes after they are expanded
* Removed hacks around &str and &&str and friends (from both the parser and the
  pretty printer).
* Un-ignored a bunch of tests
This commit is contained in:
Alex Crichton 2014-05-10 17:39:08 -07:00
parent ce8c467bd2
commit 1237530452
33 changed files with 85 additions and 95 deletions

View File

@ -29,7 +29,7 @@ use std::io::fs;
use std::from_str::FromStr;
use getopts::{optopt, optflag, reqopt};
use common::Config;
use common::{Pretty, DebugInfo, Codegen};
use common::{Pretty, DebugInfoGdb, Codegen};
use util::logv;
pub mod procsrv;
@ -199,7 +199,7 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
}
pub fn run_tests(config: &Config) {
if config.target == ~"arm-linux-androideabi" {
if config.target == "arm-linux-androideabi".to_owned() {
match config.mode {
DebugInfoGdb => {
println!("arm-linux-androideabi debug-info \

View File

@ -34,6 +34,8 @@ pub struct TestProps {
pub check_stdout: bool,
// Don't force a --crate-type=dylib flag on the command line
pub no_prefer_dynamic: bool,
// Don't run --pretty expanded when running pretty printing tests
pub no_pretty_expanded: bool,
}
// Load any test directives embedded in the file
@ -48,6 +50,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut force_host = false;
let mut check_stdout = false;
let mut no_prefer_dynamic = false;
let mut no_pretty_expanded = false;
iter_header(testfile, |ln| {
match parse_error_pattern(ln) {
Some(ep) => error_patterns.push(ep),
@ -78,6 +81,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
no_prefer_dynamic = parse_no_prefer_dynamic(ln);
}
if !no_pretty_expanded {
no_pretty_expanded = parse_no_pretty_expanded(ln);
}
match parse_aux_build(ln) {
Some(ab) => { aux_builds.push(ab); }
None => {}
@ -107,6 +114,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
force_host: force_host,
check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic,
no_pretty_expanded: no_pretty_expanded,
}
}
@ -180,6 +188,10 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
parse_name_directive(line, "no-prefer-dynamic")
}
fn parse_no_pretty_expanded(line: &str) -> bool {
parse_name_directive(line, "no-pretty-expanded")
}
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
parse_name_value_directive(line, "exec-env".to_owned()).map(|nv| {
// nv is either FOO or FOO=BAR

View File

@ -9,7 +9,7 @@
// except according to those terms.
use common::Config;
use common::{CompileFail, Pretty, RunFail, RunPass};
use common::{CompileFail, Pretty, RunFail, RunPass, DebugInfoGdb, DebugInfoLldb};
use errors;
use header::TestProps;
use header;
@ -64,7 +64,7 @@ pub fn run_metrics(config: Config, testfile: ~str, mm: &mut MetricMap) {
Pretty => run_pretty_test(&config, &props, &testfile),
DebugInfoGdb => run_debuginfo_gdb_test(&config, &props, &testfile),
DebugInfoLldb => run_debuginfo_lldb_test(&config, &props, &testfile),
Codegen => run_codegen_test(&config, &props, &testfile, mm)
Codegen => run_codegen_test(&config, &props, &testfile, mm),
}
}
@ -194,6 +194,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
if !proc_res.status.success() {
fatal_ProcRes("pretty-printed source does not typecheck".to_owned(), &proc_res);
}
if props.no_pretty_expanded { return }
// additionally, run `--pretty expanded` and try to build it.
let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "expanded");
@ -219,10 +220,17 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
Vec::new(), config.compile_lib_path, Some(src))
}
fn make_pp_args(config: &Config, _testfile: &Path) -> ProcArgs {
let args = vec!("-".to_owned(), "--pretty".to_owned(), "normal".to_owned(),
"--target=".to_owned() + config.target);
fn make_pp_args(config: &Config,
props: &TestProps,
testfile: &Path,
pretty_type: ~str) -> ProcArgs {
let aux_dir = aux_output_dir_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec!("-".to_owned(), "--pretty".to_owned(), pretty_type,
"--target=".to_owned() + config.target,
"-L".to_owned(), aux_dir.as_str().unwrap().to_owned());
args.push_all_move(split_maybe_args(&config.target_rustcflags));
args.push_all_move(split_maybe_args(&props.compile_flags));
return ProcArgs {prog: config.rustc_path.as_str().unwrap().to_owned(), args: args};
}
@ -419,14 +427,14 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
check_debugger_output(&debugger_run_result, check_lines.as_slice());
}
fn run_debuginfo_lldb_test(config: &config, props: &TestProps, testfile: &Path) {
fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path) {
use std::io::process::{Process, ProcessConfig, ProcessOutput};
if config.lldb_python_dir.is_none() {
fatal("Can't run LLDB test because LLDB's python path is not set.".to_owned());
}
let mut config = config {
let mut config = Config {
target_rustcflags: cleanup_debug_info_options(&config.target_rustcflags),
host_rustcflags: cleanup_debug_info_options(&config.host_rustcflags),
.. config.clone()
@ -481,7 +489,7 @@ fn run_debuginfo_lldb_test(config: &config, props: &TestProps, testfile: &Path)
check_debugger_output(&debugger_run_result, check_lines.as_slice());
fn run_lldb(config: &config, test_executable: &Path, debugger_script: &Path) -> ProcRes {
fn run_lldb(config: &Config, test_executable: &Path, debugger_script: &Path) -> ProcRes {
// Prepare the lldb_batchmode which executes the debugger script
let lldb_batchmode_script = "./src/etc/lldb_batchmode.py".to_owned();
let test_executable_str = test_executable.as_str().unwrap().to_owned();

View File

@ -46,6 +46,7 @@ use middle::typeck::astconv::{ast_ty_to_ty, AstConv};
use middle::typeck::infer;
use middle::typeck;
use util::ppaux::{ty_to_str};
use util::nodemap::NodeSet;
use std::cmp;
use collections::HashMap;
@ -453,10 +454,13 @@ struct Context<'a> {
// When recursing into an attributed node of the ast which modifies lint
// levels, this stack keeps track of the previous lint levels of whatever
// was modified.
lint_stack: Vec<(Lint, level, LintSource)> ,
lint_stack: Vec<(Lint, level, LintSource)>,
// id of the last visited negated expression
negated_expr_id: ast::NodeId
negated_expr_id: ast::NodeId,
// ids of structs/enums which have been checked for raw_pointer_deriving
checked_raw_pointers: NodeSet,
}
impl<'a> Context<'a> {
@ -1014,10 +1018,26 @@ impl<'a> Visitor<()> for RawPtrDerivingVisitor<'a> {
fn visit_block(&mut self, _: &ast::Block, _: ()) {}
}
fn check_raw_ptr_deriving(cx: &Context, item: &ast::Item) {
if !attr::contains_name(item.attrs.as_slice(), "deriving") {
fn check_raw_ptr_deriving(cx: &mut Context, item: &ast::Item) {
if !attr::contains_name(item.attrs.as_slice(), "automatically_derived") {
return
}
let did = match item.node {
ast::ItemImpl(..) => {
match ty::get(ty::node_id_to_type(cx.tcx, item.id)).sty {
ty::ty_enum(did, _) => did,
ty::ty_struct(did, _) => did,
_ => return,
}
}
_ => return,
};
if !ast_util::is_local(did) { return }
let item = match cx.tcx.map.find(did.node) {
Some(ast_map::NodeItem(item)) => item,
_ => return,
};
if !cx.checked_raw_pointers.insert(item.id) { return }
match item.node {
ast::ItemStruct(..) | ast::ItemEnum(..) => {
let mut visitor = RawPtrDerivingVisitor { cx: cx };
@ -1848,7 +1868,8 @@ pub fn check_crate(tcx: &ty::ctxt,
cur_struct_def_id: -1,
is_doc_hidden: false,
lint_stack: Vec::new(),
negated_expr_id: -1
negated_expr_id: -1,
checked_raw_pointers: NodeSet::new(),
};
// Install default lint levels, followed by the command line levels, and

View File

@ -26,6 +26,7 @@ use t = syntax::parse::token;
/// Highlights some source code, returning the HTML output.
pub fn highlight(src: &str, class: Option<&str>) -> StrBuf {
debug!("highlighting: ================\n{}\n==============", src);
let sess = parse::new_parse_sess();
let fm = parse::string_to_filemap(&sess,
src.to_strbuf(),

View File

@ -149,6 +149,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
let my_opaque: &MyOpaque = &*((*opaque).opaque as *MyOpaque);
slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
let text = str::from_utf8(text).unwrap();
debug!("docblock: ==============\n{}\n=======", text);
let mut lines = text.lines().filter(|l| {
stripped_filtered_line(*l).is_none()
});

View File

@ -262,7 +262,8 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander)
let it = expand_item_modifiers(it, fld);
let mut decorator_items = SmallVector::zero();
for attr in it.attrs.iter().rev() {
let mut new_attrs = Vec::new();
for attr in it.attrs.iter() {
let mname = attr.name();
match fld.extsbox.find(&intern(mname.get())) {
@ -286,7 +287,7 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander)
fld.cx.bt_pop();
}
_ => {}
_ => new_attrs.push((*attr).clone()),
}
}
@ -294,14 +295,21 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander)
ast::ItemMac(..) => expand_item_mac(it, fld),
ast::ItemMod(_) | ast::ItemForeignMod(_) => {
fld.cx.mod_push(it.ident);
let macro_escape = contains_macro_escape(it.attrs.as_slice());
let macro_escape = contains_macro_escape(new_attrs.as_slice());
let result = with_exts_frame!(fld.extsbox,
macro_escape,
noop_fold_item(it, fld));
fld.cx.mod_pop();
result
},
_ => noop_fold_item(it, fld)
_ => {
let it = @ast::Item {
attrs: new_attrs,
..(*it).clone()
};
noop_fold_item(it, fld)
}
};
new_items.push_all(decorator_items);

View File

@ -2241,9 +2241,6 @@ impl<'a> Parser<'a> {
ExprVec(..) if m == MutImmutable => {
ExprVstore(e, ExprVstoreSlice)
}
ExprLit(lit) if lit_is_str(lit) && m == MutImmutable => {
ExprVstore(e, ExprVstoreSlice)
}
ExprVec(..) if m == MutMutable => {
ExprVstore(e, ExprVstoreMutSlice)
}

View File

@ -168,7 +168,7 @@ pub fn tt_to_str(tt: &ast::TokenTree) -> StrBuf {
}
pub fn tts_to_str(tts: &[ast::TokenTree]) -> StrBuf {
to_str(|s| s.print_tts(&tts))
to_str(|s| s.print_tts(tts))
}
pub fn stmt_to_str(stmt: &ast::Stmt) -> StrBuf {
@ -1258,28 +1258,7 @@ impl<'a> State<'a> {
}
ast::ExprAddrOf(m, expr) => {
try!(word(&mut self.s, "&"));
// `ExprAddrOf(ExprLit("str"))` should be `&&"str"` instead of `&"str"`
// since `&"str"` is `ExprVstore(ExprLit("str"))` which has same meaning to
// `"str"`.
// In many cases adding parentheses (`&("str")`) would help, but it become invalid
// if expr is in `PatLit()`.
let needs_extra_amp = match expr.node {
ast::ExprLit(lit) => {
match lit.node {
ast::LitStr(..) => true,
_ => false,
}
}
ast::ExprVec(..) => true,
_ => false,
};
if needs_extra_amp {
try!(word(&mut self.s, "&"));
}
try!(self.print_mutability(m));
try!(self.print_expr_maybe_paren(expr));
}
ast::ExprLit(lit) => try!(self.print_literal(lit)),

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
@ -10,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty very bad with line comments
extern crate collections;
extern crate rand;
extern crate time;

View File

@ -9,8 +9,8 @@
// except according to those terms.
// ignore-android: FIXME(#10393)
// ignore-pretty very bad with line comments
// ignore-pretty the `let to_child` line gets an extra newline
// multi tasking k-nucleotide
extern crate collections;

View File

@ -9,7 +9,6 @@
// except according to those terms.
// ignore-android see #10393 #13206
// ignore-pretty
extern crate sync;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty very bad with line comments
extern crate sync;
use std::io;

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty very bad with line comments
// ignore-android doesn't terminate?
// ignore-pretty
use std::iter::range_step;
use std::io::{stdin, stdout, File};

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
@ -10,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty very bad with line comments
#![feature(managed_boxes)]
use std::io;

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
@ -17,6 +15,8 @@
//
// The filename is a song reference; google it in quotes.
// ignore-pretty very bad with line comments
use std::comm;
use std::os;
use std::task;

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty -- comments are unfaithfully preserved
#![allow(unused_variable)]
#![allow(dead_assignment)]

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty -- comments are unfaithfully preserved
fn main() {
let mut x: Option<int> = None;
match x {

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty
// aux-build:anon-extern-mod-cross-crate-1.rs
extern crate anonexternmod;

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty #13324
#![allow(dead_code)]
fn foo<T>() {}

View File

@ -8,18 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty - does not converge
// Copyright 2013-2014 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.
extern crate serialize; // {En,De}codable
extern crate rand; // Rand

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty: `--pretty expand` creates unnecessary `unsafe` block
#![feature(macro_rules, managed_boxes)]
#![deny(warnings)]
#![allow(unused_must_use)]
@ -77,6 +75,7 @@ pub fn main() {
t!(format!("{foo} {1} {bar} {0}", 0, 1, foo=2, bar=3), "2 1 3 0");
t!(format!("{} {0}", "a"), "a a");
t!(format!("{foo_bar}", foo_bar=1), "1");
t!(format!("{:d}", 5 + 5), "10");
// Methods should probably work
t!(format!("{0, plural, =1{a#} =2{b#} zero{c#} other{d#}}", 0u), "c0");

View File

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty
// aux-build:foreign_lib.rs
// The purpose of this test is to check that we can

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
@ -10,10 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// no-pretty-expanded
// This file is intended to test only that methods are automatically
// reachable for each numeric type, for each exported impl, with no imports
// necessary. Testing the methods of the impls is done within the source
// file for each numeric type.
pub fn main() {
// ints
// num

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty
static a: int =
(((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((

View File

@ -1,5 +1,3 @@
// ignore-pretty
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.