-
Notifications
You must be signed in to change notification settings - Fork 562
Add section on expansion-time (early) name resolution #2055
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for posting. Lot of good here. The main thing I'd suggest, by way of helping to sharpen this up, would be to try to write a concise example after each claim, in as many cases as that might make sense, that demonstrates that the claim is true (and would not pass if the claim were false). Aside from the intrinsic benefit of having such examples, I think this might help to focus the text on the language-level effects. (It's not surprising, given the good research you've been doing, that some bits of this currently have some "description of the implementation" flavor.) |
yaahc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a fair number of comments are also contained inline in the documents
src/names/name-resolution.md
Outdated
| * .visitation-order | ||
| * derive helpers | ||
| * not visited when resolving derive macros in the parent scope (starting scope) | ||
| * derive helpers compat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same concern as above about this being deprecated and removed next year.
This comment has been minimized.
This comment has been minimized.
|
@ehuss and I are looking at this together on the lang-docs office hours call, and we just wanted to express our appreciation to @petrochenkov for having been so responsive with @yaahc on working out the details here. This is a chapter that we've long wanted to exist, and we're thrilled and appreciative that @yaahc is digging in to shape this up. |
5397d08 to
1bd3afe
Compare
80fd707 to
570bedd
Compare
8a0b641 to
66899c6
Compare
|
Thanks to @yaahc for joining us on the lang-docs office hours today to speedrun many revisions to this chapter, which is really shaping up. |
Add test for derive helper compat collisions Resolves rust-lang/reference#2055 (comment) r? `@petrochenkov`
Add test for derive helper compat collisions Resolves rust-lang/reference#2055 (comment) r? `@petrochenkov`
Add test for derive helper compat collisions Resolves rust-lang/reference#2055 (comment) r? `@petrochenkov`
7751947 to
fb4fee6
Compare
This comment has been minimized.
This comment has been minimized.
8da1fb7 to
c96ed3f
Compare
Co-authored-by: Vadim Petrochenkov <[email protected]> Co-authored-by: Eric Huss <[email protected]> Co-authored-by: Tshepang Mbambo <[email protected]>
Co-authored-by: Eric Huss <[email protected]> Co-authored-by: TC
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
src/names/name-resolution.md
Outdated
| > ``` | ||
| r[names.resolution.expansion.imports.ambiguity.path-vs-textual-macro] | ||
| Path-based scope bindings for macros may not shadow textual scope bindings to macros. For bindings from [`use` declarations], this applies regardless of their [sub-namespace]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went to update this example because
- I realized that for the purposes of this ambiguity error, only path-based scope bindings from use declarations are relevant. The only other sources of path-based scope bindings are:
#[macro_export], which unconditionally adds an entry to the crate root, which by definition is always going to be in the outermost module scope and couldn't otherwise lexically shadow any textual macro bindings in a crate.- proc macros, which cannot be used in the crate they're defined, and must be imported via a use declaration in which case it's using an import, or (and I'm not sure this works) a macro_use attr on an extern crate statement for the proc macro crate, in which case the candidate would live in the macro_use prelude and this this ambiguity error would never apply (nor need to)
- I wanted to demonstrate the "regardless of their sub-namespace" claim as well as the core claim.
unfortunately, my attempt compiled without issue:
macro_rules! m {
() => {};
}
pub fn foo() {
m!();
use myinline::inline as m;
}I think the issue here is that I attempted to combine this lint with a rule in namespaces.md based on a misunderstanding of what that rule was talking about.
I believe this rule is meant to clarify the scope of https://doc.rust-lang.org/reference/items/use-declarations.html#r-items.use.restrictions.duplicate-name
| The available scopes are visited in the following order. | ||
|
|
||
| * [Derive helpers] | ||
| * [Textual scope macros] | ||
| * [Path-based scope macros] | ||
| * [`macro_use` prelude] | ||
| * [Standard library prelude] | ||
| * [Builtin attributes] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this clarify that each of these bullets represent one or more scopes or is this intuitively obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably worth clarifying.
currently mostly a skeleton of a draft so we can collaboratively massage it into shape more easily before filling in with proper reference verbiage.
hoping to take a significant chunk out of #568