about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/hir/map
AgeCommit message (Collapse)AuthorLines
2025-02-17Rename `rustc_middle/src/hir/map/mod.rs` as `map.rs`.Nicholas Nethercote-1405/+0
There is no need for the extra subdirectory, and this makes the `map` module consistent with its sibling modules `nested_filter` and `place`.
2025-02-11Simplify intra-crate qualifiers.Nicholas Nethercote-2/+1
The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers.
2025-02-03Use a different hir type for patterns in pattern types than we use in match ↵Oli Scherer-0/+2
patterns
2025-01-22Auto merge of #134478 - compiler-errors:attr-span, r=oli-obkbors-1/+4
Properly record metavar spans for other expansions other than TT This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result. Fixes #132908 Alternative to #133270 cc `@ehuss` cc `@petrochenkov`
2025-01-10Eagerly collect mono items for non-generic closuresMichael Goulet-0/+8
2025-01-08Exhaustively handle expressions in patternsOli Scherer-0/+2
2025-01-04turn hir::ItemKind::Fn into a named-field variantRalf Jung-3/+3
2024-12-21Hash only the spans that we care ended up reading in Span::try_metavarsMichael Goulet-7/+2
2024-12-21Hash the untracked macro variable expansionsMichael Goulet-1/+9
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-15Add hir::AttributeJonathan Dönszelmann-3/+3
2024-11-30Remove hir::ArrayLen, introduce ConstArgKind::InferDominik Stolz-2/+0
Remove Node::ArrayLenInfer
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-2/+2
2024-11-03compiler: Directly use rustc_abi in metadata and middleJubilee Young-2/+2
Stop reexporting ReprOptions from middle::ty
2024-10-25tcx.is_const_fn doesn't work the way it is described, remove itRalf Jung-1/+1
Then we can rename the _raw functions to drop their suffix, and instead explicitly use is_stable_const_fn for the few cases where that is really what you want.
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-1/+30
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-10-02Move in_trait into OpaqueTyOriginMichael Goulet-7/+1
2024-09-23Rollup merge of #130618 - m-ou-se:skip-query, r=compiler-errorsMichael Goulet-1/+4
Skip query in get_parent_item when possible. For HirIds with a non-zero item local id, `self.parent_owner_iter(hir_id).next()` just returns the same HirId with the item local id set to 0, but also does a query to retrieve the Node which is ignored here, which seems wasteful.
2024-09-23Update compiler/rustc_middle/src/hir/map/mod.rsMara Bos-1/+2
Co-authored-by: Michael Goulet <michael@errs.io>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-4/+4
2024-09-20Skip query in get_parent_item when possible.Mara Bos-1/+3
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-6/+6
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-1/+1
closures
2024-08-17Auto merge of #128792 - compiler-errors:foreign-sig, r=spastorinobors-4/+6
Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns. Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns. If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍 r? spastorino Fixes #128764
2024-08-16Rewrite `get_fn_id_for_return_block`Boxy-37/+27
2024-08-16Use FnSig instead of raw FnDecl for ForeignItemKind::FnMichael Goulet-4/+6
2024-08-10Differentiate between methods and associated functionsEsteban Küber-6/+12
Accurately refer to assoc fn without receiver as assoc fn instead of methods. Add `AssocItem::descr` method to centralize where we call methods and associated functions.
2024-07-31Delegation: second attempt to improve perfBryanskiy-12/+1
2024-07-29Delegation: support generics for delegation from free functionsBryanskiy-0/+15
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+6
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-16Add `ConstArgKind::Path` and make `ConstArg` its own HIR nodeNoah Lev-1/+4
This is a very large commit since a lot needs to be changed in order to make the tests pass. The salient changes are: - `ConstArgKind` gets a new `Path` variant, and all const params are now represented using it. Non-param paths still use `ConstArgKind::Anon` to prevent this change from getting too large, but they will soon use the `Path` variant too. - `ConstArg` gets a distinct `hir_id` field and its own variant in `hir::Node`. This affected many parts of the compiler that expected the parent of an `AnonConst` to be the containing context (e.g., an array repeat expression). They have been changed to check the "grandparent" where necessary. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at #127009.
2024-07-06Cache hir_owner_nodes in ParentHirIterator.Camille GILLOT-8/+26
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-30/+12
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-06Auto merge of #126068 - lqd:revert-124976, r=petrochenkovbors-3/+3
Revert "use `tcx.used_crates(())` more" before it reaches beta There are more open issues caused by #124976 than will be fixed by #125493 alone. The beta cut is soon, so let's revert it and buy some time to analyze and fix these issues in our own time. fixes https://github.com/rust-lang/rust/issues/125474 fixes https://github.com/rust-lang/rust/issues/125484 fixes https://github.com/rust-lang/rust/issues/125646 fixes https://github.com/rust-lang/rust/issues/125707 fixes #126066 fixes #125934 fixes https://github.com/rust-lang/rust/issues/126021 r? `@petrochenkov` `@bors` p=1
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-3/+3
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-04Add safe/unsafe to static inside extern blocksSantiago Pastorino-1/+3
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-1/+1
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-2/+2
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-2/+2
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-3/+18
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-9/+12
2024-05-22rustc: Use `tcx.used_crates(())` moreVadim Petrochenkov-3/+3
And explain when it should be used.
2024-05-20Inline get_node_fn_decl into get_fn_decl, simplify/explain logic in ↵Michael Goulet-1/+5
report_return_mismatched_types
2024-05-20Rename confusing function nameMichael Goulet-6/+6
2024-05-20Remove get_parent_fn_decl; it's redundantMichael Goulet-1/+1
2024-05-09fix: Check whether next_node is else-less if in get_return_blockcardigan1008-3/+1
Fix #124819, where a if-less block causes a wrong output. It is caused by get_return_block in get_fn_decl. In get_return_block, when a else-less if expression is the tail expression, the check for next_node will keep iterating. So it is necessary to make a early return in the check.
2024-05-09fix: Add if to check whether the previous node is Blockcardigan1008-0/+3
2024-04-29Avoid some `def_span` query callsOli Scherer-1/+1
2024-04-26`Span`s are already 64 bit, just like references, so stop putting them ↵Oli Scherer-1/+1
behind indirections
2024-04-16Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obkbors-0/+2
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`) Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587. We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list. We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future. We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future. r? `@oli-obk` Tracking issue: - https://github.com/rust-lang/rust/issues/123432