Skip to content

Error wrongly trying to assign assoc const to primitive speaks of methods #79760

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
jnqnfe opened this issue Dec 6, 2020 · 1 comment · Fixed by #79772
Closed

Error wrongly trying to assign assoc const to primitive speaks of methods #79760

jnqnfe opened this issue Dec 6, 2020 · 1 comment · Fixed by #79772
Assignees
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-trait-system Area: Trait system C-bug Category: This is a bug.

Comments

@jnqnfe
Copy link
Contributor

jnqnfe commented Dec 6, 2020

Imperfection in error output.

I just tried adding an associated constant to a type alias of a primitive (to see if it was allowed or whether I'd need a wrapper) and noticed an imperfection in the error output in that it says "help: consider using a trait to implement these methods" pointing to the impl block that actually just contains an constant.

error[E0390]: only a single inherent implementation marked with `#[lang = "u64"]` is allowed for the `u64` primitive
  --> pulse-binding/src/channelmap.rs:50:1
   |
50 | / impl PositionMask {
51 | |     pub const POSITION_MASK_ALL: PositionMask = 0xffffffffffffffffu64;
52 | | }
   | |_^
   |
help: consider using a trait to implement these methods
  --> pulse-binding/src/channelmap.rs:50:1
   |
50 | / impl PositionMask {
51 | |     pub const POSITION_MASK_ALL: PositionMask = 0xffffffffffffffffu64;
52 | | }
   | |_^
@eopb
Copy link
Contributor

eopb commented Dec 6, 2020

Minimal code.

type A = u64;

impl A {
    pub const B: A = 0;
}

I am going to try to work on this one.

@rustbot claim

@eopb eopb mentioned this issue Dec 6, 2020
@camelid camelid added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-trait-system Area: Trait system C-bug Category: This is a bug. labels Dec 6, 2020
@jyn514 jyn514 changed the title Error wrongly trying to assign assoc const to primative speaks of methods Error wrongly trying to assign assoc const to primitive speaks of methods Dec 6, 2020
@bors bors closed this as completed in 2b76c48 Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-trait-system Area: Trait system C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants