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

Represent lifetimes as Names instead of Idents #12451

Merged
merged 1 commit into from
Feb 23, 2014

Conversation

edwardw
Copy link
Contributor

@edwardw edwardw commented Feb 21, 2014

Closes #7743.

@huonw
Copy link
Member

huonw commented Feb 22, 2014

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 &'a self instead of a: &'a int would do weird/bad things with

impl<'a> Foo<'a> {
     foo!(&'a int) // meant to be Foo's 'a.
}

)

(Sorry to be annoying about hygiene...)

@huonw
Copy link
Member

huonw commented Feb 22, 2014

That said, reverting this patch shouldn't be particularly hard if we do implement hygiene for them later...

bors added a commit that referenced this pull request Feb 23, 2014
@bors bors closed this Feb 23, 2014
@bors bors merged commit 7607332 into rust-lang:master Feb 23, 2014
@edwardw edwardw deleted the ident-2-name branch February 23, 2014 17:05
@pnkfelix
Copy link
Member

I'm inclined to agree with @huonw here: As his example illustrates, a macro can expand into a fn that binds a lifetime. This leads me to think that lifetimes should respect hygiene. (I guess I mention this only because huon has already said that macros-expanding into methods are a potential future motivation, but I would think that the current motivations are sufficient.)

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 rustc internal code? Or writing macro expanders?

In any case I'd prefer runtime-fail over having active footguns that are hidden by lack of hygiene.

@jbclements can you elaborate?

@edwardw
Copy link
Contributor Author

edwardw commented Feb 27, 2014

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.

pnkfelix added a commit to pnkfelix/rust that referenced this pull request Feb 28, 2014
… 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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Mar 21, 2024
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`]
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.

easy fix: lifetimes should contain Name's, not idents
5 participants