@@ -7,7 +7,24 @@ use std::{
7
7
use crate :: ExitStatus ;
8
8
9
9
pub struct LintCrateSpec < ' a > {
10
+ /// Optional package name, exists if supplied from config:
11
+ /// ```toml
12
+ /// lint_a = { path = "" }
13
+ /// # `lint_a` is the package_name
14
+ /// lint_b = { path = "", package = "lint_c"}
15
+ /// # `lint_c` is the package name
16
+ /// ```
17
+ /// if the lint crate was supplied only from path, this is `None`, for example in case of
18
+ /// command-line arguments:
19
+ ///
20
+ /// `--lints ./marker_lints`
21
+ ///
22
+ /// where `./marker_lints` is `dir`, and `package_name` in this case is empty.
23
+ ///
24
+ /// Setting this to `None` won't validate the package name when building the package with
25
+ /// [`build()`](`Self::build`)
10
26
package_name : Option < & ' a str > ,
27
+ /// Path to lint crate
11
28
dir : & ' a Path ,
12
29
}
13
30
@@ -17,22 +34,20 @@ impl<'a> LintCrateSpec<'a> {
17
34
}
18
35
19
36
/// Currently only checks for semicolons, can be extended in the future
20
- pub fn validate ( & self ) -> bool {
21
- self . dir . to_string_lossy ( ) . contains ( ';' )
37
+ pub fn is_valid ( & self ) -> bool {
38
+ ! self . dir . to_string_lossy ( ) . contains ( ';' )
22
39
}
23
40
24
- pub fn build_self ( & self , target_dir : & Path , verbose : bool ) -> Result < PathBuf , ExitStatus > {
41
+ /// Creates a debug build for this crate. The path of the build library
42
+ /// will be returned, if the operation was successful.
43
+ pub fn build ( & self , target_dir : & Path , verbose : bool ) -> Result < PathBuf , ExitStatus > {
25
44
build_local_lint_crate ( self , target_dir, verbose)
26
45
}
27
46
}
28
47
29
48
/// This creates a debug build for a local crate. The path of the build library
30
49
/// will be returned, if the operation was successful.
31
- pub fn build_local_lint_crate (
32
- krate : & LintCrateSpec < ' _ > ,
33
- target_dir : & Path ,
34
- verbose : bool ,
35
- ) -> Result < PathBuf , ExitStatus > {
50
+ fn build_local_lint_crate ( krate : & LintCrateSpec < ' _ > , target_dir : & Path , verbose : bool ) -> Result < PathBuf , ExitStatus > {
36
51
if !krate. dir . exists ( ) {
37
52
eprintln ! ( "The given lint can't be found, searched at: `{}`" , krate. dir. display( ) ) ;
38
53
return Err ( ExitStatus :: LintCrateNotFound ) ;
0 commit comments