about summary refs log tree commit diff
path: root/compiler/rustc_hir
AgeCommit message (Collapse)AuthorLines
2024-03-29Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstriebbors-0/+19
Codegen const panic messages as function calls This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting shared library (see [perf]). A sample improvement from nightly: ``` leaq str.0(%rip), %rdi leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdx movl $25, %esi callq *_ZN4core9panicking5panic17h17cabb89c5bcc999E@GOTPCREL(%rip) ``` to this PR: ``` leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdi callq *_RNvNtNtCsduqIKoij8JB_4core9panicking11panic_const23panic_const_div_by_zero@GOTPCREL(%rip) ``` [perf]: https://perf.rust-lang.org/compare.html?start=a7e4de13c1785819f4d61da41f6704ed69d5f203&end=64fbb4f0b2d621ff46d559d1e9f5ad89a8d7789b&stat=instructions:u
2024-03-27Implement `mut ref`/`mut ref mut`Jules Bertholet-2/+2
2024-03-27Use a `dyn Debug` trait object instead of a closure.Oli Scherer-2/+2
Simplifies the API a bit.
2024-03-26Rollup merge of #122835 - compiler-errors:deref-pure, r=NadrierilMatthias Krüger-0/+1
Require `DerefMut` and `DerefPure` on `deref!()` patterns when appropriate Waiting on the deref pattern syntax pr to merge r? nadrieril
2024-03-26Rollup merge of #122120 - fmease:sugg-assoc-ty-bound-on-eq-bound, ↵Matthias Krüger-14/+8
r=compiler-errors Suggest associated type bounds on problematic associated equality bounds Fixes #105056. TL;DR: Suggest `Trait<Ty: Bound>` on `Trait<Ty = Bound>` in Rust >=2021. ~~Blocked on #122055 (stabilization of `associated_type_bounds`), I'd say.~~ (merged)
2024-03-25Require DerefPure for patternsMichael Goulet-0/+1
2024-03-23Add+Use `mir::BinOp::Cmp`Scott McMurray-0/+1
2024-03-22Update docs of hir::TypeBindingLeón Orell Valerian Liehr-14/+8
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-3/+3
2024-03-22Rename `hir::Node::expect_local` into `hir::Node::expect_let_stmt`Guillaume Gomez-1/+1
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-9/+9
2024-03-22Codegen const panic messages as function callsMark Rousskov-0/+19
This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary.
2024-03-22Auto merge of #122869 - matthiaskrgr:rollup-0navj4l, r=matthiaskrgrbors-0/+3
Rollup of 9 pull requests Successful merges: - #121619 (Experimental feature postfix match) - #122370 (Gracefully handle `AnonConst` in `diagnostic_hir_wf_check()`) - #122537 (interpret/allocation: fix aliasing issue in interpreter and refactor getters a bit) - #122542 (coverage: Clean up marker statements that aren't needed later) - #122800 (Add `NonNull::<[T]>::is_empty`.) - #122820 (Stop using `<DefId as Ord>` in various diagnostic situations) - #122847 (Suggest `RUST_MIN_STACK` workaround on overflow) - #122855 (Fix Itanium mangling usizes) - #122863 (add more ice tests ) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-22Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkovMatthias Krüger-0/+3
Experimental feature postfix match This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, #121618). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement. It is entirely implemented in the parser, so it should be relatively easy to remove if needed. This PR is split in to 5 commits to ease review. 1. The implementation of the feature & gating. 2. Add a MatchKind field, fix uses, fix pretty. 3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix. 4. Add new MatchSource to HIR for Clippy & other HIR consumers
2024-03-22Update (doc) commentsLeón Orell Valerian Liehr-6/+2
Several (doc) comments were super outdated or didn't provide enough context. Some doc comments shoved everything in a single paragraph without respecting the fact that the first paragraph should be a single sentence because rustdoc treats these as item descriptions / synopses on module pages.
2024-03-22Rollup merge of #122829 - ShoyuVanilla:gen-block-impl-fused-iter, ↵Matthias Krüger-0/+1
r=compiler-errors Implement `FusedIterator` for `gen` block cc #117078
2024-03-22Implement `FusedIterator` for `gen` blockShoyu Vanilla-0/+1
2024-03-21Implement macro-based deref!() syntax for deref patternsMichael Goulet-3/+8
Stop using `box PAT` syntax for deref patterns, as it's misleading and also causes their semantics being tangled up.
2024-03-21Auto merge of #121587 - ShoyuVanilla:fix-issue-121267, r=TaKO8Kibors-2/+16
Fix bad span for explicit lifetime suggestions Fixes #121267 Current explicit lifetime suggestions are not showing correct spans for some lifetimes - e.g. elided lifetime generic parameters; This should be done correctly regarding elided lifetime kind like the following code https://github.com/rust-lang/rust/blob/43fdd4916d19f4004e23d422b5547637ad67ab21/compiler/rustc_resolve/src/late/diagnostics.rs#L3015-L3044
2024-03-21Fix bad span for explicit lifetime suggestionShoyu Vanilla-2/+16
Move verbose logic to a function Minor renaming
2024-03-20Rollup merge of #122776 - GuillaumeGomez:rename-hir-let, r=oli-obkJacob Pratt-3/+3
Rename `hir::Let` into `hir::LetExpr` As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). r? `````@Zalathar`````
2024-03-20Rename `hir::Let` into `hir::LetExpr`Guillaume Gomez-3/+3
2024-03-20step cfgsMark Rousskov-1/+0
2024-03-19Rollup merge of #122719 - oli-obk:nested_static_feed_hir, r=fee1-deadMatthias Krüger-13/+9
Ensure nested statics have a HIR node to prevent various queries from ICEing fixes https://github.com/rust-lang/miri/issues/3389
2024-03-19Auto merge of #122021 - oli-obk:delangitemification, r=compiler-errorsbors-14/+21
Use hir::Node helper methods instead of repeating the same impl multiple times I wanted to do something entirely different and stumbled upon a bunch of cleanups
2024-03-19The AssocOpaqueTy HIR node is not actually needed to differentiate from ↵Oli Scherer-13/+9
other hir nodes that were fed
2024-03-18Deduplicate `associated_body` and `body_id`Oli Scherer-14/+21
They match on almost the same patterns, which is fishy. Also turn `associated_body` into a method and do some cleanups nearby the call sites
2024-03-18Add missing `try_visit` calls in visitors.Jason Newcomb-1/+1
2024-03-17Detect when move of `!Copy` value occurs within `loop` and should likely not ↵Esteban Küber-1/+1
be cloned When encountering a move error on a value within a loop of any kind, identify if the moved value belongs to a call expression that should not be cloned and avoid the semantically incorrect suggestion. Also try to suggest moving the call expression outside of the loop instead. ``` error[E0382]: use of moved value: `vec` --> $DIR/recreating-value-in-loop-condition.rs:6:33 | LL | let vec = vec!["one", "two", "three"]; | --- move occurs because `vec` has type `Vec<&str>`, which does not implement the `Copy` trait LL | while let Some(item) = iter(vec).next() { | ----------------------------^^^-------- | | | | | value moved here, in previous iteration of loop | inside of this loop | note: consider changing this parameter type in function `iter` to borrow instead if owning the value isn't necessary --> $DIR/recreating-value-in-loop-condition.rs:1:17 | LL | fn iter<T>(vec: Vec<T>) -> impl Iterator<Item = T> { | ---- ^^^^^^ this parameter takes ownership of the value | | | in this function help: consider moving the expression out of the loop so it is only moved once | LL ~ let mut value = iter(vec); LL ~ while let Some(item) = value.next() { | ``` We use the presence of a `break` in the loop that would be affected by the moved value as a heuristic for "shouldn't be cloned". Fix #121466.
2024-03-16Auto merge of #121926 - tgross35:f16-f128-step3-feature-gate, ↵bors-6/+5
r=compiler-errors,petrochenkov `f16` and `f128` step 3: compiler support & feature gate Continuation of https://github.com/rust-lang/rust/pull/121841, another portion of https://github.com/rust-lang/rust/pull/114607 This PR exposes the new types to the world and adds a feature gate. Marking this as a draft because I need some feedback on where I did the feature gate check. It also does not yet catch type via suffixed literals (so the feature gate test will fail, probably some others too because I haven't belssed). If there is a better place to check all types after resolution, I can do that. If not, I figure maybe I can add a second gate location in AST when it checks numeric suffixes. Unfortunately I still don't think there is much testing to be done for correctness (codegen tests or parsed value checks) until we have basic library support. I think that will be the next step. Tracking issue: https://github.com/rust-lang/rust/issues/116909 r? `@compiler-errors` cc `@Nilstrieb` `@rustbot` label +F-f16_and_f128
2024-03-14Rollup merge of #122487 - GuillaumeGomez:rename-stmtkind-local, r=oli-obkMatthias Krüger-2/+2
Rename `StmtKind::Local` variant into `StmtKind::Let` It comes from this [discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). Starting point was: > I often end up looking at [ExprKind::Let](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.Let) instead of Local because of the name. I think renaming it (both the `ExprKind` variant and the Let struct) to `LetPattern` or LetPat could improve the situation as I'm not sure I'm not the only one encountering this issue. And then it evolved into: > It's already `Expr::Let` instead of `StmtKind::Local`. Counterproposal: rename `StmtKind::Local` to `StmtKind::Let`. The goal here is to clear this confusion. r? `@oli-obk`
2024-03-14Auto merge of #120943 - petrochenkov:somehir3, r=oli-obkbors-1/+13
Create some minimal HIR for associated opaque types `LocalDefId`s for opaque types in traits and impls are created after AST -> HIR lowering, so they don't have corresponding HIR and return their various properties through fed queries. In this PR I also feed some core HIR-related queries for these `LocalDefId`s (which happen to be HIR owners). As a result all `LocalDefId`s now have corresponding `HirId`s and HIR nodes, and "optional" methods like `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id` can be removed. Follow up to https://github.com/rust-lang/rust/pull/120206.
2024-03-14Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`Guillaume Gomez-2/+2
2024-03-14Enable `f16` and `f128` in HIRTrevor Gross-6/+5
2024-03-13Rollup merge of #122430 - GuillaumeGomez:link-to-local, r=TaKO8KiMatthias Krüger-4/+4
Generate link to `Local` in `hir::Let` documentation This PR adds a missing link generation to `Local` type.
2024-03-13Create some minimal HIR for associated opaque typesVadim Petrochenkov-1/+13
2024-03-13Generate link to `Local` in `hir::Let` documentationGuillaume Gomez-4/+4
2024-03-12Some comment nitsOli Scherer-1/+1
2024-03-12s/mt/mutability/Oli Scherer-1/+1
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-0/+3
2024-03-12Add `nested` bool to `DefKind::Static`.Oli Scherer-0/+2
Will be used in the next commit
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-8/+11
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-1/+1
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-08Rollup merge of #122103 - compiler-errors:taits-capture-everything, r=oli-obkMatthias Krüger-0/+2
Make TAITs and ATPITs capture late-bound lifetimes in scope This generalizes the behavior that RPITs have, where they duplicate their in-scope lifetimes so that they will always *reify* late-bound lifetimes that they capture. This allows TAITs and ATPITs to properly error when they capture in-scope late-bound lifetimes. r? `@oli-obk` cc `@aliemjay` Fixes #122093 and therefore https://github.com/rust-lang/rust/pull/120700#issuecomment-1981213868
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-1/+14
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-08Make TAITs capture all higher-ranked lifetimes in scopeMichael Goulet-0/+2
2024-03-06Add postfix match MatchSource to HIRRoss Smyth-0/+3
2024-03-06Auto merge of #122045 - matthiaskrgr:rollup-5l3vpn7, r=matthiaskrgrbors-0/+2
Rollup of 9 pull requests Successful merges: - #121065 (Add basic i18n guidance for `Display`) - #121744 (Stop using Bubble in coherence and instead emulate it with an intercrate check) - #121829 (Dummy tweaks (attempt 2)) - #121857 (Implement async closure signature deduction) - #121894 (const_eval_select: make it safe but be careful with what we expose on stable for now) - #122014 (Change some attributes to only_local.) - #122016 (will_wake tests fail on Miri and that is expected) - #122018 (only set noalias on Box with the global allocator) - #122028 (Remove some dead code) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Move visitor utils to `rustc_ast_ir`Jason Newcomb-2/+1
2024-03-05only set noalias on Box with the global allocatorRalf Jung-0/+2