rustc_trait_selection/error_reporting/infer/nice_region_error/
named_anon_conflict.rs1use rustc_errors::Diag;
5use tracing::debug;
6
7use crate::error_reporting::infer::nice_region_error::NiceRegionError;
8use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type;
9use crate::errors::ExplicitLifetimeRequired;
10
11impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
12 pub(super) fn try_report_named_anon_conflict(&self) -> Option<Diag<'tcx>> {
15 let (span, sub, sup) = self.regions()?;
16
17 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs:17",
"rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs"),
::tracing_core::__macro_support::Option::Some(17u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_report_named_anon_conflict(sub={0:?}, sup={1:?}, error={2:?})",
sub, sup, self.error) as &dyn Value))])
});
} else { ; }
};debug!(
18 "try_report_named_anon_conflict(sub={:?}, sup={:?}, error={:?})",
19 sub, sup, self.error,
20 );
21
22 let (named, anon, anon_param_info, region_info) = if sub.is_named(self.tcx())
29 && let Some(region_info) = self.tcx().is_suitable_region(self.generic_param_scope, sup)
30 && let Some(anon_param_info) = self.find_param_with_region(sup, sub)
31 {
32 (sub, sup, anon_param_info, region_info)
33 } else if sup.is_named(self.tcx())
34 && let Some(region_info) = self.tcx().is_suitable_region(self.generic_param_scope, sub)
35 && let Some(anon_param_info) = self.find_param_with_region(sub, sup)
36 {
37 (sup, sub, anon_param_info, region_info)
38 } else {
39 return None; };
41
42 if named.is_static() {
45 return None;
46 }
47
48 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs:48",
"rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs"),
::tracing_core::__macro_support::Option::Some(48u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_report_named_anon_conflict: named = {0:?}",
named) as &dyn Value))])
});
} else { ; }
};debug!("try_report_named_anon_conflict: named = {:?}", named);
49 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs:49",
"rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs"),
::tracing_core::__macro_support::Option::Some(49u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_report_named_anon_conflict: anon_param_info = {0:?}",
anon_param_info) as &dyn Value))])
});
} else { ; }
};debug!("try_report_named_anon_conflict: anon_param_info = {:?}", anon_param_info);
50 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs:50",
"rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs"),
::tracing_core::__macro_support::Option::Some(50u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_report_named_anon_conflict: region_info = {0:?}",
region_info) as &dyn Value))])
});
} else { ; }
};debug!("try_report_named_anon_conflict: region_info = {:?}", region_info);
51
52 let param = anon_param_info.param;
53 let new_ty = anon_param_info.param_ty;
54 let new_ty_span = anon_param_info.param_ty_span;
55 let is_first = anon_param_info.is_first;
56 let scope_def_id = region_info.scope;
57 let is_impl_item = region_info.is_impl_item;
58
59 if anon_param_info.kind.is_named(self.tcx()) {
60 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs:61",
"rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs"),
::tracing_core::__macro_support::Option::Some(61u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_report_named_anon_conflict: not an anonymous region")
as &dyn Value))])
});
} else { ; }
};debug!("try_report_named_anon_conflict: not an anonymous region");
62 return None;
63 }
64
65 if is_impl_item {
66 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs:66",
"rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs"),
::tracing_core::__macro_support::Option::Some(66u32),
::tracing_core::__macro_support::Option::Some("rustc_trait_selection::error_reporting::infer::nice_region_error::named_anon_conflict"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_report_named_anon_conflict: impl item, bail out")
as &dyn Value))])
});
} else { ; }
};debug!("try_report_named_anon_conflict: impl item, bail out");
67 return None;
68 }
69
70 if find_anon_type(self.tcx(), self.generic_param_scope, anon).is_some()
71 && self.is_self_anon(is_first, scope_def_id)
72 {
73 return None;
74 }
75 let named = named.to_string();
76 let err = match param.pat.simple_ident() {
77 Some(simple_ident) => ExplicitLifetimeRequired::WithIdent {
78 span,
79 simple_ident,
80 named,
81 new_ty_span,
82 new_ty,
83 },
84 None => ExplicitLifetimeRequired::WithParamType { span, named, new_ty_span, new_ty },
85 };
86 Some(self.tcx().sess.dcx().create_err(err))
87 }
88}