1. 29 5月, 2022 19 次提交
  2. 28 5月, 2022 21 次提交
    • B
      Auto merge of #97383 - dingxiangfei2009:restore-region-scope-tree-query, r=dingxiangfei2009 · 4f39fb1f
      bors 提交于
      Try to cache region_scope_tree as a query
      
      This PR will attempt to restore `region_scope_tree` as a query so that caching works again. It seems that `region_scope_tree` could be re-computed for nested items after all, which could explain the performance regression introduced by #95563.
      
      cc `@Mark-Simulacrum` `@pnkfelix` I will try to trigger a perf run here.
      4f39fb1f
    • B
      Auto merge of #97158 - JakobDegen:dse, r=tmiasko,cjgillot · 68314177
      bors 提交于
      Split dead store elimination off dest prop
      
      This splits off a part of #96451 . I've added this in as its own pass for now, so that it actually runs, can be tested, etc. In the dest prop PR, I'll stop invoking this as its own pass, so that it doesn't get invoked twice.
      
      r? `@tmiasko`
      68314177
    • R
      ptr::invalid is not equivalent to a int2ptr cast · ad335194
      Ralf Jung 提交于
      ad335194
    • Y
      Make some tests check-pass · 4444defc
      Yuki Okushi 提交于
      4444defc
    • Y
      Remove FIXME on `ExtCtxt::fn_decl()` · 643c508e
      Yuki Okushi 提交于
      643c508e
    • B
      Auto merge of #97476 - Dylan-DPC:rollup-t53nxoe, r=Dylan-DPC · 19abca11
      bors 提交于
      Rollup of 5 pull requests
      
      Successful merges:
      
       - #94640 (Partially stabilize `(const_)slice_ptr_len` feature by stabilizing `NonNull::len`)
       - #97034 (Implement `Hash` for `core::alloc::Layout`)
       - #97327 (macros: introduce `fluent_messages` macro )
       - #97448 (docs: Don't imply that OsStr on Unix is always UTF-8)
       - #97466 ([bootstrap] Move `sanitize_sh` from `dist` to `install`)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      19abca11
    • D
      Rollup merge of #97466 - jyn514:consolidate-install, r=Mark-Simulacrum · 5badc299
      Dylan DPC 提交于
      [bootstrap] Move `sanitize_sh` from `dist` to `install`
      
      This is the only place it's used, so there's no need for it to be public in another module.
      In general, `dist` shouldn't ever touch shell scripts.
      5badc299
    • D
      Rollup merge of #97448 - Xiretza:os-str-unix-doc, r=joshtriplett · 529fcb57
      Dylan DPC 提交于
      docs: Don't imply that OsStr on Unix is always UTF-8
      
      The methods in `OsStrExt` consume and return `&[u8]` and don't perform any UTF-8 checks.
      529fcb57
    • D
      Rollup merge of #97327 - davidtwco:diagnostic-translation-compile-time-validation, r=oli-obk · 7e7dd1c0
      Dylan DPC 提交于
      macros: introduce `fluent_messages` macro
      
      Adds a new `fluent_messages` macro which performs compile-time validation of the compiler's Fluent resources (i.e. that the resources parse and don't multiply define the same messages) and generates constants that make using those messages in diagnostics more ergonomic.
      
      For example, given the following invocation of the macro..
      
      ```rust
      fluent_messages! {
          typeck => "./typeck.ftl",
      }
      ```
      
      ..where `typeck.ftl` has the following contents..
      
      ```fluent
      typeck-field-multiply-specified-in-initializer =
          field `{$ident}` specified more than once
          .label = used more than once
          .label-previous-use = first use of `{$ident}`
      ```
      
      ...then the macro parse the Fluent resource, emitting a diagnostic if it fails to do so...
      
      ```text
      error: could not parse Fluent resource
        --> $DIR/test.rs:35:28
         |
      LL |         missing_message => "./missing-message.ftl",
         |                            ^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: see additional errors emitted
      
      error: expected a message field for "missing-message"
       --> ./missing-message.ftl:1:1
        |
      1 | missing-message =
        | ^^^^^^^^^^^^^^^^^^
        |
      ```
      ...or generating the following code if it succeeds:
      
      ```rust
      pub static DEFAULT_LOCALE_RESOURCES: &'static [&'static str] = &[
          include_str!("./typeck.ftl"),
      ];
      
      mod fluent_generated {
          mod typeck {
              pub const field_multiply_specified_in_initializer: DiagnosticMessage =
                  DiagnosticMessage::fluent("typeck-field-multiply-specified-in-initializer");
              pub const field_multiply_specified_in_initializer_label_previous_use: DiagnosticMessage =
                  DiagnosticMessage::fluent_attr(
                      "typeck-field-multiply-specified-in-initializer",
                      "previous-use-label"
                  );
          }
      }
      ```
      
      When emitting a diagnostic, the generated constants can be used as follows:
      
      ```rust
      let mut err = sess.struct_span_err(
          span,
          fluent::typeck::field_multiply_specified_in_initializer
      );
      err.span_label(
          span,
          fluent::typeck::field_multiply_specified_in_initializer_label
      );
      err.span_label(
          previous_use_span,
          fluent::typeck::field_multiply_specified_in_initializer_label_previous_use
      );
      err.emit();
      ```
      
      I'd like to reduce the verbosity of referring to labels/notes/helps with this scheme (though it wasn't much better before), but I'll leave that for a follow-up.
      
      r? `@oli-obk`
      cc `@pvdrz` `@compiler-errors`
      7e7dd1c0
    • D
      Rollup merge of #97034 - fee1-dead-contrib:layout-hash, r=dtolnay · 880d3ea3
      Dylan DPC 提交于
      Implement `Hash` for `core::alloc::Layout`
      
      This was brought up on [reddit](https://www.reddit.com/r/rust/comments/uoypui/the_standard_library_types_are_good_except_when/), and I don't see why Layout shouldn't implement `Hash`. Feel free to comment if I am wrong though :)
      880d3ea3
    • D
      Rollup merge of #94640 - Pointerbender:issue-71146-partial-stabilization, r=yaahc · 837cd9e2
      Dylan DPC 提交于
      Partially stabilize `(const_)slice_ptr_len` feature by stabilizing `NonNull::len`
      
      This PR partially stabilizes features `const_slice_ptr_len` and `slice_ptr_len` by only stabilizing `NonNull::len`. This partial stabilization is tracked under features `slice_ptr_len_nonnull` and `const_slice_ptr_len_nonnull`, for which this PR can serve as the tracking issue.
      
      To summarize the discussion from #71146 leading up to this partial stabilization request:
      
      It's currently a bit footgunny to obtain the length of a raw slice pointer, stabilization of `NonNull:len` will help with removing these footguns. Some example footguns are:
      
      ```rust
      /// # Safety
      /// The caller must ensure that `ptr`:
      /// 1. does not point to memory that was previously allocated but is now deallocated;
      /// 2. is within the bounds of a single allocated object;
      /// 3. does not to point to a slice for which the length exceeds `isize::MAX` bytes;
      /// 4. points to a properly aligned address;
      /// 5. does not point to uninitialized memory;
      /// 6. does not point to a mutably borrowed memory location.
      pub unsafe fn ptr_len<T>(ptr: core::ptr::NonNull<[T]>) -> usize {
         (&*ptr.as_ptr()).len()
      }
      ```
      
      A slightly less complicated version (but still more complicated than it needs to be):
      
      ```rust
      /// # Safety
      /// The caller must ensure that the start of `ptr`:
      /// 1. does not point to memory that was previously allocated but is now deallocated;
      /// 2. must be within the bounds of a single allocated object.
      pub unsafe fn ptr_len<T>(ptr: NonNull<[T]>) -> usize {
         (&*(ptr.as_ptr() as *const [()])).len()
      }
      ```
      
      This PR does not stabilize `<*const [T]>::len` and  `<*mut [T]>::len` because the tracking issue #71146 list a potential blocker for these methods, but this blocker [does not apply](https://github.com/rust-lang/rust/issues/71146#issuecomment-808735714) to `NonNull::len`.
      
      We should probably also ping the [Constant Evaluation WG](https://github.com/rust-lang/const-eval) since this PR includes a `#[rustc_allow_const_fn_unstable(const_slice_ptr_len)]`. My instinct here is that this will probably be okay because the pointer is not actually dereferenced and `len()` does not touch the address component of the pointer, but would be best to double check :)
      
      One potential down-side was raised that stabilizing `NonNull::len` could lead to encouragement of coding patterns like:
      
      ```
      pub fn ptr_len<T>(ptr: *mut [T]) -> usize {
         NonNull::new(ptr).unwrap().len()
      }
      ```
      
      which unnecessarily assert non-nullness. However, these are much less of a footgun than the above examples and this should be resolved when `slice_ptr_len` fully stabilizes eventually.
      837cd9e2
    • B
      Auto merge of #97465 - jyn514:dist-ra, r=Mark-Simulacrum · b97bfc3b
      bors 提交于
      Fix `x dist --stage 1 src/tools/rust-analyzer`
      
      Previously, this would break because the submodule wasn't checked out.
      
      Fixes https://github.com/rust-lang/rust/issues/97464.
      b97bfc3b
    • B
      Auto merge of #97284 - b-naber:constraint-dyn-impl-suggestion, r=estebank · ed76b773
      bors 提交于
      Add suggestion for relaxing static lifetime bounds on dyn trait impls in NLL
      
      This PR introduces suggestions for relaxing static lifetime bounds on impls of dyn trait items for NLL similar to what is already available in lexical region diagnostics.
      
      Fixes https://github.com/rust-lang/rust/issues/95701
      
      r? `@estebank`
      ed76b773
    • J
      Update to rebased rustc-rayon 0.4 · ab57e362
      Josh Stone 提交于
      ab57e362
    • B
      Auto merge of #97433 - GuillaumeGomez:rm-refcell-context, r=notriddle · 764b8615
      bors 提交于
      Pass Context as a &mut to allow to remove RefCell fields
      
      Fixes #90323.
      
      r? `@notriddle`
      764b8615
    • J
      7a99da1d
    • B
      Auto merge of #97468 - matthiaskrgr:rollup-8cu0hqr, r=matthiaskrgr · 2aae8020
      bors 提交于
      Rollup of 6 pull requests
      
      Successful merges:
      
       - #95214 (Remove impossible panic note from `Vec::append`)
       - #97411 (Print stderr consistently)
       - #97453 (rename `TyKind` to `RegionKind` in comment in rustc_middle)
       - #97457 (Add regression test for #81899)
       - #97458 (Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error)
       - #97462 (Add more eslint rules)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      2aae8020
    • M
      Rollup merge of #97462 - GuillaumeGomez:more-eslint-rules, r=notriddle · b37b7350
      Matthias Krüger 提交于
      Add more eslint rules
      
      The last one is the most useful of this batch. :)
      
      Here are the links for the eslint rules:
      
       * [arrow-parens](https://eslint.org/docs/rules/arrow-parens)
       * [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars)
       * [eqeqeq](https://eslint.org/docs/rules/eqeqeq)
      
      r? `@notriddle`
      b37b7350
    • M
      Rollup merge of #97458 - estebank:use-self-in-derive-macro, r=compiler-errors · 0804ef65
      Matthias Krüger 提交于
      Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error
      
      Reduce verbosity in #97343.
      0804ef65
    • M
      Rollup merge of #97457 - JohnTitor:issue-81899, r=compiler-errors · 29ac9b13
      Matthias Krüger 提交于
      Add regression test for #81899
      
      Closes #81899
      r? `@compiler-errors`
      29ac9b13
    • M
      Rollup merge of #97453 - lcnr:comment, r=jackh726 · e96397b6
      Matthias Krüger 提交于
      rename `TyKind` to `RegionKind` in comment in rustc_middle
      e96397b6