@@ -42,7 +42,7 @@ fn expect_ident(it: &mut token_stream::IntoIter) -> String {
42
42
}
43
43
44
44
fn expect_punct ( it : & mut token_stream:: IntoIter ) -> char {
45
- if let TokenTree :: Punct ( punct) = it. next ( ) . unwrap ( ) {
45
+ if let TokenTree :: Punct ( punct) = it. next ( ) . expect ( "Reached end of token stream for Punct" ) {
46
46
punct. as_char ( )
47
47
} else {
48
48
panic ! ( "Expected Punct" ) ;
@@ -54,7 +54,7 @@ fn expect_literal(it: &mut token_stream::IntoIter) -> String {
54
54
}
55
55
56
56
fn expect_group ( it : & mut token_stream:: IntoIter ) -> Group {
57
- if let TokenTree :: Group ( group) = it. next ( ) . unwrap ( ) {
57
+ if let TokenTree :: Group ( group) = it. next ( ) . expect ( "Reached end of token stream for Group" ) {
58
58
group
59
59
} else {
60
60
panic ! ( "Expected Group" ) ;
@@ -84,7 +84,10 @@ fn expect_array_fields(it: &mut token_stream::IntoIter) -> ParamType {
84
84
}
85
85
86
86
fn expect_type ( it : & mut token_stream:: IntoIter ) -> ParamType {
87
- if let TokenTree :: Ident ( ident) = it. next ( ) . unwrap ( ) {
87
+ if let TokenTree :: Ident ( ident) = it
88
+ . next ( )
89
+ . expect ( "Reached end of token stream for param type" )
90
+ {
88
91
match ident. to_string ( ) . as_ref ( ) {
89
92
"ArrayParam" => expect_array_fields ( it) ,
90
93
_ => ParamType :: Ident ( ident. to_string ( ) ) ,
@@ -576,7 +579,8 @@ pub fn module(ts: TokenStream) -> TokenStream {
576
579
) ) ;
577
580
}
578
581
579
- let file = std:: env:: var ( "RUST_MODFILE" ) . unwrap ( ) ;
582
+ let file =
583
+ std:: env:: var ( "RUST_MODFILE" ) . expect ( "Unable to fetch RUST_MODFILE environmental variable" ) ;
580
584
581
585
format ! (
582
586
"
@@ -672,5 +676,5 @@ pub fn module(ts: TokenStream) -> TokenStream {
672
676
params_modinfo = params_modinfo,
673
677
generated_array_types = generated_array_types,
674
678
initcall_section = ".initcall6.init"
675
- ) . parse ( ) . unwrap ( )
679
+ ) . parse ( ) . expect ( "Error parsing formatted string into token stream." )
676
680
}
0 commit comments