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

Confusing error with :: on struct #10551

Closed
comex opened this issue Nov 18, 2013 · 2 comments
Closed

Confusing error with :: on struct #10551

comex opened this issue Nov 18, 2013 · 2 comments

Comments

@comex
Copy link
Contributor

comex commented Nov 18, 2013

The following code was my incorrect attempt to explicitly specialize a static method:

trait Test {
    fn hello();
}

fn main() {
    struct T;
    impl Test for T {
        fn hello() {}
    }
    T::hello();
}

In fact, apparently the fn is not yet possible to call at all. However, the error output is needlessly confusing with an error!() message and three errors:

!!! (resolving module in lexical scope) module wasn't actually a module!
/tmp/r.rs:10:4: 10:12 error: unresolved name
/tmp/r.rs:10     T::hello();
                 ^~~~~~~~
/tmp/r.rs:10:4: 10:12 error: use of undeclared module `T`
/tmp/r.rs:10     T::hello();
                 ^~~~~~~~
!!! (resolving module in lexical scope) module wasn't actually a module!
/tmp/r.rs:10:4: 10:12 error: unresolved name `T::hello`.
/tmp/r.rs:10     T::hello();
@geoffhill-zz
Copy link
Contributor

The "!!!" lines should be internal debugs, not user printouts. Adding a pull request to fix this, but not sure if any additional behavior here needs to be fixed. Are there existing instances where the Rust compiler warns you if you attempt to use a C++ OOP feature?

@huonw
Copy link
Member

huonw commented Aug 4, 2014

Fixed by #11623.

@huonw huonw closed this as completed Aug 4, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 6, 2023
In uninit checking, add fallback for polymorphic types

After rust-lang#10520, we always assumed that polymorphic types do not allow to be left uninitialized. But we can do better, by peeking into polymorphic types and adding a few special cases for going through tuples, arrays (because the length may be polymorphic) and blanket allowing all unions (like MaybeUninit).

fixes rust-lang#10551

changelog: [uninit_vec]: fix false positive for polymorphic types
changelog: [uninit_assumed_init]: fix false positive for polymorphic types
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

Successfully merging a pull request may close this issue.

3 participants