Skip to content

doc: replace exceeding_bitshifts with arithmetic_overflow - #162273

Open
chiang03 wants to merge 1 commit into
rust-lang:mainfrom
chiang03:main
Open

doc: replace exceeding_bitshifts with arithmetic_overflow#162273
chiang03 wants to merge 1 commit into
rust-lang:mainfrom
chiang03:main

Conversation

@chiang03

@chiang03 chiang03 commented Sep 4, 2026

Copy link
Copy Markdown

lint exceeding_bitshifts has been merged into arithmetic_overflow in PR #69185

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2026
@rustbot

rustbot commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

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:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 21 candidates

@rustbot

This comment has been minimized.

@Enselic Enselic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 default

After 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

View changes since this review

@rustbot rustbot 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 Sep 8, 2026
@rustbot

rustbot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@chiang03

chiang03 commented Sep 8, 2026

Copy link
Copy Markdown
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 Sep 8, 2026

@Enselic Enselic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.)

View changes since this review

|
2 | 100u8 << 10;
| ^^^^^^^^^^^ attempt to shift left with overflow
= note: `#[warn(arithmetic_overflow)]` on by default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When I run this locally it says deny and not warn. Does it say warn when you run locally?

Suggested change
= 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:01

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this section is "Capping lints", the command above is rustc lib.rs --cap-lints warn

@rustbot rustbot 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 Sep 8, 2026
@chiang03

chiang03 commented Sep 9, 2026

Copy link
Copy Markdown
Author

I was thinking about squashing these small commits!
but ended up not proactive do that without maintainer asking

@bors squash

@rustbot ready

@rust-bors

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>
@rust-bors

rust-bors Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🔨 2 commits were squashed into fe1c458.

@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 Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants