about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/loops.rs
AgeCommit message (Collapse)AuthorLines
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-1/+1
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-2/+2
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-13Remove `sess` from `CheckLoopVisitor`.Nicholas Nethercote-17/+11
2024-09-13Remove unnecessary lifetime from `CheckLoopVisitor`.Nicholas Nethercote-6/+6
2024-08-06Don't Suggest Labeling `const` and `unsafe` BlocksVeera-14/+26
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-3/+4
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-4/+3
2024-05-22For OutsideLoop we should not suggest add 'block label in if block, or we ↵surechen-24/+148
wiil get another err: block label not supported here. fixes #123261
2024-05-08Fix Error Messages for `break` Inside CoroutinesVeera-9/+23
Previously, `break` inside `gen` blocks and functions were incorrectly identified to be enclosed by a closure. This PR fixes it by displaying an appropriate error message for async blocks, async closures, async functions, gen blocks, gen closures, gen functions, async gen blocks, async gen closures and async gen functions. Note: gen closure and async gen closure are not supported by the compiler yet but I have added an error message here assuming that they might be implemented in the future. Also, fixes grammar in a few places by replacing `inside of a $coroutine` with `inside a $coroutine`.
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-02-07hir: Remove `fn opt_hir_id` and `fn opt_span`Vadim Petrochenkov-2/+2
2023-12-26Auto merge of #119258 - compiler-errors:closure-kind, r=eholkbors-10/+9
Make closures carry their own ClosureKind Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant. This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine". r? eholk
2023-12-25Only regular coroutines have movabilityMichael Goulet-7/+4
2023-12-25Make closures carry their own ClosureKind, rather than deducing what it is ↵Michael Goulet-10/+12
from movability
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-9/+9
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-8/+7
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-6/+6
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-10-16tweak pass description and fix lint fail post-rebaseArthur Lafrance-1/+1
2023-10-09Account for macrosEsteban Küber-1/+1
2023-10-09Suggest labeling block if `break` is in bare blockEsteban Küber-8/+47
Fix #103982.
2023-08-14Use `{Local}ModDefId` in many queriesNilstrieb-2/+2
2023-06-02Separate AnonConst from ConstBlock in HIR.Camille GILLOT-3/+7
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2022-11-05Specify that `break` cannot be used outside of loop *or* labeled blockclubby789-1/+1
2022-10-07migrate loops.rs to translateable diagnosticsNathan Stocks-116/+45
2022-07-12Add an indirection for closures in `hir::ExprKind`Maybe Waffle-1/+7
This helps bring `hir::Expr` size down, `Closure` was the biggest variant, especially after `for<>` additions.
2022-07-07Reword comments and rename HIR visiting methods.Camille GILLOT-1/+1
2022-06-15Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011Yuki Okushi-5/+5
Make `ExprKind::Closure` a struct variant. Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`. r? ``@Aaron1011``
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-1/+1
2022-06-12Make `ExprKind::Closure` a struct variant.Camille GILLOT-5/+5
2022-05-13rename visit item-like methodsMiguel Guarniz-1/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13remove ItemLikeVisitor and DeepVisitorMiguel Guarniz-1/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-4/+5
2021-01-21Do not suggest using a break label when one is already presentEsteban Küber-6/+11
2021-01-21Tweak error for invalid `break expr`Esteban Küber-20/+56
Point at loop head on invalid `break expr`. Suggest removing `expr` or using label if available.
2021-01-21Add loop head span to hirEsteban Küber-3/+2
2020-08-30mv compiler to compiler/mark-0/+240