-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Writing a non-trait impl for a struct in a different module makes it impossible to construct that struct directly #9052
Comments
A workabout for this is to qualify Foo. E.g. this works: mod foo {
fn bar() -> super::Foo {
super::Foo { x: 1 }
}
impl super::Foo { }
}
pub struct Foo { x: int }
fn main() {} Note that it still won't work perfectly, as you are liable to hit #9584 in the process. |
Just ran across this when implementing an extra method only in tests. You actually don’t need to always qualify |
@chris-morgan assures me that this is a manifestation of the same bug, although it expresses itself as the sudden invisibility of an inherent impl from a different module: use Foo::Bar;
mod Foo {
pub struct Bar {
pub x: int,
y: int
}
impl Bar {
pub fn new(new_x: int, new_y: int) -> Bar {
Bar { x: new_x, y: new_y }
}
}
}
impl Bar {
fn set_x(&self, new_x: int) {
self.x = new_x;
}
}
fn main() {
let bar = Bar::new(1, 2); // error: unresolved name `Bar::new`.
println!("{}", bar.x);
} |
So this is no longer an issue given that inherent impls are now only allowed in the same module? |
@jakub- yup |
Fix suggestions for `async` closures in redundant_closure_call Fixes rust-lang#9052 changelog: Fix suggestions given by [`redundant_closure_call`] for async closures
Commenting out the
impl
makes the build succeed.The text was updated successfully, but these errors were encountered: