Skip to content

Auto (de)ref not always handled correctly (type-mismatch false positive) #11948

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

Closed
RalfJung opened this issue Apr 9, 2022 · 3 comments
Closed
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@RalfJung
Copy link
Member

RalfJung commented Apr 9, 2022

When opening the Miri source code at revision c568f32f, and opening src/diagnostics.rs in vscode, an error is reported in this line: "expected &String, found String".

[{
	"resource": "/home/r/src/rust/miri/src/diagnostics.rs",
	"owner": "rustc",
	"code": {
		"value": "type-mismatch",
		"target": {
			"$mid": 1,
			"external": "https://rust-analyzer.github.io/manual.html#type-mismatch",
			"path": "/manual.html",
			"scheme": "https",
			"authority": "rust-analyzer.github.io",
			"fragment": "type-mismatch"
		}
	},
	"severity": 8,
	"message": "expected &String, found String",
	"source": "rust-analyzer",
	"startLineNumber": 219,
	"startColumn": 19,
	"endLineNumber": 219,
	"endColumn": 32
}]

I also saw a similar error in a file somewhere in the rustc repository but forgot where...

rust-analyzer version: rust-analyzer version: 46d7ee6 2022-04-04 stable

rustc version: rustc 1.62.0-nightly (fbdb10f9f 2022-04-09)

relevant settings: N/A

@Veykril Veykril added A-ty type system / type inference / traits / method resolution C-bug Category: bug labels Apr 9, 2022
@RalfJung
Copy link
Member Author

RalfJung commented Apr 9, 2022

Ah, here's the one in the rustc repo, revision fbdb10f9fabe47eb763cb4b52b5721740cc63783, in this line.

[{
	"resource": "/home/r/src/rust/rustc/compiler/rustc_middle/src/mir/interpret/allocation.rs",
	"owner": "rustc",
	"code": {
		"value": "type-mismatch",
		"target": {
			"$mid": 1,
			"external": "https://rust-analyzer.github.io/manual.html#type-mismatch",
			"path": "/manual.html",
			"scheme": "https",
			"authority": "rust-analyzer.github.io",
			"fragment": "type-mismatch"
		}
	},
	"severity": 8,
	"message": "expected &Allocation<Tag, Extra>, found Interned<Allocation<Tag, Extra>>",
	"source": "rust-analyzer",
	"startLineNumber": 76,
	"startColumn": 9,
	"endLineNumber": 76,
	"endColumn": 17
}]

@iDawer
Copy link
Contributor

iDawer commented Apr 28, 2022

Minimized from miri:

fn main() {
    let x: &Option<()> = &Some(());
    let _: Option<()> = x.clone();
} //                    ^^^^^^^^^

rust-analyzer 46d7ee6 2022-04-04 stable + rustc 1.62.0-nightly (69a5d2481 2022-04-27): expected Option<()>, found &Option<()>.
rust-analyzer 241b9f9 2022-04-28 nightly + rustc 1.62.0-nightly (69a5d2481 2022-04-27): good. Seems fixed?

Ah, here's the one in the rustc repo, revision fbdb10f9fabe47eb763cb4b52b5721740cc63783, in this line.

This one is #1109 or #10560

@flodiebold
Copy link
Member

The first one was #11936.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants