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 calling supertrait method via trait reference #4295

Closed
jdm opened this issue Dec 27, 2012 · 3 comments
Closed

Error calling supertrait method via trait reference #4295

jdm opened this issue Dec 27, 2012 · 3 comments
Labels
A-traits Area: Trait system

Comments

@jdm
Copy link
Contributor

jdm commented Dec 27, 2012

trait A {
    fn foo();
}

trait B: A {
}

struct BImpl {
    unused: int
}

impl BImpl: B {
}

impl BImpl: A {
    fn foo() {}
}

struct CImpl {
    b: B
}

impl CImpl: A {
    fn foo() {
        self.b.foo();
    }
}

fn main() {
    let b = BImpl { unused: 0 } as B;
    let c = CImpl { b: b };
    c.foo();
}
[jdm@rosencrantz traitinheritance]$ rustc test2.rs 
test2.rs:25:8: 25:21 error: type `@B` does not implement any method in scope named `foo`
test2.rs:25         self.b.foo();
                    ^~~~~~~~~~~~~
@jdm
Copy link
Contributor Author

jdm commented Dec 27, 2012

Here's a simpler testcase:

trait A {
    fn foo();
}

trait B: A {
}

impl int: A {
    fn foo() {}
}

impl int: B {
}

fn main() {
    5.foo();
    (5 as B).foo();
}
[jdm@rosencrantz traitinheritance]$ rustc test3.rs 
test3.rs:33:4: 33:19 error: type `@B` does not implement any method in scope named `foo`
test3.rs:33     (5 as B).foo();
                ^~~~~~~~~~~~~~~

@ghost ghost assigned catamorphism Feb 20, 2013
@catamorphism
Copy link
Contributor

Reproduced with 373504 but not critical for 0.6.

@jdm
Copy link
Contributor Author

jdm commented Mar 21, 2013

I guess this is the same as #4100.

@jdm jdm closed this as completed Mar 21, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 13, 2022
Downgrade mutex_atomic to nursery

See rust-lang#1516 and rust-lang#4295.

There are suggestions about removing this lint from the default warned lints in both issues.
Also, [`mutex_integer`](https://rust-lang.github.io/rust-clippy/master/index.html#mutex_integer) lint that has the same problems as this lint is in `nursery` group.

changelog: Moved [`mutex_atomic`] to `nursery`
flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 12, 2023
Move `mutex_atomic` to `restriction`

By rust-lang#4295, the general consensus seems to be that `mutex_atomic` is not a useful lint in most cases. If anything, it could be useful as a restriction on code that for whatever reason can't use atomics. Keeping it in `clippy::nursery` is harmful to people attempting to use clippy for soundness.

---

changelog: Moved [`mutex_atomic`] to `restriction`
[rust-lang#10115](rust-lang/rust-clippy#10115)
<!-- chnagelog_checked -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system
Projects
None yet
Development

No branches or pull requests

2 participants