Skip to content

change the strategy for diverging types #40224

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

Merged
merged 36 commits into from
Mar 30, 2017
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
276bba9
refactor if so that the "then type" is an expression
nikomatsakis Mar 9, 2017
6c02272
update comment
nikomatsakis Mar 9, 2017
6a47fa1
remove unneeded `&` that now fails to coerce
nikomatsakis Mar 30, 2017
066d44b
refactor the `targeted_by_break` field
nikomatsakis Mar 22, 2017
4c6c26e
change the strategy for diverging types
nikomatsakis Mar 3, 2017
555b6d6
add some debug logs to type_variable.rs
nikomatsakis Mar 17, 2017
27f4b57
add a `TypeVariableOrigin` we'll use later (`DerivingFn`)
nikomatsakis Mar 17, 2017
eeb6447
add an `ObligationCauseCode` we'll use later (`ReturnNoExpression`)
nikomatsakis Mar 17, 2017
dad3140
introduce (but do not yet use) a `CoerceMany` API
nikomatsakis Mar 17, 2017
56847af
port the match code to use `CoerceMany`
nikomatsakis Mar 17, 2017
b725272
port if-then-else to use `CoerceMany`
nikomatsakis Mar 17, 2017
a6e6be5
port `return` expressions to use `CoerceMany`
nikomatsakis Mar 17, 2017
4967f1a
document the diverges flag etc
nikomatsakis Mar 17, 2017
1ae620b
do not eagerly convert `!` to a diverging variable
nikomatsakis Mar 17, 2017
16a71cc
rework how we handle the type of loops
nikomatsakis Mar 17, 2017
140165f
rewrite `ExprArray` processing to use `CoerceMany`
nikomatsakis Mar 17, 2017
cecccd9
whitespace changes, debug message
nikomatsakis Mar 17, 2017
52e524a
make `try_find_coercion_lub` private; we always use `CoerceMany`
nikomatsakis Mar 17, 2017
5cd99aa
more detailed tests around diverging type variables
nikomatsakis Mar 17, 2017
2f526cc
we now get an extra unreachable code warning in this test
nikomatsakis Mar 17, 2017
f11b7d3
add regression test for #39808
nikomatsakis Mar 18, 2017
a60e27e
pacify the mercilous tidy
nikomatsakis Mar 21, 2017
609bfe8
cherry-pick over the tests I wrote for the reachability code
nikomatsakis Mar 21, 2017
bad7948
avoid allocating a vector when the coercion sites are known upfront
nikomatsakis Mar 21, 2017
f837064
coercion now depends on whether the expression diverges
nikomatsakis Mar 24, 2017
d448329
fix handling of blocks with `CoerceMany`
nikomatsakis Mar 24, 2017
127a7d6
rename `only_has_type_or_fresh_var` to `coercion_target_type`
nikomatsakis Mar 24, 2017
d08a6da
remove `Clone` from `FnCtxt`
nikomatsakis Mar 22, 2017
8c6156e
have coercion supply back the target type
nikomatsakis Mar 23, 2017
7eeddb4
add test illustrating current "coerce to `!`" behavior
nikomatsakis Mar 24, 2017
8450add
fix `X as !` behavior
nikomatsakis Mar 24, 2017
1b5768d
document `diverges` more correctly
nikomatsakis Mar 24, 2017
e97fc52
kill the graphviz-flowgraph tests
nikomatsakis Mar 24, 2017
fb99d87
update UI test
nikomatsakis Mar 25, 2017
744f666
fix error message for issue-10176.rs
nikomatsakis Mar 26, 2017
2414222
remove comments that were tripping up pretty printer
nikomatsakis Mar 27, 2017
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
Prev Previous commit
Next Next commit
rename only_has_type_or_fresh_var to coercion_target_type
  • Loading branch information
nikomatsakis committed Mar 30, 2017
commit 127a7d643d70dea605ca479c12a32f450d985b09
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> {

/// Like `only_has_type`, but instead of returning `None` if no
/// hard constraint exists, creates a fresh type variable.
fn only_has_type_or_fresh_var(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, span: Span) -> Ty<'tcx> {
fn coercion_target_type(self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, span: Span) -> Ty<'tcx> {
self.only_has_type(fcx)
.unwrap_or_else(|| fcx.next_ty_var(TypeVariableOrigin::MiscVariable(span)))
}
Expand Down Expand Up @@ -2862,7 +2862,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// `expected` if it represents a *hard* constraint
// (`only_has_type`); otherwise, we just go with a
// fresh type variable.
let coerce_to_ty = expected.only_has_type_or_fresh_var(self, sp);
let coerce_to_ty = expected.coercion_target_type(self, sp);
let mut coerce: DynamicCoerceMany = CoerceMany::new(coerce_to_ty);

let if_cause = self.cause(sp, ObligationCauseCode::IfExpression);
Expand Down Expand Up @@ -3683,7 +3683,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let coerce = match source {
// you can only use break with a value from a normal `loop { }`
hir::LoopSource::Loop => {
let coerce_to = expected.only_has_type_or_fresh_var(self, body.span);
let coerce_to = expected.coercion_target_type(self, body.span);
Some(CoerceMany::new(coerce_to))
}

Expand Down