Skip to content

Commit 4705c29

Browse files
author
Alexander Regueiro
committed
Disallow multi-trait objects via trait aliases.
1 parent c6bd75c commit 4705c29

File tree

15 files changed

+241
-145
lines changed

15 files changed

+241
-145
lines changed

src/liballoc/slice.rs

Lines changed: 4 additions & 4 deletions
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 self::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 self::hack::to_vec;
134134

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

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

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ impl<'hir> Map<'hir> {
810810
}
811811
}
812812

813-
/// Returns the name associated with the given NodeId's AST.
813+
/// Returns the name associated with the given `NodeId`'s AST.
814814
pub fn name(&self, id: NodeId) -> Name {
815815
match self.get(id) {
816816
Node::Item(i) => i.ident.name,

src/librustc/hir/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl Lifetime {
289289
}
290290
}
291291

292-
/// A "Path" is essentially Rust's notion of a name; for instance:
292+
/// A `Path` is essentially Rust's notion of a name; for instance:
293293
/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers,
294294
/// along with a bunch of supporting information.
295295
#[derive(Clone, RustcEncodable, RustcDecodable)]
@@ -2040,12 +2040,12 @@ pub enum UseKind {
20402040
ListStem,
20412041
}
20422042

2043-
/// TraitRef's appear in impls.
2043+
/// `TraitRef` are references to traits in impls.
20442044
///
2045-
/// resolve maps each TraitRef's ref_id to its defining trait; that's all
2046-
/// that the ref_id is for. Note that ref_id's value is not the NodeId of the
2047-
/// trait being referred to but just a unique NodeId that serves as a key
2048-
/// within the DefMap.
2045+
/// `resolve` maps each `TraitRef`'s `ref_id` to its defining trait; that's all
2046+
/// that the `ref_id` is for. Note that `ref_id`'s value is not the `NodeId` of the
2047+
/// trait being referred to but just a unique `NodeId` that serves as a key
2048+
/// within the `DefMap`.
20492049
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
20502050
pub struct TraitRef {
20512051
pub path: Path,
@@ -2055,10 +2055,10 @@ pub struct TraitRef {
20552055

20562056
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
20572057
pub struct PolyTraitRef {
2058-
/// The `'a` in `<'a> Foo<&'a T>`
2058+
/// The `'a` in `<'a> Foo<&'a T>`.
20592059
pub bound_generic_params: HirVec<GenericParam>,
20602060

2061-
/// The `Foo<&'a T>` in `<'a> Foo<&'a T>`
2061+
/// The `Foo<&'a T>` in `<'a> Foo<&'a T>`.
20622062
pub trait_ref: TraitRef,
20632063

20642064
pub span: Span,

src/librustc/infer/outlives/verify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
141141
}
142142

143143
fn recursive_type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
144-
let mut bounds = ty.walk_shallow()
144+
let mut bounds: Vec<_> = ty.walk_shallow()
145145
.map(|subty| self.type_bound(subty))
146-
.collect::<Vec<_>>();
146+
.collect();
147147

148148
let mut regions = smallvec![];
149149
ty.push_regions(&mut regions);

src/librustc/traits/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub use self::engine::{TraitEngine, TraitEngineExt};
6161
pub use self::util::{elaborate_predicates, elaborate_trait_ref, elaborate_trait_refs};
6262
pub use self::util::{supertraits, supertrait_def_ids, transitive_bounds,
6363
Supertraits, SupertraitDefIds};
64+
pub use self::util::{expand_trait_refs, TraitRefExpander};
6465

6566
pub use self::chalk_fulfill::{
6667
CanonicalGoal as ChalkCanonicalGoal,
@@ -1029,7 +1030,7 @@ fn vtable_methods<'a, 'tcx>(
10291030
)
10301031
}
10311032

1032-
impl<'tcx,O> Obligation<'tcx,O> {
1033+
impl<'tcx, O> Obligation<'tcx,O> {
10331034
pub fn new(cause: ObligationCause<'tcx>,
10341035
param_env: ty::ParamEnv<'tcx>,
10351036
predicate: O)

src/librustc/traits/select.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use super::{
2828
};
2929

3030
use dep_graph::{DepKind, DepNodeIndex};
31+
use hir;
3132
use hir::def_id::DefId;
3233
use infer;
3334
use infer::{InferCtxt, InferOk, TypeFreshener};
@@ -37,8 +38,6 @@ use ty::fast_reject;
3738
use ty::relate::{TypeRelation, TraitObjectMode};
3839
use ty::subst::{Subst, Substs};
3940
use ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
40-
41-
use hir;
4241
use rustc_data_structures::bit_set::GrowableBitSet;
4342
use rustc_data_structures::sync::Lock;
4443
use rustc_target::spec::abi::Abi;
@@ -1756,7 +1755,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
17561755
bounds
17571756
);
17581757

1759-
let matching_bound = util::elaborate_predicates(self.tcx(), bounds.predicates)
1758+
let elaborated_predicates = util::elaborate_predicates(self.tcx(), bounds.predicates);
1759+
let matching_bound = elaborated_predicates
17601760
.filter_to_traits()
17611761
.find(|bound| {
17621762
self.probe(|this, _| {

0 commit comments

Comments
 (0)