Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 15 deletions compiler/rustc_public/src/crate_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! such as, a function, a trait, an enum, and any other definitions.

use crate::ty::{GenericArgs, Span, Ty, index_impl};
use crate::{AssocItems, Crate, Symbol, ThreadLocalIndex, with};
use crate::{Crate, Symbol, ThreadLocalIndex, with};

/// A unique identification number for each item accessible for the current compilation unit.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -108,14 +108,6 @@ pub trait CrateDefType: CrateDef {
}
}

/// A trait for retrieving all items from a definition within a crate.
pub trait CrateDefItems: CrateDef {
/// Retrieve all associated items from a definition.
fn associated_items(&self) -> AssocItems {
with(|cx| cx.associated_items(self.def_id()))
}
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Attribute {
value: String,
Expand Down Expand Up @@ -171,9 +163,3 @@ macro_rules! crate_def_with_ty {
impl CrateDefType for $name {}
};
}

macro_rules! impl_crate_def_items {
( $name:ident $(;)? ) => {
impl CrateDefItems for $name {}
};
}
2 changes: 1 addition & 1 deletion compiler/rustc_public/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub mod rustc_internal;
use serde::Serialize;

use crate::compiler_interface::with;
pub use crate::crate_def::{CrateDef, CrateDefItems, CrateDefType, DefId};
pub use crate::crate_def::{CrateDef, CrateDefType, DefId};
pub use crate::error::*;
use crate::mir::mono::StaticDef;
use crate::mir::{Body, Mutability};
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_public/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use super::abi::ReprOptions;
use super::mir::{Body, Mutability, Safety};
use super::{DefId, Error, Symbol, with};
use crate::abi::{FnAbi, Layout};
use crate::crate_def::{CrateDef, CrateDefItems, CrateDefType};
use crate::crate_def::{CrateDef, CrateDefType};
use crate::mir::alloc::{AllocId, read_target_int, read_target_uint};
use crate::mir::mono::StaticDef;
use crate::target::MachineInfo;
use crate::{Filename, IndexedVal, Opaque, ThreadLocalIndex};
use crate::{AssocItems, Filename, IndexedVal, Opaque, ThreadLocalIndex};

#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct Ty(usize, ThreadLocalIndex);
Expand Down Expand Up @@ -952,14 +952,14 @@ crate_def! {
pub TraitDef;
}

impl_crate_def_items! {
TraitDef;
}

impl TraitDef {
pub fn declaration(trait_def: &TraitDef) -> TraitDecl {
with(|cx| cx.trait_decl(trait_def))
}

pub fn associated_items(&self) -> AssocItems {
with(|cx| cx.associated_items(self.def_id()))
}
}

crate_def! {
Expand All @@ -978,15 +978,15 @@ crate_def! {
pub ImplDef;
}

impl_crate_def_items! {
ImplDef;
}

impl ImplDef {
/// Retrieve information about this implementation.
pub fn trait_impl(&self) -> ImplTrait {
with(|cx| cx.trait_impl(self))
}

pub fn associated_items(&self) -> AssocItems {
with(|cx| cx.associated_items(self.def_id()))
}
}

crate_def! {
Expand Down
Loading