-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
158 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
SemverQuery( | ||
id: "macro_now_doc_hidden", | ||
human_readable_name: "macro is now #[doc(hidden)]", | ||
description: "A declarative macro that was previously part of the public API is now #[doc(hidden)], requiring downstream users to acknowledge their reliance on non-public APIs.", | ||
required_update: Major, | ||
lint_level: Deny, | ||
reference_link: Some("https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#hidden"), | ||
query: r#" | ||
{ | ||
CrateDiff { | ||
baseline { | ||
item { | ||
... on Macro { | ||
name @output @tag | ||
public_api_eligible @filter(op: "=", value: ["$true"]) | ||
} | ||
} | ||
} | ||
current { | ||
item { | ||
... on Macro { | ||
name @filter(op: "=", value: ["%name"]) | ||
doc_hidden @filter(op: "=", value: ["$true"]) | ||
public_api_eligible @filter(op: "!=", value: ["$true"]) | ||
span_: span @optional { | ||
filename @output | ||
begin_line @output | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"true": true, | ||
}, | ||
error_message: "A macro that was previously part of the public API is now #[doc(hidden)].", | ||
per_result_error_template: Some("macro {{name}} in {{span_filename}}:{{span_begin_line}}"), | ||
witness: None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "macro_now_doc_hidden" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/// Now hidden from docs | ||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! will_be_hidden { | ||
($val:expr, $opts:expr) => { | ||
println!("Processing {} with {:?}", $val, $opts); | ||
}; | ||
} | ||
|
||
/// A macro that stays public | ||
#[macro_export] | ||
macro_rules! stays_public { | ||
() => { | ||
println!("This macro remains public"); | ||
}; | ||
} | ||
|
||
// Already hidden macro that changes implementation but stays hidden | ||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! already_hidden { | ||
() => { | ||
println!("Version 2"); | ||
}; | ||
} | ||
|
||
// Non-exported macro that becomes hidden - should not trigger | ||
#[doc(hidden)] | ||
macro_rules! non_exported_becomes_hidden { | ||
() => { | ||
println!("Not exported and now hidden"); | ||
}; | ||
} | ||
|
||
// Macro that was exported but is no longer exported - should not trigger | ||
macro_rules! becomes_non_exported { | ||
() => { | ||
println!("No longer exported"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "macro_now_doc_hidden" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/// A macro that will become hidden | ||
#[macro_export] | ||
macro_rules! will_be_hidden { | ||
($val:expr, $opts:expr) => { | ||
println!("Processing {} with {:?}", $val, $opts); | ||
}; | ||
} | ||
|
||
/// A macro that stays public | ||
#[macro_export] | ||
macro_rules! stays_public { | ||
() => { | ||
println!("This macro remains public"); | ||
}; | ||
} | ||
|
||
// Already hidden macro that changes implementation but stays hidden | ||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! already_hidden { | ||
() => { | ||
println!("Version 1"); | ||
}; | ||
} | ||
|
||
// Non-exported macro that becomes hidden - should not trigger | ||
/// Some documentation | ||
macro_rules! non_exported_becomes_hidden { | ||
() => { | ||
println!("Not exported"); | ||
}; | ||
} | ||
|
||
// Exported macro that becomes non-exported but not doc(hidden) - should not trigger | ||
#[macro_export] | ||
macro_rules! becomes_non_exported { | ||
() => { | ||
println!("Will become non-exported"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
source: src/query.rs | ||
expression: "&query_execution_results" | ||
snapshot_kind: text | ||
--- | ||
{ | ||
"./test_crates/declarative_macro_missing/": [ | ||
{ | ||
"name": String("became_doc_hidden"), | ||
"span_begin_line": Uint64(7), | ||
"span_filename": String("src/lib.rs"), | ||
}, | ||
], | ||
"./test_crates/macro_now_doc_hidden/": [ | ||
{ | ||
"name": String("will_be_hidden"), | ||
"span_begin_line": Uint64(4), | ||
"span_filename": String("src/lib.rs"), | ||
}, | ||
], | ||
} |