Commit Graph

10960 Commits

Author SHA1 Message Date
bors
2a8dbdb1e2 Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa
Add more *-unwind ABI variants

The following *-unwind ABIs are now supported:
- "C-unwind"
- "cdecl-unwind"
- "stdcall-unwind"
- "fastcall-unwind"
- "vectorcall-unwind"
- "thiscall-unwind"
- "aapcs-unwind"
- "win64-unwind"
- "sysv64-unwind"
- "system-unwind"

cc `@rust-lang/wg-ffi-unwind`
2022-02-08 03:20:05 +00:00
Jeremy Banks
475e4eeb65 Remove obsolete no-op #[main] attribute from compiler. 2022-02-08 00:46:16 +00:00
Eric Holk
97b24f3236 Drop tracking: track borrows of projections
Previous efforts to ignore partially consumed values meant we were also
not considering borrows of a projection. This led to cases where we'd
miss borrowed types which MIR expected to be there, leading to ICEs.
2022-02-07 16:01:27 -08:00
bors
e7cc3bddbe Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis
Lazy type-alias-impl-trait

Previously opaque types were processed by

1. replacing all mentions of them with inference variables
2. memorizing these inference variables in a side-table
3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type

This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing.

This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around.
Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing

* https://github.com/rust-lang/rfcs/pull/2515

much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities).

r? `@nikomatsakis`

fixes #93411
fixes #88236
2022-02-07 23:40:26 +00:00
klensy
eb3b29fd09 14956 -> 14952 exports 2022-02-08 00:13:31 +03:00
Tomasz Miąsko
29185844c4 Add a flag enabling drop range tracking in generators 2022-02-07 12:27:09 -08:00
Jack Huey
7ad48bd4e2 Change inference var check to be in project_type 2022-02-07 15:07:03 -05:00
Jack Huey
3602e0e262 Don't match any projection predicates when the obligation has inference types or consts in GAT substs 2022-02-07 14:54:40 -05:00
klensy
7a75ebed09 15221 -> 14956 exports 2022-02-07 22:45:29 +03:00
kadmin
be236d7fc2 Rm ValuePairs::Ty/Const
Remove old value pairs which is a strict subset of Terms.
2022-02-07 16:42:37 +00:00
Guillaume Gomez
33cbf8908d Add test for block doc comments horizontal trim 2022-02-07 17:07:53 +01:00
Guillaume Gomez
e3942874a0 Fix horizontal trim for block doc comments 2022-02-07 16:50:45 +01:00
Oli Scherer
c93f571c2a Print opaque types from type aliases via their path 2022-02-07 15:50:42 +00:00
Mara Bos
f4377a8932
Rollup merge of #93682 - PatchMixolydic:where-in-the-world-is-const_fn_trait_bound, r=oli-obk
Update tracking issue for `const_fn_trait_bound`

It previously pointed to #57563, the conglomerate issue for `const fn` (presumably under the feature gate `const_fn`). This tracking issue doesn't mention anything about `const_fn_trait_bound`(the only occurrence of "trait bound" is for the now-removed `?const Trait` syntax), which can be confusing to people who want to find out more about trait bounds on `const fn`s. This pull request changes the tracking issue to one meant specifically for `const_fn_trait_bound`, #93706, which can help collect information on this feature's stabilization and point users towards `const_trait_impl` if they're looking for const-in-const-contexts trait bounds.

Fixes #93679.

`````@rustbot````` modify labels +A-const-fn +F-const_trait_impl
2022-02-07 14:08:37 +00:00
Mara Bos
bd245facd4
Rollup merge of #93680 - Mark-Simulacrum:drop-json-reader, r=bjorn3
Drop json::from_reader

Just a small cleanup -- this was essentially unused; the one use site is better suited to reading from &str regardless.
2022-02-07 14:08:36 +00:00
Mara Bos
252ff5ead0
Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-se
remove `allow_fail` test flag

close #93345
2022-02-07 14:08:34 +00:00
Mara Bos
4445a8ff84
Rollup merge of #93394 - m-ou-se:fix-93378, r=estebank
Don't allow {} to refer to implicit captures in format_args.

Fixes #93378
2022-02-07 14:08:33 +00:00
Mara Bos
557d300e1b
Rollup merge of #91530 - bobrippling:suggest-1-tuple-parens, r=camelid
Suggest 1-tuple parentheses on exprs without existing parens

A follow-on from #86116, split out from #90677.

This alters the suggestion to add a trailing comma to create a 1-tuple - previously we would only apply this if the relevant expression was parenthesised. We now make the suggestion regardless of parentheses, which reduces the fragility of the check (w.r.t formatting).

e.g.
```rust
let a: Option<(i32,)> = Some(3);
```

gets the below suggestion:

```rust
let a: Option<(i32,)> = Some((3,));
//                           ^ ^^
```

This change also improves the suggestion in other ways, such as by only making the suggestion if the types would match after the suggestion is applied and making the suggestion a multipart suggestion.
2022-02-07 14:08:31 +00:00
kadmin
fdd6f4e56c Add in ValuePair::Term
This adds in an enum when matching on positions which can either be types or consts.
It will default to emitting old special cased error messages for types.
2022-02-07 05:53:22 +00:00
bors
926e7843ea Auto merge of #93643 - lcnr:fold-substs-perf, r=michaelwoerister
use `fold_list` in `try_super_fold_with` for `SubstsRef`

split out from #93505 as this by itself is responsible for most of the perf improvements there

r? `@michaelwoerister`
2022-02-07 03:47:47 +00:00
Mark Rousskov
257839bd88 Delete query stats
These statistics are computable from the self-profile data and/or ad-hoc
collectable as needed, and in the meantime contribute to rustc bootstrap times.
2022-02-06 21:35:00 -05:00
bors
25b21a1d16 Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obk
Fix invalid special casing of the unreachable! macro

This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro.

~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is [required](https://github.com/rust-lang/rust/issues/92137#issuecomment-1018630522) because of concatenation that needs to be done inside the macro:~~
```rust
$crate::concat!("internal error: entered unreachable code: ", $fmt)
```

**In summary** the new behavior for the `unreachable!` macro with this pr is:

Edition 2021:
```rust
let x = 5;
unreachable!("x is {x}");
```
```
internal error: entered unreachable code: x is 5
```

Edition <= 2018:
```rust
let x = 5;
unreachable!("x is {x}");
```
```
internal error: entered unreachable code: x is {x}
```

Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](https://github.com/rust-lang/rust/issues/92137#issuecomment-998441613).
If someone could start a perf run and then a crater run this would be appreciated.

Fixes https://github.com/rust-lang/rust/issues/92137
2022-02-07 00:26:52 +00:00
cynecx
e075586d4f add tests and fix comments 2022-02-07 01:21:23 +01:00
Rob Pilling
82a012299d Merge duplicate suggestion string 2022-02-06 20:58:24 +00:00
Rob Pilling
344ea6e0e5 Factor out emit_tuple_wrap_err, improve Applicability 2022-02-06 20:58:24 +00:00
cynecx
03733ca65a #[used(linker)] attribute (https://github.com/dtolnay/linkme/issues/41) 2022-02-06 20:23:23 +01:00
Ruby Lazuli
57b102ff73
Fix tracking issue for const_fn_trait_bound
It previously pointed to #57563, the conglomerate issue for
`const fn` (presumably under the feature gate `const_fn`).
`const_fn_trait_bounds` weren't mentioned here, so this commit changes
its tracking issue to a new one.
2022-02-06 10:43:26 -06:00
Matthias Krüger
4695c2157c
Rollup merge of #93489 - Amanieu:panic_no_unwind, r=nagisa
Mark the panic_no_unwind lang item as nounwind

This has 2 effects:
- It helps LLVM when inlining since it doesn't need to generate landing pads for `panic_no_unwind`.
- It makes it sound for a panic handler to unwind even if `PanicInfo::can_unwind` returns true. This will simply cause another panic once the unwind tries to go past the `panic_no_unwind` lang item. Eventually this will cause a stack overflow, which is safe.
2022-02-06 10:43:51 +01:00
Matthias Krüger
9f4559c345
Rollup merge of #90998 - jhpratt:require-const-stability, r=oli-obk
Require const stability attribute on all stable functions that are `const`

This PR requires all stable functions (of all kinds) that are `const fn` to have a `#[rustc_const_stable]` or `#[rustc_const_unstable]` attribute. Stability was previously implied if omitted; a follow-up PR is planned to change the fallback to be unstable.
2022-02-06 10:43:50 +01:00
Matthias Krüger
cbf4b46640
Rollup merge of #93669 - compiler-errors:const-generic-args, r=lcnr
Resolve lifetimes for const generic defaults

We weren't visiting the const generic default argument in `rustc_resolve::late::lifetimes`. This seems to fix the issue, and we deny any non-`'static` lifetimes anyways.

Fixes #93647
2022-02-06 04:13:36 +01:00
Matthias Krüger
59baf4db0f
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
Change struct expr pretty printing to match rustfmt style

This PR backports trailing comma support from https://github.com/dtolnay/prettyplease into rustc_ast_pretty and uses it to improve the formatting of struct expressions.

Example:

```rust
macro_rules! stringify_expr {
    ($expr:expr) => {
        stringify!($expr)
    };
}

fn main() {
    println!("{}", stringify_expr!(Struct {
        a: Struct { b, c },
    }));
    println!("{}", stringify_expr!(Struct {
        aaaaaaaaaa: AAAAAAAAAA,
        bbbbbbbbbb: Struct {
            cccccccccc: CCCCCCCCCC,
            dddddddddd: DDDDDDDDDD,
            eeeeeeeeee: EEEEEEEEEE,
        },
    }));
}
```

🤮 Before:

```console
Struct{a: Struct{b, c,},}
Struct{aaaaaaaaaa: AAAAAAAAAA,
    bbbbbbbbbb:
        Struct{cccccccccc: CCCCCCCCCC,
            dddddddddd: DDDDDDDDDD,
            eeeeeeeeee: EEEEEEEEEE,},}
```

After:

```console
Struct { a: Struct { b, c } }
Struct {
    aaaaaaaaaa: AAAAAAAAAA,
    bbbbbbbbbb: Struct {
        cccccccccc: CCCCCCCCCC,
        dddddddddd: DDDDDDDDDD,
        eeeeeeeeee: EEEEEEEEEE,
    },
}
```
2022-02-06 04:13:32 +01:00
Matthias Krüger
4a3be6e6e2
Rollup merge of #92383 - lancethepants:armv7-unknown-linux-uclibceabi, r=nagisa
Add new target armv7-unknown-linux-uclibceabi (softfloat)

This adds the new target `armv7-unknown-linux-uclibceabi (softfloat)`. It is of course similar to `armv7-unknown-linux-uclibceabihf (hardfloat)` which was just recently added to rust except that it is `softfloat`.

My interest lies in the Broadcom BCM4707/4708/BCM4709 family, notably found in some Netgear and Asus consumer routers. The armv7 Cortex-A9 cpus found in these devices do not have an fpu or NEON support.

With this patch I've been able to bootstrap rustc, std and host tools `(extended = true)` to run on the target device for native compilation, allowing the target to be used as a development platform.

With the recent addition of `armv7-unknown-linux-uclibceabihf (hardfloat)` it looks like many of the edge cases of using the uclibc c-library are getting worked out nicely. I've been able to compile some complex projects. Some patching still needed in some crates, but getting there for sure.  I think `armv7-unknown-linux-uclibceabi` is ready to be a tier 3 target.

I use a cross-toolchain from my project to bootstrap rust.
https://github.com/lancethepants/tomatoware
The goal of this project is to create a native development environment with support for various languages.
2022-02-06 04:13:30 +01:00
Matthias Krüger
0eda3fa761
Rollup merge of #92300 - Itus-Shield:mips64-openwrt, r=nagisa
mips64-openwrt-linux-musl: Add Tier 3 target

Tier 3 tuple for Mips64 OpenWrt toolchain.

This add first-time support for OpenWrt.  Future Tier3 targets will be added as I test them.

Signed-off-by: Donald Hoskins <grommish@gmail.com>
2022-02-06 04:13:29 +01:00
Matthias Krüger
58bfe72f52
Rollup merge of #91939 - GKFX:feature-91866, r=cjgillot
Clarify error on casting larger integers to char

Closes #91836 with changes to E0604.md and a `span_help`.
2022-02-06 04:13:29 +01:00
Mark Rousskov
a1c261cd09 Store rlink data in opaque binary format on disk 2022-02-05 15:17:54 -05:00
Mark Rousskov
0fb2b7a2da Drop json::from_reader
Performing UTF-8 decode outside the JSON module makes more sense in almost all cases.
2022-02-05 15:07:10 -05:00
bors
88fb06a1f3 Auto merge of #93539 - petrochenkov:doclink, r=camelid,michaelwoerister
rustdoc: Collect traits in scope for foreign inherent impls

Inherent impls can be inlined for variety of reasons (impls of reexported types, impls available through `Deref`, impls inlined for unclear reasons like in https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480).
If an impl is inlined, then doc links in its comments are resolved and we may need the set of traits that are in scope at that impl's definition point.
So in this PR we simply collect traits in scope for *all* inherent impls from other crates if their `Self` type is public, which is very similar for the strategy for trait impls previously used in https://github.com/rust-lang/rust/pull/88679.

Fixes https://github.com/rust-lang/rust/issues/93476
Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1026520300
Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480
2022-02-05 18:27:06 +00:00
lcnr
ac0027d45c update comment 2022-02-05 10:45:50 +01:00
Michael Goulet
bcf98841d4 resolve lifetimes for const generic defaults 2022-02-05 01:30:14 -08:00
lancethepants
8c6f7fd5e1 Add new target armv7-unknown-linux-uclibceabi (softfloat) 2022-02-04 11:45:00 -07:00
Matthias Krüger
2d62bd00ff
Rollup merge of #93615 - Kobzol:stable-hash-opt-endianness, r=the8472
Fix `isize` optimization in `StableHasher` for big-endian architectures

This PR fixes a problem with the stable hash optimization introduced in https://github.com/rust-lang/rust/pull/93432. As `@michaelwoerister` has [found out](https://github.com/rust-lang/rust/pull/93432#issuecomment-1028756212), the original implementation wouldn't produce the same hash on little/big architectures.

r? `@the8472`
2022-02-04 18:42:18 +01:00
Matthias Krüger
9b7f1f5649
Rollup merge of #93608 - nnethercote:speed-up-find_library_crate, r=petrochenkov
Clean up `find_library_crate`

Some clean-ups.

r? `@petrochenkov`
2022-02-04 18:42:16 +01:00
Matthias Krüger
2fe9a32ed2
Rollup merge of #90132 - joshtriplett:stabilize-instrument-coverage, r=wesleywiser
Stabilize `-Z instrument-coverage` as `-C instrument-coverage`

(Tracking issue for `instrument-coverage`: https://github.com/rust-lang/rust/issues/79121)

This PR stabilizes support for instrumentation-based code coverage, previously provided via the `-Z instrument-coverage` option. (Continue supporting `-Z instrument-coverage` for compatibility for now, but show a deprecation warning for it.)

Many, many people have tested this support, and there are numerous reports of it working as expected.

Move the documentation from the unstable book to stable rustc documentation. Update uses and documentation to use the `-C` option.

Addressing questions raised in the tracking issue:

> If/when stabilized, will the compiler flag be updated to -C instrument-coverage? (If so, the -Z variant could also be supported for some time, to ease migrations for existing users and scripts.)

This stabilization PR updates the option to `-C` and keeps the `-Z` variant to ease migration.

> The Rust coverage implementation depends on (and automatically turns on) -Z symbol-mangling-version=v0. Will stabilizing this feature depend on stabilizing v0 symbol-mangling first? If so, what is the current status and timeline?

This stabilization PR depends on https://github.com/rust-lang/rust/pull/90128 , which stabilizes `-C symbol-mangling-version=v0` (but does not change the default symbol-mangling-version).

> The Rust coverage implementation implements the latest version of LLVM's Coverage Mapping Format (version 4), which forces a dependency on LLVM 11 or later. A compiler error is generated if attempting to compile with coverage, and using an older version of LLVM.

Given that LLVM 13 has now been released, requiring LLVM 11 for coverage support seems like a reasonable requirement. If people don't have at least LLVM 11, nothing else breaks; they just can't use coverage support. Given that coverage support currently requires a nightly compiler and LLVM 11 or newer, allowing it on a stable compiler built with LLVM 11 or newer seems like an improvement.

The [tracking issue](https://github.com/rust-lang/rust/issues/79121) and the [issue label A-code-coverage](https://github.com/rust-lang/rust/labels/A-code-coverage) link to a few open issues related to `instrument-coverage`, but none of them seem like showstoppers. All of them seem like improvements and refinements we can make after stabilization.

The original `-Z instrument-coverage` support went through a compiler-team MCP at https://github.com/rust-lang/compiler-team/issues/278 . Based on that, `@pnkfelix` suggested that this needed a stabilization PR and a compiler-team FCP.
2022-02-04 18:42:13 +01:00
Vadim Petrochenkov
afc0030ed3 rustdoc: Collect traits in scope for foreign inherent impls 2022-02-04 22:26:33 +08:00
Matthias Krüger
4b7035918c
Rollup merge of #93631 - notriddle:notriddle/cleanup-some-into-iter, r=oli-obk
rustc_mir_dataflow: use iter::once instead of Some().into_iter
2022-02-04 14:59:06 +01:00
Matthias Krüger
03cad867a6
Rollup merge of #93630 - matthiaskrgr:clipperf, r=oli-obk
clippy::perf fixes

single_char_pattern and to_string_in_format_args
2022-02-04 14:59:05 +01:00
Matthias Krüger
92a7f5fa07
Rollup merge of #93593 - JulianKnodt:master, r=oli-obk
Fix ret > 1 bound if shadowed by const

Prior to a change, it would only look at types in bounds. When it started looking for consts,
shadowing type variables with a const would cause an ICE, so now defer looking at consts only if
there are no types present.

cc ``````@compiler-errors``````
Should Fix #93553
2022-02-04 14:59:04 +01:00
Matthias Krüger
f7e0f97631
Rollup merge of #93402 - ehuss:llvm-dialog, r=michaelwoerister
Windows: Disable LLVM crash dialog boxes.

This disables the crash dialog box on Windows. When LLVM hits an assertion, it will open a dialog box with Abort/Retry/Ignore. This is annoying on CI because CI will just hang until it times out (which can take hours).

Instead of opening a dialog box, it will print a message like this:

```
Assertion failed: isa<X>(Val) && "cast<Ty>() argument of incompatible type!", file D:\Proj\rust\rust\src\llvm-project\llvm\include\llvm/Support/Casting.h, line 255
```

Closes #92829
2022-02-04 14:58:57 +01:00
lcnr
711e736262 fold substs 2022-02-04 11:10:02 +01:00
Nicholas Nethercote
2826586b91 Add a comment about possible mismatches. 2022-02-04 13:10:05 +11:00
Nicholas Nethercote
2b8d3dea63 Remove staticlibs local variable. 2022-02-04 13:10:00 +11:00
Jacob Pratt
41f84c258a
Require const stability on all stable const items
This was supposed to be the case previously, but a missed method call
meant that trait impls were not checked.
2022-02-03 19:15:56 -05:00
Nicholas Nethercote
6dcda2aaec Clean up find_library_crate.
By introducing prefix and suffix variables for all file types, and
renaming some variables.
2022-02-04 10:55:32 +11:00
Michael Howell
a2a4cababe rustc_mir_dataflow: use iter::once instead of Some().into_iter 2022-02-03 13:52:26 -07:00
Matthias Krüger
de2abc29e9 clippy::perf fixes
single_char_pattern and to_string_in_format_args
2022-02-03 21:45:51 +01:00
David Tolnay
40fcbbafa0
Change struct expr pretty printing to match rustfmt style 2022-02-03 10:59:35 -08:00
David Tolnay
63406ac771
Support offsetting the most recent break 2022-02-03 10:59:34 -08:00
David Tolnay
8bdf08fbed
Change pp indent to signed to allow negative indents 2022-02-03 10:59:09 -08:00
David Tolnay
0b7e1baa58
Add trailing comma support 2022-02-03 10:56:58 -08:00
Camille GILLOT
710662c8ac Remove defaultness from ImplItem. 2022-02-03 18:56:08 +01:00
Oli Scherer
7546163335 Improve self-referential diagnostic somewhat 2022-02-03 15:59:34 +00:00
bors
4e8fb743cc Auto merge of #93621 - JohnTitor:rollup-1bcud0x, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #92310 (rustdoc: Fix ICE report)
 - #92802 (Deduplicate lines in long const-eval stack trace)
 - #93515 (Factor convenience functions out of main printer implementation)
 - #93566 (Make rustc use `RUST_BACKTRACE=full` by default)
 - #93589 (Use Option::then in two places)
 - #93600 (fix: Remove extra newlines from junit output)
 - #93606 (Correct incorrect description of preorder traversals)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-03 15:49:30 +00:00
kadmin
2dfd77d675 Fix ret > 1 bound if shadowed by const
Prior to a change, it would only look at types in bounds. When it started looking for consts,
shadowing type variables with a const would cause an ICE, so now defer looking at consts only if
there are no types present.
2022-02-03 15:17:51 +00:00
Eric Huss
c64d6bf5af Only disable dialogs on CI.
The "CI" environment var isn't universal (for example, I think Azure
uses TF_BUILD). However, we are mostly concerned with rust-lang/rust's
own CI which currently is GitHub Actions which does set "CI". And I
think most other providers use "CI" as well.
2022-02-03 07:03:44 -08:00
Oli Scherer
d526a8d594 Clean up opaque type obligations in query results 2022-02-03 13:44:29 +00:00
Yuki Okushi
38adea96c5
Rollup merge of #93606 - JakobDegen:mischaracterized-preorder, r=oli-obk
Correct incorrect description of preorder traversals

The internal documentation for the `Preorder` type gave an incorrect description (the description is not even correct for the example provided, since C is visited after one of its successors). This corrects the description, and adds in a sentence explaining more precisely how the traversals are performed.
2022-02-03 22:20:29 +09:00
Yuki Okushi
7712dfd46e
Rollup merge of #93589 - est31:option_then, r=cjgillot
Use Option::then in two places
2022-02-03 22:20:27 +09:00
Yuki Okushi
333d3d6243
Rollup merge of #93566 - Aaron1011:rustc-backtrace, r=davidtwco
Make rustc use `RUST_BACKTRACE=full` by default

Compiler panics should be rare - when they do occur, we want the report
filed by the user to contain as much information as possible. This is
especially important when the panic is due to an incremental compilation
bug, since we may not have enough information to reproduce it.

This PR sets `RUST_BACKTRACE=full` inside `rustc` if the user has not
explicitly set `RUST_BACKTRACE`. This is more verbose than
`RUST_BACKTRACE=1`, but this may make it easier to debug incremental
compilation issues. Users who find this too verbose can still manually
set `RUST_BACKTRACE` before invoking the compiler.

This only affects `rustc` (and any tool using `rustc_driver::install_ice_hook`).
It does *not* affect any user crates or the standard library -
backtraces will continue to be off by default in any application
*compiled* by rustc.
2022-02-03 22:20:26 +09:00
Yuki Okushi
761705ebe5
Rollup merge of #93515 - dtolnay:convenience, r=davidtwco
Factor convenience functions out of main printer implementation

The pretty printer in rustc_ast_pretty has a section of methods commented "Convenience functions to talk to the printer". This PR pulls those out to a separate module. This leaves pp.rs with only the minimal API that is core to the pretty printing algorithm.

I found this separation to be helpful in https://github.com/dtolnay/prettyplease because it makes clear when changes are adding some fundamental new capability to the pretty printer algorithm vs just making it more convenient to call some already existing functionality.
2022-02-03 22:20:25 +09:00
Yuki Okushi
2fe9f763d0
Rollup merge of #92802 - compiler-errors:deduplicate-stack-trace, r=oli-obk
Deduplicate lines in long const-eval stack trace

Lemme know if this is kinda overkill, lol.

Fixes #92796
2022-02-03 22:20:24 +09:00
Yuki Okushi
9298bd8197
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
rustdoc: Fix ICE report

The ICE report in rustdoc was confusing because it was returning an argument parse error:

```
thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:1212:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: 'crate-version'
```

This is because the ICE reporter was trying to parse the arguments as rustc, not rustdoc.  Since an argument error is a fatal error, it was early-exiting with the argument error due to unwinding.

This changes it to be a more primitive scan of the arguments. The arguments being checked are pretty simple, and only have a small handful of forms that are easy to check for.

It now looks like this:

```
thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:1212:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.59.0-dev running on x86_64-apple-darwin

note: compiler flags: --crate-type lib -Z treat-err-as-bug

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
```

It still says `rustc`, but I can live with that.
2022-02-03 22:20:23 +09:00
bors
8b7853fe1f Auto merge of #92932 - ouz-a:master, r=oli-obk
Temporary fix for the layout of aligned enums

Fix for the issue #92464

~~I was after this issue for quite some time now, I have a temporary fix for it.
I think the current problem is [here](e75f96763f/compiler/rustc_middle/src/ty/layout.rs (L1305-L1310)) created `tag` value might be wrong, because when I checked `min` and `max` values it's always between 0..1, which results in wrong size comparison in a few lines down below.
I think `min` and `max` values don't take `#[repr(aligned(8))]` into consideration and just act from base values assigned inside the enum. If what I am saying is true, aligned enums were created with the wrong layout for some time.~~

~~As stated in the title this is only a temporary fix and I think this needs further investigation, if someone wants to mentor it I would like to work on that too.~~ 😸

**Edit: Weird some tests fail now going to close this for now...**

**Edit2: I made it work again.**

I think I figured out the main problem of the issue, layout types of aligned enums with custom discriminant types were not handled, which resulted in confusing(such as this issue) behavior down the line, this is a kinda hacky fix for the issue.
2022-02-03 12:46:02 +00:00
Jakub Beránek
c21b8e12a4
Fix isize optimization in StableHasher for big-endian architectures 2022-02-03 11:47:41 +01:00
Michael Woerister
fc7f419a63 debuginfo: Bring back DW_AT_containing_type for vtables after it has accidentally been
removed in https://github.com/rust-lang/rust/pull/89597.

Also describe vtables as structs with a field for each entry.
2022-02-03 10:03:16 +01:00
Michael Woerister
f4799b8709 debuginfo: Make some helper functions in rustc_codegen_llvm::debuginfo::metadata more generally applicable. 2022-02-03 10:03:16 +01:00
bors
1be5c8f909 Auto merge of #93432 - Kobzol:stable-hash-isize-hash-compression, r=the8472
Compress amount of hashed bytes for `isize` values in StableHasher

This is another attempt to land https://github.com/rust-lang/rust/pull/92103, this time hopefully with a correct implementation w.r.t. stable hashing guarantees. The previous PR was [reverted](https://github.com/rust-lang/rust/pull/93014) because it could produce the [same hash](https://github.com/rust-lang/rust/pull/92103#issuecomment-1014625442) for different values even in quite simple situations. I have since added a basic [test](https://github.com/rust-lang/rust/pull/93193) that should guard against that situation, I also added a new test in this PR, specialised for this optimization.

## Why this optimization helps
Since the original PR, I have tried to analyze why this optimization even helps (and why it especially helps for `clap`). I found that the vast majority of stable-hashing `i64` actually comes from hashing `isize` (which is converted to `i64` in the stable hasher). I only found a single place where is this datatype used directly in the compiler, and this place has also been showing up in traces that I used to find out when is `isize` being hashed. This place is `rustc_span::FileName::DocTest`, however, I suppose that isizes also come from other places, but they might not be so easy to find (there were some other entries in the trace). `clap` hashes about 8.5 million `isize`s, and all of them fit into a single byte, which is why this optimization has helped it [quite a lot](https://github.com/rust-lang/rust/pull/92103#issuecomment-1005711861).

Now, I'm not sure if special casing `isize` is the correct solution here, maybe something could be done with that `isize` inside `DocTest` or in other places, but that's for another discussion I suppose. In this PR, instead of hardcoding a special case inside `SipHasher128`, I instead put it into `StableHasher`, and only used it for `isize` (I tested that for `i64` it doesn't help, or at least not for `clap` and other few benchmarks that I was testing).

## New approach
Since the most common case is a single byte, I added a fast path for hashing `isize` values which positive value fits within a single byte, and a cold path for the rest of the values.

To avoid the previous correctness problem, we need to make sure that each unique `isize` value will produce a unique hash stream to the hasher. By hash stream I mean a sequence of bytes that will be hashed (a different sequence should produce a different hash, but that is of course not guaranteed).

We have to distinguish different values that produce the same bit pattern when we combine them. For example, if we just simply skipped the leading zero bytes for values that fit within a single byte, `(0xFF, 0xFFFFFFFFFFFFFFFF)` and `(0xFFFFFFFFFFFFFFFF, 0xFF)` would send the same hash stream to the hasher, which must not happen.

To avoid this situation, values `[0, 0xFE]` are hashed as a single byte. When we hash a larger (treating `isize` as `u64`) value, we first hash an additional byte `0xFF`. Since `0xFF` cannot occur when we apply the single byte optimization, we guarantee that the hash streams will be unique when hashing two values `(a, b)` and `(b, a)` if `a != b`:
1) When both `a` and `b` are within `[0, 0xFE]`, their hash streams will be different.
2) When neither `a` and `b` are within `[0, 0xFE]`, their hash streams will be different.
3) When `a` is within `[0, 0xFE]` and `b` isn't, when we hash `(a, b)`, the hash stream will definitely not begin with `0xFF`. When we hash `(b, a)`, the hash stream will definitely begin with `0xFF`. Therefore the hash streams will be different.

r? `@the8472`
2022-02-03 01:08:45 +00:00
Jakob Degen
3b52ccaa95 Correct incorrect description of preorder traversals. 2022-02-02 19:28:01 -05:00
Amanieu d'Antras
547b4e601e Add more *-unwind ABI variants
The following *-unwind ABIs are now supported:
- "C-unwind"
- "cdecl-unwind"
- "stdcall-unwind"
- "fastcall-unwind"
- "vectorcall-unwind"
- "thiscall-unwind"
- "aapcs-unwind"
- "win64-unwind"
- "sysv64-unwind"
- "system-unwind"
2022-02-02 22:21:24 +01:00
bors
27f5d830eb Auto merge of #93594 - matthiaskrgr:rollup-lcvhpdv, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #92528 (Make `Fingerprint::combine_commutative` associative)
 - #93221 ([borrowck] Fix help on mutating &self in async fns)
 - #93542 (Prevent lifetime elision in type alias)
 - #93546 (Validate that values in switch int terminator are unique)
 - #93571 (better suggestion for duplicated `where` clause)
 - #93574 (don't suggest adding `let` due to bad assignment expressions inside of `while` loop)
 - #93590 (More let_else adoptions)
 - #93592 (Remove unused dep from rustc_arena)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-02 19:07:07 +00:00
Matthias Krüger
93155c5956
Rollup merge of #93592 - est31:remove_unused_deps, r=bjorn3
Remove unused dep from rustc_arena
2022-02-02 19:34:08 +01:00
Matthias Krüger
3388e6d9fd
Rollup merge of #93590 - est31:let_else, r=lcnr
More let_else adoptions

Continuation of #89933, #91018, #91481, #93046.
2022-02-02 19:34:07 +01:00
Matthias Krüger
799bded9b4
Rollup merge of #93574 - compiler-errors:bad-let-suggestion, r=lcnr
don't suggest adding `let` due to bad assignment expressions inside of `while` loop

adds a check that our `lhs` expression is actually within the conditional part of the `while` loop, instead of anywhere in the `while` body.

fixes #93486
2022-02-02 19:34:06 +01:00
Matthias Krüger
ef500863bd
Rollup merge of #93571 - compiler-errors:better-where-suggestion, r=lcnr
better suggestion for duplicated `where` clause

fixes #93567
2022-02-02 19:34:05 +01:00
Matthias Krüger
b53eaf7ce5
Rollup merge of #93546 - tmiasko:validate-switch-int, r=oli-obk
Validate that values in switch int terminator are unique
2022-02-02 19:34:04 +01:00
Matthias Krüger
b622552e10
Rollup merge of #93221 - alyssaverkade:fix-93093, r=wesleywiser
[borrowck] Fix help on mutating &self in async fns

Previously, when rustc was provided an async function that tried to
mutate through a shared reference to an implicit self (as shown in the
ui test), rustc would suggest modifying the parameter signature
to `&mut` + the fully qualified name of the ty (in the case of the repro
`S`). If a user modified their code to match the suggestion, the
compiler would not accept it.

This commit modifies the suggestion so that when rustc is provided the
ui test that is also attached in this commit, it suggests (correctly)
`&mut self`. We try to be careful about distinguishing between implicit
and explicit self annotations, since the latter seem to be handled
correctly already.

This is my first PR here so I'm pretty sure I probably missed something/could use better terminology. I also didn't try to make the match exhaustive since implicit self is the only real special case that I need to handle (that I'm aware of), and I'm pretty sure there's a cleaner way to do this so any advice would be greatly appreciated! (I'm also not terribly confident about how I wrote the ui tests)

here is your cc as requested `@compiler-errors`

This is an attempt to fix #93093
2022-02-02 19:34:02 +01:00
Matthias Krüger
21ffe45631
Rollup merge of #92528 - tmiasko:combine-commutative, r=michaelwoerister
Make `Fingerprint::combine_commutative` associative

The previous implementation swapped lower and upper 64-bits of a result
of modular addition, so the function was non-associative.

r? `@Aaron1011`
2022-02-02 19:34:01 +01:00
Oli Scherer
d9bb93f3a4 Fix some doctests where the main function returns an opaque type 2022-02-02 17:15:18 +00:00
est31
3cb7618f58 Remove unused dep from rustc_arena 2022-02-02 17:37:14 +01:00
est31
670f5c6ef3 More let_else adoptions 2022-02-02 17:11:01 +01:00
Oli Scherer
be153f0976 Only prevent TAITs from defining each other, RPIT and async are fine, they only ever have one defining site, and it is ordered correctly around expected and actual type in type comparisons 2022-02-02 15:40:12 +00:00
Oli Scherer
7f608eb9ed Prevent two opaque types in their defining scopes from being defined via the other 2022-02-02 15:40:12 +00:00
Oli Scherer
7a1ccf9a03 Avoid an ICE in the presence of HKL 2022-02-02 15:40:12 +00:00
Oli Scherer
ee2158f1ee run rustfmt 2022-02-02 15:40:12 +00:00
Oli Scherer
59d0bff0e6 Reduce follow-up errors that are not helpful 2022-02-02 15:40:12 +00:00
Oli Scherer
6560d77a53 Bail out early if there already were errors 2022-02-02 15:40:12 +00:00
Oli Scherer
29c8732436 Make the error for opaque types that have no hidden types a bit informative 2022-02-02 15:40:12 +00:00
Oli Scherer
4d2e965106 Make a span more useful 2022-02-02 15:40:12 +00:00
Oli Scherer
5518d1931d Guess head span of async blocks 2022-02-02 15:40:12 +00:00
Oli Scherer
b6d57ecc0b Hide further opaque type errors if items that could constrain the opaque type have errors 2022-02-02 15:40:12 +00:00
Oli Scherer
e4794d9d1b Undo a change that is now unnecessary 2022-02-02 15:40:12 +00:00