Commit Graph

41079 Commits

Author SHA1 Message Date
mejrs
c88ba28d9a document type_implements_trait 2024-11-04 18:08:30 +01:00
bors
432972cae6 Auto merge of #132275 - compiler-errors:deref-effects, r=fee1-dead
Register `~const` preds for `Deref` adjustments in HIR typeck

This doesn't *do* anything yet, since `Deref` and `DerefMut` aren't constified, and we explicitly don't error on calling non-const trait methods in HIR yet -- presumably that will wait until std is re-constified. But I'm confident this logic is correct, and this (afaict?) is the only major hole left in enforcing `~const` in HIR typeck.

r? fee1-dead
2024-11-04 12:12:55 +00:00
mejrs
5a48fe2c20 Suggest creating unary tuples 2024-11-04 12:06:19 +01:00
Zalathar
5bfa0b106e Simplify FFI calls for -Ztime-llvm-passes and -Zprint-codegen-stats 2024-11-04 20:31:16 +11:00
bors
ca87b535a0 Auto merge of #132250 - nnethercote:rustc_borrowck-cleanups, r=compiler-errors
`rustc_borrowck` cleanups

A bunch of cleanups I made while reading over this crate.

r? `@lqd`
2024-11-04 09:19:05 +00:00
Ralf Jung
b2fe71a2fe miri: update ABI compat checks to accept Option-like types 2024-11-04 07:50:40 +01:00
Nicholas Nethercote
e0e7a432db BorrowckDiags tweaks.
- Store a mut ref to a `BorrowckDiags` in `MirBorrowckCtxt` instead of
  owning it, to save having to pass ownership in and out of
  `promoted_mbcx`.
- Use `buffer_error` in a couple of suitable places.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
ce2f0b4ce9 Simplify LocalUseMapBuild.
It has four different `insert` methods, with some duplication. This
commit finds the commonality and removes them all.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
6ecf80e1ad Merge BorrowCheckContext into TypeChecker.
Because there is no real reason for it to be a separate struct.
- It has no methods.
- It's easy to confuse with the nearby `BorrowckInferContext` (which
  does have methods).
- The `mut` ref to it in `TypeChecker` makes it seem like any of the
  fields within might be mutable, but only two (`all_facts` and
  `constraints`) actually are.
- Two of the fields are `pub(crate)` but can be private.

This change makes a lot of code more concise and readable.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
f86c76a782 Remove unnecessary qualifiers. 2024-11-04 17:36:25 +11:00
Nicholas Nethercote
a07011bde2 Remove unnecessary continue. 2024-11-04 17:36:25 +11:00
Nicholas Nethercote
e23bdd68f9 Remove ToUniverseInfo impl for CanonicalQueryInput<CustomTypeOp>.
It's unused.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
7901c03d2d Merge UniverseInfo and UniverseInfoInner.
It's strange to have a struct that contains a single anonymous field
that is an enum. This commit merges them. This does require increasing
the visibility of `TypeOfInfo` to `pub(crate)`, but that seems
worthwhile.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
bf1a5c2b7f Tidy up comments and some formatting.
Mostly by wrapping overly long comment lines, plus a few other things.
2024-11-04 17:36:25 +11:00
Nicholas Nethercote
ad875529bf Move some use declarations.
So they're all in the one place. Also prepend with `crate::`, à la the
`unqualified_local_imports` lint.
2024-11-04 17:36:23 +11:00
Zalathar
920d2774ac Trim and tidy includes in rustc_llvm 2024-11-04 16:35:39 +11:00
Nicholas Nethercote
981dc02eaf Revert "Avoid nested replacement ranges" from #129346.
It caused a test regression in the `cfg_eval.rs` crate. (The bugfix
in #129346 was in a different commit; this commit was just a code
simplification.)
2024-11-04 15:57:35 +11:00
Michael Goulet
7bd595d216 Make sure to enforce ~const DerefMut on mutability fixup 2024-11-04 04:51:32 +00:00
Michael Goulet
e03e9abe3c Register const preds for Deref adjustments in HIR typeck 2024-11-04 04:51:31 +00:00
Michael Goulet
d458f850aa ty::BrK -> ty::BoundRegionKind::K 2024-11-04 04:45:52 +00:00
Michael Goulet
883f8705d4 Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
Michael Goulet
be4b0261c2 ty::KContainer -> ty::AssocItemContainer::K 2024-11-04 04:45:52 +00:00
Michael Goulet
8e6af16192 Remove the trivial constkind imports 2024-11-04 04:45:51 +00:00
Nicholas Nethercote
6676cec925 Reduce visibilities. 2024-11-04 15:43:45 +11:00
bohan
6026a0f6c9 find the generic container rather than simply looking up for the assoc with const arg 2024-11-04 12:17:44 +08:00
Jubilee
759e80d019
Rollup merge of #132576 - jdonszelmann:no-attrid-in-stats, r=nnethercote
remove attribute ids from hir stats (they're simply not needed)

Turns out these are simply not needed. Yay!

r? `@nnethercote`
2024-11-03 20:08:15 -08:00
Jubilee
7155c65d68
Rollup merge of #132565 - bjorn3:less_target_name_dependence, r=workingjubilee
Reduce dependence on the target name

The target name can be anything with custom target specs. Matching on fields inside the target spec is much more robust than matching on the target name.

Also remove the unused is_builtin target spec field.
2024-11-03 20:08:14 -08:00
Jubilee
3313e760d0
Rollup merge of #132423 - RalfJung:const-eval-align-offset, r=dtolnay
remove const-support for align_offset and is_aligned

As part of the recent discussion to stabilize `ptr.is_null()` in const context, the general vibe was that it's okay for a const function to panic when the same operation would work at runtime (that's just a case of "dynamically detecting that something is not supported as a const operation"), but it is *not* okay for a const function to just return a different result.

Following that, `is_aligned` and `is_aligned_to` have their const status revoked in this PR, since they do return actively wrong results at const time. In the future we can consider having a new intrinsic or so that can check whether a pointer is "guaranteed to be aligned", but the current implementation based on `align_offset` does not have the behavior we want.

In fact `align_offset` itself behaves quite strangely in const, and that support needs a bunch of special hacks. That doesn't seem worth it. Instead, the users that can fall back to a different implementation should just use const_eval_select directly, and everything else should not be made const-callable. So this PR does exactly that, and entirely removes const support for align_offset.

Closes some tracking issues by removing the associated features:
Closes https://github.com/rust-lang/rust/issues/90962
Closes https://github.com/rust-lang/rust/issues/104203

Cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-11-03 20:08:13 -08:00
Jubilee
f35433e250
Rollup merge of #131222 - thejpster:fix-sparc-v7-symbol-o, r=workingjubilee
Generate correct symbols.o for sparc-unknown-none-elf

This fixes #130172 by selecting the correct ELF Machine type for sparc-unknown-none-elf (which has a baseline of SPARC V7).
2024-11-03 20:08:13 -08:00
Zalathar
44a056a50b Move LLVMRustAttribute[Kind] out of LLVMWrapper.h 2024-11-04 12:27:23 +11:00
Jubilee
72df7780dd
Rollup merge of #132574 - workingjubilee:abi-in-compiler, r=compiler-errors
compiler: Directly use rustc_abi almost everywhere

Use rustc_abi instead of rustc_target where applicable. This is mostly described by the following substitutions:
```rust
match path_substring {
    rustc_target::spec::abi::Abi => rustc_abi::ExternAbi,
    rustc_target::abi::call => rustc_target::callconv,
    rustc_target::abi => rustc_abi,
}
```

A number of spot-fixes make that not quite the whole story.

The main exception is in 33edc68 where I get a lot more persnickety about how things are imported, especially in `rustc_middle::ty::layout`, not just from where. This includes putting an end to a reexport of `rustc_middle::ty::ReprOptions`, for the same reason that the rest of this change is happening: reexports mostly confound things.

This notably omits rustc_passes and the ast crates, as I'm still examining a question I have about how they do stability checking of `extern "Abi"` strings and if I can simplify their logic. The rustc_abi and rustc_target crates also go untouched because they will be entangled in that cleanup.

r? compiler-errors
2024-11-03 15:25:00 -08:00
Jubilee
3285d12baf
Rollup merge of #132521 - klensy:times, r=compiler-errors
replace manual time convertions with std ones, comptime time format parsing

First commit replaces few manual time conversions with std ones, second makes parsing of time format at compiletime.
2024-11-03 15:24:58 -08:00
dianne
d7d6238b23 use backticks instead of single quotes when reporting "use of unstable library feature"
This is consistent with all other diagnostics I could find containing
features and enables the use of `DiagSymbolList` for generalizing
diagnostics for unstable library features to multiple features.
2024-11-03 13:55:52 -08:00
Jubilee Young
fa2047370b compiler: Remove unused rustc_target from Cargo.tomls 2024-11-03 13:38:47 -08:00
Jubilee Young
5c953ee910 compiler: Replace rustc_target with abi in symbol_mangling 2024-11-03 13:38:47 -08:00
Jubilee Young
7639773e70 compiler: Directly use rustc_abi in session 2024-11-03 13:38:47 -08:00
Jubilee Young
586e141be7 compiler: Directly use rustc_abi in lints 2024-11-03 13:38:47 -08:00
Jubilee Young
092135b7b4 compiler: Directly use rustc_abi in ty_utils 2024-11-03 13:38:47 -08:00
Jubilee Young
6c16a3123b compiler: Directly use rustc_abi in smir again 2024-11-03 13:38:47 -08:00
Jubilee Young
843b6e0859 compiler: Directly use rustc_abi in mir_transform 2024-11-03 13:38:47 -08:00
Jubilee Young
236fe33345 compiler: Directly use rustc_abi in metadata and middle
Stop reexporting ReprOptions from middle::ty
2024-11-03 13:38:47 -08:00
Jubilee Young
89ec8c2cfe compiler: Directly use rustc_abi in hir_{analysis,typeck} 2024-11-03 13:38:47 -08:00
Jubilee Young
bbd18e29da compiler: Directly use rustc_abi in const_eval 2024-11-03 13:38:47 -08:00
Jonathan Dönszelmann
efaf9ab430
remove attribute ids from hir stats (they're simply not needed) 2024-11-03 22:14:54 +01:00
bjorn3
775aad80fc Remove is_builtin target spec field
It is unused.
2024-11-03 21:06:49 +00:00
Jubilee Young
b895bf4fdc compiler: Directly use rustc_abi in codegen 2024-11-03 12:30:32 -08:00
Michael Goulet
6b96103bf3 Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
Michael Goulet
0b5ddf30eb Yeet effects feature 2024-11-03 18:59:31 +00:00
Esteban Küber
e26ad8b67d Properly suggest E::assoc when we encounter E::Variant::assoc
Use the right span when encountering an enum variant followed by an associated item so we don't lose the associated item in the resulting code.

Do not suggest the thing twice, once as a removal of the associated item and a second time as a typo suggestion.
2024-11-03 18:55:19 +00:00
Michael Goulet
ace9e4c078 Gate checking ~const bounds on const_trait_impl 2024-11-03 18:48:24 +00:00
bjorn3
9e6d2da83d Reduce dependence on the target name
The target name can be anything with custom target specs. Matching on
fields inside the target spec is much more robust than matching on the
target name.
2024-11-03 18:29:01 +00:00
Ralf Jung
19e287060d remove const-support for align_offset
Operations like is_aligned would return actively wrong results at compile-time,
i.e. calling it on the same pointer at compiletime and runtime could yield
different results. That's no good.

Instead of having hacks to make align_offset kind-of work in const-eval, just
use const_eval_select in the few places where it makes sense, which also ensures
those places are all aware they need to make sure the fallback behavior is
consistent.
2024-11-03 17:00:44 +01:00
Alex Crichton
c049cc17f3 Remove the wasm32-wasi target from rustc
This commit is the final step in the journey of renaming the historical
`wasm32-wasi` target in the Rust compiler to `wasm32-wasip1`. Various
steps in this journey so far have been:

* 2023-04-03: rust-lang/compiler-team#607 - initial proposal for this rename
* 2024-11-27: rust-lang/compiler-team#695 - amended schedule/procedure for rename
* 2024-01-29: rust-lang/rust#120468 - initial introduction of `wasm32-wasip1`
* 2024-06-18: rust-lang/rust#126662 - warn on usage of `wasm32-wasi`
* 2024-11-08: this PR - remove the `wasm32-wasi` target

The full transition schedule is in [this comment][comment] and is
summarized with:

* 2024-05-02: Rust 1.78 released with `wasm32-wasip1` target
* 2024-09-05: Rust 1.81 released warning on usage of `wasm32-wasi`
* 2025-01-09: Rust 1.84 to be released without the `wasm32-wasi` target

This means that support on stable for the replacement target of
`wasm32-wasip1` has currently been available for 6 months. Users have
already seen warnings on stable for 2 months about usage of
`wasm32-wasi` and stable users have another 2 months of warnings before
the target is removed from stable.

This commit is intended to be the final step in this transition so the
source tree should no longer mention `wasm32-wasi` except in historical
reference to the older name of the `wasm32-wasip1` target.

[comment]: https://github.com/rust-lang/rust/pull/120468#issuecomment-1977878747
2024-11-03 07:09:34 -08:00
bors
7028d9318f Auto merge of #132555 - matthiaskrgr:rollup-2d79661, r=matthiaskrgr
Rollup of 15 pull requests

Successful merges:

 - #129329 (Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`)
 - #131377 (Add LowerExp and UpperExp implementations to NonZero)
 - #132393 (Docs: added brief colon explanation)
 - #132437 (coverage: Regression test for inlining into an uninstrumented crate)
 - #132499 (unicode_data.rs: show command for generating file)
 - #132503 (better test for const HashMap; remove const_hash leftovers)
 - #132511 (stabilize const_arguments_as_str)
 - #132520 (NFC add known bug nr to test)
 - #132522 (make codegen help output more consistent)
 - #132523 (Added regression test for generics index out of bounds)
 - #132528 (Use `*_opt` typeck results fns to not ICE in fallback suggestion)
 - #132537 (PassWrapper: adapt for llvm/llvm-project@5445edb5d)
 - #132540 (Do not format generic consts)
 - #132543 (add and update some crashtests)
 - #132550 (compiler: Continue introducing rustc_abi to the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-03 13:46:47 +00:00
klensy
bc1d8e72e7 make time format parsing compiletime 2024-11-03 15:51:39 +03:00
klensy
be3a635fe7 replace manual time convertions with std ones 2024-11-03 15:51:39 +03:00
bors
59ae5eba7e Auto merge of #132514 - Zalathar:print-target-cpus, r=jieyouxu
Port most of `--print=target-cpus` to Rust

The logic and formatting needed by `--print=target-cpus` has historically been carried out in C++ code. Originally it used `printf` to write directly to the console, but later it switched over to writing to a `std::ostringstream` and then passing its buffer to a callback function pointer.

This PR replaces that C++ code with a very simple function that writes a list of CPU names to a `&RustString`, with the rest of the logic and formatting being handled by ordinary safe Rust code.
2024-11-03 11:09:38 +00:00
Matthias Krüger
1ba782ab3d
Rollup merge of #132550 - workingjubilee:rustc-abi-selects-borrowck-for-mono-sans, r=compiler-errors
compiler: Continue introducing rustc_abi to the compiler

Some crates have not heard of rustc_abi before, so arrange introductions.

Encourage some crates to go further and leave rustc_target behind: it was no good for them.
2024-11-03 12:08:56 +01:00
Matthias Krüger
13cdfae599
Rollup merge of #132540 - compiler-errors:gc, r=calebcartwright
Do not format generic consts

We introduced **nightly support** for generic const items in #113522, but formatting of consts was not modified. Making them format *correctly* is hard, so let's just bail formatting them so we don't accidentally strip their generics and where clauses. This is essentially no-op formatting for generic const items.

r? `````@calebcartwright````` or `````@ytmimi`````
2024-11-03 12:08:55 +01:00
Matthias Krüger
7d7f2b5e2f
Rollup merge of #132537 - durin42:llvm-20-prelinklto, r=DianQK
PassWrapper: adapt for llvm/llvm-project@5445edb5d

As with ab5583ed1e, we had been explicitly passing defaults whose type have changed. Rather than do an ifdef, we simply rely on the defaults.

````@rustbot```` label: +llvm-main
2024-11-03 12:08:55 +01:00
Matthias Krüger
1a0ab892cd
Rollup merge of #132528 - compiler-errors:fallback-sugg-opt, r=jieyouxu
Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes #132517.
2024-11-03 12:08:54 +01:00
Matthias Krüger
a7a0586618
Rollup merge of #132522 - senekor:consistenst-codegen-help, r=compiler-errors
make codegen help output more consistent

The output of `rustc -C help` generally has one option per line. There was one exception because of a (presumably) forgotten line continuation escape.
2024-11-03 12:08:53 +01:00
bors
db034cee00 Auto merge of #132419 - durin42:llvm-20-type-test-thing, r=cuviper
PassWrapper: adapt for llvm/llvm-project@b01e2a8b56

A boolean turned into an enum. None matches the old behavior of false, so we pass that.

`@rustbot` label: +llvm-main
2024-11-03 08:08:00 +00:00
bors
89ab6559cc Auto merge of #132526 - bjorn3:sync_cg_clif-2024-11-02, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The highlight this time is an update to Cranelift 0.113,

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-11-03 05:03:52 +00:00
Jubilee Young
ab6994f880 compiler: Add rustc_abi to _sanitizers 2024-11-02 20:31:47 -07:00
Jubilee Young
31cbde037b compiler: Add rustc_abi to _monomorphize 2024-11-02 20:31:47 -07:00
Jubilee Young
4046e3610c compiler: Replace rustc_target with _abi in _trait_selection 2024-11-02 20:31:47 -07:00
Jubilee Young
bb0cd5606a compiler: Replace rustc_target with _abi in _hir 2024-11-02 20:31:47 -07:00
Jubilee Young
586766e790 compiler: Replace rustc_target with _abi in _borrowck 2024-11-02 20:31:47 -07:00
bors
8ccb78e0d5 Auto merge of #125579 - Noratrieb:print-host, r=davidtwco
Add `--print host-tuple` to print host target tuple

People often parse `-vV` output to get to the host tuple, which is annoying to do. It's easier to just get it directly.

I called it "host-tuple" instead of "host" because it's clearer that it's just the target name. I'm open to different names, but I think this one is fine.

a quick GitHub search for `'^host` reveals many instances of people doing the parsing, for example:

68e0ca57cd/README.md (L369)
0e38473b0c/main.sh (L96)
8a3553b865/README.md (L625)
43f3ec3970/do.sh (L35)

needs a compiler FCP. I could also do an MCP but I think just an FCP here makes the most sense.
2024-11-02 23:04:42 +00:00
uellenberg
67a85925b1 Suggest fixing typos and let bindings at the same time
Fixes #132483
2024-11-02 14:40:37 -07:00
Noratrieb
ba481518da Add --print host-triple
People often parse `-vV` output to get to the host triple, which is
annoying to do. It's easier to just get it directly.
2024-11-02 21:29:59 +01:00
Noratrieb
a26450cf81 Rename target triple to target tuple in many places in the compiler
This changes the naming to the new naming, used by `--print
target-tuple`.
It does not change all locations, but many.
2024-11-02 21:29:59 +01:00
Michael Goulet
16394e9776 Do not format generic consts 2024-11-02 20:25:06 +00:00
bors
b3f75cc872 Auto merge of #132147 - estebank:long-types-2, r=davidtwco
Tweak E0277 output when a candidate is available

*Follow up to #132086.*

Go from

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
 --> src/main.rs:7:50
  |
7 | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
  |                                                  ^^^^^^^^^^^^^^^^^^^^^^ the trait `chumsky::private::ParserSealed<'_, &str, (), chumsky::extra::Full<EmptyErr, (), ()>>` is not implemented for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>`, which is required by `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>`
  |
  = help: the trait `chumsky::private::ParserSealed<'_, &'a str, ((), ()), chumsky::extra::Full<EmptyErr, (), ()>>` is implemented for `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>`
  = help: for that trait implementation, expected `((), ())`, found `()`
  = note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
 --> src/main.rs:5:16
  |
5 | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
  |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
```

to

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
  --> src/main.rs:7:50
   |
7  | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
   |                                                  ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
...
11 |     ws.then(parser.map(|_| ()))
   |     --------------------------- return type was inferred to be `Then<Ignored<..., ...>, ..., ..., ..., ...>` here
   |
   = help: the trait `ParserSealed<'_, &_, (), Full<_, _, _>>` is not implemented for `Then<Ignored<..., ...>, ..., ..., ..., ...>`
           but trait `ParserSealed<'_, &'a _, ((), ()), Full<_, _, _>>` is implemented for it
   = help: for that trait implementation, expected `((), ())`, found `()`
   = note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
  --> src/main.rs:5:16
   |
5  | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
   |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
   = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-df9d52be87eada65.long-type-1337037744507305372.txt'
   = note: consider using `--verbose` to print the full type name to the console
```

* Remove redundant wording
* Introduce trait diff highlighting logic and use it
* Fix incorrect "long type written to path" logic (can be split off)
* Point at tail expression in more cases in E0277
* Avoid long primary span labels in E0277 by moving them to a `help`

Fix #132013.

There are individual commits that can be their own PR. If the review load is too big, happy to split them off.
2024-11-02 20:22:49 +00:00
Augie Fackler
c61312268e PassWrapper: adapt for llvm/llvm-project@5445edb5d
As with ab5583ed1e, we had been explicitly
passing defaults whose type have changed. Rather than do an ifdef, we
simply rely on the defaults.

@rustbot label: +llvm-main
2024-11-02 15:50:44 -04:00
Augie Fackler
ab5583ed1e PassWrapper: adapt for llvm/llvm-project@b01e2a8b56
We don't see a reason to explicitly pass the default here, so just use
the default instead of explicitly passing it and needing an ifdef.

@rustbot label: +llvm-main
2024-11-02 14:39:58 -04:00
Michael Goulet
82f8b8f0e3 Use opt functions to not ICE in fallback suggestion 2024-11-02 15:25:12 +00:00
bjorn3
60f0cd87e8 Merge commit '5b1246bb4bed72fd0bb8fa497d8e5ed2c7f3515c' into sync_cg_clif-2024-11-02 2024-11-02 14:53:30 +00:00
Zalathar
90f2075b66 Port most of LLVMRustPrintTargetCPUs to Rust 2024-11-02 23:39:29 +11:00
Zalathar
0fa86f9660 Use a dedicated safe wrapper for LLVMRustGetHostCPUName 2024-11-02 23:39:29 +11:00
Remo Senekowitsch
8837fc7542 make codegen help output more consistent
The output of `rustc -C help` generally has one option per line. There was one
exception because of a (presumably) forgotten line continuation escape.
2024-11-02 12:35:48 +01:00
Taiki Endo
d19517dcd0 Support clobber_abi and vector registers (clobber-only) in PowerPC inline assembly 2024-11-02 20:26:08 +09:00
Matthias Krüger
30497b05cd
Rollup merge of #132488 - compiler-errors:more-fixmes-bye, r=jieyouxu
Remove or fix some more `FIXME(async_closure)`

Self-explanatory
2024-11-02 08:33:15 +01:00
Matthias Krüger
020b63aebc
Rollup merge of #132466 - cjgillot:opaque-late, r=compiler-errors
Account for late-bound depth when capturing all opaque lifetimes.

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

r? ````@compiler-errors````
2024-11-02 08:33:14 +01:00
Matthias Krüger
fa69b671a9
Rollup merge of #132453 - Urgau:non_local_defs-impl-mod-transparent, r=jieyouxu
Also treat `impl` definition parent as transparent regarding modules

This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules.

See tests and explanation in the changes.

``````@rustbot`````` label +L-non_local_definitions
Fixes *(after beta-backport)* #132427
cc ``````@leighmcculloch``````
r? ``````@jieyouxu``````
2024-11-02 08:33:13 +01:00
Matthias Krüger
bb544f863f
Rollup merge of #131037 - madsmtm:move-llvm-target-versioning, r=petrochenkov
Move versioned Apple LLVM targets from `rustc_target` to `rustc_codegen_ssa`

Fully specified LLVM targets contain the OS version on macOS/iOS/tvOS/watchOS/visionOS, and this version depends on the deployment target environment variables like `MACOSX_DEPLOYMENT_TARGET`, `IPHONEOS_DEPLOYMENT_TARGET` etc.

We would like to move this to later in the compilation pipeline, both because it feels impure to access environment variables when fetching target information, but mostly because we need access to more information from https://github.com/rust-lang/rust/pull/130883 to do https://github.com/rust-lang/rust/issues/118204. See also https://github.com/rust-lang/rust/pull/129342#issuecomment-2335156119 for some discussion.

The first and second commit does the actual refactor, it should be a non-functional change, the third commit adds diagnostics for invalid deployment targets, which are now possible to do because we have access to the session.

Tested with the same commands as in https://github.com/rust-lang/rust/pull/130435.

r? ``````@petrochenkov``````
2024-11-02 08:33:10 +01:00
Michael Goulet
9e5e47fc32 Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
Michael Goulet
c10fe34fb9 No need to instantiate binder in confirm_async_closure_candidate 2024-11-02 03:10:37 +00:00
Esteban Küber
143b072c62 Account for negative bounds in E0277 note and suggestion
Do not suggest `#[derive(Copy)]` when we wanted a `!Copy` type.

Do not say "`Copy` is not implemented for `T` but `Copy` is".

Do not talk about `Trait` having no implementations when `!Trait` was desired.
2024-11-02 03:08:04 +00:00
Esteban Küber
1a0c502183 On long E0277 primary span label, move it to a help
Long span labels don't read well.
2024-11-02 03:08:04 +00:00
Esteban Küber
092ecca5b9 Point at tail expression on rpit E0277
```
error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}: Coroutine` is not satisfied
  --> $DIR/gen_block_is_coro.rs:6:13
   |
LL | fn foo() -> impl Coroutine<Yield = u32, Return = ()> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}`
LL |     gen { yield 42 }
   |     ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}` here
```

The secondary span label is new.
2024-11-02 03:08:04 +00:00
Esteban Küber
86b5965608 Use short_ty_string 2024-11-02 03:08:04 +00:00
Esteban Küber
c6017badb4 Fix type shortening writing to file
Make sure that we append to the file for long ty paths. Do not write the same type more than once. Shorten the calculated width a bit.
2024-11-02 03:08:04 +00:00
Esteban Küber
7b9105dd88 Trim output of E0277 in some cases
Remove default note for "trait is not implemented" in favor of the
more colorful diff output from the previous commit. Removes
duplicated output.
2024-11-02 03:08:04 +00:00
Esteban Küber
b7fc1a7431 Add trait diff highlighting logic and use it in E0277
When a trait is not implemented for a type, but there *is* an `impl`
for another type or different trait params, we format the output to
use highlighting in the same way that E0308 does for types.

The logic accounts for 3 cases:
- When both the type and trait in the expected predicate and the candidate are different
- When only the types are different
- When only the trait generic params are different

For each case, we use slightly different formatting and wording.
2024-11-02 03:08:04 +00:00
bors
7c7bb7dc01 Auto merge of #132470 - GuillaumeGomez:rollup-1a1mkmp, r=GuillaumeGomez
Rollup of 14 pull requests

Successful merges:

 - #131829 (Remove support for `-Zprofile` (gcov-style coverage instrumentation))
 - #132369 (style-guide: Only use the new binop heuristic for assignments)
 - #132383 (Implement suggestion for never type fallback lints)
 - #132413 (update offset_of! docs to reflect the stabilization of nesting)
 - #132438 (Remove unncessary option for default rust-analyzer setting)
 - #132439 (Add `f16` and `f128` to `invalid_nan_comparison`)
 - #132444 (rustdoc: Directly use rustc_abi instead of reexports)
 - #132445 (Cleanup attributes around unchecked shifts and unchecked negation in const)
 - #132448 (Add missing backtick)
 - #132450 (Show actual MIR when MIR building forgot to terminate block)
 - #132451 (remove some unnecessary rustc_allow_const_fn_unstable)
 - #132455 (make const_alloc_layout feature gate only about functions that are already stable)
 - #132456 (Move remaining inline assembly test files into asm directory)
 - #132459 (feat(byte_sub_ptr): unstably add ptr::byte_sub_ptr)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-01 21:49:15 +00:00
Luca Versari
c8b76bcf58 Emit warning when calling/declaring functions with unavailable vectors.
On some architectures, vector types may have a different ABI depending
on whether the relevant target features are enabled. (The ABI when the
feature is disabled is often not specified, but LLVM implements some
de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily
lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to
declare or call functions using those vector types in a context in which
the corresponding target features are disabled, if using an ABI for
which the difference is relevant. This ensures that these functions are
always called with a consistent ABI.

See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187)
for more discussion.

Part of #116558
2024-11-01 22:24:35 +01:00
Guillaume Gomez
7bfdc3d898
Rollup merge of #132450 - bjorn3:better_mir_errors, r=jieyouxu
Show actual MIR when MIR building forgot to terminate block

This makes it significantly easier to debug bugs of this kind.
2024-11-02 03:08:54 +08:00
Guillaume Gomez
2896483320
Rollup merge of #132439 - tgross35:f16-f128-nan-lint, r=jieyouxu
Add `f16` and `f128` to `invalid_nan_comparison`

Currently `f32_nan` and `f64_nan` are used to provide the `invalid_nan_comparison` lint. Since we have `f16_nan` and `f128_nan`, hook these up so the new float types get the same lints.
2024-11-02 03:08:52 +08:00
Guillaume Gomez
e31a5ca1a3
Rollup merge of #132383 - compiler-errors:never-type-fallback-sugg, r=WaffleLapkin
Implement suggestion for never type fallback lints

r? ```@WaffleLapkin```

Just opening this up for vibes; it's not done yet. I'd still like to make this suggestable in a few more cases before merge:
- [x] Try to annotate `_` -> `()`
- [x] Try to annotate local variables if they're un-annotated: `let x = ...` -> `let x: () = ...`
- [x] Try to annotate the self type of a `Trait::method()` -> `<() as Trait>::method()`.

The only other case we may want to suggest is a missing turbofish, like `f()` -> `f::<()>()`. That may be possible, but seems overly annoying.

This partly addresses https://github.com/rust-lang/rust/issues/132358; the other half of fixing that would be to make the error message a bit better, perhaps just special casing the `?` operator 🤔 I don't think I'll do that part.
2024-11-02 03:08:51 +08:00
Guillaume Gomez
526c67f37b
Rollup merge of #131829 - Zalathar:goodbye-zprofile, r=chenyukang
Remove support for `-Zprofile` (gcov-style coverage instrumentation)

Tracking issue: #42524

MCP: https://github.com/rust-lang/compiler-team/issues/798

---

This PR removes the unstable `-Zprofile` flag, which enables ”gcov-style” coverage instrumentation, along with its associated `-Zprofile-emit` configuration flag.

(The profile flag predates and is almost entirely separate from the stable `-Cinstrument-coverage` flag.)

Notably, the `-Zprofile` flag:
- Is largely untested in-tree, having only one run-make test that does not check whether its output is correct or useful.
- Has no known maintainer.
- Has seen no push towards stabilization.
- Has at least one severe regression reported in 2022 that apparently remains unaddressed.
  - #100125
- Is confusingly named, since it appears to be more about coverage than performance profiling, and has nothing to do with PGO.
- Is fundamentally limited by relying on counters auto-inserted by LLVM, with no knowledge of Rust beyond debuginfo.
2024-11-02 03:08:49 +08:00
bors
705cfe0e96 Auto merge of #132276 - compiler-errors:enforce-fx-in-mir, r=fee1-dead
Double-check conditional constness in MIR

To prevent any unchecked `~const` bounds from leaking through during MIR lowering.

If this check fails, it will eventually just delay a bug, but for now it reports errors. That error reporting may be redundant if we're calling it from code that already doesn't allow `~const` (i.e. when the `effects` and `const_trait_impl` gates are disabled), but I don't think it's that big of a deal.

edit: This also makes sure that we issue a const stability error if we encounter *any* function with const conditions when `const_trait_impl` is not enabled. This ensures that that feature remains airtight.
2024-11-01 19:07:57 +00:00
Camille GILLOT
a7f609504c Skip late-bound lifetimes when crossing an AnonConst. 2024-11-01 17:42:14 +00:00
Camille GILLOT
45d4465028 Account for late-bound depth when capturing all opaque lifetimes. 2024-11-01 17:03:17 +00:00
Michael Goulet
57f2e12f4a Completely deny calling functions with const conditions in MIR const check unless const_trait_impl is enabled
This will help us make sure that we never leak any conditionally const
functions into stable.
2024-11-01 16:13:30 +00:00
Mads Marquart
1ef1af1c60 Emit diagnostics for incorrect deployment targets 2024-11-01 17:07:19 +01:00
Mads Marquart
e75a7ddad3 Move Mach-O platform information to rustc_codegen_ssa:🔙:apple
To align with the general decision to have this sort of information
there instead.

Also use the visionOS values added in newer `object` release.
2024-11-01 17:07:19 +01:00
Mads Marquart
e1233153ac Move versioned LLVM target creation to rustc_codegen_ssa
The OS version depends on the deployment target environment variables,
the access of which we want to move to later in the compilation pipeline
that has access to more information, for example `env_depinfo`.
2024-11-01 17:07:18 +01:00
Michael Goulet
e319838e8d Double-check conditional constness in MIR
To prevent any conditional constness from leaking through during MIR lowering
2024-11-01 16:03:52 +00:00
bors
5ca0e9fa9b Auto merge of #132196 - compiler-errors:probe_ty_param_bounds, r=petrochenkov
Some where clause lowering simplifications

Rename `PredicateFilter::SelfThatDefines` to `PredicateFilter::SelfTraitThatDefines` to make it clear that it's only concerned with converting *traits*, and make it do a bit less work when converting bounds.

Also, make the predicate filter matching in `probe_ty_param_bounds_in_generics` explicit, and simply the args it receives a bit.
2024-11-01 15:40:13 +00:00
Urgau
37db365948 Also treat impl definition parent as transparent regarding modules 2024-11-01 16:07:02 +01:00
Michal Piotrowski
7591eb60ad
Fix compiler panic with a large number of threads 2024-11-01 14:52:41 +01:00
bjorn3
760338526f Show actual MIR when MIR building forgot to terminate block
This makes it significantly easier to debug bugs of this kind.
2024-11-01 11:24:14 +01:00
Zalathar
4a70f4bee0 coverage: Simplify logic for chaining multiple blocks into one BCB
We only need to take action when the next block cannot be added to the current
chain, but the logic is much simpler if we express it in terms of when the
block _can_ be added.
2024-11-01 20:04:01 +11:00
bors
145f9cf95d Auto merge of #132402 - bjorn3:remove_snap_decompression, r=jieyouxu,Veykril
Remove support for decompressing dylib metadata

We haven't been compressing dylib metadata for a while now. Removing decompression support will regress error messages about an incompatible rustc version being used, but dylibs are pretty rare anyway.

Fixes https://github.com/rust-lang/rust-analyzer/issues/18451
2024-11-01 08:01:24 +00:00
Trevor Gross
3afbe4f9c7 Add f16 and f128 to invalid_nan_comparison
Currently `f32_nan` and `f64_nan` are used to provide the
`invalid_nan_comparison` lint. Since we have `f16_nan` and `f128_nan`,
hook these up so the new float types get the same lints.
2024-10-31 21:26:36 -05:00
Michael Goulet
b4248aeec3 nits 2024-11-01 01:46:23 +00:00
Michael Goulet
df6f5841e5 And also suggest for qpaths 2024-11-01 01:46:23 +00:00
Michael Goulet
c930bba283 And locals too 2024-11-01 01:46:23 +00:00
Michael Goulet
ea4fb7c25c Suggest adding self type to method 2024-11-01 01:46:23 +00:00
Michael Goulet
41966e71bc Suggest annotations for never type fallback 2024-11-01 01:46:23 +00:00
Michael Goulet
588c7a934a nit: stop using TypeckRootCtxt 2024-11-01 01:46:23 +00:00
Jubilee
acd839d992
Rollup merge of #132422 - maurer:sparc-layout, r=durin42
llvm: Match new LLVM 128-bit integer alignment on sparc

LLVM continues to align more 128-bit integers to 128-bits in the data layout rather than relying on the high level language to do it. Update SPARC target files to match and add a backcompat replacement for current LLVMs.

See llvm/llvm-project#106951 for details

`@rustbot` label: +llvm-main

r? `@durin42`

(Please wait for the LLVM CI to come back before approving), creating this PR to get it tested there.
2024-10-31 17:50:44 -07:00
Jubilee
a25ab33770
Rollup merge of #132421 - beetrees:riscv-abi-no-empty-string, r=workingjubilee
Remove `""` case from RISC-V `llvm_abiname` match statement

For RISC-V, `""` isn't the always the same ABI as `"ilp32"`/`"lp64"` (`""` means LLVM will infer the ABI based on the enabled target features), but `create_object_file` currently assumes that it is. Since all RISC-V targets explicitly specify their ABI since #131807, this PR removes `""` from the match arm's pattern (meaning an empty string will now fall through to the `_ => bug!` arm).

r? `@workingjubilee`
2024-10-31 17:50:44 -07:00
Jubilee
c57b351d38
Rollup merge of #132403 - lcnr:typing-mode, r=compiler-errors
continue `TypingMode` refactor

There are still quite a few places which (indirectly) rely on the `Reveal` of a `ParamEnv`, but we're slowly getting there

r? `@compiler-errors`
2024-10-31 17:50:43 -07:00
Jubilee
6da4221d96
Rollup merge of #132385 - workingjubilee:move-abi-to-rustc-abi, r=jieyouxu,compiler-errors
compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`

Lift `enum Abi` from its rather odd place in the middle of rustc_target, and make it available again from rustc_abi. You know, the crate where you would expect the enum that describes all the ABIs to be? The platform-neutral ones, at least. This will help further refactoring of how we handle ABIs in the near future[^0].

Rename `Abi` to `ExternAbi` because quite a lot of the compiler overloads the concept of "ABI" enough that the existing name is imprecise and it is often renamed _anyway_. Often this was to avoid conflicts with the *other* type formerly known as `Abi` (now named BackendRepr[^1]), but sometimes it is just for clarity, and this name seems more self-explanatory. It does get reexported, though, using its old name, to reduce the odds of merge-conflicting over the entire tree.

All of `ExternAbi`'s friends come along for the ride, which costs adding some optional dependencies to the rustc_abi crate. However, all of this also allows simply moving three crates entirely off rustc_target:
- rustc_hir_pretty
- rustc_lint_defs
- rustc_mir_build

This odd selection is mostly to demonstrate a secondary motivation: The majority of the front-end of the compiler should be as target-agnostic as possible, and it is easier to assure this if they simply don't depend on the crate that describes targets. Note that I didn't migrate crates that don't benefit from it in this way yet, and I didn't survey every last crate.

[^0]: This is being undertaken as part of https://github.com/rust-lang/rust/issues/119183
[^1]: https://github.com/rust-lang/rust/pull/132246
2024-10-31 17:50:42 -07:00
Jubilee
6b0c8cfedc
Rollup merge of #132357 - m-ou-se:explicit-abi, r=compiler-errors
Improve missing_abi lint

This is for the migration lint for https://github.com/rust-lang/rfcs/pull/3722

It is not yet marked as an edition migration lint, because `Edition2027` doesn't exist yet.

The lint now includes a machine applicable suggestion:

```
warning: extern declarations without an explicit ABI are deprecated
 --> src/main.rs:3:1
  |
3 | extern fn a() {}
  | ^^^^^^ help: explicitly specify the C ABI: `extern "C"`
  |
```
2024-10-31 17:50:41 -07:00
Jubilee
e31988cfc9
Rollup merge of #132209 - compiler-errors:modifiers, r=fmease
Fix validation when lowering `?` trait bounds

Pass the unlowered (`rustc_hir`) polarity to `lower_poly_trait_ref`.

This allows us to actually *validate* that generic args are actually valid on `?Trait` paths. This actually regressed in #113671 because that PR changed the behavior where we were inadvertently re-lowering paths as `BoundPolarity::Positive`, which was also coincidentally the only place we were enforcing the generics on `?Trait` paths were correct.
2024-10-31 17:50:40 -07:00
Jubilee
a43492b884
Rollup merge of #131168 - madsmtm:target-info-psx-os, r=davidtwco
Fix `target_os` for `mipsel-sony-psx`

Previously set to `target_os = "none"` and `target_env = "psx"` in [the PR introducing the target](https://github.com/rust-lang/rust/pull/102689/), but although the Playstation 1 is _close_ to a bare metal target in some regards, it's still very much an operating system, so we should instead set `target_os = "psx"`.

This also matches the `mipsel-sony-psp` target, which sets `target_os = "psp"`.

CC target maintainer ``@ayrtonm.``

If there's any code out there that uses `cfg(target_env = "psx")`, they can use `cfg(any(target_os = "psx", target_env = "psx"))` until they bump their MSRV to a version where this is fully fixed.
2024-10-31 17:50:40 -07:00
Matthew Maurer
9caced7bad llvm: Match new LLVM 128-bit integer alignment on sparc
LLVM continues to align more 128-bit integers to 128-bits in the data
layout rather than relying on the high level language to do it. Update
SPARC target files to match and add a backcompat replacement for current
LLVMs.

See llvm/llvm-project#106951 for details
2024-10-31 20:37:54 +00:00
beetrees
abb05c0fd5
Remove "" case from RISC-V llvm_abiname match statement 2024-10-31 19:17:07 +00:00
bors
a0d98ff0e5 Auto merge of #132356 - jieyouxu:unsound-simplify_aggregate_to_copy, r=cjgillot,DianQK
Mark `simplify_aggregate_to_copy` mir-opt as unsound

Mark the `simplify_aggregate_to_copy` mir-opt added in #128299 as unsound as it seems to miscompile the MCVE reported in https://github.com/rust-lang/rust/issues/132353. The mir-opt can be re-enabled once this case is fixed.

```rs
fn pop_min(mut score2head: Vec<Option<usize>>) -> Option<usize> {
    loop {
        if let Some(col) = score2head[0] {
            score2head[0] = None;
            return Some(col);
        }
    }
}

fn main() {
    let min = pop_min(vec![Some(1)]);
    println!("min: {:?}", min);
    // panic happens here on beta in release mode
    // but not in debug mode
    min.unwrap();
}
```

This MCVE is included as a `run-pass` ui regression test in the first commit. I built the ui test with a nightly manually, and can reproduce the behavioral difference with `-C opt-level=0` and `-C opt-level=1`. Locally, this ui test will fail unless it was run on a compiler built with the second commit marking the mir-opt as unsound thus disabling it by default.

This PR **partially reverts** commit e7386b3, reversing changes made to 02b1be1. The mir-opt implementation is just marked as unsound but **not** reverted to make reland reviews easier. Test changes are **reverted if they were not pure additions**. Tests added by the original PR received `-Z unsound-mir-opts` compile-flags.

cc `@DianQK` `@cjgillot` (PR author and reviewer of #128299)
2024-10-31 15:29:14 +00:00
lcnr
dc750665ae normalization folders, yeet ParamEnv::reveal 2024-10-31 14:55:53 +01:00
lcnr
2cde638ac0 stop using ParamEnv::reveal while handling MIR 2024-10-31 14:55:53 +01:00
bors
20c909ff9c Auto merge of #132401 - matthiaskrgr:rollup-599ieqr, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #130693 (Add `minicore` test auxiliary and support `//@ add-core-stubs` directive in ui/assembly/codegen tests)
 - #132316 (CI: use free runners for 3 fast windows jobs)
 - #132354 (Add `lp64e` RISC-V ABI)
 - #132395 (coverage: Avoid ICE when `coverage_cx` is unexpectedly unavailable)
 - #132396 (CI: use free runners for x86_64-gnu-tools and x86_64-rust-for-linux)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-31 12:57:11 +00:00
Kajetan Puchalski
10edeea4b4 rustc_codegen_llvm: Add a new 'pc' option to branch-protection
Add a new 'pc' option to -Z branch-protection for aarch64 that
enables the use of PC as a diversifier in PAC branch protection code.

When the pauth-lr target feature is enabled in combination
with -Z branch-protection=pac-ret,pc, the new 9.5-a instructions
(pacibsppc, retaasppc, etc) will be generated.
2024-10-31 11:59:17 +00:00
bjorn3
87b9c092fb Remove support for decompressing dylib metadata
We haven't been compressing dylib metadata for a while now. Removing
decompression support will regress error messages about an incompatible
rustc version being used, but dylibs are pretty rare anyway.
2024-10-31 11:51:00 +00:00
lcnr
aab149b58c ConstCx stop using ParamEnv::reveal 2024-10-31 12:43:22 +01:00
Matthias Krüger
bfc956e36f
Rollup merge of #132395 - Zalathar:coverage-cx-ice, r=jieyouxu
coverage: Avoid ICE when `coverage_cx` is unexpectedly unavailable

In #132124, `coverage_cx()` was changed to panic if the context was unavailable, under the assumption that it would always be available whenever coverage instrumentation is enabled.

However, there have been reports of this change causing ICEs in `polars` CI.

I don't yet understand why this is happening, but for now it seems wisest to revert that part of the change, restoring the two early returns that had been replaced with panics.
2024-10-31 12:35:56 +01:00
Matthias Krüger
6b96a7944a
Rollup merge of #132354 - koute:master, r=workingjubilee
Add `lp64e` RISC-V ABI

This PR adds support for the `lp64e` RISC-V ABI, which is the 64-bit equivalent of the `ilp32e` ABI that is already supported.

For reference, this ABI was originally added to LLVM in [this PR](https://reviews.llvm.org/D70401).
2024-10-31 12:35:56 +01:00
lcnr
84295b917d traits::project: yeet ParamEnv::reveal 2024-10-31 12:06:19 +01:00
Zalathar
8dddd1ae60 coverage: Avoid ICE when coverage_cx is unexpectedly unavailable 2024-10-31 21:25:43 +11:00
bors
9ccfedf186 Auto merge of #132301 - compiler-errors:adjust, r=lcnr
Remove region from adjustments

It's not necessary to store this region, because it's only used in THIR and MemCat/ExprUse, both of which already basically only deal with erased regions anyways.
2024-10-31 10:17:49 +00:00
Mara Bos
cb26fa07bb Improve the missing_abi lint. 2024-10-31 10:55:45 +01:00
Jan Bujak
c1db011ccb Add lp64e ABI to the spec tests match 2024-10-31 16:38:47 +09:00
Jan Bujak
44b720a2d4 Add a comment about lp64e still being unstable 2024-10-31 16:38:45 +09:00
Zalathar
899d89f64c coverage: Use a standard depth-first search on a custom subgraph 2024-10-31 17:31:16 +11:00
bors
4d296eabe4 Auto merge of #132384 - matthiaskrgr:rollup-0ze5wc4, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #132347 (Remove `ValueAnalysis` and `ValueAnalysisWrapper`.)
 - #132365 (pass `RUSTC_HOST_FLAGS` at once without the for loop)
 - #132366 (Do not enforce `~const` constness effects in typeck if `rustc_do_not_const_check`)
 - #132376 (Annotate `input` reference tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-31 06:22:57 +00:00
Zalathar
8834b5ad51 coverage: Make CoverageSuccessors a struct 2024-10-31 16:49:00 +11:00
许杰友 Jieyou Xu (Joe)
10b8ba4ecb Mark simplify_aggregate_to_copy mir-opt as unsound
Co-authored-by: DianQK <dianqk@dianqk.net>
2024-10-31 13:48:06 +08:00
Jubilee Young
8a0e64078e compiler: Switch to rustc_abi in hir_pretty, lint_defs, and mir_build
Completely abandon usage of rustc_target in these crates, as
they need no special knowledge of rustc's target tuples.
2024-10-30 22:38:49 -07:00
Jubilee Young
eca17022ef compiler: Lift rustc_target::spec::abi::Abi to rustc_abi::ExternAbi 2024-10-30 22:38:49 -07:00
Matthias Krüger
39086e4290
Rollup merge of #132366 - compiler-errors:do-not-const-check, r=fee1-dead
Do not enforce `~const` constness effects in typeck if `rustc_do_not_const_check`

Fixes a slight inconsistency between HIR and MIR enforcement of `~const` :D

r? `@rust-lang/project-const-traits`
2024-10-31 06:11:58 +01:00
Matthias Krüger
e228e31293
Rollup merge of #132347 - nnethercote:rm-ValueAnalysisWrapper, r=cjgillot
Remove `ValueAnalysis` and `ValueAnalysisWrapper`.

They represent a lot of abstraction and indirection, but they're only used for `ConstAnalysis`, and apparently won't be used for any other analyses in the future. This commit inlines and removes them, which makes `ConstAnalysis` easier to read and understand.

r? `@cjgillot`
2024-10-31 06:11:57 +01:00
Michael Goulet
81dba0755e Double check the lowered predicates in type_param_predicates 2024-10-31 04:31:59 +00:00
Michael Goulet
697eda5f9a Make SelfTraitThatDefines a tighter filter 2024-10-31 04:31:37 +00:00
Michael Goulet
ac67d295b9 Make predicate filter in probe_ty_param_bounds_in_generics more explicit 2024-10-31 04:31:37 +00:00
bors
c8b83785dc Auto merge of #131186 - compiler-errors:precise-capturing-borrowck, r=estebank
Try to point out when edition 2024 lifetime capture rules cause borrowck issues

Lifetime capture rules in 2024 are modified to capture more lifetimes, which sometimes lead to some non-local borrowck errors. This PR attempts to link these back together with a useful note pointing out the capture rule changes.

This is not a blocking concern, but I'd appreciate feedback (though, again, I'd like to stress that I don't want to block this PR on this): I'm worried about this note drowning in the sea of other diagnostics that borrowck emits. I was tempted to change the level of the note to `.span_warn` just so it would show up in a different color. Thoughts?

Fixes #130545

Opening as a draft first since it's stacked on #131183.
r? `@ghost`
2024-10-31 03:36:06 +00:00
Nicholas Nethercote
846e20c3b6 Reduce some visibilities. 2024-10-31 12:46:30 +11:00
Nicholas Nethercote
911edbfe42 Remove ValueAnalysis and ValueAnalysisWrapper.
They represent a lot of abstraction and indirection, but they're only
used for `ConstAnalysis`, and apparently won't be used for any other
analyses in the future. This commit inlines and removes them, which
makes `ConstAnalysis` easier to read and understand.
2024-10-31 12:46:26 +11:00
Michael Goulet
c1457798db Try to point out when edition 2024 lifetime capture rules cause borrowck issues 2024-10-31 01:35:14 +00:00
Michael Goulet
e093b82a41 Encode cross-crate opaque type origin 2024-10-31 01:35:13 +00:00
bors
75eff9a574 Auto merge of #132377 - matthiaskrgr:rollup-3p1c6hs, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #132368 (Remove `do_not_const_check` from `Iterator` methods)
 - #132373 (Make sure `type_param_predicates` resolves correctly for RPITIT)
 - #132374 (Remove dead code stemming from the old effects desugaring)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-31 00:46:22 +00:00
Matthias Krüger
7d0dbc5f53
Rollup merge of #132374 - fmease:rm-dead-eff-code, r=compiler-errors
Remove dead code stemming from the old effects desugaring

r? project-const-traits
2024-10-31 01:14:04 +01:00
Matthias Krüger
efd5645e43
Rollup merge of #132373 - compiler-errors:rpitit-bound, r=fmease
Make sure `type_param_predicates` resolves correctly for RPITIT

After #132194, we end up lowering the item bounds for an RPITIT in an `ItemCtxt` whose def id is the *synthetic GAT*, not the opaque type from the HIR.

This means that when we're resolving a shorthand projection like `T::Assoc`, we call the `type_param_predicates` function with the `item_def_id` of the *GAT* and not the opaque. That function operates on the HIR, and is not designed to work with the `Node::Synthetic` that gets fed for items synthesized by the compiler...

This PR reuses the trick we use elsewhere in lowering, where we intercept whether an item comes from RPITIT lowering, and forwards the query off to the correct item.

Fixes #132372
2024-10-31 01:14:03 +01:00
Michael Goulet
06a49b609f Validate associated type bounds on ? 2024-10-31 00:09:52 +00:00
Michael Goulet
e356279bdf Actually do validation for poly trait refs with ? modifier 2024-10-30 23:42:50 +00:00
León Orell Valerian Liehr
a6bbdf0fd4
Remove dead code stemming from the old effects desugaring 2024-10-30 23:55:13 +01:00
Michael Goulet
d53ca63453 Make sure type_param_predicates resolves correctly for RPITIT 2024-10-30 22:30:28 +00:00
Zalathar
ce3e14a448 Remove support for -Zprofile (gcov-style coverage instrumentation) 2024-10-31 09:09:25 +11:00
Jubilee
7b19508abe
Rollup merge of #132344 - compiler-errors:same-thing, r=lcnr
Merge `HostPolarity` and `BoundConstness`

They're basically the same thing, and I think `BoundConstness` is easier to use.

r? fee1-dead or reassign
2024-10-30 14:01:38 -07:00
Jubilee
847b6fe6b0
Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errors
Rename `rustc_abi::Abi` to `BackendRepr`

Remove the confabulation of `rustc_abi::Abi` with what "ABI" actually means by renaming it to `BackendRepr`, and rename `Abi::Aggregate` to `BackendRepr::Memory`. The type never actually represented how things are passed, as that has to have `PassMode` considered, at minimum, but rather it just is how we represented some things to the backend. This conflation arose because LLVM, the primary backend at the time, would lower certain IR forms using certain ABIs. Even that only somewhat was true, as it broke down when one ventured significantly afield of what is described by the System V AMD64 ABI either by using different architectures, ABI-modifying IR annotations, the same architecture **with different ISA extensions enabled**, or other... unexpected delights.

Unfortunately both names are still somewhat of a misnomer right now, as people have written code for years based on this misunderstanding. Still, their original names are even moreso, and for better or worse, this backend code hasn't received as much maintenance as the rest of the compiler, lately. Actually arriving at a correct end-state will simply require us to disentangle a lot of code in order to fix, much of it pointlessly repeated in several places. Thus this is not an "actual fix", just a way to deflect further misunderstandings.
2024-10-30 14:01:37 -07:00
Jubilee
6b60f03f15
Rollup merge of #129383 - cjgillot:opaque-noremap, r=compiler-errors,petrochenkov
Remap impl-trait lifetimes on HIR instead of AST lowering

Current AST->HIR lowering goes out of its way to remap lifetimes for opaque types. This is complicated and leaks into upstream and downstream code.

This PR stops trying to be clever during lowering, and prefers to do this remapping during the HIR->ty lowering. The remapping computation easily fits into the bound var resolution code. Its result can be used in by `generics_of` and `hir_ty_lowering::new_opaque` to add the proper parameters and arguments.

See an example on the doc for query `opaque_captured_lifetimes`.

Based on https://github.com/rust-lang/rust/pull/129244/

Fixes https://github.com/rust-lang/rust/issues/125249
Fixes https://github.com/rust-lang/rust/issues/126850

cc `@compiler-errors` `@spastorino`
r? `@petrochenkov`
2024-10-30 14:01:36 -07:00
Michael Howell
12dc24f460 rustdoc-search: simplify rules for generics and type params
This commit is a response to feedback on the displayed type
signatures results, by making generics act stricter.

Generics are tightened by making order significant. This means
`Vec<Allocator>` now matches only with a true vector of allocators,
instead of matching the second type param. It also makes unboxing
within generics stricter, so `Result<A, B>` only matches if `B`
is in the error type and `A` is in the success type. The top level
of the function search is unaffected.

Find the discussion on:

* <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149>
* <https://github.com/rust-lang/rust/pull/124544#issuecomment-2204272265>
* <https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/deciding.20on.20semantics.20of.20generics.20in.20rustdoc.20search/near/476841363>
2024-10-30 12:27:48 -07:00
Michael Goulet
ec033e5bf1 Do not enforce ~const constness effects in typeck if rustc_do_mot_const_check 2024-10-30 17:41:09 +00:00
Michael Goulet
802f3a78a6 Merge HostPolarity and BoundConstness 2024-10-30 16:23:16 +00:00
Camille GILLOT
2d74d8f333 Actually capture all in-scope lifetimes. 2024-10-30 16:22:23 +00:00
Camille GILLOT
27c958fb44 Review comments. 2024-10-30 16:20:49 +00:00
Camille GILLOT
d804ef8be8 Adapt comments. 2024-10-30 16:20:02 +00:00
Camille GILLOT
b6e1214ac0 Remap impl-trait lifetimes on HIR instead of AST lowering. 2024-10-30 16:18:50 +00:00
Michael Goulet
9785c7cf94 Enforce that raw lifetime identifiers must be valid raw identifiers 2024-10-30 14:45:22 +00:00
许杰友 Jieyou Xu (Joe)
426f2fbbe2
Rollup merge of #132359 - mustartt:henry/match-libc-char-type, r=jieyouxu
Fix AIX libc call char type from i8 to u8

There was an update to AIX `libc` default char type from `i8 -> u8`, we should reflect that on the call site to satisfy the type checker.

81f0cd3d97/src/unix/aix/mod.rs (L1)
2024-10-30 22:22:06 +08:00
许杰友 Jieyou Xu (Joe)
18e44f89bf
Rollup merge of #132346 - nnethercote:some-graphviz-tweaks, r=cjgillot
Some graphviz tweaks

r? `@cjgillot`
2024-10-30 22:22:05 +08:00
Henry Jiang
a43a37c706 fix libc call from i8 to u8 2024-10-30 09:17:44 -04:00
Jan Bujak
167350d3e9 Add lp64e RISC-V ABI 2024-10-30 20:28:37 +09:00
Adrian Taylor
86af0f9b7e Switch to comparing indices instead of names. 2024-10-30 10:48:10 +00:00
Adrian Taylor
6d8d79595e Reject generic self types.
The RFC for arbitrary self types v2 declares that we should reject
"generic" self types. This commit does so.

The definition of "generic" was unclear in the RFC, but has been
explored in
https://github.com/rust-lang/rust/issues/129147
and the conclusion is that "generic" means any `self` type which
is a type parameter defined on the method itself, or references
to such a type.

This approach was chosen because other definitions of "generic"
don't work. Specifically,
* we can't filter out generic type _arguments_, because that would
  filter out Rc<Self> and all the other types of smart pointer
  we want to support;
* we can't filter out all type params, because Self itself is a
  type param, and because existing Rust code depends on other
  type params declared on the type (as opposed to the method).

This PR decides to make a new error code for this case, instead of
reusing the existing E0307 error. This makes the code a
bit more complex, but it seems we have an opportunity to provide
specific diagnostics for this case so we should do so.

This PR filters out generic self types whether or not the
'arbitrary self types' feature is enabled. However, it's believed
that it can't have any effect on code which uses stable Rust, since
there are no stable traits which can be used to indicate a valid
generic receiver type, and thus it would have been impossible to
write code which could trigger this new error case.
It is however possible that this could break existing code which
uses either of the unstable `arbitrary_self_types` or
`receiver_trait` features. This breakage is intentional; as
we move arbitrary self types towards stabilization we don't want
to continue to support generic such types.

This PR adds lots of extra tests to arbitrary-self-from-method-substs.
Most of these are ways to trigger a "type mismatch" error which
9b82580c73/compiler/rustc_hir_typeck/src/method/confirm.rs (L519)
hopes can be minimized by filtering out generics in this way.
We remove a FIXME from confirm.rs suggesting that we make this change.
It's still possible to cause type mismatch errors, and a subsequent
PR may be able to improve diagnostics in this area, but it's harder
to cause these errors without contrived uses of the turbofish.

This is a part of the arbitrary self types v2 project,
https://github.com/rust-lang/rfcs/pull/3519
https://github.com/rust-lang/rust/issues/44874

r? @wesleywiser
2024-10-30 10:48:08 +00:00
Matthias Krüger
879c4d5ccc
Rollup merge of #132342 - Zalathar:operand-bundle, r=workingjubilee
cg_llvm: Clean up FFI calls for operand bundles

All of these FFI functions have equivalents in the stable LLVM-C API, though `LLVMBuildCallBr` requires a temporary polyfill on LLVM 18.

This PR also creates a clear split between `OperandBundleOwned` and `OperandBundle`, and updates the internals of the owner to be a little less terrifying.
2024-10-30 06:40:38 +01:00
Matthias Krüger
cf2cc010a3
Rollup merge of #132340 - Zalathar:set-section, r=compiler-errors
cg_llvm: Consistently use safe wrapper function `set_section`

Follow-up to #131962 and https://github.com/rust-lang/rust/pull/132260#discussion_r1821626260.

To avoid too much scope creep, I've deliberately kept the changes to `LLVMRustGetSliceFromObjectDataByName` as minimal as possible.
2024-10-30 06:40:37 +01:00
Matthias Krüger
2055237e8f
Rollup merge of #132338 - nnethercote:rm-Engine, r=nnethercote
Remove `Engine`

It's just unnecessary plumbing. Removing it results in less code, and simpler code.

r? ``@cjgillot``
2024-10-30 06:40:37 +01:00
Matthias Krüger
2480e3bbc5
Rollup merge of #132332 - nnethercote:use-token_descr-more, r=estebank
Use `token_descr` more in error messages

This is the first two commits from #124141, put into their own PR to get things rolling. Commit messages have the details.

r? ``@estebank``
cc ``@petrochenkov``
2024-10-30 06:40:36 +01:00
Matthias Krüger
305508f969
Rollup merge of #131856 - lcnr:typing-mode, r=compiler-errors
TypingMode: merge intercrate, reveal, and defining_opaque_types

This adds `TypingMode` and uses it in most places. We do not yet remove `Reveal` from `param_env`s. This and other future work as tracked in #132279 and via `FIXME`s.

Fetching the `TypingMode` of the `InferCtxt` asserts that the `TypingMode` agrees with `ParamEnv::reveal` to make sure we don't introduce any subtle bugs here. This will be unnecessary once `ParamEnv::reveal` no longer exists.

As the `TypingMode` is now a part of the query input, I've merged the coherence and non-coherence caches for the new solver. I've also enabled the local `infcx` cache during coherence by clearing the cache when forking it with a different `TypingMode`.

#### `TypingMode::from_param_env`

I am using this even in cases where I know that the `param_env` will always be `Reveal::UserFacing`. This is to make it easier to correctly refactor this code in the future, any time we use `Reveal::UserFacing` in a body while not defining its opaque types is incorrect and should use a `TypingMode` which only reveals opaques defined by that body instead, cc #124598

r? ``@compiler-errors``
2024-10-30 06:40:34 +01:00
Matthias Krüger
87d348b333
Rollup merge of #129394 - Jarcho:irrefutable_let_patterns, r=Nadrieril
Don't lint `irrefutable_let_patterns` on leading patterns if `else if` let-chains

fixes #128661

Is there any preference where the test goes? There looks to be several places it could fit.
2024-10-30 06:40:34 +01:00
Zalathar
c3071590ab Clean up FFI calls for operand bundles 2024-10-30 13:26:24 +11:00
Nicholas Nethercote
d921be92a4 Return label from write_node_label.
Instead of appending an empty label. Because it's conceptually simpler.
2024-10-30 13:21:32 +11:00
Nicholas Nethercote
a8ce44f7d9 Simplify graphviz::Formatter.
`Formatter` currently has a `RefCell<Option<Results>>` field. This is so
the `Results` can be temporarily taken and put into a `ResultsCursor`
that is used by `BlockFormatter`, and then put back, which is messy.

This commit changes `Formatter` to have a `RefCell<ResultsCursor>` and
`BlockFormatter` to have a `&mut ResultsCursor`, which greatly
simplifies the code at the `Formatter`/`BlockFormatter` interaction
point in `Formatter::node_label`. It also means we construct a
`ResultsCursor` once per `Formatter`, instead of once per `node_label`
call.

The commit also:
- documents the reason for the `RefCell`;
- adds a `Formatter::body` method, replacing the `Formatter::body`
  field.
2024-10-30 13:19:29 +11:00
Nicholas Nethercote
744eb2f937 Rename BlockFormatter::results as BlockFormatter::cursor.
Because it's a `ResultsCursor`, not a `Results`. I find this easier to
read and understand.
2024-10-30 13:12:03 +11:00
Michael Goulet
1990f15608 Reject raw lifetime followed by \' as well 2024-10-30 01:13:18 +00:00
Zalathar
65ff2a6ad7 Consistently use safe wrapper function set_section 2024-10-30 11:38:20 +11:00