doc: replace exceeding_bitshifts with arithmetic_overflow - #162273
doc: replace exceeding_bitshifts with arithmetic_overflow#162273chiang03 wants to merge 1 commit into
exceeding_bitshifts with arithmetic_overflow#162273Conversation
|
Thanks for the pull request, and welcome! The Rust Project has assigned @Enselic (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Thanks!
I've verified this fix with:
$ git diff
diff --git a/src/doc/rustc/src/lints/levels.md b/src/doc/rustc/src/lints/levels.md
index 5b23ac9e09c..70b5e279a3d 100644
--- a/src/doc/rustc/src/lints/levels.md
+++ b/src/doc/rustc/src/lints/levels.md
@@ -106,7 +106,7 @@ level is capped via cap-lints.
A 'deny' lint produces an error if you violate it. For example, this code
runs into the `exceeding_bitshifts` lint.
-```rust,no_run
+```rust
fn main() {
100u8 << 10;
}
$ ./x test src/doc/rustc -- src/lints/levels.md
error: this arithmetic operation will overflow
--> /home/martin/src/rust/src/doc/rustc/src/lints/levels.md:111:5
|
111 | 100u8 << 10;
| ^^^^^^^^^^^ attempt to shift left by `10_i32`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by defaultAfter making necessary adjustments, this PR is exactly what we end up with.
It would be nice if the rustdoc tests would work the same as regular rustc tests where the test framework compares actual stderr with expected stderr, but AFAIK that does not exist.
One thing though, would you mind also updating the example a bit further down? That way we get rid of all remaining mentions of the obsolete exceeding_bitshifts lint:
$ git grep exceeding_bitshifts
compiler/rustc_lint/src/lib.rs: store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
src/doc/rustc/src/lints/levels.md:runs into the `exceeding_bitshifts` lint.
src/doc/rustc/src/lints/levels.md: = note: `#[deny(exceeding_bitshifts)]` on by default
src/doc/rustc/src/lints/levels.md: = note: `#[warn(exceeding_bitshifts)]` on by default|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot ready |
There was a problem hiding this comment.
Thank you. One more comment though.
Also, you currently have this as two commits. In general I am a big fan of splitting up changes in self-contained, logical commits, but in this case I think a single commit is more appropriate (see the "commit history clean" checklist item in the compiler review policy) . Would you mind squashing the commits together, please? (I wouldn't bother asking if I had no other comments.)
| | | ||
| 2 | 100u8 << 10; | ||
| | ^^^^^^^^^^^ attempt to shift left with overflow | ||
| = note: `#[warn(arithmetic_overflow)]` on by default |
There was a problem hiding this comment.
When I run this locally it says deny and not warn. Does it say warn when you run locally?
| = note: `#[warn(arithmetic_overflow)]` on by default | |
| = note: `#[deny(arithmetic_overflow)]` on by default |
my output
$ git diff
diff --git a/src/doc/rustc/src/lints/levels.md b/src/doc/rustc/src/lints/levels.md
index 5b23ac9e09c..2274b70c509 100644
--- a/src/doc/rustc/src/lints/levels.md
+++ b/src/doc/rustc/src/lints/levels.md
@@ -106,7 +106,7 @@ level is capped via cap-lints.
A 'deny' lint produces an error if you violate it. For example, this code
runs into the `exceeding_bitshifts` lint.
-```rust,no_run
+```rust
fn main() {
100u8 << 10;
}
@@ -296,7 +296,7 @@ pub fn get_path() -> PathBuf {
This is the maximum level for all lints. So for example, if we take our
code sample from the "deny" lint level above:
-```rust,no_run
+```rust
fn main() {
100u8 << 10;
}
$ ./x test src/doc/rustc -- src/lints/levels.md
Building bootstrap
Finished `dev` profile [unoptimized] target(s) in 0.06s
/home/martin/src/rust/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building stage1 compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
Finished `release` profile [optimized + debuginfo] target(s) in 0.21s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 lld-wrapper (stage0 -> stage1, x86_64-unknown-linux-gnu)
Finished `release` profile [optimized + debuginfo] target(s) in 0.08s
Building stage1 library artifacts (stage1 -> stage1, x86_64-unknown-linux-gnu)
Finished `dist` profile [optimized + debuginfo] target(s) in 0.03s
Testing stage1 book rustc (x86_64-unknown-linux-gnu)
Building stage1 rustdoc_tool_binary (stage0 -> stage1, x86_64-unknown-linux-gnu)
Finished `release` profile [optimized + debuginfo] target(s) in 0.13s
Command `/home/martin/src/rust/build/bootstrap/debug/rustdoc -Wrustdoc::invalid_codeblock_attributes -Znormalize-docs -Z unstable-options --test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md --test-args src/lints/levels.md` failed with exit code 101
Created at: src/bootstrap/src/core/builder/mod.rs:1524:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:3178:13
--- STDOUT vvv
running 12 tests
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Priority_of_lint_level_sources (line 370) - compile fail ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Priority_of_lint_level_sources (line 346) - compile fail ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::deny (line 109) ... FAILED
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Configuring_warning_levels::Capping_lints (line 299) ... FAILED
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Configuring_warning_levels::Via_an_attribute (line 263) ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Priority_of_lint_level_sources (line 400) ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::warn (line 76) ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::allow (line 21) ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Priority_of_lint_level_sources (line 423) ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Configuring_warning_levels::Via_an_attribute (line 271) ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Configuring_warning_levels::Via_an_attribute (line 282) ... ok
test /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::expect (line 45) ... ok
failures:
---- /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::deny (line 109) stdout ----
error: this arithmetic operation will overflow
--> /home/martin/src/rust/src/doc/rustc/src/lints/levels.md:111:5
|
111 | 100u8 << 10;
| ^^^^^^^^^^^ attempt to shift left by `10_i32`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: aborting due to 1 previous error
Couldn't compile the test.
---- /home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Configuring_warning_levels::Capping_lints (line 299) stdout ----
error: this arithmetic operation will overflow
--> /home/martin/src/rust/src/doc/rustc/src/lints/levels.md:301:5
|
301 | 100u8 << 10;
| ^^^^^^^^^^^ attempt to shift left by `10_i32`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: aborting due to 1 previous error
Couldn't compile the test.
failures:
/home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::Configuring_warning_levels::Capping_lints (line 299)
/home/martin/src/rust/src/doc/rustc/src/lints/levels.md - Lint_Levels::deny (line 109)
test result: FAILED. 10 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.16s
--- STDERR vvv
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:00:01There was a problem hiding this comment.
this section is "Capping lints", the command above is rustc lib.rs --cap-lints warn
This comment has been minimized.
This comment has been minimized.
* doc: replace `exceeding_bitshifts` with `arithmetic_overflow` * replace another mention of `exceeding_bitshifts`, which is the only one left Co-authored-by: Cheng-Han Chiang <chiangchenghan03@gmail.com>
|
🔨 2 commits were squashed into fe1c458. |
lint
exceeding_bitshiftshas been merged intoarithmetic_overflowin PR #69185