@@ -15,72 +15,62 @@ trait NoDotNamesCheck<T, E> {
1515 fn ensure_no_dots ( & self , x : & T ) -> Result < ( ) , E > ;
1616}
1717
18- impl NoDotNamesCheck < FunctionImplementation , LintErrorPos > for DotsLinter {
19- fn ensure_no_dots ( & self , x : & FunctionImplementation ) -> Result < ( ) , LintErrorPos > {
20- self . ensure_no_dots ( & x. name ) ?;
21- self . ensure_no_dots ( & x. params )
22- }
23- }
18+ // Blanket for Positioned
2419
25- impl NoDotNamesCheck < SubImplementation , LintErrorPos > for DotsLinter {
26- fn ensure_no_dots ( & self , x : & SubImplementation ) -> Result < ( ) , LintErrorPos > {
27- self . ensure_no_dots ( & x. name ) ?;
28- self . ensure_no_dots ( & x. params )
20+ impl < T , E > NoDotNamesCheck < Positioned < T > , Positioned < E > > for DotsLinter
21+ where
22+ DotsLinter : NoDotNamesCheck < T , E > ,
23+ {
24+ fn ensure_no_dots ( & self , element : & Positioned < T > ) -> Result < ( ) , Positioned < E > > {
25+ let Positioned { element, pos } = element;
26+ self . ensure_no_dots ( element) . map_err ( |e| e. at_pos ( * pos) )
2927 }
3028}
3129
32- impl NoDotNamesCheck < Vec < Positioned < Parameter > > , LintErrorPos > for DotsLinter {
33- fn ensure_no_dots ( & self , x : & Vec < Positioned < Parameter > > ) -> Result < ( ) , LintErrorPos > {
30+ // Blanket for Vec
31+
32+ impl < T , E > NoDotNamesCheck < Vec < T > , E > for DotsLinter
33+ where
34+ DotsLinter : NoDotNamesCheck < T , E > ,
35+ {
36+ fn ensure_no_dots ( & self , x : & Vec < T > ) -> Result < ( ) , E > {
3437 x. iter ( ) . try_for_each ( |x| self . ensure_no_dots ( x) )
3538 }
3639}
3740
38- impl NoDotNamesCheck < Positioned < Parameter > , LintErrorPos > for DotsLinter {
39- fn ensure_no_dots ( & self , x : & Positioned < Parameter > ) -> Result < ( ) , LintErrorPos > {
40- let Positioned { element, pos } = x;
41- self . ensure_no_dots ( element) . map_err ( |e| e. at ( pos) )
41+ // FunctionImplementation and SubImplementation
42+
43+ impl < T > NoDotNamesCheck < SubprogramImplementation < T > , LintErrorPos > for DotsLinter
44+ where
45+ DotsLinter :
46+ NoDotNamesCheck < Positioned < T > , LintErrorPos > + NoDotNamesCheck < Parameters , LintErrorPos > ,
47+ {
48+ fn ensure_no_dots ( & self , x : & SubprogramImplementation < T > ) -> Result < ( ) , LintErrorPos > {
49+ self . ensure_no_dots ( & x. name ) ?;
50+ self . ensure_no_dots ( & x. params )
4251 }
4352}
4453
54+ // TODO the next 4 can be merged into one with a trait like AsRef<BareName>
55+
4556impl NoDotNamesCheck < Parameter , LintError > for DotsLinter {
4657 fn ensure_no_dots ( & self , x : & Parameter ) -> Result < ( ) , LintError > {
4758 self . ensure_no_dots ( & x. bare_name )
4859 }
4960}
5061
51- impl NoDotNamesCheck < DimVarPos , LintErrorPos > for DotsLinter {
52- fn ensure_no_dots ( & self , x : & DimVarPos ) -> Result < ( ) , LintErrorPos > {
53- let Positioned { element, pos } = x;
54- self . ensure_no_dots ( element) . map_err ( |e| e. at ( pos) )
55- }
56- }
57-
5862impl NoDotNamesCheck < DimVar , LintError > for DotsLinter {
5963 fn ensure_no_dots ( & self , x : & DimVar ) -> Result < ( ) , LintError > {
6064 self . ensure_no_dots ( & x. bare_name )
6165 }
6266}
6367
64- impl NoDotNamesCheck < NamePos , LintErrorPos > for DotsLinter {
65- fn ensure_no_dots ( & self , name_pos : & NamePos ) -> Result < ( ) , LintErrorPos > {
66- let name = & name_pos. element ;
67- self . ensure_no_dots ( name) . map_err ( |e| e. at ( name_pos) )
68- }
69- }
70-
7168impl NoDotNamesCheck < Name , LintError > for DotsLinter {
7269 fn ensure_no_dots ( & self , name : & Name ) -> Result < ( ) , LintError > {
7370 self . ensure_no_dots ( name. bare_name ( ) )
7471 }
7572}
7673
77- impl NoDotNamesCheck < BareNamePos , LintErrorPos > for DotsLinter {
78- fn ensure_no_dots ( & self , x : & BareNamePos ) -> Result < ( ) , LintErrorPos > {
79- let Positioned { element, pos } = x;
80- self . ensure_no_dots ( element) . map_err ( |e| e. at ( pos) )
81- }
82- }
83-
8474impl NoDotNamesCheck < BareName , LintError > for DotsLinter {
8575 fn ensure_no_dots ( & self , x : & BareName ) -> Result < ( ) , LintError > {
8676 match x. prefix ( '.' ) {
@@ -96,12 +86,6 @@ impl NoDotNamesCheck<BareName, LintError> for DotsLinter {
9686 }
9787}
9888
99- impl NoDotNamesCheck < Expressions , LintErrorPos > for DotsLinter {
100- fn ensure_no_dots ( & self , x : & Expressions ) -> Result < ( ) , LintErrorPos > {
101- x. iter ( ) . try_for_each ( |x| self . ensure_no_dots ( x) )
102- }
103- }
104-
10589impl NoDotNamesCheck < Positioned < & Expression > , LintErrorPos > for DotsLinter {
10690 fn ensure_no_dots ( & self , x : & Positioned < & Expression > ) -> Result < ( ) , LintErrorPos > {
10791 let Positioned { element, pos } = x;
0 commit comments