1. 17 5月, 2021 9 次提交
    • R
      remove size field from Allocation · 7962b5ae
      Ralf Jung 提交于
      7962b5ae
    • B
      Auto merge of #85353 - jonas-schievink:async-blocks-in-ctfe, r=oli-obk · 44ec846f
      bors 提交于
      Allow `async {}` expressions in const contexts
      
      Gated behind a new `const_async_blocks` feature.
      44ec846f
    • B
      Auto merge of #85178 - cjgillot:local-crate, r=oli-obk · 3396a383
      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.
      3396a383
    • B
      Auto merge of #84993 - eddyb:cg-ssa-on-demand-blocks, r=nagisa · a55748ff
      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`
      a55748ff
    • E
    • E
    • B
      Auto merge of #85312 - ehuss:macro_use-unused-attr, r=petrochenkov · fe72845f
      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).
      fe72845f
    • J
      Add tracking issue · 014e8d46
      Jonas Schievink 提交于
      014e8d46
    • B
      Auto merge of #85290 - Amanieu:asm_const_int, r=nagisa · 7dc9ff5c
      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`
      7dc9ff5c
  2. 16 5月, 2021 16 次提交
    • B
      Auto merge of #84549 - tmiasko:static-initializer, r=varkor · f8e1e923
      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.
      f8e1e923
    • B
      Auto merge of #85316 - eddyb:cg-ssa-on-demand-cleanuppad, r=nagisa · 747a5d2a
      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`
      747a5d2a
    • B
      Auto merge of #85332 - RalfJung:ptr-in-str, r=oli-obk · 3f46b82d
      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`
      3f46b82d
    • B
      Auto merge of #85304 - Stupremee:crates-in-sidebar-in-root, r=Nemo157 · 94ecdfd1
      bors 提交于
      rustdoc: Call `initSidebarItems` in root module of crate
      
      r? `@jsha`
      
      Resolves #85301
      94ecdfd1
    • B
      Auto merge of #85279 - DrChat:asm_powerpc64, r=Amanieu · e78bccfb
      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 👀
      e78bccfb
    • A
      Fix comments in tests · 1605e0ec
      Amanieu d'Antras 提交于
      1605e0ec
    • B
      Auto merge of #85259 - Smittyvb:thir-unsafeck-inline-asm, r=nikomatsakis · 6d525d50
      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
      6d525d50
    • J
      Allow `async {}` expressions in const contexts · bd168257
      Jonas Schievink 提交于
      bd168257
    • E
      Fix unused attributes on macro_rules. · 5bbc240f
      Eric Huss 提交于
      5bbc240f
    • B
      Auto merge of #81858 - ijackson:fork-no-unwind, r=m-ou-se · d565c748
      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`
      d565c748
    • B
      Auto merge of #84920 - Aaron1011:pretty-print-rental, r=petrochenkov · 8cf990c9
      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.
      8cf990c9
    • B
      Auto merge of #85335 - GuillaumeGomez:rollup-0tvc14g, r=GuillaumeGomez · 50f2bf6a
      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
      50f2bf6a
    • J
      Call `initSidebarItems` in root module of crate · aaf0ff83
      Justus K 提交于
      aaf0ff83
    • R
      32bit bless · 70c1cf15
      Ralf Jung 提交于
      70c1cf15
    • A
      Remove some unncessary spaces from pretty-printed tokenstream output · 357c013f
      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.
      357c013f
    • R
      split ui test stderr by bitwidth · 8af76cb6
      Ralf Jung 提交于
      8af76cb6
  3. 15 5月, 2021 15 次提交