File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1+ //! Check that associated items can be marked as lang items, so that they don't have to be looked up
2+ //! by name or by definition order indirectly.
3+ //!
4+ //! This test is not *quite* high-fidelity: it checks that you can use lang items on associated
5+ //! items by looking at the error message *as a proxy*. That is, the error message is about
6+ //! undefined lang items and not invalid attribute target, indicating that it has reached lang item
7+ //! machinery (which is relying on knowing the implementation detail). However, it's annoying to
8+ //! write a full-fidelity test for this, so I think this is acceptable even though it's not *great*.
9+ //!
10+ //! This was implemented in <https://github.com/rust-lang/rust/pull/72559> to help with
11+ //! <https://github.com/rust-lang/rust/issues/70718>, which is itself relevant for e.g. `Fn::Output`
12+ //! or `Future::Output` or specific use cases like [Use `T`'s discriminant type in
13+ //! `mem::Discriminant<T>` instead of `u64`](https://github.com/rust-lang/rust/pull/70705).
14+
115#![ feature( lang_items) ]
216
317trait Foo {
Original file line number Diff line number Diff line change 11error[E0522]: definition of an unknown lang item: `dummy_lang_item_1`
2- --> $DIR/assoc-lang-items.rs:4 :5
2+ --> $DIR/assoc-lang-items.rs:18 :5
33 |
44LL | #[lang = "dummy_lang_item_1"]
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_1`
66
77error[E0522]: definition of an unknown lang item: `dummy_lang_item_2`
8- --> $DIR/assoc-lang-items.rs:7 :5
8+ --> $DIR/assoc-lang-items.rs:21 :5
99 |
1010LL | #[lang = "dummy_lang_item_2"]
1111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_2`
1212
1313error[E0522]: definition of an unknown lang item: `dummy_lang_item_3`
14- --> $DIR/assoc-lang-items.rs:10 :5
14+ --> $DIR/assoc-lang-items.rs:24 :5
1515 |
1616LL | #[lang = "dummy_lang_item_3"]
1717 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_3`
1818
1919error[E0522]: definition of an unknown lang item: `dummy_lang_item_4`
20- --> $DIR/assoc-lang-items.rs:17 :5
20+ --> $DIR/assoc-lang-items.rs:31 :5
2121 |
2222LL | #[lang = "dummy_lang_item_4"]
2323 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_4`
You can’t perform that action at this time.
0 commit comments