Skip to content

Commit ca85746

Browse files
authored
Merge pull request #60 from coord-e/coord-e/thrust-ignored
thrust::ignored
2 parents 0744b10 + 62d7f67 commit ca85746

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

src/analyze/annot.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ pub fn predicate_path() -> [Symbol; 2] {
4545
[Symbol::intern("thrust"), Symbol::intern("predicate")]
4646
}
4747

48+
pub fn ignored_path() -> [Symbol; 2] {
49+
[Symbol::intern("thrust"), Symbol::intern("ignored")]
50+
}
51+
4852
/// A [`annot::Resolver`] implementation for resolving function parameters.
4953
///
5054
/// The parameter names and their sorts needs to be configured via

src/analyze/crate_.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::HashSet;
44

55
use rustc_hir::def_id::CRATE_DEF_ID;
66
use rustc_middle::ty::{self as mir_ty, TyCtxt};
7-
use rustc_span::def_id::{DefId, LocalDefId};
7+
use rustc_span::def_id::LocalDefId;
88

99
use crate::analyze;
1010
use crate::chc;
@@ -23,8 +23,8 @@ use crate::rty::{self, ClauseBuilderExt as _};
2323
pub struct Analyzer<'tcx, 'ctx> {
2424
tcx: TyCtxt<'tcx>,
2525
ctx: &'ctx mut analyze::Analyzer<'tcx>,
26-
trusted: HashSet<DefId>,
27-
predicates: HashSet<DefId>,
26+
27+
skip_analysis: HashSet<LocalDefId>,
2828
}
2929

3030
impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
@@ -75,17 +75,23 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
7575

7676
if analyzer.is_annotated_as_trusted() {
7777
assert!(analyzer.is_fully_annotated());
78-
self.trusted.insert(local_def_id.to_def_id());
78+
self.skip_analysis.insert(local_def_id);
7979
}
8080

8181
if analyzer.is_annotated_as_extern_spec_fn() {
8282
assert!(analyzer.is_fully_annotated());
83-
self.trusted.insert(local_def_id.to_def_id());
83+
self.skip_analysis.insert(local_def_id);
84+
}
85+
86+
if analyzer.is_annotated_as_ignored() {
87+
self.skip_analysis.insert(local_def_id);
88+
return;
8489
}
8590

8691
if analyzer.is_annotated_as_predicate() {
87-
self.predicates.insert(local_def_id.to_def_id());
8892
analyzer.analyze_predicate_definition(local_def_id);
93+
self.skip_analysis.insert(local_def_id);
94+
return;
8995
}
9096

9197
use mir_ty::TypeVisitableExt as _;
@@ -107,14 +113,10 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
107113
if !self.tcx.def_kind(*local_def_id).is_fn_like() {
108114
continue;
109115
};
110-
if self.trusted.contains(&local_def_id.to_def_id()) {
111-
tracing::info!(?local_def_id, "trusted");
112-
continue;
113-
}
114-
if self.predicates.contains(&local_def_id.to_def_id()) {
115-
tracing::info!(?local_def_id, "predicate");
116+
if self.skip_analysis.contains(local_def_id) {
116117
continue;
117118
}
119+
118120
let Some(expected) = self.ctx.concrete_def_ty(local_def_id.to_def_id()) else {
119121
// when the local_def_id is deferred it would be skipped
120122
continue;
@@ -221,13 +223,11 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
221223
impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
222224
pub fn new(ctx: &'ctx mut analyze::Analyzer<'tcx>) -> Self {
223225
let tcx = ctx.tcx;
224-
let trusted = HashSet::default();
225-
let predicates = HashSet::default();
226+
let skip_analysis = HashSet::default();
226227
Self {
227228
ctx,
228229
tcx,
229-
trusted,
230-
predicates,
230+
skip_analysis,
231231
}
232232
}
233233

src/analyze/local_def.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
202202
.is_some()
203203
}
204204

205+
pub fn is_annotated_as_ignored(&self) -> bool {
206+
self.tcx
207+
.get_attrs_by_path(
208+
self.local_def_id.to_def_id(),
209+
&analyze::annot::ignored_path(),
210+
)
211+
.next()
212+
.is_some()
213+
}
214+
205215
// TODO: unify this logic with extraction functions above
206216
pub fn is_fully_annotated(&self) -> bool {
207217
let has_require = self

0 commit comments

Comments
 (0)