about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/lang_items.rs
AgeCommit message (Collapse)AuthorLines
2025-08-14Improved `Target` typeJonathan Brouwer-1/+1
- Added a few more variants which are needed for various attributes - Previously a trait method with default block had the same target representation as a method in a `impl trait for` block, this has been changed (See `MethodKind`) - Added `plural_name` for more precision on the form of the name
2025-07-17Specify of_trait in Target::Impl.Camille GILLOT-1/+1
2025-06-06deduplicate more `walk_*` methods in AST visitDeadbeef-12/+8
2025-05-04Initial support for dynamically linked cratesBryanskiy-1/+6
2025-04-01Move `ast::Item::ident` into `ast::ItemKind`.Nicholas Nethercote-7/+7
`ast::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, `Trait`, `TraitAlias`, `MacroDef`, `Delegation`. - It's always empty for these item kinds: `Use`, `ForeignMod`, `GlobalAsm`, `Impl`, `MacCall`, `DelegationMac`. There is a similar story for `AssocItemKind` and `ForeignItemKind`. Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - `ast::Item` got 8 bytes bigger. This could be avoided by boxing the fields within some of the `ast::ItemKind` variants (specifically: `Struct`, `Union`, `Enum`). I might do that in a follow-up; this commit is big enough already. - For the visitors: `FnKind` no longer needs an `ident` field because the `Fn` within how has one. - In the parser, the `ItemInfo` typedef is no longer needed. It was used in various places to return an `Ident` alongside an `ItemKind`, but now the `Ident` (if present) is within the `ItemKind`. - In a few places I renamed identifier variables called `name` (or `foo_name`) as `ident` (or `foo_ident`), to better match the type, and because `name` is normally used for `Symbol`s. It's confusing to see something like `foo_name.name`.
2025-03-25Use `Option<Symbol>` in `DuplicateLangItem`.Nicholas Nethercote-7/+7
For the the symbols that might not be present, instead of `kw::Empty`.
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-5/+4
`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-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-08-29Add `warn(unreachable_pub)` to `rustc_passes`.Nicholas Nethercote-1/+1
2024-08-17Use cnum for extern crate dataMichael Goulet-2/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-21Minor `pub` and whitespace cleanups.Nicholas Nethercote-2/+3
2024-05-15delegation: Implement list delegationVadim Petrochenkov-2/+6
```rust reuse prefix::{a, b, c} ```
2024-04-17consistency rename: language item -> lang itemRalf Jung-1/+1
2024-03-05Avoid using feed_unit_query from within queriesOli Scherer-1/+1
2024-02-18resolve: Scale back unloading of speculatively loaded cratesVadim Petrochenkov-1/+1
2024-01-29Make duplicate lang items fatalNilstrieb-1/+3
Prevents terminal spam.
2024-01-12Delegation implementation: step 1Bryanskiy-19/+24
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-4/+4
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-15Fix enforcement of generics for associated itemsMichael Goulet-19/+27
2023-12-15Collect lang items from ASTMichael Goulet-144/+226
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-1/+1
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-12-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-2/+7
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-1/+1
cleanup
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`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-20s/generator/coroutine/Oli Scherer-1/+1
2023-09-20fix bugs with effects fallbackDeadbeef-2/+10
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-13/+14
2022-12-18avoid .into() conversion to identical typesMatthias Krüger-2/+0
2022-11-13Store a LocalDefId in hir::Variant & hir::Field.Camille GILLOT-1/+1
2022-10-29Simplify lang item groupsCameron Steffen-3/+0
2022-10-29Factor out ITEM_REFSCameron Steffen-8/+7
2022-10-29Encode LangItem directlyCameron Steffen-8/+8
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-2/+2
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-07avoid string dispatch in fluentNathan Stocks-5/+11
2022-10-07First batch of review feedback changes from #102110Nathan Stocks-4/+4
2022-10-07migrate lang_items.rs to translateable diagnosticsNathan Stocks-91/+79
2022-10-07use consistent namesNathan Stocks-4/+4
2022-10-07Migrate InvalidAttrAtCrateLevelrdvdev2-5/+2
Co-authored-by: Nathan Stocks <cleancut@github.com> Co-authored-by: rdvdev2 <rdvdev2@gmail.com>
2022-10-07Migrate derivable diagnostics in lang_items.rsrdvdev2-22/+8
2022-05-06use def_span and def_kind queries instead of calling tcx.hir() methodsMiguel Guarniz-2/+2
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08add mapping from DefKind to Target and remove more ItemLikeVisitor implsMiguel Guarniz-27/+15
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08remove some uses of visit_all_item_likes in typeck, symbol_mangling and ↵Miguel Guarniz-1/+16
passes crates Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-01-09Clean up lang_items::extractEric Huss-3/+1
Noted in https://github.com/rust-lang/rust/pull/87739#pullrequestreview-740497194, lang_items::extract no longer needs to take a closure.
2021-12-15Remove `in_band_lifetimes` for `rustc_passes`Peter Jaszkowiak-2/+2
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-3/+2
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-1/+1
2021-08-25Auto merge of #87875 - asquared31415:generic-lang-items, r=cjgillotbors-87/+35
Improve detection of generics on lang items Adds detection for the required generics for all lang items. Many lang items require an exact or minimum amount of generic arguments and if they don't exist, the compiler will ICE. This does not add any additional validation about bounds on generics or any other lang item restrictions. Fixes one of the ICEs in #87573 cc `@FabianWolff`
2021-08-23Detect incorrect number of lang item genericsasquared31415-87/+35