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

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

Closed
brson opened this issue Feb 14, 2017 · 12 comments
Closed

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

brson opened this issue Feb 14, 2017 · 12 comments
Assignees
Labels
A-type-system Area: Type system P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@brson
Copy link
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

@brson brson added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Feb 14, 2017
@nagisa
Copy link
Member

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
Copy link
Contributor

durka commented Feb 14, 2017

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

@nagisa
Copy link
Member

nagisa commented Feb 14, 2017

Oh well, then whatever other new impl for Cow?

@durka
Copy link
Contributor

durka commented Feb 14, 2017

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

@durka
Copy link
Contributor

durka commented Feb 14, 2017

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
Copy link
Contributor

durka commented Feb 14, 2017

Minimized:

use std::borrow::Cow;

fn main() {
    let _ = if false {
        Cow::Owned(format!("{:?}", panic!())) /* as Cow<str> */ // uncomment to fix
    } else {
        Cow::Borrowed("")
    };
}

@nagisa
Copy link
Member

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.

@brson brson added I-nominated T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Mar 2, 2017
@nikomatsakis
Copy link
Contributor

This is because of #39485, where we updated our handling of diverging types to be more consistent.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Mar 2, 2017

Oh, well, it says stable-to-stable, so I guess not. But yes, related to the handling of diverging types.

@nikomatsakis
Copy link
Contributor

cc @eddyb @canndrew

@nikomatsakis
Copy link
Contributor

Even smaller example:

fn main() {
    let _ = if false {
        Ok(panic!())
    } else {
        Err("")
    };
}

@nikomatsakis
Copy link
Contributor

triage: P-high

along with #39984

@rust-highfive rust-highfive added P-high High priority and removed I-nominated labels Mar 2, 2017
@nikomatsakis nikomatsakis self-assigned this Mar 2, 2017
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 7, 2017
The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes rust-lang#39808.
@brson brson added the A-type-system Area: Type system label Mar 9, 2017
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 10, 2017
The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes rust-lang#39808.
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 18, 2017
The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes rust-lang#39808.
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 18, 2017
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 25, 2017
The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes rust-lang#39808.
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 25, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 29, 2017
change the strategy for diverging types

The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes rust-lang#39808.
Fixes rust-lang#39984.
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 30, 2017
The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes rust-lang#39808.
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 30, 2017
bors added a commit that referenced this issue Mar 30, 2017
change the strategy for diverging types

The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes #39808.
Fixes #39984.
michaelwoerister pushed a commit to michaelwoerister/rust that referenced this issue Apr 7, 2017
The new strategy is as follows. First, the `!` type is assigned
in two cases:

- a block with a diverging statement and no tail expression (e.g.,
  `{return;}`);
- any expression with the type `!` is considered diverging.

Second, we track when we are in a diverging state, and we permit a value
of any type to be coerced **into** `!` if the expression that produced
it is diverging. This means that `fn foo() -> ! { panic!(); 22 }`
type-checks, even though the block has a type of `usize`.

Finally, coercions **from** the `!` type to any other are always
permitted.

Fixes rust-lang#39808.
michaelwoerister pushed a commit to michaelwoerister/rust that referenced this issue Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants