Skip to content

Commit

Permalink
lang-item:Add LangItem::Kind::RECEIVER
Browse files Browse the repository at this point in the history
Add and implement a lang item (receiver) in source code.

gcc/rust/ChangeLog:

	* util/rust-lang-item.cc: Add receiver to map.
	* util/rust-lang-item.h: Define LangItem::Kind::RECEIVER.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2954.rs: New test.

Signed-off-by: lishin <[email protected]>
  • Loading branch information
Lishin1215 committed Jan 20, 2025
1 parent aacecba commit 4854e29
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions gcc/rust/util/rust-lang-item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const BiMap<std::string, LangItem::Kind> Rust::LangItem::lang_items = {{
{"shr_assign", Kind::SHR_ASSIGN},
{"deref", Kind::DEREF},
{"deref_mut", Kind::DEREF_MUT},
{"receiver", Kind::RECEIVER},
{"index", Kind::INDEX},
{"index_mut", Kind::INDEX_MUT},
{"RangeFull", Kind::RANGE_FULL},
Expand Down
1 change: 1 addition & 0 deletions gcc/rust/util/rust-lang-item.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class LangItem

DEREF,
DEREF_MUT,
RECEIVER,

// https://github.com/rust-lang/rust/blob/master/library/core/src/ops/index.rs
INDEX,
Expand Down
17 changes: 17 additions & 0 deletions gcc/testsuite/rust/compile/issue-2954.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#[lang = "sized"]
trait Sized {}

#[lang = "receiver"]
#[unstable(feature = "receiver_trait", issue = "none")]
// #[doc(hidden)]
pub trait Receiver {
// Empty.
}

#[unstable(feature = "receiver_trait", issue = "none")]
impl<T: ?Sized> Receiver for &T {}

#[unstable(feature = "receiver_trait", issue = "none")]
impl<T: ?Sized> Receiver for &mut T {}


0 comments on commit 4854e29

Please sign in to comment.