about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-05-10Use fewer origins when creating type variables.Nicholas Nethercote-306/+118
`InferCtxt::next_{ty,const}_var*` all take an origin, but the `param_def_id` is almost always `None`. This commit changes them to just take a `Span` and build the origin within the method, and adds new methods for the rare cases where `param_def_id` might not be `None`. This avoids a lot of tedious origin building. Specifically: - next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of `TypeVariableOrigin` - next_ty_var_with_origin: added - next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin - next_const_var_with_origin: added - next_region_var, next_region_var_in_universe: these are unchanged, still take RegionVariableOrigin The API inconsistency (ty/const vs region) seems worth it for the large conciseness improvements.
2024-05-10Inline and remove unused methods.Nicholas Nethercote-24/+13
`InferCtxt::next_{ty,const,int,float}_var_id` each have a single call site, in `InferCtt::next_{ty,const,int,float}_var` respectively. The only remaining method that creates a var_id is `InferCtxt::next_ty_var_id_in_universe`, which has one use outside the crate.
2024-05-08Rollup merge of #124909 - compiler-errors:struct-tail-leftovers, ↵Matthias Krüger-7/+8
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-08Rollup merge of #124892 - jfgoog:update-cc, r=workingjubileeMatthias Krüger-2/+2
Update cc crate to v1.0.97
2024-05-08Rollup merge of #124876 - nnethercote:rm-use-crate-rustc_foo, r=compiler-errorsMatthias Krüger-13/+8
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-08Rollup merge of #124869 - compiler-errors:keyword, r=NilstriebMatthias Krüger-1/+10
Make sure we don't deny macro vars w keyword names `$async:ident`, etc are all valid. Fixes #124862
2024-05-08Rollup merge of #124587 - reitermarkus:use-generic-nonzero, r=dtolnayMatthias Krüger-31/+15
Generic `NonZero` post-stabilization changes. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? ``@dtolnay``
2024-05-08Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=NilstriebMatthias Krüger-50/+73
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-08Handle normalization failure in `struct_tail_erasing_lifetimes`Gurinder Singh-7/+8
Fixes an ICE that occurred when the struct in question has an error
2024-05-08Use generic `NonZero`.Markus Reiter-8/+9
2024-05-08Simplify suggestion.Markus Reiter-23/+6
2024-05-08Update cc crate to v1.0.97James Farrell-2/+2
2024-05-08Rollup merge of #124761 - Urgau:ref-casting_bigger_slice_index, r=jieyouxuMatthias Krüger-0/+7
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-08Rollup merge of #124548 - gurry:113272-ice-failed-to-normalize, ↵Matthias Krüger-1/+16
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-08Auto merge of #124858 - alexcrichton:some-wasi-changes, r=michaelwoeristerbors-3/+14
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-08Simplify `use crate::rustc_foo::bar` occurrences.Nicholas Nethercote-13/+8
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-08Auto merge of #124779 - workingjubilee:debug-formatting-my-beloved, ↵bors-10/+55
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-07compiler: add `Parser::debug_lookahead`Jubilee Young-0/+42
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-07compiler: derive Debug in parserJubilee Young-9/+12
It's annoying to debug the parser if you have to stop every five seconds to add a Debug impl.
2024-05-08Auto merge of #124683 - estebank:issue-124651, r=compiler-errorsbors-6/+8
Do not ICE on foreign malformed `diagnostic::on_unimplemented` Fix #124651.
2024-05-07Make sure we don't deny macro vars w keyword namesMichael Goulet-1/+10
2024-05-07Auto merge of #124223 - Zalathar:conditional-let, r=compiler-errorsbors-3/+30
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-07rustc: Change wasm32-wasip2 to PIC-by-defaultAlex Crichton-1/+6
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-07Auto merge of #124219 - gurry:122989-ice-unexpected-anon-const, ↵bors-6/+8
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-07Auto merge of #124849 - matthiaskrgr:rollup-68humsk, r=matthiaskrgrbors-45/+74
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-07Rollup merge of #124846 - compiler-errors:const-eval, r=lcnrMatthias Krüger-3/+3
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-07Rollup merge of #124842 - RalfJung:option-span, r=compiler-errorsMatthias Krüger-10/+10
replace another Option<Span> by DUMMY_SP This was missed in https://github.com/rust-lang/rust/pull/122480.
2024-05-07Rollup merge of #124832 - linyihai:visibility-of-lexer, r=fmeaseMatthias Krüger-6/+6
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-07Rollup merge of #124827 - lcnr:generalize-incomplete, r=compiler-errorsMatthias Krüger-26/+55
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-07generalize hr alias: avoid unconstrainable infer varslcnr-26/+55
2024-05-07Don't ICE when we cannot eval a const to a valtree in the new solverMichael Goulet-3/+3
2024-05-07Auto merge of #123332 - Nadrieril:testkind-never, r=matthewjasperbors-3/+84
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-07replace another Option<Span> by DUMMY_SPRalf Jung-10/+10
2024-05-07Auto merge of #124813 - maurer:llvm-aarch64-fn32, r=nikicbors-40/+49
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-07narrow down visibilities in `rustc_parse::lexer`Lin Yihai-6/+6
2024-05-06Rollup merge of #124809 - lcnr:prepopulate-opaques, r=compiler-errorsMatthias Krüger-119/+79
borrowck: prepopulate opaque storage more eagerly otherwise we ICE due to ambiguity when normalizing while computing implied bounds. r? ``@compiler-errors``
2024-05-06Rollup merge of #124759 - compiler-errors:impl-args, r=lcnrMatthias Krüger-65/+98
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-06Use correct ImplSource for alias boundsMichael Goulet-2/+1
2024-05-06Record impl args in the InsepctCandiate rather than rematching during selectMichael Goulet-65/+99
2024-05-06Adjust 64-bit ARM data layouts for LLVM updateMatthew Maurer-40/+49
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-06Rollup merge of #124808 - compiler-errors:super, r=lcnrMatthias Krüger-1/+1
Use `super_fold` in `RegionsToStatic` visitor so as to avoid an infinite stack cycle fixes #124805 r? lcnr
2024-05-06Rollup merge of #124771 - compiler-errors:cand-has-failing-wc, r=lcnrMatthias Krüger-6/+42
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-06Rollup merge of #124724 - compiler-errors:prefer-lower, r=lcnrMatthias Krüger-5/+13
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-06Use super_fold in RegionsToStatic visitorMichael Goulet-1/+1
2024-05-06switch new solver to directly inject opaque typeslcnr-9/+6
2024-05-06borrowck: more eagerly prepopulate opaqueslcnr-70/+42
2024-05-06Don't consider candidates with no failing where clausesMichael Goulet-6/+42
2024-05-06BorrowckInferCtxt: infcx by valuelcnr-40/+31
2024-05-06Prefer lower vtable candidates in select in new solverMichael Goulet-5/+13
2024-05-06Auto merge of #124679 - Urgau:check-cfg-structured-cli-errors, r=nnethercotebors-11/+43
Improve check-cfg CLI errors with more structured diagnostics This PR improve check-cfg CLI errors with more structured diagnostics. In particular it now shows the statement where the error occurred, what kind lit it is, as well as pointing users to the doc for more details. `@rustbot` label +F-check-cfg