about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-02-28Remove `rustc_transmute`'s dependence on `rustc_macros`.Nicholas Nethercote-4/+1
2025-02-28Remove `rustc_transmute`'s dependence on `rustc_infer`.Nicholas Nethercote-12/+9
`TransmuteTypeEnv` only needs a `TyCtxt`, not an `InferCtxt`.
2025-02-28Auto merge of #137710 - matthiaskrgr:rollup-3vmxxu9, r=matthiaskrgrbors-473/+535
Rollup of 8 pull requests Successful merges: - #136542 ([`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing) - #136579 (Fix UB in ThinVec::flat_map_in_place) - #136688 (require trait impls to have matching const stabilities as the traits) - #136846 (Make `AssocOp` more like `ExprKind`) - #137304 (add `IntoBounds::intersect` and `RangeBounds::is_empty`) - #137455 (Reuse machinery from `tail_expr_drop_order` for `if_let_rescope`) - #137480 (Return unexpected termination error instead of panicing in `Thread::join`) - #137694 (Spruce up `AttributeKind` docs) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-28Tweak incorrect ABI suggestionEsteban Küber-4/+5
Provide a better suggestion message, and make the suggestion verbose. ``` error[E0703]: invalid ABI: found `riscv-interrupt` --> $DIR/riscv-discoverability-guidance.rs:17:8 | LL | extern "riscv-interrupt" fn isr() {} | ^^^^^^^^^^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions help: there's a similarly named valid ABI `"riscv-interrupt-m"` | LL | extern "riscv-interrupt-m" fn isr() {} | ++ ```
2025-02-28Fix sized constraint for unsafe binderMichael Goulet-3/+6
2025-02-28fix: fix overflowing hex wrong suggestion11happy-1/+1
Signed-off-by: 11happy <soni5happy@gmail.com> rebase Signed-off-by: 11happy <soni5happy@gmail.com> fix: rebless Signed-off-by: 11happy <soni5happy@gmail.com>
2025-02-28Use mk_ty_from_kind a bit less, clean up lifetime handling in borrowckMichael Goulet-37/+21
2025-02-28Auto merge of #137669 - DianQK:fn-atts-virtual, r=saethlinbors-38/+41
Don't infer attributes of virtual calls based on the function body Fixes (after backport) #137646. Since we don't know the exact implementation of the virtual call, it might write to parameters, we can't infer the readonly attribute.
2025-02-27Fix method name in `TyCtxt::hir_crate()` documentationSamuel Tardieu-3/+3
2025-02-28Optimize `Trace`.Nicholas Nethercote-36/+51
`Trace::FromOutlivesConstraint` contains an `OutlivesConstraint`, which is 72 bytes. Lots of these are created but never used. This commit splits `Trace::FromOutlivesConstraint` into three new variants: `FromVanilla`, `FromStatic`, `FromMember`. Each of these contains just enough data to construct an `OutlivesConstraint`, if necessary. This reduces the size of `Trace` from 72 bytes to 16 bytes. All this avoids some memory traffic.
2025-02-28Split the `Edges` iterator.Nicholas Nethercote-61/+85
The `Edges` iterator returns `OutlivesConstraint` elements, which are 72 bytes. This is big enough to affect performance. Return `&OutlivesConstraint` would be better. However, each `Edges` iterator is really one of two different iterators. The "from graph" case does a graph traversal and could return `&OutlivesConstraint`. But the "from static" case just does a `0..n` iteration and constructs a new `OutlivesConstraint` from that, so it can't return a reference. This commit splits `Edges into `EdgesFromGraph` and `EdgesFromStatic`, which allows them to have different return types. This is a perf win for the `wg-grammar` benchmark.
2025-02-28Remove `NtPath`.Nicholas Nethercote-69/+44
2025-02-28Remove `NtMeta`.Nicholas Nethercote-52/+55
Note: there was an existing code path involving `Interpolated` in `MetaItem::from_tokens` that was dead. This commit transfers that to the new form, but puts an `unreachable!` call inside it.
2025-02-28Remove `NtPat`.Nicholas Nethercote-85/+67
The one notable test change is `tests/ui/macros/trace_faulty_macros.rs`. This commit removes the complicated `Interpolated` handling in `expected_expression_found` that results in a longer error message. But I think the new, shorter message is actually an improvement. The original complaint was in #71039, when the error message started with "error: expected expression, found `1 + 1`". That was confusing because `1 + 1` is an expression. Other than that, the reporter said "the whole error message is not too bad if you ignore the first line". Subsequently, extra complexity and wording was added to the error message. But I don't think the extra wording actually helps all that much. In particular, it still says of the `1+1` that "this is expected to be expression". This repeats the problem from the original complaint! This commit removes the extra complexity, reverting to a simpler error message. This is primarily because the traversal is a pain without `Interpolated` tokens. Nonetheless, I think the error message is *improved*. It now starts with "expected expression, found `pat` metavariable", which is much clearer and the real problem. It also doesn't say anything specific about `1+1`, which is good, because the `1+1` isn't really relevant to the error -- it's the `$e:pat` that's important.
2025-02-28Adjust `ConstraintGraphDirection` methods.Nicholas Nethercote-12/+12
This facilitates the next commit.
2025-02-27Defer repeat expr `Copy` checkBoxy-15/+85
2025-02-27Add note to Thir struct about necessity of Clone deriveNiels Saurer-0/+3
2025-02-27Revert "Derive `Clone` on fewer THIR types."Niels Saurer-22/+22
This reverts commit f0b6d660c9c13ab7b19da9e12aeb4dcab45e544b.
2025-02-28Unconditionally lower match arm even if it's unneeded for never pattern in matchMu001999-2/+5
2025-02-27Stop using `hash_raw_entry` in `CodegenCx::const_str`Josh Stone-31/+25
That unstable feature completed fcp-close, so the compiler needs to be migrated away to allow its removal. In this case, `cg_llvm` and `cg_gcc` were using raw entries to optimize their `const_str_cache` lookup and insertion. We can change that to separate `get` and (on miss) `insert` calls, so we still have the fast path avoiding string allocation when the cache hits.
2025-02-27Update E0133 docs for 2024 editionEric Huss-1/+2
2025-02-27Changed the dependency graph to start preallocated with 128 capacityMichał Kostrubiec-2/+1
2025-02-27switch #[cfg(not(llvm_enzyme))] to cfg!(llvm_enzyme)Vayun Biyani-26/+4
2025-02-27Delete tuple unsizingAlice Ryhl-128/+6
2025-02-27Clean up TypeckResults::extract_binding_modeMaja Kądziołka-43/+44
- Remove the `Option` from the result type, as `None` is never returned. - Document the difference from the `BindingMode` in `PatKind::Binding`.
2025-02-27Rollup merge of #137694 - aDotInTheVoid:aDotInTheVoid-patch-1, r=jdonszelmannMatthias Krüger-5/+8
Spruce up `AttributeKind` docs - Remove dead link to `rustc_attr` crate. - Add link to `rustc_attr_parsing` crate. - Split up first paragraph so it looks better at crate-level summary r? `@jdonszelmann`
2025-02-27Rollup merge of #137455 - compiler-errors:drop-lint-dtor, r=oli-obkMatthias Krüger-186/+244
Reuse machinery from `tail_expr_drop_order` for `if_let_rescope` Namely, it defines its own `extract_component_with_significant_dtor` which is a bit more accurate than `Ty::has_significant_drop`, since it has a hard-coded list of types from the ecosystem which are opted out of the lint.[^a] Also, since we extract the dtors themselves, adopt the same *label* we use in `tail_expr_drop_order` to point out the destructor impl. This makes it much clear what's actually being dropped, so it should be clearer to know when it's a false positive. This conflicts with #137444, but I will rebase whichever lands first. [^a]: Side-note, it's kinda a shame that now there are two functions that presumably do the same thing. But this isn't my circus, nor are these my monkeys.
2025-02-27Rollup merge of #136846 - nnethercote:make-AssocOp-more-like-ExprKind, ↵Matthias Krüger-251/+162
r=spastorino Make `AssocOp` more like `ExprKind` This is step 1 of [MCP 831](https://github.com/rust-lang/compiler-team/issues/831). r? ``@estebank``
2025-02-27Rollup merge of #136688 - fee1-dead-contrib:push-nppsusmpokqo, r=compiler-errorsMatthias Krüger-14/+96
require trait impls to have matching const stabilities as the traits This resolves https://github.com/rust-lang/project-const-traits/issues/5 by implementing the suggested solution in the given thread r? ``@RalfJung`` cc ``@rust-lang/project-const-traits``
2025-02-27Rollup merge of #136579 - bjorn3:fix_thinvec_ext_ub, r=BoxyUwUMatthias Krüger-17/+25
Fix UB in ThinVec::flat_map_in_place `thin_vec.as_ptr()` goes through the `Deref` impl of `ThinVec`, which will not allow access to any memory as we did call `set_len(0)` first. Found in the process of investigating https://github.com/rust-lang/rust/issues/135870.
2025-02-27Optimize empty provenance range checks.Nicholas Nethercote-10/+60
Currently it gets the pointers in the range and checks if the result is empty, but it can be done faster if you combine those two steps.
2025-02-27Don't infer unwinding of virtual calls based on the function attributesDianQK-6/+13
2025-02-27Don't infer attributes of virtual calls based on the function bodyDianQK-36/+32
2025-02-27require trait impls to have matching const stabilities as the traitsDeadbeef-14/+96
2025-02-26Fill out links_from_incr_cache in cg_clifBen Kimock-8/+10
2025-02-27Always inline `query_get_at`.Nicholas Nethercote-1/+1
2025-02-27Rename `AssocOp::As` as `AssocOp::Cast`.Nicholas Nethercote-9/+9
To match `ExprKind::Cast`, and because a semantic name makes more sense here than a syntactic name.
2025-02-27Replace `AssocOp::DotDot{,Eq}` with `AssocOp::Range`.Nicholas Nethercote-21/+24
It makes `AssocOp` more similar to `ExprKind` and makes things a little simpler. And the semantic names make more sense here than the syntactic names.
2025-02-27Introduce `AssocOp::Binary`.Nicholas Nethercote-213/+124
It mirrors `ExprKind::Binary`, and contains a `BinOpKind`. This makes `AssocOp` more like `ExprKind`. Note that the variants removed from `AssocOp` are all named differently to `BinOpToken`, e.g. `Multiply` instead of `Mul`, so that's an inconsistency removed. The commit adds `precedence` and `fixity` methods to `BinOpKind`, and calls them from the corresponding methods in `AssocOp`. This avoids the need to create an `AssocOp` from a `BinOpKind` in a bunch of places, and `AssocOp::from_ast_binop` is removed. `AssocOp::to_ast_binop` is also no longer needed. Overall things are shorter and nicer.
2025-02-27In `AssocOp::AssignOp`, use `BinOpKind` instead of `BinOpToken`Nicholas Nethercote-22/+19
`AssocOp::AssignOp` contains a `BinOpToken`. `ExprKind::AssignOp` contains a `BinOpKind`. Given that `AssocOp` is basically a cut-down version of `ExprKind`, it makes sense to make `AssocOp` more like `ExprKind`. Especially given that `AssocOp` and `BinOpKind` use semantic operation names (e.g. `Mul`, `Div`), but `BinOpToken` uses syntactic names (e.g. `Star`, `Slash`). This results in more concise code, and removes the need for various conversions. (Note that the removed functions `hirbinop2assignop` and `astbinop2assignop` are semantically identical, because `hir::BinOp` is just a synonum for `ast::BinOp`!) The only downside to this is that it allows the possibility of some nonsensical combinations, such as `AssocOp::AssignOp(BinOpKind::Lt)`. But `ExprKind::AssignOp` already has that problem. The problem can be fixed for both types in the future with some effort, by introducing an `AssignOpKind` type.
2025-02-26Spruce up `AttributeKind` docsAlona Enraght-Moony-5/+8
- Remove dead link to `rustc_attr` crate. - Add link to `rustc_attr_parsing` crate. - Split up first paragraph so it looks better at crate-level summary
2025-02-26Remove `ParamEnv::without_caller_bounds`Boxy-7/+1
2025-02-26Handle asm const similar to inline constGary Guo-69/+96
2025-02-26Print out destructorMichael Goulet-186/+244
2025-02-26Support raw-dylib link kind on ELFNoratrieb-200/+560
raw-dylib is a link kind that allows rustc to link against a library without having any library files present. This currently only exists on Windows. rustc will take all the symbols from raw-dylib link blocks and put them in an import library, where they can then be resolved by the linker. While import libraries don't exist on ELF, it would still be convenient to have this same functionality. Not having the libraries present at build-time can be convenient for several reasons, especially cross-compilation. With raw-dylib, code linking against a library can be cross-compiled without needing to have these libraries available on the build machine. If the libc crate makes use of this, it would allow cross-compilation without having any libc available on the build machine. This is not yet possible with this implementation, at least against libc's like glibc that use symbol versioning. The raw-dylib kind could be extended with support for symbol versioning in the future. This implementation is very experimental and I have not tested it very well. I have tested it for a toy example and the lz4-sys crate, where it was able to successfully link a binary despite not having a corresponding library at build-time.
2025-02-26Rollup merge of #137671 - meithecatte:discoverable-dump-mir, r=NadrierilLeón Orell Valerian Liehr-0/+1
Make -Z unpretty=mir suggest -Z dump-mir as well for discoverability While debugging something else, I got quite annoyed with `-Z unpretty=mir` showing me post-processed MIR instead of the one just after it is built. I ended up asking on Zulip and got pointed to `-Z dump-mir`. While this feature is documented in the rustc dev guide, I think it'd be good if the possibility of making use of it was staring you in the face while you need it.
2025-02-26Rollup merge of #137635 - compiler-errors:constrain-unstable, r=SparrowLiiLeón Orell Valerian Liehr-1/+4
Don't suggest constraining unstable associated types Fixes #137624 This could be made a bit more specific, considering the local crate's stability or nightly status or something, but I think in general we should not be suggesting associated type bounds on unstable associated items.
2025-02-26Rollup merge of #137631 - TaKO8Ki:issue-137508, r=compiler-errorsLeón Orell Valerian Liehr-1/+5
Avoid collecting associated types for undefined trait Fixes #137508 Fixes #137554
2025-02-26Rollup merge of #137201 - estebank:structured-errors-long-ty, r=oli-obkLeón Orell Valerian Liehr-216/+312
Teach structured errors to display short `Ty<'_>` Make it so that in every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to. ``` error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)`` --> long.rs:7:5 | 6 | fn foo(x: D) { //~ `x` has type `(... | - `x` has type `((..., ..., ..., ...), ..., ..., ...)` 7 | x(); //~ ERROR expected function, found `(... | ^-- | | | call expression requires function | = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt' = note: consider using `--verbose` to print the full type name to the console ``` Follow up to and response to the comments on #136898. r? ``@oli-obk``
2025-02-26Use bound_coroutine_witnesses in old solverMichael Goulet-81/+27