Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Type inference: Disable universal conditions by default #21151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hvitved wants to merge 1 commit into github:main
base: main
Choose a base branch
Loading
from hvitved:rust/disable-universal-conds-by-default
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ module SatisfiesBlanketConstraint<
predicate relevantConstraint(ArgumentTypeAndBlanketOffset ato, Type constraint) {
relevantConstraint(ato, _, constraint.(TraitType).getTrait())
}

predicate useUniversalConditions() { none() }
}

private module SatisfiesBlanketConstraint =
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2193,8 +2193,6 @@ private module MethodResolution {
exists(mc) and
constraint.(TraitType).getTrait() instanceof DerefTrait
}

predicate useUniversalConditions() { none() }
}

private module MethodCallSatisfiesDerefConstraint =
Expand Down Expand Up @@ -3566,8 +3564,6 @@ private module AwaitSatisfiesConstraintInput implements SatisfiesConstraintInput
exists(term) and
constraint.(TraitType).getTrait() instanceof FutureTrait
}

predicate useUniversalConditions() { none() }
}

pragma[nomagic]
Expand Down Expand Up @@ -3764,8 +3760,6 @@ private module ForIterableSatisfiesConstraintInput implements
t instanceof IntoIteratorTrait
)
}

predicate useUniversalConditions() { none() }
}

pragma[nomagic]
Expand Down Expand Up @@ -3817,8 +3811,6 @@ private module InvokedClosureSatisfiesConstraintInput implements
exists(term) and
constraint.(TraitType).getTrait() instanceof FnOnceTrait
}

predicate useUniversalConditions() { none() }
}

/** Gets the type of `ce` when viewed as an implementation of `FnOnce`. */
Expand Down
2 changes: 1 addition & 1 deletion rust/ql/test/library-tests/type-inference/main.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ mod method_non_parametric_trait_impl {

let thing = MyThing { a: S1 };
let i = thing.convert_to(); // $ type=i:S1 target=T::convert_to
let j = convert_to(thing); // $ type=j:S1 target=convert_to
let j = convert_to(thing); // $ target=convert_to $ MISSING: type=j:S1 -- the blanket implementation `impl<T: MyTrait<S1>> ConvertTo<S1> for T` is currently not included in the constraint analysis
}
}

Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7151,8 +7151,6 @@ inferType
| main.rs:440:17:440:21 | thing | | main.rs:224:5:227:5 | MyThing |
| main.rs:440:17:440:21 | thing | A | main.rs:235:5:236:14 | S1 |
| main.rs:440:17:440:34 | thing.convert_to() | | main.rs:235:5:236:14 | S1 |
| main.rs:441:13:441:13 | j | | main.rs:235:5:236:14 | S1 |
| main.rs:441:17:441:33 | convert_to(...) | | main.rs:235:5:236:14 | S1 |
| main.rs:441:28:441:32 | thing | | main.rs:224:5:227:5 | MyThing |
| main.rs:441:28:441:32 | thing | A | main.rs:235:5:236:14 | S1 |
| main.rs:450:26:450:29 | SelfParam | | main.rs:449:5:453:5 | Self [trait OverlappingTrait] |
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
* checked. Hence using these represent a trade-off between too many
* constraints and too few constraints being satisfied.
*/
default predicate useUniversalConditions() { any() }
default predicate useUniversalConditions() { none() }
}

module SatisfiesConstraint<
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /