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

rustc_ast_lowering: Stop lowering imports into multiple items #104963

Merged
merged 3 commits into from
Dec 2, 2022

Conversation

petrochenkov
Copy link
Contributor

Lower them into a single item with multiple resolutions instead.
This also allows to remove additional NodIds and DefIds related to those additional items.

@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2022

r? @wesleywiser

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

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 26, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2022

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@petrochenkov
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 26, 2022
@bors
Copy link
Contributor

bors commented Nov 26, 2022

⌛ Trying commit b93c4dca5cb7d1e000b67d3028c1e64d8a207ecf with merge 92fa2a1be7dd7730c2f2fe2f6c0ea4c1568bf834...

@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 26, 2022
@bors

This comment was marked as resolved.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 27, 2022
@rust-log-analyzer

This comment was marked as resolved.

@rust-log-analyzer

This comment was marked as resolved.

@petrochenkov
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 27, 2022

⌛ Trying commit 04eabb0d387ea54e53e513ba96d2d2cd1fc1aacd with merge 95e6cf06dca55add53a600d4152451a00fb84128...

@petrochenkov petrochenkov removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 27, 2022
@cjgillot cjgillot self-assigned this Nov 27, 2022
@bors
Copy link
Contributor

bors commented Nov 27, 2022

☀️ Try build successful - checks-actions
Build commit: 95e6cf06dca55add53a600d4152451a00fb84128 (95e6cf06dca55add53a600d4152451a00fb84128)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (95e6cf06dca55add53a600d4152451a00fb84128): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.8% [0.8%, 0.8%] 1
Improvements ✅
(primary)
-0.6% [-1.2%, -0.2%] 46
Improvements ✅
(secondary)
-4.3% [-5.5%, -2.1%] 13
All ❌✅ (primary) -0.6% [-1.2%, -0.2%] 46

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.4% [3.8%, 5.2%] 3
Improvements ✅
(primary)
-1.8% [-4.0%, -0.9%] 32
Improvements ✅
(secondary)
-8.0% [-12.1%, -0.9%] 15
All ❌✅ (primary) -1.8% [-4.0%, -0.9%] 32

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.8% [-2.1%, -1.6%] 3
Improvements ✅
(secondary)
-9.6% [-13.2%, -5.2%] 13
All ❌✅ (primary) -1.8% [-2.1%, -1.6%] 3

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 27, 2022
@petrochenkov
Copy link
Contributor Author

@rustbot ready

compiler/rustc_hir/src/hir.rs Outdated Show resolved Hide resolved
compiler/rustc_hir/src/hir.rs Outdated Show resolved Hide resolved
@petrochenkov petrochenkov 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 29, 2022
@bors

This comment was marked as resolved.

Lower them into a single item with multiple resolutions instead.
This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
@petrochenkov
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 1, 2022
@cjgillot
Copy link
Contributor

cjgillot commented Dec 1, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Dec 1, 2022

📌 Commit b32a4ed has been approved by cjgillot

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 Dec 1, 2022
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

Small review on the Clippy changes.

@@ -176,7 +176,8 @@ impl LateLintPass<'_> for WildcardImports {
format!("{import_source_snippet}::{imports_string}")
};

let (lint, message) = if let Res::Def(DefKind::Enum, _) = use_path.res {
// Glob imports always have a single resolution.
let (lint, message) = if let Res::Def(DefKind::Enum, _) = use_path.res[0] {
Copy link
Member

Choose a reason for hiding this comment

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

This could be when already matching anyway. A little bit safer.

Suggested change
let (lint, message) = if let Res::Def(DefKind::Enum, _) = use_path.res[0] {
let (lint, message) = if let Some(Res::Def(DefKind::Enum, _)) = use_path.res.get(0) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If glob import doesn't have a resolution (for its prefix) then something unexpected is happening, so it should be fine to leae this as indexing.

@@ -1,8 +1,8 @@
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:23:5
--> $DIR/macro_use_imports.rs:25:5
Copy link
Member

Choose a reason for hiding this comment

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

Those two error messages got swapped around. Weird 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are reported in a different order now, due to a different order of DefIds assigned by def collector, most probably.

@bors
Copy link
Contributor

bors commented Dec 2, 2022

⌛ Testing commit b32a4ed with merge 11663b1...

@bors
Copy link
Contributor

bors commented Dec 2, 2022

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 11663b1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 2, 2022
@bors bors merged commit 11663b1 into rust-lang:master Dec 2, 2022
@rustbot rustbot added this to the 1.67.0 milestone Dec 2, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (11663b1): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.6% [0.6%, 0.6%] 1
Improvements ✅
(primary)
-0.5% [-1.2%, -0.3%] 54
Improvements ✅
(secondary)
-4.2% [-5.4%, -2.0%] 13
All ❌✅ (primary) -0.5% [-1.2%, -0.3%] 54

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.5% [-3.6%, -0.7%] 25
Improvements ✅
(secondary)
-7.9% [-11.4%, -3.0%] 14
All ❌✅ (primary) -1.5% [-3.6%, -0.7%] 25

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
3.6% [3.2%, 4.3%] 3
Improvements ✅
(primary)
-1.5% [-2.1%, -0.9%] 3
Improvements ✅
(secondary)
-8.8% [-11.9%, -3.6%] 13
All ❌✅ (primary) -0.7% [-2.1%, 1.5%] 4

flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 17, 2022
rustc_ast_lowering: Stop lowering imports into multiple items

Lower them into a single item with multiple resolutions instead.
This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend merged-by-bors This PR was explicitly merged by bors. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants