Skip to content
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

Ban multi-trait objects via trait aliases #59445

Merged
merged 12 commits into from
May 22, 2019
8 changes: 4 additions & 4 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ pub use core::slice::{RChunks, RChunksMut, RChunksExact, RChunksExactMut};
////////////////////////////////////////////////////////////////////////////////

// HACK(japaric) needed for the implementation of `vec!` macro during testing
// NB see the hack module in this file for more details
// N.B., see the `hack` module in this file for more details.
#[cfg(test)]
pub use hack::into_vec;

// HACK(japaric) needed for the implementation of `Vec::clone` during testing
// NB see the hack module in this file for more details
// N.B., see the `hack` module in this file for more details.
#[cfg(test)]
pub use hack::to_vec;

Expand Down Expand Up @@ -376,7 +376,7 @@ impl<T> [T] {
pub fn to_vec(&self) -> Vec<T>
where T: Clone
{
// NB see hack module in this file
// N.B., see the `hack` module in this file for more details.
hack::to_vec(self)
}

Expand All @@ -397,7 +397,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn into_vec(self: Box<Self>) -> Vec<T> {
// NB see hack module in this file
// N.B., see the `hack` module in this file for more details.
hack::into_vec(self)
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ impl<'hir> Map<'hir> {
}
}

/// Returns the name associated with the given NodeId's AST.
/// Returns the name associated with the given `NodeId`'s AST.
pub fn name(&self, id: NodeId) -> Name {
let hir_id = self.node_to_hir_id(id);
self.name_by_hir_id(hir_id)
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2143,11 +2143,11 @@ pub enum UseKind {
ListStem,
}

/// TraitRef's appear in impls.
/// References to traits in impls.
///
/// resolve maps each TraitRef's ref_id to its defining trait; that's all
/// that the ref_id is for. Note that ref_id's value is not the NodeId of the
/// trait being referred to but just a unique NodeId that serves as a key
/// `resolve` maps each `TraitRef`'s `ref_id` to its defining trait; that's all
/// that the `ref_id` is for. Note that `ref_id`'s value is not the `NodeId` of the
/// trait being referred to but just a unique `NodeId` that serves as a key
/// within the resolution map.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct TraitRef {
Expand Down
42 changes: 20 additions & 22 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ rustc_queries! {
query predicates_defined_on(_: DefId)
-> Lrc<ty::GenericPredicates<'tcx>> {}

/// Returns the predicates written explicit by the user.
/// Returns the predicates written explicitly by the user.
query explicit_predicates_of(_: DefId)
-> Lrc<ty::GenericPredicates<'tcx>> {}

Expand Down Expand Up @@ -216,17 +216,17 @@ rustc_queries! {
_: DefId
) -> Result<DtorckConstraint<'tcx>, NoSolution> {}

/// True if this is a const fn, use the `is_const_fn` to know whether your crate actually
/// sees it as const fn (e.g., the const-fn-ness might be unstable and you might not have
/// the feature gate active)
/// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
/// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
/// not have the feature gate active).
///
/// **Do not call this function manually.** It is only meant to cache the base data for the
/// `is_const_fn` function.
query is_const_fn_raw(key: DefId) -> bool {
desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
}

/// Returns true if calls to the function may be promoted
/// Returns `true` if calls to the function may be promoted.
///
/// This is either because the function is e.g., a tuple-struct or tuple-variant
/// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
Expand All @@ -237,36 +237,34 @@ rustc_queries! {

query const_fn_is_allowed_fn_ptr(_: DefId) -> bool {}

/// True if this is a foreign item (i.e., linked via `extern { ... }`).
/// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
query is_foreign_item(_: DefId) -> bool {}

/// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item.
query static_mutability(_: DefId) -> Option<hir::Mutability> {}

/// Get a map with the variance of every item; use `item_variance`
/// instead.
/// Gets a map with the variance of every item; use `item_variance` instead.
query crate_variances(_: CrateNum) -> Lrc<ty::CrateVariancesMap<'tcx>> {
desc { "computing the variances for items in this crate" }
}

/// Maps from def-id of a type or region parameter to its
/// (inferred) variance.
/// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
query variances_of(_: DefId) -> &'tcx [ty::Variance] {}
}

TypeChecking {
/// Maps from def-id of a type to its (inferred) outlives.
/// Maps from thee `DefId` of a type to its (inferred) outlives.
query inferred_outlives_crate(_: CrateNum)
-> Lrc<ty::CratePredicatesMap<'tcx>> {
desc { "computing the inferred outlives predicates for items in this crate" }
}
}

Other {
/// Maps from an impl/trait def-id to a list of the def-ids of its items
/// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
query associated_item_def_ids(_: DefId) -> Lrc<Vec<DefId>> {}

/// Maps from a trait item to the trait item "descriptor"
/// Maps from a trait item to the trait item "descriptor".
query associated_item(_: DefId) -> ty::AssociatedItem {}

query impl_trait_ref(_: DefId) -> Option<ty::TraitRef<'tcx>> {}
Expand All @@ -276,7 +274,7 @@ rustc_queries! {
}

TypeChecking {
/// Maps a DefId of a type to a list of its inherent impls.
/// Maps a `DefId` of a type to a list of its inherent impls.
/// Contains implementations of methods that are inherent to a type.
/// Methods in these implementations don't need to be exported.
query inherent_impls(_: DefId) -> Lrc<Vec<DefId>> {
Expand All @@ -300,7 +298,7 @@ rustc_queries! {
desc { |tcx| "linting {}", key.describe_as_module(tcx) }
}

/// Checks the attributes in the module
/// Checks the attributes in the module.
query check_mod_attrs(key: DefId) -> () {
desc { |tcx| "checking attributes in {}", key.describe_as_module(tcx) }
}
Expand All @@ -309,7 +307,7 @@ rustc_queries! {
desc { |tcx| "checking for unstable API usage in {}", key.describe_as_module(tcx) }
}

/// Checks the loops in the module
/// Checks the loops in the module.
query check_mod_loops(key: DefId) -> () {
desc { |tcx| "checking loops in {}", key.describe_as_module(tcx) }
}
Expand Down Expand Up @@ -338,7 +336,7 @@ rustc_queries! {
desc { |tcx| "collecting item types in {}", key.describe_as_module(tcx) }
}

/// Caches CoerceUnsized kinds for impls on custom types.
/// Caches `CoerceUnsized` kinds for impls on custom types.
query coerce_unsized_info(_: DefId)
-> ty::adjustment::CoerceUnsizedInfo {}
}
Expand Down Expand Up @@ -375,7 +373,7 @@ rustc_queries! {
BorrowChecking {
query borrowck(_: DefId) -> Lrc<BorrowCheckResult> {}

/// Borrow checks the function body. If this is a closure, returns
/// Borrow-checks the function body. If this is a closure, returns
/// additional requirements that the closure's creator must verify.
query mir_borrowck(_: DefId) -> mir::BorrowCheckResult<'tcx> {}
}
Expand All @@ -401,11 +399,11 @@ rustc_queries! {
}

Other {
/// Evaluate a constant without running sanity checks
/// Evaluates a constant without running sanity checks.
///
/// **Do not use this** outside const eval. Const eval uses this to break query cycles
/// during validation. Please add a comment to every use site explaining why using
/// `const_eval` isn't sufficient
/// `const_eval` isn't sufficient.
query const_eval_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
-> ConstEvalRawResult<'tcx> {
no_force
Expand Down Expand Up @@ -660,12 +658,12 @@ rustc_queries! {
}

Linking {
// The DefIds of all non-generic functions and statics in the given crate
// The `DefId`s of all non-generic functions and statics in the given crate
// that can be reached from outside the crate.
//
// We expect this items to be available for being linked to.
//
// This query can also be called for LOCAL_CRATE. In this case it will
// This query can also be called for `LOCAL_CRATE`. In this case it will
// compute which items will be reachable to other crates, taking into account
// the kind of crate that is currently compiled. Crates with only a
// C interface have fewer reachable things.
Expand Down
8 changes: 5 additions & 3 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ pub use self::specialize::specialization_graph::FutureCompatOverlapError;
pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind;
pub use self::engine::{TraitEngine, TraitEngineExt};
pub use self::util::{elaborate_predicates, elaborate_trait_ref, elaborate_trait_refs};
pub use self::util::{supertraits, supertrait_def_ids, transitive_bounds,
Supertraits, SupertraitDefIds};
pub use self::util::{
supertraits, supertrait_def_ids, transitive_bounds, Supertraits, SupertraitDefIds,
};
pub use self::util::{expand_trait_aliases, TraitAliasExpander};

pub use self::chalk_fulfill::{
CanonicalGoal as ChalkCanonicalGoal,
Expand Down Expand Up @@ -1043,7 +1045,7 @@ fn vtable_methods<'a, 'tcx>(
)
}

impl<'tcx,O> Obligation<'tcx,O> {
impl<'tcx, O> Obligation<'tcx, O> {
pub fn new(cause: ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
predicate: O)
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
bounds
);

let matching_bound = util::elaborate_predicates(self.tcx(), bounds.predicates)
let elaborated_predicates = util::elaborate_predicates(self.tcx(), bounds.predicates);
let matching_bound = elaborated_predicates
.filter_to_traits()
.find(|bound| {
self.infcx.probe(|_| {
Expand Down
Loading