-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
172 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
SemverQuery( | ||
id: "proc_macro_now_doc_hidden", | ||
human_readable_name: "proc macro became #[doc(hidden)]", | ||
description: "A procedural macro has become #[doc(hidden)] and is no longer public API.", | ||
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 ProcMacro { | ||
kind: __typename @output @tag | ||
visibility_limit @filter(op: "=", value: ["$public"]) | ||
importable_path { | ||
path @output @tag | ||
public_api @filter(op: "=", value: ["$true"]) | ||
} | ||
} | ||
} | ||
} | ||
current { | ||
item { | ||
... on ProcMacro { | ||
__typename @filter(op: "=", value: ["%kind"]) | ||
name @output | ||
importable_path { | ||
path @filter(op: "=", value: ["%path"]) | ||
public_api @filter(op: "!=", value: ["$true"]) | ||
} | ||
span_: span @optional { | ||
filename @output | ||
begin_line @output | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"public": "public", | ||
"true": true, | ||
}, | ||
error_message: "A public procedural macro is now #[doc(hidden)], removing it from the crate's public API.", | ||
per_result_error_template: Some("proc macro {{name}} in file {{span_filename}}:{{span_begin_line}}"), | ||
) |
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,10 @@ | ||
[package] | ||
publish = false | ||
name = "proc_macro_now_doc_hidden" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[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,22 @@ | ||
use proc_macro::TokenStream; | ||
|
||
// An attribute macro we'll hide. Should trigger the lint. | ||
#[doc(hidden)] | ||
#[proc_macro_attribute] | ||
pub fn logging(_attr: TokenStream, item: TokenStream) -> TokenStream { | ||
item | ||
} | ||
|
||
// A function-like macro we'll hide. Should trigger the lint. | ||
#[doc(hidden)] | ||
#[proc_macro] | ||
pub fn sql(_item: TokenStream) -> TokenStream { | ||
TokenStream::new() | ||
} | ||
|
||
// A derive macro we'll hide. Should trigger the lint. | ||
#[doc(hidden)] | ||
#[proc_macro_derive(MyDerive)] | ||
pub fn my_derive(_item: TokenStream) -> TokenStream { | ||
TokenStream::new() | ||
} |
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,10 @@ | ||
[package] | ||
publish = false | ||
name = "proc_macro_now_doc_hidden" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[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 @@ | ||
use proc_macro::TokenStream; | ||
|
||
// An attribute macro we'll hide. Should trigger the lint. | ||
#[proc_macro_attribute] | ||
pub fn logging(_attr: TokenStream, item: TokenStream) -> TokenStream { | ||
item | ||
} | ||
|
||
// A function-like macro we'll hide. Should trigger the lint. | ||
#[proc_macro] | ||
pub fn sql(_item: TokenStream) -> TokenStream { | ||
TokenStream::new() | ||
} | ||
|
||
// A derive macro we'll hide. Should trigger the lint. | ||
#[proc_macro_derive(MyDerive)] | ||
pub fn my_derive(_item: TokenStream) -> TokenStream { | ||
TokenStream::new() | ||
} | ||
|
||
// A hidden attribute macro we'll delete. Shouldn't trigger any lint. | ||
#[doc(hidden)] | ||
#[proc_macro_attribute] | ||
pub fn hidden_logging(_attr: TokenStream, item: TokenStream) -> TokenStream { | ||
item | ||
} | ||
|
||
// A hidden function-like macro we'll delete. Shouldn't trigger any lint. | ||
#[doc(hidden)] | ||
#[proc_macro] | ||
pub fn hidden_sql(_item: TokenStream) -> TokenStream { | ||
TokenStream::new() | ||
} | ||
|
||
// A hidden derive macro we'll delete. Shouldn't trigger any lint. | ||
#[doc(hidden)] | ||
#[proc_macro_derive(MyHiddenDerive)] | ||
pub fn hidden_derive(item: TokenStream) -> TokenStream { | ||
item | ||
} |
39 changes: 39 additions & 0 deletions
39
test_outputs/query_execution/proc_macro_now_doc_hidden.snap
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,39 @@ | ||
--- | ||
source: src/query.rs | ||
expression: "&query_execution_results" | ||
snapshot_kind: text | ||
--- | ||
{ | ||
"./test_crates/proc_macro_now_doc_hidden/": [ | ||
{ | ||
"kind": String("AttributeProcMacro"), | ||
"name": String("logging"), | ||
"path": List([ | ||
String("proc_macro_now_doc_hidden"), | ||
String("logging"), | ||
]), | ||
"span_begin_line": Uint64(6), | ||
"span_filename": String("src/lib.rs"), | ||
}, | ||
{ | ||
"kind": String("FunctionLikeProcMacro"), | ||
"name": String("sql"), | ||
"path": List([ | ||
String("proc_macro_now_doc_hidden"), | ||
String("sql"), | ||
]), | ||
"span_begin_line": Uint64(13), | ||
"span_filename": String("src/lib.rs"), | ||
}, | ||
{ | ||
"kind": String("DeriveProcMacro"), | ||
"name": String("MyDerive"), | ||
"path": List([ | ||
String("proc_macro_now_doc_hidden"), | ||
String("MyDerive"), | ||
]), | ||
"span_begin_line": Uint64(20), | ||
"span_filename": String("src/lib.rs"), | ||
}, | ||
], | ||
} |