1. 17 8月, 2023 16 次提交
  2. 16 8月, 2023 24 次提交
    • B
      Auto merge of #112500 - lukas-code:span-ctxt, r=petrochenkov · c94cb834
      bors 提交于
      Fix argument removal suggestion around macros
      
      Fixes #112437.
      Fixes #113866.
      Helps with #114255.
      
      The issue was that `span.find_ancestor_inside(outer)` could previously return a span with a different expansion context from `outer`.
      
      This happens for example for the built-in macro `panic!`, which expands to another macro call of `panic_2021!` or `panic_2015!`. Because the call site of `panic_20xx!` has not associated source code, its span currently points to the call site of `panic!` instead.
      
      Something similar also happens items that get desugared in AST->HIR lowering. For example, `for` loops get two spans: One "inner" span that has the `.desugaring_kind()` kind set to `DesugaringKind::ForLoop` and one "outer" span that does not. Similar to the macro situation, both of these spans point to the same source code, but have different expansion contexts.
      
      This causes problems, because joining two spans with different expansion contexts will usually[^1] not actually join them together to avoid creating "spaghetti" spans that go from the macro definition to the macro call. For example, in the following snippet `full_span` might not actually contain the `adjusted_start` and `adjusted_end`. This caused the broken suggestion / debug ICE in the linked issues.
      ```rust
      let adjusted_start = start.find_ancestor_inside(shared_ancestor);
      let adjusted_end = end.find_ancestor_inside(shared_ancestor);
      let full_span = adjusted_start.to(adjusted_end)
      ```
      
      To fix the issue, this PR introduces a new method, `find_ancestor_inside_same_ctxt`, which combines the functionality of `find_ancestor_inside` and `find_ancestor_in_same_ctxt`: It finds an ancestor span that is contained within the parent *and* has the same syntax context, and is therefore safe to extend. This new method should probably be used everywhere, where the returned span is extended, but for now it is just used for the argument removal suggestion.
      
      Additionally, this PR fixes a second issue where the function call itself is inside a macro but the arguments come from outside the macro. The test is added in the first commit to include stderr diff, so this is best reviewed commit by commit.
      
      [^1]: If one expansion context is the root context and the other is not.
      c94cb834
    • B
      Auto merge of #114850 - khei4:khei4/trailing_zero_codegen, r=nikic · 1ec628d7
      bors 提交于
      add codegen test for `trailing_zeros` comparison
      
      This PR add codegen test for
      https://github.com/rust-lang/rust/issues/107554#issuecomment-1677369236
      
      Fixes #107554.
      1ec628d7
    • B
      Auto merge of #114847 - nikic:update-llvm-12, r=cuviper · 2bc79291
      bors 提交于
      Update LLVM submodule
      
      Merge the current release/17.x branch.
      
      Fixes #114691.
      Fixes #114312.
      
      The test for the latter is taken from #114726.
      2bc79291
    • B
      Auto merge of #114879 - matthiaskrgr:rollup-tim571q, r=matthiaskrgr · 60713f42
      bors 提交于
      Rollup of 7 pull requests
      
      Successful merges:
      
       - #114721 (Optimizing the rest of bool's Ord implementation)
       - #114746 (Don't add associated type bound for non-types)
       - #114779 (Add check before suggest removing parens)
       - #114859 (Add trait related queries to SMIR's rustc_internal)
       - #114861 (fix typo: affect -> effect)
       - #114867 ([nit] Fix a comment typo.)
       - #114871 (Update the link in the docs of `std::intrinsics`)
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      60713f42
    • M
      Rollup merge of #114871 - schvv31n:fix-link-in-docs, r=scottmcm · 6024ad1a
      Matthias Krüger 提交于
      Update the link in the docs of `std::intrinsics`
      
      The previous link in that place, https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs, no longer points to an existing file.
      6024ad1a
    • M
      Rollup merge of #114867 - ttsugriy:ttsugriy-patch-1, r=scottmcm · 8201f0ff
      Matthias Krüger 提交于
      [nit] Fix a comment typo.
      8201f0ff
    • M
      Rollup merge of #114861 - RalfJung:no-effect, r=wesleywiser · 6f270321
      Matthias Krüger 提交于
      fix typo: affect -> effect
      
      I just realized I made a silly typo when writing that comment...
      6f270321
    • M
      Rollup merge of #114859 - spastorino:add-smir-cx-trait-fns, r=compiler-errors · b54fe764
      Matthias Krüger 提交于
      Add trait related queries to SMIR's rustc_internal
      
      r? `@oli-obk`
      b54fe764
    • M
      Rollup merge of #114779 - MU001999:fix/114701, r=petrochenkov · 8f1c8116
      Matthias Krüger 提交于
      Add check before suggest removing parens
      
      Fixes #114701
      8f1c8116
    • M
      Rollup merge of #114746 - compiler-errors:atb-no-const, r=TaKO8Ki · e21e039a
      Matthias Krüger 提交于
      Don't add associated type bound for non-types
      
      We had this fix for equality constraints (#99890), but for some reason not trait constraints 😅
      
      Fixes #114744
      e21e039a
    • M
      Rollup merge of #114721 - danflapjax:bool-ord-optimization, r=cuviper · 4b2d87d8
      Matthias Krüger 提交于
      Optimizing the rest of bool's Ord implementation
      
      After coming across issue #66780, I realized that the other functions provided by Ord (`min`, `max`, and `clamp`) were similarly inefficient for bool. This change provides implementations for them in terms of boolean operators, resulting in much simpler assembly and faster code.
      Fixes issue #114653
      
      [Comparison on Godbolt](https://rust.godbolt.org/z/5nb5P8e8j)
      
      `max` assembly before:
      ```assembly
      example::max:
              mov     eax, edi
              mov     ecx, eax
              neg     cl
              mov     edx, esi
              not     dl
              cmp     dl, cl
              cmove   eax, esi
              ret
      ```
      `max` assembly after:
      ```assembly
      example::max:
              mov     eax, edi
              or      eax, esi
              ret
      ```
      `clamp` assembly before:
      ```assembly
      example::clamp:
              mov     eax, esi
              sub     al, dl
              inc     al
              cmp     al, 2
              jae     .LBB1_1
              mov     eax, edi
              sub     al, sil
              movzx   ecx, dil
              sub     dil, dl
              cmp     dil, 1
              movzx   edx, dl
              cmovne  edx, ecx
              cmp     al, -1
              movzx   eax, sil
              cmovne  eax, edx
              ret
      .LBB1_1:
              ; identical assert! code
      ```
      `clamp` assembly after:
      ```assembly
      example::clamp:
              test    edx, edx
              jne     .LBB1_2
              test    sil, sil
              jne     .LBB1_3
      .LBB1_2:
              or      dil, sil
              and     dil, dl
              mov     eax, edi
              ret
      .LBB1_3:
              ; identical assert! code
      ```
      4b2d87d8
    • K
      add codegen test for issue 107554 · 8d514f2e
      khei4 提交于
      specify llvm-version and bit width for int arg
      
      add missing percent simbol
      8d514f2e
    • B
      Auto merge of #114536 - cjgillot:eval-lint-levels, r=TaKO8Ki · 4e3ce0e7
      bors 提交于
      Do not mark shallow_lint_levels_on as eval_always.
      
      It does not need it. Removing it allows to skip recomputation.
      4e3ce0e7
    • B
      Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomcc · 656ee47d
      bors 提交于
      Stabilize thread local cell methods.
      
      Closes #92122.
      656ee47d
    • B
      Auto merge of #111071 - nyurik:simpler-issue-94005, r=m-ou-se · b531630f
      bors 提交于
      Cleaner assert_eq! & assert_ne! panic messages
      
      This PR finishes refactoring of the assert messages per #94005. The panic message format change #112849 used to be part of this PR, but has been factored out and just merged. It might be better to keep both changes in the same release once FCP vote completes.
      
      Modify panic message for `assert_eq!`, `assert_ne!`, the currently unstable `assert_matches!`, as well as the corresponding `debug_assert_*` macros.
      
      ```rust
      assert_eq!(1 + 1, 3);
      assert_eq!(1 + 1, 3, "my custom message value={}!", 42);
      ```
      
      #### Old messages
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion failed: `(left == right)`
        left: `2`,
       right: `3`
      ```
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion failed: `(left == right)`
        left: `2`,
       right: `3`: my custom message value=42!
      ```
      
      #### New messages
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion `left == right` failed
        left: 2
       right: 3
      ```
      
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion `left == right` failed: my custom message value=42!
        left: 2
       right: 3
      ```
      
      History of fixing #94005
      * #94016 was a lengthy PR that was abandoned
      * #111030 was similar, but it stringified left and right arguments, and thus caused compile time performance issues, thus closed
      * #112849 factored out the two-line formatting of all panic messages
      
      Fixes #94005
      
      r? `@m-ou-se`
      b531630f
    • T
      Update the link in the docs of `std::intrinsics` · e6ab5f72
      Tim Kurdov 提交于
      The previous link in that place, https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs, no longer points to an existing file.
      e6ab5f72
    • B
      Auto merge of #114864 - matthiaskrgr:rollup-uw47qco, r=matthiaskrgr · 0bdb00d5
      bors 提交于
      Rollup of 8 pull requests
      
      Successful merges:
      
       - #114588 (Improve docs for impl Default for ExitStatus)
       - #114619 (Fix pthread_attr_union layout on Wasi)
       - #114644 (Point out expectation even if we have `TypeError::RegionsInsufficientlyPolymorphic`)
       - #114668 (Deny `FnDef` in patterns)
       - #114819 (Point at return type when it influences non-first `match` arm)
       - #114826 (Fix typos)
       - #114837 (add missing feature(error_in_core))
       - #114853 (Migrate GUI colors test to original CSS color format)
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      0bdb00d5
    • Y
      Cleaner assert_eq! & assert_ne! panic messages · 950e3d99
      Yuri Astrakhan 提交于
      Modify panic message for `assert_eq!`, `assert_ne!`, the currently unstable `assert_matches!`, as well as the corresponding `debug_assert_*` macros.
      
      ```rust
      assert_eq!(1 + 1, 3);
      assert_eq!(1 + 1, 3, "my custom message value={}!", 42);
      ```
      
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion failed: `(left == right)`
        left: `2`,
       right: `3`
      ```
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion failed: `(left == right)`
        left: `2`,
       right: `3`: my custom message value=42!
      ```
      
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion `left == right` failed
        left: 2
       right: 3
      ```
      
      ```plain
      thread 'main' panicked at $DIR/main.rs:6:5:
      assertion `left == right` failed: my custom message value=42!
        left: 2
       right: 3
      ```
      
      This PR is a simpler subset of the #111030, but it does NOT stringify the original left and right source code assert expressions, thus should be faster to compile.
      950e3d99
    • T
      [nit] Fix a comment typo. · 785ebd9b
      Taras Tsugrii 提交于
      785ebd9b
    • M
      Rollup merge of #114853 - GuillaumeGomez:migrate-gui-test-color-33, r=notriddle · 79bc72a5
      Matthias Krüger 提交于
      Migrate GUI colors test to original CSS color format
      
      Follow-up of https://github.com/rust-lang/rust/pull/111459.
      
      r? ``@notriddle``
      79bc72a5
    • M
      Rollup merge of #114837 - RalfJung:error_in_core, r=cuviper · a830834b
      Matthias Krüger 提交于
      add missing feature(error_in_core)
      
      Needed to fix feature gate errors in https://github.com/rust-lang/miri-test-libstd/actions/runs/5862810459/job/15895203359. I don't know how doctests are passing in-tree without this feature gate...
      a830834b
    • M
      Rollup merge of #114826 - xzmeng:fix-typos, r=JohnTitor · fa15f94e
      Matthias Krüger 提交于
      Fix typos
      fa15f94e
    • M
      Rollup merge of #114819 - estebank:issue-78124, r=compiler-errors · 8db5a6d8
      Matthias Krüger 提交于
      Point at return type when it influences non-first `match` arm
      
      When encountering code like
      
      ```rust
      fn foo() -> i32 {
          match 0 {
              1 => return 0,
              2 => "",
              _ => 1,
          }
      }
      ```
      
      Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`.
      
      Fix #78124.
      8db5a6d8
    • M
      Rollup merge of #114668 - compiler-errors:match-fn-def, r=petrochenkov · 5baf2a11
      Matthias Krüger 提交于
      Deny `FnDef` in patterns
      
      We can only see these via `const { .. }` patterns, which are unstable.
      
      cc #76001 (tracking issue for inline const pats)
      
      Fixes #114658
      Fixes #114659
      5baf2a11