diff --git a/Cargo.lock b/Cargo.lock index 3e8f4640d..4baf6e757 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2199,6 +2199,7 @@ dependencies = [ name = "craft-design-lint" version = "0.1.0" dependencies = [ + "dunce", "proc-macro2", "quote", "serde", diff --git a/crates/design-lint/Cargo.toml b/crates/design-lint/Cargo.toml index fc8e27bef..ccf1124dd 100644 --- a/crates/design-lint/Cargo.toml +++ b/crates/design-lint/Cargo.toml @@ -10,6 +10,7 @@ repository.workspace = true publish = false [dependencies] +dunce = "1" proc-macro2 = { version = "1", features = ["span-locations"] } quote = "1" serde = { workspace = true } diff --git a/crates/design-lint/src/structure.rs b/crates/design-lint/src/structure.rs index 1e591b23d..1dd5b1da1 100644 --- a/crates/design-lint/src/structure.rs +++ b/crates/design-lint/src/structure.rs @@ -88,7 +88,8 @@ fn unknown_crates(root: &Path, meta: &Metadata, maps: &LayerMaps) -> Vec Vec { // Source paths come from cargo metadata, which resolves `..` and links; the root must be resolved the same way. - let root = &std::fs::canonicalize(root).unwrap_or_else(|_| root.to_owned()); + // `dunce` drops the `\\?\` prefix Windows' canonical paths carry, which metadata's paths lack. + let root = &dunce::canonicalize(root).unwrap_or_else(|_| root.to_owned()); let mut sites = Vec::new(); for tree in index.trees.values() { let mut files: Vec<&PathBuf> = tree.modules.values().map(|m| &m.file).collect(); @@ -96,7 +97,7 @@ fn source_sites(root: &Path, index: &Index) -> Vec { files.dedup(); for file in files { if let Some(parsed) = index.files.get(file) { - sites.extend(scan_parsed(&relative(root, file).to_string_lossy(), &parsed.src, Some(&parsed.file))); + sites.extend(scan_parsed(&relative(root, file).to_string_lossy().replace('\\', "/"), &parsed.src, Some(&parsed.file))); } } } diff --git a/crates/design-lint/tests/contract_rules.rs b/crates/design-lint/tests/contract_rules.rs index 33a6ccff5..90ac096ac 100644 --- a/crates/design-lint/tests/contract_rules.rs +++ b/crates/design-lint/tests/contract_rules.rs @@ -83,7 +83,7 @@ fn type_facts_cross_files_of_a_crate() { let root = Path::new(FIXTURES).join("tree"); let scope = scope().layer("src/chips", 5).crate_tree(&root, "fx", "src/lib.rs").unwrap(); let report = check_with_scope(&Config::new(["src/chips"]), &root, &scope).unwrap(); - let hits: Vec<_> = report.findings.iter().map(|f| (f.path.display().to_string(), f.rule)).collect(); + let hits: Vec<_> = report.findings.iter().map(|f| (f.path.display().to_string().replace('\\', "/"), f.rule)).collect(); assert_eq!( hits, [ diff --git a/design/exceptions/craft-ui-panels/docking.toml b/design/exceptions/craft-ui-panels/docking.toml index 5d9ad92a3..1bfc5dd49 100644 --- a/design/exceptions/craft-ui-panels/docking.toml +++ b/design/exceptions/craft-ui-panels/docking.toml @@ -16,3 +16,10 @@ path = "crates/ui-panels/src/docking/iconic/stories.rs" reason = "A story sizes its stage from the rail token." count = 1 +[[exception]] +name = "iconic-trial-rooms" +kind = "exempt" +rule = "literal-size" +path = "crates/ui-panels/src/docking/iconic/trials.rs" +reason = "Trial rooms, not looks." +count = 1