Commit Graph

234508 Commits

Author SHA1 Message Date
Zalathar
527c629cd9 coverage: Explicitly simplify coverage expressions in codegen
After coverage instrumentation and MIR transformations, we can sometimes end up
with coverage expressions that always have a value of zero. Any expression
operand that refers to an always-zero expression can be replaced with a literal
`Operand::Zero`, making the emitted coverage mapping data smaller and simpler.

This simplification step is mostly redundant with the simplifications performed
inline in `expressions_with_regions`, except that it does a slightly more
thorough job in some cases (because it checks for always-zero expressions
*after* other simplifications).

However, adding this simplification step will then let us greatly simplify that
code, without affecting the quality of the emitted coverage maps.
2023-09-21 18:32:49 +10:00
Zalathar
659575aade coverage: Make the zero counter a constant 2023-09-21 18:32:49 +10:00
Urgau
f156d3bc57 Improve invalid UTF-8 lint by finding the expression initializer 2023-09-21 10:16:29 +02:00
bors
e4a361a48a Auto merge of #115996 - lcnr:intercrate_ambiguity_causes-uwu, r=compiler-errors
implement `intercrate_ambiguity_causes` in the new solver

I added some comments but this is still somewhat of a mess. I think we should for the most part be able to treat all of this as a black box, so I can accept that this code isn't too great.

I also believe that some of the weirdness here is unavoidable, as proof trees - and their visitor - hide semantically relevant information, so they cannot perfectly represent the actual solver behavior.

There are some known bugs here when testing with `./x.py test tests/ui --bless -- --target-rustcflags -Ztrait-solver=next-coherence`. While I haven't diagnosed them all in detail I believe we are able to handle them all separately

- `structurally_normalize` currently does not normalize opaque types, resulting in divergence between the solver internal `trait_ref_is_knowable` and the one when computing intercrate ambiguity causes.
- we don't add an `intercrate_ambiguity_cause` for reserved impls
- we should `deeply_normalize` the trait ref before printing it, that requires a "best effort" version of `deeply_normalize`

r? `@compiler-errors`
2023-09-21 07:58:28 +00:00
lcnr
614760f612 review 2023-09-21 08:57:47 +02:00
lcnr
8167a25e4e w 2023-09-21 08:44:12 +02:00
lcnr
8e139eefaf slight refactor, add comment 2023-09-21 08:40:36 +02:00
lcnr
8024c69c29 HACK: avoid hang in structurally_normalize 2023-09-21 08:17:58 +02:00
lcnr
8eade3aa71 update tests 2023-09-21 08:17:58 +02:00
lcnr
de53877f8b proof trees: use for intercrate_ambiguity_causes 2023-09-21 08:17:58 +02:00
Ralf Jung
c94410c145 rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
bors
0a689c1be8 Auto merge of #116009 - compiler-errors:fulldeps-fix, r=Kobzol
Fix `ui-fulldeps --stage=1` with `-Zignore-directory-in-diagnostics-source-blocks`

Fixes #115977

Also makes sure this doesn't happen again by running `ui-fulldeps --stage=1` in CI
2023-09-21 06:11:48 +00:00
Ralf Jung
0eff07b748 try to avoid some layout_of calls 2023-09-21 07:26:16 +02:00
David Tolnay
3dcc8fcab5
Delete obsolete --disable-per-crate-search rustdoc flag 2023-09-20 22:09:48 -07:00
Michael Goulet
292588e319 Make ui-fulldeps --stage=1 builds in CI 2023-09-21 04:11:57 +00:00
Michael Goulet
bb6a46592f Fix ui-fulldeps --stage=1 with -Zignore-directory-in-diagnostics-source-blocks 2023-09-21 04:11:53 +00:00
bors
4fda889bf8 Auto merge of #115549 - saethlin:include-bytes-resilient, r=jackh726
Fall back to the unoptimized implementation in read_binary_file if File::metadata lies

Fixes https://github.com/rust-lang/rust/issues/115458

r? `@jackh726` because you approved the previous PR
2023-09-21 02:50:54 +00:00
bors
cbce15c617 Auto merge of #116013 - matthiaskrgr:rollup-mv5i4fd, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #114394 (style-guide: Document formatting of `as` casts (mostly like a binary operator))
 - #115990 (Allow anyone to set llvm-fixed-upstream)
 - #116008 (Rename BoxMeUp to PanicPayload.)
 - #116011 (Update browser-ui-test version to 0.16.10)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-21 01:02:00 +00:00
Ben Kimock
5f33647fb3 Add unit tests based on files that return odd sizes to stat 2023-09-20 21:01:13 -04:00
Matthias Krüger
156d2e2746
Rollup merge of #116011 - GuillaumeGomez:update-browser-ui, r=notriddle
Update browser-ui-test version to 0.16.10

Following https://github.com/GuillaumeGomez/browser-UI-test/pull/539, it contains generated JS improvements and also a fix in a diagnostic.

r? `@notriddle`
2023-09-21 00:11:37 +02:00
Matthias Krüger
6bcae4c93e
Rollup merge of #116008 - m-ou-se:boxmeup, r=oli-obk
Rename BoxMeUp to PanicPayload.

"BoxMeUp" is not very clear. Let's rename that to a description of what it actually represents: a panic payload.

This PR also renames the structs that implement this trait to have more descriptive names.

Part of https://github.com/rust-lang/rust/issues/116005

r? `@oli-obk`
2023-09-21 00:11:37 +02:00
Matthias Krüger
946a7209cb
Rollup merge of #115990 - nikic:triagebot-llvm-fixed-upstream, r=Nilstrieb
Allow anyone to set llvm-fixed-upstream

Allow llvm-* to be set by unauthenticated users, which is currently llvm-main and llvm-fixed-upstream.
2023-09-21 00:11:36 +02:00
Matthias Krüger
47277ab547
Rollup merge of #114394 - joshtriplett:style-guide-as, r=calebcartwright
style-guide: Document formatting of `as` casts (mostly like a binary operator)

`as` casts currently get formatted like a binary operator, except that
the second line can stack several `as` casts rather than breaking them
each onto their own line. Document this.

As far as I can tell (cc `@calebcartwright` for verification), this is not a 2024 edition change, it just documents current behavior.
2023-09-21 00:11:35 +02:00
bors
3223b0b5e8 Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkin
Simplify/Optimize FileEncoder

FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing.

So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written.

The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small.

Fixes https://github.com/rust-lang/rust/issues/115298
Fixes https://github.com/rust-lang/rust/issues/114671
Fixes https://github.com/rust-lang/rust/issues/114045
Fixes https://github.com/rust-lang/rust/issues/108100
Fixes https://github.com/rust-lang/rust/issues/106787
2023-09-20 21:47:54 +00:00
Ben Kimock
6cee6b0bde PR feedback 2023-09-20 16:49:13 -04:00
Mara Bos
667bba46b0 Fix typo. 2023-09-20 22:37:39 +02:00
Ralf Jung
23fd2860fa stronger consistency check in ImmTy::from_immediate 2023-09-20 22:28:46 +02:00
Ralf Jung
bdbf545f42 interpret: less debug-printing of types 2023-09-20 22:25:42 +02:00
Guillaume Gomez
4ce5a002c9 Update browser-ui-test version to 0.16.10 2023-09-20 22:06:56 +02:00
Ralf Jung
da08a3f40c interpret: more consistently use ImmTy in operators and casts 2023-09-20 21:57:54 +02:00
bors
ad36b5a622 Auto merge of #115987 - loongarch-rs:fix-transparent-union-abi, r=bjorn3
rustc_target/loongarch: Fix passing of transparent unions with only one non-ZST member

This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function.

Fixes https://github.com/rust-lang/rust/issues/115509

r? `@bjorn3`
2023-09-20 19:55:38 +00:00
bors
9da3e81785 Auto merge of #115870 - RalfJung:const-value-slice, r=oli-obk
adjust ConstValue::Slice to work for arbitrary slice types

valtrees have already been assuming that this works; this PR makes it a reality. Also further restrict `ConstValue::Slice` to what it is actually used for; this even shrinks `ConstValue` from 32 to 24 bytes which is a nice win. :)

The alternative to this approach is to make `ConstValue::Slice` work really only for `&str`/`&[u8]` literals, and never return it in `op_to_const`. That would make `op_to_const` very clean. We could then even remove the `meta` field; the length would always be `data.inner().len()`. We could *almost* just use a `Symbol` instead of a `ConstAllocation`, but we have to support byte strings and there doesn't seem to be an interned representation of them (or rather, `ConstAllocation` *is* their interned representation). In this world, valtrees of slice reference types would then become noticeably more expensive to turn into a `ConstValue` -- but does that matter? Specifically for `&str`/`&[u8]` we could still use the optimized representation if we wanted.

If byte strings were already interned somewhere I'd gravitate towards the alternative, but the way things stand, we need a `ConstAllocation` case anyway to support byte strings, and then we might as well support arbitrary slices. (Or we say that byte strings don't get an optimized representation at all. Such a performance cliff between `str` and byte strings is probably unexpected, though due to the lack of interning for byte strings I think there might already be a performance cliff there.)
2023-09-20 18:06:48 +00:00
Mara Bos
76d9b3689c Rename BoxMeUp to PanicPayload. 2023-09-20 19:24:52 +02:00
Mara Bos
0d07b4c2ce Call panic_display directly in const_panic_fmt. 2023-09-20 18:59:12 +02:00
bors
4f226925ce Auto merge of #116006 - GuillaumeGomez:rollup-elrbjd4, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #115566 (clean up unneeded `ToPredicate` impls)
 - #115962 (coverage: Remove debug code from the instrumentor)
 - #115988 (rustdoc: add test cases, and fix, search tabs layout jank)
 - #115991 (Ensure `build/tmp` exists in `rustdoc_themes::get_themes`)
 - #115997 (RELEASES.md: Add missing patch releases)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-20 16:16:01 +00:00
Guillaume Gomez
70076c5fe8
Rollup merge of #115997 - Turbo87:relnotes, r=pietroalbini
RELEASES.md: Add missing patch releases

This was copy-pasted from the current state of the `stable` branch

see https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/1.2E71.2E1/near/382524871
2023-09-20 17:33:18 +02:00
Guillaume Gomez
240c161bc8
Rollup merge of #115991 - ferrocene:rustdoc-themes, r=pietroalbini
Ensure `build/tmp` exists in `rustdoc_themes::get_themes`

This causes failures in ferrocene's CI as `build/tmp` might not exist at this point, causing the following expect to fail here 4b91288484/src/tools/rustdoc-themes/main.rs (L24)
2023-09-20 17:33:18 +02:00
Guillaume Gomez
c535041995
Rollup merge of #115988 - notriddle:notriddle/search-tab-layout, r=GuillaumeGomez
rustdoc: add test cases, and fix, search tabs layout jank

## Before

### Resizing

https://github.com/rust-lang/rust/assets/1593513/24bb5f2b-f6bd-4ed8-91e1-f9ff63d1acee

### Typing

https://github.com/rust-lang/rust/assets/1593513/145f53e1-42eb-4b2a-adba-7c9ab44b0aa4

## After

### Resizing

https://github.com/rust-lang/rust/assets/1593513/acc10a55-e83e-43e6-8604-5dfcb9ae3141

### Typing

https://github.com/rust-lang/rust/assets/1593513/09d6d389-e24f-428f-933f-83d9075f15a2
2023-09-20 17:33:17 +02:00
Guillaume Gomez
c5c4e18913
Rollup merge of #115962 - Zalathar:debug, r=oli-obk
coverage: Remove debug code from the instrumentor

The coverage instrumentor has an entire module full of complex code that is only used for debugging.

And as I continue to work on coverage, I keep finding that this debug code is constantly causing more trouble than it's worth. It's deeply entangled with current implementation details, such that making any non-trivial change to the instrumentor usually requires major changes to the debug code. And so far I have personally not found any of this debug code to be *useful*.

In light of that situation, I'd like to try just ripping all of it out. If I spend any more time dealing with coverage debug code, I want it to be because I'm writing new and useful tools, not dutifully maintaining a boat-anchor that quite plausibly isn't being used by anyone at all.

---
r? `@ghost`
`@rustbot` label +A-code-coverage

---

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Removing.20debug.20code.20from.20the.20coverage.20instrumentor)
2023-09-20 17:33:17 +02:00
Guillaume Gomez
4e8f637783
Rollup merge of #115566 - zirconium-n:issue-107250-clean-up-unused-to-predicate, r=oli-obk
clean up unneeded `ToPredicate` impls

Part of #107250.
Removed all totally unused impls. And inlined two impls not need to satisify trait bound.

r? `@oli-obk`
2023-09-20 17:33:16 +02:00
Michael Howell
66e0483a65 rustdoc: add comment about numeric spacing 2023-09-20 07:51:30 -07:00
bors
e3811a785e Auto merge of #115975 - mkroening:reduce-atty, r=davidtwco
dependencies: reduce the amount of crates pulling in atty

It would be nice to have only one `hermit-abi` in `Cargo.lock` (https://github.com/rust-lang/rust/pull/107405#issuecomment-1427116590).

The only crate pulling in the old `hermit-abi` version is `atty`, which is unmaintained.

This PR upgrades three dependencies, which then no longer depend on `atty`:
* `Cargo.lock`: `colored v2.0.0 -> v2.0.4`
* `Cargo.lock`: `tracing-tree v0.2.3 -> v0.2.4`
* Miri: `env_logger 0.9.3 -> 0.10.0`

The only dependency chain left that pulls in `hermit-abi 0.1.19` is:
`hermit-abi 0.1.19` -> `atty 0.2.14` -> `env_logger 0.7.1` -> `jsonpath_lib 0.2.6` -> `jsondocck 0.1.0` (src/tools/jsondocck)

Replacing jsondocck with jsondocckng is tracked in https://github.com/rust-lang/rust/issues/94140.
2023-09-20 14:24:08 +00:00
bors
78e74d959b Auto merge of #115827 - eduardosm:miri-sse-reduce-code-dup, r=RalfJung
miri: reduce code duplication in some SSE/SSE2 intrinsics

Reduces code duplication in the Miri implementation of some SSE and SSE2 using generics and rustc_const_eval helper functions.

There are also some other minor changes.

r? `@RalfJung`
2023-09-20 12:07:26 +00:00
Tobias Bieniek
31e8981fa9
RELEASES.md: Add missing patch releases
This was copy-pasted from the current state of the `stable` branch
2023-09-20 12:06:07 +02:00
bors
ed33e408c5 Auto merge of #115753 - tgross35:threadinfo-refactor, r=thomcc
Refactor `thread_info` to remove the `RefCell`

`thread_info` currently uses `RefCell`-based initialization. Refactor this to use `OnceCell` instead which is more performant and better suits the needs of one-time initialization.

This is nobody's bottleneck but OnceCell checks are a single `cmp` vs. `RefCell<Option>` needing runtime logic
2023-09-20 09:55:53 +00:00
bors
62d9034a0d Auto merge of #115995 - matthiaskrgr:rollup-jukbrvq, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #115965 (Add more if let guard tests)
 - #115978 (Copy 1.72.1 release notes to master)
 - #115983 (fix confusing let chain indentation in rustc_resolve)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-20 08:03:12 +00:00
Matthias Krüger
af36ab1a8e
Rollup merge of #115983 - eopb:confusing-if-chain-indent, r=compiler-errors
fix confusing let chain indentation in rustc_resolve

Sorry for opening a PR for such a minor style fix.
This just felt sufficiently misleading to warrant fixing.
2023-09-20 09:24:31 +02:00
Matthias Krüger
24fc098413
Rollup merge of #115978 - sksat:copy-1.72.1-release-note-to-master, r=Mark-Simulacrum
Copy 1.72.1 release notes to master

- #115976
- this cherry-pick 1.72.1 release note from #115787(0414f85177)
2023-09-20 09:24:30 +02:00
Matthias Krüger
3304ea4218
Rollup merge of #115965 - matthewjasper:extra-if-let-guard-tests, r=compiler-errors
Add more if let guard tests

cc #51114
2023-09-20 09:24:30 +02:00
Zalathar
e015f5a370 coverage: Remove vestigial counter/expression debug labels 2023-09-20 17:24:10 +10:00