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

Comments

Projects
None yet
5 participants
@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

@nagisa

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

durka commented Feb 14, 2017

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

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Feb 14, 2017

Oh well, then whatever other new impl for Cow?

@durka

This comment has been minimized.

Copy link
Contributor

durka commented Feb 14, 2017

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

@durka

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 2, 2017

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

@nikomatsakis

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 2, 2017

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 2, 2017

Even smaller example:

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

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 2, 2017

triage: P-high

along with #39984

@rust-highfive rust-highfive added P-high 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 3, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 3, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 7, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 7, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 9, 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.

@brson brson added the A-typesystem label Mar 9, 2017

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 10, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 10, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 18, 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.

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 21, 2017

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 22, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 22, 2017

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 22, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 22, 2017

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 24, 2017

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 24, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 24, 2017

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 24, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 24, 2017

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 25, 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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 25, 2017

bors added a commit that referenced this issue Mar 26, 2017

Auto merge of #40224 - nikomatsakis:issue-39808, r=eddyb
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.

bors added a commit that referenced this issue Mar 27, 2017

Auto merge of #40224 - nikomatsakis:issue-39808, r=eddyb
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.

bors added a commit that referenced this issue Mar 27, 2017

Auto merge of #40224 - nikomatsakis:issue-39808, r=eddyb
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.

frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 29, 2017

Rollup merge of rust-lang#40224 - nikomatsakis:issue-39808, r=eddyb
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

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.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 30, 2017

nikomatsakis added a commit to nikomatsakis/rust 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 rust-lang#39808.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 30, 2017

nikomatsakis added a commit to nikomatsakis/rust 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 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

Auto merge of #40224 - nikomatsakis:issue-39808, r=eddyb
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.

@bors bors closed this in #40224 Mar 30, 2017

michaelwoerister added a commit to michaelwoerister/rust that referenced this issue Apr 7, 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.

michaelwoerister added 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
You can’t perform that action at this time.