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;
}
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 \
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
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),
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 => {}
force_host: force_host,
check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic,
+ no_pretty_expanded: no_pretty_expanded,
}
}
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
// 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;
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),
}
}
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");
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};
}
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()
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();
use middle::typeck::infer;
use middle::typeck;
use util::ppaux::{ty_to_str};
+use util::nodemap::NodeSet;
use std::cmp;
use collections::HashMap;
// 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> {
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 };
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
/// 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(),
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()
});
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())) {
fld.cx.bt_pop();
}
- _ => {}
+ _ => new_attrs.push((*attr).clone()),
}
}
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);
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)
}
}
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 {
}
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)),
-// 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.
// 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;
// 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;
// except according to those terms.
// ignore-android see #10393 #13206
-// ignore-pretty
extern crate sync;
// 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;
// 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};
-// 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.
// 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;
-// 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.
//
// 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;
// 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)]
// 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 {
-// 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.
-// 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.
-// 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.
-// 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.
// 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;
-// 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.
-// 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.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-pretty #13324
-
#![allow(dead_code)]
fn foo<T>() {}
// 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
// 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)]
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");
// 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
-// 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.
// 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
-// 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.
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-pretty
-
static a: int =
(((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((
-// 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.