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

Duplicate bounds behave differently depending on their order for const_trait_impl #88383

Closed
fee1-dead opened this issue Aug 27, 2021 · 1 comment · Fixed by #88851
Closed
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]`

Comments

@fee1-dead
Copy link
Member

fee1-dead commented Aug 27, 2021

I tried this code:

const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
    *t == *t
}

I expected to see this happen: It should be the same as

const fn equals_self<T: ~const PartialEq + PartialEq>(t: &T) -> bool {
    *t == *t
}

Instead, this happened: It errors for the former but does not error for the second example.

@rustbot label F-const_trait_impl

See https://github.com/rust-lang/rust/pull/88328/files#r697229693

@fee1-dead fee1-dead added the C-bug Category: This is a bug. label Aug 27, 2021
@rustbot rustbot added the F-const_trait_impl `#![feature(const_trait_impl)]` label Aug 27, 2021
@fee1-dead fee1-dead changed the title Duplicate bounds behaves differently depending on their order for const_trait_impl Duplicate bounds behave differently depending on their order for const_trait_impl Aug 27, 2021
@fee1-dead
Copy link
Member Author

Another example:

#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]

trait A: PartialEq {}

const fn equals_self<T: A + ~const PartialEq>(t: &T) -> bool {
    *t == *t
}

play

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 13, 2021
Fix duplicate bounds for const_trait_impl

Fixes rust-lang#88383.

Compare the constness of the candidates before winnowing and removing a `~const` `BoundCandidate`.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 14, 2021
Fix duplicate bounds for const_trait_impl

Fixes rust-lang#88383.

Compare the constness of the candidates before winnowing and removing a `~const` `BoundCandidate`.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 14, 2021
Fix duplicate bounds for const_trait_impl

Fixes rust-lang#88383.

Compare the constness of the candidates before winnowing and removing a `~const` `BoundCandidate`.
@bors bors closed this as completed in a9bc2ef Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants