rust
rust copied to clipboard
const_prop_lint: Consider array length constant even if array is not
Fixes #98444.
r? @compiler-errors
(rust-highfive has picked a reviewer for you, use r? to override)
Some changes occurred to MIR optimizations
cc @rust-lang/wg-mir-opt
r? oli-obk
cc @JakobDegen
r? @oli-obk
@bors r+ rollup
:pushpin: Commit e4a4246a47b87630b1acc11b4140e044d606974e has been approved by oli-obk
It is now in the queue for this repository.
Failed in rollup: https://github.com/rust-lang/rust/pull/101016#issuecomment-1227892900 @bors r-
Some changes occurred in src/tools/clippy
cc @rust-lang/clippy
The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
IMAGE: x86_64-gnu-tools
##[endgroup]
From https://github.com/rust-lang/rust
* branch master -> FETCH_HEAD
Searching for toolstate changes between 2dc703fd6e3aaaf343828cc7dd1aec192d24c628 and c83902e575b2da5c0ce00966b6215feadda35d4b
Clippy or rustfmt subtrees were updated
##[group]Run src/ci/scripts/verify-channel.sh
src/ci/scripts/verify-channel.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
---
diff of stderr:
-error: this operation will panic at runtime
- --> $DIR/indexing_slicing_index.rs:23:5
- |
-LL | x[4]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays.
- | ^^^^ index out of bounds: the length is 4 but the index is 4
- |
- = note: `#[deny(unconditional_panic)]` on by default
-error: this operation will panic at runtime
- --> $DIR/indexing_slicing_index.rs:24:5
- |
- |
-LL | x[1 << 3]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays.
- | ^^^^^^^^^ index out of bounds: the length is 4 but the index is 8
-error: this operation will panic at runtime
- --> $DIR/indexing_slicing_index.rs:29:5
- |
- |
-LL | x[const { idx4() }]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays.
- | ^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 4 but the index is 4
-
error[E0080]: evaluation of `main::{constant#3}` failed
|
|
LL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
error[E0080]: erroneous constant used
--> $DIR/indexing_slicing_index.rs:31:5
|
|
LL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.
-error: this operation will panic at runtime
- --> $DIR/indexing_slicing_index.rs:35:5
- |
- |
-LL | y[4]; // Ok, rustc will handle references too.
- | ^^^^ index out of bounds: the length is 4 but the index is 4
-error: this operation will panic at runtime
- --> $DIR/indexing_slicing_index.rs:44:5
- |
- |
-LL | x[N]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays.
- | ^^^^ index out of bounds: the length is 4 but the index is 15
error: indexing may panic
--> $DIR/indexing_slicing_index.rs:22:5
|
LL | x[index];
LL | x[index];
| ^^^^^^^^
|
= note: `-D clippy::indexing-slicing` implied by `-D warnings`
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> $DIR/indexing_slicing_index.rs:38:5
|
LL | v[0];
LL | v[0];
| ^^^^
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> $DIR/indexing_slicing_index.rs:39:5
|
LL | v[10];
LL | v[10];
| ^^^^^
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> $DIR/indexing_slicing_index.rs:40:5
|
|
LL | v[1 << 3];
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> $DIR/indexing_slicing_index.rs:46:5
|
LL | v[N];
LL | v[N];
| ^^^^
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> $DIR/indexing_slicing_index.rs:47:5
|
LL | v[M];
LL | v[M];
| ^^^^
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
-error: aborting due to 13 previous errors
+error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0080`.
---
error: 1 errors occurred comparing output.
status: exit status: 1
error: test failed, to rerun pass '--test compile-test'
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "tests/ui/indexing_slicing_index.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui/indexing_slicing_index.stage-id" "-A" "unused" "--emit=metadata" "-Dwarnings" "-Zui-testing" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--extern" "tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-e0524b7e2611e851.rlib" "--extern" "rustc_semver=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/librustc_semver-963bbd3f89834643.rlib" "--extern" "itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-cdd893c121eb00e4.rlib" "--extern" "parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-4554cde6a1339e03.rlib" "--extern" "serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-4b46e2e2788394f2.rlib" "--extern" "clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-a74d54f3750f2f75.rlib" "--extern" "serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libserde_derive-eed8221ad604f845.so" "--extern" "clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-47229815ed3188f9.rlib" "--extern" "if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-03f75cdc6d4d3afc.rlib" "--extern" "quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-021aec868151835c.rlib" "--extern" "futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-e92c80438a94fde5.rlib" "--extern" "derive_new=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libderive_new-14dbc812a1f5dba0.so" "--extern" "syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-c6aa3eacac0eeebb.rlib" "--extern" "regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-619ac20e364f2b2c.rlib" "--edition=2021" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/test/ui/indexing_slicing_index.stage-id.aux"
------------------------------------------
------------------------------------------
stderr:
stderr:
------------------------------------------
{"message":"evaluation of `main::{constant#3}` failed","code":{"code":"E0080","explanation":"A constant value failed to get evaluated.\n\nErroneous code example:\n\n```compile_fail,E0080\nenum Enum {\n X = (1 << 500),\n Y = (1 / 0),\n}\n```\n\nThis error indicates that the compiler was unable to sensibly evaluate a\nconstant expression that had to be evaluated. Attempting to divide by 0\nor causing an integer overflow are two ways to induce this error.\n\nEnsure that the expressions given can be evaluated as the desired integer type.\n\nSee the [Custom Discriminants][custom-discriminants] section of the Reference\nfor more information about setting custom integer types on fieldless enums\nusing the [`repr` attribute][repr-attribute].\n\n[custom-discriminants]: https://doc.rust-lang.org/reference/items/enumerations.html#custom-discriminant-values-for-field-less-enumerations\n[repr-attribute]: https://doc.rust-lang.org/reference/type-layout.html#reprc-enums\n"},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":1157,"byte_end":1168,"line_start":31,"line_end":31,"column_start":14,"column_end":25,"is_primary":true,"text":[{"text":" const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.","highlight_start":14,"highlight_end":25}],"label":"index out of bounds: the length is 2 but the index is 4","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0080]: evaluation of `main::{constant#3}` failed\n --> tests/ui/indexing_slicing_index.rs:31:14\n |\nLL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.\n | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4\n\n"}
{"message":"erroneous constant used","code":{"code":"E0080","explanation":"A constant value failed to get evaluated.\n\nErroneous code example:\n\n```compile_fail,E0080\nenum Enum {\n X = (1 << 500),\n Y = (1 / 0),\n}\n```\n\nThis error indicates that the compiler was unable to sensibly evaluate a\nconstant expression that had to be evaluated. Attempting to divide by 0\nor causing an integer overflow are two ways to induce this error.\n\nEnsure that the expressions given can be evaluated as the desired integer type.\n\nSee the [Custom Discriminants][custom-discriminants] section of the Reference\nfor more information about setting custom integer types on fieldless enums\nusing the [`repr` attribute][repr-attribute].\n\n[custom-discriminants]: https://doc.rust-lang.org/reference/items/enumerations.html#custom-discriminant-values-for-field-less-enumerations\n[repr-attribute]: https://doc.rust-lang.org/reference/type-layout.html#reprc-enums\n"},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":1148,"byte_end":1170,"line_start":31,"line_end":31,"column_start":5,"column_end":27,"is_primary":true,"text":[{"text":" const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.","highlight_start":5,"highlight_end":27}],"label":"referenced constant has errors","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0080]: erroneous constant used\n --> tests/ui/indexing_slicing_index.rs:31:5\n |\nLL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.\n | ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors\n\n"}
{"message":"indexing may panic","code":{"code":"clippy::indexing_slicing","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":633,"byte_end":641,"line_start":22,"line_end":22,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":" x[index];","highlight_start":5,"highlight_end":13}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-D clippy::indexing-slicing` implied by `-D warnings`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"consider using `.get(n)` or `.get_mut(n)` instead","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: indexing may panic\n --> tests/ui/indexing_slicing_index.rs:22:5\n |\nLL | x[index];\n | ^^^^^^^^\n |\n = note: `-D clippy::indexing-slicing` implied by `-D warnings`\n = help: consider using `.get(n)` or `.get_mut(n)` instead\n\n"}
{"message":"indexing may panic","code":{"code":"clippy::indexing_slicing","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":1385,"byte_end":1389,"line_start":38,"line_end":38,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":" v[0];","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `.get(n)` or `.get_mut(n)` instead","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: indexing may panic\n --> tests/ui/indexing_slicing_index.rs:38:5\n |\nLL | v[0];\n | ^^^^\n |\n = help: consider using `.get(n)` or `.get_mut(n)` instead\n\n"}
{"message":"indexing may panic","code":{"code":"clippy::indexing_slicing","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":1395,"byte_end":1400,"line_start":39,"line_end":39,"column_start":5,"column_end":10,"is_primary":true,"text":[{"text":" v[10];","highlight_start":5,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `.get(n)` or `.get_mut(n)` instead","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: indexing may panic\n --> tests/ui/indexing_slicing_index.rs:39:5\n |\nLL | v[10];\n | ^^^^^\n |\n = help: consider using `.get(n)` or `.get_mut(n)` instead\n\n"}
{"message":"indexing may panic","code":{"code":"clippy::indexing_slicing","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":1406,"byte_end":1415,"line_start":40,"line_end":40,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":" v[1 << 3];","highlight_start":5,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `.get(n)` or `.get_mut(n)` instead","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: indexing may panic\n --> tests/ui/indexing_slicing_index.rs:40:5\n |\nLL | v[1 << 3];\n | ^^^^^^^^^\n |\n = help: consider using `.get(n)` or `.get_mut(n)` instead\n\n"}
{"message":"indexing may panic","code":{"code":"clippy::indexing_slicing","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":1636,"byte_end":1640,"line_start":46,"line_end":46,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":" v[N];","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `.get(n)` or `.get_mut(n)` instead","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: indexing may panic\n --> tests/ui/indexing_slicing_index.rs:46:5\n |\nLL | v[N];\n | ^^^^\n |\n = help: consider using `.get(n)` or `.get_mut(n)` instead\n\n"}
{"message":"indexing may panic","code":{"code":"clippy::indexing_slicing","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/indexing_slicing_index.rs","byte_start":1646,"byte_end":1650,"line_start":47,"line_end":47,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":" v[M];","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `.get(n)` or `.get_mut(n)` instead","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: indexing may panic\n --> tests/ui/indexing_slicing_index.rs:47:5\n |\nLL | v[M];\n | ^^^^\n |\n = help: consider using `.get(n)` or `.get_mut(n)` instead\n\n"}
{"message":"For more information about this error, try `rustc --explain E0080`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0080`.\n"}
------------------------------------------
Ping from triage: @TheWastl - can you post your status on this MR?
:umbrella: The latest upstream changes (presumably #102091) made this pull request unmergeable. Please resolve the merge conflicts.
@TheWastl Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this. Note: if you do please open the PR BEFORE you push to it, else you won't be able to reopen - this is a quirk of github. Thanks for your contribution.
@rustbot label: +S-inactive