Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/rustdoc-json/attrs/export_name_2021.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ edition: 2021
#![no_std]

//@ is "$.index[*][?(@.name=='example')].attrs" '["#[export_name = \"altered\"]"]'
#[export_name = "altered"]
pub extern "C" fn example() {}
9 changes: 9 additions & 0 deletions tests/rustdoc-json/attrs/export_name_2024.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ edition: 2024
#![no_std]

// The representation of `#[unsafe(export_name = ..)]` in rustdoc in edition 2024
// is still `#[export_name = ..]` without the `unsafe` attribute wrapper.

//@ is "$.index[*][?(@.name=='example')].attrs" '["#[export_name = \"altered\"]"]'
#[unsafe(export_name = "altered")]
pub extern "C" fn example() {}
9 changes: 9 additions & 0 deletions tests/rustdoc-json/attrs/must_use.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_std]

//@ is "$.index[*][?(@.name=='example')].attrs" '["#[must_use]"]'
#[must_use]
pub fn example() -> impl Iterator<Item = i64> {}

//@ is "$.index[*][?(@.name=='explicit_message')].attrs" '["#[must_use = \"does nothing if you do not use it\"]"]'
#[must_use = "does nothing if you do not use it"]
pub fn explicit_message() -> impl Iterator<Item = i64> {}
6 changes: 6 additions & 0 deletions tests/rustdoc-json/attrs/no_mangle_2021.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ edition: 2021
#![no_std]

//@ is "$.index[*][?(@.name=='example')].attrs" '["#[no_mangle]"]'
#[no_mangle]
pub extern "C" fn example() {}
9 changes: 9 additions & 0 deletions tests/rustdoc-json/attrs/no_mangle_2024.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ edition: 2024
#![no_std]

// The representation of `#[unsafe(no_mangle)]` in rustdoc in edition 2024
// is still `#[no_mangle]` without the `unsafe` attribute wrapper.

//@ is "$.index[*][?(@.name=='example')].attrs" '["#[no_mangle]"]'
#[unsafe(no_mangle)]
pub extern "C" fn example() {}
19 changes: 19 additions & 0 deletions tests/rustdoc-json/attrs/non_exhaustive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![no_std]

//@ is "$.index[*][?(@.name=='MyEnum')].attrs" '["#[non_exhaustive]"]'
#[non_exhaustive]
pub enum MyEnum {
First,
}

pub enum NonExhaustiveVariant {
//@ is "$.index[*][?(@.name=='Variant')].attrs" '["#[non_exhaustive]"]'
#[non_exhaustive]
Variant(i64),
}

//@ is "$.index[*][?(@.name=='MyStruct')].attrs" '["#[non_exhaustive]"]'
#[non_exhaustive]
pub struct MyStruct {
pub x: i64,
}
Loading