Commit Graph

11194 Commits

Author SHA1 Message Date
Vadim Petrochenkov
da4a235c26 rustc_target: Remove compiler-rt linking hack on Android 2022-02-13 21:22:02 +08:00
bjorn3
5eeff3f073 Remove Config::stderr
1. It captured stdout and not stderr
2. It isn't used anywhere
3. All error messages should go to the DiagnosticOutput instead
4. It modifies thread local state
2022-02-13 11:49:52 +01:00
Matthias Krüger
dff7d51fcc
Rollup merge of #93936 - bjorn3:simplifications2, r=cjgillot
Couple of driver cleanups

* Remove the `RustcDefaultCalls` struct, which hasn't been necessary since the introduction of `rustc_interface`.
* Move the `setup_callbacks` call around for a tiny code deduplication.
* Remove the `SPAN_DEBUG` global as it isn't actually necessary.
2022-02-13 06:44:18 +01:00
Matthias Krüger
aff74a1697
Rollup merge of #93810 - matthewjasper:chalk-and-canonical-universes, r=jackh726
Improve chalk integration

- Support subtype bounds in chalk lowering
- Handle universes in canonicalization
- Handle type parameters in chalk responses
- Use `chalk_ir::LifetimeData::Empty` for `ty::ReEmpty`
- Remove `ignore-compare-mode-chalk` for tests that no longer hang (they may still fail or ICE)

This is enough to get a hello world program to compile with `-Zchalk` now. Some of the remaining issues that are needed to get Chalk integration working on larger programs are:

- rust-lang/chalk#234
- rust-lang/chalk#548
- rust-lang/chalk#734
- Generators are handled differently in chalk and rustc

r? `@jackh726`
2022-02-13 06:44:14 +01:00
Matthias Krüger
953c4dcc30
Rollup merge of #90532 - fee1-dead:improve-const-fn-err-msg, r=oli-obk
More informative error message for E0015

Helps with #92380
2022-02-13 06:44:13 +01:00
Gary Guo
f74e8c7afc Guard against unwinding in cleanup code 2022-02-13 03:10:09 +00:00
bors
5c30d65683 Auto merge of #93670 - erikdesjardins:noundef, r=nikic
Apply noundef attribute to &T, &mut T, Box<T>, bool

This doesn't handle `char` because it's a bit awkward to distinguish it from `u32` at this point in codegen.

Note that this _does not_ change whether or not it is UB for `&`, `&mut`, or `Box` to point to undef. It only applies to the pointer itself, not the pointed-to memory.

Fixes (partially) #74378.

r? `@nikic` cc `@RalfJung`
2022-02-13 00:14:52 +00:00
bors
3cfa4def7c Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk
Inherit lifetimes for async fn instead of duplicating them.

The current desugaring of `async fn foo<'a>(&usize) -> &u8` is equivalent to
```rust
fn foo<'a, '0>(&'0 usize) -> foo<'static, 'static>::Opaque<'a, '0, '_>;
type foo<'_a, '_0>::Opaque<'a, '0, '1> = impl Future<Output = &'1 u8>;
```
following the RPIT model.

Duplicating all the inherited lifetime parameters and setting the inherited version to `'static` makes lowering more complex and causes issues like #61949. This PR removes the duplication of inherited lifetimes to directly use
```rust
fn foo<'a, '0>(&'0 usize) -> foo<'a, '0>::Opaque<'_>;
type foo<'a, '0>::Opaque<'1> = impl Future<Output = &'1 u8>;
```
following the TAIT model.

Fixes https://github.com/rust-lang/rust/issues/61949
2022-02-12 21:42:10 +00:00
Matthew Jasper
030c50824c Address review comment
canonicalize_chalk_query -> canonicalize_query_preserving_universes
2022-02-12 13:39:52 +00:00
Ellen
5e0e7ff068 trailing whitespace 2022-02-12 11:48:58 +00:00
Ellen
9130af2e4d change docs on Res::SelfTy 2022-02-12 11:23:53 +00:00
Ellen
e81e09a24e change to a struct variant 2022-02-12 11:23:53 +00:00
bjorn3
f45ba82370 Remove SPAN_DEBUG global
The only difference between the default and rustc_interface set version
is that the default accesses the source map from SESSION_GLOBALS while
the rustc_interface version accesses the source map from the global
TyCtxt. SESSION_GLOBALS is always set while running the compiler while
the global TyCtxt is not always set. If the global TyCtxt is set, it's
source map is identical to the one in SESSION_GLOBALS
2022-02-12 11:50:02 +01:00
bjorn3
5730173763 Move setup_callbacks call to create_compiler_and_run
This ensures that it is called even when run_in_thread_pool_with_globals
is avoided and reduces code duplication between the parallel and
non-parallel version of run_in_thread_pool_with_globals
2022-02-12 11:47:53 +01:00
bjorn3
bb45f5db78 Remove the RustcDefaultCalls struct
It is a leftover from before the introduction of rustc_interface
2022-02-12 11:47:50 +01:00
Hans Kratz
59536fb023 Allow inlining of ensure_sufficient_stack() 2022-02-12 11:30:04 +01:00
Matthias Krüger
16f490f354
Rollup merge of #93898 - GuillaumeGomez:error-code-check, r=Mark-Simulacrum
tidy: Extend error code check

We discovered in https://github.com/rust-lang/rust/pull/93845 that the error code tidy check didn't check everything: if you remove an error code from the listing even if it has an explanation, then it should error.

It also allowed me to put back `E0192` in that listing as well.

r? ```@Mark-Simulacrum```
2022-02-12 09:26:25 +01:00
Matthias Krüger
f30f6def0f
Rollup merge of #93759 - dtolnay:usetree, r=nagisa
Pretty print ItemKind::Use in rustfmt style

This PR backports the formatting for `use` items from https://github.com/dtolnay/prettyplease into rustc_ast_pretty.

Before:

```rust
use core::{cmp::{Eq, Ord, PartialEq, PartialOrd},
    convert::{AsMut, AsRef, From, Into},
    iter::{DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator,
    IntoIterator, Iterator},
    marker::{Copy as Copy, Send as Send, Sized as Sized, Sync as Sync, Unpin
    as U}, ops::{*, Drop, Fn, FnMut, FnOnce}};
```

After:

```rust
use core::{
    cmp::{Eq, Ord, PartialEq, PartialOrd},
    convert::{AsMut, AsRef, From, Into},
    iter::{
        DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator,
        IntoIterator, Iterator,
    },
    marker::{
        Copy as Copy, Send as Send, Sized as Sized, Sync as Sync, Unpin as U,
    },
    ops::{*, Drop, Fn, FnMut, FnOnce},
};
```
2022-02-12 09:26:23 +01:00
Matthias Krüger
602898a305
Rollup merge of #93595 - compiler-errors:ice-on-lifetime-arg, r=jackh726
fix ICE when parsing lifetime as function argument

I don't really like this, but we basically need to emit an error instead of just delaying an bug, because there are too many places in the AST that aren't covered by my previous PRs...

cc: https://github.com/rust-lang/rust/issues/93282#issuecomment-1028052945
2022-02-12 09:26:21 +01:00
Deadbeef
12397ab48b
Report the selection error when possible 2022-02-12 19:24:43 +11:00
Deadbeef
cccf4b2fc3
Adapt new change 2022-02-12 19:24:43 +11:00
Deadbeef
d3acb9d00e
Handle Fn family trait call errror 2022-02-12 19:24:43 +11:00
Deadbeef
6d6314f878
Rebased and improved errors 2022-02-12 19:24:42 +11:00
Deadbeef
f7f0f843b7
Improve error messages even more 2022-02-12 19:24:08 +11:00
Deadbeef
1b0dcdc341
More informative error message for E0015 2022-02-12 19:24:04 +11:00
bors
9cdefd763b Auto merge of #93691 - compiler-errors:mir-tainted-by-errors, r=oli-obk
Implement `tainted_by_errors` in MIR borrowck, use it to skip CTFE

Putting this up for initial review. The issue that I found is when we're evaluating a const, we're doing borrowck, but doing nothing with the fact that borrowck fails.

This implements a `tainted_by_errors` field for MIR borrowck like we have in infcx, so we can use that information to return an `Err` during const eval if our const fails to borrowck.

This PR needs some cleaning up. I should probably just use `Result` in more places, instead of `.expect`ing in the places I am, but I just wanted it to compile so I could see if it worked!

Fixes #93646

r? `@oli-obk`
feel free to reassign
2022-02-12 05:19:33 +00:00
bors
fc323035ac Auto merge of #93671 - Kobzol:stable-hash-const, r=the8472
Use const generics in SipHasher128's short_write

This was proposed by `@michaelwoerister` [here](https://github.com/rust-lang/rust/pull/93615#discussion_r799485554).
A few comments:
1) I tried to pass `&[u8; LEN]` instead of `[u8; LEN]`. Locally, it resulted in small icount regressions (about 0.5 %). When passing by value, there were no regressions (and no improvements).
2) I wonder if we should use `to_ne_bytes()` in `SipHasher128` to keep it generic and only use `to_le_bytes()` in `StableHasher`. However, currently `SipHasher128` is only used in `StableHasher` and the `short_write` method was private, so I couldn't use it directly from `StableHasher`. Using `to_le()` in the `StableHasher` was breaking this abstraction boundary before slightly.

```rust
debug_assert!(LEN <= 8);
```
This could be done at compile time, but actually I think that now we can remove this assert altogether.

r? `@the8472`
2022-02-12 02:05:11 +00:00
Michael Goulet
5be9e79ae0
Update expr.rs
Revert spurious changes included in PR
2022-02-11 17:48:06 -08:00
Camille GILLOT
10cf626d0e Bless nll tests. 2022-02-12 01:26:17 +01:00
Camille GILLOT
c6a3f5d606 Update error code documentation. 2022-02-12 01:26:17 +01:00
Camille GILLOT
a4da6308b7 Inherit lifetimes for async fn instead of duplicating them. 2022-02-12 01:26:11 +01:00
Guillaume Gomez
087fb23dc9 Add missing E0192 in the error code listing 2022-02-12 00:43:09 +01:00
Matthew Jasper
caa10dc572 Renumber universes when canonicalizing for Chalk
This is required to avoid creating large numbers of universes from each
Chalk query, while still having enough universe information for lifetime
errors.
2022-02-11 21:38:17 +00:00
Matthew Jasper
1e6d38230f Reverse parameter to placeholder substitution in chalk results 2022-02-11 21:38:17 +00:00
Matthew Jasper
d4fa173ed3 Fix more chalk lowering issues
- Implement lowering for subtype goals
- Use correct lang item for Generator trait
- Use `lower_into` for lowering `ty::Variance`
2022-02-11 21:38:17 +00:00
Matthew Jasper
cb3cff3761 Stop using a placeholder for empty regions in Chalk 2022-02-11 21:38:16 +00:00
Matthias Krüger
de0feb30bd
Rollup merge of #93910 - rosehuds:master, r=cjgillot
fix mention of moved function in `rustc_hir` docs

The function was moved from `Crate` to `Map` in db9fea508a but these docs weren't updated
2022-02-11 21:48:52 +01:00
Matthias Krüger
0986b2d0e3
Rollup merge of #93909 - saschanaz:patch-2, r=petrochenkov
Fix typo: explicitely -> explicitly
2022-02-11 21:48:51 +01:00
Matthias Krüger
db7124839c
Rollup merge of #93868 - Amanieu:asm_reg_conflict, r=cjgillot
Fix incorrect register conflict detection in asm!

This would previously incorrectly reject two subregisters that were
distinct but part of the same larger register, for example `al` and
`ah`.
2022-02-11 21:48:49 +01:00
Matthias Krüger
13d636dff2
Rollup merge of #93782 - adamgemmell:dev/adagem01/split-pauth, r=Amanieu
Split `pauth` target feature

Per discussion on https://github.com/rust-lang/rust/issues/86941 we'd like to split `pauth` into `paca` and `pacg` in order to better support possible future environments that only have the keys available for address or generic authentication. At the moment LLVM has the one `pauth` target_feature while Linux presents separate `paca` and `pacg` flags for feature detection.

Because the use of [target_feature](https://rust-lang.github.io/rfcs/2045-target-feature.html) will "allow the compiler to generate code under the assumption that this code will only be reached in hosts that support the feature", it does not make sense to simply translate `paca` into the LLVM feature `pauth`, as it will generate code as if `pacg` is available.

To accommodate this we error if only one of the two features is present. If LLVM splits them in the future we can remove this restriction without making a breaking change.

r? ```@Amanieu```
2022-02-11 21:48:48 +01:00
Matthias Krüger
642414e804
Rollup merge of #92895 - bjorn3:simplifications, r=jackh726
Remove some unused functionality

* Remove the `alt_std_name` option
* Remove the everybody loops pass
* Make two functions private
2022-02-11 21:48:44 +01:00
Matthias Krüger
b7c48b4691
Rollup merge of #91607 - FabianWolff:issue-91560-const-span, r=jackh726
Make `span_extend_to_prev_str()` more robust

Fixes #91560. The logic in `span_extend_to_prev_str()` is currently quite brittle and fails if there is extra whitespace or something else in between, and it also should return an `Option` but doesn't currently.
2022-02-11 21:48:43 +01:00
Michael Goulet
67ad0ffdf8 use body.tainted_by_error to skip loading MIR 2022-02-11 12:45:51 -08:00
Michael Goulet
a431174c23 add tainted_by_errors to mir::Body 2022-02-11 12:45:51 -08:00
Michael Goulet
29c2bb51c0 rework borrowck errors so that it's harder to not set tainted 2022-02-11 12:45:51 -08:00
Michael Goulet
8b7b0a0e49 always cache result from mir_borrowck 2022-02-11 12:45:51 -08:00
Michael Goulet
77dae2d25d skip const eval if we have an error in borrowck 2022-02-11 12:45:51 -08:00
Michael Goulet
4ad272b282 implement tainted_by_errors in mir borrowck 2022-02-11 12:45:51 -08:00
bjorn3
7ba4110012 Make two functions private 2022-02-11 20:28:38 +01:00
bjorn3
55ceed81fe Remove the alt_std_name option
This option introduced in #15820 allows a custom crate to be imported in
the place of std, but with the name std. I don't think there is any
value to this. At most it is confusing users of a driver that uses this option. There are no users of
this option on github. If anyone still needs it, they can emulate it
injecting #![no_core] in addition to their own prelude.
2022-02-11 20:28:38 +01:00
bors
6499c5e7fc Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk
Revert lazy TAIT PR

Revert https://github.com/rust-lang/rust/pull/92306 (sorry `@Aaron1011,` will include your changes in the fix PR)
Revert https://github.com/rust-lang/rust/pull/93783
Revert https://github.com/rust-lang/rust/pull/92007

fixes https://github.com/rust-lang/rust/issues/93788
fixes https://github.com/rust-lang/rust/issues/93794
fixes https://github.com/rust-lang/rust/issues/93821
fixes https://github.com/rust-lang/rust/issues/93831
fixes https://github.com/rust-lang/rust/issues/93841
2022-02-11 17:39:34 +00:00
Kagami Sascha Rosylight
f9cb01f802 Fix typo: explicitely->explicitly 2022-02-11 17:33:27 +01:00
Rose Hudson
45dc8ebb7c fix mention of moved function in rustc_hir docs
the function was moved from `Crate` to `Map` in db9fea508a but the
docs weren't updated
2022-02-11 15:38:31 +00:00
Oli Scherer
d54195db22 Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"
This reverts commit e7cc3bddbe, reversing
changes made to 734368a200.
2022-02-11 07:18:06 +00:00
Oli Scherer
2d8b8f3593 Revert "Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk"
This reverts commit 1f0a96862a, reversing
changes made to bf242bb119.
2022-02-11 07:17:16 +00:00
Oli Scherer
7a71b7a99e Revert "Fix regression from lazy opaque types"
This reverts commit 239f1e716d.
2022-02-11 07:14:58 +00:00
Michael Goulet
784c7a6cad only mark projection as ambiguous if GAT substs are constrained 2022-02-10 22:55:00 -08:00
Matthias Krüger
c543f7dbd4
Rollup merge of #93864 - bjorn3:cleanup_archive_handling, r=petrochenkov
Remove ArchiveBuilder::update_symbols

All paths to an ArchiveBuilder::build call update_symbols first.
2022-02-11 07:48:10 +01:00
Matthias Krüger
a59d312280
Rollup merge of #93861 - JulianKnodt:notraitace, r=wesleywiser
Fix ICE if no trait assoc const eq

Fixes #93835
2022-02-11 07:48:08 +01:00
Matthias Krüger
ddba967855
Rollup merge of #93853 - steffahn:map_by_value, r=wesleywiser
Make all `hir::Map` methods consistently by-value

`hir::Map` only consists of a single reference (as part of the contained `TyCtxt`) anyways, so copying is literally zero overhead compared to passing a reference
2022-02-11 07:48:06 +01:00
Matthias Krüger
8611e292e4
Rollup merge of #93443 - spastorino:add-stable-hash-impl-doc, r=cjgillot
Add comment on stable_hash_impl for OwnerNodes

r? `@cjgillot`

cc `@oli-obk`

`@bors` rollup=always
2022-02-11 07:48:03 +01:00
Matthias Krüger
664255b168
Rollup merge of #92242 - compiler-errors:layout-modulo-regions, r=matthewjasper
Erase regions before calculating layout for packed field capture

Self-explanatory. We just erase region inferencing because we don't need that for layout computation... Q: layouts are always equal modulo regions, right?

Fixes #92240
2022-02-11 07:48:02 +01:00
Charisee
4404a4e365 updating the feature-gate listing and do not require the feature-gate to use the feature 2022-02-10 21:52:08 +00:00
Amanieu d'Antras
20e6c1d013 Fix incorrect register conflict detection in asm!
This would previously incorrectly reject two subregisters that were
distinct but part of the same larger register, for example `al` and
`ah`.
2022-02-10 18:04:09 +00:00
bjorn3
609784711a Unconditionally update symbols
All paths to an ArchiveBuilder::build call update_symbols first.
2022-02-10 18:27:18 +01:00
bjorn3
203b622a65 Remove unnecessary update_symbols call
For cg_llvm update_symbols merely sets a flag, so changing the position
or removing an additional call doesn't have any effect.
2022-02-10 18:18:38 +01:00
kadmin
6bc28c82c4 Fix ICE if no trait assoc const eq 2022-02-10 16:38:40 +00:00
Adam Gemmell
d39a6377e9 Split PAuth target feature 2022-02-10 15:10:33 +00:00
bors
502d6aa47b Auto merge of #93854 - matthiaskrgr:rollup-bh2a85j, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92670 (add kernel target for RustyHermit)
 - #93756 (Support custom options for LLVM build)
 - #93802 (fix oversight in the `min_const_generics` checks)
 - #93808 (Remove first headings indent)
 - #93824 (Stabilize cfg_target_has_atomic)
 - #93830 (Refactor sidebar printing code)
 - #93843 (kmc-solid: Fix wait queue manipulation errors in the `Condvar` implementation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-10 12:31:51 +00:00
Frank Steffahn
7eff2feb62 Remove further usage of &hir::Map 2022-02-10 13:04:59 +01:00
Matthias Krüger
aa2095936a
Rollup merge of #93824 - Amanieu:stable_cfg_target_has_atomic, r=davidtwco
Stabilize cfg_target_has_atomic

`target_has_atomic_equal_alignment` is now tracked separately in #93822.

Closes #32976
2022-02-10 12:10:00 +01:00
Matthias Krüger
f3f41d76ad
Rollup merge of #93802 - lcnr:mcg-woops, r=BoxyUwU
fix oversight in the `min_const_generics` checks

r? `@BoxyUwU`
2022-02-10 12:09:58 +01:00
Matthias Krüger
03332b0a21
Rollup merge of #92670 - hermitcore:kernel, r=davidtwco
add kernel target for RustyHermit

Currently, we are thinking to use *-unknown-none targets instead to define for every platform our own one (see hermitcore/rusty-hermit#197). However, the current target aarch64-unknown-none-softfloat doesn't support dynamic relocation. Our RustyHermit project uses this feature and consequently we define a new target aarch64-unknown-hermitkernel to support it.

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I would be willing to be a target maintainer, though I would appreciate if others volunteered to help with that as well.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

Uses the same naming as the LLVM target, and the same convention as many other kernel targets (e.g. `x86_64_unknown_none_linuxkernel`). In contrast to the bare-metal target for the aarch64 architecture, the unikernel requires dynamic relocation.

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

I don't believe there is any ambiguity here. It use the same convention on x86_64 architecture.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

I don't see any legal issues here.

> The target must not introduce license incompatibilities.
Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
If the target supports building host tools (such as rustc or cargo), those host tools must not depend on proprietary (non-FOSS) libraries, other than ordinary runtime libraries supplied by the platform and commonly used by other binaries built for the target. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.
Targets should not require proprietary (non-FOSS) components to link a functional binary or library.
"onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

I see no issues with any of the above.

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

Only relevant to those making approval decisions.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

`core` and `alloc` can be used. For `std` exists already the target `aarch64_unknown_hermit`, which enables FPU support.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running tests (even if they do not pass), the documentation must explain how to run tests for the target, using emulation if possible or dedicated hardware if necessary.

Use `--target=aarch64_unknown_hermitkernel` option to cross compile. The target does currently not support running tests.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

I don't foresee this being a problem.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

No other targets should be affected by the pull request.
2022-02-10 12:09:55 +01:00
Frank Steffahn
89ac81a6e6 Make all hir::Map methods consistently by-value
(hir::Map only consists of a single reference anyways)
2022-02-10 11:54:06 +01:00
bors
56cd04af5c Auto merge of #93511 - cjgillot:query-copy, r=oli-obk
Ensure that queries only return Copy types.

This should pervent the perf footgun of returning a result with an expensive `Clone` impl (like a `Vec` of a hash map).

I went for the stupid solution of allocating on an arena everything that was not `Copy`. Some query results could be made Copy easily, but I did not really investigate.
2022-02-10 09:37:07 +00:00
lcnr
76c562f3b3 fix min_const_generics oversight 2022-02-10 08:27:29 +01:00
Matthias Krüger
323880646d
Rollup merge of #93813 - xldenis:public-mir-passes, r=wesleywiser
Make a few cleanup MIR passes public

Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Making.20passes.20public.20again

This makes a few passes which used to be public, public again. I'd like to use these to clean up MIR code for my external rustc driver. The other option would be to make them all public, but I don't know if that's warranted / useful.

r? `@wesleywiser`
2022-02-09 23:29:59 +01:00
Matthias Krüger
84c28041b4
Rollup merge of #93753 - jeremyBanks:main-conflict, r=petrochenkov
Complete removal of #[main] attribute from compiler

resolves #93786

---

The `#[main]` attribute was mostly removed from the language in #84217, but not completely. It is still recognized as a builtin attribute by the compiler, but it has no effect. However, this no-op attribute is no longer gated by `#[feature(main)]` (which no longer exists), so it's possible to include it in code *on stable* without any errors, which seems unintentional. For example, the following code is accepted ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)).

```rust
#[main]
fn main() {
    println!("hello world");
}
```

Aside from that oddity, the existence of this attribute causes code like the following to fail ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=use%20tokio%3A%3Amain%3B%0A%0A%23%5Bmain%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22hello%20world%22)%3B%0A%7D%0A)). According https://github.com/rust-lang/rust/pull/84062#issuecomment-825038275, the removal of `#[main]` was expected to eliminate this conflict (previously reported as #62127).

```rust
use tokio::main;

#[main]
fn main() {
    println!("hello world");
}
```

```
error[E0659]: `main` is ambiguous
 --> src/main.rs:3:3
  |
3 | #[main]
  |   ^^^^ ambiguous name
  |
  = note: ambiguous because of a name conflict with a builtin attribute
  = note: `main` could refer to a built-in attribute
```

[This error message can be confusing](https://stackoverflow.com/q/71024443/1114), as the mostly-removed `#[main]` attribute is not mentioned in any documentation.

Since the current availability of `#[main]` on stable seems unintentional, and to needlessly block use of the `main` identifier in the attribute namespace, this PR finishes removing the `#[main]` attribute as described in https://github.com/rust-lang/rust/issues/29634#issuecomment-274951753 by deleting it from `builtin_attrs.rs`, and adds two test cases to ensure that the attribute is no longer accepted and no longer conflicts with other attributes imported as `main`.
2022-02-09 23:29:57 +01:00
Matthias Krüger
6d40850e09
Rollup merge of #93503 - michaelwoerister:fix-vtable-holder-debuginfo-regression, r=wesleywiser
debuginfo: Fix DW_AT_containing_type vtable debuginfo regression

This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in #89597.

It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable.

r? ``@wesleywiser``

This PR should fix issue https://github.com/rust-lang/rust/issues/93164.
~~The PR is blocked on https://github.com/rust-lang/rust/pull/93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
2022-02-09 23:29:56 +01:00
Matthias Krüger
3f4aaf4f2e
Rollup merge of #91504 - cynecx:used_retain, r=nikic
`#[used(linker)]` attribute

See https://github.com/dtolnay/linkme/issues/41#issuecomment-927255631.
2022-02-09 23:29:56 +01:00
Matthias Krüger
9634559599
Rollup merge of #91443 - compiler-errors:bad_collect_into_slice, r=wesleywiser
Better suggestions when user tries to collect into an unsized `[_]`

1. Extend the predicate on `rustc_on_unimplemented` to support substitutions like note, label, etc (i.e. treat it as a `OnUnimplementedFormatString`) so we can have slightly more general `rustc_on_unimplemented` special-cases.
2. Add a `rustc_on_unimplemented` if we fail on `FromIterator<A> for [A]` which happens when we don't explicitly collect into a `vec<A>`, but then pass the return from a `.collect` call into something that takes a slice.

Fixes #91423
2022-02-09 23:29:55 +01:00
Camille GILLOT
8edd32c940 Avoid clone. 2022-02-09 20:11:33 +01:00
Camille GILLOT
e1a72c29aa Explain &Arc. 2022-02-09 20:11:30 +01:00
Camille GILLOT
4435dfec0f Make FnAbiError Copy. 2022-02-09 20:11:29 +01:00
Camille GILLOT
e52131efad Use a slice for object_lifetime_defaults. 2022-02-09 20:11:01 +01:00
Camille GILLOT
f72f15ca28 Use a slice in DefIdForest. 2022-02-09 20:11:00 +01:00
Camille GILLOT
6c2ee885e6 Ensure that queries only return Copy types. 2022-02-09 20:07:38 +01:00
bors
e7aca89598 Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillot
Refactor query system to maintain a global job id counter

This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to `Cell<u64>` as the backing
storage over a `u64`, but the latter was already inside a `RefCell` so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.
2022-02-09 18:54:30 +00:00
Amanieu d'Antras
49d4823112 Stabilize cfg_target_has_atomic
Closes #32976
2022-02-09 18:45:44 +00:00
Michael Goulet
f43e3a86a7 Allow substitutions in rustc_on_unimplemented predicate 2022-02-09 09:35:42 -08:00
Xavier Denis
c97302efad Make a few cleanup MIR passes public 2022-02-09 17:27:58 +01:00
bors
9747ee4755 Auto merge of #93724 - Mark-Simulacrum:drop-query-stats, r=michaelwoerister
Delete -Zquery-stats infrastructure

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 -- locally, this PR shaves ~2.5% from rustc_query_impl builds in instruction counts.

If this does lose some functionality we want to keep, I think we should migrate it to self-profile (or a similar interface) rather than this ad-hoc reporting.
2022-02-09 15:53:10 +00:00
Donald Hoskins
bfd16ab109 mips64-openwrt-linux-musl: correct soft-foat
MIPS64 targets under OpenWrt require soft-float fpu support.

Rust-lang requires soft-float defined in tuple definition and
isn't over-ridden by toolchain compile-time CFLAGS/LDFLAGS

Set explicit soft-float for tuple.

Signed-off-by: Donald Hoskins <grommish@gmail.com>
2022-02-09 10:24:53 -05:00
bors
b7cd0f7864 Auto merge of #93681 - Mark-Simulacrum:rlink-binary, r=davidtwco,bjorn3
Store rlink data in opaque binary format on disk

This removes one of the only uses of JSON decoding (to Rust structs) from the compiler, and fixes the FIXME comment. It's not clear to me what the reason for using JSON here originally was, and from what I can tell nothing outside of rustc expects to read the emitted information, so it seems like a reasonable step to move it to the metadata-encoding format (rustc_serialize::opaque).

Mostly intended as a FIXME fix, though potentially a stepping stone to dropping the support for Decodable to be used to decode JSON entirely (allowing for better/faster APIs on the Decoder trait).

cc #64191
2022-02-09 12:51:53 +00:00
Nikita Popov
933963e10a Add tracking issue 2022-02-09 11:21:25 +01:00
bors
1f0a96862a Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk
Improve opaque type higher-ranked region error message under NLL

Currently, any higher-ranked region errors involving opaque types
fall back to a generic "higher-ranked subtype error" message when
run under NLL. This PR adds better error message handling for this
case, giving us the same kinds of error messages that we currently
get without NLL:

```
error: implementation of `MyTrait` is not general enough
  --> $DIR/opaque-hrtb.rs:12:13
   |
LL | fn foo() -> impl for<'a> MyTrait<&'a str> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough
   |
   = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`...
   = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2`

error: aborting due to previous error
```

To accomplish this, several different refactoring needed to be made:

* We now have a dedicated `InstantiateOpaqueType` struct which
implements `TypeOp`. This is used to invoke `instantiate_opaque_types`
during MIR type checking.
* `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is
needed to report opaque type region errors.
* We no longer assume that all `TypeOp`s correspond to canonicalized
queries. This allows us to properly handle opaque type instantiation
(which does not occur in a query) as a `TypeOp`.
A new `ErrorInfo` associated type is used to determine what
additional information is used during higher-ranked region error
handling.
* The body of `try_extract_error_from_fulfill_cx`
has been moved out to a new function `try_extract_error_from_region_constraints`.
This allows us to re-use the same error reporting code between
canonicalized queries (which can extract region constraints directly
from a fresh `InferCtxt`) and opaque type handling (which needs to take
region constraints from the pre-existing `InferCtxt` that we use
throughout MIR borrow checking).
2022-02-09 09:41:48 +00:00
Yuki Okushi
7f4486b255
Rollup merge of #93781 - lcnr:ty-kind-docs, r=jackh726
update `ty::TyKind` documentation

slightly unsure about `ty::Opaque` and `ty::Bound`/`ty::Placeholder`.

r? `@jackh726` `@nikomatsakis` `@oli-obk`
2022-02-09 14:12:25 +09:00
Yuki Okushi
a07eed99f6
Rollup merge of #93751 - eholk:issue-93648-drop-tracking-projection, r=tmiasko
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.

This PR also includes the `-Zdrop-tracking` flag from #93313. If that PR lands first, I'll rebase to drop the commit from this one.

Fixes #93648
2022-02-09 14:12:24 +09:00
Yuki Okushi
68fa9b198a
Rollup merge of #93748 - klensy:vis-r, r=cjgillot
rustc_query_impl: reduce visibility of some modules/fn's

Locally this reduces number of exported functions from 15221 -> 14952 and size a little.

Perf run please?
2022-02-09 14:12:23 +09:00
Yuki Okushi
e5ac08779b
Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakis
Remove defaultness from ImplItem.

This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-09 14:12:22 +09:00
bors
9a5a961be9 Auto merge of #93778 - matthiaskrgr:rollup-yfngdao, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91950 (Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`)
 - #92715 (Do not suggest char literal for zero-length strings)
 - #92917 (Don't constrain projection predicates with inference vars in GAT substs)
 - #93206 (Use `NtCreateFile` instead of `NtOpenFile` to open a file)
 - #93732 (add fut/back compat tests for implied trait bounds)
 - #93764 (⬆️ rust-analyzer)
 - #93767 (deduplicate `lcnr` in mailmap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-09 01:18:06 +00:00
Mark Rousskov
e240783a4d Switch QueryJobId to a single global counter
This replaces the per-shard counters with a single global counter, simplifying
the JobId struct down to just a u64 and removing the need to pipe a DepKind
generic through a bunch of code. The performance implications on non-parallel
compilers are likely minimal (this switches to `Cell<u64>` as the backing
storage over a `u64`, but the latter was already inside a `RefCell` so it's not
really a significance divergence). On parallel compilers, the cost of a single
global u64 counter may be more significant: it adds a serialization point in
theory. On the other hand, we can imagine changing the counter to have a
thread-local component if it becomes worrisome or some similar structure.

The new design is sufficiently simpler that it warrants the potential for slight
changes down the line if/when we get parallel compilation to be more of a
default.

A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid
possibly overflowing it and causing problems; it is effectively impossible that
we would overflow a u64 counter in this context.
2022-02-08 18:49:55 -05:00
cynecx
438826fd1a add more tests and make used(linker/compiler) mutually exclusive 2022-02-08 23:51:17 +01:00
Aaron Hill
48a48fd1b8
Improve opaque type higher-ranked region error message under NLL
Currently, any higher-ranked region errors involving opaque types
fall back to a generic "higher-ranked subtype error" message when
run under NLL. This PR adds better error message handling for this
case, giving us the same kinds of error messages that we currently
get without NLL:

```
error: implementation of `MyTrait` is not general enough
  --> $DIR/opaque-hrtb.rs:12:13
   |
LL | fn foo() -> impl for<'a> MyTrait<&'a str> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough
   |
   = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`...
   = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2`

error: aborting due to previous error
```

To accomplish this, several different refactoring needed to be made:

* We now have a dedicated `InstantiateOpaqueType` struct which
implements `TypeOp`. This is used to invoke `instantiate_opaque_types`
during MIR type checking.
* `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is
needed to report opaque type region errors.
* We no longer assume that all `TypeOp`s correspond to canonicalized
queries. This allows us to properly handle opaque type instantiation
(which does not occur in a query) as a `TypeOp`.
A new `ErrorInfo` associated type is used to determine what
additional information is used during higher-ranked region error
handling.
* The body of `try_extract_error_from_fulfill_cx`
has been moved out to a new function `try_extract_error_from_region_constraints`.
This allows us to re-use the same error reporting code between
canonicalized queries (which can extract region constraints directly
from a fresh `InferCtxt`) and opaque type handling (which needs to take
region constraints from the pre-existing `InferCtxt` that we use
throughout MIR borrow checking).
2022-02-08 12:35:42 -05:00
lcnr
a8be000109
Update compiler/rustc_middle/src/ty/sty.rs 2022-02-08 18:11:59 +01:00
lcnr
af77bdf439
Update compiler/rustc_middle/src/ty/sty.rs
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-02-08 18:10:28 +01:00
Oli Scherer
239f1e716d Fix regression from lazy opaque types 2022-02-08 17:01:33 +00:00
lcnr
4c793538d4 update ty::TyKind documentation 2022-02-08 17:14:04 +01:00
Matthias Krüger
a11e2b1f75
Rollup merge of #92917 - jackh726:issue-91762-2, r=nikomatsakis
Don't constrain projection predicates with inference vars in GAT substs

cc #91762

Not a fix, but a mitigation to prevent a backwards-compatible hazard where we normalize using a predicate only because it's the only one available, but shouldn't. This would constrain an inference variable which didn't really want. We already do this when selecting a projection candidate, which isn't always correct. But changing that is a problem for a different day.

Also found out that a suggestion for `await`ing a future was using the wrong substs.

r? ``@nikomatsakis``
2022-02-08 16:40:48 +01:00
Matthias Krüger
8429dcdb79
Rollup merge of #92715 - chordtoll:empty-string, r=davidtwco
Do not suggest char literal for zero-length strings

PR #92507 adds a hint to switch to single quotes when a char is expected and a single-character string literal is provided.

The check to ensure the string literal is one character long missed the 0-char case, and would incorrectly offer the hint.

This PR adds the missing check, and a test case to confirm the new behavior.
2022-02-08 16:40:47 +01:00
Matthias Krüger
d7c2eda794
Rollup merge of #91950 - estebank:point-at-type-of-non-allocator, r=matthewjasper
Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`
2022-02-08 16:40:45 +01:00
Michael Woerister
ed21805aee debuginfo: Bring back DW_AT_containing_type for vtables -- address review comments 2022-02-08 15:31:09 +01:00
Stefan Lankes
b5c1dc09fc rename file to use the correct naming convention 2022-02-08 09:34:36 +01:00
Stefan Lankes
beb042ae8f add missing targert for library operating system RustyHermit 2022-02-08 09:34:36 +01:00
Stefan Lankes
0b269f33f4 add kernel target for RustyHermit
Currently, we are thinking to use *-unknown-none targets instead
to define for every platform our own one (see hermitcore/rusty-hermit#197).
However, the current target aarch64-unknown-none-softfloat doesn't support
dynamic relocation. Our kernel uses this feature and consequently
we define a new target aarch64-unknown-hermitkernel to support it.
2022-02-08 09:33:29 +01:00
bors
03b17b181a Auto merge of #93762 - matthiaskrgr:rollup-vdjpfmz, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #86497 (Add {floor,ceil}_char_boundary methods to str)
 - #92695 (Add `#[no_coverage]` tests for nested functions)
 - #93521 (Fix hover effects in sidebar)
 - #93568 (Include all contents of first line of scraped item in Rustdoc)
 - #93569 (rustdoc: correct unclosed HTML tags as generics)
 - #93672 (update comment wrt const param defaults)
 - #93715 (Fix horizontal trim for block doc comments)
 - #93721 (rustdoc: Special-case macro lookups less)
 - #93728 (Add in ValuePair::Term)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-08 06:34:18 +00:00
David Tolnay
d1b9e4a6f2
Pretty print ItemKind::Use in rustfmt style 2022-02-07 21:51:05 -08:00
Matthias Krüger
25ce315c76
Rollup merge of #93728 - JulianKnodt:toterm, r=oli-obk
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.

r? `@oli-obk`
cc `@matthiaskrgr`
Fixes #93578
2022-02-08 06:47:38 +01:00
Matthias Krüger
7d5e2ac5eb
Rollup merge of #93715 - GuillaumeGomez:horizontal-trim, r=notriddle
Fix horizontal trim for block doc comments

Fixes #93662.

r? `@notriddle`
2022-02-08 06:47:36 +01:00
Matthias Krüger
b7f785092d
Rollup merge of #93672 - lcnr:const-param-defaults-xx, r=matthewjasper
update comment wrt const param defaults

after #93669 i looked through all other uses of `GenericParamKind::Const` again to detect if we missed the `default` there as well, but afaict we really only missed lifetime resolution '^^ at least i found an outdated comment :3
2022-02-08 06:47:35 +01:00
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
c37a906db5 Drop tracking: improve break and continue handling
This commit fixes two issues.

One, sometimes break or continue have a block target instead of an
expression target. This seems to mainly happen with try blocks. Since
the drop tracking analysis only works on expressions, if we see a block
target for break or continue, we substitute the last expression of the
block as the target instead.

Two, break and continue were incorrectly being treated as the same, so
continue would also show up as an exit from the loop or block. This
patch corrects the way continue is handled by keeping a stack of loop
entry points and uses those to find the target of the continue.
2022-02-07 16:30:30 -08: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
Erik Desjardins
75ed7def5d apply noundef explicitly in all cases instead of relying on dereferenceable implying it 2022-02-06 21:11:11 -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
Jakub Beránek
5fc2e5623b
Use const generics in SipHasher128's short_write 2022-02-05 19:55:44 +01: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
Erik Desjardins
8cb0b6ca5b Apply noundef attribute to &T, &mut T, Box<T>, bool
This doesn't handle `char` because it's a bit awkward to distinguish it
from u32 at this point in codegen.

Note that for some types (like `&Struct` and `&mut Struct`),
we already apply `dereferenceable`, which implies `noundef`,
so the IR does not change.
2022-02-05 01:09:52 -05: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
Matthias Krüger
b80057d08d compiler: clippy::complexity fixes
useless_format
map_flatten
useless_conversion
needless_bool
filter_next
clone_on_copy
needless_option_as_deref
2022-02-03 23:16:03 +01: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