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

Error reported over different Send and Sync ordering #12739

Closed
coreyja opened this issue Jul 10, 2022 · 2 comments · Fixed by #12793
Closed

Error reported over different Send and Sync ordering #12739

coreyja opened this issue Jul 10, 2022 · 2 comments · Fixed by #12793
Assignees
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@coreyja
Copy link

coreyja commented Jul 10, 2022

Hey, first issue over here! Thanks everyone for the hard work put into this tool!

I ran into a small issue where I get an error that the order of Send + Sync is 'wrong'. Here is an example error message:

expected &(dyn Fn(&GameType) -> ScoreType + Send + Sync), found &(dyn Fn(&GameType) -> ScoreType + Sync + Send)

image

Notice the only difference being the order of Send and Sync at the end of each type. This code compiles fine with rustc but rust-analyzer (via nvim for me) is showing this error. Changing the order of Send and Sync in my code, so each site matches, resolves the error.

Is this intended behavior or a bug?
I fixed my usage, as it makes sense for both sites to have the same ordering! But was midly surprised me that it showed an error, especially when rustc did not.

Minimal Example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ac7efd618222cb33058c459d2d9b98de

rust-analyzer version: rust-analyzer 0.0.0 (5342f47 2022-07-09)
Also present on the latest (https://github.com/rust-lang/rust-analyzer/tree/2022-07-04) release, both downloaded from Github Releases for arm64 apple

rustc version: rustc 1.62.0 (a8314ef7d 2022-06-27)

relevant settings: None that I know of

@veber-alex
Copy link
Contributor

veber-alex commented Jul 11, 2022

Minimal repro:

fn foo(t: &(dyn Sync + Send)) {}

fn main() {
    let t: &(dyn Send + Sync) = &1;
    foo(t);
}

This actually exposes another bug in the line casting &i32 to a trait object.
expected &(dyn Send + Sync), found &i32

@flodiebold flodiebold added A-ty type system / type inference / traits / method resolution C-bug Category: bug labels Jul 11, 2022
@lowr
Copy link
Contributor

lowr commented Jul 16, 2022

@rustbot claim

Regarding "another bug", it seems like another case of #11847.

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

Successfully merging a pull request may close this issue.

4 participants