collect unused unsafe code
FIXME: de-uglify
This commit is contained in:
parent
cd279a5b98
commit
12aedc833c
10 changed files with 233 additions and 86 deletions
|
|
@ -482,7 +482,7 @@ define_dep_nodes!( <'tcx>
|
|||
[] BorrowCheckKrate,
|
||||
[] BorrowCheck(DefId),
|
||||
[] MirBorrowCheck(DefId),
|
||||
[] UnsafetyViolations(DefId),
|
||||
[] UnsafetyCheckResult(DefId),
|
||||
|
||||
[] Reachability,
|
||||
[] MirKeys,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ impl_stable_hash_for!(struct mir::LocalDecl<'tcx> {
|
|||
impl_stable_hash_for!(struct mir::UpvarDecl { debug_name, by_ref });
|
||||
impl_stable_hash_for!(struct mir::BasicBlockData<'tcx> { statements, terminator, is_cleanup });
|
||||
impl_stable_hash_for!(struct mir::UnsafetyViolation { source_info, description, lint_node_id });
|
||||
impl_stable_hash_for!(struct mir::UnsafetyCheckResult { violations, unsafe_blocks });
|
||||
|
||||
impl<'gcx> HashStable<StableHashingContext<'gcx>>
|
||||
for mir::Terminator<'gcx> {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ use std::cell::Ref;
|
|||
use std::fmt::{self, Debug, Formatter, Write};
|
||||
use std::{iter, u32};
|
||||
use std::ops::{Index, IndexMut};
|
||||
use std::rc::Rc;
|
||||
use std::vec::IntoIter;
|
||||
use syntax::ast::{self, Name};
|
||||
use syntax_pos::Span;
|
||||
|
|
@ -1683,6 +1684,15 @@ pub struct UnsafetyViolation {
|
|||
pub lint_node_id: Option<ast::NodeId>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct UnsafetyCheckResult {
|
||||
/// Violations that are propagated *upwards* from this function
|
||||
pub violations: Rc<[UnsafetyViolation]>,
|
||||
/// unsafe blocks in this function, along with whether they are used. This is
|
||||
/// used for the "unused_unsafe" lint.
|
||||
pub unsafe_blocks: Rc<[(ast::NodeId, bool)]>,
|
||||
}
|
||||
|
||||
/// The layout of generator state
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct GeneratorLayout<'tcx> {
|
||||
|
|
|
|||
|
|
@ -171,9 +171,8 @@ define_maps! { <'tcx>
|
|||
/// expression defining the closure.
|
||||
[] fn closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
|
||||
|
||||
/// Unsafety violations for this def ID.
|
||||
[] fn unsafety_violations: UnsafetyViolations(DefId)
|
||||
-> Rc<[mir::UnsafetyViolation]>,
|
||||
/// The result of unsafety-checking this def-id.
|
||||
[] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
|
||||
|
||||
/// The signature of functions and closures.
|
||||
[] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
|
||||
|
|
|
|||
|
|
@ -720,7 +720,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
|
|||
|
||||
DepKind::BorrowCheck => { force!(borrowck, def_id!()); }
|
||||
DepKind::MirBorrowCheck => { force!(mir_borrowck, def_id!()); }
|
||||
DepKind::UnsafetyViolations => { force!(unsafety_violations, def_id!()); }
|
||||
DepKind::UnsafetyCheckResult => { force!(unsafety_check_result, def_id!()); }
|
||||
DepKind::Reachability => { force!(reachable_set, LOCAL_CRATE); }
|
||||
DepKind::MirKeys => { force!(mir_keys, LOCAL_CRATE); }
|
||||
DepKind::CrateVariances => { force!(crate_variances, LOCAL_CRATE); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue