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

Add internal lint for detecting non-glob imports of rustc_type_ir::inherent #127854

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

fmease
Copy link
Member

@fmease fmease commented Jul 17, 2024

#127627 (comment)

r? compiler-errors

@rustbot rustbot added 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. labels Jul 17, 2024
Comment on lines +294 to +295
match cx.tcx.sess.source_map().span_to_snippet(path.span).as_deref() {
Ok("self") => (path.span, "*"),
Copy link
Member Author

@fmease fmease Jul 17, 2024

Choose a reason for hiding this comment

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

Super gross but I couldn't think of anything better w/o tweaking AST lowering (e.g., to use mark_with_reason in this case). This is for dealing with use path::to::{self}; properly.

In HIR, there's no way to tell whether use path::to; comes from use path::{to}; or use path::to::{self}; but it matters for diagnostics (need to suggest ::* vs. * + differing spans partly cuz use path::to::{self::*}; isn't allowed). Span etc. doesn't help.

report_in_external_macro: true
}

declare_lint_pass!(TypeIr => [NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT]);
Copy link
Member Author

@fmease fmease Jul 17, 2024

Choose a reason for hiding this comment

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

I'm inclined to consolidate the lint passes TypeIr and TyTyKind to reduce bloat. I'd just need to think of a good name 🤔

Copy link
Member

Choose a reason for hiding this comment

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

"opinionated imports"?

@@ -1,4 +1,4 @@
use crate::inherent::{AdtDef, IntoKind, Ty};
use crate::inherent::*;
Copy link
Member Author

Choose a reason for hiding this comment

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

🎉

Copy link
Member

Choose a reason for hiding this comment

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

omfg

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

This is great, thanks

@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 17, 2024

📌 Commit adc48b0 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 17, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 17, 2024
…t-lint, r=compiler-errors

Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`

rust-lang#127627 (comment)

r? compiler-errors
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#127542 ([`macro_metavar_expr_concat`] Add support for literals)
 - rust-lang#127652 (Unignore cg_gcc fmt)
 - rust-lang#127664 (Fix precise capturing suggestion for hidden regions when we have APITs)
 - rust-lang#127806 (Some parser improvements)
 - rust-lang#127828 (Commonize `uname -m` results for `aarch64` in docker runner)
 - rust-lang#127845 (unix: break `stack_overflow::install_main_guard` into smaller fn)
 - rust-lang#127854 (Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`)
 - rust-lang#127861 (Document the column numbers for the dbg! macro)
 - rust-lang#127875 (style-guide: Clarify version-sorting)

r? `@ghost`
`@rustbot` modify labels: rollup
@tgross35
Copy link
Contributor

@bors r- failed the rollup in #127876 (comment). Lint didn't get registered?

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 18, 2024
@fmease fmease force-pushed the glob-import-type_ir_inherent-lint branch from adc48b0 to bd6a408 Compare July 18, 2024 02:44
@fmease
Copy link
Member Author

fmease commented Jul 18, 2024

Lint didn't get registered?

It's registered … in a stage2 compiler but apparently we also run tests/ui-fulldeps/ with a stage1 compiler during a full build (apart from stageN, N>1).

@bors try

@bors
Copy link
Contributor

bors commented Jul 18, 2024

⌛ Trying commit bd6a408 with merge 647fdf7...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
…lint, r=<try>

Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`

rust-lang#127627 (comment)

r? compiler-errors
@bors
Copy link
Contributor

bors commented Jul 18, 2024

☀️ Try build successful - checks-actions
Build commit: 647fdf7 (647fdf7192d0da819a91af60a41fab722116bc10)

@fmease

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 18, 2024
@fmease fmease force-pushed the glob-import-type_ir_inherent-lint branch from bd6a408 to ee27b4c Compare July 18, 2024 10:48
@fmease

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@fmease

This comment was marked as outdated.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 18, 2024
@fmease fmease force-pushed the glob-import-type_ir_inherent-lint branch from ee27b4c to 2507301 Compare July 18, 2024 11:04
@fmease
Copy link
Member Author

fmease commented Jul 18, 2024

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jul 18, 2024

📌 Commit 2507301 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 18, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#124881 (Use ThreadId instead of TLS-address in `ReentrantLock`)
 - rust-lang#127656 (make pub_use_of_private_extern_crate show up in cargo's future breakage reports)
 - rust-lang#127748 (Use Option's discriminant as its size hint)
 - rust-lang#127854 (Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`)
 - rust-lang#127908 (Update extern linking documentation)
 - rust-lang#127919 (Allow a git command for getting the current branch in bootstrap to fail)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4ad2c99 into rust-lang:master Jul 18, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
Rollup merge of rust-lang#127854 - fmease:glob-import-type_ir_inherent-lint, r=compiler-errors

Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`

rust-lang#127627 (comment)

r? compiler-errors
@fmease fmease deleted the glob-import-type_ir_inherent-lint branch July 18, 2024 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants