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

Document uniform_paths #697

Closed
wants to merge 2 commits into from

Conversation

mattheww
Copy link
Contributor

This updates use-declarations.md to describe the uniform_paths behaviour (requested in #487).

It also reorders things so that the main text and example describe the 2018 edition semantics, and the "Edition Differences" section says how the 2015 edition differs.

See also #291 "Path and module changes".

Ie, state that "use" statements can start with an identifier, resolved in a
similar way to a path expression.

Now the main text and example in use-declarations.md describe the 2018 edition
semantics, and the "Edition Differences" section says how the 2015 edition
differs.
module. `::` can be used to explicitly refer to a crate, requiring an extern
crate name to follow.
Paths in `use` items must start with an identifier or one of the [path
qualifiers] `crate`, `self`, `super`, or `::`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not specific to use paths and is true for all paths.

<!-- Note: This example works as-is in either 2015 or 2018. -->
`crate` refers to the current crate. `self` refers to the current module.
`super` refers to the parent module. `::` refers to the [extern prelude] (so
it requires a crate name to follow).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not specific to use paths and is true for all paths.

Also, what edition is documented? The :: bit is not true for 2015 edition.


```rust
If the path starts with an identifier, the identifier is resolved in the same
way as for a path in an expression (in particular, it can be a crate name or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Expression" here is a bit too specific, this is true for any non-import path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the path starts with an identifier

And if the path doesn't start with an identifier, the behavior is also the same.
The text leaves the non-identifier case up in the air though and never talks about it below.

Now the main text describes what is true in both 2015 and 2018 editions; the
varying behaviour (and all examples) are in an "Edition differences" section.

For the behaviour which doesn't vary between editions, avoids repeating
resolution rules which are documented elsewhere.
@mattheww
Copy link
Contributor Author

I've pushed a new proposed version of the text.

I've reduced the text which describes resolution behaviour which isn't specific to use paths.

I've made it more explicit about which pieces of text describe which editions.

@mattheww
Copy link
Contributor Author

mattheww commented Sep 6, 2023

Closing: #1052 covers this properly

@mattheww mattheww closed this Sep 6, 2023
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 this pull request may close these issues.

3 participants