mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 03:36:18 +00:00
restructure this a bit
This commit is contained in:
parent
ea0bffb571
commit
4b7f75adae
1 changed files with 34 additions and 18 deletions
|
|
@ -734,15 +734,23 @@ impl<'db> Node<'db> {
|
|||
Node::AlwaysTrue => true,
|
||||
Node::AlwaysFalse => false,
|
||||
Node::Interior(interior) => {
|
||||
// with_assignment will return None if this node's constraint causes the if_true
|
||||
// edge to become impossible. We want to ignore impossible paths, and so we treat
|
||||
// them as passing the "always satisfied" check.
|
||||
let constraint = interior.constraint(db);
|
||||
path.with_assignment(db, map, constraint.when_true(), |path| {
|
||||
let true_always_satisfied = path
|
||||
.with_assignment(db, map, constraint.when_true(), |path| {
|
||||
interior
|
||||
.if_true(db)
|
||||
.is_always_satisfied_inner(db, map, path)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
&& path
|
||||
.with_assignment(db, map, constraint.when_false(), |path| {
|
||||
.unwrap_or(true);
|
||||
if !true_always_satisfied {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ditto for the if_false branch
|
||||
path.with_assignment(db, map, constraint.when_false(), |path| {
|
||||
interior
|
||||
.if_false(db)
|
||||
.is_always_satisfied_inner(db, map, path)
|
||||
|
|
@ -775,13 +783,21 @@ impl<'db> Node<'db> {
|
|||
Node::AlwaysTrue => false,
|
||||
Node::AlwaysFalse => true,
|
||||
Node::Interior(interior) => {
|
||||
// with_assignment will return None if this node's constraint causes the if_true
|
||||
// edge to become impossible. We want to ignore impossible paths, and so we treat
|
||||
// them as passing the "never satisfied" check.
|
||||
let constraint = interior.constraint(db);
|
||||
path.with_assignment(db, map, constraint.when_true(), |path| {
|
||||
let true_never_satisfied = path
|
||||
.with_assignment(db, map, constraint.when_true(), |path| {
|
||||
interior.if_true(db).is_never_satisfied_inner(db, map, path)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
&& path
|
||||
.with_assignment(db, map, constraint.when_false(), |path| {
|
||||
.unwrap_or(true);
|
||||
if !true_never_satisfied {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ditto for the if_false branch
|
||||
path.with_assignment(db, map, constraint.when_false(), |path| {
|
||||
interior
|
||||
.if_false(db)
|
||||
.is_never_satisfied_inner(db, map, path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue