Skip to content

Mismatched type error: type of crate instead of std is displayed #46112

Closed
@SWW13

Description

@SWW13

On nightly rustc (cargo) I get misleading expected type errors. If a crate has the same(?) type it is displayed instead of the std type.

I tried this code:

extern crate bitflags;
fn test(r: Result<Option<()>, &'static str>) { }
fn main() { test(Ok(())); }

I expected to see this happen: (stable rust)

$ rustup default stable
$ cargo build
   Compiling rust-sample v0.1.0 (file:///[...]/rust-sample)
error[E0308]: mismatched types
 --> src/main.rs:3:21
  |
3 | fn main() { test(Ok(())); }
  |                     ^^
  |                     |
  |                     expected enum `std::option::Option`, found ()
  |                     help: try using a variant of the expected type: `Some(())`
  |
  = note: expected type `std::option::Option<()>`
             found type `()`

Instead, this happened: (nightly)

$ rustup default nightly
$ cargo build
   Compiling rust-sample v0.1.0 (file:///[...]/rust-sample)
error[E0308]: mismatched types
 --> src/main.rs:3:21
  |
3 | fn main() { test(Ok(())); }
  |                     ^^
  |                     |
  |                     expected enum `bitflags::<unnamed>::option::Option`, found ()
  |                     help: try using a variant of the expected type: `bitflags::<unnamed>::prelude::v1::Some(())`
  |
  = note: expected type `bitflags::<unnamed>::option::Option<()>`
             found type `()`

Meta

rustc --version --verbose:

rustc 1.23.0-nightly (5041b3bb3 2017-11-19)
binary: rustc
commit-hash: 5041b3bb3d953a14f32b15d1e41341c629acae12
commit-date: 2017-11-19
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0

Activity

arielb1

arielb1 commented on Nov 20, 2017

@arielb1
Contributor

Confirming - broken on nightly (1.23), good on beta.

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Nov 20, 2017
added and removed on Nov 30, 2017
pnkfelix

pnkfelix commented on Dec 1, 2017

@pnkfelix
Member

bisected across nightlys: bug was injected between rustc 1.23.0-nightly (02004ef78 2017-11-08) and rustc 1.23.0-nightly (d6b06c63a 2017-11-09)

pnkfelix

pnkfelix commented on Dec 1, 2017

@pnkfelix
Member

Skimming output from git log 02004ef78^..d6b06c63a, there are a number of different potential culprits. Rather than guess and "point fingers" right now, I'll just continue bisecting within that commit range.

Mark-Simulacrum

Mark-Simulacrum commented on Dec 1, 2017

@Mark-Simulacrum
Member

This is recent enough that we should be able to run bisect-rust on it (cc @est31).

est31

est31 commented on Dec 1, 2017

@est31
Member
Searching in 7 commits; about 3 steps
Checking
  |                        expected enum `std::option::Option`, found ()
INFO:bisect: tested fd9ecfdfd from Thu,  9 Nov 2017 04:14:28 +0000: test failed: true
Checking
  |                        expected enum `std::option::Option`, found ()
INFO:bisect: tested da3fbe750 from Wed,  8 Nov 2017 22:27:06 +0000: test failed: true
Checking
  |                        expected enum `std::option::Option`, found ()
INFO:bisect: tested 02004ef78 from Wed,  8 Nov 2017 20:00:41 +0000: test failed: true
searched commits 02004ef78383cb174a41df7735a552823fa10b90 through d6b06c63a0c735fc15c9c704422375c17b7c7e12
regression in 0; Some(Commit { sha: "02004ef78383cb174a41df7735a552823fa10b90", date: 2017-11-08T20:00:41Z, summary: "Auto merge of #45452 - estebank:colon-typo, r=nikomatsakis" })

#45452 it is cc @estebank @nikomatsakis .

estebank

estebank commented on Dec 1, 2017

@estebank
Contributor

I'm a little surprised that this would be caused by that PR. I can push a revert but would like to first test locally to make sure that revert that PR will fix this.

est31

est31 commented on Dec 1, 2017

@est31
Member

I have misread @pnkfelix 's statement. Your PR is not at fault, sorry. I'm doing another search further back to find the causing PR.

estebank

estebank commented on Dec 1, 2017

@estebank
Contributor

@est31 I tried it locally in the meantime and I can confirm it is not :)

est31

est31 commented on Dec 1, 2017

@est31
Member

Okay so the bug dates as far back as efceda2 from September 2nd which is as close to the limit as I dare to go. So to the people in control, please, prolong the limit :).

37 remaining items

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @nikomatsakis@pnkfelix@TimNN@SWW13@ExpHP

    Issue actions

      Mismatched type error: type of crate instead of std is displayed · Issue #46112 · rust-lang/rust