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

generic_const_exprs: duplicate definitions in disjoint impls #98448

Closed
lcnr opened this issue Jun 24, 2022 · 3 comments
Closed

generic_const_exprs: duplicate definitions in disjoint impls #98448

lcnr opened this issue Jun 24, 2022 · 3 comments
Labels
F-generic_const_exprs `#![feature(generic_const_exprs)]`

Comments

@lcnr
Copy link
Contributor

lcnr commented Jun 24, 2022

I found something weird, not sure if it is a bug:

const ONE : i32 = 1;
const TWO : i32 = 2;

struct Foo<const i: i32, const j: i32> {}

impl<const i: i32> Foo<i, ONE> {
    pub fn foo() {}
}

impl<const i: i32> Foo<i, TWO> {
    pub fn foo() {}
}

This can comiple without #![feature(generic_const_exprs)], but if #![feature(generic_const_exprs)] is added, it won't compile:

error[E0592]: duplicate definitions with name `foo`
  --> src/main.rs:9:5
   |
9  |     pub fn foo() {}
   |     ^^^^^^^^^^^^ duplicate definitions for `foo`
...
13 |     pub fn foo() {}
   |     ------------ other definition for `foo`

Originally posted by @psionic12 in #76560 (comment)

@lcnr lcnr changed the title generic_const_exprs: doublicate definitions in disjoint impls generic_const_exprs: duplicate definitions in disjoint impls Jun 24, 2022
@lcnr lcnr added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label Jun 24, 2022
@lcnr
Copy link
Contributor Author

lcnr commented Jun 24, 2022

@psionic12 moved your comment out of the tracking issues as these are not meant for large scale discussion, questions, or bug reports about a feature.

This is definitely a bug. I do assume it's the same underlying issue as #92186

@lcnr
Copy link
Contributor Author

lcnr commented Jun 24, 2022

actually closing this in favor of #92186, added your test as a comment, thanks

@lcnr lcnr closed this as completed Jun 24, 2022
@psionic12
Copy link

Thanks for helping @lcnr, hope this bug can be fixed asap, I'm highly relied on this feature, and have to use macros instead for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-generic_const_exprs `#![feature(generic_const_exprs)]`
Projects
None yet
Development

No branches or pull requests

2 participants