Commit graph

171834 commits

Author SHA1 Message Date
Dylan DPC ade6d2cf6b
Rollup merge of #98901 - davidtwco:split-dwarf-incr-workproduct, r=michaelwoerister
incr: cache dwarf objects in work products

Cache DWARF objects alongside object files in work products when those exist so that DWARF object files are available for thorin in packed mode in incremental scenarios.

r? `@michaelwoerister`
2022-07-07 18:06:52 +05:30
Dylan DPC 776bb64474
Rollup merge of #98692 - camelid:more-fixmes, r=GuillaumeGomez
rustdoc: Cleanup more FIXMEs

r? `@GuillaumeGomez`
2022-07-07 18:06:51 +05:30
Dylan DPC c815fef795
Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, r=wesleywiser
Finishing touches for `#[expect]` (RFC 2383)

This PR adds documentation and some functionality to rustc's lint passes, to manually fulfill expectations. This is needed for some lints in Clippy. Hopefully, it should be one of the last things before we can move forward with stabilizing this feature.

As part of this PR, I've also updated `clippy::duplicate_mod` to showcase how this new functionality can be used and to ensure that it works correctly.

---

changelog: [`duplicate_mod`]: Fixed lint attribute interaction

r? `@wesleywiser`

cc: https://github.com/rust-lang/rust/issues/97660, https://github.com/rust-lang/rust/issues/85549

And I guess that's it. Here have a magical unicorn 🦄
2022-07-07 18:06:50 +05:30
Dylan DPC d63c713947
Rollup merge of #97711 - Nilstrieb:rustc-arena-ub, r=wesleywiser
Improve soundness of rustc_arena

Make it runnable in miri by changing the loop iteration count for some tests in miri. Also fix a stacked borrows issue with box.
2022-07-07 18:06:49 +05:30
Dylan DPC f6bbe280bf
Rollup merge of #96856 - DrMeepster:fix_projection_validation, r=Icnr
Fix ProjectionElem validation

`TypeChecker::visit_projection_elem` was not actually being called.
2022-07-07 18:06:48 +05:30
bors c461f7a16e Auto merge of #98841 - Kobzol:hir-validator-bitset, r=cjgillot
Use a bitset instead of a hash map in HIR ID validator

The hashset insertion was slightly hot in incr patched runs, but it seems unnecessary to use a hashset here, as it just checks that a dense set of N integers was seen.

I'm not sure if it's possible to know the amount of items beforehand to preallocate the bitset? I suppose not.
2022-07-07 07:38:08 +00:00
bors e78e747f53 Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisa
Suggest using block for `extern "abi" fn` with no body

`@rustbot` modify labels: +A-diagnostics
2022-07-07 04:18:47 +00:00
bors fac8fa5672 Auto merge of #98487 - cjgillot:variance-nohir, r=wesleywiser
Do not fetch HIR to compute variances.

Everything can be done using higher-level queries.  This simplifies the code, and should allow better incremental caching.
2022-07-07 01:17:36 +00:00
bors 8824d13161 Auto merge of #98831 - RalfJung:no-more-unsized-locals, r=oli-obk
interpret: remove support for unsized_locals

I added support for unsized_locals in https://github.com/rust-lang/rust/pull/59780 but the current implementation is a crude hack and IMO definitely not the right way to have unsized locals in MIR. It also [causes problems](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Missing.20Layout.20Check.20in.20.60interpret.2Foperand.2Ers.60.3F). and what codegen does is unsound and has been for years since clearly nobody cares (so I hope nobody actually relies on that implementation and I'll be happy if Miri ensures they do not). I think if we want to have unsized locals in Miri/MIR we should add them properly, either by having a `StorageLive` that takes metadata or by having an `alloca` that returns a pointer (making the ptr indirection explicit) or something like that.

So, this PR removes the `LocalValue::Unallocated` hack. It adds `Immediate::Uninit`, for several reasons:
- This lets us still do fairly little work in `push_stack_frame`, in particular we do not actually have to create any allocations.
- If/when I remove `ScalarMaybeUninit`, we will need something like this to have an "optimized" representation of uninitialized locals. Without this we'd have to put uninitialized integers into the heap!
- const-prop needs some way to indicate "I don't know the value of this local'; it used to use `LocalValue::Unallocated` for that, now it can use `Immediate::Uninit`.

There is still a fundamental difference between `LocalValue::Unallocated` and `Immediate::Uninit`: the latter is considered a regular local that you can read from and write to, it just has a more optimized representation when compared with an actual `Allocation` that is fully uninit. In contrast, `LocalValue::Unallocated`  had this really odd behavior where you would write to it but not read from it. (This is in fact what caused the problems mentioned above.)

While at it I also did two drive-by cleanups/improvements:
- In `pop_stack_frame`, do the return value copying and local deallocation while the frame is still on the stack. This leads to better error locations being reported. The old errors were [sometimes rather confusing](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Cron.20Job.20Failure.202022-06-24/near/287445522).
- Deduplicate `copy_op` and `copy_op_transmute`.

r? `@oli-obk`
2022-07-06 22:50:29 +00:00
bors 7665c35430 Auto merge of #98987 - GuillaumeGomez:rollup-bcy32bp, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #96935 (Allow arithmetic and certain bitwise ops on AtomicPtr)
 - #98519 (Replace some `guess_head_span` with `def_span`)
 - #98911 (rustdoc: filter '_ lifetimes from ty::Generics)
 - #98939 (rustdoc: Add more semantic information to impl IDs)
 - #98971 (Fix typo in file descriptor docs)
 - #98983 (docs: Add overview of `rustc_middle::mir::TerminatorKind`)
 - #98984 (Remove erroneous doc comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-06 20:09:41 +00:00
xFrednet a2810cd277
Fix #[expect] and #[allow] for clippy::duplicate_mod 2022-07-06 22:01:40 +02:00
xFrednet c8b4873cf9
Add function to manually fulfill lint expectations (RFC 2383) 2022-07-06 22:01:39 +02:00
xFrednet 6c6388cd6c
Document, that some lint have to be expected on the crate level (RFC 2383)
Examples: NON_ASCII_IDENTS, UNCOMMON_CODEPOINTS, CONFUSABLE_IDENTS, MIXED_SCRIPT_CONFUSABLES
2022-07-06 22:01:39 +02:00
Guillaume Gomez 4b88cba353
Rollup merge of #98984 - pierwill:patch-4, r=RalfJung
Remove erroneous doc comment

Fixes the formatting issue shown here:

<img width="803" alt="Screen Shot 2022-07-06 at 12 50 56 PM" src="https://user-images.githubusercontent.com/19642016/177612734-2d881c6a-2850-4c1b-8f1a-08339ad5bfbc.png">
2022-07-06 20:43:29 +02:00
Guillaume Gomez 47de8e96f8
Rollup merge of #98983 - pierwill:patch-3, r=RalfJung
docs: Add overview of `rustc_middle::mir::TerminatorKind`
2022-07-06 20:43:28 +02:00
Guillaume Gomez e8ba11362b
Rollup merge of #98971 - MinnDevelopment:patch-1, r=Dylan-DPC
Fix typo in file descriptor docs
2022-07-06 20:43:28 +02:00
Guillaume Gomez 77ec591727
Rollup merge of #98939 - GuillaumeGomez:rustdoc-disamb-impls, r=notriddle
rustdoc: Add more semantic information to impl IDs

Take over of #92745.

I fixed the last remaining issue for the links in the sidebar (mentioned by `@jsha)` and fixed the few links broken in the std/core docs.

cc `@camelid`
r? `@notriddle`
2022-07-06 20:43:27 +02:00
Guillaume Gomez d87bf24925
Rollup merge of #98911 - notriddle:notriddle/rustdoc-string-impl, r=GuillaumeGomez
rustdoc: filter '_ lifetimes from ty::Generics

Fixes a weirdly-rendered section of the std::string::String docs.

Before:

![image](https://user-images.githubusercontent.com/1593513/177256873-20b9cf6e-2429-4865-853b-b269d74672f4.png)

After:

![image](https://user-images.githubusercontent.com/1593513/177256900-ef3efd17-f624-40c5-af90-fe709ec034f2.png)
2022-07-06 20:43:25 +02:00
Guillaume Gomez d712f67897
Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, r=cjgillot
Replace some `guess_head_span` with `def_span`

This patch fixes a part of #97417.
r? `@cjgillot`
2022-07-06 20:43:24 +02:00
Guillaume Gomez 4755173cf6
Rollup merge of #96935 - thomcc:atomicptr-strict-prov, r=dtolnay
Allow arithmetic and certain bitwise ops on AtomicPtr

This is mainly to support migrating from `AtomicUsize`, for the strict provenance experiment.

This is a pretty dubious set of APIs, but it should be sufficient to allow code that's using `AtomicUsize` to manipulate a tagged pointer atomically. It's under a new feature gate, `#![feature(strict_provenance_atomic_ptr)]`, but I'm not sure if it needs its own tracking issue. I'm happy to make one, but it's not clear that it's needed.

I'm unsure if it needs changes in the various non-LLVM backends. Because we just cast things to integers anyway (and were already doing so), I doubt it.

API change proposal: https://github.com/rust-lang/libs-team/issues/60

Fixes #95492
2022-07-06 20:43:23 +02:00
Ralf Jung dc9e0bf782 fix a strange ConstProp ICE 2022-07-06 14:11:44 -04:00
Ralf Jung e685530b07 deduplicate some copy_op code 2022-07-06 14:11:41 -04:00
Ralf Jung 924a4cd008 bless 2022-07-06 14:03:20 -04:00
Ralf Jung 47cb276ab8 support passing unsized fn arguments 2022-07-06 14:03:20 -04:00
Ralf Jung 8ef0caa23c interpret: remove LocalValue::Unallocated, add Operand::Uninit
Operand::Uninit is an *allocated* operand that is fully uninitialized.
This lets us lazily allocate the actual backing store of *all* locals (no matter their ABI).

I also reordered things in pop_stack_frame at the same time.
I should probably have made that a separate commit...
2022-07-06 14:03:20 -04:00
Nilstrieb 211fb66810 Fix stacked borrows violation in rustc_arena
There was a problem with storing a `Box<T>` in a struct, where
the current rules would invalidate the value. this makes it store
a raw pointer instead, circumventing the aliasing problems.
2022-07-06 20:02:45 +02:00
pierwill 482bb39032
Remove erroneous doc comment 2022-07-06 12:52:02 -05:00
pierwill fb579435a5
docs: Add overview of rustc_middle::mir::TerminatorKind 2022-07-06 12:48:19 -05:00
bors 3dcb616888 Auto merge of #98959 - cjgillot:late-bound-order, r=michaelwoerister
Return a FxIndexSet in is_late_bound query.

This return value is iterated upon by borrowck, hence the need to preserve
a deterministic iteration order.

Fixes https://github.com/rust-lang/rust/issues/98890
Affects https://github.com/rust-lang/rust/issues/96655

I don't know if this supersedes https://github.com/rust-lang/rust/pull/98924 or fixes an unrelated bug.

r? `@michaelwoerister`
This may deserve a backport.
2022-07-06 17:38:48 +00:00
bors 049308cf8b Auto merge of #98970 - Dylan-DPC:rollup-j0od37w, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98881 (Only compute DefKind through the query.)
 - #98884 (macros: `LintDiagnostic` derive)
 - #98964 (fix typo in function name)
 - #98967 (fix typo in note about multiple inaccessible type aliases)
 - #98968 (assert Scalar sanity)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-06 15:10:37 +00:00
bors 0aef72017f Auto merge of #98567 - Patryk27:update-llvm, r=nikic
Update llvm-project

Closes https://github.com/rust-lang/rust/issues/98167 🙂
2022-07-06 12:29:40 +00:00
Nixon Enraght-Moony 02fb345964 Suggest using block for extern "abi" fn with no body 2022-07-06 13:27:53 +01:00
David Wood e1065239fe ssa: abort if dwarf packaging fails
This should have been here from the start... oops. When `thorin` fails
to package a DWARF package, that should fail compilation.
2022-07-06 11:15:13 +01:00
David Wood fc641f21c2 ssa: remove dwo of metadata and allocator module
Compiling with `-Csplit-debuginfo=packed` was leaving behind `.dwo`
files because either the metadata or allocator module contained a DWARF
object which was not being removed by the
`maybe_remove_temps_from_module` closure.
2022-07-06 11:15:13 +01:00
David Wood 8371a036ea incr: cache dwarf objects in work products
Cache DWARF objects alongside object files in work products when those
exist so that DWARF object files are available for thorin in packed mode
in incremental scenarios.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-06 11:15:13 +01:00
Takayuki Maeda b730bc9f20 fix miri-opt tests 2022-07-06 19:09:50 +09:00
Takayuki Maeda 0541b4e034 use named_span in case of tuple variant 2022-07-06 19:09:50 +09:00
Takayuki Maeda 3d1b679a3c add Node::Variant to Map::opt_span 2022-07-06 19:09:50 +09:00
Takayuki Maeda 83dea35384 replace guess_head_span with def_span 2022-07-06 19:09:47 +09:00
Florian Spieß 75967cdad5
Fix typo in file descriptor docs 2022-07-06 11:57:58 +02:00
Michael Woerister 8ff4115b5b
Add link to issue for src/test/incremental/async-lifetimes.rs 2022-07-06 11:32:55 +02:00
Dylan DPC 7f62a719af
Rollup merge of #98968 - RalfJung:scalar-sanity, r=oli-obk
assert Scalar sanity

With https://github.com/rust-lang/rust/pull/96814 having landed, finally our `Scalar` layouts have the invariants they deserve. :)
2022-07-06 14:49:13 +05:30
Dylan DPC 41e30e3371
Rollup merge of #98967 - ClementTsang:fix_inaccessible_type_alias_plural_typo, r=lcnr
fix typo in note about multiple inaccessible type aliases

Mainly intended as a small typo fix ("aliass" -> "aliases") for the case where a type cannot be found in scope but there are multiple inaccessible type aliases that match the missing type.

In general this change would use the correct plural form in this scenario for base words that end with 's'.
2022-07-06 14:49:12 +05:30
Dylan DPC 56667b5a07
Rollup merge of #98964 - RalfJung:typo, r=Dylan-DPC
fix typo in function name

I don't know what I was doing when I named that function...
follow-up to #98888
r? `@oli-obk`
2022-07-06 14:49:11 +05:30
Dylan DPC df1f415305
Rollup merge of #98884 - davidtwco:translation-on-lints-derive, r=oli-obk
macros: `LintDiagnostic` derive

- Move `LintDiagnosticBuilder` into `rustc_errors` so that a diagnostic derive can refer to it.
- Introduce a `DecorateLint` trait, which is equivalent to `SessionDiagnostic` or `AddToDiagnostic` but for lints. Necessary without making more changes to the lint infrastructure as `DecorateLint` takes a `LintDiagnosticBuilder` and re-uses all of the existing logic for determining what type of diagnostic a lint should be emitted as (e.g. error/warning).
- Various refactorings of the diagnostic derive machinery (extracting `build_field_mapping` helper and moving `sess` field out of the `DiagnosticDeriveBuilder`).
- Introduce a `LintDiagnostic` derive macro that works almost exactly like the `SessionDiagnostic` derive macro  except that it derives a `DecorateLint` implementation instead. A new derive is necessary for this because `SessionDiagnostic` is intended for when the generated code creates the diagnostic. `AddToDiagnostic` could have been used but it would have required more changes to the lint machinery.

~~At time of opening this pull request, ignore all of the commits from #98624, it's just the last few commits that are new.~~

r? `@oli-obk`
2022-07-06 14:49:10 +05:30
Dylan DPC 707c0d9a2d
Rollup merge of #98881 - cjgillot:q-def-kind, r=fee1-dead
Only compute DefKind through the query.
2022-07-06 14:49:08 +05:30
fee1-dead 31629860e8
Fix double space 2022-07-06 17:02:58 +08:00
DrMeepster a2799b2de8 fix projectionelem validation 2022-07-06 01:59:16 -07:00
Camille GILLOT 9715ea4562 Add regression test. 2022-07-06 10:56:35 +02:00
bors 5b8cf49c51 Auto merge of #98206 - eggyal:align-to-chalk-folding-api, r=jackh726
Split TypeVisitable from TypeFoldable

Impl of rust-lang/compiler-team#520 following MCP approval.

r? `@ghost`
2022-07-06 05:48:11 +00:00