File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,16 @@ use syn::{parse_macro_input, DeriveInput};
20
20
/// It expected to run inside composite_template_derive, not by users
21
21
#[ cfg( feature = "blueprint" ) ]
22
22
#[ proc_macro]
23
+ #[ proc_macro_error]
24
+ #[ doc( hidden) ]
23
25
pub fn include_blueprint ( input : TokenStream ) -> TokenStream {
26
+ use proc_macro_error:: abort_call_site;
24
27
use quote:: quote;
25
28
26
29
let tokens: Vec < _ > = input. into_iter ( ) . collect ( ) ;
27
30
28
31
if tokens. len ( ) != 1 {
29
- panic ! ( "File name not found" ) ;
32
+ abort_call_site ! ( "File name not found" ) ;
30
33
}
31
34
32
35
let root = std:: env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap_or_else ( |_| "." . into ( ) ) ;
@@ -38,14 +41,14 @@ pub fn include_blueprint(input: TokenStream) -> TokenStream {
38
41
let path = std:: path:: Path :: new ( & root) . join ( file_name) ;
39
42
40
43
if !path. exists ( ) {
41
- panic ! ( "{path:? } not found" ) ;
44
+ abort_call_site ! ( "{} not found" , & path . to_string_lossy ( ) ) ;
42
45
}
43
46
44
47
let path = path. to_string_lossy ( ) . to_string ( ) ;
45
48
46
49
let template = blueprint:: compile_blueprint (
47
50
std:: fs:: read_to_string ( & path)
48
- . unwrap_or_else ( |err| panic ! ( "{err}" ) )
51
+ . unwrap_or_else ( |err| abort_call_site ! ( "{}" , err ) )
49
52
. as_bytes ( ) ,
50
53
)
51
54
. unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments