Skip to content

Commit

Permalink
Emit crate info for UnmatchedSkip
Browse files Browse the repository at this point in the history
Helps with (but doesn't fix) EmbarkStudios#264
  • Loading branch information
daviddrysdale committed Aug 13, 2022
1 parent 1188b6d commit cfd6917
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/bans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ pub fn check(
file: file_id,
span: skip.span,
},
skipped_krate: &skip.value,
});
}

Expand Down
19 changes: 15 additions & 4 deletions src/bans/diags.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
bans::KrateId,
diag::{CfgCoord, Check, Diag, Diagnostic, KrateCoord, Label, Pack, Severity},
Krate,
};
Expand Down Expand Up @@ -126,14 +127,24 @@ impl<'a> From<Wildcards<'a>> for Pack {
}
}

pub(crate) struct UnmatchedSkip {
pub(crate) struct UnmatchedSkip<'a> {
pub(crate) skip_cfg: CfgCoord,
pub(crate) skipped_krate: &'a KrateId,
}

impl From<UnmatchedSkip> for Diag {
fn from(us: UnmatchedSkip) -> Self {
impl<'a> From<UnmatchedSkip<'a>> for Diag {
fn from(us: UnmatchedSkip<'a>) -> Self {
Diagnostic::new(Severity::Warning)
.with_message("skipped crate was not encountered")
.with_message(match &us.skipped_krate.version {
Some(version) => format!(
"skipped crate '{} = {}' was not encountered",
us.skipped_krate.name, version
),
None => format!(
"skipped crate '{}' was not encountered",
us.skipped_krate.name
),
})
.with_code("B007")
.with_labels(vec![us
.skip_cfg
Expand Down

0 comments on commit cfd6917

Please sign in to comment.