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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

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

@craterbot
Copy link
Collaborator

🚧 Experiment pr-134523-1 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-1 is completed!
📊 984 regressed and 46 fixed (563652 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 5, 2025
@Skgland
Copy link
Contributor

Skgland commented Jan 5, 2025

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

Mostly Cycle Detection Errors, some running out of disk space, two ices and some other problems.

ICEs

Others:

  • rustc stack overflow
  • 2x error: a temporary value will be dropped here before the execution exits the block in Edition 2024, which will raise borrow checking error in dependencies
  • 3x (c)make can't build something due to some missing file
  • 3x linking fails due to missing file
  • cmake cannot create directory
  • docker no such file or directory
Full report
Regressed: 984
build failed(unknown): 527
----------------------------------
Results:
E0391: 388
ice: 2
no-space: 126
----------------------------------
sum: 516
others: 11
----------------------------------
[
    (
        "JakeDawkins.graphql-client-302-repro.0378a702e84d04a3d3a7b20fdfbbf3ce2d2e728c",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/JakeDawkins.graphql-client-302-repro",
    ),
    (
        "MoAlyousef.objectif.bd283ccd33e664b22fada4311f438c0e69d0ca40",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/MoAlyousef.objectif",
    ),
    (
        "dbydd.dawdle-todo-backend.fb1a455e344738cc2aca38fc7cf62f8a70314619",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/dbydd.dawdle-todo-backend",
    ),
    (
        "gnicod.earthel.d3fd147b82db0c7c034402ec6db1c9649b2cfaf5",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/gnicod.earthel",
    ),
    (
        "jhbruhn.ics-adapter.300a22f5ea1558967c8a8d1bd873c02a779ceffd",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/jhbruhn.ics-adapter",
    ),
    (
        "lfn3.pyru-graphql.47e488e25b1ace40f22401b90fd65dcbf2cbfe05",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/lfn3.pyru-graphql",
    ),
    (
        "llpghn.mqtt_monitor.88cd673821c0784719c85a29003670e138c4d85a",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/llpghn.mqtt_monitor",
    ),
    (
        "vasily-kirichenko.DropTest.9e4abfe0738df924002113d8859c50ea21cdd04e",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/gh/vasily-kirichenko.DropTest",
    ),
    (
        "dbus-executor-0.1.0",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/reg/dbus-executor-0.1.0",
    ),
    (
        "ministo-0.1.0",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/reg/ministo-0.1.0",
    ),
    (
        "wordexp-0.1.0",
        "try%2345e7e02865cae718624ebeb3feed6d2f7848b800%2Brustflags=-Dtail-expr-drop-order/reg/wordexp-0.1.0",
    ),
]

@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@compiler-errors
Copy link
Member

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 5, 2025
…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.
@bors
Copy link
Contributor

bors commented Jan 5, 2025

⌛ Trying commit 4749325 with merge 214d5c94d03280918aa7845a8377fe60924de7b4...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 5, 2025

☀️ Try build successful - checks-actions
Build commit: 214d5c9 (214d5c94d03280918aa7845a8377fe60924de7b4)

@compiler-errors
Copy link
Member

@craterbot run start=master#dcfa38fe234de9304169afc6638e81d0dd222c06+rustflags=-Dtail-expr-drop-order end=try#214d5c94d03280918aa7845a8377fe60924de7b4+rustflags=-Dtail-expr-drop-order mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-134523-2 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 Jan 5, 2025
@compiler-errors
Copy link
Member

I believe I've fixed the ICEs and the cycle errors, and I'll rerun crater on just the subset of failing crates.

@craterbot crates=https://crater-reports.s3.amazonaws.com/pr-134523-1/retry-regressed-list.txt

@craterbot
Copy link
Collaborator

📝 Configuration of the pr-134523-2 experiment changed.

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

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 6, 2025
…=chenyukang

A few borrowck tweaks to improve 2024 edition migration lints

See first two commits' changes to test outputs. Test coverage in this area is kinda weak, but I think it affects more cases than this (like the craters that will begin to trigger the `tail_expr_drop_order` tests in rust-lang#134523).

Third commit is a drive-by change that removes a deref hack from `UseSpans` which doesn't really improve diagnostics much.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L-tail_expr_drop_order Lint: tail_expr_drop_order S-waiting-on-crater Status: Waiting on a crater run to be completed. 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