adding macro, cleaning up code
This commit is contained in:
parent
b569094d94
commit
cb563a93dc
@ -46,22 +46,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Determine whether the sub and sup consist of both anonymous (elided) regions.
|
// Determine whether the sub and sup consist of both anonymous (elided) regions.
|
||||||
let (ty_sup, ty_sub, scope_def_id_sup, scope_def_id_sub, bregion_sup, bregion_sub) =
|
let anon_reg_sup = or_false!(self.is_suitable_anonymous_region(sup));
|
||||||
if let (Some(anon_reg_sup), Some(anon_reg_sub)) =
|
|
||||||
(self.is_suitable_anonymous_region(sup), self.is_suitable_anonymous_region(sub)) {
|
let anon_reg_sub = or_false!(self.is_suitable_anonymous_region(sub));
|
||||||
let (def_id_sup, br_sup, def_id_sub, br_sub) = (anon_reg_sup.def_id,
|
let scope_def_id_sup = anon_reg_sup.def_id;
|
||||||
anon_reg_sup.boundregion,
|
let bregion_sup = anon_reg_sup.boundregion;
|
||||||
anon_reg_sub.def_id,
|
let scope_def_id_sub = anon_reg_sub.def_id;
|
||||||
anon_reg_sub.boundregion);
|
let bregion_sub = anon_reg_sub.boundregion;
|
||||||
if let (Some(anonarg_sup), Some(anonarg_sub)) =
|
|
||||||
(self.find_anon_type(sup, &br_sup), self.find_anon_type(sub, &br_sub)) {
|
let ty_sup = or_false!(self.find_anon_type(sup, &bregion_sup));
|
||||||
(anonarg_sup, anonarg_sub, def_id_sup, def_id_sub, br_sup, br_sub)
|
|
||||||
} else {
|
let ty_sub = or_false!(self.find_anon_type(sub, &bregion_sub));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
let (main_label, label1, label2) = if let (Some(sup_arg), Some(sub_arg)) =
|
let (main_label, label1, label2) = if let (Some(sup_arg), Some(sub_arg)) =
|
||||||
(self.find_arg_with_anonymous_region(sup, sup),
|
(self.find_arg_with_anonymous_region(sup, sup),
|
||||||
@ -105,7 +100,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct_span_err!(self.tcx.sess, span, E0623, "lifetime mismatch")
|
struct_span_err!(self.tcx.sess, span, E0623, "lifetime mismatch")
|
||||||
.span_label(ty_sup.span, main_label)
|
.span_label(ty_sup.span, main_label)
|
||||||
.span_label(ty_sub.span, format!(""))
|
.span_label(ty_sub.span, format!(""))
|
||||||
|
@ -75,8 +75,10 @@ use errors::{DiagnosticBuilder, DiagnosticStyledString};
|
|||||||
mod note;
|
mod note;
|
||||||
|
|
||||||
mod need_type_info;
|
mod need_type_info;
|
||||||
mod util;
|
|
||||||
mod named_anon_conflict;
|
mod named_anon_conflict;
|
||||||
|
#[macro_use]
|
||||||
|
mod util;
|
||||||
mod anon_anon_conflict;
|
mod anon_anon_conflict;
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
@ -16,6 +16,15 @@ use ty::{self, Region};
|
|||||||
use hir::def_id::DefId;
|
use hir::def_id::DefId;
|
||||||
use hir::map as hir_map;
|
use hir::map as hir_map;
|
||||||
|
|
||||||
|
macro_rules! or_false {
|
||||||
|
($v:expr) => {
|
||||||
|
match $v {
|
||||||
|
Some(v) => v,
|
||||||
|
None => return false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The struct contains the information about the anonymous region
|
// The struct contains the information about the anonymous region
|
||||||
// we are searching for.
|
// we are searching for.
|
||||||
pub struct AnonymousArgInfo<'tcx> {
|
pub struct AnonymousArgInfo<'tcx> {
|
||||||
@ -59,7 +68,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||||||
-> Option<AnonymousArgInfo> {
|
-> Option<AnonymousArgInfo> {
|
||||||
|
|
||||||
if let ty::ReFree(ref free_region) = *anon_region {
|
if let ty::ReFree(ref free_region) = *anon_region {
|
||||||
|
|
||||||
let id = free_region.scope;
|
let id = free_region.scope;
|
||||||
let hir = &self.tcx.hir;
|
let hir = &self.tcx.hir;
|
||||||
if let Some(node_id) = hir.as_local_node_id(id) {
|
if let Some(node_id) = hir.as_local_node_id(id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user