diff options
| -rw-r--r-- | tests/ui/assoc-lang-items.rs | 14 | ||||
| -rw-r--r-- | tests/ui/assoc-lang-items.stderr | 8 |
2 files changed, 18 insertions, 4 deletions
diff --git a/tests/ui/assoc-lang-items.rs b/tests/ui/assoc-lang-items.rs index 23453d201a7..460d3ed2326 100644 --- a/tests/ui/assoc-lang-items.rs +++ b/tests/ui/assoc-lang-items.rs @@ -1,3 +1,17 @@ +//! Check that associated items can be marked as lang items, so that they don't have to be looked up +//! by name or by definition order indirectly. +//! +//! This test is not *quite* high-fidelity: it checks that you can use lang items on associated +//! items by looking at the error message *as a proxy*. That is, the error message is about +//! undefined lang items and not invalid attribute target, indicating that it has reached lang item +//! machinery (which is relying on knowing the implementation detail). However, it's annoying to +//! write a full-fidelity test for this, so I think this is acceptable even though it's not *great*. +//! +//! This was implemented in <https://github.com/rust-lang/rust/pull/72559> to help with +//! <https://github.com/rust-lang/rust/issues/70718>, which is itself relevant for e.g. `Fn::Output` +//! or `Future::Output` or specific use cases like [Use `T`'s discriminant type in +//! `mem::Discriminant<T>` instead of `u64`](https://github.com/rust-lang/rust/pull/70705). + #![feature(lang_items)] trait Foo { diff --git a/tests/ui/assoc-lang-items.stderr b/tests/ui/assoc-lang-items.stderr index 59aec8e3fdc..7e61fea449b 100644 --- a/tests/ui/assoc-lang-items.stderr +++ b/tests/ui/assoc-lang-items.stderr @@ -1,23 +1,23 @@ error[E0522]: definition of an unknown lang item: `dummy_lang_item_1` - --> $DIR/assoc-lang-items.rs:4:5 + --> $DIR/assoc-lang-items.rs:18:5 | LL | #[lang = "dummy_lang_item_1"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_1` error[E0522]: definition of an unknown lang item: `dummy_lang_item_2` - --> $DIR/assoc-lang-items.rs:7:5 + --> $DIR/assoc-lang-items.rs:21:5 | LL | #[lang = "dummy_lang_item_2"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_2` error[E0522]: definition of an unknown lang item: `dummy_lang_item_3` - --> $DIR/assoc-lang-items.rs:10:5 + --> $DIR/assoc-lang-items.rs:24:5 | LL | #[lang = "dummy_lang_item_3"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_3` error[E0522]: definition of an unknown lang item: `dummy_lang_item_4` - --> $DIR/assoc-lang-items.rs:17:5 + --> $DIR/assoc-lang-items.rs:31:5 | LL | #[lang = "dummy_lang_item_4"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_4` |
