Skip to content

Conversation

@nikomatsakis
Copy link
Contributor

Per our discussion today, we are moving towards modeling polonius-α which will require a context-dependent notion of outlives. This will also imply merging the type-check + borrow-check rules. These refactorings move us closer to that world.

r? @lqd or @jackh726

- Fn(fn_id) values now return FnDef types instead of storing in side table
- Call sites extract function signature from FnDef type
- Removes callee_input_tys field from TypeckEnv entirely
- More correct type system behavior
- Removes ret_place_is_initialised field from TypeckEnv
- Comments out return place initialization checks (filed as issue rust-lang#209)
- Updates test expectations for struct format changes
- Marks test_uninitialised_return_type with FIXME(rust-lang#209) - should fail when issue is resolved

This enables using &self for TypeckEnv methods instead of &mut self, supporting the pending_outlives refactoring.
- Remove pending_outlives field from TypeckEnv struct
- Thread &mut Set<PendingOutlives> parameter through all type checking functions
- Update borrow_check to take pending_outlives as parameter
- Update transitively_outlived_by to take pending_outlives parameter
- Most TypeckEnv methods now use &self instead of &mut self (except those that still mutate other fields)
- Update test expectations for struct format changes

This makes outlives constraint collection more explicit and functional rather than hidden mutable state.
}

/// The borrow checker's job is to pick up where the type-checker left off:
/// Given the `TypeckEnv`, which includes a (populated) list of `pending_outlives`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we've extracted the outlives out of the env, this doc comment was slightly invalidated, so maybe:

Suggested change
/// Given the `TypeckEnv`, which includes a (populated) list of `pending_outlives`
/// Given the `TypeckEnv`, and a (populated) list of `pending_outlives`

CrateItem::NegTraitImpl(i) => self.check_neg_trait_impl(i),
CrateItem::Test(t) => self.check_test(t),
CrateItem::FeatureGate(_feature_gate) => {
Ok(ProofTree::leaf("feature gates are OK with me!"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can add a comment like "TODO: reject duplicate gates like rustc"

}

// Test the behaviour of having unitialised return local variable.
// FIXME(#209): This test should fail but currently passes due to removed return place initialization check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could maybe just #[ignore] that test with the comment, rather than changing the assertion from err to ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants