about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/lang_items.rs
AgeCommit message (Collapse)AuthorLines
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-1/+2
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-07-08Rollup merge of #86726 - ↵Guillaume Gomez-3/+0
sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r=nikomatsakis Use diagnostic items instead of lang items for rfc2229 migrations This PR removes the `Send`, `UnwindSafe` and `RefUnwindSafe` lang items introduced in https://github.com/rust-lang/rust/pull/84730, and uses diagnostic items instead to check for `Send`, `UnwindSafe` and `RefUnwindSafe` traits for RFC2229 migrations. r? ```@nikomatsakis```
2021-07-01Rename all_crate_nums query to crates and remove useless wrapperbjorn3-1/+1
2021-06-29Remove lang items Send, UnwindSafe and RefUnwindSafeRoxane Fruytier-3/+0
2021-05-18Rollup merge of #85339 - FabianWolff:issue-83893, r=varkorGuillaume Gomez-3/+124
Report an error if a lang item has the wrong number of generic arguments This pull request fixes #83893. The issue is that the lang item code currently checks whether the lang item has the correct item kind (e.g. a `#[lang="add"]` has to be a trait), but not whether the item has the correct number of generic arguments. This can lead to an "index out of bounds" ICE when the compiler tries to create more substitutions than there are suitable types available (if the lang item was declared with too many generic arguments). For instance, here is a reduced ("reduced" in the sense that it does not trigger additional errors) version of the example given in #83893: ```rust #![feature(lang_items,no_core)] #![no_core] #![crate_type="lib"] #[lang = "sized"] trait MySized {} #[lang = "add"] trait MyAdd<'a, T> {} fn ice() { let r = 5; let a = 6; r + a } ``` On current nightly, this immediately causes an ICE without any warnings or errors emitted. With the changes in this PR, however, I get no ICE and two errors: ``` error[E0718]: `add` language item must be applied to a trait with 1 generic argument --> pr-ex.rs:8:1 | 8 | #[lang = "add"] | ^^^^^^^^^^^^^^^ 9 | trait MyAdd<'a, T> {} | ------- this trait has 2 generic arguments, not 1 error[E0369]: cannot add `{integer}` to `{integer}` --> pr-ex.rs:14:7 | 14 | r + a | - ^ - {integer} | | | {integer} error: aborting due to 2 previous errors Some errors have detailed explanations: E0369, E0718. For more information about an error, try `rustc --explain E0369`. ```
2021-05-17Two minor changes for readability and efficiencyFabian Wolff-3/+2
2021-05-16Implement changes suggested by varkorFabian Wolff-5/+49
2021-05-15Report an error if a lang item has the wrong number of generic argumentsFabian Wolff-5/+83
2021-05-12Use () for lang items.Camille GILLOT-6/+3
2021-03-09Access attrs directly from HirId in rustc_passes::lang_items.Camille GILLOT-14/+6
2021-02-15Only store a LocalDefId in hir::ImplItem.Camille GILLOT-1/+1
2021-02-15Only store a LocalDefId in hir::TraitItem.Camille GILLOT-1/+1
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-1/+1
Items are guaranteed to be HIR owner.
2020-11-26Store ForeignItem in a side table.Camille GILLOT-0/+2
2020-08-30mv compiler to compiler/mark-0/+220