-
Notifications
You must be signed in to change notification settings - Fork 13k
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
use self::b
has stopped consulting local non-pub use
of b
#13598
Comments
Here is a more fully fleshed out illustration of the alternatives I described above: mod a {
pub mod b {
pub type C = uint;
}
}
#[cfg(variant1)]
mod variant1 {
use a::b;
use D = self::b::C;
pub fn main() {
let d : D = 3;
println!("d: {}", d);
}
}
#[cfg(variant2)]
mod variant2 {
use D = a::b::C;
pub fn main() {
let d : D = 3;
println!("d: {}", d);
}
}
#[cfg(variant3)]
mod variant3 {
pub use a::b;
use D = self::b::C;
pub fn main() {
let d : D = 3;
println!("d: {}", d);
}
}
#[cfg(variant4)]
mod variant4 {
use D = self::b::C;
pub fn main() {
let d : D = 3;
println!("d: {}", d);
}
mod b {
pub type C = uint;
}
}
#[cfg(variant1)]
pub fn main() {
variant1::main();
}
#[cfg(variant2)]
pub fn main() {
variant2::main();
}
#[cfg(variant3)]
pub fn main() {
variant3::main();
}
#[cfg(variant4)]
pub fn main() {
variant4::main();
} The point is that (There may indeed be good reasons. For example, if we need to impose this restriction to avoid import cycles, I can accept that. But I want to make sure we did not just accidentally regress this feature without consideration.) |
If we wanted to restore this behavior, it would also enable something like: mod a {
use b::c;
use self::c::foo;
use a::c::foo;
}
mod b {
pub mod c {
pub fn foo() {}
}
} Allowing |
@alexcrichton I guess from my POV, I do not see It makes sense to me that But |
Triage: The syntax mod a {
pub mod b {
pub type C = uint;
}
}
#[cfg(variant1)]
mod variant1 {
use a::b;
use self::b::C as D;
pub fn main() {
let d : D = 3;
println!("d: {}", d);
}
}
#[cfg(variant2)]
mod variant2 {
use a::b::C as D;
pub fn main() {
let d : D = 3;
println!("d: {}", d);
}
}
#[cfg(variant1)]
pub fn main() {
variant1::main();
}
#[cfg(variant2)]
pub fn main() {
variant2::main();
} And the updated output:
|
Triage; still reproduces |
Add action to expand a declarative macro once, inline. Fixes rust-lang#13598 This commit adds a new r-a method, `expandMacroInline`, which expands the macro that's currently selected. See rust-lang#13598 for the most applicable issue; though I suspect it'll resolve part of rust-lang#5949 and make rust-lang#11888 significantly easier). The macro works like this: ![rust-analyser-feature](https://user-images.githubusercontent.com/10906982/208813167-3123e379-8fd5-4206-a4f4-5af1129565f9.gif) I have 2 questions before this PR can be merged: 1. **Should we rustfmt the output?** The advantage of doing this is neater code. The disadvantages are we'd have to format the whole expr/stmt/block (since there's no point just formatting one part, especially over multiple lines), and maybe it moves the code around more in weird ways. My suggestion here is to start off by not doing any formatting; and if it appears useful we can decide to do formatting in a later release. 2. **Is it worth solving the `$crate` hygiene issue now?** -- I think this PR is usable as of right now for some use-cases; but it is annoying that many common macros (i.e. `println!()`, `format!()`) can't be expanded further unless the user guesses the correct `$crate` value. The trouble with solving that issue is that I think it's complicated and imperfect. If we do solve it; we'd also need to either change the existing `expandMacro`/`expandMacroInline` commands; provide some option to allow/disallow `$crate` expanding; or come to some other compromise.
I used to be able to do:
but now I cannot, at least not in all cases.
Here is a test case:
Here is a transcript of how this used to work (on a rustc v0.11-pre circa 2014-04-07) versus breaking now (on a rustc v0.11-pre circa 2014-04018).
Discussion with @alexcrichton leads me to think that this change may have been injected as part of PR #13409.
It may or may be a bug. Whether you see it as a bug may depend on your view of how privacy and
use
interact. (In particular, if you make a variant3 of variant1 where theuse a::b
is rewritten topub use a::b
, so that theb
is now publicly exported fromself
, then things seem to work.)My reasoning is that we should be able to do:
because the way we resolve
use self::b::C
, we look for other non-pub things inself
, such as a hypothetical non-pubmod b
defined withinself
.The text was updated successfully, but these errors were encountered: