Comments (4)
I think that if you want this you should write
fn test<const SIZE: usize>() {
- if SIZE < 4096 {
+ if const { SIZE < 4096 } {
so that rust will know it's a constant, and be more likely to give you the behaviour you want in unoptimized builds.
(Or make your own trait so it can be <[u8; 4096]>::IS_SMALL
or something if you need an older MSRV.)
Anything else will just mean exactly the same bug comes back if you write it as SIZE.ilog2() < 12
instead, but if you write const { SIZE.ilog2() < 12 }
that'd be fine again.
from rust.
@saethlin informed me that this is an issue with his mono-reachable traversal implementation.
from rust.
I know that when I initially worked on this I searched the generated LLVM IR for the special "No predecessors!" comment that LLVM leaves on such orphaned basic blocks. There are a lot and I think I concluded they were all not actionable.
Clearly this case is.
There are actually two bugs here:
-
The mono-reachable traverasal only looks for a constant SwitchInt param coming from
Rvalue::Use
andRvalue::UbChecks
. In this case, we haveRvalue::BinOp
. GVN could fix this, but only iftest
were inlined or we had post-mono MIR optimizations. So I lean towards it being worthwhile to teach mono-reachable traversal about this. -
Even if we get the traversal right (this can be simulated by wrapping the comparison in an inline const) we still have an alloca for the argument, because we don't set up locals based on reachability.
from rust.
@scottmcm That doesn't work, either. See version 1.80.0 or version 1.82.0-nightly on Compiler Explorer.
from rust.
Related Issues (20)
- [ICE] adding a def'n for node-id NodeId(130468) and def kind AnonConst but a previous def'n exists HOT 3
- #[inline(never)] does not work for async functions HOT 3
- `unreachable_patterns` fires on match arm that can't be removed. HOT 3
- Compiler doesn't realize that all match cases are covered HOT 3
- Error message suggests to use a Box to wrap dyn Trait when it's unnecessary
- Compiler can't infer &str type when &String is inserted first in a collection with tuples HOT 1
- Integer literal type inference causes weird behavior including strange compiler diagnostic (but the suggestion is working).
- `dylib-soname` run-make test is not language independant HOT 3
- Add some docs for tidy
- ICE with higher order associated types HOT 5
- Tracking Issue for unbounded_shifts
- rust-analyzer compiler error (not issue with code) HOT 2
- Closure Fn* trait coercion removes other implementable Fn* traits HOT 3
- run-make: fix `run_make_support::fs::create_symlink` API and audit symlink usages in rmake.rs tests HOT 1
- run-make: audit tests that codegen for specific targets HOT 1
- Tracking Issue for `new_zeroed_alloc`
- Tracking Issue for `box_uninit_write`
- wasip2 uses wasi:random/random to generate hashmap_random_keys
- `refining_impl_trait` suggestion in invalid code
- error: linking with x86_64-w64-mingw32-gcc failed: exit code: 1
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.