Skip to content

Commit 1237530

Browse files
committed
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
1 parent ce8c467 commit 1237530

33 files changed

+85
-95
lines changed

src/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use std::io::fs;
2929
use std::from_str::FromStr;
3030
use getopts::{optopt, optflag, reqopt};
3131
use common::Config;
32-
use common::{Pretty, DebugInfo, Codegen};
32+
use common::{Pretty, DebugInfoGdb, Codegen};
3333
use util::logv;
3434

3535
pub mod procsrv;
@@ -199,7 +199,7 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
199199
}
200200

201201
pub fn run_tests(config: &Config) {
202-
if config.target == ~"arm-linux-androideabi" {
202+
if config.target == "arm-linux-androideabi".to_owned() {
203203
match config.mode {
204204
DebugInfoGdb => {
205205
println!("arm-linux-androideabi debug-info \

src/compiletest/header.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub struct TestProps {
3434
pub check_stdout: bool,
3535
// Don't force a --crate-type=dylib flag on the command line
3636
pub no_prefer_dynamic: bool,
37+
// Don't run --pretty expanded when running pretty printing tests
38+
pub no_pretty_expanded: bool,
3739
}
3840

3941
// Load any test directives embedded in the file
@@ -48,6 +50,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
4850
let mut force_host = false;
4951
let mut check_stdout = false;
5052
let mut no_prefer_dynamic = false;
53+
let mut no_pretty_expanded = false;
5154
iter_header(testfile, |ln| {
5255
match parse_error_pattern(ln) {
5356
Some(ep) => error_patterns.push(ep),
@@ -78,6 +81,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
7881
no_prefer_dynamic = parse_no_prefer_dynamic(ln);
7982
}
8083

84+
if !no_pretty_expanded {
85+
no_pretty_expanded = parse_no_pretty_expanded(ln);
86+
}
87+
8188
match parse_aux_build(ln) {
8289
Some(ab) => { aux_builds.push(ab); }
8390
None => {}
@@ -107,6 +114,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
107114
force_host: force_host,
108115
check_stdout: check_stdout,
109116
no_prefer_dynamic: no_prefer_dynamic,
117+
no_pretty_expanded: no_pretty_expanded,
110118
}
111119
}
112120

@@ -180,6 +188,10 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
180188
parse_name_directive(line, "no-prefer-dynamic")
181189
}
182190

191+
fn parse_no_pretty_expanded(line: &str) -> bool {
192+
parse_name_directive(line, "no-pretty-expanded")
193+
}
194+
183195
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
184196
parse_name_value_directive(line, "exec-env".to_owned()).map(|nv| {
185197
// nv is either FOO or FOO=BAR

src/compiletest/runtest.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use common::Config;
12-
use common::{CompileFail, Pretty, RunFail, RunPass};
12+
use common::{CompileFail, Pretty, RunFail, RunPass, DebugInfoGdb, DebugInfoLldb};
1313
use errors;
1414
use header::TestProps;
1515
use header;
@@ -64,7 +64,7 @@ pub fn run_metrics(config: Config, testfile: ~str, mm: &mut MetricMap) {
6464
Pretty => run_pretty_test(&config, &props, &testfile),
6565
DebugInfoGdb => run_debuginfo_gdb_test(&config, &props, &testfile),
6666
DebugInfoLldb => run_debuginfo_lldb_test(&config, &props, &testfile),
67-
Codegen => run_codegen_test(&config, &props, &testfile, mm)
67+
Codegen => run_codegen_test(&config, &props, &testfile, mm),
6868
}
6969
}
7070

@@ -194,6 +194,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
194194
if !proc_res.status.success() {
195195
fatal_ProcRes("pretty-printed source does not typecheck".to_owned(), &proc_res);
196196
}
197+
if props.no_pretty_expanded { return }
197198

198199
// additionally, run `--pretty expanded` and try to build it.
199200
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) {
219220
Vec::new(), config.compile_lib_path, Some(src))
220221
}
221222

222-
fn make_pp_args(config: &Config, _testfile: &Path) -> ProcArgs {
223-
let args = vec!("-".to_owned(), "--pretty".to_owned(), "normal".to_owned(),
224-
"--target=".to_owned() + config.target);
223+
fn make_pp_args(config: &Config,
224+
props: &TestProps,
225+
testfile: &Path,
226+
pretty_type: ~str) -> ProcArgs {
227+
let aux_dir = aux_output_dir_name(config, testfile);
225228
// FIXME (#9639): This needs to handle non-utf8 paths
229+
let mut args = vec!("-".to_owned(), "--pretty".to_owned(), pretty_type,
230+
"--target=".to_owned() + config.target,
231+
"-L".to_owned(), aux_dir.as_str().unwrap().to_owned());
232+
args.push_all_move(split_maybe_args(&config.target_rustcflags));
233+
args.push_all_move(split_maybe_args(&props.compile_flags));
226234
return ProcArgs {prog: config.rustc_path.as_str().unwrap().to_owned(), args: args};
227235
}
228236

@@ -419,14 +427,14 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
419427
check_debugger_output(&debugger_run_result, check_lines.as_slice());
420428
}
421429

422-
fn run_debuginfo_lldb_test(config: &config, props: &TestProps, testfile: &Path) {
430+
fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path) {
423431
use std::io::process::{Process, ProcessConfig, ProcessOutput};
424432

425433
if config.lldb_python_dir.is_none() {
426434
fatal("Can't run LLDB test because LLDB's python path is not set.".to_owned());
427435
}
428436

429-
let mut config = config {
437+
let mut config = Config {
430438
target_rustcflags: cleanup_debug_info_options(&config.target_rustcflags),
431439
host_rustcflags: cleanup_debug_info_options(&config.host_rustcflags),
432440
.. config.clone()
@@ -481,7 +489,7 @@ fn run_debuginfo_lldb_test(config: &config, props: &TestProps, testfile: &Path)
481489

482490
check_debugger_output(&debugger_run_result, check_lines.as_slice());
483491

484-
fn run_lldb(config: &config, test_executable: &Path, debugger_script: &Path) -> ProcRes {
492+
fn run_lldb(config: &Config, test_executable: &Path, debugger_script: &Path) -> ProcRes {
485493
// Prepare the lldb_batchmode which executes the debugger script
486494
let lldb_batchmode_script = "./src/etc/lldb_batchmode.py".to_owned();
487495
let test_executable_str = test_executable.as_str().unwrap().to_owned();

src/librustc/middle/lint.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ use middle::typeck::astconv::{ast_ty_to_ty, AstConv};
4646
use middle::typeck::infer;
4747
use middle::typeck;
4848
use util::ppaux::{ty_to_str};
49+
use util::nodemap::NodeSet;
4950

5051
use std::cmp;
5152
use collections::HashMap;
@@ -453,10 +454,13 @@ struct Context<'a> {
453454
// When recursing into an attributed node of the ast which modifies lint
454455
// levels, this stack keeps track of the previous lint levels of whatever
455456
// was modified.
456-
lint_stack: Vec<(Lint, level, LintSource)> ,
457+
lint_stack: Vec<(Lint, level, LintSource)>,
457458

458459
// id of the last visited negated expression
459-
negated_expr_id: ast::NodeId
460+
negated_expr_id: ast::NodeId,
461+
462+
// ids of structs/enums which have been checked for raw_pointer_deriving
463+
checked_raw_pointers: NodeSet,
460464
}
461465

462466
impl<'a> Context<'a> {
@@ -1014,10 +1018,26 @@ impl<'a> Visitor<()> for RawPtrDerivingVisitor<'a> {
10141018
fn visit_block(&mut self, _: &ast::Block, _: ()) {}
10151019
}
10161020

1017-
fn check_raw_ptr_deriving(cx: &Context, item: &ast::Item) {
1018-
if !attr::contains_name(item.attrs.as_slice(), "deriving") {
1021+
fn check_raw_ptr_deriving(cx: &mut Context, item: &ast::Item) {
1022+
if !attr::contains_name(item.attrs.as_slice(), "automatically_derived") {
10191023
return
10201024
}
1025+
let did = match item.node {
1026+
ast::ItemImpl(..) => {
1027+
match ty::get(ty::node_id_to_type(cx.tcx, item.id)).sty {
1028+
ty::ty_enum(did, _) => did,
1029+
ty::ty_struct(did, _) => did,
1030+
_ => return,
1031+
}
1032+
}
1033+
_ => return,
1034+
};
1035+
if !ast_util::is_local(did) { return }
1036+
let item = match cx.tcx.map.find(did.node) {
1037+
Some(ast_map::NodeItem(item)) => item,
1038+
_ => return,
1039+
};
1040+
if !cx.checked_raw_pointers.insert(item.id) { return }
10211041
match item.node {
10221042
ast::ItemStruct(..) | ast::ItemEnum(..) => {
10231043
let mut visitor = RawPtrDerivingVisitor { cx: cx };
@@ -1848,7 +1868,8 @@ pub fn check_crate(tcx: &ty::ctxt,
18481868
cur_struct_def_id: -1,
18491869
is_doc_hidden: false,
18501870
lint_stack: Vec::new(),
1851-
negated_expr_id: -1
1871+
negated_expr_id: -1,
1872+
checked_raw_pointers: NodeSet::new(),
18521873
};
18531874

18541875
// Install default lint levels, followed by the command line levels, and

src/librustdoc/html/highlight.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use t = syntax::parse::token;
2626

2727
/// Highlights some source code, returning the HTML output.
2828
pub fn highlight(src: &str, class: Option<&str>) -> StrBuf {
29+
debug!("highlighting: ================\n{}\n==============", src);
2930
let sess = parse::new_parse_sess();
3031
let fm = parse::string_to_filemap(&sess,
3132
src.to_strbuf(),

src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
149149
let my_opaque: &MyOpaque = &*((*opaque).opaque as *MyOpaque);
150150
slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
151151
let text = str::from_utf8(text).unwrap();
152+
debug!("docblock: ==============\n{}\n=======", text);
152153
let mut lines = text.lines().filter(|l| {
153154
stripped_filtered_line(*l).is_none()
154155
});

src/libsyntax/ext/expand.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander)
262262
let it = expand_item_modifiers(it, fld);
263263

264264
let mut decorator_items = SmallVector::zero();
265-
for attr in it.attrs.iter().rev() {
265+
let mut new_attrs = Vec::new();
266+
for attr in it.attrs.iter() {
266267
let mname = attr.name();
267268

268269
match fld.extsbox.find(&intern(mname.get())) {
@@ -286,22 +287,29 @@ pub fn expand_item(it: @ast::Item, fld: &mut MacroExpander)
286287

287288
fld.cx.bt_pop();
288289
}
289-
_ => {}
290+
_ => new_attrs.push((*attr).clone()),
290291
}
291292
}
292293

293294
let mut new_items = match it.node {
294295
ast::ItemMac(..) => expand_item_mac(it, fld),
295296
ast::ItemMod(_) | ast::ItemForeignMod(_) => {
296297
fld.cx.mod_push(it.ident);
297-
let macro_escape = contains_macro_escape(it.attrs.as_slice());
298+
let macro_escape = contains_macro_escape(new_attrs.as_slice());
298299
let result = with_exts_frame!(fld.extsbox,
299300
macro_escape,
300301
noop_fold_item(it, fld));
301302
fld.cx.mod_pop();
302303
result
303304
},
304-
_ => noop_fold_item(it, fld)
305+
_ => {
306+
let it = @ast::Item {
307+
attrs: new_attrs,
308+
..(*it).clone()
309+
310+
};
311+
noop_fold_item(it, fld)
312+
}
305313
};
306314

307315
new_items.push_all(decorator_items);

src/libsyntax/parse/parser.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,9 +2241,6 @@ impl<'a> Parser<'a> {
22412241
ExprVec(..) if m == MutImmutable => {
22422242
ExprVstore(e, ExprVstoreSlice)
22432243
}
2244-
ExprLit(lit) if lit_is_str(lit) && m == MutImmutable => {
2245-
ExprVstore(e, ExprVstoreSlice)
2246-
}
22472244
ExprVec(..) if m == MutMutable => {
22482245
ExprVstore(e, ExprVstoreMutSlice)
22492246
}

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub fn tt_to_str(tt: &ast::TokenTree) -> StrBuf {
168168
}
169169

170170
pub fn tts_to_str(tts: &[ast::TokenTree]) -> StrBuf {
171-
to_str(|s| s.print_tts(&tts))
171+
to_str(|s| s.print_tts(tts))
172172
}
173173

174174
pub fn stmt_to_str(stmt: &ast::Stmt) -> StrBuf {
@@ -1258,28 +1258,7 @@ impl<'a> State<'a> {
12581258
}
12591259
ast::ExprAddrOf(m, expr) => {
12601260
try!(word(&mut self.s, "&"));
1261-
1262-
// `ExprAddrOf(ExprLit("str"))` should be `&&"str"` instead of `&"str"`
1263-
// since `&"str"` is `ExprVstore(ExprLit("str"))` which has same meaning to
1264-
// `"str"`.
1265-
// In many cases adding parentheses (`&("str")`) would help, but it become invalid
1266-
// if expr is in `PatLit()`.
1267-
let needs_extra_amp = match expr.node {
1268-
ast::ExprLit(lit) => {
1269-
match lit.node {
1270-
ast::LitStr(..) => true,
1271-
_ => false,
1272-
}
1273-
}
1274-
ast::ExprVec(..) => true,
1275-
_ => false,
1276-
};
1277-
if needs_extra_amp {
1278-
try!(word(&mut self.s, "&"));
1279-
}
1280-
12811261
try!(self.print_mutability(m));
1282-
12831262
try!(self.print_expr_maybe_paren(expr));
12841263
}
12851264
ast::ExprLit(lit) => try!(self.print_literal(lit)),

src/test/bench/core-set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-pretty
2-
31
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
42
// file at the top-level directory of this distribution and at
53
// http://rust-lang.org/COPYRIGHT.
@@ -10,6 +8,8 @@
108
// option. This file may not be copied, modified, or distributed
119
// except according to those terms.
1210

11+
// ignore-pretty very bad with line comments
12+
1313
extern crate collections;
1414
extern crate rand;
1515
extern crate time;

src/test/bench/shootout-k-nucleotide-pipes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
// ignore-android: FIXME(#10393)
12+
// ignore-pretty very bad with line comments
1213

13-
// ignore-pretty the `let to_child` line gets an extra newline
1414
// multi tasking k-nucleotide
1515

1616
extern crate collections;

src/test/bench/shootout-k-nucleotide.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
// ignore-android see #10393 #13206
12-
// ignore-pretty
1312

1413
extern crate sync;
1514

src/test/bench/shootout-mandelbrot.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-pretty very bad with line comments
12+
1113
extern crate sync;
1214

1315
use std::io;

src/test/bench/shootout-reverse-complement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-pretty very bad with line comments
1112
// ignore-android doesn't terminate?
12-
// ignore-pretty
1313

1414
use std::iter::range_step;
1515
use std::io::{stdin, stdout, File};

src/test/bench/sudoku.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-pretty
2-
31
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
42
// file at the top-level directory of this distribution and at
53
// http://rust-lang.org/COPYRIGHT.
@@ -10,6 +8,8 @@
108
// option. This file may not be copied, modified, or distributed
119
// except according to those terms.
1210

11+
// ignore-pretty very bad with line comments
12+
1313
#![feature(managed_boxes)]
1414

1515
use std::io;

src/test/bench/task-perf-jargon-metal-smoke.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-pretty
2-
31
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
42
// file at the top-level directory of this distribution and at
53
// http://rust-lang.org/COPYRIGHT.
@@ -17,6 +15,8 @@
1715
//
1816
// The filename is a song reference; google it in quotes.
1917

18+
// ignore-pretty very bad with line comments
19+
2020
use std::comm;
2121
use std::os;
2222
use std::task;

src/test/compile-fail/borrowck-lend-flow-match.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-pretty -- comments are unfaithfully preserved
12-
1311
#![allow(unused_variable)]
1412
#![allow(dead_assignment)]
1513

0 commit comments

Comments
 (0)