Commit Graph

226515 Commits

Author SHA1 Message Date
Michael Goulet 80e9ca9398 Don't print Interned or PrivateZst 2023-06-09 00:20:37 +00:00
bors 68c8fdaac0 Auto merge of #108293 - Jarcho:mut_analyses, r=eholk
Take MIR dataflow analyses by mutable reference

The main motivation here is any analysis requiring dynamically sized scratch memory to work. One concrete example would be pointer target tracking, where tracking the results of a dereference can result in multiple possible targets. This leads to processing multi-level dereferences requiring the ability to handle a changing number of potential targets per step. A (simplified) function for this would be `fn apply_deref(potential_targets: &mut Vec<Target>)` which would use the scratch space contained in the analysis to send arguments and receive the results.

The alternative to this would be to wrap everything in a `RefCell`, which is what `MaybeRequiresStorage` currently does. This comes with a small perf cost and loses the compiler's guarantee that we don't try to take multiple borrows at the same time.

For the implementation:
* `AnalysisResults` is an unfortunate requirement to avoid an unconstrained type parameter error.
* `CloneAnalysis` could just be `Clone` instead, but that would result in more work than is required to have multiple cursors over the same result set.
* `ResultsVisitor` now takes the results type on in each function as there's no other way to have access to the analysis without cloning it. This could use an associated type rather than a type parameter, but the current approach makes it easier to not care about the type when it's not necessary.
* `MaybeRequiresStorage` now no longer uses a `RefCell`, but the graphviz formatter now does. It could be removed, but that would require even more changes and doesn't really seem necessary.
2023-06-08 23:58:44 +00:00
Michael Goulet d5e25d40c9 deduplicate identical region constraints 2023-06-08 23:38:07 +00:00
est31 9fb266b525 Move parse_seq_to_before_end closure to own function 2023-06-09 00:08:03 +02:00
est31 1b90f5efaf Support float-like tuple indices in offset_of!()
The tokenizer gives us whole float literal tokens, we have to split them up
in order to be able to create field access from them.
2023-06-08 23:42:58 +02:00
bors 8b35c0bb0f Auto merge of #112068 - WaffleLapkin:move-discrim-tests, r=compiler-errors
Move tests from `ui/discrim` dir

It seems that we already have a `enum-discriminant` with more tests, so it makes sense to merge them.
2023-06-08 21:06:43 +00:00
est31 d74ec96e8d Move float breaking out of Parser::parse_expr_tuple_field_access_float
Purely a refactor in preparation of using it in offset_of!() parsing
2023-06-08 22:03:06 +02:00
Santiago Pastorino 313143b6a3
Add Terminator::InlineAsm conversion from MIR to SMIR 2023-06-08 16:53:41 -03:00
Michael Goulet a9188226a8 Peel borrows before suggesting as_ref/as_deref 2023-06-08 16:30:05 +00:00
Michael Goulet c92140e838 Don't suggest cyclic associated type constraint 2023-06-08 16:30:05 +00:00
Michael Goulet acf257e62c Point at correct exprs for assert_eq type mismatch 2023-06-08 16:30:05 +00:00
Michael Goulet af54d584b2 More robust as_ref/as_deref suggestions 2023-06-08 16:30:05 +00:00
Bryanskiy 5e917a6039 increase the accuracy of effective visibilities calculation 2023-06-08 19:22:30 +03:00
Michael Goulet 522ae84e03 Suggest type mismatches even when using ref syntax on binding 2023-06-08 16:17:30 +00:00
bors a77659a1e1 Auto merge of #112420 - matthiaskrgr:rollup-spiavw5, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #109953 (Use 128 bits for TypeId hash)
 - #112333 (Don't hold the active queries lock while calling `make_query`)
 - #112339 (Fix rust-analyzer proc macro server)
 - #112410 (Do `fix_*_builtin_expr` hacks on the writeback results)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-08 13:30:52 +00:00
Maybe Waffle 7b8e8adad2 Bless tidy root entry limit 2023-06-08 12:50:00 +00:00
Maybe Waffle 70f28a9110 Move tests from `ui/discrim` dir 2023-06-08 12:33:17 +00:00
Matthias Krüger 909bfa31ed
Rollup merge of #112410 - compiler-errors:writeback, r=lcnr
Do `fix_*_builtin_expr` hacks on the writeback results

During writeback, we do `fix_{scalar,index}_builtin_expr` so that during MIR build we generate built-in MIR instructions instead of method calls for certain built-in arithmetic operations. We do this by checking the types of these built-in operations are scalar types, and remove the method def-id to essentially mark the operation as built-in and not "overloaded".

For lazy norm and the new trait solver, this is a problem, because we don't actually normalize all the types we end up seeing in the typeck results until they're copied over writeback's copy of the typeck results. To fix this, delay these fixup calls until after this normalization has been done.

This doesn't affect the old trait solver, but does simplify the code a bit IMO, since we can remove a few sets of calls to `resolve_vars_if_possible` and some `borrow_mut`s.

r? `@lcnr`
2023-06-08 12:36:19 +02:00
Matthias Krüger c71daaac1f
Rollup merge of #112339 - lnicola:proc-macro-srv-feature, r=Veykril
Fix rust-analyzer proc macro server

The feature now exists on `proc-macro-srv-cli`, and without it the proc macro server will bail rigth out.

CC https://github.com/rust-lang/rust-analyzer/issues/14991
2023-06-08 12:36:18 +02:00
Matthias Krüger 4f2e1df29d
Rollup merge of #112333 - Zoxc:try_collect_active_jobs-deadlock, r=cjgillot
Don't hold the active queries lock while calling `make_query`

This moves the call to `make_query` outside the parts that holds the active queries lock in `try_collect_active_jobs`. This should help removed the deadlock and borrow panic that has been observed when printing the query stack during an ICE.

cc `@SparrowLii`
r? `@cjgillot`
2023-06-08 12:36:18 +02:00
Matthias Krüger 8747c0ebea
Rollup merge of #109953 - thomcc:thomcc/typeid128, r=WaffleLapkin
Use 128 bits for TypeId hash

Preliminary/Draft impl of https://github.com/rust-lang/compiler-team/issues/608

Prior art (probably incomplete list)
- https://github.com/rust-lang/rust/pull/75923
- https://github.com/rust-lang/rust/pull/95845
2023-06-08 12:36:17 +02:00
bors e7409258db Auto merge of #112415 - GuillaumeGomez:rollup-5pa9frd, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #112034 (Migrate `item_opaque_ty` to Askama)
 - #112179 (Avoid passing --cpu-features when empty)
 - #112309 (bootstrap: remove dependency `is-terminal`)
 - #112388 (Migrate GUI colors test to original CSS color format)
 - #112389 (Add a test for #105709)
 - #112392 (Fix ICE for while loop with assignment condition with LHS place expr)
 - #112394 (Remove accidental comment)
 - #112396 (Track more diagnostics in `rustc_expand`)
 - #112401 (Don't `use compile_error as print`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-08 10:31:52 +00:00
Urgau d9d1c76ded Allow undropped_manually_drops for some tests 2023-06-08 11:41:34 +02:00
Urgau 5f55f863db Drop uplifted clippy::undropped_manually_drops 2023-06-08 11:41:34 +02:00
Urgau 52300bf8d8 Uplift clippy::undropped_manually_drops to rustc 2023-06-08 11:41:34 +02:00
Guillaume Gomez cf5e0b0618
Rollup merge of #112401 - WaffleLapkin:dont_compile_error, r=Nilstrieb
Don't `use compile_error as print`

I've spent **1.5 hours** debugging this while trying to compile #112400, if we use `compile_error!`, we should not just forward user input to it, but issue a reasonable error message.

The better solution would be to use a lint like `clippy::print_stdout`, but since we don't have clippy in CI, let's at least make the macro error better.

Also note that some functions called here actually do use `println` (see for example `print_type_sizes` function).
2023-06-08 10:15:13 +02:00
Guillaume Gomez b3d1a83311
Rollup merge of #112396 - WaffleLapkin:track_more_diagnostics, r=compiler-errors
Track more diagnostics in `rustc_expand`

I wish we could lint this somehow...
2023-06-08 10:15:13 +02:00
Guillaume Gomez 80c26483ba
Rollup merge of #112394 - clubby789:remove-comment, r=petrochenkov
Remove accidental comment

Left this in in #110092 while debugging, thanks to `@WaffleLapkin` for spotting
2023-06-08 10:15:12 +02:00
Guillaume Gomez 80829ceaa7
Rollup merge of #112392 - jieyouxu:issue-112385, r=compiler-errors
Fix ICE for while loop with assignment condition with LHS place expr

Fixes #112385.
2023-06-08 10:15:12 +02:00
Guillaume Gomez 5b7eba6a29
Rollup merge of #112389 - TaKO8Ki:issue-105709, r=compiler-errors
Add a test for #105709

Closes #105709
2023-06-08 10:15:11 +02:00
Guillaume Gomez 53ee185855
Rollup merge of #112388 - GuillaumeGomez:migrate-gui-test-color-12, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-06-08 10:15:11 +02:00
Guillaume Gomez 737dbb04d6
Rollup merge of #112309 - kadiwa4:remove_is_terminal, r=albertlarsan68
bootstrap: remove dependency `is-terminal`
2023-06-08 10:15:10 +02:00
Guillaume Gomez ad9d7e3ed5
Rollup merge of #112179 - tamird:no-empty-cpu-features, r=petrochenkov
Avoid passing --cpu-features when empty

Added in 12ac719b99, this logic always
passed --cpu-features, even when the value was the empty string.
2023-06-08 10:15:09 +02:00
Guillaume Gomez e7059f103b
Rollup merge of #112034 - sladyn98:migrate-opaque-ty, r=GuillaumeGomez
Migrate `item_opaque_ty` to Askama

This PR migrates `item_opaque_ty` to Askama

Refers: https://github.com/rust-lang/rust/issues/108868
2023-06-08 10:15:09 +02:00
bors a0df04c0f2 Auto merge of #110040 - ndrewxie:issue-84447-partial-1, r=lcnr,michaelwoerister
Removed use of iteration through a HashMap/HashSet in rustc_incremental and replaced with IndexMap/IndexSet

This allows for the `#[allow(rustc::potential_query_instability)]` in rustc_incremental to be removed, moving towards fixing #84447 (although a LOT more modules have to be changed to fully resolve it). Only HashMaps/HashSets that are being iterated through have been modified (although many structs and traits outside of rustc_incremental had to be modified as well, as they had fields/methods that involved a HashMap/HashSet that would be iterated through)

I'm making a PR for just 1 module changed to test for performance regressions and such, for future changes I'll either edit this PR to reflect additional modules being converted, or batch multiple modules of changes together and make a PR for each group of modules.
2023-06-08 07:30:03 +00:00
sladynnunes 29a51e14d9 Migrate item_opaque_type to Askama
Migrate item_opaque_type to Askama

Fix wrap_item parameters

Fix to write
2023-06-08 00:09:15 -07:00
Takayuki Maeda 5e57e27d7a add a test for #105709
replace build with check

Co-authored-by: Michael Goulet <michael@errs.io>

use appropriate test name
2023-06-08 15:24:09 +09:00
Jacob Lifshay 400fad779e
add programmerjake to portable-simd cc list 2023-06-07 22:26:31 -07:00
Andrew Xie 3f324a8b7d Whoops, submodule change was actually valid - undoing fixup 2023-06-08 01:05:38 -04:00
bors 80917360d3 Auto merge of #112292 - thomcc:tls-ohno, r=m-ou-se
Avoid unwind across `extern "C"` in `thread_local::fast_local`

This is a minimal fix for #112285, in case we want a simple patch that can be easily to backported if that's desirable.

*(Note: I have another broader cleanup which I've mostly omitted from here to avoid clutter, except for the `Cell` change, which isn't needed to fix UB, but simplifies safety comments).*

The only tier-1 target that this occurs on in a way that seems likely to cause problems in practice linux-gnu, although I believe some folks care about that platform somewhat 😉. I'm unsure how big of an issue this is. I've seen stuff like this behave quite badly, but there's a number of reasons to think this might actually be "fine in practice".

I've hedged my bets and assumed we'll backport this at least to beta but my feeling is that there's not enough evidence this is a problem worth backporting further than that.

### More details

This issue seems to have existed since `thread_local!`'s `const` init functionality was added. It occurs if you have a `const`-initialized thread local for a type that `needs_drop`, the drop panics, and you're on a target with support for static thread locals. In this case, we will end up defining an `extern "C"` function in the user crate rather than in libstd, and because the user crate will not have `#![feature(c_unwind)]` enabled, their panic will not be caught by an auto-inserted abort guard.

In practice, the actual situation where problems are likely[^ub] is somewhat narrower.

On most targets with static thread locals, we manage the TLS dtor list by hand (for reentrancy reasons among others). In these cases, while the users code may panic, we're calling it inside our own `extern "C"` (or `extern "system"`) function, which seems to (at least in practice) catch the panic and convert it to an abort.

However, on a few targets, most notably linux-gnu with recent glibc (but also fuchsia and redox), a tls dtor registration mechanism exists which we can actually use directly, [`__cxa_thread_atexit_impl`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/thread_local_dtor.rs#L26-L36).

This is the case that seems most likely to be a cause for concern, as now we're passing a function to the system library and panicking out of it in a case where there are may not be Rust frames above it on the call stack (since it's running thread shutdown), and even if there were, it may not be prepared to handle such unwinding. If that's the case, it'd be bad.

Is it? Dunno. The fact that it's a `__cxa_*` function makes me think they probably have considered that the callback could throw but I have no evidence here and it doesn't seem to be written down anywhere, so it's just a guess. (I would not be surprised if someone comes into this thread to tell me how definitely-bad-news it is).

That said, as I said, all this is actually UB! If this isn't a "technically UB but fine in practice", but all bets are off if this is the kind of thing we are telling LLVM about.

[^ub]: This is UB so take that with a grain of salt -- I'm absolutely making assumptions about how the UB will behave "in practice" here, which is almost certainly a mistake.
2023-06-08 04:44:08 +00:00
Andrew Xie 4ae250bf4e fixup! Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:40:29 -04:00
Andrew Xie 54d7b327e5 Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:38:50 -04:00
Thom Chiovoloni b512004a4a
Fix typo
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2023-06-07 21:27:51 -07:00
Michael Goulet 54fb5a48b9 Structurally resolve correctly in check_pat_lit 2023-06-08 04:22:47 +00:00
Michael Goulet 8efcb28d3c Do fix_*_builtin_expr hacks on the writeback results 2023-06-08 03:21:13 +00:00
bors 50f2176721 Auto merge of #112012 - Kobzol:try-build-llvm-rebuild, r=nikic
Avoid one `rustc` rebuild in the optimized build pipeline

This PR changes the optimized build pipeline to avoid one `rustc` rebuild, inspired by [this comment](https://github.com/rust-lang/rust/issues/112011#issuecomment-1564991175). This speeds up the pipeline by 5-10 minutes. After this change, we **no longer gather LLVM PGO profiles from compiling stage 2 of `rustc`**.

Now we build `rustc` two times (1x PGO instrumented, 1x PGO optimized) and LLVM three times (1x normal, 1x PGO instrumented, 1x PGO optimized). It should be possible to cache the normal LLVM build, but I'll leave that for another PR.
2023-06-08 00:46:58 +00:00
bors f383703e32 Auto merge of #111698 - Amanieu:force-static-lib, r=petrochenkov
Force all native libraries to be statically linked when linking a static binary

Previously, `#[link]` without an explicit `kind = "static"` would confuse the linker and end up producing a dynamically linked library because of the `-Bdynamic` flag. However this binary would not work correctly anyways since it was linked with startup code for a static binary.

This PR solves this by forcing all native libraries to be statically linked when the output is a static binary that cannot link to dynamic libraries anyways.

Fixes #108878
Fixes #102993
2023-06-07 22:02:24 +00:00
Maybe Waffle c38d80ee9f Track more diagnostics in `rustc_expand` 2023-06-07 19:08:50 +00:00
Maybe Waffle fbe3a475f2 Don't `use compile_error as print` 2023-06-07 18:59:31 +00:00
许杰友 Jieyou Xu (Joe) adbfd0da68
Fix ICE for while loop with assignment condition with LHS place expr 2023-06-08 02:38:12 +08:00