Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pretty printer is injecting extra newlines/spaces in funky ways in some run-fail tests #23623

Closed
pnkfelix opened this issue Mar 22, 2015 · 1 comment · Fixed by #37202
Closed
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`)

Comments

@pnkfelix
Copy link
Member

From end of the following build log:

http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/4172/steps/test/logs/stdio

From narrowing the test down a little, it seems to be due to those tests mixing comments at the end of a statement with further multi-line comments further down.

In particular, here is my attempt to produce a more minimal test case:

Input:

// bogus.rs
fn main() {
    let x = 1; // hi

    // first
    // second
    assert_eq!(x, 2_i8);
}

Transcript of a run:

% DYLD_LIBRARY_PATH=$(pwd)/x86_64-apple-darwin/stage2/lib:$DYLD_LIBRARY_PATH x86_64-apple-darwin/stage2/bin/compiletest --compile-lib-path x86_64-apple-darwin/stage2/lib --run-lib-path x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib --rustc-path x86_64-apple-darwin/stage2/bin/rustc --clang-path "/Users/fklock/bin/clang++" --llvm-bin-path $(pwd)/x86_64-apple-darwin/llvm/Release+Asserts/bin --aux-base $(pwd)/../src/test/auxiliary/ --stage-id stage2-x86_64-apple-darwin --target x86_64-apple-darwin --host x86_64-apple-darwin --gdb-version="Not there; switching to /usr/bin/gdb" --lldb-version="lldb-320.4.160" --android-cross-path="" --adb-path="/Users/fklock/bin/adb" --adb-test-dir= --host-rustcflags "   --cfg rtopt --cfg debug  -O -L x86_64-apple-darwin/rt" --lldb-python-dir="" --target-rustcflags "   --cfg rtopt --cfg debug  -O -L x86_64-apple-darwin/rt" bogus --src-base $(pwd)/../src/test/run-fail/ --build-base x86_64-apple-darwin/test/run-fail/ --mode pretty
Could not extract GDB version from line 'Not there; switching to /usr/bin/gdb'

running 1 test
test [pretty] run-fail/bogus.rs ... FAILED

failures:

---- [pretty] run-fail/bogus.rs stdout ----

error: pretty-printed source does not match expected source

expected:
------------------------------------------
// bogus.rs
fn main() {
    let x = 1; // hi

     // first
     // second

    assert_eq!(x , 2_i8);
}

------------------------------------------
actual:
------------------------------------------
// bogus.rs
fn main() {
    let x = 1; // hi

     // first
     // second


    assert_eq!(x , 2_i8);
}

------------------------------------------


thread '[pretty] run-fail/bogus.rs' panicked at 'explicit panic', /Users/fklock/Dev/Mozilla/rust-oflo/src/compiletest/runtest.rs:318



failures:
    [pretty] run-fail/bogus.rs

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured

thread '<main>' panicked at 'Some tests failed', /Users/fklock/Dev/Mozilla/rust-oflo/src/compiletest/compiletest.rs:256
@pnkfelix pnkfelix added the A-pretty Area: Pretty printing (including `-Z unpretty`) label Mar 22, 2015
@dotdash
Copy link
Contributor

dotdash commented Oct 7, 2015

I hit the same problem in a slightly different setup in #28873:

running 1 test
test [pretty] run-pass/issue-28839.rs ... FAILED

failures:

---- [pretty] run-pass/issue-28839.rs stdout ----

error: pretty-printed source does not match expected source

expected:
------------------------------------------
// 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.

pub struct Foo;

pub fn get_foo2<'a>(foo: &'a mut Option<&'a mut Foo>) -> &'a mut Foo {
    match foo {

        // Ensure that this is not considered a move, but rather a reborrow.
        &mut Some(ref mut x) => *x,
        &mut None => panic!(),
    }
}

fn main() { }

------------------------------------------
actual:
------------------------------------------
// 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.

pub struct Foo;

pub fn get_foo2<'a>(foo: &'a mut Option<&'a mut Foo>) -> &'a mut Foo {
    match foo {


        // Ensure that this is not considered a move, but rather a reborrow.
        &mut Some(ref mut x) => *x,
        &mut None => panic!(),
    }
}

fn main() { }

------------------------------------------


thread '[pretty] run-pass/issue-28839.rs' panicked at 'explicit panic', /home/bs/src/rust/src/compiletest/runtest.rs:298

The original source for the test had no newlines before the comment in the match, but every round of pretty printing adds one.

eddyb added a commit to eddyb/rust that referenced this issue Oct 19, 2016
Fix some pretty printing tests

Many pretty-printing tests are un-ignored.
Some issues in classification of comments (trailing/isolated) and blank line counting are fixed.
Some comments are printed more carefully.
Some minor refactoring in pprust.rs
`no-pretty-expanded` annotations are removed because this is the default now.
`pretty-expanded` annotations are removed from compile-fail tests, they are not tested with pretty-printer.

Closes rust-lang#23623 in favor of more specific rust-lang#37201 and rust-lang#37199
r? @nrc
eddyb added a commit to eddyb/rust that referenced this issue Oct 19, 2016
Fix some pretty printing tests

Many pretty-printing tests are un-ignored.
Some issues in classification of comments (trailing/isolated) and blank line counting are fixed.
Some comments are printed more carefully.
Some minor refactoring in pprust.rs
`no-pretty-expanded` annotations are removed because this is the default now.
`pretty-expanded` annotations are removed from compile-fail tests, they are not tested with pretty-printer.

Closes rust-lang#23623 in favor of more specific rust-lang#37201 and rust-lang#37199
r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants