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

Run borrowck tests on BIDs and emit tail-expr-drop-order lints for violations #134523

Merged
merged 6 commits into from
Jan 8, 2025

Conversation

dingxiangfei2009
Copy link
Contributor

Fix #132861

r? @nikomatsakis
cc @compiler-errors

This patch enlarges the scope where the tail-expr-drop-order lint applies, so that all locals involved in tail expressions are inspected. This is necessary to run borrow-checking to capture the cases where it used to compile under Edition 2021 but is not going to pass borrow-checking from Edition 2024 onwards.

The way it works is to inspect each BID against the set of borrows that are still live. If the local involved in BID has a borrow index which happens to be live as well at the location of this BID statement, in the future this will be a borrow-checking violation. The lint will fire in this case.

@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 Dec 19, 2024
@@ -994,6 +997,23 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
}
}

fn maybe_polonius_borrows_in_scope<'s>(
Copy link
Member

Choose a reason for hiding this comment

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

why does this mention polonius at all? why isn't this just called borrows_in_scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, let's.

I am tucking the comment into this function, too.

@dingxiangfei2009
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Dec 19, 2024

⌛ Trying commit 0a77622 with merge 9b5e8b1...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2024
…t-2, r=<try>

Run borrowck tests on BIDs and emit tail-expr-drop-order lints for violations

Fix rust-lang#132861

r? `@nikomatsakis`
cc `@compiler-errors`

This patch enlarges the scope where the `tail-expr-drop-order` lint applies, so that all locals involved in tail expressions are inspected. This is necessary to run borrow-checking to capture the cases where it used to compile under Edition 2021 but is not going to pass borrow-checking from Edition 2024 onwards.

The way it works is to inspect each BID against the set of borrows that are still live. If the local involved in BID has a borrow index which happens to be live as well at the location of this BID statement, in the future this will be a borrow-checking violation. The lint will fire in this case.
@dingxiangfei2009
Copy link
Contributor Author

I have prepared the following craterbot message.

@craterbot run start=master#11663cd3bfefef7d34e8f0892c250bf698049392 end=try#9b5e8b16bd1c4acf4cf8e6880368314cf021a987 mode=build-only +rustflags=-Dtail-expr-drop-order
  • I would like to check the difference in lint effects with -Dtail-expr-drop-order before and after, to see if there is any false positives and negatives.
  • build-only is required, because Always run tail_expr_drop_order lint in promoted MIR query #134493 is still not on master yet. Otherwise, we could use check-only for the experiment.

Shall we double-check and give this a go afterwards? Big thanks!

@craterbot
Copy link
Collaborator

🔒 Error: you're not allowed to interact with this bot.

🔑 If you are a member of the Rust team and need access, add yourself to the whitelist.
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2024
…-run, r=<try>

Crater run for `tail-expr-drop-order`

This is experiment for rust-lang#134523
@traviscross traviscross added the L-tail_expr_drop_order Lint: tail_expr_drop_order label Dec 19, 2024
@bors
Copy link
Contributor

bors commented Dec 19, 2024

☀️ Try build successful - checks-actions
Build commit: 9b5e8b1 (9b5e8b16bd1c4acf4cf8e6880368314cf021a987)

@lqd
Copy link
Member

lqd commented Dec 20, 2024

A perf run shouldn't show anything since this shouldn't be enabled by default. However, some of these previous PRs have been unexpected regressions, let's check.

@rust-timer build 9b5e8b1

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9b5e8b1): comparison URL.

Overall result: ❌ regressions - 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-perf -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.8%)

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)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-0.8%, -0.8%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 769.451s -> 768.407s (-0.14%)
Artifact size: 330.39 MiB -> 330.40 MiB (0.00%)

@compiler-errors
Copy link
Member

@craterbot run start=master#11663cd3bfefef7d34e8f0892c250bf698049392+rustflags=-Dtail-expr-drop-order end=try#9b5e8b16bd1c4acf4cf8e6880368314cf021a987+rustflags=-Dtail-expr-drop-order mode=build-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-134523 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 31, 2024
@craterbot
Copy link
Collaborator

🚧 Experiment pr-134523 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-134523 is completed!
📊 35438 regressed and 36 fixed (561988 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jan 1, 2025
@Skgland
Copy link
Contributor

Skgland commented Jan 1, 2025

I ran https://github.com/Skgland/Crater-Analysis to classify the build failed (unknown) regressions.

31091 contain error: internal compiler error: so are likly ICEs, from a small sample these are all in dependencies of the tested crate so likely not classified as a deps breakage due to the problem I am trying to fix in rust-lang/crater#758 .

85 failures appear to be due to running out of disk space,
either containing no space left on device or in one instance collect2: fatal error: ld terminated with signal 7 [Bus error]

Full report
Regressed: 35438
build failed(unknown): 31257
----------------------------------
Results:
E0277: 3
E0308: 3
E0422: 1
E0463: 1
E0557: 1
E0635: 28
compile_error!: 1
delimiter missmatch: 2
ice: 31091
include_bytes-missing-file: 7
include_str-missing-file: 11
linker-bus-error: 1
linker-missing-library: 18
linker-undefined-symbol: 7
missing-env-var: 1
no-space: 84
----------------------------------
sum: 31260
others: 16
----------------------------------
[
    (
        "Flying-Toast.lang.9586e323c23abf9a57dc074d09470eac07f59259",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/Flying-Toast.lang",
    ),
    (
        "JanBerktold.jute-rust.0a9a534599efa22a7c317c1b9963ac2438ac028b",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/JanBerktold.jute-rust",
    ),
    (
        "KavinduShamalka.rust_addnames.a7aeddf247ddc1e9cc4c357a8d229bd3ea69de59",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/KavinduShamalka.rust_addnames",
    ),
    (
        "Wopple.bookcase-rs.ce12f79a71946ea65b637b34773af863f1c034fd",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/Wopple.bookcase-rs",
    ),
    (
        "hardglitch.xmath.bda74b1d575c7c65e13558c361f26947597295aa",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/hardglitch.xmath",
    ),
    (
        "irreducible-io.term-rewriting.546119b6ecbd8ef8c0270bc7893e28d3286384e1",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/irreducible-io.term-rewriting",
    ),
    (
        "kirisaki.jit-compiler.5ceb89cb2a39b0f5cfe69ae1cb7944580f41eb89",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/kirisaki.jit-compiler",
    ),
    (
        "meddion.fugue.9ad7c4b881efcb66a6edde1681a01aadc4a12142",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/meddion.fugue",
    ),
    (
        "mii443.breakout-checker.62e4dabd9f7940cbf0bed01793284cf1bfe20b75",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/mii443.breakout-checker",
    ),
    (
        "raviqqe.stak.d6fa9052b0eea9e9276da15a1ac60e06b251ce1e",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/raviqqe.stak",
    ),
    (
        "scupit.gcmake-rust.50476479f7776605d30e7f1a40026c3a13e85d7b",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/scupit.gcmake-rust",
    ),
    (
        "ssav7912.rust-FreeD.6f1bbd038d6746ae06276034375dcba78453bef3",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/gh/ssav7912.rust-FreeD",
    ),
    (
        "bookcase_alloc-0.0.2",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/reg/bookcase_alloc-0.0.2",
    ),
    (
        "crypto-brainfuck-0.2.0",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/reg/crypto-brainfuck-0.2.0",
    ),
    (
        "protobuf3-2.27.2",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/reg/protobuf3-2.27.2",
    ),
    (
        "vec-with-gaps-0.7.0",
        "master%2311663cd3bfefef7d34e8f0892c250bf698049392%2Brustflags=-Dtail-expr-drop-order/reg/vec-with-gaps-0.7.0",
    ),
]

@compiler-errors
Copy link
Member

@bors try

Need to re-run crater after #134575 was merged

@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 Jan 8, 2025
@compiler-errors
Copy link
Member

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 8, 2025

📌 Commit c55eefe has been approved by nikomatsakis

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 Jan 8, 2025
@bors
Copy link
Contributor

bors commented Jan 8, 2025

⌛ Testing commit c55eefe with merge a580b5c...

@bors
Copy link
Contributor

bors commented Jan 8, 2025

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing a580b5c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 8, 2025
@bors bors merged commit a580b5c into rust-lang:master Jan 8, 2025
7 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 8, 2025
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a580b5c): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.3%, 0.6%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -3.1%, secondary -2.7%)

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)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) -3.1% [-3.1%, -3.1%] 1

Cycles

Results (primary -2.2%, secondary -2.8%)

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)
-2.2% [-3.6%, -0.8%] 11
Improvements ✅
(secondary)
-2.8% [-3.7%, -2.0%] 4
All ❌✅ (primary) -2.2% [-3.6%, -0.8%] 11

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 763.722s -> 763.382s (-0.04%)
Artifact size: 325.68 MiB -> 325.74 MiB (0.02%)

@@ -1149,6 +1161,61 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
error_reported
}

/// Through #123739, backward incompatible drops (BIDs) are introduced.
Copy link
Contributor

Choose a reason for hiding this comment

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

@dingxiangfei2009 A tiny late nit. I have just learned from this comment what BID stand for. Is it a commonly used acronym? I wasn't able to find it using a search engine. Could only find it disentangled here.

(thanks @lqd for the pointing me here)

@dingxiangfei2009
Copy link
Contributor Author

dingxiangfei2009 commented Jan 9, 2025 via email

@lqd
Copy link
Member

lqd commented Jan 9, 2025

note for t-release if the backport is approved: the backport will likely not apply cleanly due to landing after #133858. I hit similar conflicts when doing a revert, so the conflicting pieces will be present and fixed in #135263. (But if there are issues, dingxiangfei/errs/I should be able to prepare it for you.)

@apiraino
Copy link
Contributor

apiraino commented Jan 9, 2025

Beta backport accepted as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels handled by them.

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jan 9, 2025
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 11, 2025
@cuviper cuviper modified the milestones: 1.86.0, 1.85.0 Jan 11, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 11, 2025
[beta] stage0 bump and backports

- bump stage0 to 1.84.0
- Run borrowck tests on BIDs and emit tail-expr-drop-order lints for violations rust-lang#134523

r? cuviper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. L-tail_expr_drop_order Lint: tail_expr_drop_order 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible false-negative with tail-expr-drop-order