Commit Graph

7773 Commits

Author SHA1 Message Date
Maybe Lapkin
673bb5e3ff
Mark never_type_fallback_flowing_into_unsafe as a semantic change
...rather than a future error
2024-11-14 06:01:14 +01:00
Maybe Lapkin
46967bd2e9
Mention both release *and* edition breakage for never type lints 2024-11-14 01:32:54 +01:00
bors
6503543d11 Auto merge of #132282 - Noratrieb:it-is-the-end-of-serial, r=cjgillot
Delete the `cfg(not(parallel))` serial compiler

Since it's inception a long time ago, the parallel compiler and its cfgs have been a maintenance burden. This was a necessary evil the allow iteration while not degrading performance because of synchronization overhead.

But this time is over. Thanks to the amazing work by the parallel working group (and the dyn sync crimes), the parallel compiler has now been fast enough to be shipped by default in nightly for quite a while now.
Stable and beta have still been on the serial compiler, because they can't use `-Zthreads` anyways.
But this is quite suboptimal:
- the maintenance burden still sucks
- we're not testing the serial compiler in nightly

Because of these reasons, it's time to end it. The serial compiler has served us well in the years since it was split from the parallel one, but it's over now.

Let the knight slay one head of the two-headed dragon!

#113349

Note that the default is still 1 thread, as more than 1 thread is still fairly broken.

cc `@onur-ozkan` to see if i did the bootstrap field removal correctly, `@SparrowLii` on the sync parts
2024-11-12 15:14:56 +00:00
Noratrieb
505b8e1332 Delete the cfg(not(parallel)) serial compiler
Since it's inception a long time ago, the parallel compiler and its cfgs
have been a maintenance burden. This was a necessary evil the allow
iteration while not degrading performance because of synchronization
overhead.

But this time is over. Thanks to the amazing work by the parallel
working group (and the dyn sync crimes), the parallel compiler has now
been fast enough to be shipped by default in nightly for quite a while
now.
Stable and beta have still been on the serial compiler, because they
can't use `-Zthreads` anyways.
But this is quite suboptimal:
- the maintenance burden still sucks
- we're not testing the serial compiler in nightly

Because of these reasons, it's time to end it. The serial compiler has
served us well in the years since it was split from the parallel one,
but it's over now.

Let the knight slay one head of the two-headed dragon!
2024-11-12 13:38:58 +00:00
bors
583b25d8d1 Auto merge of #132843 - RalfJung:mono-time-checks, r=lcnr
move all mono-time checks into their own folder, and their own query

The mono item collector currently also drives two mono-time checks: the lint for "large moves", and the check whether function calls are done with all the required target features.

Instead of doing this "inside" the collector, this PR refactors things so that we have a new `rustc_monomorphize::mono_checks` module providing a per-instance query that does these checks. We already have a per-instance query for the ABI checks, so this should be "free" for incremental builds. Non-incremental builds might do a bit more work now since we now have two separate MIR visits (in the collector and the mono-time checks) -- but one of them is cached in case the MIR doesn't change, which is nice.

This slightly changes behavior of the large-move check since the "move_size_spans" deduplication logic now only works per-instance, not globally across the entire collector.

Cc `@saethlin` since you're also doing some work related to queries and caching and monomorphization, though I don't know if there's any interaction here.
2024-11-12 11:24:46 +00:00
bors
5700240aff Auto merge of #132943 - matthiaskrgr:rollup-164l3ej, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #132651 (Remove attributes from generics in built-in derive macros)
 - #132668 (Feature gate yield expressions not in 2024)
 - #132771 (test(configure): cover `parse_args` in `src/bootstrap/configure.py`)
 - #132895 (Generalize `NonNull::from_raw_parts` per ACP362)
 - #132914 (Update grammar in std::cell docs.)
 - #132927 (Consolidate type system const evaluation under `traits::evaluate_const`)
 - #132935 (Make sure to ignore elided lifetimes when pointing at args for fulfillment errors)
 - #132941 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 08:15:38 +00:00
Matthias Krüger
ea61714d52
Rollup merge of #132927 - BoxyUwU:consolidate_type_system_const_eval, r=compiler-errors
Consolidate type system const evaluation under `traits::evaluate_const`

Part of #130704

Fixes #128232
Fixes #118545

Removes `ty::Const::{normalize_internal, eval_valtree}` and `InferCtxt::(try_)const_eval_resolve`, consolidating the associated logic into `evaluate_const` in `rustc_trait_selection`. This results in an API for `ty::Const` that is free of any normalization/evaluation functions that would be incorrect to use under `min_generic_const_args`/`associated_const_equality`/`generic_const_exprs` or, more generally, that would be incorrect to use in the presence of generic type system constants.

Moving this logic to `rustc_trait_selection` and out of `rustc_middle` is also a pre-requisite for ensuring that we do not evaluate constants whose where clauses do not hold.

From this point it should be relatively simple (hah) to implement more complex normalization of type system constants such as: checking wf'ness before invoking CTFE machinery, or being able to normalize const aliases that still refer to generic parameters.

r? `@compiler-errors`
2024-11-12 08:07:18 +01:00
Matthias Krüger
2ad4a3568d
Rollup merge of #132627 - adwinwhite:thir_body_cleanup, r=compiler-errors
cleanup: Remove outdated comment of `thir_body`

When typeck fails, `thir_body` returns `ErrorGuaranteed` rather than empty body.

No other code follows this outdated description except `check_unsafety`, which is also cleaned up in this PR.
2024-11-12 06:27:17 +01:00
Boxy
bea0148ac6 Consolidate type system const evaluation under traits::evaluate_const
mew
2024-11-12 02:54:03 +00:00
Matthias Krüger
b41baf8c81
Rollup merge of #132912 - fmease:simplify-gen-param-default-users, r=compiler-errors
Simplify some places that deal with generic parameter defaults
2024-11-11 21:58:33 +01:00
León Orell Valerian Liehr
d0ddba3d5b
Simplify some places that deal with generic parameter defaults 2024-11-11 21:29:18 +01:00
bors
3a258d1cf9 Auto merge of #132854 - RalfJung:query-key-limit, r=compiler-errors
query/plumbing: adjust comment to reality

The limit for the query key size got changed recently in f51ec110a7 but the comment was not updated.

Though maybe it is time to intern `CanonicalTypeOpAscribeUserTypeGoal` rather than copying it everywhere?

r? `@lcnr`
2024-11-11 05:17:13 +00:00
Matthias Krüger
b95232dabb
Rollup merge of #132675 - Zalathar:empty-spans, r=jieyouxu
coverage: Restrict empty-span expansion to only cover `{` and `}`

Coverage instrumentation has some tricky code for converting a coverage-relevant `Span` into a set of start/end line/byte-column coordinates that will be embedded in the CGU's coverage metadata.

A big part of this complexity is special code for handling empty spans, which are expanded into non-empty spans (if possible) because LLVM's coverage reporter does not handle empty spans well.

This PR simplifies that code by restricting it to only apply in two specific situations: when the character after the empty span is `{`, or the character before the empty span is `}`.

(As an added benefit, this means that the expanded spans no longer extend awkwardly beyond the end of a physical line, which was common under the previous implementation.)

Along the way, this PR also removes some unhelpful code for dealing with function source code spread across multiple files. Functions currently can't have coverage spans in multiple files, and if that ever changes (e.g. to properly support expansion regions) then this code will need to be completely overhauled anyway.
2024-11-10 17:43:07 +01:00
Ralf Jung
c8058c81bf query/plumbing: adjust comment to reality 2024-11-10 15:13:33 +01:00
Ralf Jung
23054c5dfc move all mono-time checks into their own folder, and their own query 2024-11-10 12:12:12 +01:00
bors
668959740f Auto merge of #132831 - workingjubilee:rollup-6fdif44, r=workingjubilee
Rollup of 6 pull requests

Successful merges:

 - #131258 (Stabilize s390x inline assembly)
 - #132801 (interpret: get_alloc_info: also return mutability)
 - #132823 (require const_impl_trait gate for all conditional and trait const calls)
 - #132824 (Update grammar in wasm-c-abi's compiler flag documentation)
 - #132825 (Exclude relnotes-tracking-issue from needs-triage)
 - #132828 (Additional tests to ensure let is rejected during parsing)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-10 05:54:13 +00:00
Jubilee
61f51931b2
Rollup merge of #132801 - RalfJung:alloc-mutability, r=oli-obk
interpret: get_alloc_info: also return mutability

This will be needed for https://github.com/rust-lang/miri/pull/3971

This then tuned into a larger refactor where we introduce a new type for the `get_alloc_info` return data, and we move some code to methods on `GlobalAlloc` to avoid duplicating it between the validity check and `get_alloc_info`.
2024-11-09 20:28:43 -08:00
bors
7660aed73d Auto merge of #132173 - veluca93:abi_checks, r=RalfJung,compiler-errors
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

r? RalfJung
2024-11-10 02:52:25 +00:00
Matthias Krüger
3aa1a24799
Rollup merge of #132799 - zachs18:str-primitive-symbol, r=compiler-errors
Make `Ty::primitive_symbol` recognize `str`

Make `Ty::primitive_symbol` recognize `str`, which makes `str` eligible for the "expected primitive, found local type" (and vice versa) [diagnostic](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs#L1430-L1437) that already exists for other primitives.

<details><summary> diagnostic difference</summary>

```rs
#[allow(non_camel_case_types)]
struct str;

fn foo() {
    let _: &str = "hello";
    let _: &core::primitive::str = &str;
}
```

`rustc --crate-type lib --edition 2021 a.rs`

Current nightly:

```rs
error[E0308]: mismatched types
 --> a.rs:5:19
  |
5 |     let _: &str = "hello";
  |            ----   ^^^^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: expected reference `&str`
             found reference `&'static str`

error[E0308]: mismatched types
 --> a.rs:6:36
  |
6 |     let _: &core::primitive::str = &str;
  |            ---------------------   ^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: expected reference `&str` (`str`)
             found reference `&str` (`str`)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
```

With this patch:

```rs
error[E0308]: mismatched types
 --> a.rs:5:19
  |
5 |     let _: &str = "hello";
  |            ----   ^^^^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: str and `str` have similar names, but are actually distinct types
  = note: str is a primitive defined by the language
note: `str` is defined in the current crate
 --> a.rs:2:1
  |
2 | struct str;
  | ^^^^^^^^^^

error[E0308]: mismatched types
 --> a.rs:6:36
  |
6 |     let _: &core::primitive::str = &str;
  |            ---------------------   ^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: str and `str` have similar names, but are actually distinct types
  = note: str is a primitive defined by the language
note: `str` is defined in the current crate
 --> a.rs:2:1
  |
2 | struct str;
  | ^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
```

</details>
2024-11-09 19:16:46 +01:00
Ralf Jung
4a54ec8c18 make return type of get_alloc_info a struct, and reduce some code duplication with validity checking 2024-11-09 15:18:52 +01:00
Matthias Krüger
6e05afd744
Rollup merge of #132745 - RalfJung:pointee-info-inside-enum, r=DianQK
pointee_info_at: fix logic for recursing into enums

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

The logic in `pointee_info_at` was likely written at a time when the null pointer optimization was the *only* enum layout optimization -- and as `Variant::Multiple` kept getting expanded, nobody noticed that the logic is now unsound.

The job of this function is to figure out whether there is a dereferenceable-or-null and aligned pointer at a given offset inside a type. So when we recurse into a multi-variant enum, we better make sure that all the other enum variants must be null! This is the part that was forgotten, and this PR adds it.

The reason this didn't explode in many ways so far is that our references only have 1 niche value (null), so it's not possible on stable to have a multi-variant enum with a dereferenceable pointer and other enum variants that are not null. But with `rustc_layout_scalar_valid_range` attributes one can force such a layout, and if `@the8472's` work on alignment niches ever lands, that will make this possible on stable.
2024-11-09 10:52:03 +01:00
Zachary S
d37e6dfee8 Add str to "expected primitive, found type" diagnostic 2024-11-09 00:18:47 -06:00
Jubilee
7a4970476e
Rollup merge of #132757 - compiler-errors:yeet-check-wf, r=lcnr
Get rid of `check_opaque_type_well_formed`

Instead, replicate it by improving the span of the opaque in `check_opaque_meets_bounds`.

This has two consequences:
1. We now prefer "concrete type differs" errors, since we'll hit those first before we check the opaque is WF.
2. Spans have gotten slightly worse.

Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration.

r? lcnr
2024-11-08 20:46:12 -08:00
Michael Goulet
13ab08d7dc Do not reveal opaques in the param-env, we got lazy norm instead 2024-11-09 03:55:07 +00:00
Zalathar
996bdabc2a coverage: Remove unhelpful code for handling multiple files per function
Functions currently can't have mappings in multiple files, and if that ever
changes (e.g. to properly support expansion regions), this code will need to be
completely overhauled anyway.
2024-11-08 20:43:08 +11:00
Ralf Jung
e3010e84db remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead 2024-11-08 09:16:00 +01:00
Ralf Jung
35a913b968 pointee_info_at: fix logic for recursing into enums 2024-11-08 07:35:29 +01:00
Michael Goulet
97dfe8b871 Manually register some bounds for a better span 2024-11-08 04:56:08 +00:00
Jubilee
4036472749
Rollup merge of #132131 - celinval:smir-crate-defs, r=compiler-errors
[StableMIR] API to retrieve definitions from crates

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? ````@compiler-errors:```` Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!
2024-11-07 18:48:22 -08:00
Celina G. Val
0ce579f6f3 [StableMIR] API to retrieve definitions from crates
Add functions to retrieve function definitions and static items from
all crates (local and external).

For external crates, add a query to retrieve the number of defs in a
foreign crate.
2024-11-07 13:11:46 -08:00
Matthias Krüger
fd41a373f3
Rollup merge of #132734 - RalfJung:platform-intrinsic, r=compiler-errors
remove 'platform-intrinsic' ABI leftovers

This was removed a while ago, but some parts haven't been fully cleaned up.
2024-11-07 18:19:38 +01:00
Ralf Jung
fa0b97268a remove 'platform-intrinsic' ABI leftovers 2024-11-07 17:42:49 +01:00
Esteban Küber
dceb3fc9fa Tweak E0320 overflow error wording
Surrount type with backticks as we should in every error.
2024-11-05 21:54:45 +00:00
bors
e8c698bb3b Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee
mark some target features as 'forbidden' so they cannot be (un)set with -Ctarget-feature

The context for this is https://github.com/rust-lang/rust/issues/116344: some target features change the way floats are passed between functions. Changing those target features is unsound as code compiled for the same target may now use different ABIs.

So this introduces a new concept of "forbidden" target features (on top of the existing "stable " and "unstable" categories), and makes it a hard error to (un)set such a target feature. For now, the x86 and ARM feature `soft-float` is on that list. We'll have to make some effort to collect more relevant features, and similar features from other targets, but that can happen after the basic infrastructure for this landed. (These features are being collected in https://github.com/rust-lang/rust/issues/131799.)

I've made this a warning for now to give people some time to speak up if this would break something.

MCP: https://github.com/rust-lang/compiler-team/issues/780
2024-11-05 16:25:45 +00:00
bors
096277e989 Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
Remove unnecessary pub enum glob-imports from `rustc_middle::ty`

We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly.

`@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`.

This PR is a bit large, but it's just naming.

The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine.

r? `@noratrieb` or reassign
2024-11-05 08:30:56 +00:00
Adwin White
15a71b64b8 cleanup: Remove outdated comment and logic of thir_body 2024-11-05 12:41:52 +08:00
Ralf Jung
a741b33c14 when an intrinsic has a const-stable fallback body, we can easily expose it on stable 2024-11-04 23:27:46 +01:00
Ralf Jung
1f0ed2b0f5 add new rustc_const_stable_intrinsic attribute for const-stable intrinsics 2024-11-04 23:27:46 +01:00
Ralf Jung
ffad9aac27 mark some target features as 'forbidden' so they cannot be (un)set
For now, this is just a warning, but should become a hard error in the future
2024-11-04 22:56:47 +01:00
Matthias Krüger
b9db639ea5
Rollup merge of #132544 - dianne:unstable-library-feature-backticks, r=compiler-errors
Use backticks instead of single quotes for library feature names in diagnostics

This PR changes the text of library feature errors for using unstable or body-unstable items. Displaying library feature names in backticks is consistent with other diagnostics (e.g. those from `rustc_passes`) and with the `reason`s on unstable attributes in the library. Additionally, this simplifies diagnostics when supporting multiple unstable attributes on items (see #131824) since `DiagSymbolList` also displays symbols using backticks.
2024-11-04 18:12:46 +01: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
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
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
236fe33345 compiler: Directly use rustc_abi in metadata and middle
Stop reexporting ReprOptions from middle::ty
2024-11-03 13:38:47 -08:00
Michael Goulet
6b96103bf3 Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +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