Skip to content

Commit 1e3328d

Browse files
committed
Document assoc-lang-items.rs
1 parent 5e07f6e commit 1e3328d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Diff for: tests/ui/assoc-lang-items.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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

317
trait Foo {

Diff for: tests/ui/assoc-lang-items.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error[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
|
44
LL | #[lang = "dummy_lang_item_1"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_1`
66

77
error[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
|
1010
LL | #[lang = "dummy_lang_item_2"]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_2`
1212

1313
error[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
|
1616
LL | #[lang = "dummy_lang_item_3"]
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_3`
1818

1919
error[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
|
2222
LL | #[lang = "dummy_lang_item_4"]
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_4`

0 commit comments

Comments
 (0)