Commit Graph

35646 Commits

Author SHA1 Message Date
Alex Crichton
7a77108809 rustc: Change LLVM target for the wasm32-wasip2 Rust target
This commit changes the LLVM target of for the Rust `wasm32-wasip2`
target to `wasm32-wasip2` as well. LLVM does a bit of detection on the
target string to know when to call `wasm-component-ld` vs `wasm-ld` so
otherwise clang is invoking the wrong linker.
2024-05-03 15:57:31 -07:00
bors
befabbc9e5 Auto merge of #124675 - matthiaskrgr:rollup-x6n79ua, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #122492 (Implement ptr_as_ref_unchecked)
 - #123815 (Fix cannot usage in time.rs)
 - #124059 (default_alloc_error_hook: explain difference to default __rdl_oom in alloc)
 - #124510 (Add raw identifier in a typo suggestion)
 - #124555 (coverage: Clean up creation of MC/DC condition bitmaps)
 - #124593 (Describe and use CStr literals in CStr and CString docs)
 - #124630 (CI: remove `env-x86_64-apple-tests` YAML anchor)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-03 19:46:04 +00:00
Matthias Krüger
613bccc4ca
Rollup merge of #124555 - Zalathar:init-coverage, r=nnethercote
coverage: Clean up creation of MC/DC condition bitmaps

This PR improves the code for creating and initializing [MC/DC](https://en.wikipedia.org/wiki/Modified_condition/decision_coverage) condition bitmap variables, as introduced by #123409 and modified by #124255.

- The condition bitmap variables are now created eagerly at the start of per-function codegen, via a new `init_coverage` method in `CoverageInfoBuilderMethods`. This avoids having to retroactively create the bitmaps while doing codegen for an individual coverage statement.
- As a result, we can now create and initialize those bitmaps using existing safe APIs, instead of having to perform our own unsafe call to `llvm::LLVMBuildAlloca`.
- This PR also tweaks the way we count the number of condition bitmaps needed, by tracking the total number of bitmaps needed (max depth + 1), instead of only tracking the maximum depth. This reduces the potential for subtle off-by-one confusion.
2024-05-03 20:33:46 +02:00
Matthias Krüger
bd305e10c2
Rollup merge of #124510 - linyihai:raw-ident-in-typo-suggestion, r=fmease
Add raw identifier in a typo suggestion

Fixes #68962
2024-05-03 20:33:45 +02:00
bors
0d7b2fb797 Auto merge of #123441 - saethlin:fixed-len-file-names, r=oli-obk
Stabilize the size of incr comp object file names

The current implementation does not produce stable-length paths, and we create the paths in a way that makes our allocation behavior is nondeterministic. I think `@eddyb` fixed a number of other cases like this in the past, and this PR fixes another one. Whether that actually matters I have no idea, but we still have bimodal behavior in rustc-perf and the non-uniformity in `find` and `ls` was bothering me.

I've also removed the truncation of the mangled CGU names. Before this PR incr comp paths look like this:
```
target/debug/incremental/scratch-38izrrq90cex7/s-gux6gz0ow8-1ph76gg-ewe1xj434l26w9up5bedsojpd/261xgo1oqnd90ry5.o
```
And after, they look like this:
```
target/debug/incremental/scratch-035omutqbfkbw/s-gux6borni0-16r3v1j-6n64tmwqzchtgqzwwim5amuga/55v2re42sztc8je9bva6g8ft3.o
```

On the one hand, I'm sure this will break some people's builds because they're on Windows and only a few bytes from the path length limit. But if we're that seriously worried about the length of our file names, I have some other ideas on how to make them smaller. And last time I deleted some hash truncations from the compiler, there was a huge drop in the number if incremental compilation ICEs that were reported: https://github.com/rust-lang/rust/pull/110367https://github.com/rust-lang/rust/pull/110367

---

Upon further reading, this PR actually fixes a bug. This comment says the CGU names are supposed to be a fixed-length hash, and before this PR they aren't: ca7d34efa9/compiler/rustc_monomorphize/src/partitioning.rs (L445-L448)
2024-05-03 17:41:48 +00:00
Matthias Krüger
08d9992812
Rollup merge of #124588 - compiler-errors:ocx, r=lcnr
Use `ObligationCtxt` in favor of `TraitEngine` in many more places

r? lcnr
2024-05-03 15:26:10 +02:00
Matthias Krüger
eaca729e0b
Rollup merge of #124492 - Strophox:adjust-allocbytes, r=RalfJung
Generalize `adjust_from_tcx` for `Allocation`

Previously, `adjust_from_tcx` would take an `Allocation` and "adjust allocation from the ones in `tcx` to a custom Machine instance [...]".
This PR generalizes this so the Machine instance can also determine the `Bytes` type of the output `Allocation`.

r? `@RalfJung`
2024-05-03 15:26:09 +02:00
Strophox
38181cba79 remove trait bounds on AllocBytes 2024-05-03 15:00:37 +02:00
Strophox
235770c851 Cow::from(&*...) changed to Cow::Owned(Vec::from(...)) 2024-05-03 13:47:16 +02:00
Strophox
47e2cc2ea1 generalize adjust_from_tcx 2024-05-03 13:47:16 +02:00
Matthias Krüger
e6c82d9b59
Rollup merge of #124637 - fmease:ast-pretty-ty-asc-builtin-syn, r=compiler-errors
AST pretty: Use `builtin_syntax` for type ascription

Follow-up to #122806.
CC #124619.
2024-05-03 06:04:24 +02:00
Matthias Krüger
a9edd38d18
Rollup merge of #124610 - nnethercote:typenum, r=lcnr
Tweak `consts_may_unify`

r? ````@lcnr````
2024-05-03 06:04:22 +02:00
Michael Goulet
92861517aa Take ocx by move for pending obligations 2024-05-02 22:03:01 -04:00
Michael Goulet
d9eb5232b6 Use ObligationCtxt in favor of TraitEngine in many places 2024-05-02 22:03:01 -04:00
León Orell Valerian Liehr
3a3df3e638
AST pretty: Use builtin_syntax for type ascription 2024-05-03 01:10:22 +02:00
Nicholas Nethercote
3a3a15d753 Refactor Frame.
It is currently an enum and the `tts` and `idx` fields are repeated
across the two variants.

This commit splits it into a struct `Frame` and an enum `FrameKind`, to
factor out the duplication. The commit also renames `Frame::new` as
`Frame::new_delimited` and adds `Frame::new_sequence`. I.e. both
variants now have a constructor.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
5ac017e772 Type annotate repeats.
Because the type is not obvious, and this clarifies things.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
ae7e32880a Introduce Invocation::span_mut.
Alongside the existing `Invocation::span`.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
1c15b6ae9c Replace a hard-to-read line.
Too clever by half, IMO.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
3b6978196d Tweak fully_expand_fragment loop.
Control flow never gets past the end of the `ExpandResult::Retry` match
arm, due to the `span_bug` and the `continue`. Therefore, the code after
the match can only be reached from the `ExpandResult::Ready` arm.

This commit moves that code after the match into the
`ExpandResult::Ready` arm, avoiding the need for the `continue` in the
`ExpandResult::Retry` arm.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
79c4d0202f Remove unnecessary pubs. 2024-05-03 09:06:26 +10:00
Nicholas Nethercote
c9c964fc37 Fix some comment formatting. 2024-05-03 09:06:26 +10:00
Nicholas Nethercote
d7f5319b6d Inline and remove three DummyResult methods.
They each have a single call site.
2024-05-03 09:06:26 +10:00
Nicholas Nethercote
e809df6ed4 Remove unnecessary re-export of MacroKind. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
189a8a6925 De-pub some rustc_expand modules. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
3f055893b4 Remove unused ExpCtxt methods. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
7c6d36345f Remove an unnecessary #[macro_use]. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
d817856978 Remove an unnecessary re-export of rustc_span::hygiene. 2024-05-03 09:06:25 +10:00
Nicholas Nethercote
aabb90d254 rustc_expand: clean up attributes.
Sort them, and remove the unused ones (`lint_reasons` and
`proc_macro_span`).
2024-05-03 09:06:23 +10:00
Nicholas Nethercote
3722eb0b8f Tweak consts_may_unify.
`ConstKind::Value` is the only variant where control flow leaves the
first match on `impl_ct.kind()`, so there is no need for a second match
on the same expression later on.
2024-05-03 08:07:48 +10:00
Matthias Krüger
a248411a97
Rollup merge of #124627 - RalfJung:interpret-doc-no-inline, r=fmease
interpret: hide some reexports in rustdoc

Cc https://github.com/rust-lang/rust/issues/124608
2024-05-02 19:42:50 +02:00
Matthias Krüger
d6940fb43d
Rollup merge of #124624 - WaffleLapkin:old_unit, r=fmease
Use `tcx.types.unit` instead of `Ty::new_unit(tcx)`

I don't think there is any need for the function, given that we can just access the `.types`, similarly to all other primitives?
2024-05-02 19:42:50 +02:00
Matthias Krüger
fe62bc5ea5
Rollup merge of #124623 - lcnr:coherence-uwu, r=compiler-errors
shallow resolve in orphan check

r? ``@compiler-errors`` cc https://github.com/rust-lang/rust/pull/124588#pullrequestreview-2036012292
2024-05-02 19:42:49 +02:00
Matthias Krüger
490c0d60f8
Rollup merge of #124579 - RalfJung:align-bytes-usize, r=fmease
Align: add bytes_usize and bits_usize

This matches `Size::bytes/bits_usize`. I recently wanted this in Miri as well.
2024-05-02 19:42:48 +02:00
Matthias Krüger
e9e2ebb051
Rollup merge of #124414 - lqd:subdiagnostics, r=davidtwco
remove extraneous note on `UnableToRunDsymutil` diagnostic

If I understand [this FIXME](1367827eac/compiler/rustc_macros/src/diagnostics/diagnostic.rs (L205)) correctly, it seems we don't yet validate subdiagnostics, so `#[note]` and co in the `#[derive(Diagnostic]` item could be out-of-sync with the fluent message, without causing compile errors.

It was the case for `rustc_codegen_ssa::errors::UnableToRunDsymutil`, causing the ICE in #124392.

I've grepped and scripted my way through most of our diagnostics structs and fluent bundles and the above was the only such extraneous `#[note]`/`#[note(name)]`/`#[help]`/`#[warning]` I could find, so hopefully there aren't many others like it.

I haven't checked if the opposite can happen, a `.note = ` in a fluent message that is lacking a corresponding `#[note]` on the struct and not causing an error, but maybe it's possible?

r? ``@davidtwco``
fixes #124392
2024-05-02 19:42:48 +02:00
Ralf Jung
dba1849c22 interpret: hide some reexports in rustdoc 2024-05-02 18:47:36 +02:00
Waffle Lapkin
698d7a031e Inline & delete Ty::new_unit, since it's just a field access 2024-05-02 17:49:23 +02:00
lcnr
c4e882fd99 shallow resolve in orphan check 2024-05-02 15:44:05 +00:00
Guillaume Gomez
871f047c4c
Rollup merge of #124582 - RalfJung:std-not-found, r=Nilstrieb
always print nice 'std not found' error when std is not found

Fixes https://github.com/rust-lang/miri/issues/3529

Arguably Miri is doing something odd by letting people create no-std sysroots for arbitrary targets -- but equally arguably, there's no good reason for rustc to special-case the host triple here. Being a non-host triple does not imply the target is a no-std target, after all.
2024-05-02 15:11:22 +02:00
Guillaume Gomez
df9f8d0153
Rollup merge of #124568 - Urgau:non-local-defs-doctest, r=michaelwoerister,GuillaumeGomez
Adjust `#[macro_export]`/doctest help suggestion for non_local_defs lint

This PR adjust the help suggestion of the `non_local_definitions` lint when encountering a `#[macro_export]` at top-level doctest.

So instead of a non-sentential help suggestion to move the `macro_rules!` up above the `rustdoc`-generated function. We now suggest users to declare their own function.

Fixes *(partially, needs backport)* #124534
2024-05-02 15:11:22 +02:00
bors
f5efc3c286 Auto merge of #124521 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68
Bump bootstrap compiler to latest beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday

This also cherry-picks d716d72586548963f32e5c8d57c41db0065fa6e0 from the beta branching, to continue to workaround #122758.

r? bootstrap
2024-05-02 09:21:43 +00:00
bors
fcc06c894b Auto merge of #123939 - WaffleLapkin:never-fallback-unsafe-lint, r=compiler-errors
Add a lint against never type fallback affecting unsafe code

~~I'm not very happy with the code quality... `VecGraph` not allowing you to get predecessors is very annoying. This should work though, so there is that.~~ (ended up updating `VecGraph` to support getting predecessors)

~~First few commits are from https://github.com/rust-lang/rust/pull/123934 https://github.com/rust-lang/rust/pull/123980~~
2024-05-02 02:41:40 +00:00
Mark Rousskov
a64f941611 Step bootstrap cfgs 2024-05-01 22:19:11 -04:00
Waffle Lapkin
b5626172d1 Split hir_typeck_never_type_fallback_flowing_into_unsafe into 5 slugs 2024-05-02 03:49:49 +02:00
Waffle Lapkin
0df43db50c Add proper support for all kinds of unsafe ops to the lint
(never_type_fallback_flowing_into_unsafe)
2024-05-02 03:49:49 +02:00
Waffle Lapkin
3c815a644c Add UnordMap::try_insert 2024-05-02 03:49:46 +02:00
Waffle Lapkin
fe9c5e6510 Reorganize uses 2024-05-02 03:47:32 +02:00
Maybe Waffle
b63cb6fd81 Add an explanation about never type fallback 2024-05-02 03:47:32 +02:00
Maybe Waffle
aa0a916c81 Add a lint against never type fallback affecting unsafe code 2024-05-02 03:47:32 +02:00
Maybe Waffle
ff0bfea45f Convert if to match 2024-05-02 03:47:32 +02:00