Use associated_type_bounds where applicable - closes #61738

This commit is contained in:
Ilija Tovilo 2019-07-31 21:00:35 +02:00
parent d4abb08be6
commit 3a6a29b4ec
No known key found for this signature in database
GPG Key ID: 3F123D0ADD448198
25 changed files with 169 additions and 124 deletions

View File

@ -329,8 +329,8 @@ impl<'a, B: ?Sized> PartialOrd for Cow<'a, B>
#[stable(feature = "rust1", since = "1.0.0")]
impl<B: ?Sized> fmt::Debug for Cow<'_, B>
where B: fmt::Debug + ToOwned,
<B as ToOwned>::Owned: fmt::Debug
where
B: fmt::Debug + ToOwned<Owned: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
@ -342,8 +342,8 @@ impl<B: ?Sized> fmt::Debug for Cow<'_, B>
#[stable(feature = "rust1", since = "1.0.0")]
impl<B: ?Sized> fmt::Display for Cow<'_, B>
where B: fmt::Display + ToOwned,
<B as ToOwned>::Owned: fmt::Display
where
B: fmt::Display + ToOwned<Owned: fmt::Display>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
@ -355,8 +355,8 @@ impl<B: ?Sized> fmt::Display for Cow<'_, B>
#[stable(feature = "default", since = "1.11.0")]
impl<B: ?Sized> Default for Cow<'_, B>
where B: ToOwned,
<B as ToOwned>::Owned: Default
where
B: ToOwned<Owned: Default>,
{
/// Creates an owned Cow<'a, B> with the default value for the contained owned value.
fn default() -> Self {

View File

@ -122,6 +122,7 @@
#![feature(alloc_layout_extra)]
#![feature(try_trait)]
#![feature(mem_take)]
#![feature(associated_type_bounds)]
// Allow testing this library

View File

@ -1638,10 +1638,12 @@ mod pattern {
}
}
fn cmp_search_to_vec<'a, P: Pattern<'a>>(rev: bool, pat: P, haystack: &'a str,
right: Vec<SearchStep>)
where P::Searcher: ReverseSearcher<'a>
{
fn cmp_search_to_vec<'a>(
rev: bool,
pat: impl Pattern<'a, Searcher: ReverseSearcher<'a>>,
haystack: &'a str,
right: Vec<SearchStep>
) {
let mut searcher = pat.into_searcher(haystack);
let mut v = vec![];
loop {

View File

@ -513,7 +513,7 @@ impl<T: ?Sized, U: ?Sized> AsRef<U> for &mut T where T: AsRef<U>
// FIXME (#45742): replace the above impls for &/&mut with the following more general one:
// // As lifts over Deref
// impl<D: ?Sized + Deref, U: ?Sized> AsRef<U> for D where D::Target: AsRef<U> {
// impl<D: ?Sized + Deref<Target: AsRef<U>>, U: ?Sized> AsRef<U> for D {
// fn as_ref(&self) -> &U {
// self.deref().as_ref()
// }
@ -530,7 +530,7 @@ impl<T: ?Sized, U: ?Sized> AsMut<U> for &mut T where T: AsMut<U>
// FIXME (#45742): replace the above impl for &mut with the following more general one:
// // AsMut lifts over DerefMut
// impl<D: ?Sized + Deref, U: ?Sized> AsMut<U> for D where D::Target: AsMut<U> {
// impl<D: ?Sized + Deref<Target: AsMut<U>>, U: ?Sized> AsMut<U> for D {
// fn as_mut(&mut self) -> &mut U {
// self.deref_mut().as_mut()
// }

View File

@ -111,8 +111,7 @@ impl<F: ?Sized + Future + Unpin> Future for &mut F {
#[stable(feature = "futures_api", since = "1.36.0")]
impl<P> Future for Pin<P>
where
P: Unpin + ops::DerefMut,
P::Target: Future,
P: Unpin + ops::DerefMut<Target: Future>,
{
type Output = <<P as ops::Deref>::Target as Future>::Output;

View File

@ -24,15 +24,17 @@ impl<I: Iterator, U: IntoIterator, F: FnMut(I::Item) -> U> FlatMap<I, U, F> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<I: Clone, U: Clone + IntoIterator, F: Clone> Clone for FlatMap<I, U, F>
where <U as IntoIterator>::IntoIter: Clone
impl<I: Clone, U, F: Clone> Clone for FlatMap<I, U, F>
where
U: Clone + IntoIterator<IntoIter: Clone>,
{
fn clone(&self) -> Self { FlatMap { inner: self.inner.clone() } }
}
#[stable(feature = "core_impl_debug", since = "1.9.0")]
impl<I: fmt::Debug, U: IntoIterator, F> fmt::Debug for FlatMap<I, U, F>
where U::IntoIter: fmt::Debug
impl<I: fmt::Debug, U, F> fmt::Debug for FlatMap<I, U, F>
where
U: IntoIterator<IntoIter: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FlatMap").field("inner", &self.inner).finish()
@ -68,9 +70,10 @@ impl<I: Iterator, U: IntoIterator, F> Iterator for FlatMap<I, U, F>
#[stable(feature = "rust1", since = "1.0.0")]
impl<I: DoubleEndedIterator, U, F> DoubleEndedIterator for FlatMap<I, U, F>
where F: FnMut(I::Item) -> U,
U: IntoIterator,
U::IntoIter: DoubleEndedIterator
where
F: FnMut(I::Item) -> U,
U: IntoIterator,
U::IntoIter: DoubleEndedIterator,
{
#[inline]
fn next_back(&mut self) -> Option<U::Item> { self.inner.next_back() }
@ -105,11 +108,13 @@ impl<I, U, F> FusedIterator for FlatMap<I, U, F>
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "iterator_flatten", since = "1.29.0")]
pub struct Flatten<I: Iterator>
where I::Item: IntoIterator {
where
I::Item: IntoIterator,
{
inner: FlattenCompat<I, <I::Item as IntoIterator>::IntoIter>,
}
impl<I: Iterator> Flatten<I>
where I::Item: IntoIterator {
impl<I: Iterator<Item: IntoIterator>> Flatten<I> {
pub(in super::super) fn new(iter: I) -> Flatten<I> {
Flatten { inner: FlattenCompat::new(iter) }
}
@ -117,8 +122,9 @@ where I::Item: IntoIterator {
#[stable(feature = "iterator_flatten", since = "1.29.0")]
impl<I, U> fmt::Debug for Flatten<I>
where I: Iterator + fmt::Debug, U: Iterator + fmt::Debug,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>,
where
I: fmt::Debug + Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
U: fmt::Debug + Iterator,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Flatten").field("inner", &self.inner).finish()
@ -127,16 +133,18 @@ impl<I, U> fmt::Debug for Flatten<I>
#[stable(feature = "iterator_flatten", since = "1.29.0")]
impl<I, U> Clone for Flatten<I>
where I: Iterator + Clone, U: Iterator + Clone,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>,
where
I: Clone + Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
U: Clone + Iterator,
{
fn clone(&self) -> Self { Flatten { inner: self.inner.clone() } }
}
#[stable(feature = "iterator_flatten", since = "1.29.0")]
impl<I, U> Iterator for Flatten<I>
where I: Iterator, U: Iterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
where
I: Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
U: Iterator,
{
type Item = U::Item;
@ -163,8 +171,9 @@ impl<I, U> Iterator for Flatten<I>
#[stable(feature = "iterator_flatten", since = "1.29.0")]
impl<I, U> DoubleEndedIterator for Flatten<I>
where I: DoubleEndedIterator, U: DoubleEndedIterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
where
I: DoubleEndedIterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
U: DoubleEndedIterator,
{
#[inline]
fn next_back(&mut self) -> Option<U::Item> { self.inner.next_back() }
@ -186,8 +195,10 @@ impl<I, U> DoubleEndedIterator for Flatten<I>
#[stable(feature = "iterator_flatten", since = "1.29.0")]
impl<I, U> FusedIterator for Flatten<I>
where I: FusedIterator, U: Iterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item> {}
where
I: FusedIterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
U: Iterator,
{}
/// Real logic of both `Flatten` and `FlatMap` which simply delegate to
/// this type.
@ -205,8 +216,9 @@ impl<I, U> FlattenCompat<I, U> {
}
impl<I, U> Iterator for FlattenCompat<I, U>
where I: Iterator, U: Iterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
where
I: Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
U: Iterator,
{
type Item = U::Item;
@ -274,8 +286,9 @@ impl<I, U> Iterator for FlattenCompat<I, U>
}
impl<I, U> DoubleEndedIterator for FlattenCompat<I, U>
where I: DoubleEndedIterator, U: DoubleEndedIterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
where
I: DoubleEndedIterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
U: DoubleEndedIterator,
{
#[inline]
fn next_back(&mut self) -> Option<U::Item> {

View File

@ -195,8 +195,8 @@ pub trait FromIterator<A>: Sized {
///
/// ```rust
/// fn collect_as_strings<T>(collection: T) -> Vec<String>
/// where T: IntoIterator,
/// T::Item: std::fmt::Debug,
/// where
/// T: IntoIterator<Item: std::fmt::Debug>,
/// {
/// collection
/// .into_iter()

View File

@ -132,6 +132,7 @@
#![feature(maybe_uninit_slice, maybe_uninit_array)]
#![feature(external_doc)]
#![feature(mem_take)]
#![feature(associated_type_bounds)]
#[prelude_import]
#[allow(unused)]

View File

@ -439,10 +439,7 @@ where
}
}
impl<P: Deref> Pin<P>
where
P::Target: Unpin,
{
impl<P: Deref<Target: Unpin>> Pin<P> {
/// Construct a new `Pin<P>` around a pointer to some data of a type that
/// implements [`Unpin`].
///
@ -730,10 +727,7 @@ impl<P: Deref> Deref for Pin<P> {
}
#[stable(feature = "pin", since = "1.33.0")]
impl<P: DerefMut> DerefMut for Pin<P>
where
P::Target: Unpin
{
impl<P: DerefMut<Target: Unpin>> DerefMut for Pin<P> {
fn deref_mut(&mut self) -> &mut P::Target {
Pin::get_mut(Pin::as_mut(self))
}

View File

@ -851,8 +851,9 @@ unsafe impl TrustedRandomAccess for Bytes<'_> {
/// wrapper types of the form X<'a, P>
macro_rules! derive_pattern_clone {
(clone $t:ident with |$s:ident| $e:expr) => {
impl<'a, P: Pattern<'a>> Clone for $t<'a, P>
where P::Searcher: Clone
impl<'a, P> Clone for $t<'a, P>
where
P: Pattern<'a, Searcher: Clone>,
{
fn clone(&self) -> Self {
let $s = self;
@ -928,8 +929,9 @@ macro_rules! generate_pattern_iterators {
pub struct $forward_iterator<'a, P: Pattern<'a>>($internal_iterator<'a, P>);
$(#[$common_stability_attribute])*
impl<'a, P: Pattern<'a>> fmt::Debug for $forward_iterator<'a, P>
where P::Searcher: fmt::Debug
impl<'a, P> fmt::Debug for $forward_iterator<'a, P>
where
P: Pattern<'a, Searcher: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple(stringify!($forward_iterator))
@ -949,8 +951,9 @@ macro_rules! generate_pattern_iterators {
}
$(#[$common_stability_attribute])*
impl<'a, P: Pattern<'a>> Clone for $forward_iterator<'a, P>
where P::Searcher: Clone
impl<'a, P> Clone for $forward_iterator<'a, P>
where
P: Pattern<'a, Searcher: Clone>,
{
fn clone(&self) -> Self {
$forward_iterator(self.0.clone())
@ -962,8 +965,9 @@ macro_rules! generate_pattern_iterators {
pub struct $reverse_iterator<'a, P: Pattern<'a>>($internal_iterator<'a, P>);
$(#[$common_stability_attribute])*
impl<'a, P: Pattern<'a>> fmt::Debug for $reverse_iterator<'a, P>
where P::Searcher: fmt::Debug
impl<'a, P> fmt::Debug for $reverse_iterator<'a, P>
where
P: Pattern<'a, Searcher: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple(stringify!($reverse_iterator))
@ -973,8 +977,9 @@ macro_rules! generate_pattern_iterators {
}
$(#[$common_stability_attribute])*
impl<'a, P: Pattern<'a>> Iterator for $reverse_iterator<'a, P>
where P::Searcher: ReverseSearcher<'a>
impl<'a, P> Iterator for $reverse_iterator<'a, P>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
type Item = $iterty;
@ -985,8 +990,9 @@ macro_rules! generate_pattern_iterators {
}
$(#[$common_stability_attribute])*
impl<'a, P: Pattern<'a>> Clone for $reverse_iterator<'a, P>
where P::Searcher: Clone
impl<'a, P> Clone for $reverse_iterator<'a, P>
where
P: Pattern<'a, Searcher: Clone>,
{
fn clone(&self) -> Self {
$reverse_iterator(self.0.clone())
@ -997,8 +1003,10 @@ macro_rules! generate_pattern_iterators {
impl<'a, P: Pattern<'a>> FusedIterator for $forward_iterator<'a, P> {}
#[stable(feature = "fused", since = "1.26.0")]
impl<'a, P: Pattern<'a>> FusedIterator for $reverse_iterator<'a, P>
where P::Searcher: ReverseSearcher<'a> {}
impl<'a, P> FusedIterator for $reverse_iterator<'a, P>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{}
generate_pattern_iterators!($($t)* with $(#[$common_stability_attribute])*,
$forward_iterator,
@ -1010,8 +1018,9 @@ macro_rules! generate_pattern_iterators {
$reverse_iterator:ident, $iterty:ty
} => {
$(#[$common_stability_attribute])*
impl<'a, P: Pattern<'a>> DoubleEndedIterator for $forward_iterator<'a, P>
where P::Searcher: DoubleEndedSearcher<'a>
impl<'a, P> DoubleEndedIterator for $forward_iterator<'a, P>
where
P: Pattern<'a, Searcher: DoubleEndedSearcher<'a>>,
{
#[inline]
fn next_back(&mut self) -> Option<$iterty> {
@ -1020,8 +1029,9 @@ macro_rules! generate_pattern_iterators {
}
$(#[$common_stability_attribute])*
impl<'a, P: Pattern<'a>> DoubleEndedIterator for $reverse_iterator<'a, P>
where P::Searcher: DoubleEndedSearcher<'a>
impl<'a, P> DoubleEndedIterator for $reverse_iterator<'a, P>
where
P: Pattern<'a, Searcher: DoubleEndedSearcher<'a>>,
{
#[inline]
fn next_back(&mut self) -> Option<$iterty> {
@ -1049,7 +1059,10 @@ struct SplitInternal<'a, P: Pattern<'a>> {
finished: bool,
}
impl<'a, P: Pattern<'a>> fmt::Debug for SplitInternal<'a, P> where P::Searcher: fmt::Debug {
impl<'a, P> fmt::Debug for SplitInternal<'a, P>
where
P: Pattern<'a, Searcher: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SplitInternal")
.field("start", &self.start)
@ -1166,7 +1179,10 @@ struct SplitNInternal<'a, P: Pattern<'a>> {
count: usize,
}
impl<'a, P: Pattern<'a>> fmt::Debug for SplitNInternal<'a, P> where P::Searcher: fmt::Debug {
impl<'a, P> fmt::Debug for SplitNInternal<'a, P>
where
P: Pattern<'a, Searcher: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SplitNInternal")
.field("iter", &self.iter)
@ -1222,7 +1238,10 @@ derive_pattern_clone!{
struct MatchIndicesInternal<'a, P: Pattern<'a>>(P::Searcher);
impl<'a, P: Pattern<'a>> fmt::Debug for MatchIndicesInternal<'a, P> where P::Searcher: fmt::Debug {
impl<'a, P> fmt::Debug for MatchIndicesInternal<'a, P>
where
P: Pattern<'a, Searcher: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("MatchIndicesInternal")
.field(&self.0)
@ -1273,7 +1292,10 @@ derive_pattern_clone!{
struct MatchesInternal<'a, P: Pattern<'a>>(P::Searcher);
impl<'a, P: Pattern<'a>> fmt::Debug for MatchesInternal<'a, P> where P::Searcher: fmt::Debug {
impl<'a, P> fmt::Debug for MatchesInternal<'a, P>
where
P: Pattern<'a, Searcher: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("MatchesInternal")
.field(&self.0)
@ -2882,8 +2904,9 @@ impl str {
/// assert!(!bananas.ends_with("nana"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
where P::Searcher: ReverseSearcher<'a>
pub fn ends_with<'a, P>(&'a self, pat: P) -> bool
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
pat.is_suffix_of(self)
}
@ -2975,8 +2998,9 @@ impl str {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
where P::Searcher: ReverseSearcher<'a>
pub fn rfind<'a, P>(&'a self, pat: P) -> Option<usize>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
pat.into_searcher(self).next_match_back().map(|(i, _)| i)
}
@ -3142,8 +3166,9 @@ impl str {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rsplit<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplit<'a, P>
where P::Searcher: ReverseSearcher<'a>
pub fn rsplit<'a, P>(&'a self, pat: P) -> RSplit<'a, P>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
RSplit(self.split(pat).0)
}
@ -3233,8 +3258,9 @@ impl str {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rsplit_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplitTerminator<'a, P>
where P::Searcher: ReverseSearcher<'a>
pub fn rsplit_terminator<'a, P>(&'a self, pat: P) -> RSplitTerminator<'a, P>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
RSplitTerminator(self.split_terminator(pat).0)
}
@ -3333,8 +3359,9 @@ impl str {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn rsplitn<'a, P: Pattern<'a>>(&'a self, n: usize, pat: P) -> RSplitN<'a, P>
where P::Searcher: ReverseSearcher<'a>
pub fn rsplitn<'a, P>(&'a self, n: usize, pat: P) -> RSplitN<'a, P>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
RSplitN(self.splitn(n, pat).0)
}
@ -3406,8 +3433,9 @@ impl str {
/// ```
#[stable(feature = "str_matches", since = "1.2.0")]
#[inline]
pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P>
where P::Searcher: ReverseSearcher<'a>
pub fn rmatches<'a, P>(&'a self, pat: P) -> RMatches<'a, P>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
RMatches(self.matches(pat).0)
}
@ -3491,8 +3519,9 @@ impl str {
/// ```
#[stable(feature = "str_match_indices", since = "1.5.0")]
#[inline]
pub fn rmatch_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatchIndices<'a, P>
where P::Searcher: ReverseSearcher<'a>
pub fn rmatch_indices<'a, P>(&'a self, pat: P) -> RMatchIndices<'a, P>
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
RMatchIndices(self.match_indices(pat).0)
}
@ -3700,8 +3729,9 @@ impl str {
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: DoubleEndedSearcher<'a>
pub fn trim_matches<'a, P>(&'a self, pat: P) -> &'a str
where
P: Pattern<'a, Searcher: DoubleEndedSearcher<'a>>,
{
let mut i = 0;
let mut j = 0;
@ -3792,8 +3822,9 @@ impl str {
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[stable(feature = "trim_direction", since = "1.30.0")]
pub fn trim_end_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: ReverseSearcher<'a>
pub fn trim_end_matches<'a, P>(&'a self, pat: P) -> &'a str
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
let mut j = 0;
let mut matcher = pat.into_searcher(self);
@ -3880,8 +3911,9 @@ impl str {
reason = "superseded by `trim_end_matches`",
suggestion = "trim_end_matches",
)]
pub fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: ReverseSearcher<'a>
pub fn trim_right_matches<'a, P>(&'a self, pat: P) -> &'a str
where
P: Pattern<'a, Searcher: ReverseSearcher<'a>>,
{
self.trim_end_matches(pat)
}

View File

@ -61,6 +61,7 @@
#![feature(proc_macro_hygiene)]
#![feature(log_syntax)]
#![feature(mem_take)]
#![feature(associated_type_bounds)]
#![recursion_limit="512"]

View File

@ -3901,7 +3901,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// each predicate must be preceded by the obligations required
// to normalize it.
// for example, if we have:
// impl<U: Iterator, V: Iterator<Item=U>> Foo for V where U::Item: Copy
// impl<U: Iterator<Item: Copy>, V: Iterator<Item = U>> Foo for V
// the impl will have the following predicates:
// <V as Iterator>::Item = U,
// U: Iterator, U: Sized,

View File

@ -980,8 +980,7 @@ EnumTypeFoldableImpl! {
(chalk_engine::DelayedLiteral::Negative)(a),
(chalk_engine::DelayedLiteral::Positive)(a, b),
} where
C: chalk_engine::context::Context + Clone,
C::CanonicalConstrainedSubst: TypeFoldable<'tcx>,
C: chalk_engine::context::Context<CanonicalConstrainedSubst: TypeFoldable<'tcx>> + Clone,
}
EnumTypeFoldableImpl! {
@ -989,8 +988,7 @@ EnumTypeFoldableImpl! {
(chalk_engine::Literal::Negative)(a),
(chalk_engine::Literal::Positive)(a),
} where
C: chalk_engine::context::Context + Clone,
C::GoalInEnvironment: Clone + TypeFoldable<'tcx>,
C: chalk_engine::context::Context<GoalInEnvironment: Clone + TypeFoldable<'tcx>> + Clone,
}
CloneTypeFoldableAndLiftImpls! {

View File

@ -2663,8 +2663,8 @@ impl<'tcx> TyCtxt<'tcx> {
unsafety: hir::Unsafety,
abi: abi::Abi)
-> <I::Item as InternIteratorElement<Ty<'tcx>, ty::FnSig<'tcx>>>::Output
where I: Iterator,
I::Item: InternIteratorElement<Ty<'tcx>, ty::FnSig<'tcx>>
where
I: Iterator<Item: InternIteratorElement<Ty<'tcx>, ty::FnSig<'tcx>>>,
{
inputs.chain(iter::once(output)).intern_with(|xs| ty::FnSig {
inputs_and_output: self.intern_type_list(xs),

View File

@ -2027,9 +2027,9 @@ impl ty::query::TyCtxtAt<'tcx> {
impl<'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
where
C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
C: HasParamEnv<'tcx>,
C: LayoutOf<Ty = Ty<'tcx>, TyLayout: MaybeResult<TyLayout<'tcx>>>
+ HasTyCtxt<'tcx>
+ HasParamEnv<'tcx>,
{
fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> {
let details = match this.variants {

View File

@ -1055,9 +1055,8 @@ fn encode_query_results<'a, 'tcx, Q, E>(
query_result_index: &mut EncodedQueryResultIndex,
) -> Result<(), E::Error>
where
Q: super::config::QueryDescription<'tcx>,
Q: super::config::QueryDescription<'tcx, Value: Encodable>,
E: 'a + TyEncoder,
Q::Value: Encodable,
{
let desc = &format!("encode_query_results for {}",
::std::any::type_name::<Q>());

View File

@ -50,8 +50,8 @@ impl Command {
}
pub fn args<I>(&mut self, args: I) -> &mut Command
where I: IntoIterator,
I::Item: AsRef<OsStr>,
where
I: IntoIterator<Item: AsRef<OsStr>>,
{
for arg in args {
self._arg(arg.as_ref());

View File

@ -11,6 +11,7 @@
#![feature(nll)]
#![feature(trusted_len)]
#![feature(mem_take)]
#![feature(associated_type_bounds)]
#![recursion_limit="256"]

View File

@ -23,6 +23,7 @@
#![feature(core_intrinsics)]
#![feature(integer_atomics)]
#![feature(test)]
#![feature(associated_type_bounds)]
#![cfg_attr(unix, feature(libc))]

View File

@ -847,7 +847,9 @@ pub trait ToHandleMut {
}
impl<O, H> OwningHandle<O, H>
where O: StableAddress, O::Target: ToHandle<Handle = H>, H: Deref,
where
O: StableAddress<Target: ToHandle<Handle = H>>,
H: Deref,
{
/// Creates a new `OwningHandle` for a type that implements `ToHandle`. For types
/// that don't implement `ToHandle`, callers may invoke `new_with_fn`, which accepts
@ -858,7 +860,9 @@ impl<O, H> OwningHandle<O, H>
}
impl<O, H> OwningHandle<O, H>
where O: StableAddress, O::Target: ToHandleMut<HandleMut = H>, H: DerefMut,
where
O: StableAddress<Target: ToHandleMut<HandleMut = H>>,
H: DerefMut,
{
/// Creates a new mutable `OwningHandle` for a type that implements `ToHandleMut`.
pub fn new_mut(o: O) -> Self {

View File

@ -589,10 +589,8 @@ impl<E:Idx> GenKillSet<E> {
self.gen_set.insert(e);
self.kill_set.remove(e);
}
fn gen_all<I>(&mut self, i: I)
where I: IntoIterator,
I::Item: Borrow<E>
{
fn gen_all(&mut self, i: impl IntoIterator<Item: Borrow<E>>) {
for j in i {
self.gen(*j.borrow());
}
@ -603,10 +601,7 @@ impl<E:Idx> GenKillSet<E> {
self.kill_set.insert(e);
}
fn kill_all<I>(&mut self, i: I)
where I: IntoIterator,
I::Item: Borrow<E>
{
fn kill_all(&mut self, i: impl IntoIterator<Item: Borrow<E>>) {
for j in i {
self.kill(*j.borrow());
}

View File

@ -23,6 +23,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(trusted_len)]
#![feature(try_blocks)]
#![feature(mem_take)]
#![feature(associated_type_bounds)]
#![recursion_limit="256"]

View File

@ -9,10 +9,7 @@ use std::sync::Arc;
use smallvec::{Array, SmallVec};
impl<A> Encodable for SmallVec<A>
where A: Array,
A::Item: Encodable
{
impl<A: Array<Item: Encodable>> Encodable for SmallVec<A> {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
@ -23,10 +20,7 @@ impl<A> Encodable for SmallVec<A>
}
}
impl<A> Decodable for SmallVec<A>
where A: Array,
A::Item: Decodable
{
impl<A: Array<Item: Decodable>> Decodable for SmallVec<A> {
fn decode<D: Decoder>(d: &mut D) -> Result<SmallVec<A>, D::Error> {
d.read_seq(|d, len| {
let mut vec = SmallVec::with_capacity(len);

View File

@ -13,6 +13,7 @@ Core encoding and decoding interfaces.
#![feature(specialization)]
#![feature(never_type)]
#![feature(nll)]
#![feature(associated_type_bounds)]
#![cfg_attr(test, feature(test))]
pub use self::serialize::{Decoder, Encoder, Decodable, Encodable};

View File

@ -522,7 +522,11 @@ impl<T: ?Sized> Drop for User<T> where T: UserSafe {
impl<T: CoerceUnsized<U>, U> CoerceUnsized<UserRef<U>> for UserRef<T> {}
#[unstable(feature = "sgx_platform", issue = "56975")]
impl<T, I: SliceIndex<[T]>> Index<I> for UserRef<[T]> where [T]: UserSafe, I::Output: UserSafe {
impl<T, I> Index<I> for UserRef<[T]>
where
[T]: UserSafe,
I: SliceIndex<[T], Output: UserSafe>,
{
type Output = UserRef<I::Output>;
#[inline]
@ -538,7 +542,11 @@ impl<T, I: SliceIndex<[T]>> Index<I> for UserRef<[T]> where [T]: UserSafe, I::Ou
}
#[unstable(feature = "sgx_platform", issue = "56975")]
impl<T, I: SliceIndex<[T]>> IndexMut<I> for UserRef<[T]> where [T]: UserSafe, I::Output: UserSafe {
impl<T, I> IndexMut<I> for UserRef<[T]>
where
[T]: UserSafe,
I: SliceIndex<[T], Output: UserSafe>,
{
#[inline]
fn index_mut(&mut self, index: I) -> &mut UserRef<I::Output> {
unsafe {