Skip to content
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

Implement arbitrary_self_types #45870

Merged
merged 26 commits into from
Nov 12, 2017
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
edc8c76
add tests for the arbitrary_self_types, which won't pass yet
mikeyhew Oct 20, 2017
497397a
initial implementation of arbitrary_self_types
mikeyhew Nov 2, 2017
7dff08d
Rewrote check_method_receiver and ExplicitSelf, got a borrow checker …
mikeyhew Nov 5, 2017
a3f5866
Fix the lifetime error in ExplicitSelf
mikeyhew Nov 5, 2017
9a592e6
Improve feature gate error, and return after emitting errors instead …
mikeyhew Nov 5, 2017
d03eb2c
Fix some of the tests
mikeyhew Nov 5, 2017
aa0df3d
get the old error messages back
mikeyhew Nov 6, 2017
6fd2156
Add arbitrary_self_types feature gate error to some tests
mikeyhew Nov 7, 2017
0d739b5
Update/improve documentation of ExpliciSelf
mikeyhew Nov 7, 2017
1d29966
wrap error code in DiagnosticId::Error so it compiles
mikeyhew Nov 7, 2017
0b27dcc
modify ExplicitSelf::determine to take an `is_self_type` predicate cl…
mikeyhew Nov 8, 2017
3902643
move ExplicitSelf to rustc::ty::util, and use it to implement object …
mikeyhew Nov 8, 2017
2369746
normalize associated types in both self_ty and self_arg_ty
mikeyhew Nov 8, 2017
bbe755c
Switch from using At::eq to InferCtxt::can_eq and demand_eqtype_with_…
mikeyhew Nov 8, 2017
02ce3ac
add a NOTE comment to the object safety test so that it passes
mikeyhew Nov 8, 2017
e06cd31
Remove the error check that I think is redundant, and change the test…
mikeyhew Nov 8, 2017
0a3a46d
tidy things up a bit
mikeyhew Nov 8, 2017
0954e54
shorten line length for tidy
mikeyhew Nov 8, 2017
aa00f17
fix error message in arbitrary-self-types-not-object-safe test
mikeyhew Nov 8, 2017
7f8b003
update ui test to new error message
mikeyhew Nov 8, 2017
dcbb27a
fix the bug in region_inference where constraint origins were being o…
mikeyhew Nov 9, 2017
31d3783
fixed all the compile-fail error messages
mikeyhew Nov 9, 2017
c046fda
update test/ui/static-lifetime.stderr with new error message
mikeyhew Nov 9, 2017
5d170f0
add a comment explaining the bugfix to infer::region_inference::add_c…
mikeyhew Nov 9, 2017
ddc21d5
Don't emit the feature error if it's an invalid self type
mikeyhew Nov 9, 2017
77cd993
add run-pass tests
mikeyhew Nov 9, 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
Switch from using At::eq to InferCtxt::can_eq and demand_eqtype_with_…
…origin

I doubt this changes anything, I was just trying to fix an issue with
error messages and ended up doing this along with other things.
Committing it separately so I can undo it easily.
  • Loading branch information
mikeyhew committed Nov 8, 2017
commit bbe755c7a6b20c1340ef1d86fb30d4b91b81450e
8 changes: 4 additions & 4 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use check::{Inherited, FnCtxt};
use constrained_type_params::{identify_constrained_type_params, Parameter};

use hir::def_id::DefId;
use rustc::infer::InferOk;
use rustc::traits::{self, ObligationCauseCode};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::util::ExplicitSelf;
Expand Down Expand Up @@ -478,7 +477,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
let self_arg_ty = sig.inputs()[0];

let cause = fcx.cause(span, ObligationCauseCode::MethodReceiver);
let eq = |expected, actual| fcx.at(&cause, fcx.param_env).eq(expected, actual);
let self_arg_ty = fcx.normalize_associated_types_in(span, &self_arg_ty);
let self_arg_ty = fcx.liberate_late_bound_regions(
method.def_id,
Expand All @@ -491,9 +489,11 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
if let Some((potential_self_ty, _)) = autoderef.next() {
debug!("check_method_receiver: potential self type `{:?}` to match `{:?}`", potential_self_ty, self_ty);

if let Ok(InferOk { obligations, value: () }) = eq(self_ty, potential_self_ty) {
fcx.register_predicates(obligations);
if fcx.infcx.can_eq(fcx.param_env, self_ty, potential_self_ty).is_ok() {
autoderef.finalize();
if let Some(mut err) = fcx.demand_eqtype_with_origin(&cause, self_ty, potential_self_ty) {
err.emit();
}
break
}
} else {
Expand Down