@@ -74,6 +74,7 @@ pub enum VolatileItemKind {
74
74
/// This builder has a number of configuration options which modify how the
75
75
/// generated tests are emitted, and it is also the main entry point for parsing
76
76
/// an FFI header crate for definitions.
77
+ #[ allow( clippy:: type_complexity) ]
77
78
pub struct TestGenerator {
78
79
headers : Vec < String > ,
79
80
includes : Vec < PathBuf > ,
@@ -163,7 +164,7 @@ impl TestGenerator {
163
164
f. to_string ( )
164
165
}
165
166
} ) ,
166
- const_cname : Box :: new ( std :: string :: ToString :: to_string) ,
167
+ const_cname : Box :: new ( ToString :: to_string) ,
167
168
rust_version : rustc_version:: version ( ) . unwrap ( ) ,
168
169
}
169
170
}
@@ -324,7 +325,7 @@ impl TestGenerator {
324
325
/// ```
325
326
pub fn define ( & mut self , k : & str , v : Option < & str > ) -> & mut Self {
326
327
self . defines
327
- . push ( ( k. to_string ( ) , v. map ( std :: string :: ToString :: to_string) ) ) ;
328
+ . push ( ( k. to_string ( ) , v. map ( ToString :: to_string) ) ) ;
328
329
self
329
330
}
330
331
@@ -337,10 +338,10 @@ impl TestGenerator {
337
338
/// optional value of `v`:
338
339
///
339
340
/// * `k == "foo"` and `v == None` makes `#[cfg(foo)]` expand. That is,
340
- /// `cfg!(foo)` expands to `true`.
341
+ /// `cfg!(foo)` expands to `true`.
341
342
///
342
343
/// * `k == "bar"` and `v == Some("baz")` makes `#[cfg(bar = "baz")]`
343
- /// expand. That is, `cfg!(bar = "baz")` expands to `true`.
344
+ /// expand. That is, `cfg!(bar = "baz")` expands to `true`.
344
345
///
345
346
/// # Examples
346
347
///
@@ -353,7 +354,7 @@ impl TestGenerator {
353
354
/// ```
354
355
pub fn cfg ( & mut self , k : & str , v : Option < & str > ) -> & mut Self {
355
356
self . cfg
356
- . push ( ( k. to_string ( ) , v. map ( std :: string :: ToString :: to_string) ) ) ;
357
+ . push ( ( k. to_string ( ) , v. map ( ToString :: to_string) ) ) ;
357
358
self
358
359
}
359
360
@@ -811,7 +812,7 @@ impl TestGenerator {
811
812
Lang :: C => "c" ,
812
813
Lang :: CXX => "cpp" ,
813
814
} ;
814
- cfg. file ( & out. with_extension ( ext) ) ;
815
+ cfg. file ( out. with_extension ( ext) ) ;
815
816
if target. contains ( "msvc" ) {
816
817
cfg. flag ( "/W3" ) . flag ( "/Wall" ) . flag ( "/WX" )
817
818
// ignored warnings
@@ -844,7 +845,7 @@ impl TestGenerator {
844
845
cfg. flag ( flag) ;
845
846
}
846
847
847
- for & ( ref a , ref b) in & self . defines {
848
+ for ( a , b) in & self . defines {
848
849
cfg. define ( a, b. as_ref ( ) . map ( |s| & s[ ..] ) ) ;
849
850
}
850
851
for p in & self . includes {
@@ -884,7 +885,7 @@ impl TestGenerator {
884
885
. clone ( )
885
886
. unwrap_or_else ( || env:: var ( "TARGET" ) . unwrap ( ) ) ;
886
887
for ( k, v) in default_cfg ( & target) . into_iter ( ) . chain ( self . cfg . clone ( ) ) {
887
- let s = |s : & str | ast :: Name :: intern ( s) ;
888
+ let s = |s : & str | Name :: intern ( s) ;
888
889
sess. config . insert ( ( s ( & k) , v. as_ref ( ) . map ( |n| s ( n) ) ) ) ;
889
890
}
890
891
@@ -995,9 +996,7 @@ fn default_cfg(target: &str) -> Vec<(String, Option<String>)> {
995
996
( "powerpc" , "32" , "big" )
996
997
} else if target. starts_with ( "s390x" ) {
997
998
( "s390x" , "64" , "big" )
998
- } else if target. starts_with ( "sparc64" ) {
999
- ( "sparc64" , "64" , "big" )
1000
- } else if target. starts_with ( "sparcv9" ) {
999
+ } else if target. starts_with ( "sparc64" ) || target. starts_with ( "sparcv9" ) {
1001
1000
( "sparc64" , "64" , "big" )
1002
1001
} else if target. starts_with ( "asmjs" ) {
1003
1002
( "asmjs" , "32" , "little" )
@@ -1092,7 +1091,7 @@ fn linkage(lang: &Lang) -> &'static str {
1092
1091
}
1093
1092
}
1094
1093
1095
- impl < ' a > Generator < ' a > {
1094
+ impl Generator < ' _ > {
1096
1095
fn rust2c_test ( & self , ty : & str ) -> bool {
1097
1096
let rustc_types = [
1098
1097
"usize" , "u8" , "u16" , "u32" , "u64" , "isize" , "i8" , "i16" , "i32" , "i64" ,
@@ -1116,7 +1115,7 @@ impl<'a> Generator<'a> {
1116
1115
1117
1116
fn rust2c ( & self , ty : & str ) -> String {
1118
1117
match ty {
1119
- "c_longdouble" | "c_long_double" => format ! ( "long double" ) ,
1118
+ "c_longdouble" | "c_long_double" => "long double" . to_string ( ) ,
1120
1119
t if t. starts_with ( "c_" ) => match & ty[ 2 ..] . replace ( "long" , " long" ) [ ..] {
1121
1120
s if s. starts_with ( 'u' ) => format ! ( "unsigned {}" , & s[ 1 ..] ) ,
1122
1121
"short" => "short" . to_string ( ) ,
@@ -1984,8 +1983,8 @@ impl<'a> Generator<'a> {
1984
1983
ast:: TyKind :: Path ( _, ref path) => {
1985
1984
let last = path. segments . last ( ) . unwrap ( ) ;
1986
1985
if last. identifier . to_string ( ) == "Option" {
1987
- match last. parameters . as_ref ( ) . map ( |p| & * * p ) {
1988
- Some ( & ast:: PathParameters :: AngleBracketed ( ref p) ) => {
1986
+ match last. parameters . as_deref ( ) {
1987
+ Some ( ast:: PathParameters :: AngleBracketed ( p) ) => {
1989
1988
self . ty2name ( & p. types [ 0 ] , rust)
1990
1989
}
1991
1990
_ => panic ! ( ) ,
@@ -2017,7 +2016,7 @@ impl<'a> Generator<'a> {
2017
2016
format ! ( "{} {}*" , self . ty2name( & t. ty, rust) , modifier)
2018
2017
}
2019
2018
ast:: TyKind :: Array ( ref t, ref e) => {
2020
- let len = self . expr2str ( e) ;
2019
+ let len = Self :: expr2str ( e) ;
2021
2020
let ty = self . ty2name ( t, rust) ;
2022
2021
format ! ( "{} {} [{}]" , modifier, ty, len)
2023
2022
}
@@ -2056,9 +2055,9 @@ impl<'a> Generator<'a> {
2056
2055
}
2057
2056
ast:: TyKind :: Array ( ref t, ref e) => {
2058
2057
if rust {
2059
- format ! ( "[{}; {}]" , self . ty2name( t, rust) , self . expr2str( e) )
2058
+ format ! ( "[{}; {}]" , self . ty2name( t, rust) , Self :: expr2str( e) )
2060
2059
} else {
2061
- let len = self . expr2str ( e) ;
2060
+ let len = Self :: expr2str ( e) ;
2062
2061
let ty = self . ty2name ( t, rust) ;
2063
2062
format ! ( "{} [{}]" , ty, len)
2064
2063
}
@@ -2125,8 +2124,8 @@ impl<'a> Generator<'a> {
2125
2124
if path. segments . last ( ) . unwrap ( ) . identifier . to_string ( ) == "Option" =>
2126
2125
{
2127
2126
let last = path. segments . last ( ) . unwrap ( ) ;
2128
- match last. parameters . as_ref ( ) . map ( |s| & * * s ) {
2129
- Some ( & ast:: PathParameters :: AngleBracketed ( ref p) ) => {
2127
+ match last. parameters . as_deref ( ) {
2128
+ Some ( ast:: PathParameters :: AngleBracketed ( p) ) => {
2130
2129
self . csig_returning_ptr ( & p. types [ 0 ] , sig)
2131
2130
}
2132
2131
_ => panic ! ( ) ,
@@ -2148,16 +2147,16 @@ impl<'a> Generator<'a> {
2148
2147
"{}(*{})[{}][{}]" ,
2149
2148
self . ty2name( t2, false ) ,
2150
2149
sig,
2151
- self . expr2str( e) ,
2152
- self . expr2str( e2)
2150
+ Self :: expr2str( e) ,
2151
+ Self :: expr2str( e2)
2153
2152
) ,
2154
- _ => format ! ( "{}(*{})[{}]" , self . ty2name( t, false ) , sig, self . expr2str( e) ) ,
2153
+ _ => format ! ( "{}(*{})[{}]" , self . ty2name( t, false ) , sig, Self :: expr2str( e) ) ,
2155
2154
} ,
2156
2155
_ => format ! ( "{}* {}" , self . ty2name( ty, false ) , sig) ,
2157
2156
}
2158
2157
}
2159
2158
2160
- fn expr2str ( & self , e : & ast:: Expr ) -> String {
2159
+ fn expr2str ( e : & ast:: Expr ) -> String {
2161
2160
match e. node {
2162
2161
ast:: ExprKind :: Lit ( ref l) => match l. node {
2163
2162
ast:: LitKind :: Int ( a, _) => a. to_string ( ) ,
@@ -2166,10 +2165,10 @@ impl<'a> Generator<'a> {
2166
2165
ast:: ExprKind :: Path ( _, ref path) => {
2167
2166
path. segments . last ( ) . unwrap ( ) . identifier . to_string ( )
2168
2167
}
2169
- ast:: ExprKind :: Cast ( ref e, _) => self . expr2str ( e) ,
2168
+ ast:: ExprKind :: Cast ( ref e, _) => Self :: expr2str ( e) ,
2170
2169
ast:: ExprKind :: Binary ( ref op, ref e1, ref e2) => {
2171
- let e1 = self . expr2str ( e1) ;
2172
- let e2 = self . expr2str ( e2) ;
2170
+ let e1 = Self :: expr2str ( e1) ;
2171
+ let e2 = Self :: expr2str ( e2) ;
2173
2172
match op. node {
2174
2173
ast:: BinOpKind :: Add => format ! ( "{} + {}" , e1, e2) ,
2175
2174
ast:: BinOpKind :: Sub => format ! ( "{} - {}" , e1, e2) ,
@@ -2248,7 +2247,7 @@ impl<'a> Generator<'a> {
2248
2247
}
2249
2248
}
2250
2249
2251
- impl < ' a , ' v > Visitor < ' v > for Generator < ' a > {
2250
+ impl < ' v > Visitor < ' v > for Generator < ' _ > {
2252
2251
fn visit_item ( & mut self , i : & ' v ast:: Item ) {
2253
2252
let prev_abi = self . abi ;
2254
2253
let public = i. vis == ast:: Visibility :: Public ;
@@ -2316,8 +2315,8 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
2316
2315
. unwrap ( ) ;
2317
2316
}
2318
2317
ast:: ForeignItemKind :: Static ( ref ty, mutbl) => {
2319
- let rust_ty = self . ty2name ( & ty, true ) ;
2320
- let c_ty = self . ty2name ( & ty, false ) ;
2318
+ let rust_ty = self . ty2name ( ty, true ) ;
2319
+ let c_ty = self . ty2name ( ty, false ) ;
2321
2320
let c_name = attr:: first_attr_value_str_by_name ( & i. attrs , "link_name" )
2322
2321
. map ( |i| i. to_string ( ) ) ;
2323
2322
self . test_extern_static ( & i. ident . to_string ( ) , c_name, & rust_ty, & c_ty, mutbl)
@@ -2356,7 +2355,7 @@ struct MyResolver<'a> {
2356
2355
map : HashMap < Name , Rc < SyntaxExtension > > ,
2357
2356
}
2358
2357
2359
- impl < ' a > Resolver for MyResolver < ' a > {
2358
+ impl Resolver for MyResolver < ' _ > {
2360
2359
fn next_node_id ( & mut self ) -> ast:: NodeId {
2361
2360
self . id += 1 ;
2362
2361
ast:: NodeId :: new ( self . id )
@@ -2463,7 +2462,7 @@ struct MyVisitor<'b> {
2463
2462
map : & ' b mut HashMap < Name , Rc < SyntaxExtension > > ,
2464
2463
}
2465
2464
2466
- impl < ' a , ' b > Visitor < ' a > for MyVisitor < ' b > {
2465
+ impl < ' a > Visitor < ' a > for MyVisitor < ' _ > {
2467
2466
fn visit_item ( & mut self , item : & ' a ast:: Item ) {
2468
2467
if let ast:: ItemKind :: MacroDef ( ..) = item. node {
2469
2468
self . map . insert (
0 commit comments