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

Mismatched type for cyclic dev-dependency on same crate #79381

Open
lausek opened this issue Nov 24, 2020 · 2 comments
Open

Mismatched type for cyclic dev-dependency on same crate #79381

lausek opened this issue Nov 24, 2020 · 2 comments
Labels
A-resolve Area: Name resolution C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lausek
Copy link

lausek commented Nov 24, 2020

Repository @kaichaosun

See above link for minimal viable example. There are two crates, one is test-utils, another is client. This is the client code with a dev-dependency on test-utils:

#[derive(Eq, PartialEq, Debug)]
pub struct Name {
	pub first_name: String,
	pub last_name: String,
}

pub fn full_name(first: String, last: String) -> Name {
	Name {
		first_name: first,
		last_name: last,
	}
}

mod test {
	use super::*;

	#[test]
	fn full_name_works() {
		assert_eq!(
			full_name(String::from("hello"), String::from("world")), 
			test_utils::helper()
		)
	}
}

This is test-utils code with a dependency on client:

use client::Name;

pub fn helper() -> Name {
	Name {
		first_name: String::from("hello"),
		last_name: String::from("world"),
	}
}

Running cargo test (cargo test +stable) in the workspace shows this error:

error[E0308]: mismatched types
  --> client/src/lib.rs:19:3
   |
19 |           assert_eq!(
   |  _________^
20 | |             full_name(String::from("hello"), String::from("world")),
21 | |             test_utils::helper()
22 | |         )
   | |_________^ expected struct `Name`, found struct `client::Name`

I expect this code to correctly determine that the types are compatible, because they effectively reference the same crate.

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (5404efc28 2020-11-11)
binary: rustc
commit-hash: 5404efc28a0cddee103ef6396c48ea71ff9631c8
commit-date: 2020-11-11
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Other Issue: #59305
Discussion on Rust forum: https://users.rust-lang.org/t/cyclic-dev-dependency-get-type-mismatch-error/48391/1

@lausek lausek added the C-bug Category: This is a bug. label Nov 24, 2020
@lausek lausek changed the title Mismatched type for dev-dependency on same crate Mismatched type for cyclic dev-dependency on same crate Nov 24, 2020
@camelid camelid added the A-resolve Area: Name resolution label Nov 25, 2020
@camelid
Copy link
Member

camelid commented Nov 25, 2020

Do you know if this is a regression; i.e., if it used to work?

@lausek
Copy link
Author

lausek commented Nov 25, 2020

Do you know if this is a regression; i.e., if it used to work?

No, I'm not aware of this code being able to function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name resolution C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants