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

Universes #55517

Merged
merged 30 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5f0fe8f
remove `commit_if_ok` wrapper
nikomatsakis Oct 15, 2018
79efed8
remove wrapper functions that had no purpose
nikomatsakis Oct 15, 2018
4b5f274
make evaluation track whether outlives relationships mattered
nikomatsakis Sep 20, 2018
4170829
introduce ability to detect region constraints from snapshot
nikomatsakis Oct 16, 2018
904a0bd
select.rs: unsizing coercion should use a subtype
nikomatsakis Dec 27, 2018
eba2ae5
WIP: wfcheck ability to detect
nikomatsakis Dec 27, 2018
b68fad6
universe transition
nikomatsakis Sep 8, 2018
652fd2e
add tests exercising `exists<'a> { forall<'b> { .. } }` pattern
nikomatsakis Oct 30, 2018
78705b5
tests: move coherence-subtyping from run-pass to compile-fail
nikomatsakis Oct 30, 2018
d3c96ff
tests: worse diagnostics, but basically same errors
nikomatsakis Oct 30, 2018
c8e0a90
tests: cases where we now do the right thing but did not before
nikomatsakis Dec 31, 2018
a2d9179
WIP other test changes
nikomatsakis Dec 31, 2018
0b03b9b
remove outdated `rustc_driver` tests
nikomatsakis Oct 31, 2018
995192a
make `get_highlight_region_for_regionvid` only affect re-vid
nikomatsakis Nov 17, 2018
6a6d2f4
dump out the exact state in error reporting debugs
nikomatsakis Nov 17, 2018
37b0b3e
generalize region highlights into a struct
nikomatsakis Nov 17, 2018
1597f2a
add the ability to highlight placeholders
nikomatsakis Nov 17, 2018
0a61d68
introduce placeholder-placeholder errors for trait matching
nikomatsakis Nov 17, 2018
6cbbee1
apply the new placeholder errors even with just one placeholder
nikomatsakis Nov 18, 2018
77924de
refactor highlighting to take any RegionKind, making it more general
nikomatsakis Nov 18, 2018
7bc3f55
apply the same logic to ConcreteFailure errors
nikomatsakis Nov 19, 2018
a24e04d
say "the lifetime" instead of "some lifetime" when it feels right
nikomatsakis Nov 19, 2018
bc4404c
improve handling for subtype
nikomatsakis Nov 19, 2018
cf2f7cc
pacify the mercilous tidy
nikomatsakis Nov 19, 2018
1db7193
address tmandry nits
nikomatsakis Nov 19, 2018
c04563e
add some comments about lifetimes etc
nikomatsakis Nov 19, 2018
13ea9b8
pacify the mercilous eddyb ;)
nikomatsakis Nov 19, 2018
2c17af0
track if any region constraints involved placeholders
nikomatsakis Nov 20, 2018
4c8fd2e
try to detect affected code and direct people to #56105
nikomatsakis Nov 20, 2018
8e89184
rename `type_moves_by_default` to `type_is_copy_modulo_regions`
nikomatsakis Nov 20, 2018
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
60 changes: 48 additions & 12 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

ty::ReEmpty => ("the empty lifetime".to_owned(), None),

ty::RePlaceholder(_) => (format!("any other region"), None),

// FIXME(#13998) RePlaceholder should probably print like
// ReFree rather than dumping Debug output on the user.
//
// We shouldn't really be having unification failures with ReVar
// and ReLateBound though.
ty::RePlaceholder(..) | ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => {
ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => {
(format!("lifetime {:?}", region), None)
}

Expand Down Expand Up @@ -324,8 +326,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// the error. If all of these fails, we fall back to a rather
// general bit of code that displays the error information
RegionResolutionError::ConcreteFailure(origin, sub, sup) => {
self.report_concrete_failure(region_scope_tree, origin, sub, sup)
.emit();
if sub.is_placeholder() || sup.is_placeholder() {
self.report_placeholder_failure(region_scope_tree, origin, sub, sup)
.emit();
} else {
self.report_concrete_failure(region_scope_tree, origin, sub, sup)
.emit();
}
}

RegionResolutionError::GenericBoundFailure(origin, param_ty, sub) => {
Expand All @@ -339,20 +346,39 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}

RegionResolutionError::SubSupConflict(
_,
var_origin,
sub_origin,
sub_r,
sup_origin,
sup_r,
) => {
self.report_sub_sup_conflict(
region_scope_tree,
var_origin,
sub_origin,
sub_r,
sup_origin,
sup_r,
);
if sub_r.is_placeholder() {
self.report_placeholder_failure(
region_scope_tree,
sub_origin,
sub_r,
sup_r,
)
.emit();
} else if sup_r.is_placeholder() {
self.report_placeholder_failure(
region_scope_tree,
sup_origin,
sub_r,
sup_r,
)
.emit();
} else {
self.report_sub_sup_conflict(
region_scope_tree,
var_origin,
sub_origin,
sub_r,
sup_origin,
sup_r,
);
}
}
}
}
Expand Down Expand Up @@ -407,7 +433,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
errors.sort_by_key(|u| match *u {
RegionResolutionError::ConcreteFailure(ref sro, _, _) => sro.span(),
RegionResolutionError::GenericBoundFailure(ref sro, _, _) => sro.span(),
RegionResolutionError::SubSupConflict(ref rvo, _, _, _, _) => rvo.span(),
RegionResolutionError::SubSupConflict(_, ref rvo, _, _, _, _) => rvo.span(),
});
errors
}
Expand Down Expand Up @@ -1306,6 +1332,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {

match (&sup_origin, &sub_origin) {
(&infer::Subtype(ref sup_trace), &infer::Subtype(ref sub_trace)) => {
debug!("report_sub_sup_conflict: var_origin={:?}", var_origin);
debug!("report_sub_sup_conflict: sub_region={:?}", sub_region);
debug!("report_sub_sup_conflict: sub_origin={:?}", sub_origin);
debug!("report_sub_sup_conflict: sup_region={:?}", sup_region);
debug!("report_sub_sup_conflict: sup_origin={:?}", sup_origin);
debug!("report_sub_sup_conflict: sup_trace={:?}", sup_trace);
debug!("report_sub_sup_conflict: sub_trace={:?}", sub_trace);
debug!("report_sub_sup_conflict: sup_trace.values={:?}", sup_trace.values);
debug!("report_sub_sup_conflict: sub_trace.values={:?}", sub_trace.values);

if let (Some((sup_expected, sup_found)), Some((sub_expected, sub_found))) = (
self.values_str(&sup_trace.values),
self.values_str(&sub_trace.values),
Expand Down
8 changes: 5 additions & 3 deletions src/librustc/infer/error_reporting/nice_region_error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use util::common::ErrorReported;
mod different_lifetimes;
mod find_anon_type;
mod named_anon_conflict;
mod placeholder_error;
mod outlives_closure;
mod static_impl_trait;
mod util;
Expand Down Expand Up @@ -58,19 +59,20 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> {
// Due to the improved diagnostics returned by the MIR borrow checker, only a subset of
// the nice region errors are required when running under the MIR borrow checker.
self.try_report_named_anon_conflict()
.or_else(|| self.try_report_placeholder_conflict())
}

pub fn try_report(&self) -> Option<ErrorReported> {
self.try_report_named_anon_conflict()
self.try_report_from_nll()
.or_else(|| self.try_report_anon_anon_conflict())
.or_else(|| self.try_report_outlives_closure())
.or_else(|| self.try_report_static_impl_trait())
}

pub fn get_regions(&self) -> (Span, ty::Region<'tcx>, ty::Region<'tcx>) {
match (&self.error, self.regions) {
(&Some(ConcreteFailure(ref origin, sub, sup)), None) => (origin.span(), sub, sup),
(&Some(SubSupConflict(_, ref origin, sub, _, sup)), None) => (origin.span(), sub, sup),
(Some(ConcreteFailure(origin, sub, sup)), None) => (origin.span(), sub, sup),
(Some(SubSupConflict(_, _, origin, sub, _, sup)), None) => (origin.span(), sub, sup),
(None, Some((span, sub, sup))) => (span, sub, sup),
(Some(_), Some(_)) => panic!("incorrectly built NiceRegionError"),
_ => panic!("trying to report on an incorrect lifetime failure"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
/// ...because it cannot outlive this closure
/// ```
pub(super) fn try_report_outlives_closure(&self) -> Option<ErrorReported> {
if let Some(SubSupConflict(origin,
if let Some(SubSupConflict(_,
origin,
ref sub_origin,
_,
ref sup_origin,
Expand Down
Loading