-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollup of 6 pull requests #74084
Rollup of 6 pull requests #74084
Commits on Jul 2, 2020
-
Configuration menu - View commit details
-
Copy full SHA for ec31b4e - Browse repository at this point
Copy the full SHA ec31b4eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 84282fd - Browse repository at this point
Copy the full SHA 84282fdView commit details -
mir: mark mir construction temporaries as internal
This commit marks temporaries from MIR construction as internal such that they are skipped in `sanitize_witness` (where each MIR local is checked to have been contained within the generator interior computed during typeck). This resolves an ICE whereby the construction of checked addition introduced a `(u64, bool)` temporary which was not in the HIR and thus not in the generator interior. Signed-off-by: David Wood <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 1b747a0 - Browse repository at this point
Copy the full SHA 1b747a0View commit details -
Move A|Rc::as_ptr from feature(weak_into_raw)
to feature(rc_as_ptr) These were stabilized alongside the Weak versions, but having `feature = "weak_.."` on a fn definition for the non-weak pointers is potentially very confusing.
Configuration menu - View commit details
-
Copy full SHA for 7391bf8 - Browse repository at this point
Copy the full SHA 7391bf8View commit details
Commits on Jul 5, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 54d95ed - Browse repository at this point
Copy the full SHA 54d95edView commit details -
Configuration menu - View commit details
-
Copy full SHA for c3fc4f0 - Browse repository at this point
Copy the full SHA c3fc4f0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 751b594 - Browse repository at this point
Copy the full SHA 751b594View commit details -
Configuration menu - View commit details
-
Copy full SHA for 319c7f7 - Browse repository at this point
Copy the full SHA 319c7f7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8a2e376 - Browse repository at this point
Copy the full SHA 8a2e376View commit details
Commits on Jul 6, 2020
-
Always resolve type@primitive as a primitive, not a module
Previously, if there were a module in scope with the same name as the primitive, that would take precedence. Coupled with rust-lang#58699, this made it impossible to link to the primitive when that module was in scope. This approach could be extended so that `struct@foo` would no longer resolve to any type, etc. However, it could not be used for glob imports: ```rust pub mod foo { pub struct Bar; } pub enum Bar {} use foo::*; // This is expected to link to `inner::Bar`, but instead it will link to the enum. /// Link to [struct@Bar] pub struct MyDocs; ``` The reason for this is that this change does not affect the resolution algorithm of rustc_resolve at all. The only reason we could special-case primitives is because we have a list of all possible primitives ahead of time.
Configuration menu - View commit details
-
Copy full SHA for e46c187 - Browse repository at this point
Copy the full SHA e46c187View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6cef103 - Browse repository at this point
Copy the full SHA 6cef103View commit details -
Rollup merge of rust-lang#70835 - yoshuawuyts:int-log2, r=dtolnay
Add Integer::checked_{log,log2,log10} This implements `{log,log2,log10}` methods for all integer types. The implementation was provided by @substack for use in the stdlib. _Note: I'm not big on math, so this PR is a best effort written with limited knowledge. It's likely I'll be getting things wrong, but happy to learn and correct. Please bare with me._ ## Motivation Calculating the logarithm of a number is a generally useful operation. Currently the stdlib only provides implementations for floats, which means that if we want to calculate the logarithm for an integer we have to cast it to a float and then back to an int. > would be nice if there was an integer log2 instead of having to either use the f32 version or leading_zeros() which i have to verify the results of every time to be sure _— [@substack, 2020-03-08](https://twitter.com/substack/status/1236445105197727744)_ At higher numbers converting from an integer to a float we also risk overflows. This means that Rust currently only provides log operations for a limited set of integers. The process of doing log operations by converting between floats and integers is also prone to rounding errors. In the following example we're trying to calculate `base10` for an integer. We might try and calculate the `base2` for the values, and attempt [a base swap](https://www.rapidtables.com/math/algebra/Logarithm.html#log-rules) to arrive at `base10`. However because we're performing intermediate rounding we arrive at the wrong result: ```rust // log10(900) = ~2.95 = 2 dbg!(900f32.log10() as u64); // log base change rule: logb(x) = logc(x) / logc(b) // log2(900) / log2(10) = 9/3 = 3 dbg!((900f32.log2() as u64) / (10f32.log2() as u64)); ``` _[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6bd6c68b3539e400f9ca4fdc6fc2eed0)_ This is somewhat nuanced as a lot of the time it'll work well, but in real world code this could lead to some hard to track bugs. By providing correct log implementations directly on integers we can help prevent errors around this. ## Implementation notes I checked whether LLVM intrinsics existed before implementing this, and none exist yet. ~~Also I couldn't really find a better way to write the `ilog` function. One option would be to make it a private method on the number, but I didn't see any precedent for that. I also didn't know where to best place the tests, so I added them to the bottom of the file. Even though they might seem like quite a lot they take no time to execute.~~ ## References - [Log rules](https://www.rapidtables.com/math/algebra/Logarithm.html#log-rules) - [Rounding error playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6bd6c68b3539e400f9ca4fdc6fc2eed0) - [substack's tweet asking about integer log2 in the stdlib](https://twitter.com/substack/status/1236445105197727744) - [Integer Logarithm, A. Jaffer 2008](https://people.csail.mit.edu/jaffer/III/ilog.pdf)
Configuration menu - View commit details
-
Copy full SHA for b2fe1f8 - Browse repository at this point
Copy the full SHA b2fe1f8View commit details -
Rollup merge of rust-lang#73953 - JohnTitor:audit-hidden-sugg, r=este…
…bank Audit hidden/short code suggestions Should fix rust-lang#73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
Configuration menu - View commit details
-
Copy full SHA for bab8b12 - Browse repository at this point
Copy the full SHA bab8b12View commit details -
Rollup merge of rust-lang#73969 - davidtwco:issue-73914-checkedadd-te…
…mp-generator-interior, r=matthewjasper mir: mark mir construction temporaries as internal Fixes rust-lang#73914. This PR marks temporaries from MIR construction as internal such that they are skipped in `sanitize_witness` (where each MIR local is checked to have been contained within the generator interior computed during typeck). This resolves an ICE whereby the construction of checked addition introduced a `(u64, bool)` temporary which was not in the HIR and thus not in the generator interior. r? @matthewjasper
Configuration menu - View commit details
-
Copy full SHA for 3e5c248 - Browse repository at this point
Copy the full SHA 3e5c248View commit details -
Rollup merge of rust-lang#73974 - CAD97:rc-no-weak, r=dtolnay
Move A|Rc::as_ptr from feature(weak_into_raw) to feature(rc_as_ptr) These were stabilized alongside the Weak versions, but having `feature = "weak_.."` on a fn definition for the non-weak pointers is potentially very misleading, especially in a review context where the impl header may not be immediately visible. r? @RalfJung @bors rollup=always
Configuration menu - View commit details
-
Copy full SHA for 0fa3647 - Browse repository at this point
Copy the full SHA 0fa3647View commit details -
Rollup merge of rust-lang#74059 - RalfJung:miri-uninit-validation, r=…
…oli-obk Miri value validation: fix handling of uninit memory Fixes rust-lang/miri#1456 Fixes rust-lang/miri#1467 r? @oli-obk
Configuration menu - View commit details
-
Copy full SHA for 2b3bc21 - Browse repository at this point
Copy the full SHA 2b3bc21View commit details -
Rollup merge of rust-lang#74078 - jyn514:lut, r=Manishearth
Always resolve type@primitive as a primitive, not a module Previously, if there were a module in scope with the same name as the primitive, that would take precedence. Coupled with rust-lang#58699, this made it impossible to link to the primitive when that module was in scope. This approach could be extended so that `struct@foo` would no longer resolve to any type, etc. However, it could not be used for glob imports: ```rust pub mod foo { pub struct Bar; } pub enum Bar {} use foo::*; // This is expected to link to `inner::Bar`, but instead it will link to the enum. /// Link to [struct@Bar] pub struct MyDocs; ``` The reason for this is that this change does not affect the resolution algorithm of rustc_resolve at all. The only reason we could special-case primitives is because we have a list of all possible primitives ahead of time. Closes rust-lang#74063 r? @Manishearth
Configuration menu - View commit details
-
Copy full SHA for 346a147 - Browse repository at this point
Copy the full SHA 346a147View commit details