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

Possibly Syntax Issue #12739

Closed
kylecook80 opened this issue Mar 6, 2014 · 1 comment
Closed

Possibly Syntax Issue #12739

kylecook80 opened this issue Mar 6, 2014 · 1 comment

Comments

@kylecook80
Copy link

I attempted to compile this code:

pub fn set_game_state<T: GameState>(&mut self, state: ~T) {
  self.state = state;
}

It gave me the error:

src/game_window.rs:37:18: 37:23 error: mismatched types: expected `~game_state::GameState:Send` but found `~T` (expected trait game_state::GameState but found ~-ptr)
src/game_window.rs:37     self.state = state;

The following code did compile:

pub fn set_game_state(&mut self, state: ~GameState) {
  self.state = state;
}

I was made aware on the IRC Chat that both of these snippets of code should have worked.

Rust Version: master (0.10-pre)
OS: Mac OSX 10.9
Architecture: x86_64

@kylecook80
Copy link
Author

Didn't see that my previous issue got closed! I apologize for the duplicate.

JohnTitor pushed a commit to JohnTitor/rust that referenced this issue Sep 6, 2022
fix: sort and deduplicate auto traits in trait object types

Fixes rust-lang#12739

Chalk solver doesn't sort and deduplicate auto traits in trait object types, so we need to handle them ourselves in the lowering phase, just like [`rustc`](https://github.com/rust-lang/rust/blob/880416180b0a9ee1141c07d4d17667edb77daebd/compiler/rustc_typeck/src/astconv/mod.rs#L1487-L1488) and [`chalk-integration`](https://github.com/rust-lang/chalk/blob/master/chalk-integration/src/lowering.rs#L575) do.

Quoting from [the Chalk book](https://rust-lang.github.io/chalk/book/types/rust_types.html#dyn-types):

> Note that -- for this purpose -- ordering of bounds is significant. That means that if you create a `dyn Foo + Send` and a `dyn Send + Foo`, chalk would consider them distinct types. The assumption is that bounds are ordered in some canonical fashion somewhere else.

Also, trait object types with more than one non-auto traits were previously allowed, but are now disallowed with this patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant