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

(More) consistently use "region" terminology in rustc_middle #110621

Closed
wants to merge 8 commits into from

Conversation

WaffleLapkin
Copy link
Member

I started with GenericArg and then renamed some other stuff I saw. It looks like in the later compiler stages we almost always use "region" as a term instead of "lifetime". I've renamed some weird occurrences of lifetimes in these stages:

  • GenericArgKind::{Lifetime => Region} (this one literally hold ty::Region as a field...)
  • GenericParamDefKind::{Lifetime => Region}
  • tcx.{lifetimes => regions}
    • CommonLifetimes => CommonRegions
    • CommonRegions::{re_erased => erased, re_vars => vars, re_late_bounds => late_bounds}
      • re_static was left as-is (static is a keyword...)

@bors rollup=never p=1

@rustbot
Copy link
Collaborator

rustbot commented Apr 20, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative labels Apr 20, 2023
@rustbot
Copy link
Collaborator

rustbot commented Apr 20, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in need_type_info.rs

cc @lcnr

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@compiler-errors
Copy link
Member

Hm, I think this may need further discussion.

I don't think, for example, we should call them GenericParamDefKind:: Region. It feels like that type is right at the threshold of the distinction we make between calling them "lifetimes" in user-facing positions and "regions" for internal purposes. Also, while I personally prefer the name region, I'm somewhat suspicious that it's not universally preferred over lifetime, and it's not necessarily clear that we should be renaming things from lifetime=>region or region=>lifetime...

@lcnr
Copy link
Contributor

lcnr commented Apr 21, 2023

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/naming.20bikeshedding it doesn't seem like there is consensus that we go with region over lifetime 🤷

@WaffleLapkin
Copy link
Member Author

My point was that consistency matters and in later compilation stages we almost exclusively use "region" as the term, so changing few places where we don't makes sense. With GenericArg for example, it literally holds ty::Region, so it's weird to call the variant Lifetime...

I think even if we eventually end up renaming "region" to something else, it would be a much bigger change and this does not conflict with that (if anything by making it more consistent, the rename would be easier to do).

(I also just like the "region", so there is that)

I don't think, for example, we should call them GenericParamDefKind::Region. It feels like that type is right at the threshold of the distinction we make between calling them "lifetimes" in user-facing positions and "regions" for internal purposes.

The good thing is — I can just drop commits that rename GenericParamDefKind::.... Maybe I went a little bit too far with it...

@bors
Copy link
Contributor

bors commented Apr 22, 2023

☔ The latest upstream changes (presumably #110666) made this pull request unmergeable. Please resolve the merge conflicts.

@apiraino
Copy link
Contributor

hello, checking progress - any actionable here yet or is the discussion still ongoing? Does it need to be nominated for a {compiler|lang} meeting? thanks!

@WaffleLapkin WaffleLapkin added S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 16, 2023
@WaffleLapkin
Copy link
Member Author

WaffleLapkin commented May 16, 2023

I've opened an MCP for this change: rust-lang/compiler-team#634

(as a side-note I've also added a S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. label)

@WaffleLapkin
Copy link
Member Author

The MCP was closed and this has a ton of conflicts, so — closing.

As a remark, I still like the region name better, but it doesn't seem like a lot of people agree with me. Hope someone will work on #110254, so that we at least use something consistently.

@WaffleLapkin WaffleLapkin deleted the region_in_france branch November 8, 2023 22:04
@apiraino apiraino removed the S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants