-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Represent lifetimes as Names instead of Idents #12451
Conversation
FWIW, do we really want lifetimes to be non-hygienic? i.e. should macro_rules! foo ( ($t: ty) => { fn foo<'a>(a: &'a int, b: $t) { ... } })
foo!(&'a int) be valid? (This is particularly important if we ever get macros being able to expand to methods (#4621), in which case the above with impl<'a> Foo<'a> {
foo!(&'a int) // meant to be Foo's 'a.
} ) (Sorry to be annoying about hygiene...) |
That said, reverting this patch shouldn't be particularly hard if we do implement hygiene for them later... |
I'm inclined to agree with @huonw here: As his example illustrates, a macro can expand into a I do not understand the motivation outlined in the description on #7743: "This will allow them to be safely compared without fear of runtime-fail." Is this just talking about when writing In any case I'd prefer runtime-fail over having active footguns that are hidden by lack of hygiene. @jbclements can you elaborate? |
If a decision is made, I can always revert this patch. One caveat is since #12338 has turned lifetime renaming on, we may hit ast.rs#L67. |
… fields. After PR rust-lang#12451 landed, lifetimes carry a `Name` instead of an `Ident`. But that PR did not change the field names in `ast.rs` to `name` instead of the prevous `ident`. This impedes hacking on the code, since you are using `foo.ident` in a content expecting a `Name` half the time. We may or may not revert PR rust-lang#12451 in the future (for unrelated reasons). But in the mean time, here are two changes to ease working with the existing code: * Adding the `ast::LifetimeName` alias eases swapping in a newtype struct when hacking, or changing the alias to `Ident` in the future. * Renaming the `ident` fields of type `LifetimeName` to be `name` instead makes the code look much saner.
feat: Support `$$` in macros. The implementation mirrors what `rustc` currently does [1]. Part of rust-lang#11952. \[1]: https://github.com/rust-lang/rust/blob/0595ea1d12cf745e0a672d05341429ecb0917e66/compiler/rustc_expand/src/mbe/quoted.rs#L230-L241
new restriction lint: `integer_division_remainder_used` Fixes rust-lang/rust-clippy#12391 Introduces a restriction lint which disallows the use of `/` and `%` operators on any `Int` or `Uint` types (i.e., any that use the default `Div` or `Rem` trait implementations). Custom implementations of these traits are ignored. ---- changelog: Add new restriction lint [`integer_division_remainder_used`]
Closes #7743.