mod unsafety;
fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
- let impl_def_id = tcx.hir.local_def_id(node_id);
+ let impl_def_id = tcx.hir().local_def_id(node_id);
// If there are no traits, then this implementation must have a
// base type.
tcx.item_path_str(impl_def_id));
// Skip impls where one of the self type is an error type.
- // This occurs with e.g. resolve failures (#30589).
+ // This occurs with e.g., resolve failures (#30589).
if trait_ref.references_error() {
return;
}
}
fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
- let impls = tcx.hir.trait_impls(def_id);
+ let impls = tcx.hir().trait_impls(def_id);
for &impl_id in impls {
check_impl(tcx, impl_id);
}
}
pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
- for &trait_def_id in tcx.hir.krate().trait_impls.keys() {
+ for &trait_def_id in tcx.hir().krate().trait_impls.keys() {
ty::query::queries::coherent_trait::ensure(tcx, trait_def_id);
}
/// same type. Likewise, no two inherent impls for a given type
/// constructor provide a method with the same name.
fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
- let impl_def_id = tcx.hir.local_def_id(node_id);
+ let impl_def_id = tcx.hir().local_def_id(node_id);
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
let trait_def_id = trait_ref.def_id;
// This is something like impl Trait1 for Trait2. Illegal
// if Trait1 is a supertrait of Trait2 or Trait2 is not object safe.
- if data.principal().map_or(true, |p| !tcx.is_object_safe(p.def_id())) {
+ if !tcx.is_object_safe(data.principal().def_id()) {
// This is an error, but it will be reported by wfcheck. Ignore it here.
// This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.
} else {
let mut supertrait_def_ids =
- traits::supertrait_def_ids(tcx,
- data.principal().unwrap().def_id());
+ traits::supertrait_def_ids(tcx, data.principal().def_id());
if supertrait_def_ids.any(|d| d == trait_def_id) {
let sp = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap());
struct_span_err!(tcx.sess,