Skip to content

Commit e4865b8

Browse files
committed
Address review comment
1 parent f23351a commit e4865b8

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,17 @@ private predicate summaryModelRelevant(
132132
QlBuiltins::ExtensionId madId
133133
) {
134134
exists(boolean isExact | summaryModel(f, input, output, kind, provenance, isExact, madId) |
135-
(
136-
provenance.isManual()
137-
or
138-
// only apply generated models to functions not defined in source code, and
139-
// when there are no exact manual models for the functions
140-
provenance.isGenerated() and
141-
not any(Provenance manual | summaryModel(f, _, _, _, manual, true, _)).isManual() and
142-
not f.fromSource()
143-
) and
144-
(
145-
isExact = true
146-
or
147-
// only apply trait models to concrete implementations when they are not
148-
// defined in source code, and when there are no exact model for the functions
149-
isExact = false and
150-
not summaryModel(f, _, _, _, provenance, true, _) and
151-
not f.fromSource()
152-
)
135+
// Only apply generated or inherited models to functions in library code and
136+
// when no strictly better model exists
137+
if provenance.isGenerated() or isExact = false
138+
then
139+
not f.fromSource() and
140+
not exists(Provenance other | summaryModel(f, _, _, _, other, true, _) |
141+
provenance.isGenerated() and other.isManual()
142+
or
143+
provenance = other and isExact = false
144+
)
145+
else any()
153146
)
154147
}
155148

0 commit comments

Comments
 (0)