mac-0.1.0 fails test suite due to type inference regression in Rust 1.15 #39808

Open
brson opened this Issue Feb 14, 2017 · 7 comments

Projects

None yet

3 participants

@brson
Contributor
brson commented Feb 14, 2017
   Doc-tests mac

running 12 tests
test format_if_0 ... FAILED
test do_while_1 ... ok
test addrs_of_0 ... ok
test do_while_0 ... ok
test inspect_1 ... ignored
test if_cfg_0 ... ok
test if_cfg_1 ... ok
test match_cfg_0 ... ok
test inspect_0 ... ok
test matches_0 ... ok
test unwrap_or_return_0 ... ok
test test_eq_0 ... ok

failures:

---- format_if_0 stdout ----
        error[E0283]: type annotations required: cannot resolve `_: std::borrow::ToOwned`
  --> <anon>:11:21
   |
11 |   let not_formatted = format_if!(false, "Vague error", "Error code {:?}", {
   |  _____________________^ starting here...
12 | |     // Note that the argument is not evaluated.
13 | |     panic!("oops");
14 | | });
   | |__^ ...ending here
   |
   = note: required by `std::borrow::Cow::Owned`
   = note: this error originates in a macro outside of the current crate

error: aborting due to previous error(s)

thread 'format_if_0' panicked at 'Box<Any>', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/session/mod.rs:201
note: Run with `RUST_BACKTRACE=1` for a backtrace.
https://github.com/reem/rust-mac dcc9155e9d23a81e92e325899d4b6bed098bcded

failures:
    format_if_0

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

error: test failed

This is on 1.15. Not 1.14.

cc @reem

@nagisa
Contributor
nagisa commented Feb 14, 2017

Likely #39440? This is not considered a breakage.

Actionable items: send PR to the crate or inform the author of the issue.

@durka
Contributor
durka commented Feb 14, 2017

Merged 10 days ago and it's in stable already?

@nagisa
Contributor
nagisa commented Feb 14, 2017

Oh well, then whatever other new impl for Cow?

@durka
Contributor
durka commented Feb 14, 2017

Yeah. Why wasn't this caught during the beta period though?

@durka
Contributor
durka commented Feb 14, 2017 edited

It's actually because of the never-type stuff. The type error is complaining about a block that says { panic!(); }. Annotating the type as Cow<str> fixes it.

@durka
Contributor
durka commented Feb 14, 2017 edited

Minimized:

use std::borrow::Cow;

fn main() {
    let _ = if false {
        Cow::Owned(format!("{:?}", panic!())) /* as Cow<str> */ // uncomment to fix
    } else {
        Cow::Borrowed("")
    };
}
@durka durka referenced this issue in reem/rust-mac Feb 14, 2017
Merged

fix format_if for rustc 1.15 #13

@nagisa
Contributor
nagisa commented Feb 15, 2017

Oh wow, this sounds nasty. Especially since typeck shouldn’t even bother figuring out the type of the branch with panic!() in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment