Commit Graph

35789 Commits

Author SHA1 Message Date
Nicholas Nethercote df6f7133ee De-tuple two `vtable_trait_first_method_offset` args.
Thus eliminating a `FIXME` comment.
2024-05-10 09:55:09 +10:00
Nicholas Nethercote 24445d3b6a Remove out-of-date comment.
The use of `Binder` was removed in the recent #123900, but the comment
wasn't removed at the same time.
2024-05-10 09:55:09 +10:00
Nicholas Nethercote d13612bce7 Remove `TyCtxt::try_normalize_erasing_late_bound_regions`.
It's unused.
2024-05-10 09:55:09 +10:00
Nicholas Nethercote 5b5dd1b3de Fix out-of-date comment.
The type name has changed.
2024-05-10 09:55:07 +10:00
Nicholas Nethercote d6c63bdb21 Fix up `DescriptionCtx::new`.
The comment mentions that `ReBound` and `ReVar` aren't expected here.
Experimentation with the full test suite indicates this is true, and
that `ReErased` also doesn't occur. So the commit introduces `bug!` for
those cases. (If any of them show up later on, at least we'll have a
test case.)

The commit also remove the first sentence in the comment.
`RePlaceholder` is now handled in the match arm above this comment and
nothing is printed for it, so that sentence is just wrong. Furthermore,
issue #13998 was closed some time ago.
2024-05-09 20:15:44 +10:00
Nicholas Nethercote 609b9a67c9 Correct a comment.
I tried simplifying `RegionCtxt`, which led me to finding that the
fields are printed in `sccs_info`.
2024-05-09 20:15:42 +10:00
Matthias Krüger 782ef18168
Rollup merge of #124909 - compiler-errors:struct-tail-leftovers, r=compiler-errors
Reapply the part of #124548 that bors forgot

https://github.com/rust-lang/rust/pull/124548#issuecomment-2101311205
r? compiler-errors
2024-05-08 23:33:28 +02:00
Matthias Krüger 294ac1b57d
Rollup merge of #124892 - jfgoog:update-cc, r=workingjubilee
Update cc crate to v1.0.97
2024-05-08 23:33:27 +02:00
Matthias Krüger 3e22ea9e2f
Rollup merge of #124876 - nnethercote:rm-use-crate-rustc_foo, r=compiler-errors
Simplify `use crate::rustc_foo::bar` occurrences.

They can just be written as `use rustc_foo::bar`, which is far more standard. (I didn't even know that a `crate::` prefix was valid.)

r? ``@eholk``
2024-05-08 23:33:26 +02:00
Matthias Krüger 952f12ea7a
Rollup merge of #124869 - compiler-errors:keyword, r=Nilstrieb
Make sure we don't deny macro vars w keyword names

`$async:ident`, etc are all valid.

Fixes #124862
2024-05-08 23:33:26 +02:00
Matthias Krüger d8a3a69ad1
Rollup merge of #124587 - reitermarkus:use-generic-nonzero, r=dtolnay
Generic `NonZero` post-stabilization changes.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? ``@dtolnay``
2024-05-08 23:33:25 +02:00
Matthias Krüger d30af5e168
Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=Nilstrieb
Remove braces when fixing a nested use tree into a single item

[Back in 2019](https://github.com/rust-lang/rust/pull/56645) I added rustfix support for the `unused_imports` lint, to automatically remove them when running `cargo fix`. For the most part this worked great, but when removing all but one childs of a nested use tree it turned `use foo::{Unused, Used}` into `use foo::{Used}`. This is slightly annoying, because it then requires you to run `rustfmt` to get `use foo::Used`.

This PR automatically removes braces and the surrouding whitespace when all but one child of a nested use tree are unused. To get it done I had to add the span of the nested use tree to the AST, and refactor a bit the code I wrote back then.

A thing I noticed is, there doesn't seem to be any `//@ run-rustfix` test for fixing the `unused_imports` lint. I created a test in `tests/suggestions` (is that the right directory?) that for now tests just what I added in the PR. I can followup in a separate PR to add more tests for fixing `unused_lints`.

This PR is best reviewed commit-by-commit.
2024-05-08 23:33:24 +02:00
Gurinder Singh cacc0829ff Handle normalization failure in `struct_tail_erasing_lifetimes`
Fixes an ICE that occurred when the struct in question has an error
2024-05-08 17:24:17 -04:00
Markus Reiter bd8e565e16
Use generic `NonZero`. 2024-05-08 21:37:55 +02:00
Markus Reiter 7531eafa7e
Simplify suggestion. 2024-05-08 21:37:54 +02:00
James Farrell fbc2abd6be Update cc crate to v1.0.97 2024-05-08 15:06:35 +00:00
Matthias Krüger 9fce3dc685
Rollup merge of #124761 - Urgau:ref-casting_bigger_slice_index, r=jieyouxu
Fix insufficient logic when searching for the underlying allocation

This PR fixes the logic inside the `invalid_reference_casting` lint, when trying to lint on bigger memory layout casts.

More specifically when looking for the "underlying allocation" we were wrongly assuming that when we got `&mut slice[index]` that `slice[index]` was the allocation, but it's not.

Fixes https://github.com/rust-lang/rust/issues/124685
2024-05-08 17:03:09 +02:00
Matthias Krüger e997508ecb
Rollup merge of #124548 - gurry:113272-ice-failed-to-normalize, r=compiler-errors
Handle normalization failure in `struct_tail_erasing_lifetimes`

Fixes #113272

The ICE occurred because the struct being normalized had an error. This PR adds some defensive code to guard against that.
2024-05-08 17:03:08 +02:00
bors e3029d220f Auto merge of #124858 - alexcrichton:some-wasi-changes, r=michaelwoerister
rustc: Some small changes for the wasm32-wasip2 target

This commit has a few changes for the wasm32-wasip2 target. The first two are aimed at improving the compatibility of using `clang` as an external linker driver on this target. The default target to LLVM is updated to match the Rust target and additionally the `-fuse-ld=lld` argument is dropped since that otherwise interferes with clang's own linker detection. The only linker on wasm targets is LLD but on the wasip2 target a wrapper around LLD, `wasm-component-ld`, is used to drive the process and perform steps necessary for componentization.

The final commit changes the output of all objects on the wasip2 target to being PIC by default. This improves compatibilty with shared libaries but notably does not mean that there's a turnkey solution for shared libraries. The hope is that by having the standard libray work both with and without dynamic libraries will make experimentation easier.
2024-05-08 11:39:26 +00:00
Nicholas Nethercote b68b92041c Simplify `use crate::rustc_foo::bar` occurrences.
They can just be written as `use rustc_foo::bar`, which is far more
standard. (I didn't even know that a `crate::` prefix was valid.)
2024-05-08 16:57:31 +10:00
bors 5ce96b1d0f Auto merge of #124779 - workingjubilee:debug-formatting-my-beloved, r=compiler-errors
Improve `rustc_parse::Parser`'s debuggability

The main event is the final commit where I add `Parser::debug_lookahead`. Everything else was basically cleaning up things that bugged me (debugging, as it were) until I felt comfortable enough to actually work on it.

The motivation is that it's annoying as hell to try to figure out how the debug infra works in rustc without having basic queries like `debug!(?parser);` come up "empty". However, Parser has a lot of fields that are mostly irrelevant for most debugging, like the entire ParseSess. I think `Parser::debug_lookahead` with a capped lookahead might be fine as a general-purpose Debug impl, but this adapter version was suggested to allow more choice, and admittedly, it's a refined version of what I was already handrolling just to get some insight going.
2024-05-08 05:11:18 +00:00
Jubilee Young 5e67a3783c compiler: add `Parser::debug_lookahead`
I tried debugging a parser-related issue but found it annoying to not be
able to easily peek into the Parser's token stream.

Add a convenience fn that offers an opinionated view into the parser,
but one that is useful for answering basic questions about parser state.
2024-05-07 19:10:29 -07:00
Jubilee Young c70290da0a compiler: derive Debug in parser
It's annoying to debug the parser if you have to stop every five seconds
to add a Debug impl.
2024-05-07 19:09:39 -07:00
bors a60f077c38 Auto merge of #124683 - estebank:issue-124651, r=compiler-errors
Do not ICE on foreign malformed `diagnostic::on_unimplemented`

Fix #124651.
2024-05-08 00:54:38 +00:00
Michael Goulet 1d9d6715ae Make sure we don't deny macro vars w keyword names 2024-05-07 19:13:33 -04:00
bors 5486f0c1c2 Auto merge of #124223 - Zalathar:conditional-let, r=compiler-errors
coverage: Branch coverage support for let-else and if-let

This PR adds branch coverage instrumentation for let-else and if-let, including let-chains.

This lifts two of the limitations listed at #124118.
2024-05-07 22:28:51 +00:00
Alex Crichton 38b2bd782b rustc: Change wasm32-wasip2 to PIC-by-default
This commit changes the new `wasm32-wasip2` target to being PIC by
default rather than the previous non-PIC by default. This change is
intended to make it easier for the standard library to be used in a
shared object in its precompiled form. This comes with a hypothetical
modest slowdown but it's expected that this is quite minor in most use
cases or otherwise wasm compilers and/or optimizing runtimes can elide
the cost.
2024-05-07 13:26:01 -07:00
bors faefc618cf Auto merge of #124219 - gurry:122989-ice-unexpected-anon-const, r=compiler-errors
Do not ICE on `AnonConst`s in `diagnostic_hir_wf_check`

Fixes #122989

Below is the snippet from #122989 that ICEs:
```rust
trait Traitor<const N: N<2> = 1, const N: N<2> = N> {
    fn N(&N) -> N<2> {
        M
    }
}

trait N<const N: Traitor<2> = 12> {}
```

The `AnonConst` that triggers the ICE is the `2` in the param `const N: N<2> = 1`. The currently existing code in `diagnostic_hir_wf_check` deals only with `AnonConst`s that are default values of some param, but  the `2` is not a default value. It is just an `AnonConst` HIR node inside a `TraitRef` HIR node corresponding to `N<2>`. Therefore the existing code cannot handle it and this PR ensures that it does.
2024-05-07 20:01:18 +00:00
bors b923ea4924 Auto merge of #124849 - matthiaskrgr:rollup-68humsk, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124738 (rustdoc: dedup search form HTML)
 - #124827 (generalize hr alias: avoid unconstrainable infer vars)
 - #124832 (narrow down visibilities in `rustc_parse::lexer`)
 - #124842 (replace another Option<Span> by DUMMY_SP)
 - #124846 (Don't ICE when we cannot eval a const to a valtree in the new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-07 17:44:06 +00:00
Matthias Krüger 067f6327a5
Rollup merge of #124846 - compiler-errors:const-eval, r=lcnr
Don't ICE when we cannot eval a const to a valtree in the new solver

Use `const_eval_resolve` instead of `try_const_eval_resolve` because naming aside, the former doesn't ICE when a value can't be evaluated to a valtree.

r? lcnr
2024-05-07 18:12:56 +02:00
Matthias Krüger a29a7d1551
Rollup merge of #124842 - RalfJung:option-span, r=compiler-errors
replace another Option<Span> by DUMMY_SP

This was missed in https://github.com/rust-lang/rust/pull/122480.
2024-05-07 18:12:56 +02:00
Matthias Krüger fdeac24c52
Rollup merge of #124832 - linyihai:visibility-of-lexer, r=fmease
narrow down visibilities in `rustc_parse::lexer`

Found something visibility can be narrowed down on `rustc_parse::lexer`.

The mods only used in lexer, so it is ok to limit visibility to `pub(super)`,
see https://github.com/rust-lang/rust/blob/master/compiler/rustc_parse/src/lexer/mod.rs#L22-L25
2024-05-07 18:12:55 +02:00
Matthias Krüger 4a5bf7b06e
Rollup merge of #124827 - lcnr:generalize-incomplete, r=compiler-errors
generalize hr alias: avoid unconstrainable infer vars

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

see inline comments for more details

r? `@compiler-errors` cc `@BoxyUwU`
2024-05-07 18:12:55 +02:00
lcnr 690d5aa417 generalize hr alias: avoid unconstrainable infer vars 2024-05-07 15:58:06 +00:00
Michael Goulet b58f5a7800 Don't ICE when we cannot eval a const to a valtree in the new solver 2024-05-07 11:14:25 -04:00
bors 0f40f14b61 Auto merge of #123332 - Nadrieril:testkind-never, r=matthewjasper
never patterns: lower never patterns to `Unreachable` in MIR

This lowers a `!` pattern to "goto Unreachable". Ideally I'd like to read from the place to make it clear that the UB is coming from an invalid value, but that's tricky so I'm leaving it for later.

r? `@compiler-errors` how do you feel about a lil bit of MIR lowering
2024-05-07 15:14:20 +00:00
Ralf Jung 1d87efc1da replace another Option<Span> by DUMMY_SP 2024-05-07 14:52:42 +02:00
bors d71b3f486a Auto merge of #124813 - maurer:llvm-aarch64-fn32, r=nikic
Adjust 64-bit ARM data layouts for LLVM update

LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid C++ accidentally underaligning functions when trying to comply with member function ABIs.

This should only affect Rust in cases where we had a similar bug (I don't believe we have one), but our data layout must match to generate code.

As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32` gets voided from the data layout.

See llvm/llvm-project#90415

`@rustbot` label: +llvm-main
cc `@krasimirgg`
r? `@durin42`
2024-05-07 03:46:03 +00:00
Lin Yihai f9bb5df5a0 narrow down visibilities in `rustc_parse::lexer` 2024-05-07 11:02:28 +08:00
Matthias Krüger 284b5530b8
Rollup merge of #124809 - lcnr:prepopulate-opaques, r=compiler-errors
borrowck: prepopulate opaque storage more eagerly

otherwise we ICE due to ambiguity when normalizing while computing implied bounds.

r? ``@compiler-errors``
2024-05-06 21:46:06 +02:00
Matthias Krüger f76c8f7f77
Rollup merge of #124759 - compiler-errors:impl-args, r=lcnr
Record impl args in the proof tree in new solver

Rather than rematching them during select.

Also use `ImplSource::Param` instead of `ImplSource::Builtin` for alias-bound candidates, so we don't ICE in `Instance::resolve`.

r? lcnr
2024-05-06 21:46:05 +02:00
Michael Goulet e34723997a Use correct ImplSource for alias bounds 2024-05-06 14:38:35 -04:00
Michael Goulet 207b4b8e88 Record impl args in the InsepctCandiate rather than rematching during select 2024-05-06 14:17:22 -04:00
Matthew Maurer 4d397d33da Adjust 64-bit ARM data layouts for LLVM update
LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid
C++ accidentally underaligning functions when trying to comply with
member function ABIs.

This should only affect Rust in cases where we had a similar bug (I
don't believe we have one), but our data layout must match to generate
code.

As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32`
gets voided from the data layout.

See llvm/llvm-project#90415
2024-05-06 16:53:17 +00:00
Matthias Krüger ad73b1623d
Rollup merge of #124808 - compiler-errors:super, r=lcnr
Use `super_fold` in `RegionsToStatic` visitor

so as to avoid an infinite stack cycle

fixes #124805
r? lcnr
2024-05-06 18:50:36 +02:00
Matthias Krüger 43de8225dc
Rollup merge of #124771 - compiler-errors:cand-has-failing-wc, r=lcnr
Don't consider candidates with no failing where clauses when refining obligation causes in new solver

Improves error messages when we have param-env candidates that don't deeply unify (i.e. after alias-bounds).

r? lcnr
2024-05-06 18:50:35 +02:00
Matthias Krüger 2d557ba9f4
Rollup merge of #124724 - compiler-errors:prefer-lower, r=lcnr
Prefer lower vtable candidates in select in new solver

Also, adjust the select visitor to only winnow when the *parent* goal is `Certainty::Yes`. This means that we won't winnow in cases when we have any ambiguous inference guidance from two candidates.

r? lcnr
2024-05-06 18:50:35 +02:00
Michael Goulet 116f95bb46 Use super_fold in RegionsToStatic visitor 2024-05-06 12:22:15 -04:00
lcnr 5714c1f364 switch new solver to directly inject opaque types 2024-05-06 16:19:32 +00:00
lcnr 24ee32cf70 borrowck: more eagerly prepopulate opaques 2024-05-06 16:04:57 +00:00