]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #93368 - eddyb:diagbld-guarantee, r=estebank
bors [Fri, 25 Feb 2022 00:46:04 +0000 (00:46 +0000)]
Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebank

rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".

That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have:
* `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics
  * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation
  * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`)
  * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called
    (though note that this isn't a real guarantee until after completing the work on
     #69426)
* `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.)
  * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()`

This PR is a companion to other ongoing work, namely:
* #69426
  and it's ongoing implementation:
  #93222
  the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes
* #93244
  would make the choices of API changes (esp. naming) in this PR fit better overall

In order to be able to let `.emit()` return anything trustable, several changes had to be made:
* `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail)
  * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()`
* `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic
  * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user
  * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it
  * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early)
  * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`)
* since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>,
  we have to make `.emit()` idempotent wrt the guarantees it returns
  * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission
* `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic)
  * the APIs were already mostly identical, allowing for low-effort porting to this new setup
  * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259)
  * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective)
  * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same)

This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each.

r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`

2 years agoAuto merge of #94333 - Dylan-DPC:rollup-7yxtywp, r=Dylan-DPC
bors [Thu, 24 Feb 2022 22:29:14 +0000 (22:29 +0000)]
Auto merge of #94333 - Dylan-DPC:rollup-7yxtywp, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #91795 (resolve/metadata: Stop encoding macros as reexports)
 - #93714 (better ObligationCause for normalization errors in `can_type_implement_copy`)
 - #94175 (Improve `--check-cfg` implementation)
 - #94212 (Stop manually SIMDing in `swap_nonoverlapping`)
 - #94242 (properly handle fat pointers to uninhabitable types)
 - #94308 (Normalize main return type during mono item collection & codegen)
 - #94315 (update auto trait lint for `PhantomData`)
 - #94316 (Improve string literal unescaping)
 - #94327 (Avoid emitting full macro body into JSON errors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #94327 - Mark-Simulacrum:avoid-macro-sp, r=petrochenkov
Dylan DPC [Thu, 24 Feb 2022 20:42:19 +0000 (21:42 +0100)]
Rollup merge of #94327 - Mark-Simulacrum:avoid-macro-sp, r=petrochenkov

Avoid emitting full macro body into JSON errors

While investigating https://github.com/rust-lang/rust/issues/94322, it was noted that currently the JSON diagnostics for macro backtraces include the full def_site span -- the whole macro body.

It seems like this shouldn't be necessary, so this PR adjusts the span to just be the "guessed head", typically the macro name. It doesn't look like we keep enough information to synthesize a nicer span here at this time.

Atop #92123, this reduces output for the src/test/ui/suggestions/missing-lifetime-specifier.rs test from 660 KB to 156 KB locally.

2 years agoRollup merge of #94316 - nnethercote:improve-string-literal-unescaping, r=petrochenkov
Dylan DPC [Thu, 24 Feb 2022 20:42:18 +0000 (21:42 +0100)]
Rollup merge of #94316 - nnethercote:improve-string-literal-unescaping, r=petrochenkov

Improve string literal unescaping

Some easy wins that affect a few popular crates.

r? ```@matklad```

2 years agoRollup merge of #94315 - lcnr:auto-trait-lint-update, r=oli-obk
Dylan DPC [Thu, 24 Feb 2022 20:42:17 +0000 (21:42 +0100)]
Rollup merge of #94315 - lcnr:auto-trait-lint-update, r=oli-obk

update auto trait lint for `PhantomData`

cc https://github.com/rust-lang/rust/issues/93367#issuecomment-1047898410

2 years agoRollup merge of #94308 - tmiasko:normalize-main-ret-ty, r=oli-obk
Dylan DPC [Thu, 24 Feb 2022 20:42:16 +0000 (21:42 +0100)]
Rollup merge of #94308 - tmiasko:normalize-main-ret-ty, r=oli-obk

Normalize main return type during mono item collection & codegen

The issue can be observed with `-Zprint-mono-items=lazy` in:

```rust
#![feature(termination_trait_lib)]
fn main() -> impl std::process::Termination { }
```
```
BEFORE: MONO_ITEM fn std::rt::lang_start::<impl std::process::Termination> ````@@```` t.93933fa2-cgu.2[External]
AFTER:  MONO_ITEM fn std::rt::lang_start::<()> ````@@```` t.df56e625-cgu.1[External]
```

2 years agoRollup merge of #94242 - compiler-errors:fat-uninhabitable-pointer, r=michaelwoerister
Dylan DPC [Thu, 24 Feb 2022 20:42:15 +0000 (21:42 +0100)]
Rollup merge of #94242 - compiler-errors:fat-uninhabitable-pointer, r=michaelwoerister

properly handle fat pointers to uninhabitable types

Calculate the pointee metadata size by using `tcx.struct_tail_erasing_lifetimes` instead of duplicating the logic in `fat_pointer_kind`. Open to alternatively suggestions on how to fix this.

Fixes #94149

r? ````@michaelwoerister```` since you touched this code last, I think!

2 years agoRollup merge of #94212 - scottmcm:swapper, r=dtolnay
Dylan DPC [Thu, 24 Feb 2022 20:42:14 +0000 (21:42 +0100)]
Rollup merge of #94212 - scottmcm:swapper, r=dtolnay

Stop manually SIMDing in `swap_nonoverlapping`

Like I previously did for `reverse` (#90821), this leaves it to LLVM to pick how to vectorize it, since it can know better the chunk size to use, compared to the "32 bytes always" approach we currently have.

A variety of codegen tests are included to confirm that the various cases are still being vectorized.

It does still need logic to type-erase in some cases, though, as while LLVM is now smart enough to vectorize over slices of things like `[u8; 4]`, it fails to do so over slices of `[u8; 3]`.

As a bonus, this change also means one no longer gets the spurious `memcpy`(s?) at the end up swapping a slice of `__m256`s: <https://rust.godbolt.org/z/joofr4v8Y>

<details>

<summary>ASM for this example</summary>

## Before (from godbolt)

note the `push`/`pop`s and `memcpy`

```x86
swap_m256_slice:
        push    r15
        push    r14
        push    r13
        push    r12
        push    rbx
        sub     rsp, 32
        cmp     rsi, rcx
        jne     .LBB0_6
        mov     r14, rsi
        shl     r14, 5
        je      .LBB0_6
        mov     r15, rdx
        mov     rbx, rdi
        xor     eax, eax
.LBB0_3:
        mov     rcx, rax
        vmovaps ymm0, ymmword ptr [rbx + rax]
        vmovaps ymm1, ymmword ptr [r15 + rax]
        vmovaps ymmword ptr [rbx + rax], ymm1
        vmovaps ymmword ptr [r15 + rax], ymm0
        add     rax, 32
        add     rcx, 64
        cmp     rcx, r14
        jbe     .LBB0_3
        sub     r14, rax
        jbe     .LBB0_6
        add     rbx, rax
        add     r15, rax
        mov     r12, rsp
        mov     r13, qword ptr [rip + memcpy@GOTPCREL]
        mov     rdi, r12
        mov     rsi, rbx
        mov     rdx, r14
        vzeroupper
        call    r13
        mov     rdi, rbx
        mov     rsi, r15
        mov     rdx, r14
        call    r13
        mov     rdi, r15
        mov     rsi, r12
        mov     rdx, r14
        call    r13
.LBB0_6:
        add     rsp, 32
        pop     rbx
        pop     r12
        pop     r13
        pop     r14
        pop     r15
        vzeroupper
        ret
```

## After (from my machine)

Note no `rsp` manipulation, sorry for different ASM syntax

```x86
swap_m256_slice:
cmpq %r9, %rdx
jne .LBB1_6
testq %rdx, %rdx
je .LBB1_6
cmpq $1, %rdx
jne .LBB1_7
xorl %r10d, %r10d
jmp .LBB1_4
.LBB1_7:
movq %rdx, %r9
andq $-2, %r9
movl $32, %eax
xorl %r10d, %r10d
.p2align 4, 0x90
.LBB1_8:
vmovaps -32(%rcx,%rax), %ymm0
vmovaps -32(%r8,%rax), %ymm1
vmovaps %ymm1, -32(%rcx,%rax)
vmovaps %ymm0, -32(%r8,%rax)
vmovaps (%rcx,%rax), %ymm0
vmovaps (%r8,%rax), %ymm1
vmovaps %ymm1, (%rcx,%rax)
vmovaps %ymm0, (%r8,%rax)
addq $2, %r10
addq $64, %rax
cmpq %r10, %r9
jne .LBB1_8
.LBB1_4:
testb $1, %dl
je .LBB1_6
shlq $5, %r10
vmovaps (%rcx,%r10), %ymm0
vmovaps (%r8,%r10), %ymm1
vmovaps %ymm1, (%rcx,%r10)
vmovaps %ymm0, (%r8,%r10)
.LBB1_6:
vzeroupper
retq
```

</details>

This does all its copying operations as either the original type or as `MaybeUninit`s, so as far as I know there should be no potential abstract machine issues with reading padding bytes as integers.

<details>

<summary>Perf is essentially unchanged</summary>

Though perhaps with more target features this would help more, if it could pick bigger chunks

## Before

```
running 10 tests
test slice::swap_with_slice_4x_usize_30                            ... bench:         894 ns/iter (+/- 11)
test slice::swap_with_slice_4x_usize_3000                          ... bench:      99,476 ns/iter (+/- 2,784)
test slice::swap_with_slice_5x_usize_30                            ... bench:       1,257 ns/iter (+/- 7)
test slice::swap_with_slice_5x_usize_3000                          ... bench:     139,922 ns/iter (+/- 959)
test slice::swap_with_slice_rgb_30                                 ... bench:         328 ns/iter (+/- 27)
test slice::swap_with_slice_rgb_3000                               ... bench:      16,215 ns/iter (+/- 176)
test slice::swap_with_slice_u8_30                                  ... bench:         312 ns/iter (+/- 9)
test slice::swap_with_slice_u8_3000                                ... bench:       5,401 ns/iter (+/- 123)
test slice::swap_with_slice_usize_30                               ... bench:         368 ns/iter (+/- 3)
test slice::swap_with_slice_usize_3000                             ... bench:      28,472 ns/iter (+/- 3,913)
```

## After

```
running 10 tests
test slice::swap_with_slice_4x_usize_30                            ... bench:         868 ns/iter (+/- 36)
test slice::swap_with_slice_4x_usize_3000                          ... bench:      99,642 ns/iter (+/- 1,507)
test slice::swap_with_slice_5x_usize_30                            ... bench:       1,194 ns/iter (+/- 11)
test slice::swap_with_slice_5x_usize_3000                          ... bench:     139,761 ns/iter (+/- 5,018)
test slice::swap_with_slice_rgb_30                                 ... bench:         324 ns/iter (+/- 6)
test slice::swap_with_slice_rgb_3000                               ... bench:      15,962 ns/iter (+/- 287)
test slice::swap_with_slice_u8_30                                  ... bench:         281 ns/iter (+/- 5)
test slice::swap_with_slice_u8_3000                                ... bench:       5,324 ns/iter (+/- 40)
test slice::swap_with_slice_usize_30                               ... bench:         275 ns/iter (+/- 5)
test slice::swap_with_slice_usize_3000                             ... bench:      28,277 ns/iter (+/- 277)
```

</detail>

2 years agoRollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkov
Dylan DPC [Thu, 24 Feb 2022 20:42:13 +0000 (21:42 +0100)]
Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkov

Improve `--check-cfg` implementation

This pull-request is a mix of improvements regarding the `--check-cfg` implementation:

- Simpler internal representation (usage of `Option` instead of separate bool)
- Add --check-cfg to the unstable book (based on the RFC)
- Improved diagnostics:
    * List possible values when the value is unexpected
    * Suggest if possible a name or value that is similar
- Add more tests (well known names, mix of combinations, ...)

r? ```@petrochenkov```

2 years agoRollup merge of #93714 - compiler-errors:can-type-impl-copy-error-span, r=jackh726
Dylan DPC [Thu, 24 Feb 2022 20:42:12 +0000 (21:42 +0100)]
Rollup merge of #93714 - compiler-errors:can-type-impl-copy-error-span, r=jackh726

better ObligationCause for normalization errors in `can_type_implement_copy`

Some logic is needed so we can point to the field when given totally nonsense types like `struct Foo(<u32 as Iterator>::Item);`

Fixes #93687

2 years agoRollup merge of #91795 - petrochenkov:nomacreexport, r=cjgillot
Dylan DPC [Thu, 24 Feb 2022 20:42:11 +0000 (21:42 +0100)]
Rollup merge of #91795 - petrochenkov:nomacreexport, r=cjgillot

resolve/metadata: Stop encoding macros as reexports

Supersedes https://github.com/rust-lang/rust/pull/88335.
r? `@cjgillot`

2 years agoUpdate clippy tests
Vadim Petrochenkov [Sat, 5 Feb 2022 02:07:13 +0000 (10:07 +0800)]
Update clippy tests

2 years agoresolve/metadata: Stop encoding macros as reexports
Vadim Petrochenkov [Mon, 24 Jan 2022 07:41:25 +0000 (15:41 +0800)]
resolve/metadata: Stop encoding macros as reexports

2 years agometadata: Tweak the way in which declarative macros are encoded
Vadim Petrochenkov [Mon, 24 Jan 2022 07:30:54 +0000 (15:30 +0800)]
metadata: Tweak the way in which declarative macros are encoded

To make the `macro_rules` flag more readily available without decoding everything else

2 years agoresolve: Fix incorrect results of `opt_def_kind` query for some built-in macros
Vadim Petrochenkov [Sat, 11 Dec 2021 11:52:23 +0000 (19:52 +0800)]
resolve: Fix incorrect results of `opt_def_kind` query for some built-in macros

Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives

2 years agoAuto merge of #94131 - Mark-Simulacrum:fmt-string, r=oli-obk
bors [Thu, 24 Feb 2022 17:18:07 +0000 (17:18 +0000)]
Auto merge of #94131 - Mark-Simulacrum:fmt-string, r=oli-obk

Always format to internal String in FmtPrinter

This avoids monomorphizing for different parameters, decreasing generic code
instantiated downstream from rustc_middle -- locally seeing 7% unoptimized LLVM IR
line wins on rustc_borrowck, for example.

We likely can't/shouldn't get rid of the Result-ness on most functions, though some
further cleanup avoiding fmt::Error where we now know it won't occur may be possible,
though somewhat painful -- fmt::Write is a pretty annoying API to work with in practice
when you're trying to use it infallibly.

2 years agorestore spans for issue-50480
Michael Goulet [Sun, 6 Feb 2022 23:57:29 +0000 (15:57 -0800)]
restore spans for issue-50480

2 years agobetter ObligationCause for normalization errors in can_type_implement_copy
Michael Goulet [Sun, 6 Feb 2022 21:03:28 +0000 (13:03 -0800)]
better ObligationCause for normalization errors in can_type_implement_copy

2 years agoAvoid emitting full macro body into JSON
Mark Rousskov [Thu, 24 Feb 2022 16:16:45 +0000 (11:16 -0500)]
Avoid emitting full macro body into JSON

2 years agoAuto merge of #94123 - bjorn3:cg_ssa_singleton_builder, r=tmiasko
bors [Thu, 24 Feb 2022 12:28:19 +0000 (12:28 +0000)]
Auto merge of #94123 - bjorn3:cg_ssa_singleton_builder, r=tmiasko

Partially move cg_ssa towards using a single builder

Not all codegen backends can handle hopping between blocks well. For example Cranelift requires blocks to be terminated before switching to building a new block. Rust-gpu requires a `RefCell` to allow hopping between blocks and cg_gcc currently has a buggy implementation of hopping between blocks. This PR reduces the amount of cases where cg_ssa switches between blocks before they are finished and mostly fixes the block hopping in cg_gcc. (~~only `scalar_to_backend` doesn't handle it correctly yet in cg_gcc~~ fixed that one.)

`@antoyo` please review the cg_gcc changes.

2 years agoIntroduce Bx::switch_to_block
bjorn3 [Fri, 18 Feb 2022 14:37:31 +0000 (15:37 +0100)]
Introduce Bx::switch_to_block

2 years agoAuto merge of #94129 - cjgillot:rmeta-table, r=petrochenkov
bors [Thu, 24 Feb 2022 10:02:26 +0000 (10:02 +0000)]
Auto merge of #94129 - cjgillot:rmeta-table, r=petrochenkov

Back more metadata using per-query tables

r? `@ghost`

2 years agoupdate auto trait lint
lcnr [Thu, 24 Feb 2022 07:36:29 +0000 (08:36 +0100)]
update auto trait lint

2 years agoAuto merge of #94314 - matthiaskrgr:rollup-hmed8n7, r=matthiaskrgr
bors [Thu, 24 Feb 2022 06:56:38 +0000 (06:56 +0000)]
Auto merge of #94314 - matthiaskrgr:rollup-hmed8n7, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #89887 (Change `char` type in debuginfo to DW_ATE_UTF)
 - #94267 (Remove unused ordering derivations and bounds for `SimplifiedTypeGen`)
 - #94270 (Miri: relax fn ptr check)
 - #94273 (add matching doc to errorkind)
 - #94283 (remove feature gate in control_flow examples)
 - #94288 (Cleanup a few Decoder methods)
 - #94292 (riscv32imc_esp_espidf: set max_atomic_width to 64)
 - #94296 (:arrow_up: rust-analyzer)
 - #94300 (Fix a typo in documentation of `array::IntoIter::new_unchecked`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #94300 - WaffleLapkin:patch-4, r=scottmcm
Matthias Krüger [Thu, 24 Feb 2022 06:48:12 +0000 (07:48 +0100)]
Rollup merge of #94300 - WaffleLapkin:patch-4, r=scottmcm

Fix a typo in documentation of `array::IntoIter::new_unchecked`

🌸

2 years agoRollup merge of #94296 - lnicola:rust-analyzer-2022-02-23, r=lnicola
Matthias Krüger [Thu, 24 Feb 2022 06:48:11 +0000 (07:48 +0100)]
Rollup merge of #94296 - lnicola:rust-analyzer-2022-02-23, r=lnicola

:arrow_up: rust-analyzer

r? `@ghost`

2 years agoRollup merge of #94292 - esp-rs:riscv32imc-esp-espidf-64bit-atomics, r=petrochenkov
Matthias Krüger [Thu, 24 Feb 2022 06:48:10 +0000 (07:48 +0100)]
Rollup merge of #94292 - esp-rs:riscv32imc-esp-espidf-64bit-atomics, r=petrochenkov

riscv32imc_esp_espidf: set max_atomic_width to 64

For espidf targets without native atomics, there is atomic emulation inside [the newlib component of espidf](https://github.com/espressif/esp-idf/blob/master/components/newlib/stdatomic.c), this has been extended to support emulation up to 64bits therefore we are safe to increase the atomic width for the `riscv32imc_esp_espidf` target.

Closes https://github.com/esp-rs/rust/issues/107

cc: `@ivmarkov`

2 years agoRollup merge of #94288 - Mark-Simulacrum:ser-opt, r=nnethercote
Matthias Krüger [Thu, 24 Feb 2022 06:48:09 +0000 (07:48 +0100)]
Rollup merge of #94288 - Mark-Simulacrum:ser-opt, r=nnethercote

Cleanup a few Decoder methods

This is just some simple follow up to #93839.

r? `@nnethercote`

2 years agoRollup merge of #94283 - hellow554:stable_flow_control, r=Dylan-DPC
Matthias Krüger [Thu, 24 Feb 2022 06:48:08 +0000 (07:48 +0100)]
Rollup merge of #94283 - hellow554:stable_flow_control, r=Dylan-DPC

remove feature gate in control_flow examples

Stabilization was done in https://github.com/rust-lang/rust/pull/91091, but the two examples weren't updated accordingly.

Probably too late to put it into stable, but it should be in the next release :)

2 years agoRollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplett
Matthias Krüger [Thu, 24 Feb 2022 06:48:07 +0000 (07:48 +0100)]
Rollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplett

add matching doc to errorkind

Rework of #90706

2 years agoRollup merge of #94270 - RalfJung:fn-ptrs, r=oli-obk
Matthias Krüger [Thu, 24 Feb 2022 06:48:06 +0000 (07:48 +0100)]
Rollup merge of #94270 - RalfJung:fn-ptrs, r=oli-obk

Miri: relax fn ptr check

As discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/72#issuecomment-1025407536, the function pointer check done by Miri is currently overeager: contrary to our usual principle of only checking rather uncontroversial validity invariants, we actually check that the pointer points to a real function.

So, this relaxes the check to what the validity invariant probably will be (and what the reference already says it is): the function pointer must be non-null, and that's it.

The check that CTFE does on the final value of a constant is unchanged -- CTFE recurses through references, so it makes some sense to also recurse through function pointers. We might still want to relax this in the future, but that would be a separate change.

r? `@oli-obk`

2 years agoRollup merge of #94267 - pierwill:fast-reject-bound, r=michaelwoerister
Matthias Krüger [Thu, 24 Feb 2022 06:48:05 +0000 (07:48 +0100)]
Rollup merge of #94267 - pierwill:fast-reject-bound, r=michaelwoerister

Remove unused ordering derivations and bounds for `SimplifiedTypeGen`

This is another small PR clearing the way for work on #90317.

2 years agoRollup merge of #89887 - arlosi:char-debug, r=wesleywiser
Matthias Krüger [Thu, 24 Feb 2022 06:48:04 +0000 (07:48 +0100)]
Rollup merge of #89887 - arlosi:char-debug, r=wesleywiser

Change `char` type in debuginfo to DW_ATE_UTF

Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more appropriate encoding is `DW_ATE_UTF`.

Clang also uses the DW_ATE_UTF for `char32_t` in C++.

This fixes the display of the `char` type in the Windows debuggers. Without this change, the variable did not show in the locals window.
![image](https://user-images.githubusercontent.com/704597/137368067-9b3e4dc8-a075-44ba-a687-bf3810a44e5a.png)

LLDB 13 is also able to display the char value, when before it failed with `need to add support for DW_TAG_base_type 'char' encoded with DW_ATE = 0x8, bit_size = 32`

r? `@wesleywiser`

2 years agoInline a hot closure in `from_lit_token`.
Nicholas Nethercote [Thu, 24 Feb 2022 05:49:37 +0000 (16:49 +1100)]
Inline a hot closure in `from_lit_token`.

The change looks big because `rustfmt` rearranges things, but the only
real change is the inlining annotation.

2 years agoImprove `scan_escape`.
Nicholas Nethercote [Thu, 24 Feb 2022 05:10:36 +0000 (16:10 +1100)]
Improve `scan_escape`.

`scan_escape` currently has a fast path (for when the first char isn't
'\\') and a slow path.

This commit changes `scan_escape` so it only handles the slow path, i.e.
the actual escaping code. The fast path is inlined into the two call
sites.

This change makes the code faster, because there is no function call
overhead on the fast path. (`scan_escape` is a big function and doesn't
get inlined.)

This change also improves readability, because it removes a bunch of
mode checks on the the fast paths.

2 years agoAuto merge of #94107 - tmiasko:fewer-types, r=davidtwco
bors [Thu, 24 Feb 2022 04:07:48 +0000 (04:07 +0000)]
Auto merge of #94107 - tmiasko:fewer-types, r=davidtwco

Reapply cg_llvm: `fewer_names` in `uncached_llvm_type`

r? `@davidtwco` `@erikdesjardins`

2 years agoAuto merge of #93438 - spastorino:node_id_to_hir_id_refactor, r=oli-obk
bors [Thu, 24 Feb 2022 01:26:57 +0000 (01:26 +0000)]
Auto merge of #93438 - spastorino:node_id_to_hir_id_refactor, r=oli-obk

Node id to hir id refactor

Related to #89278

r? `@oli-obk`

2 years agoword wrpa
Dylan DPC [Wed, 23 Feb 2022 23:37:06 +0000 (00:37 +0100)]
word wrpa

2 years agoword wrpa
Dylan DPC [Wed, 23 Feb 2022 23:30:07 +0000 (00:30 +0100)]
word wrpa

2 years agoUpdate library/std/src/io/error.rs
Dylan DPC [Wed, 23 Feb 2022 22:18:42 +0000 (23:18 +0100)]
Update library/std/src/io/error.rs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2 years agoNormalize main return type during mono item collection & codegen
Tomasz Miąsko [Wed, 23 Feb 2022 00:00:00 +0000 (00:00 +0000)]
Normalize main return type during mono item collection & codegen

2 years agoMiri: relax fn ptr check
Ralf Jung [Tue, 22 Feb 2022 23:49:12 +0000 (18:49 -0500)]
Miri: relax fn ptr check

2 years agoAuto merge of #94286 - matthiaskrgr:rollup-6i1spjg, r=matthiaskrgr
bors [Wed, 23 Feb 2022 18:18:23 +0000 (18:18 +0000)]
Auto merge of #94286 - matthiaskrgr:rollup-6i1spjg, r=matthiaskrgr

Rollup of 12 pull requests

Successful merges:

 - #94128 (rustdoc: several minor fixes)
 - #94137 (rustdoc-json: Better Header Type)
 - #94213 (fix names in feature(...) suggestion)
 - #94240 (Suggest calling .display() on `PathBuf` too)
 - #94253 (Use 2021 edition in ./x.py fmt)
 - #94259 (Bump download-ci-llvm-stamp for llvm-nm inclusion)
 - #94260 (Fix rustdoc infinite redirection generation)
 - #94263 (Typo fix: Close inline-code backtick)
 - #94264 (Fix typo.)
 - #94271 (Miri: extend comments on downcast operation)
 - #94280 (Rename `region_should_not_be_omitted` to `should_print_region`)
 - #94285 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoFix a typo in documentation of `array::IntoIter::new_unchecked`
Waffle Maybe [Wed, 23 Feb 2022 18:10:04 +0000 (21:10 +0300)]
Fix a typo in documentation of `array::IntoIter::new_unchecked`

2 years agoChange `char` type in debuginfo to DW_ATE_UTF
Arlo Siemsen [Thu, 14 Oct 2021 17:26:42 +0000 (10:26 -0700)]
Change `char` type in debuginfo to DW_ATE_UTF

Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more
appropriate encoding is DW_ATE_UTF.

Clang uses this same debug encoding for char32_t.

This fixes the display of `char` types in Windows debuggers as well as LLDB.

2 years agoproperly handle fat pointers to uninhabitable types
Michael Goulet [Wed, 23 Feb 2022 16:11:50 +0000 (08:11 -0800)]
properly handle fat pointers to uninhabitable types

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Wed, 23 Feb 2022 15:11:18 +0000 (17:11 +0200)]
:arrow_up: rust-analyzer

2 years agoriscv32imc_esp_espidf: set max_atomic_width to 64
Scott Mabin [Tue, 22 Feb 2022 10:44:56 +0000 (10:44 +0000)]
riscv32imc_esp_espidf: set max_atomic_width to 64

2 years agoAdd compiler flag `--check-cfg` to the unstable book
Loïc BRANSTETT [Mon, 21 Feb 2022 14:29:04 +0000 (15:29 +0100)]
Add compiler flag `--check-cfg` to the unstable book

2 years agoContinue improvements on the --check-cfg implementation
Loïc BRANSTETT [Sun, 20 Feb 2022 00:26:52 +0000 (01:26 +0100)]
Continue improvements on the --check-cfg implementation

- Test the combinations of --check-cfg with partial values() and --cfg
- Test that we detect unexpected value when none are expected

2 years agoRollup merge of #94285 - bjorn3:sync_cg_clif-2022-02-23, r=bjorn3
Matthias Krüger [Wed, 23 Feb 2022 11:26:48 +0000 (12:26 +0100)]
Rollup merge of #94285 - bjorn3:sync_cg_clif-2022-02-23, r=bjorn3

Sync rustc_codegen_cranelift

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

2 years agoRollup merge of #94280 - tmiasko:should-print-region, r=oli-obk
Matthias Krüger [Wed, 23 Feb 2022 11:26:47 +0000 (12:26 +0100)]
Rollup merge of #94280 - tmiasko:should-print-region, r=oli-obk

Rename `region_should_not_be_omitted` to `should_print_region`

to avoid double negation

2 years agoRollup merge of #94271 - RalfJung:downcast, r=oli-obk
Matthias Krüger [Wed, 23 Feb 2022 11:26:46 +0000 (12:26 +0100)]
Rollup merge of #94271 - RalfJung:downcast, r=oli-obk

Miri: extend comments on downcast operation

r? `@oli-obk`

2 years agoRollup merge of #94264 - NyantasticUwU:patch-1, r=yaahc
Matthias Krüger [Wed, 23 Feb 2022 11:26:45 +0000 (12:26 +0100)]
Rollup merge of #94264 - NyantasticUwU:patch-1, r=yaahc

Fix typo.

Yeah just a typo (probably some breaking changes in here be careful) :)

2 years agoRollup merge of #94263 - anko:patch-1, r=GuillaumeGomez
Matthias Krüger [Wed, 23 Feb 2022 11:26:45 +0000 (12:26 +0100)]
Rollup merge of #94263 - anko:patch-1, r=GuillaumeGomez

Typo fix: Close inline-code backtick

A drop in the ocean.

2 years agoRollup merge of #94260 - GuillaumeGomez:infinite-redirection, r=notriddle
Matthias Krüger [Wed, 23 Feb 2022 11:26:44 +0000 (12:26 +0100)]
Rollup merge of #94260 - GuillaumeGomez:infinite-redirection, r=notriddle

Fix rustdoc infinite redirection generation

Someone came to me about a funny bug they had when clicking on any link on [this page](https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/stable/latest/docs/libadwaita/builders/index.html): it ended one page redirecting to itself indefinitely.

I was able to make a minimum reproducible case to trigger this bug which I now use as a test.

r? ``@notriddle``

2 years agoRollup merge of #94259 - krasimirgg:bump-llvm-ci, r=Mark-Simulacrum
Matthias Krüger [Wed, 23 Feb 2022 11:26:44 +0000 (12:26 +0100)]
Rollup merge of #94259 - krasimirgg:bump-llvm-ci, r=Mark-Simulacrum

Bump download-ci-llvm-stamp for llvm-nm inclusion

We started using it in https://github.com/rust-lang/rust/pull/94023.

2 years agoRollup merge of #94253 - bjorn3:xpy-fmt-2021, r=Mark-Simulacrum
Matthias Krüger [Wed, 23 Feb 2022 11:26:43 +0000 (12:26 +0100)]
Rollup merge of #94253 - bjorn3:xpy-fmt-2021, r=Mark-Simulacrum

Use 2021 edition in ./x.py fmt

2 years agoRollup merge of #94240 - compiler-errors:pathbuf-display, r=lcnr
Matthias Krüger [Wed, 23 Feb 2022 11:26:42 +0000 (12:26 +0100)]
Rollup merge of #94240 - compiler-errors:pathbuf-display, r=lcnr

Suggest calling .display() on `PathBuf` too

Fixes #94210

2 years agoRollup merge of #94213 - digama0:patch-4, r=Dylan-DPC
Matthias Krüger [Wed, 23 Feb 2022 11:26:41 +0000 (12:26 +0100)]
Rollup merge of #94213 - digama0:patch-4, r=Dylan-DPC

fix names in feature(...) suggestion

2 years agoRollup merge of #94137 - aDotInTheVoid:abi-enum, r=CraftSpider
Matthias Krüger [Wed, 23 Feb 2022 11:26:41 +0000 (12:26 +0100)]
Rollup merge of #94137 - aDotInTheVoid:abi-enum, r=CraftSpider

rustdoc-json: Better Header Type

- Make ABI an enum, instead of being stringly typed
- Replace Qualifier HashSet with 3 bools
- Merge ABI field into header, as they always occor together

r? ``@CraftSpider``

``@rustbot`` modify labels: +A-rustdoc-json +T-rustdoc

2 years agoRollup merge of #94128 - mqy:master, r=Dylan-DPC
Matthias Krüger [Wed, 23 Feb 2022 11:26:40 +0000 (12:26 +0100)]
Rollup merge of #94128 - mqy:master, r=Dylan-DPC

rustdoc: several minor fixes

``@rustbot`` label A-docs

2 years agoMerge commit '35d9c6bf256968e1b40e0d554607928bdf9cebea' into sync_cg_clif-2022-02-23
bjorn3 [Wed, 23 Feb 2022 10:49:34 +0000 (11:49 +0100)]
Merge commit '35d9c6bf256968e1b40e0d554607928bdf9cebea' into sync_cg_clif-2022-02-23

2 years agoRustup to rustc 1.61.0-nightly (68369a041 2022-02-22)
bjorn3 [Wed, 23 Feb 2022 10:45:41 +0000 (11:45 +0100)]
Rustup to rustc 1.61.0-nightly (68369a041 2022-02-22)

2 years agoSync from rust bafe8d06e015eb00724d3d497516191d6681943f
bjorn3 [Wed, 23 Feb 2022 10:38:28 +0000 (11:38 +0100)]
Sync from rust bafe8d06e015eb00724d3d497516191d6681943f

2 years agoremove feature gate in control_flow examples
Marcel Hellwig [Wed, 23 Feb 2022 09:42:46 +0000 (10:42 +0100)]
remove feature gate in control_flow examples

2 years agoAuto merge of #94277 - ehuss:update-cargo, r=ehuss
bors [Wed, 23 Feb 2022 08:04:34 +0000 (08:04 +0000)]
Auto merge of #94277 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in ea2a21c994ca1e4d4c49412827b3cf4dcb158b1d..d6cdde584a1f15ea086bae922e20fd27f7165431
2022-02-15 04:24:07 +0000 to 2022-02-22 19:55:51 +0000
- Add common profile validation. (rust-lang/cargo#10411)
- Add -Z check-cfg-features to enable compile-time checking of features (rust-lang/cargo#10408)
- Remove invalid target-specific dependency example. (rust-lang/cargo#10401)
- Fix errors in `cargo fetch` usage guide (rust-lang/cargo#10398)
- Fix some broken doc links. (rust-lang/cargo#10404)
- Implement "artifact dependencies" (RFC-3028) (rust-lang/cargo#9992)
- Print executable name on cargo test --no-run rust-lang/cargo#2 (rust-lang/cargo#10346)
- Avoid new deprecation warnings from clap 3.1.0 (rust-lang/cargo#10396)

2 years agoRename `region_should_not_be_omitted` to `should_print_region`
Tomasz Miąsko [Tue, 22 Feb 2022 00:00:00 +0000 (00:00 +0000)]
Rename `region_should_not_be_omitted` to `should_print_region`

to avoid double negation

2 years agoUpdate cargo
Eric Huss [Wed, 23 Feb 2022 07:22:42 +0000 (23:22 -0800)]
Update cargo

2 years agorustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".
Eduard-Mihai Burtescu [Thu, 27 Jan 2022 09:44:25 +0000 (09:44 +0000)]
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".

2 years agorustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.
Eduard-Mihai Burtescu [Wed, 26 Jan 2022 03:39:14 +0000 (03:39 +0000)]
rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.

2 years agorustc_errors: remove `struct_dummy`.
Eduard-Mihai Burtescu [Wed, 26 Jan 2022 04:40:43 +0000 (04:40 +0000)]
rustc_errors: remove `struct_dummy`.

2 years agorustc_errors: handle `force_warn` only through `DiagnosticId::Lint`.
Eduard-Mihai Burtescu [Wed, 26 Jan 2022 03:46:56 +0000 (03:46 +0000)]
rustc_errors: handle `force_warn` only through `DiagnosticId::Lint`.

2 years agoReplace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.
Eduard-Mihai Burtescu [Sun, 23 Jan 2022 20:41:46 +0000 (20:41 +0000)]
Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.

2 years agoRemove unused ordering derivations and bounds for `SimplifiedTypeGen`
pierwill [Tue, 22 Feb 2022 21:56:37 +0000 (15:56 -0600)]
Remove unused ordering derivations and bounds for `SimplifiedTypeGen`

2 years agorustc_errors: add `downgrade_to_delayed_bug` to `Diagnostic` itself.
Eduard-Mihai Burtescu [Sun, 23 Jan 2022 23:11:37 +0000 (23:11 +0000)]
rustc_errors: add `downgrade_to_delayed_bug` to `Diagnostic` itself.

2 years agoadd some more summary from pr discussion
Dylan DPC [Wed, 23 Feb 2022 02:29:02 +0000 (03:29 +0100)]
add some more summary from pr discussion

2 years agoadd some more summary from pr discussion
Dylan DPC [Wed, 23 Feb 2022 02:28:27 +0000 (03:28 +0100)]
add some more summary from pr discussion

2 years agoadd matching to errorkind
Dylan DPC [Wed, 23 Feb 2022 02:22:23 +0000 (03:22 +0100)]
add matching to errorkind

2 years agoAuto merge of #93984 - nnethercote:ChunkedBitSet, r=Mark-Simulacrum
bors [Wed, 23 Feb 2022 01:26:07 +0000 (01:26 +0000)]
Auto merge of #93984 - nnethercote:ChunkedBitSet, r=Mark-Simulacrum

Introduce `ChunkedBitSet` and use it for some dataflow analyses.

This reduces peak memory usage significantly for some programs with very
large functions.

r? `@ghost`

2 years agoMiri: extend comments on downcast operation
Ralf Jung [Wed, 23 Feb 2022 00:09:11 +0000 (19:09 -0500)]
Miri: extend comments on downcast operation

2 years agoIntroduce `ChunkedBitSet` and use it for some dataflow analyses.
Nicholas Nethercote [Wed, 9 Feb 2022 13:47:48 +0000 (00:47 +1100)]
Introduce `ChunkedBitSet` and use it for some dataflow analyses.

This reduces peak memory usage significantly for some programs with very
large functions, such as:
- `keccak`, `unicode_normalization`, and `match-stress-enum`, from
  the `rustc-perf` benchmark suite;
- `http-0.2.6` from crates.io.

The new type is used in the analyses where the bitsets can get huge
(e.g. 10s of thousands of bits): `MaybeInitializedPlaces`,
`MaybeUninitializedPlaces`, and `EverInitializedPlaces`.

Some refactoring was required in `rustc_mir_dataflow`. All existing
analysis domains are either `BitSet` or a trivial wrapper around
`BitSet`, and access in a few places is done via `Borrow<BitSet>` or
`BorrowMut<BitSet>`. Now that some of these domains are `ClusterBitSet`,
that no longer works. So this commit replaces the `Borrow`/`BorrowMut`
usage with a new trait `BitSetExt` containing the needed bitset
operations. The impls just forward these to the underlying bitset type.
This required fiddling with trait bounds in a few places.

The commit also:
- Moves `static_assert_size` from `rustc_data_structures` to
  `rustc_index` so it can be used in the latter; the former now
  re-exports it so existing users are unaffected.
- Factors out some common "clear excess bits in the final word"
  functionality in `bit_set.rs`.
- Uses `fill` in a few places instead of loops.

2 years agoDelete Decoder::read_unit
Mark Rousskov [Tue, 22 Feb 2022 23:14:51 +0000 (18:14 -0500)]
Delete Decoder::read_unit

2 years agoProvide copy-free access to raw Decoder bytes
Mark Rousskov [Tue, 22 Feb 2022 23:11:59 +0000 (18:11 -0500)]
Provide copy-free access to raw Decoder bytes

2 years agoProvide raw &str access from Decoder
Mark Rousskov [Tue, 22 Feb 2022 23:05:51 +0000 (18:05 -0500)]
Provide raw &str access from Decoder

2 years agoImprove diagnostic of the unexpected_cfgs lint
Loïc BRANSTETT [Sat, 19 Feb 2022 23:48:10 +0000 (00:48 +0100)]
Improve diagnostic of the unexpected_cfgs lint

2 years agoAdd test for well known names defined by rustc
Loïc BRANSTETT [Sat, 19 Feb 2022 23:04:10 +0000 (00:04 +0100)]
Add test for well known names defined by rustc

2 years agoImprove CheckCfg internal representation
Loïc BRANSTETT [Sat, 19 Feb 2022 22:06:11 +0000 (23:06 +0100)]
Improve CheckCfg internal representation

2 years agoAuto merge of #83706 - a1phyr:fix_vec_layout_calculation, r=JohnTitor
bors [Tue, 22 Feb 2022 20:50:38 +0000 (20:50 +0000)]
Auto merge of #83706 - a1phyr:fix_vec_layout_calculation, r=JohnTitor

Fix a layout possible miscalculation in `alloc::RawVec`

A layout miscalculation could happen in `RawVec` when used with a type whose size isn't a multiple of its alignment. I don't know if such type can exist in Rust, but the Layout API provides ways to manipulate such types. Anyway, it is better to calculate memory size in a consistent way.

2 years agoRustup to rustc 1.61.0-nightly (03a8cc7df 2022-02-21)
bjorn3 [Tue, 22 Feb 2022 19:37:22 +0000 (20:37 +0100)]
Rustup to rustc 1.61.0-nightly (03a8cc7df 2022-02-21)

2 years agoSync from rust 03a8cc7df1d65554a4d40825b0490c93ac0f0236
bjorn3 [Tue, 22 Feb 2022 18:55:24 +0000 (19:55 +0100)]
Sync from rust 03a8cc7df1d65554a4d40825b0490c93ac0f0236

2 years agoFix typo.
NyantasticUwU [Tue, 22 Feb 2022 17:44:45 +0000 (11:44 -0600)]
Fix typo.

Yeah just a typo (probably some breaking changes in here be careful) :)

2 years agoTypo fix: Close inline-code backtick
Antti Korpi [Tue, 22 Feb 2022 17:26:41 +0000 (18:26 +0100)]
Typo fix: Close inline-code backtick

2 years agoAdd test for infinite redirection
Guillaume Gomez [Tue, 22 Feb 2022 14:21:15 +0000 (15:21 +0100)]
Add test for infinite redirection

2 years agoPrevent generation of infinite redirections
Guillaume Gomez [Tue, 22 Feb 2022 14:20:57 +0000 (15:20 +0100)]
Prevent generation of infinite redirections

2 years agoAuto merge of #94254 - matthiaskrgr:rollup-7llbjhd, r=matthiaskrgr
bors [Tue, 22 Feb 2022 14:41:26 +0000 (14:41 +0000)]
Auto merge of #94254 - matthiaskrgr:rollup-7llbjhd, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #94169 (Fix several asm! related issues)
 - #94178 (tidy: fire less "ignoring file length unneccessarily" warnings)
 - #94179 (solarish current_exe using libc call directly)
 - #94196 (compiletest: Print process output info with less whitespace)
 - #94208 (Add the let else tests found missing in the stabilization report)
 - #94237 (Do not suggest wrapping an item if it has ambiguous un-imported methods)
 - #94246 (ScalarMaybeUninit is explicitly hexadecimal in its formatting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoBump download-ci-llvm-stamp for llvm-nm inclusion
Krasimir Georgiev [Tue, 22 Feb 2022 13:47:44 +0000 (14:47 +0100)]
Bump download-ci-llvm-stamp for llvm-nm inclusion

We started using it in https://github.com/rust-lang/rust/pull/94023.

2 years agolocal_id is always != 0 at this point
Santiago Pastorino [Tue, 22 Feb 2022 12:37:47 +0000 (09:37 -0300)]
local_id is always != 0 at this point

2 years agoRollup merge of #94246 - RalfJung:hex, r=oli-obk
Matthias Krüger [Tue, 22 Feb 2022 11:16:34 +0000 (12:16 +0100)]
Rollup merge of #94246 - RalfJung:hex, r=oli-obk

ScalarMaybeUninit is explicitly hexadecimal in its formatting

This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in https://github.com/rust-lang/rust/pull/94189.

r? ``@oli-obk``

2 years agoRollup merge of #94237 - compiler-errors:dont-wrap-ambiguous-receivers, r=lcnr
Matthias Krüger [Tue, 22 Feb 2022 11:16:33 +0000 (12:16 +0100)]
Rollup merge of #94237 - compiler-errors:dont-wrap-ambiguous-receivers, r=lcnr

Do not suggest wrapping an item if it has ambiguous un-imported methods

If the method is defined for the receiver we have, but is ambiguous during probe, then it probably comes from one of several traits that just weren't `use`d. Don't suggest wrapping the receiver in `Box`/etc., even if that makes the method probe unambiguous.

Fixes #94218