- 17 5月, 2021 9 次提交
-
-
由 Ralf Jung 提交于
-
由 bors 提交于
Allow `async {}` expressions in const contexts Gated behind a new `const_async_blocks` feature.
-
由 bors 提交于
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
-
由 bors 提交于
rustc_codegen_ssa: only create backend `BasicBlock`s as-needed. Instead of creating one backend (e.g. LLVM) block per MIR block ahead of time, and then deleting the ones that weren't visited, this PR moves to creating the blocks as they're needed (either reached via the RPO visit, or used as the target of a branch from a different block). As deleting a block was the only `unsafe` builder method (generally we only *create* backend objects, not *remove* them), that's gone now and codegen is overall a bit safer. The only change in output is the order of LLVM blocks (which AFAIK has no semantic meaning, other than the first block being the entry block). This happens because the blocks are now created due to control-flow edges, rather than MIR block order. I'm making this a standalone PR because I keep getting wild perf results when I change *anything* in codegen, but if you want to read more about my plans in this area, see https://github.com/rust-lang/rust/pull/84771#issuecomment-830636256 (and https://github.com/rust-lang/rust/pull/84771#issue-628295651 - but that may be a bit outdated). (You may notice some of the APIs in this PR, like `append_block`, don't help with the future plans - but I didn't want to include the necessary refactors that pass a build around everywhere, in this PR, so it's a small compromise) r? `@nagisa` `@bjorn3`
-
由 Eduard-Mihai Burtescu 提交于
-
由 Eduard-Mihai Burtescu 提交于
-
由 bors 提交于
Fix unused attributes on macro_rules. The `unused_attributes` lint wasn't firing on attributes of `macro_rules` definitions. The consequence is that many attributes are silently ignored on `macro_rules`. The reason is that `unused_attributes` is a late-lint pass, and only has access to the HIR, which does not have macro_rules definitions. My solution here is to change `non_exported_macro_attrs` to be `macro_attrs` (a list of all attributes used for `macro_rules`, instead of just those for `macro_export`), and then to check this list in the `unused_attributes` lint. There are a number of alternate approaches, but this seemed the most reliable and least invasive. I am open to completely different approaches, though. One concern is that I don't fully understand the implications of extending `non_exported_macro_attrs` to include non-exported macros. That list was originally added in #62042 to handle stability attributes, so I suspect it was just an optimization since that was all that was needed. It was later extended to be included in SVH in #83901. #80641 also added a use to check for `invalid` attributes, which seems a little odd to me (it didn't validate non-exported macros, and seems highly specific). Overall, there doesn't seem to be a clear story of when `unused_attributes` should be used versus an error like E0518. I considered alternatively using an "allow list" of built-in attributes that can be used on macro_rules (allow, warn, deny, forbid, cfg, cfg_attr, macro_export, deprecated, doc), but I feel like that could be a pain to maintain. Some built-in attributes already present hard-errors when used with macro_rules. These are each hard-coded in various places: - `derive` - `test` and `bench` - `proc_macro` and `proc_macro_derive` - `inline` - `global_allocator` The primary motivation is that I sometimes see people use `#[macro_use]` in front of `macro_rules`, which indicates there is some confusion out there (evident that there was even a case of it in rustc).
-
由 Jonas Schievink 提交于
-
由 bors 提交于
Remove support for floating-point constants in asm! Floating-point constants aren't very useful anyways and this simplifies the code since the type check can now be done in typeck. cc `@rust-lang/wg-inline-asm` r? `@nagisa`
-
- 16 5月, 2021 16 次提交
-
-
由 bors 提交于
Reachable statics have reachable initializers Static initializer can read other statics. Initializers are evaluated at compile time, and so their content could become inlined into another crate. Ensure that initializers of reachable statics are also reachable. Previously, when an item incorrectly considered to be unreachable was reached from another crate an attempt would be made to codegen it. The attempt could fail with an ICE (in the case MIR wasn't available to do so) in some circumstances the attempt could also succeed resulting in a local codegen of non-local items, including static ones. Fixes #84455.
-
由 bors 提交于
rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads. This unblocks #84993 in terms of codegen tests, as it brings the MSVC-style (`cleanup_pad`) EH (LLVM) block order in line with the GNU-style (`landing_pad`) EH (LLVM) block order, by having both of them be on-demand (instead of MSVC-style being eager and GNU-style lazy/on-demand). It also unifies the two implementations a bit, similar to #84699, but in the opposite direction (as that attempt made both kinds of EH pads eagerly built). ~~Opening as draft because I haven't done enough Windows testing just yet, of both this PR, and of #84993 rebased on it.~~ (**EDIT**: seems to be working as expected) r? `@nagisa`
-
由 bors 提交于
CTFE validation: handle pointers in str I also finally learned how I can match *some* NOTEs in a ui test without matching all of them, and applied that to some const tests in the 2nd commit where I added NOTE because I did not know what I was doing. I can separate this into its own PR if you prefer. Fixes https://github.com/rust-lang/rust/issues/83182 r? `@oli-obk`
-
由 bors 提交于
rustdoc: Call `initSidebarItems` in root module of crate r? `@jsha` Resolves #85301
-
由 bors 提交于
Add asm!() support for PowerPC64 I was anticipating this to be difficult so I didn't do it as part of #84732... but this was pretty easy to do
👀 -
由 Amanieu d'Antras 提交于
-
由 bors 提交于
Check for inline assembly in THIR unsafeck #83129 was merged recently and added a THIR unsafe checker. This adds a check for inline assembly. (and this is 2x simpler than the MIR version, which has to check for `asm` and `llvm_asm` in two separate spots!) see also rust-lang/project-thir-unsafeck#7
-
由 Jonas Schievink 提交于
-
由 Eric Huss 提交于
-
由 bors 提交于
Do not allocate or unwind after fork ### Objective scenarios * Make (simple) panics safe in `Command::pre_exec_hook`, including most `panic!` calls, `Option::unwrap`, and array bounds check failures. * Make it possible to `libc::fork` and then safely panic in the child (needed for the above, but this requirement means exposing the new raw hook API which the `Command` implementation needs). * In singlethreaded programs, where panic in `pre_exec_hook` is already memory-safe, prevent the double-unwinding malfunction #79740. I think we want to make panic after fork safe even though the post-fork child environment is only experienced by users of `unsafe`, beause the subset of Rust in which any panic is UB is really far too hazardous and unnatural. #### Approach * Provide a way for a program to, at runtime, switch to having panics abort. This makes it possible to panic without making *any* heap allocations, which is needed because on some platforms malloc is UB in a child forked from a multithreaded program (see https://github.com/rust-lang/rust/pull/80263#issuecomment-774272370, and maybe also the SuS [spec](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html)). * Make that change in the child spawned by `Command`. * Document the rules comprehensively enough that a programmer has a fighting chance of writing correct code. * Test that this all works as expected (and in particular, that there aren't any heap allocations we missed) Fixes #79740 #### Rejected (or previously attempted) approaches * Change the panic machinery to be able to unwind without allocating, at least when the payload and message are both `'static`. This seems like it would be even more subtle. Also that is a potentially-hot path which I don't want to mess with. * Change the existing panic hook mechanism to not convert the message to a `String` before calling the hook. This would be a surprising change for existing code and would not be detected by the type system. * Provide a `raw_panic_hook` function to intercept panics in a way that doesn't allocate. (That was an earlier version of this MR.) ### History This MR could be considered a v2 of #80263. Thanks to everyone who commented there. In particular, thanks to `@m-ou-se,` `@Mark-Simulacrum` and `@hyd-dev.` (Tagging you since I think you might be interested in this new MR.) Compared to #80263, this MR has very substantial changes and additions. Additionally, I have recently (2021-04-20) completely revised this series following very helpful comments from `@m-ou-se.` r? `@m-ou-se`
-
由 bors 提交于
Remove some unncessary spaces from pretty-printed tokenstream output In addition to making the output look nicer for all crates, this also aligns the pretty-printing output with what the `rental` crate expects. This will allow us to eventually disable a backwards-compat hack in a follow-up PR. See https://github.com/rust-lang/rust/issues/84428 for some background information about why we want to make this change. Note that this change would be desirable (but not particularly necessary) even if `rental` didn't exist, so we're not adding any crate-specific hacks into the compiler.
-
由 bors 提交于
Rollup of 4 pull requests Successful merges: - #84751 (str::is_char_boundary - slight optimization) - #85185 (Generate not more docs than necessary) - #85324 (Warn about unused `pub` fields in non-`pub` structs) - #85329 (fix version_str comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
-
由 Justus K 提交于
-
由 Ralf Jung 提交于
-
由 Aaron Hill 提交于
In addition to making the output look nicer for all crates, this also aligns the pretty-printing output with what the `rental` crate expects. This will allow us to eventually disable a backwards-compat hack in a follow-up PR.
-
由 Ralf Jung 提交于
-
- 15 5月, 2021 15 次提交
-
-
由 Guillaume Gomez 提交于
fix version_str comment This version string is ultimately generated here https://github.com/rust-lang/rust/blob/87423fbc6af5aae2b5f6d0a11f2a0c60c7c22e98/src/bootstrap/channel.rs#L72 and I don't think it includes the `rustc` prefix. That also matches its use here https://github.com/rust-lang/rust/blob/ac923d94f86a6f7c881ecbedcd0a68d7986a35bd/compiler/rustc_driver/src/lib.rs#L758
-
由 Guillaume Gomez 提交于
Warn about unused `pub` fields in non-`pub` structs This pull request fixes #85255. The current implementation of dead code analysis is too prudent because it marks all `pub` fields of structs as live, even though they cannot be accessed from outside of the current crate if the struct itself only has restricted or private visibility. I have changed this behavior to take the containing struct's visibility into account when looking at field visibility and liveness. This also makes dead code warnings more consistent; consider the example given in #85255: ```rust struct Foo { a: i32, pub b: i32, } struct Bar; impl Bar { fn a(&self) -> i32 { 5 } pub fn b(&self) -> i32 { 6 } } fn main() { let _ = Foo { a: 1, b: 2 }; let _ = Bar; } ``` Current nightly already warns about `Bar::b()`, even though it is `pub` (but `Bar` is not). It should therefore also warn about `Foo::b`, which it does with the changes in this PR.
-
由 Guillaume Gomez 提交于
Generate not more docs than necessary This is something that `@Nemo157` was talking about: they wanted that when using `x.py doc std`, it only generated `std` (and the crates "before" it). r? `@Mark-Simulacrum`
-
由 Guillaume Gomez 提交于
str::is_char_boundary - slight optimization Current `str::is_char_boundary` implementation emits slightly more instructions, because it includes an additional branch for `index == s.len()` ```rust pub fn is_char_boundary(s: &str, index: usize) -> bool { if index == 0 || index == s.len() { return true; } match s.as_bytes().get(index) { None => false, Some(&b) => (b as i8) >= -0x40, } } ``` Just changing the place of `index == s.len()` merges it with `index < s.len()` from `s.as_bytes().get(index)` ```rust pub fn is_char_boundary2(s: &str, index: usize) -> bool { if index == 0 { return true; } match s.as_bytes().get(index) { // For some reason, LLVM likes this comparison here more None => index == s.len(), // This is bit magic equivalent to: b < 128 || b >= 192 Some(&b) => (b as i8) >= -0x40, } } ``` This one has better codegen on every platform, except powerpc <details><summary>x86 codegen</summary> <p> ```nasm example::is_char_boundary: mov al, 1 test rdx, rdx je .LBB0_5 cmp rsi, rdx je .LBB0_5 cmp rsi, rdx jbe .LBB0_3 cmp byte ptr [rdi + rdx], -65 setg al .LBB0_5: ret .LBB0_3: xor eax, eax ret example::is_char_boundary2: test rdx, rdx je .LBB1_1 cmp rsi, rdx jbe .LBB1_4 cmp byte ptr [rdi + rdx], -65 setg al ret .LBB1_1: ; technically this branch is the same as LBB1_4 mov al, 1 ret .LBB1_4: sete al ret ``` </p> </details> <details><summary>aarch64 codegen</summary> <p> ```as example::is_char_boundary: mov x8, x0 mov w0, #1 cbz x2, .LBB0_4 cmp x1, x2 b.eq .LBB0_4 b.ls .LBB0_5 ldrsb w8, [x8, x2] cmn w8, #65 cset w0, gt .LBB0_4: ret .LBB0_5: mov w0, wzr ret example::is_char_boundary2: cbz x2, .LBB1_3 cmp x1, x2 b.ls .LBB1_4 ldrsb w8, [x0, x2] cmn w8, #65 cset w0, gt ret .LBB1_3: mov w0, #1 ret .LBB1_4: cset w0, eq ret ``` </p> </details> <details><summary>riscv64gc codegen</summary> <p> example::is_char_boundary: seqz a3, a2 xor a4, a1, a2 seqz a4, a4 or a4, a4, a3 addi a3, zero, 1 bnez a4, .LBB0_3 bgeu a2, a1, .LBB0_4 add a0, a0, a2 lb a0, 0(a0) addi a1, zero, -65 slt a3, a1, a0 .LBB0_3: mv a0, a3 ret .LBB0_4: mv a0, zero ret example::is_char_boundary2: beqz a2, .LBB1_3 bgeu a2, a1, .LBB1_4 add a0, a0, a2 lb a0, 0(a0) addi a1, zero, -65 slt a0, a1, a0 ret .LBB1_3: addi a0, zero, 1 ret .LBB1_4: xor a0, a1, a2 seqz a0, a0 ret </p> </details> [Link to godbolt](https://godbolt.org/z/K8avEz8Gr) `@rustbot` label: A-codegen
-
由 Guillaume Gomez 提交于
-
由 bors 提交于
Convert rustfmt from a submodule to a subtree r? `@calebcartwright` cc `@Manishearth` `@Mark-Simulacrum` The motivation is that submodule updates cause rustfmt to not be available on nightly a lot; most recently it was unavailable for over 10 days, causing the beta release to be delayed. Additionally this is much less work on the part of the rustfmt maintainers to keep the rustfmt compiling, since now people making breaking changes will be responsible for fixing them. I kept the rustfmt git history so it looks like there are thousands of commits. The important commits are https://github.com/rust-lang/rust/compare/851dee3af9404bf399c3c4ffefe5105edb3debad~..pull/82208/head. This adds about 10 MB of git history, which is not terribly much compared to the 702 MB that already exist. - Add `src/tools/rustfmt` to `x.py check` - Fix CRLF issues with rustfmt tests (see commit for details) - Use `rustc_private` instead of crates.io dependencies This was already switched upstream and would have landed in the next submodule bump anyway. This just updates Cargo.lock for rust-lang/rust. - Add `yansi-term` to the list of allowed dependencies. This is a false positive - rustc doesn't actually use it, only rustfmt, but because it's activated by the cargo feature of a dependency, tidy gets confused. It's fairly innocuous in any case, it's used for color printing. This would have happened in the next submodule bump. - Remove rustfmt from the list of toolstate tools. - Give a hard error if testing or building rustfmt fails. - Update log to 0.4.14 This avoids a warning about semicolons in macros; see the commit for details. - Don't add tools to the sysroot when they finish building. This is the only change that could be considered a regression - this avoids a "colliding StableCrateId" error due to a bug in resolve (https://github.com/rust-lang/rust/issues/56935). The regression is that this rebuilds dependencies more often than strictly necessary. See the commit for details. Fixes https://github.com/rust-lang/rust/issues/85226 (permanently). Closes https://github.com/rust-lang/rust/issues/82385. Helps with https://github.com/rust-lang/rust/issues/70651. Helps with https://github.com/rust-lang/rust/issues/80639.
-
由 Ralf Jung 提交于
-
由 Ralf Jung 提交于
-
由 bors 提交于
Rollup of 12 pull requests Successful merges: - #84461 (rustdoc: Remove unnecessary `StripItem` wrapper) - #85067 (Minimize amount of fake `DefId`s used in rustdoc) - #85207 (Fix typo in comment) - #85215 (coverage bug fixes and some refactoring) - #85221 (dbg macro: Discuss use in tests, and slightly clarify) - #85246 (Miner code formatting) - #85253 (swap function order for better read flow) - #85256 (Fix display for "implementors" section) - #85268 (Use my real name) - #85278 (Improve match statements) - #85289 (Fix toggle position on mobile) - #85323 (Fix eslint errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
-
由 Ralf Jung 提交于
-
由 Guillaume Gomez 提交于
Fix eslint errors I cherry-picked the two non-CI commits from #85285. r? ```@jsha```
-
由 Guillaume Gomez 提交于
Fix toggle position on mobile Before: ![Screenshot from 2021-05-14 14-21-27](https://user-images.githubusercontent.com/3050060/118276475-fe210300-b4c7-11eb-94f8-4e2a4e10d91e.png) ![Screenshot from 2021-05-14 14-21-30](https://user-images.githubusercontent.com/3050060/118276479-feb99980-b4c7-11eb-85db-40e9df6e9abd.png) After: ![Screenshot from 2021-05-14 15-16-54](https://user-images.githubusercontent.com/3050060/118276494-0416e400-b4c8-11eb-9479-d447928cfa62.png) ![Screenshot from 2021-05-14 15-16-59](https://user-images.githubusercontent.com/3050060/118276498-0416e400-b4c8-11eb-99f6-894276c62dfc.png) r? ```@jsha```
-
由 Guillaume Gomez 提交于
Improve match statements
-
由 Guillaume Gomez 提交于
Use my real name
-
由 Guillaume Gomez 提交于
Fix display for "implementors" section Just saw this problem when going through docs: ![Screenshot from 2021-05-13 15-20-52](https://user-images.githubusercontent.com/3050060/118131978-766fc180-b3ff-11eb-86a8-7f6d22afa675.png) This fix puts it back to normal: ![Screenshot from 2021-05-13 15-23-29](https://user-images.githubusercontent.com/3050060/118132006-7e2f6600-b3ff-11eb-9985-025a7b7c5216.png) You can see it on the `TryFrom` page for example. r? ```@Nemo157```
-