Move is_hir_ty_cfg_dependant to util,

add stuff on pointer::cast` to the document for `cast_ptr_alignment`
and fix line numbers in the test.
This commit is contained in:
rail
2021-01-08 14:15:12 +13:00
parent f50ded0592
commit ee9b47dae6
3 changed files with 22 additions and 20 deletions

View File

@@ -1686,6 +1686,18 @@ macro_rules! unwrap_cargo_metadata {
}};
}
pub fn is_hir_ty_cfg_dependant(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
if_chain! {
if let TyKind::Path(QPath::Resolved(_, path)) = ty.kind;
if let Res::Def(_, def_id) = path.res;
then {
cx.tcx.has_attr(def_id, sym::cfg) || cx.tcx.has_attr(def_id, sym::cfg_attr)
} else {
false
}
}
}
#[cfg(test)]
mod test {
use super::{reindent_multiline, without_block_comments};