Commit Graph

30626 Commits

Author SHA1 Message Date
bors 2b399b5275 Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errors
never_patterns: Parse match arms with no body

Never patterns are meant to signal unreachable cases, and thus don't take bodies:
```rust
let ptr: *const Option<!> = ...;
match *ptr {
    None => { foo(); }
    Some(!),
}
```
This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser).

~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit

r? `@compiler-errors`
2023-12-08 17:08:52 +00:00
bors ae612bedcb Auto merge of #118689 - compiler-errors:const-drop, r=fee1-dead
Fix const drop checking

Fixes confirmation of `~const Destruct` and const drops.

r? fee1-dead
2023-12-08 13:43:12 +00:00
bors 5ea62560f2 Auto merge of #118668 - fmease:resolve-assoc-item-bindings-by-namespace, r=compiler-errors
Resolve associated item bindings by namespace

This is the 3rd commit split off from #118360 with tests reblessed (they no longer contain duplicated diags which were caused by 4c0addc80a) & slightly adapted (removed supertraits from a UI test, cc #118040).

> * Resolve all assoc item bindings (type, const, fn (feature `return_type_notation`)) by namespace instead of trying to resolve a type first (in the non-RTN case) and falling back to consts afterwards. This is consistent with RTN. E.g., for `Tr<K = {…}>` we now always try to look up assoc consts (this extends to supertrait bounds). This gets rid of assoc tys shadowing assoc consts in assoc item bindings which is undesirable & inconsistent (types and consts live in different namespaces after all)
> * Consolidate the resolution of assoc {ty, const} bindings and RTN (dedup, better diags for RTN)
> * Fix assoc consts being labeled as assoc *types* in several diagnostics
> * Make a bunch of diagnostics translatable

Fixes #112560 (error → pass).

As discussed
r? `@compiler-errors`

---

**Addendum**: What I call “associated item bindings” are commonly referred to as “type bindings” for historical reasons. Nowadays, “type bindings” include assoc type bindings, assoc const bindings and RTN (return type notation) which is why I prefer not to use this outdated term.
2023-12-08 09:30:52 +00:00
Matthias Krüger beabb5e2e3
Rollup merge of #118709 - oksbsb:fix-job-server, r=SparrowLii
fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use

override #118589, resolve merge conflict

`@petrochenkov` `@SparrowLii`

Thanks!
2023-12-08 06:44:43 +01:00
Matthias Krüger f7c892e323
Rollup merge of #118695 - Zalathar:push-refined, r=davidtwco
coverage: Merge refined spans in a separate final pass

Pulling this merge step out of `push_refined_span` and into a separate pass lets us push directly to `refined_spans` instead of calling a helper method.

Because the compiler can now see partial borrows of `refined_spans`, we can remove some extra code that was jumping through hoops to satisfy the borrow checker.

---

``@rustbot`` label +A-code-coverage
2023-12-08 06:44:43 +01:00
Matthias Krüger 646d627661
Rollup merge of #118693 - saethlin:alignment-check-symbol-reachable, r=bjorn3
Tell MirUsedCollector that the pointer alignment checks calls its panic symbol

Fixes https://github.com/rust-lang/rust/pull/118683 (not an issue, but that PR is a basically a bug report)

When we had `panic_immediate_abort` start adding `#[inline]` to this panic function, builds started breaking because we failed to write up the MIR assert terminator to the correct panic shim. Things happened to work before by pure luck because without this feature enabled, the function we're inserting calls to is `#[inline(never)]` so we always generated code for it.

r? bjorn3
2023-12-08 06:44:42 +01:00
Matthias Krüger 0c121b568e
Rollup merge of #118690 - Zalathar:test-macros, r=cjgillot
coverage: Avoid unnecessary macros in unit tests

These macros don't provide enough value to justify their complexity, when they can just as easily be functions instead.

---

`@rustbot` label +A-code-coverage
2023-12-08 06:44:42 +01:00
bors 21982a4383 Auto merge of #118725 - lcnr:normalizes-to-projection-split-3, r=BoxyUwU
split `NormalizesTo` out of `Projection` 3

third attempt at #112658. Rebasing #116262 is very annoying, so I am doing it again from scratch. We should now be able to merge it without regressing anything as we handle occurs check failures involving aliases correctly since #117088.

see https://hackmd.io/ktEL8knTSYmtdfrMMnA-Hg

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/1

r? `@compiler-errors`
2023-12-08 02:28:10 +00:00
oksbsb dabedb711f 1. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
2023-12-08 09:50:28 +08:00
lcnr ac50f4b571 update fixme 2023-12-08 02:16:29 +01:00
lcnr ffb4c08a81 implement and use `NormalizesTo` 2023-12-08 01:31:18 +01:00
bors d6fa38a9b2 Auto merge of #118442 - tmiasko:fuel-inc, r=lqd
-Zfuel is incompatible with incremental compilation
2023-12-08 00:28:32 +00:00
Tomasz Miąsko 1a47e413b2 Fuel is incompatible with incremental compilation 2023-12-08 00:00:00 +00:00
bors 370c91100c Auto merge of #118723 - matthiaskrgr:rollup-409e9u1, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #116420 (discard invalid spans in external blocks)
 - #118686 (Only check principal trait ref for object safety)
 - #118688 (Add method to get type of an Rvalue in StableMIR)
 - #118707 (Ping GuillaumeGomez for changes in rustc_codegen_gcc)
 - #118712 (targets: remove not-added {i386,i486}-unknown-linux-gnu)
 - #118719 (CFI: Add char to CFI integer normalization)

Failed merges:

 - #117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-07 22:30:24 +00:00
Tomasz Miąsko a73d1bf631 Inline check_thread_count implementation 2023-12-07 23:28:44 +01:00
León Orell Valerian Liehr 55559d93e7
Resolve assoc item bindings by namespace
If a const is expected, resolve a const.
If a type is expected, resolve a type.
Don't try to resolve a type first falling back to consts.
2023-12-07 22:33:56 +01:00
Matthias Krüger 71812d7eb0
Rollup merge of #118719 - rcvalle:rust-cfi-normalize-integers-118032, r=compiler-errors
CFI: Add char to CFI integer normalization

Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-07 21:38:09 +01:00
Matthias Krüger 0be2196c45
Rollup merge of #118712 - davidtwco:targets-remove-i386-i486, r=compiler-errors
targets: remove not-added {i386,i486}-unknown-linux-gnu

These files were added to the repository but never wired up so they could be used - and that was a few years ago without anyone noticing - so let's remove these, they can be re-added if someone wants them.

cc #80662
r? ```@pnkfelix``` (familiar with the tier policy and Wesley is on vacation)
2023-12-07 21:38:09 +01:00
Matthias Krüger 20ed80523a
Rollup merge of #118688 - celinval:smir-rvalue-ty, r=compiler-errors
Add method to get type of an Rvalue in StableMIR

Provide a method to StableMIR users to retrieve the type of an Rvalue operation. There were two possible implementation:

1. Create the logic inside stable_mir to process the type according to the Rvalue semantics, which duplicates the logic of `rustc_middle::mir::Rvalue::ty()`.
2. Implement the Rvalue translation from StableMIR back to internal representation, invoke the `rustc_middle::mir::Rvalue::ty()`, and translate the return value to StableMIR.

I chose the first one for now since the duplication was fairly small, and the option 2 would require way more work to translate everything back to rustc internal representation. If we eventually add those translations, we could easily swap to the option 2.

```@compiler-errors``` / ```@ouz-a``` Please let me know if you have any strong opinion here.

r? ```@compiler-errors```
2023-12-07 21:38:08 +01:00
Matthias Krüger b20430345e
Rollup merge of #118686 - compiler-errors:object-safety, r=lcnr
Only check principal trait ref for object safety

It should make things a bit faster, in case we end up registering a bunch of object safety preds.

r? ```@ghost```
2023-12-07 21:38:08 +01:00
Matthias Krüger 71a8ca0522
Rollup merge of #116420 - bvanjoi:fix-116203, r=Nilstrieb
discard invalid spans in external blocks

Fixes #116203

This PR has discarded the invalid `const_span`, thereby making the format more neat.

r? ``@Nilstrieb``
2023-12-07 21:38:07 +01:00
bors 503e129328 Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelix
Avoid adding builtin functions to `symbols.o`

We found performance regressions in #113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not.

I found that `used` adds symbols to `symbols.o` at 3e202ead60/compiler/rustc_codegen_ssa/src/back/linker.rs (L1786-L1791).
The PR removes builtin functions.

Note that under LTO, ld still preserves these symbols. (lld will still remove them.)

The first commit also fixes #118559. But I think the second commit also makes sense.
2023-12-07 20:31:55 +00:00
Ramon de C Valle 97032d63bd CFI: Add char to CFI integer normalization
Adds char to CFI integer normalization to conform to #118032 for
cross-language CFI support.
2023-12-07 11:28:16 -08:00
bors 0e7f91b75e Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlin
compile-time evaluation: detect writes through immutable pointers

This has two motivations:
- it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable"
- it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB

When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already.

The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers.

I just hope perf works out.
2023-12-07 18:11:01 +00:00
lcnr 3978f545ba add unused `NormalizesTo` predicate 2023-12-07 17:52:51 +01:00
Ralf Jung 8188bd4548 avoid marking as immutable what is already immutable
this has been demonstrated to help performance
2023-12-07 17:46:48 +01:00
Ralf Jung 29c95e98e3 also print 'immutable' flag 2023-12-07 17:46:36 +01:00
Ralf Jung 4d93590d59 compile-time evaluation: emit a lint when a write through an immutable pointer occurs 2023-12-07 17:46:36 +01:00
Ralf Jung cb86303342 ctfe interpreter: extend provenance so that it can track whether a pointer is immutable 2023-12-07 17:46:36 +01:00
Michael Goulet efe8ae730f Fix const drop checking 2023-12-07 16:28:33 +00:00
bors f16c81fa79 Auto merge of #118706 - Urgau:update-rccg-gcc-libc, r=GuillaumeGomez
Fix `rustc_codegen_gcc` build and tests failure in CI

https://github.com/rust-lang/rust/pull/118463 seems to have broke the PR CI, more specificaly the `x86_64-gnu-llvm-16` builder which [fail with](https://github.com/rust-lang/rust/actions/runs/7128709674/job/19411205695?pr=118705#step:26:1668):

```
Building stage1 codegen backend gcc (x86_64-unknown-linux-gnu)
     Compiling libc v0.2.147
     Compiling rustix v0.38.8
     Compiling memchr v2.5.0
     Compiling bitflags v2.4.0
     Compiling linux-raw-sys v0.4.5
     Compiling fastrand v2.0.0
     Compiling smallvec v1.10.0
error: invalid `--check-cfg` argument: `values(freebsd10)` (expected `cfg(name, values("value1", "value2", ... "valueN"))`)

error: could not compile `libc` (lib) due to previous error
```

Updating to `libc` version 0.2.150 fixes the build issue since it includes the support for the new check-cfg syntax.

Then it [failed](https://github.com/rust-lang/rust/actions/runs/7129280743/job/19413025132?pr=118706#step:26:2218) with a missing `#![allow(internal_features)]` in one of the example.

r? `@GuillaumeGomez`
2023-12-07 16:12:06 +00:00
David Wood 399cd6cbfd
targets: remove not-added {i386,i486}-unknown-linux-gnu
These files were added to the repository but never wired up so they could
be used - and that was a few years ago without anyone noticing - so let's
remove these, they can be re-added if someone wants them.

Signed-off-by: David Wood <david@davidtw.co>
2023-12-07 15:36:00 +00:00
lcnr 40aa9f4fd9 avoid instantiating infer vars with infer 2023-12-07 16:13:09 +01:00
Urgau 0ed3b6850e Allow internal_features in rustc_codegen_gcc examples 2023-12-07 15:26:18 +01:00
bors 57fec79bec Auto merge of #118675 - petrochenkov:macreach, r=davidtwco
privacy: Simplify `update_macro_reachable`

Address a FIXME in code.
2023-12-07 14:08:20 +00:00
Urgau 61f62f19fe Update rustc_codegen_gcc libc 2023-12-07 14:59:37 +01:00
bors 7df0c211ac Auto merge of #118635 - nnethercote:fewer-early-errors, r=davidtwco
Fewer early errors

r? `@davidtwco`
2023-12-07 11:57:14 +00:00
bors f90f898fa5 Auto merge of #118685 - compiler-errors:stack-dependent, r=lcnr
`EvaluatedToUnknown` -> `EvaluatedToAmbigStackDependent`, `EvaluatedToRecur` -> `EvaluatedToErrStackDependent`

Less confusing names, since the only difference between them and their parallel `EvalutedTo..` is that they are stack dependent.

r? lcnr
2023-12-07 08:00:12 +00:00
Zalathar 9a4321518c coverage: Simplify code that pushes to `refined_spans` 2023-12-07 17:41:04 +11:00
Zalathar 9089d28780 coverage: Inline `push_refined_span` 2023-12-07 17:41:01 +11:00
Zalathar ec0110be09 coverage: Merge refined spans in a separate final pass
This makes `push_refined_span` trivial, which will let us inline it and benefit
from partial borrows of `refined_spans`.
2023-12-07 17:31:49 +11:00
Celina G. Val 4616b9fd1d Add sanity check to `BinOp::ty()` 2023-12-06 22:15:36 -08:00
bors 568f6a8641 Auto merge of #116565 - Sword-Destiny:master, r=Amanieu
add teeos std impl

add teeos std library implement.

this MR is draft untill the libc update to 0.2.150

this MR is the final step for suppot rust in teeos.
first step(add target): https://github.com/rust-lang/rust/pull/113480
second step(add teeos libc): https://github.com/rust-lang/libc/pull/3333
2023-12-07 05:22:21 +00:00
袁浩 e353eb91fb add teeos std impl
Signed-off-by: 袁浩 <yuanhao34@huawei.com>
2023-12-07 10:33:03 +08:00
Ben Kimock aa58ccb53e Tell MirUsedCollector that the pointer alignment checks calls its panic symbol 2023-12-06 21:30:23 -05:00
Celina G. Val 77d7e44573
Update compiler/stable_mir/src/mir/body.rs
Co-authored-by: Michael Goulet <michael@errs.io>
2023-12-06 17:48:38 -08:00
bors 670188cec9 Auto merge of #118684 - compiler-errors:yeet-poly-gen-sig, r=spastorino
Remove `PolyGenSig` since it's always a dummy binder

Coroutines are never polymorphic in their signature. This cleans up a FIXME in the code:

```
    /// Returns the "coroutine signature", which consists of its yield
    /// and return types.
    ///
    /// N.B., some bits of the code prefers to see this wrapped in a
    /// binder, but it never contains bound regions. Probably this
    /// function should be removed.
```
2023-12-07 00:30:07 +00:00
Zalathar 47e6e5ee67 coverage: Avoid unnecessary macros in unit tests
These macros don't provide enough value to justify their complexity, when they
can just as easily be functions instead.
2023-12-07 11:12:48 +11:00
Celina G. Val e16ebdbb06 Simplify StaticDef to Instance conversion 2023-12-06 15:08:08 -08:00
Celina G. Val 281b65aad9 Add method to get type of an Rvalue in StableMIR 2023-12-06 14:26:52 -08:00