Comments (3)
curr
is initialized tobuf.len()
, and is only ever decremented, so as long as the decrements do not overflow,&buf[curr..]
cannot panic.
It's OK that it won't panic in practice, but the compiler is unable to prove it, so it is generating the panic code and linking with panic-related functionality which is desirable to avoid. That is, using crates such as no_panics_whatsoever or similar functionality by other means won't work.
from rust.
curr
is initialized to buf.len()
, and is only ever decremented, so as long as the decrements do not overflow, &buf[curr..]
cannot panic.
buf
has length 128, and curr
is decremented exactly once for each digit, so for curr
to overflow would require that the number to be formatted have more that 128 digits in the particular base (2, 8, or 16), which is currently not possible since u128
is the largest fixed-width integer type, and usize::BITS <= 64
on all currently supported platforms.
I suppose a const _: () = assert!(T::BITS <= 128)
or similar could be added to this code to ensure that any future platform with usize::BITS > 128
would fail to compile unless this code was updated to account for it, (but I imagine there are several other places in the standard library which makes a similar assumption).
from rust.
@rustbot label -needs-triage +T-libs +A-panic +C-enhancement
from rust.
Related Issues (20)
- compile fail when using async_drop HOT 2
- Compiler Error E0530 When Shadowing None with mut keyword HOT 2
- `remove_dir_all` fails removing directores (with subdirectories) on network drives (SFTP) under windows HOT 28
- Two subsequent labels and unnecessary `jmp` with `opt-level=s` HOT 2
- Can the rust/build/x86_64-unknown-linux-gnu/stage0 directory be generated without network? HOT 2
- Strange TcpStream TTL type implementation (set_ttl/ttl) HOT 6
- Lint against using `libc::c_*` types in std if they're also avaliable in `core::ffi`
- `std::process::exit` is not thread-safe HOT 20
- compiletest: `./x test <test-name>.stderr` (or existing non-`.rs` file) should warn or error
- rustc hangs / infinite loop on small example with generic_const_exprs and specialization HOT 1
- integer_decode() for float: example usage in docs doesn't make sense HOT 1
- Confusing "Mismatched types" error due to unsatisfied trait bound HOT 3
- Tracking Issue for `x86_amx_intrinsics`
- Tracking Issue for `x86_sha512_sm`
- `#[coverage(..)]` attribute should apply recursively to nested functions/methods/closures HOT 1
- Coverage spans should not overlap nested items HOT 1
- rust lang analyzer is not working in vs code.
- `debuginfo` test suite shows zero tests being executed if pre-requisites are missing
- rust_eh_personality already defined in dynamic library HOT 5
- Tracking Issue for `#![feature(externally_constructed_attr)]`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.