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

Allow interpolated paths after use during macro expansion. #10415

Closed
brendanzab opened this issue Nov 11, 2013 · 2 comments
Closed

Allow interpolated paths after use during macro expansion. #10415

brendanzab opened this issue Nov 11, 2013 · 2 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-syntaxext Area: Syntax extensions

Comments

@brendanzab
Copy link
Member

#![feature(macro_rules)]

macro_rules! use_path(($p:path) => (use $p;))

use_path!(std::uint)

fn main() {
    let _ = uint::max_value;
}
<anon>:3:42: 3:43 error: expected ident, found `std::uint`
<anon>:3 macro_rules! use_path(($p:path) => (use $p;))
                                                  ^
@huonw
Copy link
Member

huonw commented Aug 4, 2014

Triage, the error message has improved slightly, but no change (I updated the example code & diagnostics). It's worth noting that import paths are actually different to normal paths, since e.g. foo::<T>::bar::<U> is a valid path, but not a valid import path.

(For completeness, I believe there's no import paths that are invalid normal paths, e.g. super::super::foo() is a valid expression.)

@steveklabnik
Copy link
Member

Triage: no change

@arielb1 arielb1 added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) and removed I-wrong labels Jun 29, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 17, 2016
syntax: Parse import prefixes as paths

Fixes rust-lang#10415

r? @eddyb
(This partially intersects with rust-lang#33041)
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 24, 2016
 Paths are mostly parsed without taking whitespaces into account, e.g. `std :: vec :: Vec :: new ()` parses successfully, however, there are some special cases involving keywords `super`, `self` and `Self`. For example, `self::` is considered a path start only if there are no spaces between `self` and `::`. These restrictions probably made sense when `self` and friends weren't keywords, but now they are unnecessary.

The first two commits remove this special treatment of whitespaces by removing `token::IdentStyle` entirely and therefore fix rust-lang#14109.
This change also affects naked `self` and `super` (which are not tightly followed by `::`, obviously) they can now be parsed as paths, however they are still not resolved correctly in imports (cc @jseyfried, see `compile-fail/use-keyword.rs`), so rust-lang#29036 is not completely fixed.

The third commit also makes `super`, `self`, `Self` and `static` keywords nominally (before this they acted as keywords for all purposes) and removes most of remaining \"special idents\".

The last commit (before tests) contains some small improvements - some qualified paths with type parameters are parsed correctly, `parse_path` is not used for parsing single identifiers, imports are sanity checked for absence of type parameters - such type parameters can be generated by syntax extensions or by macros when rust-lang#10415 is fixed (~~soon!~~already!).

This patch changes some pretty basic things in `libsyntax`, like `token::Token` and the keyword list, so it's a plugin-[breaking-change].

r? @eddyb
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 10, 2023
…llogiq

Add `collection_is_never_read`

Fixes rust-lang#9267

`@flip1995` and `@llogiq,` I talked with you about this one at Rust Nation in London last week. :-)

This is my first contribution to Clippy, so lots of feedback would be greatly appreciated.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

`dogfood` found one true positive (see rust-lang#9509) and no false positives.

`lintcheck` found no (true or false) positives, even when running on an extended set of crates.

---

changelog: new lint [`collection_is_never_read`]
[rust-lang#10415](rust-lang/rust-clippy#10415)
<!-- changelog_checked -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

4 participants