1
Fork 0

Auto merge of #83723 - cjgillot:ownernode, r=petrochenkov

Store all HIR owners in the same container

This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem.
This should allow for a more compact storage.

Based on https://github.com/rust-lang/rust/pull/83114
This commit is contained in:
bors 2021-07-25 11:11:02 +00:00
commit 6489ee1041
34 changed files with 579 additions and 486 deletions

View file

@ -82,15 +82,11 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
self.lctx.with_hir_id_owner(item.id, |lctx| match ctxt { self.lctx.with_hir_id_owner(item.id, |lctx| match ctxt {
AssocCtxt::Trait => { AssocCtxt::Trait => {
let hir_item = lctx.lower_trait_item(item); let hir_item = lctx.lower_trait_item(item);
let id = hir_item.trait_item_id(); lctx.insert_trait_item(hir_item);
lctx.trait_items.insert(id, hir_item);
lctx.modules.entry(lctx.current_module).or_default().trait_items.insert(id);
} }
AssocCtxt::Impl => { AssocCtxt::Impl => {
let hir_item = lctx.lower_impl_item(item); let hir_item = lctx.lower_impl_item(item);
let id = hir_item.impl_item_id(); lctx.insert_impl_item(hir_item);
lctx.impl_items.insert(id, hir_item);
lctx.modules.entry(lctx.current_module).or_default().impl_items.insert(id);
} }
}); });
@ -101,9 +97,7 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
self.lctx.allocate_hir_id_counter(item.id); self.lctx.allocate_hir_id_counter(item.id);
self.lctx.with_hir_id_owner(item.id, |lctx| { self.lctx.with_hir_id_owner(item.id, |lctx| {
let hir_item = lctx.lower_foreign_item(item); let hir_item = lctx.lower_foreign_item(item);
let id = hir_item.foreign_item_id(); lctx.insert_foreign_item(hir_item);
lctx.foreign_items.insert(id, hir_item);
lctx.modules.entry(lctx.current_module).or_default().foreign_items.insert(id);
}); });
visit::walk_foreign_item(self, item); visit::walk_foreign_item(self, item);
@ -123,7 +117,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
) -> T { ) -> T {
let old_len = self.in_scope_lifetimes.len(); let old_len = self.in_scope_lifetimes.len();
let parent_generics = match self.items.get(&parent_hir_id).unwrap().kind { let parent_generics = match self.owners[parent_hir_id.def_id].unwrap().expect_item().kind {
hir::ItemKind::Impl(hir::Impl { ref generics, .. }) hir::ItemKind::Impl(hir::Impl { ref generics, .. })
| hir::ItemKind::Trait(_, _, ref generics, ..) => generics.params, | hir::ItemKind::Trait(_, _, ref generics, ..) => generics.params,
_ => &[], _ => &[],
@ -224,7 +218,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let hir_id = self.lower_node_id(i.id); let hir_id = self.lower_node_id(i.id);
self.lower_attrs(hir_id, &i.attrs); self.lower_attrs(hir_id, &i.attrs);
let body = P(self.lower_mac_args(body)); let body = P(self.lower_mac_args(body));
self.exported_macros.push(hir::MacroDef { self.insert_macro_def(hir::MacroDef {
ident, ident,
vis, vis,
def_id: hir_id.expect_owner(), def_id: hir_id.expect_owner(),

View file

@ -101,13 +101,8 @@ struct LoweringContext<'a, 'hir: 'a> {
arena: &'hir Arena<'hir>, arena: &'hir Arena<'hir>,
/// The items being lowered are collected here. /// The items being lowered are collected here.
items: BTreeMap<hir::ItemId, hir::Item<'hir>>, owners: IndexVec<LocalDefId, Option<hir::OwnerNode<'hir>>>,
trait_items: BTreeMap<hir::TraitItemId, hir::TraitItem<'hir>>,
impl_items: BTreeMap<hir::ImplItemId, hir::ImplItem<'hir>>,
foreign_items: BTreeMap<hir::ForeignItemId, hir::ForeignItem<'hir>>,
bodies: BTreeMap<hir::BodyId, hir::Body<'hir>>, bodies: BTreeMap<hir::BodyId, hir::Body<'hir>>,
exported_macros: Vec<hir::MacroDef<'hir>>,
non_exported_macro_attrs: Vec<ast::Attribute>, non_exported_macro_attrs: Vec<ast::Attribute>,
trait_impls: BTreeMap<DefId, Vec<LocalDefId>>, trait_impls: BTreeMap<DefId, Vec<LocalDefId>>,
@ -330,15 +325,11 @@ pub fn lower_crate<'a, 'hir>(
resolver, resolver,
nt_to_tokenstream, nt_to_tokenstream,
arena, arena,
items: BTreeMap::new(), owners: IndexVec::default(),
trait_items: BTreeMap::new(),
impl_items: BTreeMap::new(),
foreign_items: BTreeMap::new(),
bodies: BTreeMap::new(), bodies: BTreeMap::new(),
trait_impls: BTreeMap::new(), trait_impls: BTreeMap::new(),
modules: BTreeMap::new(), modules: BTreeMap::new(),
attrs: BTreeMap::default(), attrs: BTreeMap::default(),
exported_macros: Vec::new(),
non_exported_macro_attrs: Vec::new(), non_exported_macro_attrs: Vec::new(),
catch_scopes: Vec::new(), catch_scopes: Vec::new(),
loop_scopes: Vec::new(), loop_scopes: Vec::new(),
@ -521,8 +512,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
visit::walk_crate(&mut MiscCollector { lctx: &mut self }, c); visit::walk_crate(&mut MiscCollector { lctx: &mut self }, c);
visit::walk_crate(&mut item::ItemLowerer { lctx: &mut self }, c); visit::walk_crate(&mut item::ItemLowerer { lctx: &mut self }, c);
let module = self.lower_mod(&c.items, c.span); let module = self.arena.alloc(self.lower_mod(&c.items, c.span));
self.lower_attrs(hir::CRATE_HIR_ID, &c.attrs); self.lower_attrs(hir::CRATE_HIR_ID, &c.attrs);
self.owners.ensure_contains_elem(CRATE_DEF_ID, || None);
self.owners[CRATE_DEF_ID] = Some(hir::OwnerNode::Crate(module));
let body_ids = body_ids(&self.bodies); let body_ids = body_ids(&self.bodies);
let proc_macros = let proc_macros =
c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect(); c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect();
@ -557,13 +551,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} }
let krate = hir::Crate { let krate = hir::Crate {
item: module,
exported_macros: self.arena.alloc_from_iter(self.exported_macros),
non_exported_macro_attrs: self.arena.alloc_from_iter(self.non_exported_macro_attrs), non_exported_macro_attrs: self.arena.alloc_from_iter(self.non_exported_macro_attrs),
items: self.items, owners: self.owners,
trait_items: self.trait_items,
impl_items: self.impl_items,
foreign_items: self.foreign_items,
bodies: self.bodies, bodies: self.bodies,
body_ids, body_ids,
trait_impls: self.trait_impls, trait_impls: self.trait_impls,
@ -576,12 +565,48 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} }
fn insert_item(&mut self, item: hir::Item<'hir>) -> hir::ItemId { fn insert_item(&mut self, item: hir::Item<'hir>) -> hir::ItemId {
let id = hir::ItemId { def_id: item.def_id }; let id = item.item_id();
self.items.insert(id, item); let item = self.arena.alloc(item);
self.owners.ensure_contains_elem(id.def_id, || None);
self.owners[id.def_id] = Some(hir::OwnerNode::Item(item));
self.modules.entry(self.current_module).or_default().items.insert(id); self.modules.entry(self.current_module).or_default().items.insert(id);
id id
} }
fn insert_foreign_item(&mut self, item: hir::ForeignItem<'hir>) -> hir::ForeignItemId {
let id = item.foreign_item_id();
let item = self.arena.alloc(item);
self.owners.ensure_contains_elem(id.def_id, || None);
self.owners[id.def_id] = Some(hir::OwnerNode::ForeignItem(item));
self.modules.entry(self.current_module).or_default().foreign_items.insert(id);
id
}
fn insert_impl_item(&mut self, item: hir::ImplItem<'hir>) -> hir::ImplItemId {
let id = item.impl_item_id();
let item = self.arena.alloc(item);
self.owners.ensure_contains_elem(id.def_id, || None);
self.owners[id.def_id] = Some(hir::OwnerNode::ImplItem(item));
self.modules.entry(self.current_module).or_default().impl_items.insert(id);
id
}
fn insert_trait_item(&mut self, item: hir::TraitItem<'hir>) -> hir::TraitItemId {
let id = item.trait_item_id();
let item = self.arena.alloc(item);
self.owners.ensure_contains_elem(id.def_id, || None);
self.owners[id.def_id] = Some(hir::OwnerNode::TraitItem(item));
self.modules.entry(self.current_module).or_default().trait_items.insert(id);
id
}
fn insert_macro_def(&mut self, item: hir::MacroDef<'hir>) {
let def_id = item.def_id;
let item = self.arena.alloc(item);
self.owners.ensure_contains_elem(def_id, || None);
self.owners[def_id] = Some(hir::OwnerNode::MacroDef(item));
}
fn allocate_hir_id_counter(&mut self, owner: NodeId) -> hir::HirId { fn allocate_hir_id_counter(&mut self, owner: NodeId) -> hir::HirId {
// Set up the counter if needed. // Set up the counter if needed.
self.item_local_id_counters.entry(owner).or_insert(0); self.item_local_id_counters.entry(owner).or_insert(0);

View file

@ -29,11 +29,14 @@ macro_rules! arena_types {
[] fn_decl: rustc_hir::FnDecl<$tcx>, [] fn_decl: rustc_hir::FnDecl<$tcx>,
[] foreign_item: rustc_hir::ForeignItem<$tcx>, [] foreign_item: rustc_hir::ForeignItem<$tcx>,
[few] foreign_item_ref: rustc_hir::ForeignItemRef<$tcx>, [few] foreign_item_ref: rustc_hir::ForeignItemRef<$tcx>,
[] impl_item: rustc_hir::ImplItem<$tcx>,
[] impl_item_ref: rustc_hir::ImplItemRef<$tcx>, [] impl_item_ref: rustc_hir::ImplItemRef<$tcx>,
[] item: rustc_hir::Item<$tcx>,
[few] inline_asm: rustc_hir::InlineAsm<$tcx>, [few] inline_asm: rustc_hir::InlineAsm<$tcx>,
[few] llvm_inline_asm: rustc_hir::LlvmInlineAsm<$tcx>, [few] llvm_inline_asm: rustc_hir::LlvmInlineAsm<$tcx>,
[] local: rustc_hir::Local<$tcx>, [] local: rustc_hir::Local<$tcx>,
[few] macro_def: rustc_hir::MacroDef<$tcx>, [few] macro_def: rustc_hir::MacroDef<$tcx>,
[few] mod_: rustc_hir::Mod<$tcx>,
[] param: rustc_hir::Param<$tcx>, [] param: rustc_hir::Param<$tcx>,
[] pat: rustc_hir::Pat<$tcx>, [] pat: rustc_hir::Pat<$tcx>,
[] path: rustc_hir::Path<$tcx>, [] path: rustc_hir::Path<$tcx>,
@ -42,6 +45,7 @@ macro_rules! arena_types {
[] qpath: rustc_hir::QPath<$tcx>, [] qpath: rustc_hir::QPath<$tcx>,
[] stmt: rustc_hir::Stmt<$tcx>, [] stmt: rustc_hir::Stmt<$tcx>,
[] field_def: rustc_hir::FieldDef<$tcx>, [] field_def: rustc_hir::FieldDef<$tcx>,
[] trait_item: rustc_hir::TraitItem<$tcx>,
[] trait_item_ref: rustc_hir::TraitItemRef, [] trait_item_ref: rustc_hir::TraitItemRef,
[] ty: rustc_hir::Ty<$tcx>, [] ty: rustc_hir::Ty<$tcx>,
[] type_binding: rustc_hir::TypeBinding<$tcx>, [] type_binding: rustc_hir::TypeBinding<$tcx>,

View file

@ -1,6 +1,6 @@
// ignore-tidy-filelength // ignore-tidy-filelength
use crate::def::{CtorKind, DefKind, Res}; use crate::def::{CtorKind, DefKind, Res};
use crate::def_id::DefId; use crate::def_id::{DefId, CRATE_DEF_ID};
crate use crate::hir_id::{HirId, ItemLocalId}; crate use crate::hir_id::{HirId, ItemLocalId};
use crate::{itemlikevisit, LangItem}; use crate::{itemlikevisit, LangItem};
@ -12,6 +12,7 @@ pub use rustc_ast::{CaptureBy, Movability, Mutability};
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
use rustc_index::vec::IndexVec;
use rustc_macros::HashStable_Generic; use rustc_macros::HashStable_Generic;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
@ -627,22 +628,10 @@ pub struct ModuleItems {
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
#[derive(Debug)] #[derive(Debug)]
pub struct Crate<'hir> { pub struct Crate<'hir> {
pub item: Mod<'hir>,
pub exported_macros: &'hir [MacroDef<'hir>],
// Attributes from non-exported macros, kept only for collecting the library feature list. // Attributes from non-exported macros, kept only for collecting the library feature list.
pub non_exported_macro_attrs: &'hir [Attribute], pub non_exported_macro_attrs: &'hir [Attribute],
// N.B., we use a `BTreeMap` here so that `visit_all_items` iterates pub owners: IndexVec<LocalDefId, Option<OwnerNode<'hir>>>,
// over the ids in increasing order. In principle it should not
// matter what order we visit things in, but in *practice* it
// does, because it can affect the order in which errors are
// detected, which in turn can make UI tests yield
// slightly different results.
pub items: BTreeMap<ItemId, Item<'hir>>,
pub trait_items: BTreeMap<TraitItemId, TraitItem<'hir>>,
pub impl_items: BTreeMap<ImplItemId, ImplItem<'hir>>,
pub foreign_items: BTreeMap<ForeignItemId, ForeignItem<'hir>>,
pub bodies: BTreeMap<BodyId, Body<'hir>>, pub bodies: BTreeMap<BodyId, Body<'hir>>,
pub trait_impls: BTreeMap<DefId, Vec<LocalDefId>>, pub trait_impls: BTreeMap<DefId, Vec<LocalDefId>>,
@ -668,20 +657,24 @@ pub struct Crate<'hir> {
} }
impl Crate<'hir> { impl Crate<'hir> {
pub fn item(&self, id: ItemId) -> &Item<'hir> { pub fn module(&self) -> &'hir Mod<'hir> {
&self.items[&id] if let Some(OwnerNode::Crate(m)) = self.owners[CRATE_DEF_ID] { m } else { panic!() }
} }
pub fn trait_item(&self, id: TraitItemId) -> &TraitItem<'hir> { pub fn item(&self, id: ItemId) -> &'hir Item<'hir> {
&self.trait_items[&id] self.owners[id.def_id].as_ref().unwrap().expect_item()
} }
pub fn impl_item(&self, id: ImplItemId) -> &ImplItem<'hir> { pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
&self.impl_items[&id] self.owners[id.def_id].as_ref().unwrap().expect_trait_item()
} }
pub fn foreign_item(&self, id: ForeignItemId) -> &ForeignItem<'hir> { pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
&self.foreign_items[&id] self.owners[id.def_id].as_ref().unwrap().expect_impl_item()
}
pub fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
self.owners[id.def_id].as_ref().unwrap().expect_foreign_item()
} }
pub fn body(&self, id: BodyId) -> &Body<'hir> { pub fn body(&self, id: BodyId) -> &Body<'hir> {
@ -702,20 +695,14 @@ impl Crate<'_> {
where where
V: itemlikevisit::ItemLikeVisitor<'hir>, V: itemlikevisit::ItemLikeVisitor<'hir>,
{ {
for item in self.items.values() { for owner in self.owners.iter().filter_map(Option::as_ref) {
visitor.visit_item(item); match owner {
} OwnerNode::Item(item) => visitor.visit_item(item),
OwnerNode::ForeignItem(item) => visitor.visit_foreign_item(item),
for trait_item in self.trait_items.values() { OwnerNode::ImplItem(item) => visitor.visit_impl_item(item),
visitor.visit_trait_item(trait_item); OwnerNode::TraitItem(item) => visitor.visit_trait_item(item),
} OwnerNode::MacroDef(_) | OwnerNode::Crate(_) => {}
}
for impl_item in self.impl_items.values() {
visitor.visit_impl_item(impl_item);
}
for foreign_item in self.foreign_items.values() {
visitor.visit_foreign_item(foreign_item);
} }
} }
@ -724,28 +711,27 @@ impl Crate<'_> {
where where
V: itemlikevisit::ParItemLikeVisitor<'hir> + Sync + Send, V: itemlikevisit::ParItemLikeVisitor<'hir> + Sync + Send,
{ {
parallel!( par_for_each_in(&self.owners.raw, |owner| match owner {
{ Some(OwnerNode::Item(item)) => visitor.visit_item(item),
par_for_each_in(&self.items, |(_, item)| { Some(OwnerNode::ForeignItem(item)) => visitor.visit_foreign_item(item),
visitor.visit_item(item); Some(OwnerNode::ImplItem(item)) => visitor.visit_impl_item(item),
}); Some(OwnerNode::TraitItem(item)) => visitor.visit_trait_item(item),
}, Some(OwnerNode::MacroDef(_)) | Some(OwnerNode::Crate(_)) | None => {}
{ })
par_for_each_in(&self.trait_items, |(_, trait_item)| { }
visitor.visit_trait_item(trait_item);
}); pub fn items<'hir>(&'hir self) -> impl Iterator<Item = &'hir Item<'hir>> + 'hir {
}, self.owners.iter().filter_map(|owner| match owner {
{ Some(OwnerNode::Item(item)) => Some(*item),
par_for_each_in(&self.impl_items, |(_, impl_item)| { _ => None,
visitor.visit_impl_item(impl_item); })
}); }
},
{ pub fn exported_macros<'hir>(&'hir self) -> impl Iterator<Item = &'hir MacroDef<'hir>> + 'hir {
par_for_each_in(&self.foreign_items, |(_, foreign_item)| { self.owners.iter().filter_map(|owner| match owner {
visitor.visit_foreign_item(foreign_item); Some(OwnerNode::MacroDef(macro_def)) => Some(*macro_def),
}); _ => None,
} })
);
} }
} }
@ -2956,6 +2942,163 @@ pub struct TraitCandidate {
pub import_ids: SmallVec<[LocalDefId; 1]>, pub import_ids: SmallVec<[LocalDefId; 1]>,
} }
#[derive(Copy, Clone, Debug, HashStable_Generic)]
pub enum OwnerNode<'hir> {
Item(&'hir Item<'hir>),
ForeignItem(&'hir ForeignItem<'hir>),
TraitItem(&'hir TraitItem<'hir>),
ImplItem(&'hir ImplItem<'hir>),
MacroDef(&'hir MacroDef<'hir>),
Crate(&'hir Mod<'hir>),
}
impl<'hir> OwnerNode<'hir> {
pub fn ident(&self) -> Option<Ident> {
match self {
OwnerNode::Item(Item { ident, .. })
| OwnerNode::ForeignItem(ForeignItem { ident, .. })
| OwnerNode::ImplItem(ImplItem { ident, .. })
| OwnerNode::TraitItem(TraitItem { ident, .. })
| OwnerNode::MacroDef(MacroDef { ident, .. }) => Some(*ident),
OwnerNode::Crate(..) => None,
}
}
pub fn span(&self) -> Span {
match self {
OwnerNode::Item(Item { span, .. })
| OwnerNode::ForeignItem(ForeignItem { span, .. })
| OwnerNode::ImplItem(ImplItem { span, .. })
| OwnerNode::TraitItem(TraitItem { span, .. })
| OwnerNode::MacroDef(MacroDef { span, .. })
| OwnerNode::Crate(Mod { inner: span, .. }) => *span,
}
}
pub fn fn_decl(&self) -> Option<&FnDecl<'hir>> {
match self {
OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
| OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
| OwnerNode::Item(Item { kind: ItemKind::Fn(fn_sig, _, _), .. }) => Some(fn_sig.decl),
OwnerNode::ForeignItem(ForeignItem {
kind: ForeignItemKind::Fn(fn_decl, _, _),
..
}) => Some(fn_decl),
_ => None,
}
}
pub fn body_id(&self) -> Option<BodyId> {
match self {
OwnerNode::TraitItem(TraitItem {
kind: TraitItemKind::Fn(_, TraitFn::Provided(body_id)),
..
})
| OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })
| OwnerNode::Item(Item { kind: ItemKind::Fn(.., body_id), .. }) => Some(*body_id),
_ => None,
}
}
pub fn generics(&self) -> Option<&'hir Generics<'hir>> {
match self {
OwnerNode::TraitItem(TraitItem { generics, .. })
| OwnerNode::ImplItem(ImplItem { generics, .. }) => Some(generics),
OwnerNode::Item(item) => item.kind.generics(),
_ => None,
}
}
pub fn def_id(self) -> LocalDefId {
match self {
OwnerNode::Item(Item { def_id, .. })
| OwnerNode::TraitItem(TraitItem { def_id, .. })
| OwnerNode::ImplItem(ImplItem { def_id, .. })
| OwnerNode::ForeignItem(ForeignItem { def_id, .. })
| OwnerNode::MacroDef(MacroDef { def_id, .. }) => *def_id,
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
}
}
pub fn expect_item(self) -> &'hir Item<'hir> {
match self {
OwnerNode::Item(n) => n,
_ => panic!(),
}
}
pub fn expect_foreign_item(self) -> &'hir ForeignItem<'hir> {
match self {
OwnerNode::ForeignItem(n) => n,
_ => panic!(),
}
}
pub fn expect_impl_item(self) -> &'hir ImplItem<'hir> {
match self {
OwnerNode::ImplItem(n) => n,
_ => panic!(),
}
}
pub fn expect_trait_item(self) -> &'hir TraitItem<'hir> {
match self {
OwnerNode::TraitItem(n) => n,
_ => panic!(),
}
}
pub fn expect_macro_def(self) -> &'hir MacroDef<'hir> {
match self {
OwnerNode::MacroDef(n) => n,
_ => panic!(),
}
}
}
impl<'hir> Into<OwnerNode<'hir>> for &'hir Item<'hir> {
fn into(self) -> OwnerNode<'hir> {
OwnerNode::Item(self)
}
}
impl<'hir> Into<OwnerNode<'hir>> for &'hir ForeignItem<'hir> {
fn into(self) -> OwnerNode<'hir> {
OwnerNode::ForeignItem(self)
}
}
impl<'hir> Into<OwnerNode<'hir>> for &'hir ImplItem<'hir> {
fn into(self) -> OwnerNode<'hir> {
OwnerNode::ImplItem(self)
}
}
impl<'hir> Into<OwnerNode<'hir>> for &'hir TraitItem<'hir> {
fn into(self) -> OwnerNode<'hir> {
OwnerNode::TraitItem(self)
}
}
impl<'hir> Into<OwnerNode<'hir>> for &'hir MacroDef<'hir> {
fn into(self) -> OwnerNode<'hir> {
OwnerNode::MacroDef(self)
}
}
impl<'hir> Into<Node<'hir>> for OwnerNode<'hir> {
fn into(self) -> Node<'hir> {
match self {
OwnerNode::Item(n) => Node::Item(n),
OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
OwnerNode::ImplItem(n) => Node::ImplItem(n),
OwnerNode::TraitItem(n) => Node::TraitItem(n),
OwnerNode::MacroDef(n) => Node::MacroDef(n),
OwnerNode::Crate(n) => Node::Crate(n),
}
}
}
#[derive(Copy, Clone, Debug, HashStable_Generic)] #[derive(Copy, Clone, Debug, HashStable_Generic)]
pub enum Node<'hir> { pub enum Node<'hir> {
Param(&'hir Param<'hir>), Param(&'hir Param<'hir>),
@ -3084,6 +3227,18 @@ impl<'hir> Node<'hir> {
_ => Constness::NotConst, _ => Constness::NotConst,
} }
} }
pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
match self {
Node::Item(i) => Some(OwnerNode::Item(i)),
Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
Node::MacroDef(i) => Some(OwnerNode::MacroDef(i)),
Node::Crate(i) => Some(OwnerNode::Crate(i)),
_ => None,
}
}
} }
// Some nodes are used a lot. Make sure they don't unintentionally get bigger. // Some nodes are used a lot. Make sure they don't unintentionally get bigger.

View file

@ -478,8 +478,9 @@ pub trait Visitor<'v>: Sized {
/// Walks the contents of a crate. See also `Crate::visit_all_items`. /// Walks the contents of a crate. See also `Crate::visit_all_items`.
pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate<'v>) { pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate<'v>) {
visitor.visit_mod(&krate.item, krate.item.inner, CRATE_HIR_ID); let top_mod = krate.module();
walk_list!(visitor, visit_macro_def, krate.exported_macros); visitor.visit_mod(top_mod, top_mod.inner, CRATE_HIR_ID);
walk_list!(visitor, visit_macro_def, krate.exported_macros());
for (&id, attrs) in krate.attrs.iter() { for (&id, attrs) in krate.attrs.iter() {
for a in *attrs { for a in *attrs {
visitor.visit_attribute(id, a) visitor.visit_attribute(id, a)

View file

@ -169,7 +169,7 @@ pub fn print_crate<'a>(
// When printing the AST, we sometimes need to inject `#[no_std]` here. // When printing the AST, we sometimes need to inject `#[no_std]` here.
// Since you can't compile the HIR, it's not necessary. // Since you can't compile the HIR, it's not necessary.
s.print_mod(&krate.item, s.attrs(hir::CRATE_HIR_ID)); s.print_mod(&krate.module(), s.attrs(hir::CRATE_HIR_ID));
s.print_remaining_comments(); s.print_remaining_comments();
s.s.eof() s.s.eof()
} }

View file

@ -568,9 +568,9 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
} }
fn check_crate(&mut self, cx: &LateContext<'_>, krate: &hir::Crate<'_>) { fn check_crate(&mut self, cx: &LateContext<'_>, krate: &hir::Crate<'_>) {
self.check_missing_docs_attrs(cx, hir::CRATE_HIR_ID, krate.item.inner, "the", "crate"); self.check_missing_docs_attrs(cx, hir::CRATE_HIR_ID, krate.module().inner, "the", "crate");
for macro_def in krate.exported_macros { for macro_def in krate.exported_macros() {
// Non exported macros should be skipped, since `missing_docs` only // Non exported macros should be skipped, since `missing_docs` only
// applies to externally visible items. // applies to externally visible items.
if !cx.access_levels.is_exported(macro_def.hir_id()) { if !cx.access_levels.is_exported(macro_def.hir_id()) {

View file

@ -33,11 +33,11 @@ fn lint_levels(tcx: TyCtxt<'_>, (): ()) -> LintLevelMap {
let mut builder = LintLevelMapBuilder { levels, tcx, store }; let mut builder = LintLevelMapBuilder { levels, tcx, store };
let krate = tcx.hir().krate(); let krate = tcx.hir().krate();
builder.levels.id_to_set.reserve(krate.exported_macros.len() + 1); builder.levels.id_to_set.reserve(krate.owners.len() + 1);
let push = builder.levels.push(tcx.hir().attrs(hir::CRATE_HIR_ID), &store, true); let push = builder.levels.push(tcx.hir().attrs(hir::CRATE_HIR_ID), &store, true);
builder.levels.register_id(hir::CRATE_HIR_ID); builder.levels.register_id(hir::CRATE_HIR_ID);
for macro_def in krate.exported_macros { for macro_def in krate.exported_macros() {
builder.levels.register_id(macro_def.hir_id()); builder.levels.register_id(macro_def.hir_id());
} }
intravisit::walk_crate(&mut builder, krate); intravisit::walk_crate(&mut builder, krate);

View file

@ -439,7 +439,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
fn encode_info_for_items(&mut self) { fn encode_info_for_items(&mut self) {
let krate = self.tcx.hir().krate(); let krate = self.tcx.hir().krate();
self.encode_info_for_mod(CRATE_DEF_ID, &krate.item); self.encode_info_for_mod(CRATE_DEF_ID, krate.module());
// Proc-macro crates only export proc-macro items, which are looked // Proc-macro crates only export proc-macro items, which are looked
// up using `proc_macro_data` // up using `proc_macro_data`
@ -448,7 +448,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
} }
krate.visit_all_item_likes(&mut self.as_deep_visitor()); krate.visit_all_item_likes(&mut self.as_deep_visitor());
for macro_def in krate.exported_macros { for macro_def in krate.exported_macros() {
self.visit_macro_def(macro_def); self.visit_macro_def(macro_def);
} }
} }

View file

@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_hir::def_id::CRATE_DEF_INDEX; use rustc_hir::def_id::CRATE_DEF_ID;
use rustc_hir::definitions; use rustc_hir::definitions;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::*; use rustc_hir::*;
@ -75,46 +75,20 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
arena: &'hir Arena<'hir>, arena: &'hir Arena<'hir>,
krate: &'hir Crate<'hir>, krate: &'hir Crate<'hir>,
definitions: &'a definitions::Definitions, definitions: &'a definitions::Definitions,
mut hcx: StableHashingContext<'a>, hcx: StableHashingContext<'a>,
) -> NodeCollector<'a, 'hir> { ) -> NodeCollector<'a, 'hir> {
let hash = {
let Crate {
ref item,
// These fields are handled separately:
exported_macros: _,
non_exported_macro_attrs: _,
items: _,
trait_items: _,
impl_items: _,
foreign_items: _,
bodies: _,
trait_impls: _,
body_ids: _,
modules: _,
proc_macros: _,
trait_map: _,
attrs: _,
} = *krate;
hash_body(&mut hcx, item)
};
let mut collector = NodeCollector { let mut collector = NodeCollector {
arena, arena,
krate, krate,
source_map: sess.source_map(), source_map: sess.source_map(),
parent_node: hir::CRATE_HIR_ID, parent_node: hir::CRATE_HIR_ID,
current_dep_node_owner: LocalDefId { local_def_index: CRATE_DEF_INDEX }, current_dep_node_owner: CRATE_DEF_ID,
definitions, definitions,
hcx, hcx,
map: IndexVec::from_fn_n(|_| None, definitions.def_index_count()), map: IndexVec::from_fn_n(|_| None, definitions.def_index_count()),
parenting: FxHashMap::default(), parenting: FxHashMap::default(),
}; };
collector.insert_entry( collector.insert_owner(CRATE_DEF_ID, OwnerNode::Crate(krate.module()));
hir::CRATE_HIR_ID,
Entry { parent: hir::CRATE_HIR_ID, node: Node::Crate(&krate.item) },
hash,
);
collector collector
} }
@ -128,53 +102,20 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
IndexedHir { map: self.map, parenting: self.parenting } IndexedHir { map: self.map, parenting: self.parenting }
} }
fn insert_entry(&mut self, id: HirId, entry: Entry<'hir>, hash: Fingerprint) { fn insert_owner(&mut self, owner: LocalDefId, node: OwnerNode<'hir>) {
let i = id.local_id.as_u32() as usize; let hash = hash_body(&mut self.hcx, node);
let arena = self.arena; let mut nodes = IndexVec::new();
nodes.push(Some(ParentedNode { parent: ItemLocalId::new(0), node: node.into() }));
let data = &mut self.map[id.owner]; debug_assert!(self.map[owner].is_none());
self.map[owner] =
if i == 0 { Some(self.arena.alloc(OwnerNodes { hash, nodes, bodies: FxHashMap::default() }));
debug_assert!(data.is_none());
*data = Some(arena.alloc(OwnerNodes {
hash,
nodes: IndexVec::new(),
bodies: FxHashMap::default(),
}));
let dk_parent = self.definitions.def_key(id.owner).parent;
if let Some(dk_parent) = dk_parent {
let dk_parent = LocalDefId { local_def_index: dk_parent };
let dk_parent = self.definitions.local_def_id_to_hir_id(dk_parent);
if dk_parent.owner != entry.parent.owner {
panic!(
"Different parents for {:?} => dk_parent={:?} actual={:?}",
id.owner, dk_parent, entry.parent,
)
}
debug_assert_eq!(self.parenting.get(&id.owner), Some(&entry.parent));
}
} else {
debug_assert_eq!(entry.parent.owner, id.owner);
}
let data = data.as_mut().unwrap();
insert_vec_map(
&mut data.nodes,
id.local_id,
ParentedNode { parent: entry.parent.local_id, node: entry.node },
);
} }
fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) { fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
self.insert_with_hash(span, hir_id, node, Fingerprint::ZERO) debug_assert_eq!(self.current_dep_node_owner, hir_id.owner);
} debug_assert_ne!(hir_id.local_id.as_u32(), 0);
fn insert_with_hash(&mut self, span: Span, hir_id: HirId, node: Node<'hir>, hash: Fingerprint) {
let entry = Entry { parent: self.parent_node, node };
// Make sure that the DepNode of some node coincides with the HirId // Make sure that the DepNode of some node coincides with the HirId
// owner of that node. // owner of that node.
@ -201,7 +142,14 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
} }
} }
self.insert_entry(hir_id, entry, hash); let nodes = self.map[hir_id.owner].as_mut().unwrap();
debug_assert_eq!(self.parent_node.owner, self.current_dep_node_owner);
insert_vec_map(
&mut nodes.nodes,
hir_id.local_id,
ParentedNode { parent: self.parent_node.local_id, node: node },
);
} }
fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_node_id: HirId, f: F) { fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_node_id: HirId, f: F) {
@ -211,21 +159,15 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
self.parent_node = parent_node; self.parent_node = parent_node;
} }
fn with_dep_node_owner< fn with_dep_node_owner(&mut self, dep_node_owner: LocalDefId, f: impl FnOnce(&mut Self)) {
T: for<'b> HashStable<StableHashingContext<'b>>,
F: FnOnce(&mut Self, Fingerprint),
>(
&mut self,
dep_node_owner: LocalDefId,
item_like: &T,
f: F,
) {
let prev_owner = self.current_dep_node_owner; let prev_owner = self.current_dep_node_owner;
let hash = hash_body(&mut self.hcx, item_like); let prev_parent = self.parent_node;
self.current_dep_node_owner = dep_node_owner; self.current_dep_node_owner = dep_node_owner;
f(self, hash); self.parent_node = HirId::make_owner(dep_node_owner);
f(self);
self.current_dep_node_owner = prev_owner; self.current_dep_node_owner = prev_owner;
self.parent_node = prev_parent;
} }
fn insert_nested(&mut self, item: LocalDefId) { fn insert_nested(&mut self, item: LocalDefId) {
@ -291,28 +233,22 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
fn visit_item(&mut self, i: &'hir Item<'hir>) { fn visit_item(&mut self, i: &'hir Item<'hir>) {
debug!("visit_item: {:?}", i); debug!("visit_item: {:?}", i);
self.with_dep_node_owner(i.def_id, i, |this, hash| { self.insert_owner(i.def_id, OwnerNode::Item(i));
let hir_id = i.hir_id(); self.with_dep_node_owner(i.def_id, |this| {
this.insert_with_hash(i.span, hir_id, Node::Item(i), hash); if let ItemKind::Struct(ref struct_def, _) = i.kind {
this.with_parent(hir_id, |this| { // If this is a tuple or unit-like struct, register the constructor.
if let ItemKind::Struct(ref struct_def, _) = i.kind { if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
// If this is a tuple or unit-like struct, register the constructor. this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));
}
} }
intravisit::walk_item(this, i); }
}); intravisit::walk_item(this, i);
}); });
} }
fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) { fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) {
self.with_dep_node_owner(fi.def_id, fi, |this, hash| { self.insert_owner(fi.def_id, OwnerNode::ForeignItem(fi));
this.insert_with_hash(fi.span, fi.hir_id(), Node::ForeignItem(fi), hash); self.with_dep_node_owner(fi.def_id, |this| {
intravisit::walk_foreign_item(this, fi);
this.with_parent(fi.hir_id(), |this| {
intravisit::walk_foreign_item(this, fi);
});
}); });
} }
@ -322,26 +258,22 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
} }
fn visit_const_param_default(&mut self, param: HirId, ct: &'hir AnonConst) { fn visit_const_param_default(&mut self, param: HirId, ct: &'hir AnonConst) {
self.with_parent(param, |this| intravisit::walk_const_param_default(this, ct)) self.with_parent(param, |this| {
intravisit::walk_const_param_default(this, ct);
})
} }
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) { fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
self.with_dep_node_owner(ti.def_id, ti, |this, hash| { self.insert_owner(ti.def_id, OwnerNode::TraitItem(ti));
this.insert_with_hash(ti.span, ti.hir_id(), Node::TraitItem(ti), hash); self.with_dep_node_owner(ti.def_id, |this| {
intravisit::walk_trait_item(this, ti);
this.with_parent(ti.hir_id(), |this| {
intravisit::walk_trait_item(this, ti);
});
}); });
} }
fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) { fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
self.with_dep_node_owner(ii.def_id, ii, |this, hash| { self.insert_owner(ii.def_id, OwnerNode::ImplItem(ii));
this.insert_with_hash(ii.span, ii.hir_id(), Node::ImplItem(ii), hash); self.with_dep_node_owner(ii.def_id, |this| {
intravisit::walk_impl_item(this, ii);
this.with_parent(ii.hir_id(), |this| {
intravisit::walk_impl_item(this, ii);
});
}); });
} }
@ -433,7 +365,9 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
fn visit_local(&mut self, l: &'hir Local<'hir>) { fn visit_local(&mut self, l: &'hir Local<'hir>) {
self.insert(l.span, l.hir_id, Node::Local(l)); self.insert(l.span, l.hir_id, Node::Local(l));
self.with_parent(l.hir_id, |this| intravisit::walk_local(this, l)) self.with_parent(l.hir_id, |this| {
intravisit::walk_local(this, l);
})
} }
fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) { fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) {
@ -460,16 +394,9 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
let parent = def_key.parent.map_or(hir::CRATE_HIR_ID, |local_def_index| { let parent = def_key.parent.map_or(hir::CRATE_HIR_ID, |local_def_index| {
self.definitions.local_def_id_to_hir_id(LocalDefId { local_def_index }) self.definitions.local_def_id_to_hir_id(LocalDefId { local_def_index })
}); });
self.insert_owner(macro_def.def_id, OwnerNode::MacroDef(macro_def));
self.with_parent(parent, |this| { self.with_parent(parent, |this| {
this.insert_nested(macro_def.def_id); this.insert_nested(macro_def.def_id);
this.with_dep_node_owner(macro_def.def_id, macro_def, |this, hash| {
this.insert_with_hash(
macro_def.span,
macro_def.hir_id(),
Node::MacroDef(macro_def),
hash,
);
})
}); });
} }

View file

@ -1,6 +1,6 @@
use self::collector::NodeCollector; use self::collector::NodeCollector;
use crate::hir::{AttributeMap, IndexedHir}; use crate::hir::{AttributeMap, IndexedHir, Owner};
use crate::ty::TyCtxt; use crate::ty::TyCtxt;
use rustc_ast as ast; use rustc_ast as ast;
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
@ -121,13 +121,13 @@ pub struct ParentOwnerIterator<'map, 'hir> {
} }
impl<'hir> Iterator for ParentOwnerIterator<'_, 'hir> { impl<'hir> Iterator for ParentOwnerIterator<'_, 'hir> {
type Item = (HirId, Node<'hir>); type Item = (HirId, OwnerNode<'hir>);
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
if self.current_id.local_id.index() != 0 { if self.current_id.local_id.index() != 0 {
self.current_id.local_id = ItemLocalId::new(0); self.current_id.local_id = ItemLocalId::new(0);
if let Some(node) = self.map.find(self.current_id) { if let Some(node) = self.map.tcx.hir_owner(self.current_id.owner) {
return Some((self.current_id, node)); return Some((self.current_id, node.node));
} }
} }
if self.current_id == CRATE_HIR_ID { if self.current_id == CRATE_HIR_ID {
@ -144,8 +144,8 @@ impl<'hir> Iterator for ParentOwnerIterator<'_, 'hir> {
self.current_id = HirId::make_owner(parent_id); self.current_id = HirId::make_owner(parent_id);
// If this `HirId` doesn't have an entry, skip it and look for its `parent_id`. // If this `HirId` doesn't have an entry, skip it and look for its `parent_id`.
if let Some(node) = self.map.find(self.current_id) { if let Some(node) = self.map.tcx.hir_owner(self.current_id.owner) {
return Some((self.current_id, node)); return Some((self.current_id, node.node));
} }
} }
} }
@ -313,7 +313,7 @@ impl<'hir> Map<'hir> {
pub fn find(&self, id: HirId) -> Option<Node<'hir>> { pub fn find(&self, id: HirId) -> Option<Node<'hir>> {
if id.local_id == ItemLocalId::from_u32(0) { if id.local_id == ItemLocalId::from_u32(0) {
let owner = self.tcx.hir_owner(id.owner)?; let owner = self.tcx.hir_owner(id.owner)?;
Some(owner.node) Some(owner.node.into())
} else { } else {
let owner = self.tcx.hir_owner_nodes(id.owner)?; let owner = self.tcx.hir_owner_nodes(id.owner)?;
let node = owner.nodes[id.local_id].as_ref()?; let node = owner.nodes[id.local_id].as_ref()?;
@ -331,10 +331,12 @@ impl<'hir> Map<'hir> {
} }
pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>> { pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>> {
self.get_if_local(id).and_then(|node| match &node { let id = id.as_local()?;
Node::ImplItem(impl_item) => Some(&impl_item.generics), let node = self.tcx.hir_owner(id)?;
Node::TraitItem(trait_item) => Some(&trait_item.generics), match node.node {
Node::Item(Item { OwnerNode::ImplItem(impl_item) => Some(&impl_item.generics),
OwnerNode::TraitItem(trait_item) => Some(&trait_item.generics),
OwnerNode::Item(Item {
kind: kind:
ItemKind::Fn(_, generics, _) ItemKind::Fn(_, generics, _)
| ItemKind::TyAlias(_, generics) | ItemKind::TyAlias(_, generics)
@ -347,35 +349,23 @@ impl<'hir> Map<'hir> {
.. ..
}) => Some(generics), }) => Some(generics),
_ => None, _ => None,
}) }
} }
pub fn item(&self, id: ItemId) -> &'hir Item<'hir> { pub fn item(&self, id: ItemId) -> &'hir Item<'hir> {
match self.find(id.hir_id()).unwrap() { self.tcx.hir_owner(id.def_id).unwrap().node.expect_item()
Node::Item(item) => item,
_ => bug!(),
}
} }
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> { pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
match self.find(id.hir_id()).unwrap() { self.tcx.hir_owner(id.def_id).unwrap().node.expect_trait_item()
Node::TraitItem(item) => item,
_ => bug!(),
}
} }
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> { pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
match self.find(id.hir_id()).unwrap() { self.tcx.hir_owner(id.def_id).unwrap().node.expect_impl_item()
Node::ImplItem(item) => item,
_ => bug!(),
}
} }
pub fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> { pub fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
match self.find(id.hir_id()).unwrap() { self.tcx.hir_owner(id.def_id).unwrap().node.expect_foreign_item()
Node::ForeignItem(item) => item,
_ => bug!(),
}
} }
pub fn body(&self, id: BodyId) -> &'hir Body<'hir> { pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
@ -519,10 +509,12 @@ impl<'hir> Map<'hir> {
} }
pub fn get_module(&self, module: LocalDefId) -> (&'hir Mod<'hir>, Span, HirId) { pub fn get_module(&self, module: LocalDefId) -> (&'hir Mod<'hir>, Span, HirId) {
let hir_id = self.local_def_id_to_hir_id(module); let hir_id = HirId::make_owner(module);
match self.get(hir_id) { match self.tcx.hir_owner(module).map(|o| o.node) {
Node::Item(&Item { span, kind: ItemKind::Mod(ref m), .. }) => (m, span, hir_id), Some(OwnerNode::Item(&Item { span, kind: ItemKind::Mod(ref m), .. })) => {
Node::Crate(item) => (&item, item.inner, hir_id), (m, span, hir_id)
}
Some(OwnerNode::Crate(item)) => (item, item.inner, hir_id),
node => panic!("not a module: {:?}", node), node => panic!("not a module: {:?}", node),
} }
} }
@ -554,8 +546,8 @@ impl<'hir> Map<'hir> {
where where
V: Visitor<'hir>, V: Visitor<'hir>,
{ {
for id in self.krate().exported_macros { for macro_def in self.krate().exported_macros() {
visitor.visit_macro_def(self.expect_macro_def(id.hir_id())); visitor.visit_macro_def(macro_def);
} }
} }
@ -659,24 +651,20 @@ impl<'hir> Map<'hir> {
/// in the HIR which is recorded by the map and is an item, either an item /// in the HIR which is recorded by the map and is an item, either an item
/// in a module, trait, or impl. /// in a module, trait, or impl.
pub fn get_parent_item(&self, hir_id: HirId) -> HirId { pub fn get_parent_item(&self, hir_id: HirId) -> HirId {
for (hir_id, node) in self.parent_owner_iter(hir_id) { if let Some((hir_id, _node)) = self.parent_owner_iter(hir_id).next() {
if let Node::Crate(_) // A MacroDef does not have children.
| Node::Item(_) debug_assert!(!matches!(_node, OwnerNode::MacroDef(_)));
| Node::ForeignItem(_) hir_id
| Node::TraitItem(_) } else {
| Node::ImplItem(_) = node CRATE_HIR_ID
{
return hir_id;
}
} }
CRATE_HIR_ID
} }
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no /// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
/// module parent is in this map. /// module parent is in this map.
pub(super) fn get_module_parent_node(&self, hir_id: HirId) -> HirId { pub(super) fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
for (hir_id, node) in self.parent_owner_iter(hir_id) { for (hir_id, node) in self.parent_owner_iter(hir_id) {
if let Node::Item(&Item { kind: ItemKind::Mod(_), .. }) = node { if let OwnerNode::Item(&Item { kind: ItemKind::Mod(_), .. }) = node {
return hir_id; return hir_id;
} }
} }
@ -749,8 +737,9 @@ impl<'hir> Map<'hir> {
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi { pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
let parent = self.get_parent_item(hir_id); let parent = self.get_parent_item(hir_id);
if let Some(node) = self.find(parent) { if let Some(node) = self.tcx.hir_owner(self.local_def_id(parent)) {
if let Node::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) = node { if let OwnerNode::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) = node.node
{
return *abi; return *abi;
} }
} }
@ -758,22 +747,22 @@ impl<'hir> Map<'hir> {
} }
pub fn expect_item(&self, id: HirId) -> &'hir Item<'hir> { pub fn expect_item(&self, id: HirId) -> &'hir Item<'hir> {
match self.find(id) { match self.tcx.hir_owner(id.expect_owner()) {
Some(Node::Item(item)) => item, Some(Owner { node: OwnerNode::Item(item) }) => item,
_ => bug!("expected item, found {}", self.node_to_string(id)), _ => bug!("expected item, found {}", self.node_to_string(id)),
} }
} }
pub fn expect_impl_item(&self, id: HirId) -> &'hir ImplItem<'hir> { pub fn expect_impl_item(&self, id: HirId) -> &'hir ImplItem<'hir> {
match self.find(id) { match self.tcx.hir_owner(id.expect_owner()) {
Some(Node::ImplItem(item)) => item, Some(Owner { node: OwnerNode::ImplItem(item) }) => item,
_ => bug!("expected impl item, found {}", self.node_to_string(id)), _ => bug!("expected impl item, found {}", self.node_to_string(id)),
} }
} }
pub fn expect_trait_item(&self, id: HirId) -> &'hir TraitItem<'hir> { pub fn expect_trait_item(&self, id: HirId) -> &'hir TraitItem<'hir> {
match self.find(id) { match self.tcx.hir_owner(id.expect_owner()) {
Some(Node::TraitItem(item)) => item, Some(Owner { node: OwnerNode::TraitItem(item) }) => item,
_ => bug!("expected trait item, found {}", self.node_to_string(id)), _ => bug!("expected trait item, found {}", self.node_to_string(id)),
} }
} }
@ -786,15 +775,15 @@ impl<'hir> Map<'hir> {
} }
pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem<'hir> { pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem<'hir> {
match self.find(id) { match self.tcx.hir_owner(id.expect_owner()) {
Some(Node::ForeignItem(item)) => item, Some(Owner { node: OwnerNode::ForeignItem(item) }) => item,
_ => bug!("expected foreign item, found {}", self.node_to_string(id)), _ => bug!("expected foreign item, found {}", self.node_to_string(id)),
} }
} }
pub fn expect_macro_def(&self, id: HirId) -> &'hir MacroDef<'hir> { pub fn expect_macro_def(&self, id: HirId) -> &'hir MacroDef<'hir> {
match self.find(id) { match self.tcx.hir_owner(id.expect_owner()) {
Some(Node::MacroDef(macro_def)) => macro_def, Some(Owner { node: OwnerNode::MacroDef(macro_def) }) => macro_def,
_ => bug!("expected macro def, found {}", self.node_to_string(id)), _ => bug!("expected macro def, found {}", self.node_to_string(id)),
} }
} }

View file

@ -33,9 +33,12 @@ pub struct IndexedHir<'hir> {
/// Top-level HIR node for current owner. This only contains the node for which /// Top-level HIR node for current owner. This only contains the node for which
/// `HirId::local_id == 0`, and excludes bodies. /// `HirId::local_id == 0`, and excludes bodies.
///
/// This struct exists to encapsulate all access to the hir_owner query in this module, and to
/// implement HashStable without hashing bodies.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct Owner<'tcx> { pub struct Owner<'tcx> {
node: Node<'tcx>, node: OwnerNode<'tcx>,
} }
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> { impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> {
@ -140,7 +143,8 @@ pub fn provide(providers: &mut Providers) {
providers.hir_module_items = |tcx, id| &tcx.untracked_crate.modules[&id]; providers.hir_module_items = |tcx, id| &tcx.untracked_crate.modules[&id];
providers.hir_owner = |tcx, id| { providers.hir_owner = |tcx, id| {
let owner = tcx.index_hir(()).map[id].as_ref()?; let owner = tcx.index_hir(()).map[id].as_ref()?;
let node = owner.nodes[ItemLocalId::new(0)].as_ref()?.node; let node = owner.nodes[ItemLocalId::new(0)].as_ref().unwrap().node;
let node = node.as_owner().unwrap(); // Indexing must ensure it is an OwnerNode.
Some(Owner { node }) Some(Owner { node })
}; };
providers.hir_owner_nodes = |tcx, id| tcx.index_hir(()).map[id].as_deref(); providers.hir_owner_nodes = |tcx, id| tcx.index_hir(()).map[id].as_deref();

View file

@ -2307,7 +2307,7 @@ define_print_and_forward_display! {
fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, Namespace, DefId)) { fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, Namespace, DefId)) {
// Iterate all local crate items no matter where they are defined. // Iterate all local crate items no matter where they are defined.
let hir = tcx.hir(); let hir = tcx.hir();
for item in hir.krate().items.values() { for item in hir.krate().items() {
if item.ident.name.as_str().is_empty() || matches!(item.kind, ItemKind::Use(_, _)) { if item.ident.name.as_str().is_empty() || matches!(item.kind, ItemKind::Use(_, _)) {
continue; continue;
} }

View file

@ -1644,11 +1644,11 @@ fn check_invalid_macro_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
let check_attr_visitor = &mut CheckAttrVisitor { tcx }; let check_attr_visitor = &mut CheckAttrVisitor { tcx };
tcx.hir().visit_item_likes_in_module(module_def_id, &mut check_attr_visitor.as_deep_visitor()); tcx.hir().visit_item_likes_in_module(module_def_id, &mut check_attr_visitor.as_deep_visitor());
tcx.hir().visit_exported_macros_in_krate(check_attr_visitor);
check_invalid_macro_level_attr(tcx, tcx.hir().krate().non_exported_macro_attrs);
if module_def_id.is_top_level_module() { if module_def_id.is_top_level_module() {
check_attr_visitor.check_attributes(CRATE_HIR_ID, &DUMMY_SP, Target::Mod, None); check_attr_visitor.check_attributes(CRATE_HIR_ID, &DUMMY_SP, Target::Mod, None);
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs()); check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
tcx.hir().visit_exported_macros_in_krate(check_attr_visitor);
check_invalid_macro_level_attr(tcx, tcx.hir().krate().non_exported_macro_attrs);
} }
} }

View file

@ -108,7 +108,7 @@ fn diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> FxHashMap<Symbol
// Collect diagnostic items in this crate. // Collect diagnostic items in this crate.
tcx.hir().krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
for m in tcx.hir().krate().exported_macros { for m in tcx.hir().krate().exported_macros() {
collector.observe_item(m.def_id); collector.observe_item(m.def_id);
} }

View file

@ -183,7 +183,7 @@ fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) -> Option<(De
} }
fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) { fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
let sp = tcx.hir().krate().item.inner; let sp = tcx.hir().krate().module().inner;
if *tcx.sess.parse_sess.reached_eof.borrow() { if *tcx.sess.parse_sess.reached_eof.borrow() {
// There's an unclosed brace that made the parser reach `Eof`, we shouldn't complain about // There's an unclosed brace that made the parser reach `Eof`, we shouldn't complain about
// the missing `fn main()` then as it might have been hidden inside an unclosed block. // the missing `fn main()` then as it might have been hidden inside an unclosed block.

View file

@ -732,7 +732,7 @@ fn stability_index(tcx: TyCtxt<'tcx>, (): ()) -> Index<'tcx> {
annotator.annotate( annotator.annotate(
hir::CRATE_HIR_ID, hir::CRATE_HIR_ID,
krate.item.inner, krate.module().inner,
None, None,
AnnotationKind::Required, AnnotationKind::Required,
InheritDeprecation::Yes, InheritDeprecation::Yes,
@ -929,7 +929,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
if tcx.stability().staged_api[&LOCAL_CRATE] { if tcx.stability().staged_api[&LOCAL_CRATE] {
let krate = tcx.hir().krate(); let krate = tcx.hir().krate();
let mut missing = MissingStabilityAnnotations { tcx, access_levels }; let mut missing = MissingStabilityAnnotations { tcx, access_levels };
missing.check_missing_stability(hir::CRATE_HIR_ID, krate.item.inner); missing.check_missing_stability(hir::CRATE_HIR_ID, krate.module().inner);
intravisit::walk_crate(&mut missing, krate); intravisit::walk_crate(&mut missing, krate);
krate.visit_all_item_likes(&mut missing.as_deep_visitor()); krate.visit_all_item_likes(&mut missing.as_deep_visitor());
} }

View file

@ -1015,24 +1015,17 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
// Ensure that the parent of the def is an item, not HRTB // Ensure that the parent of the def is an item, not HRTB
let parent_id = self.tcx.hir().get_parent_node(hir_id); let parent_id = self.tcx.hir().get_parent_node(hir_id);
let parent_is_item = if let Some(parent_def_id) = // FIXME(cjgillot) Can this check be replaced by
parent_id.as_owner() // `let parent_is_item = parent_id.is_owner();`?
{ let parent_is_item =
let parent_item_id = hir::ItemId { def_id: parent_def_id }; if let Some(parent_def_id) = parent_id.as_owner() {
let parent_impl_id = hir::ImplItemId { def_id: parent_def_id }; matches!(
let parent_trait_id = self.tcx.hir().krate().owners.get(parent_def_id),
hir::TraitItemId { def_id: parent_def_id }; Some(Some(_)),
let parent_foreign_id = )
hir::ForeignItemId { def_id: parent_def_id }; } else {
let krate = self.tcx.hir().krate(); false
};
krate.items.contains_key(&parent_item_id)
|| krate.impl_items.contains_key(&parent_impl_id)
|| krate.trait_items.contains_key(&parent_trait_id)
|| krate.foreign_items.contains_key(&parent_foreign_id)
} else {
false
};
if !parent_is_item { if !parent_is_item {
if !self.trait_definition_only { if !self.trait_definition_only {

View file

@ -146,7 +146,7 @@ impl<'tcx> DumpVisitor<'tcx> {
}, },
crate_root: crate_root.unwrap_or_else(|| "<no source>".to_owned()), crate_root: crate_root.unwrap_or_else(|| "<no source>".to_owned()),
external_crates: self.save_ctxt.get_external_crates(), external_crates: self.save_ctxt.get_external_crates(),
span: self.span_from_span(krate.item.inner), span: self.span_from_span(krate.module().inner),
}; };
self.dumper.crate_prelude(data); self.dumper.crate_prelude(data);
@ -1092,11 +1092,12 @@ impl<'tcx> DumpVisitor<'tcx> {
format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(id).to_def_id())); format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(id).to_def_id()));
let sm = self.tcx.sess.source_map(); let sm = self.tcx.sess.source_map();
let filename = sm.span_to_filename(krate.item.inner); let krate_mod = krate.module();
let filename = sm.span_to_filename(krate_mod.inner);
let data_id = id_from_hir_id(id, &self.save_ctxt); let data_id = id_from_hir_id(id, &self.save_ctxt);
let children = let children =
krate.item.item_ids.iter().map(|i| id_from_def_id(i.def_id.to_def_id())).collect(); krate_mod.item_ids.iter().map(|i| id_from_def_id(i.def_id.to_def_id())).collect();
let span = self.span_from_span(krate.item.inner); let span = self.span_from_span(krate_mod.inner);
let attrs = self.tcx.hir().attrs(id); let attrs = self.tcx.hir().attrs(id);
self.dumper.dump_def( self.dumper.dump_def(

View file

@ -227,7 +227,7 @@ impl ExternalCrate {
if root.is_local() { if root.is_local() {
tcx.hir() tcx.hir()
.krate() .krate()
.item .module()
.item_ids .item_ids
.iter() .iter()
.filter_map(|&id| { .filter_map(|&id| {
@ -293,7 +293,7 @@ impl ExternalCrate {
if root.is_local() { if root.is_local() {
tcx.hir() tcx.hir()
.krate() .krate()
.item .module()
.item_ids .item_ids
.iter() .iter()
.filter_map(|&id| { .filter_map(|&id| {

View file

@ -144,7 +144,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
hir_collector.visit_testable( hir_collector.visit_testable(
"".to_string(), "".to_string(),
CRATE_HIR_ID, CRATE_HIR_ID,
krate.item.inner, krate.module().inner,
|this| { |this| {
intravisit::walk_crate(this, krate); intravisit::walk_crate(this, krate);
}, },

View file

@ -72,18 +72,18 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
} }
crate fn visit(mut self, krate: &'tcx hir::Crate<'_>) -> Module<'tcx> { crate fn visit(mut self, krate: &'tcx hir::Crate<'_>) -> Module<'tcx> {
let span = krate.item.inner; let span = krate.module().inner;
let mut top_level_module = self.visit_mod_contents( let mut top_level_module = self.visit_mod_contents(
&Spanned { span, node: hir::VisibilityKind::Public }, &Spanned { span, node: hir::VisibilityKind::Public },
hir::CRATE_HIR_ID, hir::CRATE_HIR_ID,
&krate.item, &krate.module(),
self.cx.tcx.crate_name(LOCAL_CRATE), self.cx.tcx.crate_name(LOCAL_CRATE),
); );
// Attach the crate's exported macros to the top-level module. // Attach the crate's exported macros to the top-level module.
// In the case of macros 2.0 (`pub macro`), and for built-in `derive`s or attributes as // In the case of macros 2.0 (`pub macro`), and for built-in `derive`s or attributes as
// well (_e.g._, `Copy`), these are wrongly bundled in there too, so we need to fix that by // well (_e.g._, `Copy`), these are wrongly bundled in there too, so we need to fix that by
// moving them back to their correct locations. // moving them back to their correct locations.
'exported_macros: for def in krate.exported_macros { 'exported_macros: for def in krate.exported_macros() {
// The `def` of a macro in `exported_macros` should correspond to either: // The `def` of a macro in `exported_macros` should correspond to either:
// - a `#[macro_export] macro_rules!` macro, // - a `#[macro_export] macro_rules!` macro,
// - a built-in `derive` (or attribute) macro such as the ones in `::core`, // - a built-in `derive` (or attribute) macro such as the ones in `::core`,

View file

@ -33,7 +33,7 @@ macro_rules! fake_lint_pass {
if !cx.sess().contains_name(attrs, $attr) { if !cx.sess().contains_name(attrs, $attr) {
cx.lint(CRATE_NOT_OKAY, |lint| { cx.lint(CRATE_NOT_OKAY, |lint| {
let msg = format!("crate is not marked with #![{}]", $attr); let msg = format!("crate is not marked with #![{}]", $attr);
lint.build(&msg).set_span(krate.item.inner).emit() lint.build(&msg).set_span(krate.module().inner).emit()
}); });
} }
)* )*

View file

@ -31,7 +31,7 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) { if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) {
cx.lint(CRATE_NOT_OKAY, |lint| { cx.lint(CRATE_NOT_OKAY, |lint| {
lint.build("crate is not marked with #![crate_okay]") lint.build("crate is not marked with #![crate_okay]")
.set_span(krate.item.inner) .set_span(krate.module().inner)
.emit() .emit()
}); });
} }

View file

@ -1,18 +1,3 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-48027.rs:6:6
|
LL | impl dyn Bar {}
| ^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-48027.rs:2:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
error[E0283]: type annotations needed error[E0283]: type annotations needed
--> $DIR/issue-48027.rs:3:32 --> $DIR/issue-48027.rs:3:32
| |
@ -30,6 +15,21 @@ note: required by `Bar::X`
LL | const X: usize; LL | const X: usize;
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-48027.rs:6:6
|
LL | impl dyn Bar {}
| ^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-48027.rs:2:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
Some errors have detailed explanations: E0038, E0283. Some errors have detailed explanations: E0038, E0283.

View file

@ -13,6 +13,21 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
= help: the following implementations were found: = help: the following implementations were found:
<&T as Clone> <&T as Clone>
error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-2.rs:4:8
|
LL | trait Z<'a, T: ?Sized>
| - required by a bound in this
LL | where
LL | T: Z<'a, u16>,
| ^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `<u16 as Z<'b, u16>>::W`
...
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ----- required by this bound in `Z`
|
= help: the following implementations were found:
<&T as Clone>
error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-2.rs:16:14 --> $DIR/hr-associated-type-bound-param-2.rs:16:14
| |
@ -28,21 +43,6 @@ LL | type W = str;
= help: the following implementations were found: = help: the following implementations were found:
<&T as Clone> <&T as Clone>
error[E0277]: the trait bound `for<'b> <u16 as Z<'b, u16>>::W: Clone` is not satisfied
--> $DIR/hr-associated-type-bound-param-2.rs:4:8
|
LL | trait Z<'a, T: ?Sized>
| - required by a bound in this
LL | where
LL | T: Z<'a, u16>,
| ^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `<u16 as Z<'b, u16>>::W`
...
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
| ----- required by this bound in `Z`
|
= help: the following implementations were found:
<&T as Clone>
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0277`.

View file

@ -46,6 +46,15 @@ LL | impl<const N: &u8> A<N> {
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#![feature(const_generics)]` = help: more complex types are supported with `#![feature(const_generics)]`
error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:18:21
|
LL | fn foo<const M: &u8>(&self) {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#![feature(const_generics)]`
error: `&'static u8` is forbidden as the type of a const generic parameter error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:23:15 --> $DIR/const-param-elided-lifetime.rs:23:15
| |
@ -64,15 +73,6 @@ LL | fn bar<const N: &u8>() {}
= note: the only supported types are integers, `bool` and `char` = note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#![feature(const_generics)]` = help: more complex types are supported with `#![feature(const_generics)]`
error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/const-param-elided-lifetime.rs:18:21
|
LL | fn foo<const M: &u8>(&self) {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
= help: more complex types are supported with `#![feature(const_generics)]`
error: aborting due to 10 previous errors error: aborting due to 10 previous errors
For more information about this error, try `rustc --explain E0637`. For more information about this error, try `rustc --explain E0637`.

View file

@ -16,6 +16,12 @@ error: no path from `WillChange` to `trait_def`
LL | #[rustc_then_this_would_need(trait_def)] LL | #[rustc_then_this_would_need(trait_def)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:31:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK error: OK
--> $DIR/dep-graph-struct-signature.rs:35:5 --> $DIR/dep-graph-struct-signature.rs:35:5
| |
@ -46,12 +52,36 @@ error: OK
LL | #[rustc_then_this_would_need(type_of)] LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:47:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:48:9
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK error: OK
--> $DIR/dep-graph-struct-signature.rs:52:5 --> $DIR/dep-graph-struct-signature.rs:52:5
| |
LL | #[rustc_then_this_would_need(type_of)] LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:54:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:55:9
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK error: OK
--> $DIR/dep-graph-struct-signature.rs:60:9 --> $DIR/dep-graph-struct-signature.rs:60:9
| |
@ -76,6 +106,12 @@ error: no path from `WillChange` to `type_of`
LL | #[rustc_then_this_would_need(type_of)] LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: no path from `WillChange` to `fn_sig`
--> $DIR/dep-graph-struct-signature.rs:76:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: no path from `WillChange` to `fn_sig` error: no path from `WillChange` to `fn_sig`
--> $DIR/dep-graph-struct-signature.rs:80:5 --> $DIR/dep-graph-struct-signature.rs:80:5
| |
@ -94,41 +130,5 @@ error: no path from `WillChange` to `typeck`
LL | #[rustc_then_this_would_need(typeck)] LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:31:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: no path from `WillChange` to `fn_sig`
--> $DIR/dep-graph-struct-signature.rs:76:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:47:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:48:9
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:54:9
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-struct-signature.rs:55:9
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 22 previous errors error: aborting due to 22 previous errors

View file

@ -28,12 +28,30 @@ error: no path from `TypeAlias` to `type_of`
LL | #[rustc_then_this_would_need(type_of)] LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-type-alias.rs:35:5
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: no path from `TypeAlias` to `type_of` error: no path from `TypeAlias` to `type_of`
--> $DIR/dep-graph-type-alias.rs:41:1 --> $DIR/dep-graph-type-alias.rs:41:1
| |
LL | #[rustc_then_this_would_need(type_of)] LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-type-alias.rs:43:5
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-type-alias.rs:44:5
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK error: OK
--> $DIR/dep-graph-type-alias.rs:48:1 --> $DIR/dep-graph-type-alias.rs:48:1
| |
@ -52,23 +70,5 @@ error: OK
LL | #[rustc_then_this_would_need(typeck)] LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-type-alias.rs:35:5
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-type-alias.rs:43:5
|
LL | #[rustc_then_this_would_need(fn_sig)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: OK
--> $DIR/dep-graph-type-alias.rs:44:5
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors error: aborting due to 12 previous errors

View file

@ -1,17 +1,17 @@
error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types` feature error[E0658]: `*const Foo` cannot be used as the type of `self` without the `arbitrary_self_types` feature
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:9:18 --> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:4:18
| |
LL | fn bar(self: *const Self); LL | fn foo(self: *const Self) {}
| ^^^^^^^^^^^ | ^^^^^^^^^^^
| |
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
error[E0658]: `*const Foo` cannot be used as the type of `self` without the `arbitrary_self_types` feature error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types` feature
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:4:18 --> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:9:18
| |
LL | fn foo(self: *const Self) {} LL | fn bar(self: *const Self);
| ^^^^^^^^^^^ | ^^^^^^^^^^^
| |
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information

View file

@ -25,6 +25,47 @@ LL | impl<T> Foo for T where NoData<T>: Foo {
= note: 127 redundant requirements hidden = note: 127 redundant requirements hidden
= note: required because of the requirements on the impl of `Foo` for `NoData<T>` = note: required because of the requirements on the impl of `Foo` for `NoData<T>`
error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
--> $DIR/issue-20413.rs:8:36
|
LL | trait Foo {
| --------- required by this bound in `Foo`
...
LL | impl<T> Foo for T where NoData<T>: Foo {
| ^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`)
note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/issue-20413.rs:8:9
|
LL | impl<T> Foo for T where NoData<T>: Foo {
| ^^^ ^
= note: 127 redundant requirements hidden
= note: required because of the requirements on the impl of `Foo` for `NoData<T>`
error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz`
--> $DIR/issue-20413.rs:28:42
|
LL | trait Baz {
| --------- required by this bound in `Baz`
...
LL | impl<T> Bar for T where EvenLessData<T>: Baz {
| ^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`)
note: required because of the requirements on the impl of `Bar` for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/issue-20413.rs:28:9
|
LL | impl<T> Bar for T where EvenLessData<T>: Baz {
| ^^^ ^
note: required because of the requirements on the impl of `Baz` for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/issue-20413.rs:36:9
|
LL | impl<T> Baz for T where AlmostNoData<T>: Bar {
| ^^^ ^
= note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `Baz` for `EvenLessData<T>`
error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz` error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz`
--> $DIR/issue-20413.rs:28:42 --> $DIR/issue-20413.rs:28:42
| |
@ -71,47 +112,6 @@ LL | impl<T> Bar for T where EvenLessData<T>: Baz {
= note: 126 redundant requirements hidden = note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `Bar` for `AlmostNoData<T>` = note: required because of the requirements on the impl of `Bar` for `AlmostNoData<T>`
error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
--> $DIR/issue-20413.rs:8:36
|
LL | trait Foo {
| --------- required by this bound in `Foo`
...
LL | impl<T> Foo for T where NoData<T>: Foo {
| ^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`)
note: required because of the requirements on the impl of `Foo` for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/issue-20413.rs:8:9
|
LL | impl<T> Foo for T where NoData<T>: Foo {
| ^^^ ^
= note: 127 redundant requirements hidden
= note: required because of the requirements on the impl of `Foo` for `NoData<T>`
error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz`
--> $DIR/issue-20413.rs:28:42
|
LL | trait Baz {
| --------- required by this bound in `Baz`
...
LL | impl<T> Bar for T where EvenLessData<T>: Baz {
| ^^^
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_20413`)
note: required because of the requirements on the impl of `Bar` for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/issue-20413.rs:28:9
|
LL | impl<T> Bar for T where EvenLessData<T>: Baz {
| ^^^ ^
note: required because of the requirements on the impl of `Baz` for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/issue-20413.rs:36:9
|
LL | impl<T> Baz for T where AlmostNoData<T>: Bar {
| ^^^ ^
= note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `Baz` for `EvenLessData<T>`
error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar` error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar`
--> $DIR/issue-20413.rs:36:42 --> $DIR/issue-20413.rs:36:42
| |

View file

@ -1,22 +1,3 @@
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/adt-param-with-implicit-sized-bound.rs:25:9
|
LL | struct X<T>(T);
| - required by this bound in `X`
...
LL | struct Struct5<T: ?Sized>{
| - this type parameter needs to be `std::marker::Sized`
LL | _t: X<T>,
| ^^^^ doesn't have a size known at compile-time
|
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
|
LL | struct X<T>(T);
| ^ - ...if indirection were used here: `Box<T>`
| |
| this could be changed to `T: ?Sized`...
error[E0277]: the size for values of type `Self` cannot be known at compilation time error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/adt-param-with-implicit-sized-bound.rs:2:19 --> $DIR/adt-param-with-implicit-sized-bound.rs:2:19
| |
@ -92,6 +73,25 @@ help: consider relaxing the implicit `Sized` restriction
LL | struct Struct4<T: ?Sized>{ LL | struct Struct4<T: ?Sized>{
| ^^^^^^^^ | ^^^^^^^^
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/adt-param-with-implicit-sized-bound.rs:25:9
|
LL | struct X<T>(T);
| - required by this bound in `X`
...
LL | struct Struct5<T: ?Sized>{
| - this type parameter needs to be `std::marker::Sized`
LL | _t: X<T>,
| ^^^^ doesn't have a size known at compile-time
|
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
|
LL | struct X<T>(T);
| ^ - ...if indirection were used here: `Box<T>`
| |
| this could be changed to `T: ?Sized`...
error: aborting due to 5 previous errors error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0277`. For more information about this error, try `rustc --explain E0277`.

View file

@ -1,3 +1,12 @@
error[E0307]: invalid `self` parameter type: ()
--> $DIR/object-unsafe-trait-should-use-where-sized.rs:6:18
|
LL | fn bar(self: ()) {}
| ^^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
error[E0038]: the trait `Trait` cannot be made into an object error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/object-unsafe-trait-should-use-where-sized.rs:9:12 --> $DIR/object-unsafe-trait-should-use-where-sized.rs:9:12
| |
@ -26,15 +35,6 @@ help: consider changing method `bar`'s `self` parameter to be `&self`
LL | fn bar(self: &Self) {} LL | fn bar(self: &Self) {}
| ^^^^^ | ^^^^^
error[E0307]: invalid `self` parameter type: ()
--> $DIR/object-unsafe-trait-should-use-where-sized.rs:6:18
|
LL | fn bar(self: ()) {}
| ^^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
Some errors have detailed explanations: E0038, E0307. Some errors have detailed explanations: E0038, E0307.

View file

@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) { fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID); let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
self.check_missing_docs_attrs(cx, attrs, krate.item.inner, "the", "crate"); self.check_missing_docs_attrs(cx, attrs, krate.module().inner, "the", "crate");
} }
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) { fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {