mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #152674 - makai410:rpub/sus-trait, r=celinval
rustc_public: remove the `CrateDefItems` trait This trait feels sus since its documentation says it's for 'retrieving all items from a definition' however it only provides an `associated_items` method (??), which I believe should only be valid for `impl`s and `trait`s.
This commit is contained in:
@@ -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)]
|
||||
@@ -111,14 +111,6 @@ fn ty_with_args(&self, args: &GenericArgs) -> Ty {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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,
|
||||
@@ -174,9 +166,3 @@ fn def_id(&self) -> DefId {
|
||||
impl CrateDefType for $name {}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! impl_crate_def_items {
|
||||
( $name:ident $(;)? ) => {
|
||||
impl CrateDefItems for $name {}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
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};
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
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);
|
||||
@@ -943,14 +943,14 @@ pub fn is_union(&self) -> bool {
|
||||
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! {
|
||||
@@ -969,15 +969,15 @@ pub fn declaration(trait_def: &TraitDef) -> TraitDecl {
|
||||
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! {
|
||||
|
||||
Reference in New Issue
Block a user