Skip to content

Commit 37ff5d3

Browse files
committed
Auto merge of #59445 - alexreg:ban-multi-trait-objects-via-aliases, r=oli-obk
Ban multi-trait objects via trait aliases Obviously, multi-trait objects are not normally supported, so they should not be supported via trait aliases. This has been factored out from the previous PR #55994 (see point 1). r? @Centril CC @nikomatsakis ------------------ ### RELNOTES: We now allow `dyn Send + fmt::Debug` with equivalent semantics to `dyn fmt::Debug + Send`. That is, the order of the mentioned traits does not matter wrt. principal/not-principal traits. This is a small change that might deserve a mention in the blog post because it is a language change but most likely not. See https://github.com/rust-lang/rust/blob/ce2ee305f9165c037ecddddb5792588a15ff6c37/src/test/ui/traits/wf-trait-object-reverse-order.rs. // @Centril
2 parents 1cc822c + ce2ee30 commit 37ff5d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2032
-294
lines changed

src/liballoc/slice.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ pub use core::slice::{RChunks, RChunksMut, RChunksExact, RChunksExactMut};
123123
////////////////////////////////////////////////////////////////////////////////
124124

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

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

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

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

src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ impl<'hir> Map<'hir> {
957957
}
958958
}
959959

960-
/// Returns the name associated with the given NodeId's AST.
960+
/// Returns the name associated with the given `NodeId`'s AST.
961961
pub fn name(&self, id: NodeId) -> Name {
962962
let hir_id = self.node_to_hir_id(id);
963963
self.name_by_hir_id(hir_id)

src/librustc/hir/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2143,11 +2143,11 @@ pub enum UseKind {
21432143
ListStem,
21442144
}
21452145

2146-
/// TraitRef's appear in impls.
2146+
/// References to traits in impls.
21472147
///
2148-
/// resolve maps each TraitRef's ref_id to its defining trait; that's all
2149-
/// that the ref_id is for. Note that ref_id's value is not the NodeId of the
2150-
/// trait being referred to but just a unique NodeId that serves as a key
2148+
/// `resolve` maps each `TraitRef`'s `ref_id` to its defining trait; that's all
2149+
/// that the `ref_id` is for. Note that `ref_id`'s value is not the `NodeId` of the
2150+
/// trait being referred to but just a unique `NodeId` that serves as a key
21512151
/// within the resolution map.
21522152
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
21532153
pub struct TraitRef {

src/librustc/query/mod.rs

+20-22
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ rustc_queries! {
168168
query predicates_defined_on(_: DefId)
169169
-> Lrc<ty::GenericPredicates<'tcx>> {}
170170

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

@@ -216,17 +216,17 @@ rustc_queries! {
216216
_: DefId
217217
) -> Result<DtorckConstraint<'tcx>, NoSolution> {}
218218

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

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

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

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

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

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

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

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

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

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

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

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

303-
/// Checks the attributes in the module
301+
/// Checks the attributes in the module.
304302
query check_mod_attrs(key: DefId) -> () {
305303
desc { |tcx| "checking attributes in {}", key.describe_as_module(tcx) }
306304
}
@@ -309,7 +307,7 @@ rustc_queries! {
309307
desc { |tcx| "checking for unstable API usage in {}", key.describe_as_module(tcx) }
310308
}
311309

312-
/// Checks the loops in the module
310+
/// Checks the loops in the module.
313311
query check_mod_loops(key: DefId) -> () {
314312
desc { |tcx| "checking loops in {}", key.describe_as_module(tcx) }
315313
}
@@ -338,7 +336,7 @@ rustc_queries! {
338336
desc { |tcx| "collecting item types in {}", key.describe_as_module(tcx) }
339337
}
340338

341-
/// Caches CoerceUnsized kinds for impls on custom types.
339+
/// Caches `CoerceUnsized` kinds for impls on custom types.
342340
query coerce_unsized_info(_: DefId)
343341
-> ty::adjustment::CoerceUnsizedInfo {}
344342
}
@@ -375,7 +373,7 @@ rustc_queries! {
375373
BorrowChecking {
376374
query borrowck(_: DefId) -> Lrc<BorrowCheckResult> {}
377375

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

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

662660
Linking {
663-
// The DefIds of all non-generic functions and statics in the given crate
661+
// The `DefId`s of all non-generic functions and statics in the given crate
664662
// that can be reached from outside the crate.
665663
//
666664
// We expect this items to be available for being linked to.
667665
//
668-
// This query can also be called for LOCAL_CRATE. In this case it will
666+
// This query can also be called for `LOCAL_CRATE`. In this case it will
669667
// compute which items will be reachable to other crates, taking into account
670668
// the kind of crate that is currently compiled. Crates with only a
671669
// C interface have fewer reachable things.

src/librustc/traits/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ pub use self::specialize::specialization_graph::FutureCompatOverlapError;
6060
pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind;
6161
pub use self::engine::{TraitEngine, TraitEngineExt};
6262
pub use self::util::{elaborate_predicates, elaborate_trait_ref, elaborate_trait_refs};
63-
pub use self::util::{supertraits, supertrait_def_ids, transitive_bounds,
64-
Supertraits, SupertraitDefIds};
63+
pub use self::util::{
64+
supertraits, supertrait_def_ids, transitive_bounds, Supertraits, SupertraitDefIds,
65+
};
66+
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
6567

6668
pub use self::chalk_fulfill::{
6769
CanonicalGoal as ChalkCanonicalGoal,
@@ -1043,7 +1045,7 @@ fn vtable_methods<'a, 'tcx>(
10431045
)
10441046
}
10451047

1046-
impl<'tcx,O> Obligation<'tcx,O> {
1048+
impl<'tcx, O> Obligation<'tcx, O> {
10471049
pub fn new(cause: ObligationCause<'tcx>,
10481050
param_env: ty::ParamEnv<'tcx>,
10491051
predicate: O)

src/librustc/traits/select.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
17721772
bounds
17731773
);
17741774

1775-
let matching_bound = util::elaborate_predicates(self.tcx(), bounds.predicates)
1775+
let elaborated_predicates = util::elaborate_predicates(self.tcx(), bounds.predicates);
1776+
let matching_bound = elaborated_predicates
17761777
.filter_to_traits()
17771778
.find(|bound| {
17781779
self.infcx.probe(|_| {

0 commit comments

Comments
 (0)