Skip to content

Rollup of 8 pull requests #103712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
328f817
Make `CStr::from_ptr` `const`.
reitermarkus Oct 12, 2022
36dbb07
Update docs for `CStr::from_ptr`.
reitermarkus Oct 12, 2022
4accf83
Note scope of TAIT more accurately
compiler-errors Oct 22, 2022
509d8ad
rustdoc: remove redundant `div.search-container`
notriddle Oct 27, 2022
92b314b
add test for issue 98634
Rageking8 Oct 21, 2022
d7edda7
Rename some `OwnerId` fields.
nnethercote Oct 27, 2022
064ad83
rustdoc-json-types: Improve ItemSummary::path docs
aDotInTheVoid Oct 28, 2022
b3f9277
Remove unneeded attribute.
reitermarkus Oct 28, 2022
6bc5fdd
Add a test for TAIT used with impl/dyn Trait inside RPIT
xxchan Oct 28, 2022
298253a
Specialize ToString for Symbol
camsteffen Oct 27, 2022
5b45bfe
Rollup merge of #102961 - reitermarkus:const-cstr-from-ptr, r=oli-obk
matthiaskrgr Oct 29, 2022
b3bd24e
Rollup merge of #103342 - Rageking8:add-test-for-issue-98634, r=compi…
matthiaskrgr Oct 29, 2022
89735ec
Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obk
matthiaskrgr Oct 29, 2022
4d988ce
Rollup merge of #103618 - nnethercote:rename-OwnerId-fields, r=compil…
matthiaskrgr Oct 29, 2022
50a6af2
Rollup merge of #103656 - camsteffen:symbol-to-string, r=compiler-errors
matthiaskrgr Oct 29, 2022
37604ab
Rollup merge of #103663 - notriddle:notriddle/search-container, r=Gui…
matthiaskrgr Oct 29, 2022
31d81b8
Rollup merge of #103664 - aDotInTheVoid:rdj-path-docs, r=Urgau,Guilla…
matthiaskrgr Oct 29, 2022
4c7f49a
Rollup merge of #103704 - xxchan:xxchan/applicable-bug, r=compiler-er…
matthiaskrgr Oct 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions compiler/rustc_ast_lowering/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {

fn visit_nested_item(&mut self, item: ItemId) {
debug!("visit_nested_item: {:?}", item);
self.insert_nested(item.def_id.def_id);
self.insert_nested(item.owner_id.def_id);
}

fn visit_nested_trait_item(&mut self, item_id: TraitItemId) {
self.insert_nested(item_id.def_id.def_id);
self.insert_nested(item_id.owner_id.def_id);
}

fn visit_nested_impl_item(&mut self, item_id: ImplItemId) {
self.insert_nested(item_id.def_id.def_id);
self.insert_nested(item_id.owner_id.def_id);
}

fn visit_nested_foreign_item(&mut self, foreign_id: ForeignItemId) {
self.insert_nested(foreign_id.def_id.def_id);
self.insert_nested(foreign_id.owner_id.def_id);
}

fn visit_nested_body(&mut self, id: BodyId) {
Expand All @@ -143,7 +143,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {

#[instrument(level = "debug", skip(self))]
fn visit_item(&mut self, i: &'hir Item<'hir>) {
debug_assert_eq!(i.def_id, self.owner);
debug_assert_eq!(i.owner_id, self.owner);
self.with_parent(i.hir_id(), |this| {
if let ItemKind::Struct(ref struct_def, _) = i.kind {
// If this is a tuple or unit-like struct, register the constructor.
Expand All @@ -157,7 +157,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {

#[instrument(level = "debug", skip(self))]
fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) {
debug_assert_eq!(fi.def_id, self.owner);
debug_assert_eq!(fi.owner_id, self.owner);
self.with_parent(fi.hir_id(), |this| {
intravisit::walk_foreign_item(this, fi);
});
Expand All @@ -176,15 +176,15 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {

#[instrument(level = "debug", skip(self))]
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
debug_assert_eq!(ti.def_id, self.owner);
debug_assert_eq!(ti.owner_id, self.owner);
self.with_parent(ti.hir_id(), |this| {
intravisit::walk_trait_item(this, ti);
});
}

#[instrument(level = "debug", skip(self))]
fn visit_impl_item(&mut self, ii: &'hir ImplItem<'hir>) {
debug_assert_eq!(ii.def_id, self.owner);
debug_assert_eq!(ii.owner_id, self.owner);
self.with_parent(ii.hir_id(), |this| {
intravisit::walk_impl_item(this, ii);
});
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

pub(super) fn lower_item_ref(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
let mut node_ids =
smallvec![hir::ItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } }];
smallvec![hir::ItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } }];
if let ItemKind::Use(ref use_tree) = &i.kind {
self.lower_item_id_use_tree(use_tree, i.id, &mut node_ids);
}
Expand All @@ -195,7 +195,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
UseTreeKind::Nested(ref nested_vec) => {
for &(ref nested, id) in nested_vec {
vec.push(hir::ItemId {
def_id: hir::OwnerId { def_id: self.local_def_id(id) },
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
});
self.lower_item_id_use_tree(nested, id, vec);
}
Expand All @@ -206,7 +206,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
iter::zip(self.expect_full_res_from_use(base_id).skip(1), &[id1, id2])
{
vec.push(hir::ItemId {
def_id: hir::OwnerId { def_id: self.local_def_id(id) },
owner_id: hir::OwnerId { def_id: self.local_def_id(id) },
});
}
}
Expand All @@ -220,7 +220,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let attrs = self.lower_attrs(hir_id, &i.attrs);
let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, vis_span, &i.kind);
let item = hir::Item {
def_id: hir_id.expect_owner(),
owner_id: hir_id.expect_owner(),
ident: self.lower_ident(ident),
kind,
vis_span,
Expand Down Expand Up @@ -562,7 +562,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

let item = hir::Item {
def_id: hir::OwnerId { def_id: new_id },
owner_id: hir::OwnerId { def_id: new_id },
ident: this.lower_ident(ident),
kind,
vis_span,
Expand Down Expand Up @@ -640,7 +640,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

let item = hir::Item {
def_id: hir::OwnerId { def_id: new_hir_id },
owner_id: hir::OwnerId { def_id: new_hir_id },
ident: this.lower_ident(ident),
kind,
vis_span,
Expand All @@ -660,10 +660,10 @@ impl<'hir> LoweringContext<'_, 'hir> {

fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir hir::ForeignItem<'hir> {
let hir_id = self.lower_node_id(i.id);
let def_id = hir_id.expect_owner();
let owner_id = hir_id.expect_owner();
self.lower_attrs(hir_id, &i.attrs);
let item = hir::ForeignItem {
def_id,
owner_id,
ident: self.lower_ident(i.ident),
kind: match i.kind {
ForeignItemKind::Fn(box Fn { ref sig, ref generics, .. }) => {
Expand Down Expand Up @@ -702,7 +702,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef {
hir::ForeignItemRef {
id: hir::ForeignItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
id: hir::ForeignItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
ident: self.lower_ident(i.ident),
span: self.lower_span(i.span),
}
Expand Down Expand Up @@ -845,7 +845,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

self.lower_attrs(hir_id, &i.attrs);
let item = hir::TraitItem {
def_id: trait_item_def_id,
owner_id: trait_item_def_id,
ident: self.lower_ident(i.ident),
generics,
kind,
Expand All @@ -864,7 +864,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
AssocItemKind::MacCall(..) => unimplemented!(),
};
let id = hir::TraitItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
let id = hir::TraitItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } };
hir::TraitItemRef {
id,
ident: self.lower_ident(i.ident),
Expand Down Expand Up @@ -931,7 +931,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let hir_id = self.lower_node_id(i.id);
self.lower_attrs(hir_id, &i.attrs);
let item = hir::ImplItem {
def_id: hir_id.expect_owner(),
owner_id: hir_id.expect_owner(),
ident: self.lower_ident(i.ident),
generics,
kind,
Expand All @@ -944,7 +944,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef {
hir::ImplItemRef {
id: hir::ImplItemId { def_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
id: hir::ImplItemId { owner_id: hir::OwnerId { def_id: self.local_def_id(i.id) } },
ident: self.lower_ident(i.ident),
span: self.lower_span(i.span),
kind: match &i.kind {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

// `impl Trait` now just becomes `Foo<'a, 'b, ..>`.
hir::TyKind::OpaqueDef(
hir::ItemId { def_id: hir::OwnerId { def_id: opaque_ty_def_id } },
hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } },
lifetimes,
in_trait,
)
Expand All @@ -1593,7 +1593,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// Generate an `type Foo = impl Trait;` declaration.
trace!("registering opaque type with id {:#?}", opaque_ty_id);
let opaque_ty_item = hir::Item {
def_id: hir::OwnerId { def_id: opaque_ty_id },
owner_id: hir::OwnerId { def_id: opaque_ty_id },
ident: Ident::empty(),
kind: opaque_ty_item_kind,
vis_span: self.lower_span(span.shrink_to_lo()),
Expand Down Expand Up @@ -2044,7 +2044,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// async fn, so the *type parameters* are inherited. It's
// only the lifetime parameters that we must supply.
let opaque_ty_ref = hir::TyKind::OpaqueDef(
hir::ItemId { def_id: hir::OwnerId { def_id: opaque_ty_def_id } },
hir::ItemId { owner_id: hir::OwnerId { def_id: opaque_ty_def_id } },
generic_args,
in_trait,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ hir_analysis_expected_default_return_type = expected `()` because of default ret
hir_analysis_expected_return_type = expected `{$expected}` because of return type

hir_analysis_unconstrained_opaque_type = unconstrained opaque type
.note = `{$name}` must be used in combination with a concrete type within the same module
.note = `{$name}` must be used in combination with a concrete type within the same {$what}

hir_analysis_missing_type_params =
the type {$parameterCount ->
Expand Down
48 changes: 24 additions & 24 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2207,14 +2207,14 @@ pub struct FnSig<'hir> {
// so it can fetched later.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct TraitItemId {
pub def_id: OwnerId,
pub owner_id: OwnerId,
}

impl TraitItemId {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}
}

Expand All @@ -2225,7 +2225,7 @@ impl TraitItemId {
#[derive(Debug, HashStable_Generic)]
pub struct TraitItem<'hir> {
pub ident: Ident,
pub def_id: OwnerId,
pub owner_id: OwnerId,
pub generics: &'hir Generics<'hir>,
pub kind: TraitItemKind<'hir>,
pub span: Span,
Expand All @@ -2236,11 +2236,11 @@ impl TraitItem<'_> {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}

pub fn trait_item_id(&self) -> TraitItemId {
TraitItemId { def_id: self.def_id }
TraitItemId { owner_id: self.owner_id }
}
}

Expand Down Expand Up @@ -2271,22 +2271,22 @@ pub enum TraitItemKind<'hir> {
// so it can fetched later.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct ImplItemId {
pub def_id: OwnerId,
pub owner_id: OwnerId,
}

impl ImplItemId {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}
}

/// Represents anything within an `impl` block.
#[derive(Debug, HashStable_Generic)]
pub struct ImplItem<'hir> {
pub ident: Ident,
pub def_id: OwnerId,
pub owner_id: OwnerId,
pub generics: &'hir Generics<'hir>,
pub kind: ImplItemKind<'hir>,
pub defaultness: Defaultness,
Expand All @@ -2298,11 +2298,11 @@ impl ImplItem<'_> {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}

pub fn impl_item_id(&self) -> ImplItemId {
ImplItemId { def_id: self.def_id }
ImplItemId { owner_id: self.owner_id }
}
}

Expand Down Expand Up @@ -2914,14 +2914,14 @@ impl<'hir> VariantData<'hir> {
// so it can fetched later.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash, HashStable_Generic)]
pub struct ItemId {
pub def_id: OwnerId,
pub owner_id: OwnerId,
}

impl ItemId {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}
}

Expand All @@ -2931,7 +2931,7 @@ impl ItemId {
#[derive(Debug, HashStable_Generic)]
pub struct Item<'hir> {
pub ident: Ident,
pub def_id: OwnerId,
pub owner_id: OwnerId,
pub kind: ItemKind<'hir>,
pub span: Span,
pub vis_span: Span,
Expand All @@ -2941,11 +2941,11 @@ impl Item<'_> {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}

pub fn item_id(&self) -> ItemId {
ItemId { def_id: self.def_id }
ItemId { owner_id: self.owner_id }
}
}

Expand Down Expand Up @@ -3158,14 +3158,14 @@ pub enum AssocItemKind {
// so it can fetched later.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
pub struct ForeignItemId {
pub def_id: OwnerId,
pub owner_id: OwnerId,
}

impl ForeignItemId {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}
}

Expand All @@ -3186,7 +3186,7 @@ pub struct ForeignItemRef {
pub struct ForeignItem<'hir> {
pub ident: Ident,
pub kind: ForeignItemKind<'hir>,
pub def_id: OwnerId,
pub owner_id: OwnerId,
pub span: Span,
pub vis_span: Span,
}
Expand All @@ -3195,11 +3195,11 @@ impl ForeignItem<'_> {
#[inline]
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id.def_id)
HirId::make_owner(self.owner_id.def_id)
}

pub fn foreign_item_id(&self) -> ForeignItemId {
ForeignItemId { def_id: self.def_id }
ForeignItemId { owner_id: self.owner_id }
}
}

Expand Down Expand Up @@ -3291,10 +3291,10 @@ impl<'hir> OwnerNode<'hir> {

pub fn def_id(self) -> OwnerId {
match self {
OwnerNode::Item(Item { def_id, .. })
| OwnerNode::TraitItem(TraitItem { def_id, .. })
| OwnerNode::ImplItem(ImplItem { def_id, .. })
| OwnerNode::ForeignItem(ForeignItem { def_id, .. }) => *def_id,
OwnerNode::Item(Item { owner_id, .. })
| OwnerNode::TraitItem(TraitItem { owner_id, .. })
| OwnerNode::ImplItem(ImplItem { owner_id, .. })
| OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
}
}
Expand Down
Loading