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

Rollup of 5 pull requests #63412

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ad832a1
add basic lint testing for misuse of mem::zeroed and mem::uninitialized
RalfJung Aug 6, 2019
16c0902
warn for more cases
RalfJung Aug 7, 2019
a902f7a
fix a comment
RalfJung Aug 7, 2019
d03b64a
add tuple_fields convenience method and use it in a few places
RalfJung Aug 7, 2019
1873844
note a FIXME
RalfJung Aug 7, 2019
b258ed5
proper doc comment for 'recovered' field of variant
RalfJung Aug 7, 2019
157b76a
allow the lint if a few UB-demonstrating doc tests
RalfJung Aug 7, 2019
6c7d84d
note down some more future plans
RalfJung Aug 7, 2019
3a6a29b
Use associated_type_bounds where applicable - closes #61738
iluuu1994 Jul 31, 2019
322a7d6
Add test for issue 36804
jackh726 Aug 8, 2019
3d231ac
Add missing #![feature(associated_type_bounds)]
iluuu1994 Aug 8, 2019
77bfd7f
Don't use associated type bounds in docs until it is stable
iluuu1994 Aug 9, 2019
e1bd8cb
rustc_target: add musl targets for MIPS64 arches
xen0n Jul 28, 2019
c076392
Tweak mismatched types error on break expressions
estebank Aug 6, 2019
799b13a
Do not suggest using ! with break
estebank Aug 7, 2019
4fbbf99
Be more accurate when mentioning type of found match arms
estebank Aug 7, 2019
01a6139
Change wording for function without return value
estebank Aug 7, 2019
94fe8a3
Suggest calling function on type error when finding bare fn
estebank Aug 7, 2019
195d837
When suggesting fn call use an appropriate number of placeholder argu…
estebank Aug 8, 2019
b7f7756
Recover parser from `foo(_, _)`
estebank Aug 8, 2019
0d53f69
review comments
estebank Aug 8, 2019
efa62d6
Tweak wording of fn without explicit return
estebank Aug 8, 2019
52da091
Differentiate between tuple structs and tuple variants
estebank Aug 8, 2019
5a54945
Extend suggestion support for traits and foreign items
estebank Aug 8, 2019
33d1082
review comment: review wording or missing return error
estebank Aug 8, 2019
bc1a4f5
review comments: typo and rewording
estebank Aug 8, 2019
45a5bc7
fix tests
estebank Aug 9, 2019
4637396
Rollup merge of #63165 - xen0n:mips64-musl-targets, r=alexcrichton
Centril Aug 9, 2019
3b99865
Rollup merge of #63337 - estebank:break-ee0308, r=Centril
Centril Aug 9, 2019
a133e53
Rollup merge of #63346 - RalfJung:zeroed-lint, r=eddyb
Centril Aug 9, 2019
4cd0e7d
Rollup merge of #63350 - iluuu1994:use-associated-type-bounds, r=Centril
Centril Aug 9, 2019
56d3742
Rollup merge of #63394 - jackh726:issue-36804, r=jonas-schievink
Centril Aug 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/liballoc/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
#![feature(alloc_layout_extra)]
#![feature(try_trait)]
#![feature(mem_take)]
#![feature(associated_type_bounds)]

// Allow testing this library

Expand Down
1 change: 1 addition & 0 deletions src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![feature(trusted_len)]
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![feature(associated_type_bounds)]

use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
Expand Down
10 changes: 6 additions & 4 deletions src/liballoc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
// }
Expand All @@ -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()
// }
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
61 changes: 37 additions & 24 deletions src/libcore/iter/adapters/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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() }
Expand Down Expand Up @@ -105,20 +108,23 @@ 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) }
}
}

#[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()
Expand All @@ -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;

Expand All @@ -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() }
Expand All @@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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> {
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ 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,
/// T::Item: std::fmt::Debug,
/// {
/// collection
/// .into_iter()
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::mem::ManuallyDrop;
/// ever gets used to access memory:
///
/// ```rust,no_run
/// # #![allow(invalid_value)]
/// use std::mem::{self, MaybeUninit};
///
/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior!
Expand All @@ -27,6 +28,7 @@ use crate::mem::ManuallyDrop;
/// always be `true` or `false`. Hence, creating an uninitialized `bool` is undefined behavior:
///
/// ```rust,no_run
/// # #![allow(invalid_value)]
/// use std::mem::{self, MaybeUninit};
///
/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior!
Expand All @@ -40,6 +42,7 @@ use crate::mem::ManuallyDrop;
/// which otherwise can hold any *fixed* bit pattern:
///
/// ```rust,no_run
/// # #![allow(invalid_value)]
/// use std::mem::{self, MaybeUninit};
///
/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior!
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ pub const fn needs_drop<T>() -> bool {
///
/// *Incorrect* usage of this function: initializing a reference with zero.
///
/// ```no_run
/// ```rust,no_run
/// # #![allow(invalid_value)]
/// use std::mem;
///
/// let _x: &i32 = unsafe { mem::zeroed() }; // Undefined behavior!
Expand Down
10 changes: 2 additions & 8 deletions src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,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`].
///
Expand Down Expand Up @@ -731,10 +728,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))
}
Expand Down
Loading