Commit Graph

33253 Commits

Author SHA1 Message Date
Nicholas Nethercote
899cb40809 Rename DiagnosticBuilder as Diag.
Much better!

Note that this involves renaming (and updating the value of)
`DIAGNOSTIC_BUILDER` in clippy.
2024-02-28 08:55:35 +11:00
Nicholas Nethercote
4e1f9bd528 Rename SubDiagnostic as Subdiag.
Note the change of the `D` to `d`, to match all the other names that
have `Subdiag` in them, such as `SubdiagnosticMessage` and
`derive(Subdiagnostic)`.
2024-02-28 08:33:25 +11:00
Nicholas Nethercote
366536ba2b Rename DelayedDiagnostic as DelayedDiagInner. 2024-02-28 08:33:25 +11:00
Nicholas Nethercote
6588f5b749 Rename Diagnostic as DiagInner.
I started by changing it to `DiagData`, but that didn't feel right.
`DiagInner` felt much better.
2024-02-28 08:33:25 +11:00
bors
b6e4299415 Auto merge of #121548 - RalfJung:ffi-unwind-intrinsics, r=davidtwco
ffi_unwind_calls: treat RustIntrinsic like regular Rust calls

Also add some comments to `abi_can_unwind` to explain what happens.

r? `@nbdd0121`  Cc `@BatmanAoD`
2024-02-27 13:33:35 +00:00
Ralf Jung
bd3ea3e096 ffi_unwind_calls: treat RustIntrinsic like regular Rust calls 2024-02-27 12:28:25 +01:00
bors
9afdb8d1d5 Auto merge of #121285 - nnethercote:delayed_bug-audit, r=lcnr
Delayed bug audit

I went through all the calls to `delayed_bug` and `span_delayed_bug` and found a few places where they could be avoided.

r? `@compiler-errors`
2024-02-27 11:03:07 +00:00
bors
53ed660d47 Auto merge of #120411 - erikdesjardins:netbsdcall, r=Nilstrieb
i586_unknown_netbsd: use inline stack probes

This is one of the last two targets still using "call" stack probes.

I don't believe that this target uses call stack probes for any particular reason--inline stack probes are used on [`i686_unknown_netbsd`](b362939be1/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs (L8)), suggesting they work on netbsd; and on [`i586_unknown_linux_gnu`](b362939be1/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs (L4)) (via the base [`i686_unknown_linux_gnu`](b362939be1/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs (L9))), suggesting they work with `cpu = "pentium"`.

...although I don't have a netbsd system to test this on.

(cc `@he32)`
2024-02-27 08:35:56 +00:00
bors
1c28a2c1b0 Auto merge of #121667 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb
syms for legacy numeric constants diag items

Missed these in #121272 and #121361, woops.

For https://github.com/rust-lang/rust-clippy/pull/12312

r? `@Nilstrieb`
2024-02-27 06:04:54 +00:00
Nicholas Nethercote
a8a486c846 Refactor take_for_recovery call sites.
To make them more concise and similar to each other.
2024-02-27 16:40:15 +11:00
Nicholas Nethercote
62b4e55112 Avoid a span_delayed_bug in compute_regions.
By storing error guarantees in `RegionErrors`.
2024-02-27 16:40:13 +11:00
Nicholas Nethercote
9f82563718 Avoid a span_delayed_bug in TypeErrCtxt::report_region_errors.
By returning error guarantees from a few functions it relies on.
2024-02-27 16:40:11 +11:00
Nicholas Nethercote
b2d1d6f6ff Avoid span_delayed_bug on one path in AdtDef::eval_explicit_discr.
Also change its return type to `Result`.
2024-02-27 16:31:45 +11:00
Nicholas Nethercote
d0267cb26b Remove an unnecessary span_delayed_bug in Resolver::valid_res_from_ribs.
`Resolver::report_error` always emits (this commit makes that clearer),
so the `span_delayed_bug` is unnecessary.
2024-02-27 16:31:40 +11:00
Nicholas Nethercote
c743e4a855 Refactor LoweringContext::get_delegation_sig_id.
I find the function much easier to read this way. Thanks to @kadiwa4 for
the suggestion.
2024-02-27 16:09:20 +11:00
Nicholas Nethercote
2fc94cefc5 Remove an unnecessary span_delayed_bug call.
The existing code calls a function that returns `Result<_,
ErrorGuaranteed>`, and then calls `span_delayed_bug` pointlessly in the
`Err` case.
2024-02-27 16:09:14 +11:00
bors
91cae1dcdc Auto merge of #121635 - 823984418:remove_archive_builder_lifetime_a, r=nnethercote
Remove useless lifetime of ArchiveBuilder

`trait ArchiveBuilder<'a>` has a seemingly useless lifetime a, so I remove it. If this is intentional, please reject this PR.

```rust
pub trait ArchiveBuilder<'a> {
    fn add_file(&mut self, path: &Path);

    fn add_archive(
        &mut self,
        archive: &Path,
        skip: Box<dyn FnMut(&str) -> bool + 'static>,
    ) -> io::Result<()>;

    fn build(self: Box<Self>, output: &Path) -> bool;
}
```
2024-02-27 03:27:48 +00:00
bors
71ffdf7ff7 Auto merge of #121655 - matthiaskrgr:rollup-qpx3kks, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #121598 (rename 'try' intrinsic to 'catch_unwind')
 - #121639 (Update books)
 - #121648 (Update Vec and String `{from,into}_raw_parts`-family docs)
 - #121651 (Properly emit `expected ;` on `#[attr] expr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-27 00:55:14 +00:00
Peter Jaszkowiak
2ea33225c2 syms for legacy numeric constants diag items 2024-02-26 17:37:12 -07:00
Matthias Krüger
ec5c5b7da8
Rollup merge of #121651 - ShE3py:issue-121647, r=estebank
Properly emit `expected ;` on `#[attr] expr`

Fixes #121647

See #118182, #120586

---
r? estebank
2024-02-27 00:40:01 +01:00
Matthias Krüger
d95c321062
Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk
rename 'try' intrinsic to 'catch_unwind'

The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO.

Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2024-02-27 00:40:00 +01:00
bors
5c786a7fe3 Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obk
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics

`@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit.

Blocked on https://github.com/rust-lang/stdarch/pull/1538, https://github.com/rust-lang/rust/pull/121542.
2024-02-26 22:24:16 +00:00
Lieselotte
1658ca082a
Properly emit expected ; on #[attr] expr 2024-02-26 21:47:10 +01:00
bors
829308e9af Auto merge of #121636 - matthiaskrgr:rollup-1tt2o5n, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #121389 (llvm-wrapper: fix few warnings)
 - #121493 (By changing some attributes to only_local, reducing encoding attributes in the crate metadate.)
 - #121615 (Move `emit_stashed_diagnostic` call in rustfmt.)
 - #121617 (Actually use the right closure kind when checking async Fn goals)
 - #121628 (Do not const prop unions)
 - #121629 (fix some references to no-longer-existing ReprOptions.layout_seed)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-26 17:14:13 +00:00
Matthias Krüger
81eddb3dac
Rollup merge of #121629 - RalfJung:field-shuffle-seed, r=oli-obk
fix some references to no-longer-existing ReprOptions.layout_seed

Seems like the field got renamed but some comments not updated.
2024-02-26 16:06:05 +01:00
Matthias Krüger
218be2771d
Rollup merge of #121628 - gurry:121534-ice-asymm-binop, r=oli-obk
Do not const prop unions

Unions can produce values whose types don't match their underlying layout types which can lead to ICEs on eval.

Fixes #121534
2024-02-26 16:06:04 +01:00
Matthias Krüger
4f167b4baf
Rollup merge of #121617 - compiler-errors:async-closure-kind-check, r=oli-obk
Actually use the right closure kind when checking async Fn goals

Dumb copy-paste mistake on my part from #120712. Sorry!

r? oli-obk

Fixes #121599
2024-02-26 16:06:04 +01:00
Matthias Krüger
6e3ece3aac
Rollup merge of #121493 - surechen:edit_attribute_only_local, r=lcnr
By changing some attributes to only_local, reducing encoding attributes in the crate metadate.

Thank you.
This is part of changing attributes to only_local. I hope get your opinion  whether I should split into multiple PRs, or submit in one.

According to [try to not rely on attributes from extern crates](https://github.com/rust-lang/compiler-team/issues/505) and lcnr's guidance.
2024-02-26 16:06:03 +01:00
Matthias Krüger
6700714394
Rollup merge of #121389 - klensy:llvm-warn-fix, r=nikic
llvm-wrapper: fix few warnings

Two fixes: first one is simple unsigned -> uint64_t, but how second one is more subtile, see commit description.
2024-02-26 16:06:02 +01:00
bors
b79db437dc Auto merge of #120586 - ShE3py:exprkind-err, r=fmease
Add `ErrorGuaranteed` to `ast::ExprKind::Err`

See #119967 for context
```
      \
       \
          _~^~^~_
      \) /  o o  \ (/
        '_   -   _'
        / '-----' \
```

r? fmease
2024-02-26 14:43:15 +00:00
823984418
0c082b7fa9 remove useless lifetime of ArchiveBuilder 2024-02-26 22:37:04 +08:00
bors
b8de591b65 Auto merge of #119106 - lcnr:decrement-universes, r=BoxyUwU
avoid generalization inside of aliases

The basic idea of this PR is that we don't generalize aliases when the instantiation could fail later on, either due to the *occurs check* or because of a universe error. We instead replace the whole alias with an inference variable and emit a nested `AliasRelate` goal. This `AliasRelate` then fully normalizes the alias before equating it with the inference variable, at which point the alias can be treated like any other rigid type.

We now treat aliases differently depending on whether they are *rigid* or not. To detect whether an alias is rigid we check whether `NormalizesTo` fails. While we already do so inside of `AliasRelate` anyways, also doing so when instantiating a query response would be both ugly/difficult and likely inefficient. To avoid that I change `instantiate_and_apply_query_response` to relate types completely structurally. This change generally removes a lot of annoying complexity, which is nice. It's implemented by adding a flag to `Equate` to change it to structurally handle aliases.

We currently always apply constraints from canonical queries right away. By providing all the necessary information to the canonical query, we can guarantee that instantiating the query response never fails, which further simplifies the implementation. This does add the invariant that *any information which could cause instantiating type variables to fail must also be available inside of the query*.

While it's acceptable for canonicalization to result in more ambiguity, we must not cause the solver to incompletely structurally relate aliases by erasing information. This means we have to be careful when merging universes during canonicalization. As we only generalize for type and const variables we have to make sure that anything nameable by such a type or const variable inside of the canonical query is also nameable outside of it. Because of this we both stop merging universes of existential variables when canonicalizing inputs, we put all uniquified regions into a higher universe which is not nameable by any type or const variable.

I will look into always replacing aliases with inference variables when generalizing in a later PR unless the alias references bound variables. This should both pretty much fix https://github.com/rust-lang/trait-system-refactor-initiative/issues/4. This may allow us to merge the universes of existential variables again by changing generalize to not consider their universe when deciding whether to generalize aliases. This requires some additional non-trivial changes to alias-relate, so I am leaving that as future work.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/79. While it would be nice to decrement universe indices when existing a `forall`, that was surprisingly difficult and not necessary to fix this issue. I am really happy with the approach in this PR think it is the correct way forward to also fix the remaining cases of https://github.com/rust-lang/trait-system-refactor-initiative/issues/8.
2024-02-26 12:11:58 +00:00
lcnr
3b3514acec consider placeholders in fn term_is_fully_unconstrained 2024-02-26 11:51:01 +01:00
Ralf Jung
b4ca582b89 rename 'try' intrinsic to 'catch_unwind' 2024-02-26 11:10:18 +01:00
lcnr
a788be0aae use fulfillment in `Coerce::unify'
only checking whether nested goals hold means that we don't consider
their inference constraints. Given that we now emit `AliasRelate` when relating
aliases and infer vars, this previously resulted in an "unconstrained" inference var
in `coerce_unsized`.
2024-02-26 10:57:38 +01:00
Gurinder Singh
633c92cd6d Do not const pop unions
as they can made to produce values whose types don't
match their underlying layout types which can lead to
ICEs on eval
2024-02-26 15:22:22 +05:30
Ralf Jung
297abc35b3 fix some references to no-longer-existing ReprOptions.layout_seed 2024-02-26 10:40:48 +01:00
Guillaume Gomez
76f303d658
Rollup merge of #121620 - nnethercote:fix-even-more-121208-fallout, r=lcnr
Fix more #121208 fallout (round 3)

#121208 converted lots of delayed bugs to bugs. Unsurprisingly, there were a few invalid conversion found via fuzzing.

r? `@lcnr`
2024-02-26 10:27:43 +01:00
Guillaume Gomez
91d337dfa8
Rollup merge of #120840 - HTGAzureX1212:HTGAzureX1212/unicode-identifier-types, r=fmease,Manishearth
Split Diagnostics for Uncommon Codepoints: Add Individual Identifier Types

This pull request further modifies the `uncommon_codepoints` lint, adding the individual identifier types of `Technical`, `Not_NFKC`, `Exclusion` and `Limited_Use` to the diagnostic message.

Example rendered diagnostic:
```
error: identifier contains a Unicode codepoint that is not used in normalized strings: 'ij'
  --> $DIR/lint-uncommon-codepoints.rs:6:4
   |
LL | fn dijkstra() {}
   |    ^^^^^^^
   = note: this character is included in the Not_NFKC Unicode general security profile
```

Second step of #120228.
2024-02-26 10:27:41 +01:00
lcnr
1b3164f5c9 always emit AliasRelate goals when relating aliases
Add `StructurallyRelateAliases` to allow instantiating infer vars with rigid aliases.
Change `instantiate_query_response` to be infallible in the new solver. This requires canonicalization to not hide any information used by the query, so weaken
universe compression. It also modifies `term_is_fully_unconstrained` to allow
region inference variables in a higher universe.
2024-02-26 10:17:43 +01:00
lcnr
eeeb9b4d31 add additional logging 2024-02-26 10:12:40 +01:00
HTGAzureX1212.
8bccceb8fc separate messages for individual categories 2024-02-26 10:09:03 +08:00
Michael Goulet
ff07f55db5 Actually use the right closure kind when checking async Fn goals 2024-02-26 01:36:14 +00:00
Nicholas Nethercote
edda2a7d3e Revert some span_bugs to span_delayed_bug.
Fixes #121503.
Fixes #121597.
2024-02-26 10:57:30 +11:00
Lieselotte
34eae07ee5
Remove ast:: & base:: prefixes from some builtin macros 2024-02-25 22:25:26 +01:00
Lieselotte
c440a5b814
Add ErrorGuaranteed to ast::ExprKind::Err 2024-02-25 22:24:31 +01:00
Lieselotte
a3fce72a27
Add ast::ExprKind::Dummy 2024-02-25 22:22:09 +01:00
bors
b0d3e04ca9 Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
Implement RFC 3373: Avoid non-local definitions in functions

This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-25 19:11:06 +00:00
bors
8c0b1fcd29 Auto merge of #121591 - matthiaskrgr:rollup-8wfhh3v, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #119590 (Stabilize `cfg_target_abi`)
 - #120805 (make non-PartialEq-typed consts as patterns a hard error)
 - #121060 (Add newtypes for bool fields/params/return types)
 - #121284 (Add test cases for inlining compiler-private items)
 - #121324 (pattern_analysis: factor out unspecialization)
 - #121409 (Prevent cycle in implied predicates computation)
 - #121513 (Fix sgx unit test compilation)
 - #121570 (Make most bootstrap step types !Copy)
 - #121586 (Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-25 16:18:45 +00:00
Matthias Krüger
a4423884c1
Rollup merge of #121586 - gurry:121532-ice-unwrap-on-none, r=cjgillot
Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails

Fixes #121532
2024-02-25 17:05:23 +01:00