Auto merge of #58578 - kennytm:rollup, r=kennytm

Rollup of 24 pull requests

Successful merges:

 - #56470 (Modify doctest's auto-`fn main()` to allow `Result`s)
 - #58044 (Make overflowing and wrapping negation const)
 - #58303 (Improve stability tags display)
 - #58336 (Fix search results interactions)
 - #58384 (Fix tables display)
 - #58392 (Use less explicit shifting in std::net::ip)
 - #58409 (rustdoc: respect alternate flag when formatting impl trait)
 - #58456 (Remove no longer accurate diagnostic code about NLL)
 - #58528 (Don't use an allocation for ItemId in StmtKind)
 - #58530 (Monomorphize less code in fs::{read|write})
 - #58534 (Mention capping forbid lints)
 - #58536 (Remove UB in pointer tests)
 - #58538 (Add missing fmt structs examples)
 - #58539 (Add alias methods to PathBuf for underlying OsString (#58234))
 - #58544 (Fix doc for rustc "-g" flag)
 - #58545 (Add regression test for a specialization-related ICE (#39448))
 - #58546 (librustc_codegen_llvm => 2018)
 - #58551 (Explain a panic in test case net::tcp::tests::double_bind)
 - #58553 (Use more impl header lifetime elision)
 - #58562 (Fix style nits)
 - #58565 (Fix typo in std::future::Future docs)
 - #58568 (Fix a transposition in driver.rs.)
 - #58569 (Reduce Some Code Repetitions like `(n << amt) >> amt`)
 - #58576 (Stabilize iter::successors and iter::from_fn)
This commit is contained in:
bors 2019-02-20 10:14:28 +00:00
commit f66e4697ae
114 changed files with 1177 additions and 633 deletions

View file

@ -42,11 +42,11 @@ This flag prints out various information about the compiler.
## `-g`: include debug information ## `-g`: include debug information
A synonym for `-C debug-level=2`. A synonym for `-C debuginfo=2`, for more see [here](codegen-options/index.html#debuginfo).
## `-O`: optimize your code ## `-O`: optimize your code
A synonym for `-C opt-level=2`. A synonym for `-C opt-level=2`, for more see [here](codegen-options/index.html#opt-level).
## `-o`: filename of the output ## `-o`: filename of the output

View file

@ -90,7 +90,9 @@ This lint level gives you that.
'forbid' is a special lint level that's stronger than 'deny'. It's the same 'forbid' is a special lint level that's stronger than 'deny'. It's the same
as 'deny' in that a lint at this level will produce an error, but unlike the as 'deny' in that a lint at this level will produce an error, but unlike the
'deny' level, the 'forbid' level can not be overridden to be anything lower 'deny' level, the 'forbid' level can not be overridden to be anything lower
than an error. than an error. However, lint levels may still be capped with `--cap-lints`
(see below) so `rustc --cap-lints warn` will make lints set to 'forbid' just
warn.
## Configuring warning levels ## Configuring warning levels

View file

@ -236,6 +236,23 @@ appears to the reader as the initial idea but works with doc tests:
/// ``` /// ```
``` ```
As of version 1.34.0, one can also omit the `fn main()`, but you will have to
disambiguate the error type:
```ignore
/// ```
/// use std::io;
/// let mut input = String::new();
/// io::stdin().read_line(&mut input)?;
/// # Ok::<(), io:Error>(())
/// ```
```
This is an unfortunate consequence of the `?` operator adding an implicit
conversion, so type inference fails because the type is not unique. Please note
that you must write the `(())` in one sequence without intermediate whitespace
so that rustdoc understands you want an implicit `Result`-returning function.
## Documenting macros ## Documenting macros
Heres an example of documenting a macro: Heres an example of documenting a macro:

View file

@ -182,8 +182,8 @@ pub enum Cow<'a, B: ?Sized + 'a>
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> { impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
fn clone(&self) -> Cow<'a, B> { fn clone(&self) -> Self {
match *self { match *self {
Borrowed(b) => Borrowed(b), Borrowed(b) => Borrowed(b),
Owned(ref o) => { Owned(ref o) => {
@ -193,7 +193,7 @@ impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> {
} }
} }
fn clone_from(&mut self, source: &Cow<'a, B>) { fn clone_from(&mut self, source: &Self) {
if let Owned(ref mut dest) = *self { if let Owned(ref mut dest) = *self {
if let Owned(ref o) = *source { if let Owned(ref o) = *source {
o.borrow().clone_into(dest); o.borrow().clone_into(dest);
@ -296,11 +296,11 @@ impl<B: ?Sized + ToOwned> Deref for Cow<'_, B> {
impl<B: ?Sized> Eq for Cow<'_, B> where B: Eq + ToOwned {} impl<B: ?Sized> Eq for Cow<'_, B> where B: Eq + ToOwned {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Ord for Cow<'a, B> impl<B: ?Sized> Ord for Cow<'_, B>
where B: Ord + ToOwned where B: Ord + ToOwned
{ {
#[inline] #[inline]
fn cmp(&self, other: &Cow<'a, B>) -> Ordering { fn cmp(&self, other: &Self) -> Ordering {
Ord::cmp(&**self, &**other) Ord::cmp(&**self, &**other)
} }
} }
@ -353,18 +353,18 @@ impl<B: ?Sized> fmt::Display for Cow<'_, B>
} }
#[stable(feature = "default", since = "1.11.0")] #[stable(feature = "default", since = "1.11.0")]
impl<'a, B: ?Sized> Default for Cow<'a, B> impl<B: ?Sized> Default for Cow<'_, B>
where B: ToOwned, where B: ToOwned,
<B as ToOwned>::Owned: Default <B as ToOwned>::Owned: Default
{ {
/// Creates an owned Cow<'a, B> with the default value for the contained owned value. /// Creates an owned Cow<'a, B> with the default value for the contained owned value.
fn default() -> Cow<'a, B> { fn default() -> Self {
Owned(<B as ToOwned>::Owned::default()) Owned(<B as ToOwned>::Owned::default())
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Hash for Cow<'a, B> impl<B: ?Sized> Hash for Cow<'_, B>
where B: Hash + ToOwned where B: Hash + ToOwned
{ {
#[inline] #[inline]

View file

@ -947,8 +947,8 @@ impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Iter<'a, T> { impl<T> Clone for Iter<'_, T> {
fn clone(&self) -> Iter<'a, T> { fn clone(&self) -> Self {
Iter { iter: self.iter.clone() } Iter { iter: self.iter.clone() }
} }
} }

View file

@ -1218,8 +1218,8 @@ impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Iter<'a, K, V> { impl<K, V> Clone for Iter<'_, K, V> {
fn clone(&self) -> Iter<'a, K, V> { fn clone(&self) -> Self {
Iter { Iter {
range: self.range.clone(), range: self.range.clone(),
length: self.length, length: self.length,
@ -1441,8 +1441,8 @@ impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
impl<K, V> FusedIterator for Keys<'_, K, V> {} impl<K, V> FusedIterator for Keys<'_, K, V> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Keys<'a, K, V> { impl<K, V> Clone for Keys<'_, K, V> {
fn clone(&self) -> Keys<'a, K, V> { fn clone(&self) -> Self {
Keys { inner: self.inner.clone() } Keys { inner: self.inner.clone() }
} }
} }
@ -1478,8 +1478,8 @@ impl<K, V> ExactSizeIterator for Values<'_, K, V> {
impl<K, V> FusedIterator for Values<'_, K, V> {} impl<K, V> FusedIterator for Values<'_, K, V> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Values<'a, K, V> { impl<K, V> Clone for Values<'_, K, V> {
fn clone(&self) -> Values<'a, K, V> { fn clone(&self) -> Self {
Values { inner: self.inner.clone() } Values { inner: self.inner.clone() }
} }
} }
@ -1606,8 +1606,8 @@ impl<'a, K, V> Range<'a, K, V> {
impl<K, V> FusedIterator for Range<'_, K, V> {} impl<K, V> FusedIterator for Range<'_, K, V> {}
#[stable(feature = "btree_range", since = "1.17.0")] #[stable(feature = "btree_range", since = "1.17.0")]
impl<'a, K, V> Clone for Range<'a, K, V> { impl<K, V> Clone for Range<'_, K, V> {
fn clone(&self) -> Range<'a, K, V> { fn clone(&self) -> Self {
Range { Range {
front: self.front, front: self.front,
back: self.back, back: self.back,

View file

@ -907,8 +907,8 @@ impl<T: Debug> Debug for BTreeSet<T> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Iter<'a, T> { impl<T> Clone for Iter<'_, T> {
fn clone(&self) -> Iter<'a, T> { fn clone(&self) -> Self {
Iter { iter: self.iter.clone() } Iter { iter: self.iter.clone() }
} }
} }
@ -963,8 +963,8 @@ impl<T> ExactSizeIterator for IntoIter<T> {
impl<T> FusedIterator for IntoIter<T> {} impl<T> FusedIterator for IntoIter<T> {}
#[stable(feature = "btree_range", since = "1.17.0")] #[stable(feature = "btree_range", since = "1.17.0")]
impl<'a, T> Clone for Range<'a, T> { impl<T> Clone for Range<'_, T> {
fn clone(&self) -> Range<'a, T> { fn clone(&self) -> Self {
Range { iter: self.iter.clone() } Range { iter: self.iter.clone() }
} }
} }
@ -998,8 +998,8 @@ fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>, short: Ordering, long: Ordering
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Difference<'a, T> { impl<T> Clone for Difference<'_, T> {
fn clone(&self) -> Difference<'a, T> { fn clone(&self) -> Self {
Difference { Difference {
a: self.a.clone(), a: self.a.clone(),
b: self.b.clone(), b: self.b.clone(),
@ -1036,8 +1036,8 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
impl<T: Ord> FusedIterator for Difference<'_, T> {} impl<T: Ord> FusedIterator for Difference<'_, T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for SymmetricDifference<'a, T> { impl<T> Clone for SymmetricDifference<'_, T> {
fn clone(&self) -> SymmetricDifference<'a, T> { fn clone(&self) -> Self {
SymmetricDifference { SymmetricDifference {
a: self.a.clone(), a: self.a.clone(),
b: self.b.clone(), b: self.b.clone(),
@ -1070,8 +1070,8 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
impl<T: Ord> FusedIterator for SymmetricDifference<'_, T> {} impl<T: Ord> FusedIterator for SymmetricDifference<'_, T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Intersection<'a, T> { impl<T> Clone for Intersection<'_, T> {
fn clone(&self) -> Intersection<'a, T> { fn clone(&self) -> Self {
Intersection { Intersection {
a: self.a.clone(), a: self.a.clone(),
b: self.b.clone(), b: self.b.clone(),
@ -1108,8 +1108,8 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
impl<T: Ord> FusedIterator for Intersection<'_, T> {} impl<T: Ord> FusedIterator for Intersection<'_, T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Union<'a, T> { impl<T> Clone for Union<'_, T> {
fn clone(&self) -> Union<'a, T> { fn clone(&self) -> Self {
Union { Union {
a: self.a.clone(), a: self.a.clone(),
b: self.b.clone(), b: self.b.clone(),

View file

@ -1200,16 +1200,16 @@ unsafe impl<T: Send> Send for LinkedList<T> {}
unsafe impl<T: Sync> Sync for LinkedList<T> {} unsafe impl<T: Sync> Sync for LinkedList<T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, T: Sync> Send for Iter<'a, T> {} unsafe impl<T: Sync> Send for Iter<'_, T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, T: Sync> Sync for Iter<'a, T> {} unsafe impl<T: Sync> Sync for Iter<'_, T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, T: Send> Send for IterMut<'a, T> {} unsafe impl<T: Send> Send for IterMut<'_, T> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {} unsafe impl<T: Sync> Sync for IterMut<'_, T> {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View file

@ -2132,8 +2132,8 @@ impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Iter<'a, T> { impl<T> Clone for Iter<'_, T> {
fn clone(&self) -> Iter<'a, T> { fn clone(&self) -> Self {
Iter { Iter {
ring: self.ring, ring: self.ring,
tail: self.tail, tail: self.tail,
@ -2225,7 +2225,7 @@ pub struct IterMut<'a, T: 'a> {
} }
#[stable(feature = "collection_debug", since = "1.17.0")] #[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: fmt::Debug> fmt::Debug for IterMut<'_, T> { impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail); let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail);
f.debug_tuple("IterMut") f.debug_tuple("IterMut")

View file

@ -2455,7 +2455,7 @@ pub struct Drain<'a, T: 'a> {
} }
#[stable(feature = "collection_debug", since = "1.17.0")] #[stable(feature = "collection_debug", since = "1.17.0")]
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> { impl<T: fmt::Debug> fmt::Debug for Drain<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("Drain") f.debug_tuple("Drain")
.field(&self.iter.as_slice()) .field(&self.iter.as_slice())

View file

@ -71,8 +71,10 @@ impl fmt::Write for PadAdapter<'_> {
/// } /// }
/// } /// }
/// ///
/// // prints "Foo { bar: 10, baz: "Hello World" }" /// assert_eq!(
/// println!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() }); /// format!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() }),
/// "Foo { bar: 10, baz: \"Hello World\" }",
/// );
/// ``` /// ```
#[must_use = "must eventually call `finish()` on Debug builders"] #[must_use = "must eventually call `finish()` on Debug builders"]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
@ -96,6 +98,33 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>,
impl<'a, 'b: 'a> DebugStruct<'a, 'b> { impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
/// Adds a new field to the generated struct output. /// Adds a new field to the generated struct output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Bar {
/// bar: i32,
/// another: String,
/// }
///
/// impl fmt::Debug for Bar {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_struct("Bar")
/// .field("bar", &self.bar) // We add `bar` field.
/// .field("another", &self.another) // We add `another` field.
/// // We even add a field which doesn't exist (because why not?).
/// .field("not_existing_field", &1)
/// .finish() // We're good to go!
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Bar { bar: 10, another: "Hello World".to_string() }),
/// "Bar { bar: 10, another: \"Hello World\", not_existing_field: 1 }",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn field(&mut self, name: &str, value: &dyn fmt::Debug) -> &mut DebugStruct<'a, 'b> { pub fn field(&mut self, name: &str, value: &dyn fmt::Debug) -> &mut DebugStruct<'a, 'b> {
self.result = self.result.and_then(|_| { self.result = self.result.and_then(|_| {
@ -124,6 +153,32 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
} }
/// Finishes output and returns any error encountered. /// Finishes output and returns any error encountered.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Bar {
/// bar: i32,
/// baz: String,
/// }
///
/// impl fmt::Debug for Bar {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_struct("Bar")
/// .field("bar", &self.bar)
/// .field("baz", &self.baz)
/// .finish() // You need to call it to "finish" the
/// // struct formatting.
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Bar { bar: 10, baz: "Hello World".to_string() }),
/// "Bar { bar: 10, baz: \"Hello World\" }",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result { pub fn finish(&mut self) -> fmt::Result {
if self.has_fields { if self.has_fields {
@ -168,8 +223,10 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
/// } /// }
/// } /// }
/// ///
/// // prints "Foo(10, "Hello World")" /// assert_eq!(
/// println!("{:?}", Foo(10, "Hello World".to_string())); /// format!("{:?}", Foo(10, "Hello World".to_string())),
/// "Foo(10, \"Hello World\")",
/// );
/// ``` /// ```
#[must_use = "must eventually call `finish()` on Debug builders"] #[must_use = "must eventually call `finish()` on Debug builders"]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
@ -193,6 +250,28 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
impl<'a, 'b: 'a> DebugTuple<'a, 'b> { impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
/// Adds a new field to the generated tuple struct output. /// Adds a new field to the generated tuple struct output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(i32, String);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_tuple("Foo")
/// .field(&self.0) // We add the first field.
/// .field(&self.1) // We add the second field.
/// .finish() // We're good to go!
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(10, "Hello World".to_string())),
/// "Foo(10, \"Hello World\")",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn field(&mut self, value: &dyn fmt::Debug) -> &mut DebugTuple<'a, 'b> { pub fn field(&mut self, value: &dyn fmt::Debug) -> &mut DebugTuple<'a, 'b> {
self.result = self.result.and_then(|_| { self.result = self.result.and_then(|_| {
@ -220,6 +299,29 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
} }
/// Finishes output and returns any error encountered. /// Finishes output and returns any error encountered.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(i32, String);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_tuple("Foo")
/// .field(&self.0)
/// .field(&self.1)
/// .finish() // You need to call it to "finish" the
/// // tuple formatting.
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(10, "Hello World".to_string())),
/// "Foo(10, \"Hello World\")",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result { pub fn finish(&mut self) -> fmt::Result {
if self.fields > 0 { if self.fields > 0 {
@ -306,8 +408,10 @@ impl<'a, 'b: 'a> DebugInner<'a, 'b> {
/// } /// }
/// } /// }
/// ///
/// // prints "{10, 11}" /// assert_eq!(
/// println!("{:?}", Foo(vec![10, 11])); /// format!("{:?}", Foo(vec![10, 11])),
/// "{10, 11}",
/// );
/// ``` /// ```
#[must_use = "must eventually call `finish()` on Debug builders"] #[must_use = "must eventually call `finish()` on Debug builders"]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
@ -329,6 +433,28 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
impl<'a, 'b: 'a> DebugSet<'a, 'b> { impl<'a, 'b: 'a> DebugSet<'a, 'b> {
/// Adds a new entry to the set output. /// Adds a new entry to the set output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<i32>, Vec<u32>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_set()
/// .entry(&self.0) // Adds the first "entry".
/// .entry(&self.1) // Adds the second "entry".
/// .finish()
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
/// "{[10, 11], [12, 13]}",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugSet<'a, 'b> { pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugSet<'a, 'b> {
self.inner.entry(entry); self.inner.entry(entry);
@ -336,6 +462,28 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
} }
/// Adds the contents of an iterator of entries to the set output. /// Adds the contents of an iterator of entries to the set output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<i32>, Vec<u32>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_set()
/// .entries(self.0.iter()) // Adds the first "entry".
/// .entries(self.1.iter()) // Adds the second "entry".
/// .finish()
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
/// "{10, 11, 12, 13}",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugSet<'a, 'b> pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugSet<'a, 'b>
where D: fmt::Debug, where D: fmt::Debug,
@ -348,6 +496,27 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
} }
/// Finishes output and returns any error encountered. /// Finishes output and returns any error encountered.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<i32>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_set()
/// .entries(self.0.iter())
/// .finish() // Ends the struct formatting.
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![10, 11])),
/// "{10, 11}",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result { pub fn finish(&mut self) -> fmt::Result {
self.inner.finish(); self.inner.finish();
@ -377,8 +546,10 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
/// } /// }
/// } /// }
/// ///
/// // prints "[10, 11]" /// assert_eq!(
/// println!("{:?}", Foo(vec![10, 11])); /// format!("{:?}", Foo(vec![10, 11])),
/// "[10, 11]",
/// );
/// ``` /// ```
#[must_use = "must eventually call `finish()` on Debug builders"] #[must_use = "must eventually call `finish()` on Debug builders"]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
@ -400,6 +571,28 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
impl<'a, 'b: 'a> DebugList<'a, 'b> { impl<'a, 'b: 'a> DebugList<'a, 'b> {
/// Adds a new entry to the list output. /// Adds a new entry to the list output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<i32>, Vec<u32>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_list()
/// .entry(&self.0) // We add the first "entry".
/// .entry(&self.1) // We add the second "entry".
/// .finish()
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
/// "[[10, 11], [12, 13]]",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugList<'a, 'b> { pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugList<'a, 'b> {
self.inner.entry(entry); self.inner.entry(entry);
@ -407,6 +600,28 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
} }
/// Adds the contents of an iterator of entries to the list output. /// Adds the contents of an iterator of entries to the list output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<i32>, Vec<u32>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_list()
/// .entries(self.0.iter())
/// .entries(self.1.iter())
/// .finish()
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
/// "[10, 11, 12, 13]",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugList<'a, 'b> pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugList<'a, 'b>
where D: fmt::Debug, where D: fmt::Debug,
@ -419,6 +634,27 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
} }
/// Finishes output and returns any error encountered. /// Finishes output and returns any error encountered.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<i32>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_list()
/// .entries(self.0.iter())
/// .finish() // Ends the struct formatting.
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![10, 11])),
/// "[10, 11]",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result { pub fn finish(&mut self) -> fmt::Result {
self.inner.finish(); self.inner.finish();
@ -448,8 +684,10 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
/// } /// }
/// } /// }
/// ///
/// // prints "{"A": 10, "B": 11}" /// assert_eq!(
/// println!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])); /// format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
/// "{\"A\": 10, \"B\": 11}",
/// );
/// ``` /// ```
#[must_use = "must eventually call `finish()` on Debug builders"] #[must_use = "must eventually call `finish()` on Debug builders"]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
@ -471,6 +709,27 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
impl<'a, 'b: 'a> DebugMap<'a, 'b> { impl<'a, 'b: 'a> DebugMap<'a, 'b> {
/// Adds a new entry to the map output. /// Adds a new entry to the map output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<(String, i32)>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_map()
/// .entry(&"whole", &self.0) // We add the "whole" entry.
/// .finish()
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
/// "{\"whole\": [(\"A\", 10), (\"B\", 11)]}",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entry(&mut self, key: &dyn fmt::Debug, value: &dyn fmt::Debug) -> &mut DebugMap<'a, 'b> { pub fn entry(&mut self, key: &dyn fmt::Debug, value: &dyn fmt::Debug) -> &mut DebugMap<'a, 'b> {
self.result = self.result.and_then(|_| { self.result = self.result.and_then(|_| {
@ -500,6 +759,29 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
} }
/// Adds the contents of an iterator of entries to the map output. /// Adds the contents of an iterator of entries to the map output.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<(String, i32)>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_map()
/// // We map our vec so each entries' first field will become
/// // the "key".
/// .entries(self.0.iter().map(|&(ref k, ref v)| (k, v)))
/// .finish()
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
/// "{\"A\": 10, \"B\": 11}",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entries<K, V, I>(&mut self, entries: I) -> &mut DebugMap<'a, 'b> pub fn entries<K, V, I>(&mut self, entries: I) -> &mut DebugMap<'a, 'b>
where K: fmt::Debug, where K: fmt::Debug,
@ -513,6 +795,27 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
} }
/// Finishes output and returns any error encountered. /// Finishes output and returns any error encountered.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(Vec<(String, i32)>);
///
/// impl fmt::Debug for Foo {
/// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// fmt.debug_map()
/// .entries(self.0.iter().map(|&(ref k, ref v)| (k, v)))
/// .finish() // Ends the struct formatting.
/// }
/// }
///
/// assert_eq!(
/// format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
/// "{\"A\": 10, \"B\": 11}",
/// );
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")] #[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result { pub fn finish(&mut self) -> fmt::Result {
let prefix = if self.is_pretty() && self.has_fields { let prefix = if self.is_pretty() && self.has_fields {

View file

@ -81,7 +81,7 @@ pub trait Future {
/// ///
/// Once a future has completed (returned `Ready` from `poll`), /// Once a future has completed (returned `Ready` from `poll`),
/// then any future calls to `poll` may panic, block forever, or otherwise /// then any future calls to `poll` may panic, block forever, or otherwise
/// cause any kind of bad behavior expect causing memory unsafety. /// cause any kind of bad behavior except causing memory unsafety.
/// The `Future` trait itself provides no guarantees about the behavior /// The `Future` trait itself provides no guarantees about the behavior
/// of `poll` after a future has completed. /// of `poll` after a future has completed.
/// ///
@ -92,7 +92,7 @@ pub trait Future {
fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output>; fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output>;
} }
impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F { impl<F: ?Sized + Future + Unpin> Future for &mut F {
type Output = F::Output; type Output = F::Output;
fn poll(mut self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {

View file

@ -7,7 +7,7 @@ macro_rules! forward_ref_unop {
}; };
(impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => { (impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => {
#[$attr] #[$attr]
impl<'a> $imp for &'a $t { impl $imp for &$t {
type Output = <$t as $imp>::Output; type Output = <$t as $imp>::Output;
#[inline] #[inline]

View file

@ -326,8 +326,10 @@ pub use self::sources::{Empty, empty};
pub use self::sources::{Once, once}; pub use self::sources::{Once, once};
#[unstable(feature = "iter_once_with", issue = "57581")] #[unstable(feature = "iter_once_with", issue = "57581")]
pub use self::sources::{OnceWith, once_with}; pub use self::sources::{OnceWith, once_with};
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_from_fn", since = "1.34.0")]
pub use self::sources::{FromFn, from_fn, Successors, successors}; pub use self::sources::{FromFn, from_fn};
#[stable(feature = "iter_successors", since = "1.34.0")]
pub use self::sources::{Successors, successors};
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend}; pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend};

View file

@ -514,7 +514,6 @@ pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
/// [module-level documentation]: index.html /// [module-level documentation]: index.html
/// ///
/// ``` /// ```
/// #![feature(iter_unfold)]
/// let mut count = 0; /// let mut count = 0;
/// let counter = std::iter::from_fn(move || { /// let counter = std::iter::from_fn(move || {
/// // Increment our count. This is why we started at zero. /// // Increment our count. This is why we started at zero.
@ -530,7 +529,7 @@ pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
/// assert_eq!(counter.collect::<Vec<_>>(), &[1, 2, 3, 4, 5]); /// assert_eq!(counter.collect::<Vec<_>>(), &[1, 2, 3, 4, 5]);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_from_fn", since = "1.34.0")]
pub fn from_fn<T, F>(f: F) -> FromFn<F> pub fn from_fn<T, F>(f: F) -> FromFn<F>
where F: FnMut() -> Option<T> where F: FnMut() -> Option<T>
{ {
@ -544,10 +543,10 @@ pub fn from_fn<T, F>(f: F) -> FromFn<F>
/// ///
/// [`iter::from_fn`]: fn.from_fn.html /// [`iter::from_fn`]: fn.from_fn.html
#[derive(Clone)] #[derive(Clone)]
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_from_fn", since = "1.34.0")]
pub struct FromFn<F>(F); pub struct FromFn<F>(F);
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_from_fn", since = "1.34.0")]
impl<T, F> Iterator for FromFn<F> impl<T, F> Iterator for FromFn<F>
where F: FnMut() -> Option<T> where F: FnMut() -> Option<T>
{ {
@ -559,7 +558,7 @@ impl<T, F> Iterator for FromFn<F>
} }
} }
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_from_fn", since = "1.34.0")]
impl<F> fmt::Debug for FromFn<F> { impl<F> fmt::Debug for FromFn<F> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("FromFn").finish() f.debug_struct("FromFn").finish()
@ -572,13 +571,12 @@ impl<F> fmt::Debug for FromFn<F> {
/// and calls the given `FnMut(&T) -> Option<T>` closure to compute each items successor. /// and calls the given `FnMut(&T) -> Option<T>` closure to compute each items successor.
/// ///
/// ``` /// ```
/// #![feature(iter_unfold)]
/// use std::iter::successors; /// use std::iter::successors;
/// ///
/// let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10)); /// let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
/// assert_eq!(powers_of_10.collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]); /// assert_eq!(powers_of_10.collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
/// ``` /// ```
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_successors", since = "1.34.0")]
pub fn successors<T, F>(first: Option<T>, succ: F) -> Successors<T, F> pub fn successors<T, F>(first: Option<T>, succ: F) -> Successors<T, F>
where F: FnMut(&T) -> Option<T> where F: FnMut(&T) -> Option<T>
{ {
@ -598,13 +596,13 @@ pub fn successors<T, F>(first: Option<T>, succ: F) -> Successors<T, F>
/// ///
/// [`successors`]: fn.successors.html /// [`successors`]: fn.successors.html
#[derive(Clone)] #[derive(Clone)]
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_successors", since = "1.34.0")]
pub struct Successors<T, F> { pub struct Successors<T, F> {
next: Option<T>, next: Option<T>,
succ: F, succ: F,
} }
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_successors", since = "1.34.0")]
impl<T, F> Iterator for Successors<T, F> impl<T, F> Iterator for Successors<T, F>
where F: FnMut(&T) -> Option<T> where F: FnMut(&T) -> Option<T>
{ {
@ -628,12 +626,12 @@ impl<T, F> Iterator for Successors<T, F>
} }
} }
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_successors", since = "1.34.0")]
impl<T, F> FusedIterator for Successors<T, F> impl<T, F> FusedIterator for Successors<T, F>
where F: FnMut(&T) -> Option<T> where F: FnMut(&T) -> Option<T>
{} {}
#[unstable(feature = "iter_unfold", issue = "55977")] #[stable(feature = "iter_successors", since = "1.34.0")]
impl<T: fmt::Debug, F> fmt::Debug for Successors<T, F> { impl<T: fmt::Debug, F> fmt::Debug for Successors<T, F> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Successors") f.debug_struct("Successors")

View file

@ -1215,7 +1215,7 @@ $EndFeature, "
```"), ```"),
#[stable(feature = "num_wrapping", since = "1.2.0")] #[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline] #[inline]
pub fn wrapping_neg(self) -> Self { pub const fn wrapping_neg(self) -> Self {
self.overflowing_neg().0 self.overflowing_neg().0
} }
} }
@ -1569,12 +1569,8 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
```"), ```"),
#[inline] #[inline]
#[stable(feature = "wrapping", since = "1.7.0")] #[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_neg(self) -> (Self, bool) { pub const fn overflowing_neg(self) -> (Self, bool) {
if self == Self::min_value() { ((!self).wrapping_add(1), self == Self::min_value())
(Self::min_value(), true)
} else {
(-self, false)
}
} }
} }
@ -3092,7 +3088,7 @@ assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);
/// ``` /// ```
#[stable(feature = "num_wrapping", since = "1.2.0")] #[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline] #[inline]
pub fn wrapping_neg(self) -> Self { pub const fn wrapping_neg(self) -> Self {
self.overflowing_neg().0 self.overflowing_neg().0
} }
@ -3397,7 +3393,7 @@ assert_eq!(2", stringify!($SelfT), ".overflowing_neg(), (-2i32 as ", stringify!(
```"), ```"),
#[inline] #[inline]
#[stable(feature = "wrapping", since = "1.7.0")] #[stable(feature = "wrapping", since = "1.7.0")]
pub fn overflowing_neg(self) -> (Self, bool) { pub const fn overflowing_neg(self) -> (Self, bool) {
((!self).wrapping_add(1), self != 0) ((!self).wrapping_add(1), self != 0)
} }
} }

View file

@ -874,7 +874,7 @@ impl<T> Option<T> {
} }
} }
impl<'a, T: Copy> Option<&'a T> { impl<T: Copy> Option<&T> {
/// Maps an `Option<&T>` to an `Option<T>` by copying the contents of the /// Maps an `Option<&T>` to an `Option<T>` by copying the contents of the
/// option. /// option.
/// ///
@ -895,7 +895,7 @@ impl<'a, T: Copy> Option<&'a T> {
} }
} }
impl<'a, T: Copy> Option<&'a mut T> { impl<T: Copy> Option<&mut T> {
/// Maps an `Option<&mut T>` to an `Option<T>` by copying the contents of the /// Maps an `Option<&mut T>` to an `Option<T>` by copying the contents of the
/// option. /// option.
/// ///
@ -916,7 +916,7 @@ impl<'a, T: Copy> Option<&'a mut T> {
} }
} }
impl<'a, T: Clone> Option<&'a T> { impl<T: Clone> Option<&T> {
/// Maps an `Option<&T>` to an `Option<T>` by cloning the contents of the /// Maps an `Option<&T>` to an `Option<T>` by cloning the contents of the
/// option. /// option.
/// ///
@ -935,7 +935,7 @@ impl<'a, T: Clone> Option<&'a T> {
} }
} }
impl<'a, T: Clone> Option<&'a mut T> { impl<T: Clone> Option<&mut T> {
/// Maps an `Option<&mut T>` to an `Option<T>` by cloning the contents of the /// Maps an `Option<&mut T>` to an `Option<T>` by cloning the contents of the
/// option. /// option.
/// ///

View file

@ -2903,7 +2903,7 @@ macro_rules! iterator {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for $name<'a, T> { impl<T> ExactSizeIterator for $name<'_, T> {
#[inline(always)] #[inline(always)]
fn len(&self) -> usize { fn len(&self) -> usize {
len!(self) len!(self)
@ -3098,10 +3098,10 @@ macro_rules! iterator {
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, T> FusedIterator for $name<'a, T> {} impl<T> FusedIterator for $name<'_, T> {}
#[unstable(feature = "trusted_len", issue = "37572")] #[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for $name<'a, T> {} unsafe impl<T> TrustedLen for $name<'_, T> {}
} }
} }
@ -4365,8 +4365,8 @@ pub struct RChunks<'a, T:'a> {
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> Clone for RChunks<'a, T> { impl<T> Clone for RChunks<'_, T> {
fn clone(&self) -> RChunks<'a, T> { fn clone(&self) -> Self {
RChunks { RChunks {
v: self.v, v: self.v,
chunk_size: self.chunk_size, chunk_size: self.chunk_size,
@ -4455,13 +4455,13 @@ impl<'a, T> DoubleEndedIterator for RChunks<'a, T> {
} }
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> ExactSizeIterator for RChunks<'a, T> {} impl<T> ExactSizeIterator for RChunks<'_, T> {}
#[unstable(feature = "trusted_len", issue = "37572")] #[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for RChunks<'a, T> {} unsafe impl<T> TrustedLen for RChunks<'_, T> {}
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> FusedIterator for RChunks<'a, T> {} impl<T> FusedIterator for RChunks<'_, T> {}
#[doc(hidden)] #[doc(hidden)]
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
@ -4580,13 +4580,13 @@ impl<'a, T> DoubleEndedIterator for RChunksMut<'a, T> {
} }
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> ExactSizeIterator for RChunksMut<'a, T> {} impl<T> ExactSizeIterator for RChunksMut<'_, T> {}
#[unstable(feature = "trusted_len", issue = "37572")] #[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for RChunksMut<'a, T> {} unsafe impl<T> TrustedLen for RChunksMut<'_, T> {}
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> FusedIterator for RChunksMut<'a, T> {} impl<T> FusedIterator for RChunksMut<'_, T> {}
#[doc(hidden)] #[doc(hidden)]
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
@ -4711,10 +4711,10 @@ impl<'a, T> ExactSizeIterator for RChunksExact<'a, T> {
} }
#[unstable(feature = "trusted_len", issue = "37572")] #[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for RChunksExact<'a, T> {} unsafe impl<T> TrustedLen for RChunksExact<'_, T> {}
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> FusedIterator for RChunksExact<'a, T> {} impl<T> FusedIterator for RChunksExact<'_, T> {}
#[doc(hidden)] #[doc(hidden)]
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
@ -4822,17 +4822,17 @@ impl<'a, T> DoubleEndedIterator for RChunksExactMut<'a, T> {
} }
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> ExactSizeIterator for RChunksExactMut<'a, T> { impl<T> ExactSizeIterator for RChunksExactMut<'_, T> {
fn is_empty(&self) -> bool { fn is_empty(&self) -> bool {
self.v.is_empty() self.v.is_empty()
} }
} }
#[unstable(feature = "trusted_len", issue = "37572")] #[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<'a, T> TrustedLen for RChunksExactMut<'a, T> {} unsafe impl<T> TrustedLen for RChunksExactMut<'_, T> {}
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]
impl<'a, T> FusedIterator for RChunksExactMut<'a, T> {} impl<T> FusedIterator for RChunksExactMut<'_, T> {}
#[doc(hidden)] #[doc(hidden)]
#[stable(feature = "rchunks", since = "1.31.0")] #[stable(feature = "rchunks", since = "1.31.0")]

View file

@ -823,7 +823,7 @@ impl FusedIterator for Bytes<'_> {}
unsafe impl TrustedLen for Bytes<'_> {} unsafe impl TrustedLen for Bytes<'_> {}
#[doc(hidden)] #[doc(hidden)]
unsafe impl<'a> TrustedRandomAccess for Bytes<'a> { unsafe impl TrustedRandomAccess for Bytes<'_> {
unsafe fn get_unchecked(&mut self, i: usize) -> u8 { unsafe fn get_unchecked(&mut self, i: usize) -> u8 {
self.0.get_unchecked(i) self.0.get_unchecked(i)
} }

View file

@ -14,7 +14,6 @@
#![feature(iter_copied)] #![feature(iter_copied)]
#![feature(iter_nth_back)] #![feature(iter_nth_back)]
#![feature(iter_once_with)] #![feature(iter_once_with)]
#![feature(iter_unfold)]
#![feature(pattern)] #![feature(pattern)]
#![feature(range_is_empty)] #![feature(range_is_empty)]
#![feature(raw)] #![feature(raw)]

View file

@ -40,18 +40,17 @@ fn test() {
} }
#[test] #[test]
#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic
fn test_is_null() { fn test_is_null() {
let p: *const isize = null(); let p: *const isize = null();
assert!(p.is_null()); assert!(p.is_null());
let q = unsafe { p.offset(1) }; let q = p.wrapping_offset(1);
assert!(!q.is_null()); assert!(!q.is_null());
let mp: *mut isize = null_mut(); let mp: *mut isize = null_mut();
assert!(mp.is_null()); assert!(mp.is_null());
let mq = unsafe { mp.offset(1) }; let mq = mp.wrapping_offset(1);
assert!(!mq.is_null()); assert!(!mq.is_null());
// Pointers to unsized types -- slices // Pointers to unsized types -- slices
@ -208,7 +207,6 @@ fn test_ptr_addition() {
} }
#[test] #[test]
#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic
fn test_ptr_subtraction() { fn test_ptr_subtraction() {
unsafe { unsafe {
let xs = vec![0,1,2,3,4,5,6,7,8,9]; let xs = vec![0,1,2,3,4,5,6,7,8,9];
@ -224,8 +222,11 @@ fn test_ptr_subtraction() {
let m_start = xs_mut.as_mut_ptr(); let m_start = xs_mut.as_mut_ptr();
let mut m_ptr = m_start.offset(9); let mut m_ptr = m_start.offset(9);
while m_ptr >= m_start { loop {
*m_ptr += *m_ptr; *m_ptr += *m_ptr;
if m_ptr == m_start {
break;
}
m_ptr = m_ptr.offset(-1); m_ptr = m_ptr.offset(-1);
} }

View file

@ -150,9 +150,11 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
} }
} }
fn pats_all<'b, I: Iterator<Item=&'b P<hir::Pat>>>(&mut self, fn pats_all<'b, I: Iterator<Item=&'b P<hir::Pat>>>(
pats: I, &mut self,
pred: CFGIndex) -> CFGIndex { pats: I,
pred: CFGIndex
) -> CFGIndex {
//! Handles case where all of the patterns must match. //! Handles case where all of the patterns must match.
pats.fold(pred, |pred, pat| self.pat(&pat, pred)) pats.fold(pred, |pred, pat| self.pat(&pat, pred))
} }

View file

@ -408,11 +408,7 @@ fn bar(x: &str, y: &str) -> &str { }
fn baz<'a>(x: &'a str, y: &str) -> &str { } fn baz<'a>(x: &'a str, y: &str) -> &str { }
``` ```
Lifetime elision in implementation headers was part of the lifetime elision
RFC. It is, however, [currently unimplemented][iss15872].
[book-le]: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html#lifetime-elision [book-le]: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html#lifetime-elision
[iss15872]: https://github.com/rust-lang/rust/issues/15872
"##, "##,
E0119: r##" E0119: r##"

View file

@ -953,7 +953,7 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
visitor.visit_id(statement.id); visitor.visit_id(statement.id);
match statement.node { match statement.node {
StmtKind::Local(ref local) => visitor.visit_local(local), StmtKind::Local(ref local) => visitor.visit_local(local),
StmtKind::Item(ref item) => visitor.visit_nested_item(**item), StmtKind::Item(item) => visitor.visit_nested_item(item),
StmtKind::Expr(ref expression) | StmtKind::Expr(ref expression) |
StmtKind::Semi(ref expression) => { StmtKind::Semi(ref expression) => {
visitor.visit_expr(expression) visitor.visit_expr(expression)

View file

@ -4656,7 +4656,7 @@ impl<'a> LoweringContext<'a> {
hir::Stmt { hir::Stmt {
id: node_id, id: node_id,
hir_id, hir_id,
node: hir::StmtKind::Item(P(item_id)), node: hir::StmtKind::Item(item_id),
span: s.span, span: s.span,
} }
}) })
@ -4686,7 +4686,7 @@ impl<'a> LoweringContext<'a> {
hir::Stmt { hir::Stmt {
id: node_id, id: node_id,
hir_id, hir_id,
node: hir::StmtKind::Item(P(item_id)), node: hir::StmtKind::Item(item_id),
span: s.span, span: s.span,
} }
}) })

View file

@ -964,14 +964,19 @@ pub enum PatKind {
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position. /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
/// `0 <= position <= subpats.len()` /// `0 <= position <= subpats.len()`
Tuple(HirVec<P<Pat>>, Option<usize>), Tuple(HirVec<P<Pat>>, Option<usize>),
/// A `box` pattern. /// A `box` pattern.
Box(P<Pat>), Box(P<Pat>),
/// A reference pattern (e.g., `&mut (a, b)`). /// A reference pattern (e.g., `&mut (a, b)`).
Ref(P<Pat>, Mutability), Ref(P<Pat>, Mutability),
/// A literal. /// A literal.
Lit(P<Expr>), Lit(P<Expr>),
/// A range pattern (e.g., `1...2` or `1..2`). /// A range pattern (e.g., `1...2` or `1..2`).
Range(P<Expr>, P<Expr>, RangeEnd), Range(P<Expr>, P<Expr>, RangeEnd),
/// `[a, b, ..i, y, z]` is represented as: /// `[a, b, ..i, y, z]` is represented as:
/// `PatKind::Slice(box [a, b], Some(i), box [y, z])`. /// `PatKind::Slice(box [a, b], Some(i), box [y, z])`.
Slice(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>), Slice(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),
@ -1175,8 +1180,9 @@ impl fmt::Debug for Stmt {
pub enum StmtKind { pub enum StmtKind {
/// A local (`let`) binding. /// A local (`let`) binding.
Local(P<Local>), Local(P<Local>),
/// An item binding. /// An item binding.
Item(P<ItemId>), Item(ItemId),
/// An expression without a trailing semi-colon (must have unit type). /// An expression without a trailing semi-colon (must have unit type).
Expr(P<Expr>), Expr(P<Expr>),

View file

@ -1007,8 +1007,8 @@ impl<'a> State<'a> {
} }
self.end()? self.end()?
} }
hir::StmtKind::Item(ref item) => { hir::StmtKind::Item(item) => {
self.ann.nested(self, Nested::Item(**item))? self.ann.nested(self, Nested::Item(item))?
} }
hir::StmtKind::Expr(ref expr) => { hir::StmtKind::Expr(ref expr) => {
self.space_if_not_bol()?; self.space_if_not_bol()?;

View file

@ -1311,12 +1311,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
Def::Err => { Def::Err => {
debug!("access to unresolvable pattern {:?}", pat); debug!("access to unresolvable pattern {:?}", pat);
return Err(()) return Err(())
}, }
Def::Variant(variant_did) | Def::Variant(variant_did) |
Def::VariantCtor(variant_did, ..) => { Def::VariantCtor(variant_did, ..) => {
self.cat_downcast_if_needed(pat, cmt, variant_did) self.cat_downcast_if_needed(pat, cmt, variant_did)
}, }
_ => cmt _ => cmt,
}; };
for fp in field_pats { for fp in field_pats {
@ -1347,7 +1347,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
} }
} }
PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => { PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => {
// box p1, &p1, &mut p1. we can ignore the mutability of // box p1, &p1, &mut p1. we can ignore the mutability of
// PatKind::Ref since that information is already contained // PatKind::Ref since that information is already contained
// in the type. // in the type.

View file

@ -1167,13 +1167,13 @@ pub type Region<'tcx> = &'tcx RegionKind;
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html /// [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html
#[derive(Clone, PartialEq, Eq, Hash, Copy, RustcEncodable, RustcDecodable, PartialOrd, Ord)] #[derive(Clone, PartialEq, Eq, Hash, Copy, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
pub enum RegionKind { pub enum RegionKind {
// Region bound in a type or fn declaration which will be /// Region bound in a type or fn declaration which will be
// substituted 'early' -- that is, at the same time when type /// substituted 'early' -- that is, at the same time when type
// parameters are substituted. /// parameters are substituted.
ReEarlyBound(EarlyBoundRegion), ReEarlyBound(EarlyBoundRegion),
// Region bound in a function scope, which will be substituted when the /// Region bound in a function scope, which will be substituted when the
// function is called. /// function is called.
ReLateBound(DebruijnIndex, BoundRegion), ReLateBound(DebruijnIndex, BoundRegion),
/// When checking a function body, the types of all arguments and so forth /// When checking a function body, the types of all arguments and so forth

View file

@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"] authors = ["The Rust Project Developers"]
name = "rustc_codegen_llvm" name = "rustc_codegen_llvm"
version = "0.0.0" version = "0.0.0"
edition = "2018"
[lib] [lib]
name = "rustc_codegen_llvm" name = "rustc_codegen_llvm"
@ -10,7 +11,7 @@ crate-type = ["dylib"]
test = false test = false
[dependencies] [dependencies]
cc = "1.0.1" cc = "1.0.1" # Used to locate MSVC
num_cpus = "1.0" num_cpus = "1.0"
rustc-demangle = "0.1.4" rustc-demangle = "0.1.4"
rustc_llvm = { path = "../librustc_llvm" } rustc_llvm = { path = "../librustc_llvm" }

View file

@ -1,12 +1,12 @@
use llvm::{self, AttributePlace}; use crate::llvm::{self, AttributePlace};
use crate::builder::Builder;
use crate::context::CodegenCx;
use crate::type_::Type;
use crate::type_of::{LayoutLlvmExt, PointerKind};
use crate::value::Value;
use rustc_codegen_ssa::MemFlags; use rustc_codegen_ssa::MemFlags;
use builder::Builder;
use context::CodegenCx;
use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_codegen_ssa::mir::operand::OperandValue; use rustc_codegen_ssa::mir::operand::OperandValue;
use type_::Type;
use type_of::{LayoutLlvmExt, PointerKind};
use value::Value;
use rustc_target::abi::call::ArgType; use rustc_target::abi::call::ArgType;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;

View file

@ -1,13 +1,13 @@
use std::ffi::CString; use std::ffi::CString;
use attributes; use crate::attributes;
use libc::c_uint; use libc::c_uint;
use rustc::middle::allocator::AllocatorKind; use rustc::middle::allocator::AllocatorKind;
use rustc::ty::TyCtxt; use rustc::ty::TyCtxt;
use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy};
use ModuleLlvm; use crate::ModuleLlvm;
use llvm::{self, False, True}; use crate::llvm::{self, False, True};
pub(crate) unsafe fn codegen(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) { pub(crate) unsafe fn codegen(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) {
let llcx = &*mods.llcx; let llcx = &*mods.llcx;

View file

@ -1,8 +1,8 @@
use llvm; use crate::llvm;
use context::CodegenCx; use crate::context::CodegenCx;
use type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use builder::Builder; use crate::builder::Builder;
use value::Value; use crate::value::Value;
use rustc::hir; use rustc::hir;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;

View file

@ -15,15 +15,15 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_target::spec::PanicStrategy; use rustc_target::spec::PanicStrategy;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use abi::Abi; use crate::abi::Abi;
use attributes; use crate::attributes;
use llvm::{self, Attribute}; use crate::llvm::{self, Attribute};
use llvm::AttributePlace::Function; use crate::llvm::AttributePlace::Function;
use llvm_util; use crate::llvm_util;
pub use syntax::attr::{self, InlineAttr, OptimizeAttr}; pub use syntax::attr::{self, InlineAttr, OptimizeAttr};
use context::CodegenCx; use crate::context::CodegenCx;
use value::Value; use crate::value::Value;
/// Mark LLVM function to use provided inline heuristic. /// Mark LLVM function to use provided inline heuristic.
#[inline] #[inline]

View file

@ -7,12 +7,11 @@ use std::path::{Path, PathBuf};
use std::ptr; use std::ptr;
use std::str; use std::str;
use back::bytecode::RLIB_BYTECODE_EXTENSION; use crate::back::bytecode::RLIB_BYTECODE_EXTENSION;
use crate::llvm::archive_ro::{ArchiveRO, Child};
use crate::llvm::{self, ArchiveKind};
use crate::metadata::METADATA_FILENAME;
use rustc_codegen_ssa::back::archive::find_library; use rustc_codegen_ssa::back::archive::find_library;
use libc;
use llvm::archive_ro::{ArchiveRO, Child};
use llvm::{self, ArchiveKind};
use metadata::METADATA_FILENAME;
use rustc::session::Session; use rustc::session::Session;
pub struct ArchiveConfig<'a> { pub struct ArchiveConfig<'a> {

View file

@ -1,13 +1,15 @@
use back::wasm;
use super::archive::{ArchiveBuilder, ArchiveConfig}; use super::archive::{ArchiveBuilder, ArchiveConfig};
use super::bytecode::RLIB_BYTECODE_EXTENSION; use super::bytecode::RLIB_BYTECODE_EXTENSION;
use super::rpath::RPathConfig;
use super::rpath;
use crate::back::wasm;
use crate::metadata::METADATA_FILENAME;
use crate::context::get_reloc_model;
use crate::llvm;
use rustc_codegen_ssa::back::linker::Linker; use rustc_codegen_ssa::back::linker::Linker;
use rustc_codegen_ssa::back::link::{remove, ignored_for_lto, each_linked_rlib, linker_and_flavor, use rustc_codegen_ssa::back::link::{remove, ignored_for_lto, each_linked_rlib, linker_and_flavor,
get_linker}; get_linker};
use rustc_codegen_ssa::back::command::Command; use rustc_codegen_ssa::back::command::Command;
use super::rpath::RPathConfig;
use super::rpath;
use metadata::METADATA_FILENAME;
use rustc::session::config::{self, DebugInfo, OutputFilenames, OutputType, PrintRequest}; use rustc::session::config::{self, DebugInfo, OutputFilenames, OutputType, PrintRequest};
use rustc::session::config::{RUST_CGU_EXT, Lto, Sanitizer}; use rustc::session::config::{RUST_CGU_EXT, Lto, Sanitizer};
use rustc::session::filesearch; use rustc::session::filesearch;
@ -22,8 +24,6 @@ use rustc::hir::def_id::CrateNum;
use tempfile::{Builder as TempFileBuilder, TempDir}; use tempfile::{Builder as TempFileBuilder, TempDir};
use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor}; use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use context::get_reloc_model;
use llvm;
use std::ascii; use std::ascii;
use std::char; use std::char;
@ -523,7 +523,7 @@ fn link_natively(sess: &Session,
} }
{ {
let target_cpu = ::llvm_util::target_cpu(sess); let target_cpu = crate::llvm_util::target_cpu(sess);
let mut linker = codegen_results.linker_info.to_linker(cmd, &sess, flavor, target_cpu); let mut linker = codegen_results.linker_info.to_linker(cmd, &sess, flavor, target_cpu);
link_args(&mut *linker, flavor, sess, crate_type, tmpdir, link_args(&mut *linker, flavor, sess, crate_type, tmpdir,
out_filename, codegen_results); out_filename, codegen_results);

View file

@ -1,12 +1,15 @@
use back::bytecode::{DecodedBytecode, RLIB_BYTECODE_EXTENSION}; use crate::back::bytecode::{DecodedBytecode, RLIB_BYTECODE_EXTENSION};
use crate::back::write::{self, DiagnosticHandlers, with_llvm_pmb, save_temp_bitcode,
to_llvm_opt_settings};
use crate::llvm::archive_ro::ArchiveRO;
use crate::llvm::{self, True, False};
use crate::time_graph::Timeline;
use crate::{ModuleLlvm, LlvmCodegenBackend};
use rustc_codegen_ssa::back::symbol_export; use rustc_codegen_ssa::back::symbol_export;
use rustc_codegen_ssa::back::write::{ModuleConfig, CodegenContext, FatLTOInput}; use rustc_codegen_ssa::back::write::{ModuleConfig, CodegenContext, FatLTOInput};
use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinShared, ThinModule}; use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinShared, ThinModule};
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use back::write::{self, DiagnosticHandlers, with_llvm_pmb, save_temp_bitcode, to_llvm_opt_settings};
use errors::{FatalError, Handler}; use errors::{FatalError, Handler};
use llvm::archive_ro::ArchiveRO;
use llvm::{self, True, False};
use rustc::dep_graph::WorkProduct; use rustc::dep_graph::WorkProduct;
use rustc::dep_graph::cgu_reuse_tracker::CguReuse; use rustc::dep_graph::cgu_reuse_tracker::CguReuse;
use rustc::hir::def_id::LOCAL_CRATE; use rustc::hir::def_id::LOCAL_CRATE;
@ -14,12 +17,8 @@ use rustc::middle::exported_symbols::SymbolExportLevel;
use rustc::session::config::{self, Lto}; use rustc::session::config::{self, Lto};
use rustc::util::common::time_ext; use rustc::util::common::time_ext;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use time_graph::Timeline;
use {ModuleLlvm, LlvmCodegenBackend};
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind}; use rustc_codegen_ssa::{ModuleCodegen, ModuleKind};
use libc;
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::ptr; use std::ptr;
use std::slice; use std::slice;

View file

@ -1,28 +1,27 @@
use attributes; use crate::attributes;
use back::bytecode::{self, RLIB_BYTECODE_EXTENSION}; use crate::back::bytecode::{self, RLIB_BYTECODE_EXTENSION};
use back::lto::ThinBuffer; use crate::back::lto::ThinBuffer;
use crate::base;
use crate::consts;
use crate::time_graph::Timeline;
use crate::llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic};
use crate::llvm_util;
use crate::ModuleLlvm;
use crate::type_::Type;
use crate::context::{is_pie_binary, get_reloc_model};
use crate::common;
use crate::LlvmCodegenBackend;
use rustc_codegen_ssa::back::write::{CodegenContext, ModuleConfig, run_assembler}; use rustc_codegen_ssa::back::write::{CodegenContext, ModuleConfig, run_assembler};
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use base;
use consts;
use rustc::hir::def_id::LOCAL_CRATE; use rustc::hir::def_id::LOCAL_CRATE;
use rustc::session::config::{self, OutputType, Passes, Lto}; use rustc::session::config::{self, OutputType, Passes, Lto};
use rustc::session::Session; use rustc::session::Session;
use rustc::ty::TyCtxt; use rustc::ty::TyCtxt;
use time_graph::Timeline;
use llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic};
use llvm_util;
use ModuleLlvm;
use rustc_codegen_ssa::{ModuleCodegen, CompiledModule}; use rustc_codegen_ssa::{ModuleCodegen, CompiledModule};
use rustc::util::common::time_ext; use rustc::util::common::time_ext;
use rustc_fs_util::{path_to_c_string, link_or_copy}; use rustc_fs_util::{path_to_c_string, link_or_copy};
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
use errors::{self, Handler, FatalError}; use errors::{Handler, FatalError};
use type_::Type;
use context::{is_pie_binary, get_reloc_model};
use common;
use LlvmCodegenBackend;
use rustc_demangle;
use std::ffi::{CString, CStr}; use std::ffi::{CString, CStr};
use std::fs; use std::fs;

View file

@ -18,18 +18,18 @@ use rustc_codegen_ssa::{ModuleCodegen, ModuleKind};
use rustc_codegen_ssa::base::maybe_create_entry_wrapper; use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
use super::LlvmCodegenBackend; use super::LlvmCodegenBackend;
use llvm; use crate::llvm;
use metadata; use crate::metadata;
use crate::builder::Builder;
use crate::common;
use crate::context::CodegenCx;
use crate::monomorphize::partitioning::CodegenUnitExt;
use rustc::dep_graph; use rustc::dep_graph;
use rustc::mir::mono::{Linkage, Visibility, Stats}; use rustc::mir::mono::{Linkage, Visibility, Stats};
use rustc::middle::cstore::{EncodedMetadata}; use rustc::middle::cstore::{EncodedMetadata};
use rustc::ty::TyCtxt; use rustc::ty::TyCtxt;
use rustc::middle::exported_symbols; use rustc::middle::exported_symbols;
use rustc::session::config::{self, DebugInfo}; use rustc::session::config::{self, DebugInfo};
use builder::Builder;
use common;
use context::CodegenCx;
use monomorphize::partitioning::CodegenUnitExt;
use rustc_codegen_ssa::mono_item::MonoItemExt; use rustc_codegen_ssa::mono_item::MonoItemExt;
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
@ -41,7 +41,7 @@ use std::time::Instant;
use syntax_pos::symbol::InternedString; use syntax_pos::symbol::InternedString;
use rustc::hir::CodegenFnAttrs; use rustc::hir::CodegenFnAttrs;
use value::Value; use crate::value::Value;
pub fn write_metadata<'a, 'gcx>( pub fn write_metadata<'a, 'gcx>(

View file

@ -1,12 +1,12 @@
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect}; use crate::llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
use llvm::{self, False, BasicBlock}; use crate::llvm::{self, False, BasicBlock};
use crate::common::Funclet;
use crate::context::CodegenCx;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate}; use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate};
use rustc_codegen_ssa::{self, MemFlags}; use rustc_codegen_ssa::MemFlags;
use common::Funclet;
use context::CodegenCx;
use type_::Type;
use type_of::LayoutLlvmExt;
use value::Value;
use libc::{c_uint, c_char}; use libc::{c_uint, c_char};
use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::{self, Align, Size, TyLayout}; use rustc::ty::layout::{self, Align, Size, TyLayout};
@ -14,7 +14,6 @@ use rustc::hir::def_id::DefId;
use rustc::session::config; use rustc::session::config;
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use syntax;
use rustc_codegen_ssa::base::to_immediate; use rustc_codegen_ssa::base::to_immediate;
use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef}; use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef};
use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::mir::place::PlaceRef;

View file

@ -4,11 +4,11 @@
//! and methods are represented as just a fn ptr and not a full //! and methods are represented as just a fn ptr and not a full
//! closure. //! closure.
use attributes; use crate::attributes;
use llvm; use crate::llvm;
use monomorphize::Instance; use crate::monomorphize::Instance;
use context::CodegenCx; use crate::context::CodegenCx;
use value::Value; use crate::value::Value;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use rustc::ty::TypeFoldable; use rustc::ty::TypeFoldable;

View file

@ -2,17 +2,17 @@
//! Code that is useful in various codegen modules. //! Code that is useful in various codegen modules.
use llvm::{self, True, False, Bool, BasicBlock, OperandBundleDef}; use crate::llvm::{self, True, False, Bool, BasicBlock, OperandBundleDef};
use abi; use crate::abi;
use consts; use crate::consts;
use type_::Type; use crate::type_::Type;
use type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use value::Value; use crate::value::Value;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use crate::consts::const_alloc_to_llvm;
use rustc::ty::layout::{HasDataLayout, LayoutOf, self, TyLayout, Size}; use rustc::ty::layout::{HasDataLayout, LayoutOf, self, TyLayout, Size};
use rustc::mir::interpret::{Scalar, AllocKind, Allocation}; use rustc::mir::interpret::{Scalar, AllocKind, Allocation};
use consts::const_alloc_to_llvm;
use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::mir::place::PlaceRef;
use libc::{c_uint, c_char}; use libc::{c_uint, c_char};
@ -20,7 +20,7 @@ use libc::{c_uint, c_char};
use syntax::symbol::LocalInternedString; use syntax::symbol::LocalInternedString;
use syntax::ast::Mutability; use syntax::ast::Mutability;
pub use context::CodegenCx; pub use crate::context::CodegenCx;
/* /*
* A note on nomenclature of linking: "extern", "foreign", and "upcall". * A note on nomenclature of linking: "extern", "foreign", and "upcall".

View file

@ -1,20 +1,20 @@
use crate::llvm::{self, SetUnnamedAddr, True};
use crate::debuginfo;
use crate::monomorphize::MonoItem;
use crate::common::CodegenCx;
use crate::monomorphize::Instance;
use crate::base;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use libc::c_uint; use libc::c_uint;
use llvm::{self, SetUnnamedAddr, True};
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::mir::interpret::{ConstValue, Allocation, read_target_uint, use rustc::mir::interpret::{ConstValue, Allocation, read_target_uint,
Pointer, ErrorHandled, GlobalId}; Pointer, ErrorHandled, GlobalId};
use rustc::hir::Node; use rustc::hir::Node;
use debuginfo;
use monomorphize::MonoItem;
use common::CodegenCx;
use monomorphize::Instance;
use syntax_pos::Span; use syntax_pos::Span;
use rustc_target::abi::HasDataLayout; use rustc_target::abi::HasDataLayout;
use syntax_pos::symbol::LocalInternedString; use syntax_pos::symbol::LocalInternedString;
use base;
use type_::Type;
use type_of::LayoutLlvmExt;
use value::Value;
use rustc::ty::{self, Ty}; use rustc::ty::{self, Ty};
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;

View file

@ -1,14 +1,14 @@
use attributes; use crate::attributes;
use llvm; use crate::llvm;
use crate::debuginfo;
use crate::monomorphize::Instance;
use crate::value::Value;
use rustc::dep_graph::DepGraphSafe; use rustc::dep_graph::DepGraphSafe;
use rustc::hir; use rustc::hir;
use debuginfo;
use monomorphize::Instance;
use value::Value;
use monomorphize::partitioning::CodegenUnit; use crate::monomorphize::partitioning::CodegenUnit;
use type_::Type; use crate::type_::Type;
use type_of::PointeeInfo; use crate::type_of::PointeeInfo;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use libc::c_uint; use libc::c_uint;
@ -23,7 +23,7 @@ use rustc::util::nodemap::FxHashMap;
use rustc_target::spec::{HasTargetSpec, Target}; use rustc_target::spec::{HasTargetSpec, Target};
use rustc_codegen_ssa::callee::resolve_and_get_fn; use rustc_codegen_ssa::callee::resolve_and_get_fn;
use rustc_codegen_ssa::base::wants_msvc_seh; use rustc_codegen_ssa::base::wants_msvc_seh;
use callee::get_fn; use crate::callee::get_fn;
use std::ffi::CStr; use std::ffi::CStr;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
@ -31,7 +31,7 @@ use std::iter;
use std::str; use std::str;
use std::sync::Arc; use std::sync::Arc;
use syntax::symbol::LocalInternedString; use syntax::symbol::LocalInternedString;
use abi::Abi; use crate::abi::Abi;
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
/// `llvm::Context` so that several compilation units may be optimized in parallel. /// `llvm::Context` so that several compilation units may be optimized in parallel.
@ -103,7 +103,7 @@ pub fn get_reloc_model(sess: &Session) -> llvm::RelocMode {
None => &sess.target.target.options.relocation_model[..], None => &sess.target.target.options.relocation_model[..],
}; };
match ::back::write::RELOC_MODEL_ARGS.iter().find( match crate::back::write::RELOC_MODEL_ARGS.iter().find(
|&&arg| arg.0 == reloc_model_arg) { |&&arg| arg.0 == reloc_model_arg) {
Some(x) => x.1, Some(x) => x.1,
_ => { _ => {
@ -121,7 +121,7 @@ fn get_tls_model(sess: &Session) -> llvm::ThreadLocalMode {
None => &sess.target.target.options.tls_model[..], None => &sess.target.target.options.tls_model[..],
}; };
match ::back::write::TLS_MODEL_ARGS.iter().find( match crate::back::write::TLS_MODEL_ARGS.iter().find(
|&&arg| arg.0 == tls_model_arg) { |&&arg| arg.0 == tls_model_arg) {
Some(x) => x.1, Some(x) => x.1,
_ => { _ => {
@ -154,7 +154,7 @@ pub unsafe fn create_module(
// Ensure the data-layout values hardcoded remain the defaults. // Ensure the data-layout values hardcoded remain the defaults.
if sess.target.target.options.is_builtin { if sess.target.target.options.is_builtin {
let tm = ::back::write::create_target_machine(tcx, false); let tm = crate::back::write::create_target_machine(tcx, false);
llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm); llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
llvm::LLVMRustDisposeTargetMachine(tm); llvm::LLVMRustDisposeTargetMachine(tm);
@ -212,7 +212,7 @@ pub unsafe fn create_module(
impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
crate fn new(tcx: TyCtxt<'ll, 'tcx, 'tcx>, crate fn new(tcx: TyCtxt<'ll, 'tcx, 'tcx>,
codegen_unit: Arc<CodegenUnit<'tcx>>, codegen_unit: Arc<CodegenUnit<'tcx>>,
llvm_module: &'ll ::ModuleLlvm) llvm_module: &'ll crate::ModuleLlvm)
-> Self { -> Self {
// An interesting part of Windows which MSVC forces our hand on (and // An interesting part of Windows which MSVC forces our hand on (and
// apparently MinGW didn't) is the usage of `dllimport` and `dllexport` // apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
@ -377,7 +377,7 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
// Returns a Value of the "eh_unwind_resume" lang item if one is defined, // Returns a Value of the "eh_unwind_resume" lang item if one is defined,
// otherwise declares it as an external function. // otherwise declares it as an external function.
fn eh_unwind_resume(&self) -> &'ll Value { fn eh_unwind_resume(&self) -> &'ll Value {
use attributes; use crate::attributes;
let unwresume = &self.eh_unwind_resume; let unwresume = &self.eh_unwind_resume;
if let Some(llfn) = unwresume.get() { if let Some(llfn) = unwresume.get() {
return llfn; return llfn;

View file

@ -2,9 +2,9 @@ use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, FunctionDebugContextDat
use super::metadata::file_metadata; use super::metadata::file_metadata;
use super::utils::{DIB, span_start}; use super::utils::{DIB, span_start};
use llvm; use crate::llvm;
use llvm::debuginfo::{DIScope, DISubprogram}; use crate::llvm::debuginfo::{DIScope, DISubprogram};
use common::CodegenCx; use crate::common::CodegenCx;
use rustc::mir::{Mir, SourceScope}; use rustc::mir::{Mir, SourceScope};
use libc::c_uint; use libc::c_uint;

View file

@ -1,11 +1,11 @@
// .debug_gdb_scripts binary section. // .debug_gdb_scripts binary section.
use llvm; use crate::llvm;
use common::CodegenCx; use crate::common::CodegenCx;
use builder::Builder; use crate::builder::Builder;
use crate::value::Value;
use rustc::session::config::DebugInfo; use rustc::session::config::DebugInfo;
use value::Value;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use syntax::attr; use syntax::attr;

View file

@ -7,15 +7,16 @@ use super::utils::{debug_context, DIB, span_start,
use super::namespace::mangled_name_of_instance; use super::namespace::mangled_name_of_instance;
use super::type_names::compute_debuginfo_type_name; use super::type_names::compute_debuginfo_type_name;
use super::{CrateDebugContext}; use super::{CrateDebugContext};
use crate::abi;
use crate::value::Value;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use abi;
use value::Value;
use llvm; use crate::llvm;
use llvm::debuginfo::{DIArray, DIType, DIFile, DIScope, DIDescriptor, use crate::llvm::debuginfo::{DIArray, DIType, DIFile, DIScope, DIDescriptor,
DICompositeType, DILexicalBlock, DIFlags, DebugEmissionKind}; DICompositeType, DILexicalBlock, DIFlags, DebugEmissionKind};
use llvm_util; use crate::llvm_util;
use crate::common::CodegenCx;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc::hir::CodegenFnAttrFlags; use rustc::hir::CodegenFnAttrFlags;
use rustc::hir::def::CtorKind; use rustc::hir::def::CtorKind;
@ -23,7 +24,6 @@ use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
use rustc::ich::NodeIdHashingMode; use rustc::ich::NodeIdHashingMode;
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc::ty::Instance; use rustc::ty::Instance;
use common::CodegenCx;
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
use rustc::ty::layout::{self, Align, Integer, IntegerExt, LayoutOf, use rustc::ty::layout::{self, Align, Integer, IntegerExt, LayoutOf,
PrimitiveExt, Size, TyLayout}; PrimitiveExt, Size, TyLayout};

View file

@ -10,24 +10,24 @@ use self::type_names::compute_debuginfo_type_name;
use self::metadata::{type_metadata, file_metadata, TypeMap}; use self::metadata::{type_metadata, file_metadata, TypeMap};
use self::source_loc::InternalDebugLocation::{self, UnknownLocation}; use self::source_loc::InternalDebugLocation::{self, UnknownLocation};
use llvm; use crate::llvm;
use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilder, DISubprogram, DIArray, DIFlags, use crate::llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilder, DISubprogram, DIArray, DIFlags,
DISPFlags, DILexicalBlock}; DISPFlags, DILexicalBlock};
use rustc::hir::CodegenFnAttrFlags; use rustc::hir::CodegenFnAttrFlags;
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE}; use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
use rustc::ty::subst::{Substs, UnpackedKind}; use rustc::ty::subst::{Substs, UnpackedKind};
use abi::Abi; use crate::abi::Abi;
use common::CodegenCx; use crate::common::CodegenCx;
use builder::Builder; use crate::builder::Builder;
use monomorphize::Instance; use crate::monomorphize::Instance;
use crate::value::Value;
use rustc::ty::{self, ParamEnv, Ty, InstanceDef}; use rustc::ty::{self, ParamEnv, Ty, InstanceDef};
use rustc::mir; use rustc::mir;
use rustc::session::config::{self, DebugInfo}; use rustc::session::config::{self, DebugInfo};
use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet}; use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::indexed_vec::IndexVec;
use value::Value;
use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, VariableAccess, use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, VariableAccess,
VariableKind, FunctionDebugContextData}; VariableKind, FunctionDebugContextData};

View file

@ -2,14 +2,14 @@
use super::metadata::{unknown_file_metadata, UNKNOWN_LINE_NUMBER}; use super::metadata::{unknown_file_metadata, UNKNOWN_LINE_NUMBER};
use super::utils::{DIB, debug_context}; use super::utils::{DIB, debug_context};
use monomorphize::Instance; use crate::monomorphize::Instance;
use rustc::ty; use rustc::ty;
use llvm; use crate::llvm;
use llvm::debuginfo::DIScope; use crate::llvm::debuginfo::DIScope;
use crate::common::CodegenCx;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::hir::map::DefPathData; use rustc::hir::map::DefPathData;
use common::CodegenCx;
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;

View file

@ -4,9 +4,9 @@ use super::utils::{debug_context, span_start};
use super::metadata::UNKNOWN_COLUMN_NUMBER; use super::metadata::UNKNOWN_COLUMN_NUMBER;
use rustc_codegen_ssa::debuginfo::FunctionDebugContext; use rustc_codegen_ssa::debuginfo::FunctionDebugContext;
use llvm; use crate::llvm;
use llvm::debuginfo::DIScope; use crate::llvm::debuginfo::DIScope;
use builder::Builder; use crate::builder::Builder;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use libc::c_uint; use libc::c_uint;

View file

@ -1,6 +1,6 @@
// Type Names for Debug Info. // Type Names for Debug Info.
use common::CodegenCx; use crate::common::CodegenCx;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::ty::subst::Substs; use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty}; use rustc::ty::{self, Ty};
@ -125,7 +125,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
} }
let abi = sig.abi(); let abi = sig.abi();
if abi != ::abi::Abi::Rust { if abi != crate::abi::Abi::Rust {
output.push_str("extern \""); output.push_str("extern \"");
output.push_str(abi.name()); output.push_str(abi.name());
output.push_str("\" "); output.push_str("\" ");

View file

@ -6,12 +6,12 @@ use super::namespace::item_namespace;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::ty::DefIdTree; use rustc::ty::DefIdTree;
use llvm; use crate::llvm;
use llvm::debuginfo::{DIScope, DIBuilder, DIDescriptor, DIArray}; use crate::llvm::debuginfo::{DIScope, DIBuilder, DIDescriptor, DIArray};
use common::{CodegenCx}; use crate::common::{CodegenCx};
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use syntax_pos::{self, Span}; use syntax_pos::Span;
pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool
{ {

View file

@ -11,18 +11,18 @@
//! * Use define_* family of methods when you might be defining the Value. //! * Use define_* family of methods when you might be defining the Value.
//! * When in doubt, define. //! * When in doubt, define.
use llvm; use crate::llvm;
use llvm::AttributePlace::Function; use crate::llvm::AttributePlace::Function;
use crate::abi::{FnType, FnTypeExt};
use crate::attributes;
use crate::context::CodegenCx;
use crate::type_::Type;
use crate::value::Value;
use rustc::ty::{self, PolyFnSig}; use rustc::ty::{self, PolyFnSig};
use rustc::ty::layout::LayoutOf; use rustc::ty::layout::LayoutOf;
use rustc::session::config::Sanitizer; use rustc::session::config::Sanitizer;
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
use abi::{FnType, FnTypeExt};
use attributes;
use context::CodegenCx;
use type_::Type;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use value::Value;
/// Declare a function. /// Declare a function.
/// ///

View file

@ -1,26 +1,26 @@
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]
use attributes; use crate::attributes;
use llvm; use crate::llvm;
use llvm_util; use crate::llvm_util;
use abi::{Abi, FnType, LlvmType, PassMode}; use crate::abi::{Abi, FnType, LlvmType, PassMode};
use crate::context::CodegenCx;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::builder::Builder;
use crate::value::Value;
use crate::va_arg::emit_va_arg;
use rustc_codegen_ssa::MemFlags; use rustc_codegen_ssa::MemFlags;
use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
use rustc_codegen_ssa::glue; use rustc_codegen_ssa::glue;
use rustc_codegen_ssa::base::{to_immediate, wants_msvc_seh, compare_simd_types}; use rustc_codegen_ssa::base::{to_immediate, wants_msvc_seh, compare_simd_types};
use context::CodegenCx;
use type_::Type;
use type_of::LayoutLlvmExt;
use rustc::ty::{self, Ty}; use rustc::ty::{self, Ty};
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive}; use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
use rustc::hir; use rustc::hir;
use syntax::ast::{self, FloatTy}; use syntax::ast::{self, FloatTy};
use syntax::symbol::Symbol; use syntax::symbol::Symbol;
use builder::Builder;
use value::Value;
use va_arg::emit_va_arg;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
@ -192,8 +192,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
"size_of_val" => { "size_of_val" => {
let tp_ty = substs.type_at(0); let tp_ty = substs.type_at(0);
if let OperandValue::Pair(_, meta) = args[0].val { if let OperandValue::Pair(_, meta) = args[0].val {
let (llsize, _) = let (llsize, _) = glue::size_and_align_of_dst(self, tp_ty, Some(meta));
glue::size_and_align_of_dst(self, tp_ty, Some(meta));
llsize llsize
} else { } else {
self.const_usize(self.size_of(tp_ty).bytes()) self.const_usize(self.size_of(tp_ty).bytes())
@ -206,8 +205,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
"min_align_of_val" => { "min_align_of_val" => {
let tp_ty = substs.type_at(0); let tp_ty = substs.type_at(0);
if let OperandValue::Pair(_, meta) = args[0].val { if let OperandValue::Pair(_, meta) = args[0].val {
let (_, llalign) = let (_, llalign) = glue::size_and_align_of_dst(self, tp_ty, Some(meta));
glue::size_and_align_of_dst(self, tp_ty, Some(meta));
llalign llalign
} else { } else {
self.const_usize(self.align_of(tp_ty).bytes()) self.const_usize(self.align_of(tp_ty).bytes())

View file

@ -21,6 +21,9 @@
#![feature(concat_idents)] #![feature(concat_idents)]
#![feature(link_args)] #![feature(link_args)]
#![feature(static_nobundle)] #![feature(static_nobundle)]
#![deny(rust_2018_idioms)]
#![allow(explicit_outlives_requirements)]
#![allow(elided_lifetimes_in_paths)]
use back::write::create_target_machine; use back::write::create_target_machine;
use syntax_pos::symbol::Symbol; use syntax_pos::symbol::Symbol;
@ -29,16 +32,11 @@ extern crate flate2;
#[macro_use] extern crate bitflags; #[macro_use] extern crate bitflags;
extern crate libc; extern crate libc;
#[macro_use] extern crate rustc; #[macro_use] extern crate rustc;
extern crate jobserver;
extern crate num_cpus;
extern crate rustc_mir; extern crate rustc_mir;
extern crate rustc_allocator; extern crate rustc_allocator;
extern crate rustc_apfloat;
extern crate rustc_target; extern crate rustc_target;
#[macro_use] extern crate rustc_data_structures; #[macro_use] extern crate rustc_data_structures;
extern crate rustc_demangle;
extern crate rustc_incremental; extern crate rustc_incremental;
extern crate rustc_llvm;
extern crate rustc_codegen_utils; extern crate rustc_codegen_utils;
extern crate rustc_codegen_ssa; extern crate rustc_codegen_ssa;
extern crate rustc_fs_util; extern crate rustc_fs_util;
@ -48,9 +46,7 @@ extern crate rustc_fs_util;
extern crate syntax_pos; extern crate syntax_pos;
extern crate rustc_errors as errors; extern crate rustc_errors as errors;
extern crate serialize; extern crate serialize;
extern crate cc; // Used to locate MSVC
extern crate tempfile; extern crate tempfile;
extern crate memmap;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::back::write::{CodegenContext, ModuleConfig, FatLTOInput}; use rustc_codegen_ssa::back::write::{CodegenContext, ModuleConfig, FatLTOInput};

View file

@ -4,7 +4,7 @@ pub use self::OptimizationDiagnosticKind::*;
pub use self::Diagnostic::*; pub use self::Diagnostic::*;
use libc::c_uint; use libc::c_uint;
use value::Value; use crate::value::Value;
use super::{DiagnosticInfo, Twine}; use super::{DiagnosticInfo, Twine};

View file

@ -9,8 +9,6 @@ use libc::{c_uint, c_int, size_t, c_char};
use libc::{c_ulonglong, c_void}; use libc::{c_ulonglong, c_void};
use std::marker::PhantomData; use std::marker::PhantomData;
use syntax;
use rustc_codegen_ssa;
use super::RustString; use super::RustString;

View file

@ -16,7 +16,7 @@ use std::string::FromUtf8Error;
use std::slice; use std::slice;
use std::ffi::CStr; use std::ffi::CStr;
use std::cell::RefCell; use std::cell::RefCell;
use libc::{self, c_uint, c_char, size_t}; use libc::{c_uint, c_char, size_t};
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
pub mod archive_ro; pub mod archive_ro;

View file

@ -1,6 +1,6 @@
use crate::back::write::create_informational_target_machine;
use crate::llvm;
use syntax_pos::symbol::Symbol; use syntax_pos::symbol::Symbol;
use back::write::create_informational_target_machine;
use llvm;
use rustc::session::Session; use rustc::session::Session;
use rustc::session::config::PrintRequest; use rustc::session::config::PrintRequest;
use rustc_target::spec::MergeFunctions; use rustc_target::spec::MergeFunctions;

View file

@ -1,8 +1,8 @@
use crate::llvm;
use crate::llvm::{False, ObjectFile, mk_section_iter};
use crate::llvm::archive_ro::ArchiveRO;
use rustc::middle::cstore::MetadataLoader; use rustc::middle::cstore::MetadataLoader;
use rustc_target::spec::Target; use rustc_target::spec::Target;
use llvm;
use llvm::{False, ObjectFile, mk_section_iter};
use llvm::archive_ro::ArchiveRO;
use rustc_data_structures::owning_ref::OwningRef; use rustc_data_structures::owning_ref::OwningRef;
use std::path::Path; use std::path::Path;

View file

@ -1,9 +1,9 @@
use attributes; use crate::attributes;
use base; use crate::base;
use context::CodegenCx; use crate::context::CodegenCx;
use llvm; use crate::llvm;
use monomorphize::Instance; use crate::monomorphize::Instance;
use type_of::LayoutLlvmExt; use crate::type_of::LayoutLlvmExt;
use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::mir::mono::{Linkage, Visibility}; use rustc::mir::mono::{Linkage, Visibility};
use rustc::ty::TypeFoldable; use rustc::ty::TypeFoldable;

View file

@ -1,22 +1,22 @@
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]
pub use llvm::Type; pub use crate::llvm::Type;
use llvm; use crate::llvm;
use llvm::{Bool, False, True}; use crate::llvm::{Bool, False, True};
use context::CodegenCx; use crate::context::CodegenCx;
use crate::value::Value;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use value::Value;
use crate::common;
use crate::type_of::LayoutLlvmExt;
use crate::abi::{LlvmType, FnTypeExt};
use rustc::util::nodemap::FxHashMap; use rustc::util::nodemap::FxHashMap;
use rustc::ty::Ty; use rustc::ty::Ty;
use rustc::ty::layout::TyLayout; use rustc::ty::layout::TyLayout;
use rustc_target::abi::call::{CastTarget, FnType, Reg}; use rustc_target::abi::call::{CastTarget, FnType, Reg};
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
use common;
use rustc_codegen_ssa::common::TypeKind; use rustc_codegen_ssa::common::TypeKind;
use type_of::LayoutLlvmExt;
use abi::{LlvmType, FnTypeExt};
use std::fmt; use std::fmt;
use std::cell::RefCell; use std::cell::RefCell;
@ -82,7 +82,6 @@ impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
fn type_i16(&self) -> &'ll Type { fn type_i16(&self) -> &'ll Type {
unsafe { unsafe {
llvm::LLVMInt16TypeInContext(self.llcx) llvm::LLVMInt16TypeInContext(self.llcx)
} }
} }

View file

@ -1,12 +1,12 @@
use abi::{FnType, FnTypeExt}; use crate::abi::{FnType, FnTypeExt};
use common::*; use crate::common::*;
use crate::type_::Type;
use rustc::hir; use rustc::hir;
use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout}; use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout};
use rustc_target::abi::FloatTy; use rustc_target::abi::FloatTy;
use rustc_mir::monomorphize::item::DefPathBasedNames; use rustc_mir::monomorphize::item::DefPathBasedNames;
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use type_::Type;
use std::fmt::Write; use std::fmt::Write;

View file

@ -1,11 +1,11 @@
use builder::Builder; use crate::builder::Builder;
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
use crate::value::Value;
use rustc_codegen_ssa::mir::operand::OperandRef; use rustc_codegen_ssa::mir::operand::OperandRef;
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods, ConstMethods, DerivedTypeMethods}; use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods, ConstMethods, DerivedTypeMethods};
use rustc::ty::layout::{Align, HasDataLayout, HasTyCtxt, LayoutOf, Size}; use rustc::ty::layout::{Align, HasDataLayout, HasTyCtxt, LayoutOf, Size};
use rustc::ty::Ty; use rustc::ty::Ty;
use type_::Type;
use type_of::LayoutLlvmExt;
use value::Value;
#[allow(dead_code)] #[allow(dead_code)]
fn round_pointer_up_to_alignment( fn round_pointer_up_to_alignment(

View file

@ -1,6 +1,6 @@
pub use llvm::Value; pub use crate::llvm::Value;
use llvm; use crate::llvm;
use std::fmt; use std::fmt;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};

View file

@ -1172,7 +1172,7 @@ pub fn default_provide_extern(providers: &mut ty::query::Providers) {
cstore::provide_extern(providers); cstore::provide_extern(providers);
} }
/// Runs the resolution, typec-hecking, region checking and other /// Runs the resolution, type-checking, region checking and other
/// miscellaneous analysis passes on the crate. Return various /// miscellaneous analysis passes on the crate. Return various
/// structures carrying the results of the analysis. /// structures carrying the results of the analysis.
pub fn phase_3_run_analysis_passes<'tcx, F, R>( pub fn phase_3_run_analysis_passes<'tcx, F, R>(

View file

@ -338,6 +338,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard); self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard);
block.unit() block.unit()
} }
_ => { _ => {
let place = unpack!(block = self.as_place(block, initializer)); let place = unpack!(block = self.as_place(block, initializer));
self.place_into_pattern(block, irrefutable_pat, &place, true) self.place_into_pattern(block, irrefutable_pat, &place, true)
@ -534,6 +535,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
self.visit_bindings(subpattern, pattern_user_ty, f); self.visit_bindings(subpattern, pattern_user_ty, f);
} }
} }
PatternKind::Array { PatternKind::Array {
ref prefix, ref prefix,
ref slice, ref slice,
@ -556,10 +558,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
self.visit_bindings(subpattern, pattern_user_ty.clone().index(), f); self.visit_bindings(subpattern, pattern_user_ty.clone().index(), f);
} }
} }
PatternKind::Constant { .. } | PatternKind::Range { .. } | PatternKind::Wild => {} PatternKind::Constant { .. } | PatternKind::Range { .. } | PatternKind::Wild => {}
PatternKind::Deref { ref subpattern } => { PatternKind::Deref { ref subpattern } => {
self.visit_bindings(subpattern, pattern_user_ty.deref(), f); self.visit_bindings(subpattern, pattern_user_ty.deref(), f);
} }
PatternKind::AscribeUserType { PatternKind::AscribeUserType {
ref subpattern, ref subpattern,
ascription: hair::pattern::Ascription { ascription: hair::pattern::Ascription {

View file

@ -45,10 +45,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
} }
} }
/// Tries to simplify `match_pair`, returning true if /// Tries to simplify `match_pair`, returning `Ok(())` if
/// successful. If successful, new match pairs and bindings will /// successful. If successful, new match pairs and bindings will
/// have been pushed into the candidate. If no simplification is /// have been pushed into the candidate. If no simplification is
/// possible, Err is returned and no changes are made to /// possible, `Err` is returned and no changes are made to
/// candidate. /// candidate.
fn simplify_match_pair<'pat>(&mut self, fn simplify_match_pair<'pat>(&mut self,
match_pair: MatchPair<'pat, 'tcx>, match_pair: MatchPair<'pat, 'tcx>,
@ -174,7 +174,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
} else { } else {
Err(match_pair) Err(match_pair)
} }
}, }
PatternKind::Array { ref prefix, ref slice, ref suffix } => { PatternKind::Array { ref prefix, ref slice, ref suffix } => {
self.prefix_slice_suffix(&mut candidate.match_pairs, self.prefix_slice_suffix(&mut candidate.match_pairs,

View file

@ -35,10 +35,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
} }
} }
PatternKind::Constant { .. } PatternKind::Constant { .. } if is_switch_ty(match_pair.pattern.ty) => {
if is_switch_ty(match_pair.pattern.ty) => { // For integers, we use a `SwitchInt` match, which allows
// for integers, we use a SwitchInt match, which allows // us to handle more cases.
// us to handle more cases
Test { Test {
span: match_pair.pattern.span, span: match_pair.pattern.span,
kind: TestKind::SwitchInt { kind: TestKind::SwitchInt {
@ -253,12 +252,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
TestKind::Eq { value, mut ty } => { TestKind::Eq { value, mut ty } => {
let val = Operand::Copy(place.clone()); let val = Operand::Copy(place.clone());
let mut expect = self.literal_operand(test.span, ty, value); let mut expect = self.literal_operand(test.span, ty, value);
// Use PartialEq::eq instead of BinOp::Eq // Use `PartialEq::eq` instead of `BinOp::Eq`
// (the binop can only handle primitives) // (the binop can only handle primitives)
let fail = self.cfg.start_new_block(); let fail = self.cfg.start_new_block();
if !ty.is_scalar() { if !ty.is_scalar() {
// If we're using b"..." as a pattern, we need to insert an // If we're using `b"..."` as a pattern, we need to insert an
// unsizing coercion, as the byte string has the type &[u8; N]. // unsizing coercion, as the byte string has the type `&[u8; N]`.
// //
// We want to do this even when the scrutinee is a reference to an // We want to do this even when the scrutinee is a reference to an
// array, so we can call `<[u8]>::eq` rather than having to find an // array, so we can call `<[u8]>::eq` rather than having to find an
@ -503,6 +502,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
resulting_candidates[variant_index.as_usize()].push(new_candidate); resulting_candidates[variant_index.as_usize()].push(new_candidate);
true true
} }
(&TestKind::Switch { .. }, _) => false, (&TestKind::Switch { .. }, _) => false,
// If we are performing a switch over integers, then this informs integer // If we are performing a switch over integers, then this informs integer
@ -539,7 +539,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
(&TestKind::SwitchInt { .. }, _) => false, (&TestKind::SwitchInt { .. }, _) => false,
(&TestKind::Len { len: test_len, op: BinOp::Eq }, (&TestKind::Len { len: test_len, op: BinOp::Eq },
&PatternKind::Slice { ref prefix, ref slice, ref suffix }) => { &PatternKind::Slice { ref prefix, ref slice, ref suffix }) => {
let pat_len = (prefix.len() + suffix.len()) as u64; let pat_len = (prefix.len() + suffix.len()) as u64;

View file

@ -13,7 +13,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
subpatterns.iter() subpatterns.iter()
.map(|fieldpat| { .map(|fieldpat| {
let place = place.clone().field(fieldpat.field, let place = place.clone().field(fieldpat.field,
fieldpat.pattern.ty); fieldpat.pattern.ty);
MatchPair::new(place, &fieldpat.pattern) MatchPair::new(place, &fieldpat.pattern)
}) })
.collect() .collect()

View file

@ -634,8 +634,8 @@ impl<'tcx> Witness<'tcx> {
/// but is instead bounded by the maximum fixed length of slice patterns in /// but is instead bounded by the maximum fixed length of slice patterns in
/// the column of patterns being analyzed. /// the column of patterns being analyzed.
/// ///
/// We make sure to omit constructors that are statically impossible. eg for /// We make sure to omit constructors that are statically impossible. E.g., for
/// Option<!> we do not include Some(_) in the returned list of constructors. /// `Option<!>`, we do not include `Some(_)` in the returned list of constructors.
fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
pcx: PatternContext<'tcx>) pcx: PatternContext<'tcx>)
-> Vec<Constructor<'tcx>> -> Vec<Constructor<'tcx>>
@ -1347,7 +1347,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>,
/// This computes the arity of a constructor. The arity of a constructor /// This computes the arity of a constructor. The arity of a constructor
/// is how many subpattern patterns of that constructor should be expanded to. /// is how many subpattern patterns of that constructor should be expanded to.
/// ///
/// For instance, a tuple pattern (_, 42, Some([])) has the arity of 3. /// For instance, a tuple pattern `(_, 42, Some([]))` has the arity of 3.
/// A struct pattern's arity is the number of fields it contains, etc. /// A struct pattern's arity is the number of fields it contains, etc.
fn constructor_arity(cx: &MatchCheckCtxt<'a, 'tcx>, ctor: &Constructor<'tcx>, ty: Ty<'tcx>) -> u64 { fn constructor_arity(cx: &MatchCheckCtxt<'a, 'tcx>, ctor: &Constructor<'tcx>, ty: Ty<'tcx>) -> u64 {
debug!("constructor_arity({:#?}, {:?})", ctor, ty); debug!("constructor_arity({:#?}, {:?})", ctor, ty);
@ -1357,7 +1357,7 @@ fn constructor_arity(cx: &MatchCheckCtxt<'a, 'tcx>, ctor: &Constructor<'tcx>, ty
Slice(length) => length, Slice(length) => length,
ConstantValue(_) => 0, ConstantValue(_) => 0,
_ => bug!("bad slice pattern {:?} {:?}", ctor, ty) _ => bug!("bad slice pattern {:?} {:?}", ctor, ty)
}, }
ty::Ref(..) => 1, ty::Ref(..) => 1,
ty::Adt(adt, _) => { ty::Adt(adt, _) => {
adt.variants[ctor.variant_index_for_adt(cx, adt)].fields.len() as u64 adt.variants[ctor.variant_index_for_adt(cx, adt)].fields.len() as u64
@ -1381,7 +1381,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>,
Slice(length) => (0..length).map(|_| ty).collect(), Slice(length) => (0..length).map(|_| ty).collect(),
ConstantValue(_) => vec![], ConstantValue(_) => vec![],
_ => bug!("bad slice pattern {:?} {:?}", ctor, ty) _ => bug!("bad slice pattern {:?} {:?}", ctor, ty)
}, }
ty::Ref(_, rty, _) => vec![rty], ty::Ref(_, rty, _) => vec![rty],
ty::Adt(adt, substs) => { ty::Adt(adt, substs) => {
if adt.is_box() { if adt.is_box() {

View file

@ -375,7 +375,7 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
}, },
_ => bug!(), _ => bug!(),
} }
}, }
hir::MatchSource::ForLoopDesugar | hir::MatchSource::ForLoopDesugar |
hir::MatchSource::Normal => { hir::MatchSource::Normal => {
@ -391,7 +391,7 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
err.span_label(catchall, "matches any value"); err.span_label(catchall, "matches any value");
} }
err.emit(); err.emit();
}, }
// Unreachable patterns in try expressions occur when one of the arms // Unreachable patterns in try expressions occur when one of the arms
// are an uninhabited type. Which is OK. // are an uninhabited type. Which is OK.
@ -436,7 +436,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
let (tail, head) = witnesses.split_last().unwrap(); let (tail, head) = witnesses.split_last().unwrap();
let head: Vec<_> = head.iter().map(|w| w.to_string()).collect(); let head: Vec<_> = head.iter().map(|w| w.to_string()).collect();
format!("`{}` and `{}`", head.join("`, `"), tail) format!("`{}` and `{}`", head.join("`, `"), tail)
}, }
_ => { _ => {
let (head, tail) = witnesses.split_at(LIMIT); let (head, tail) = witnesses.split_at(LIMIT);
let head: Vec<_> = head.iter().map(|w| w.to_string()).collect(); let head: Vec<_> = head.iter().map(|w| w.to_string()).collect();
@ -446,7 +446,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
let label_text = match witnesses.len() { let label_text = match witnesses.len() {
1 => format!("pattern {} not covered", joined_patterns), 1 => format!("pattern {} not covered", joined_patterns),
_ => format!("patterns {} not covered", joined_patterns) _ => format!("patterns {} not covered", joined_patterns),
}; };
create_e0004(cx.tcx.sess, sp, create_e0004(cx.tcx.sess, sp,
format!("non-exhaustive patterns: {} not covered", format!("non-exhaustive patterns: {} not covered",
@ -456,7 +456,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
} }
NotUseful => { NotUseful => {
// This is good, wildcard pattern isn't reachable // This is good, wildcard pattern isn't reachable
}, }
_ => bug!() _ => bug!()
} }
} }

View file

@ -965,7 +965,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
PatternKind::Constant { PatternKind::Constant {
value: cv, value: cv,
} }
}, }
ty::Adt(adt_def, _) if adt_def.is_union() => { ty::Adt(adt_def, _) if adt_def.is_union() => {
// Matching on union fields is unsafe, we can't hide it in constants // Matching on union fields is unsafe, we can't hide it in constants
self.tcx.sess.span_err(span, "cannot use unions in constant patterns"); self.tcx.sess.span_err(span, "cannot use unions in constant patterns");
@ -978,7 +978,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
self.tcx.item_path_str(adt_def.did)); self.tcx.item_path_str(adt_def.did));
self.tcx.sess.span_err(span, &msg); self.tcx.sess.span_err(span, &msg);
PatternKind::Wild PatternKind::Wild
}, }
ty::Adt(adt_def, substs) if adt_def.is_enum() => { ty::Adt(adt_def, substs) if adt_def.is_enum() => {
let variant_index = const_variant_index( let variant_index = const_variant_index(
self.tcx, self.param_env, cv self.tcx, self.param_env, cv
@ -993,7 +993,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
variant_index, variant_index,
subpatterns, subpatterns,
} }
}, }
ty::Adt(adt_def, _) => { ty::Adt(adt_def, _) => {
let struct_var = adt_def.non_enum_variant(); let struct_var = adt_def.non_enum_variant();
PatternKind::Leaf { PatternKind::Leaf {
@ -1018,7 +1018,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
PatternKind::Constant { PatternKind::Constant {
value: cv, value: cv,
} }
}, }
}; };
Pattern { Pattern {
@ -1252,19 +1252,19 @@ pub fn compare_const_vals<'a, 'gcx, 'tcx>(
let l = ::rustc_apfloat::ieee::Single::from_bits(a); let l = ::rustc_apfloat::ieee::Single::from_bits(a);
let r = ::rustc_apfloat::ieee::Single::from_bits(b); let r = ::rustc_apfloat::ieee::Single::from_bits(b);
l.partial_cmp(&r) l.partial_cmp(&r)
}, }
ty::Float(ast::FloatTy::F64) => { ty::Float(ast::FloatTy::F64) => {
let l = ::rustc_apfloat::ieee::Double::from_bits(a); let l = ::rustc_apfloat::ieee::Double::from_bits(a);
let r = ::rustc_apfloat::ieee::Double::from_bits(b); let r = ::rustc_apfloat::ieee::Double::from_bits(b);
l.partial_cmp(&r) l.partial_cmp(&r)
}, }
ty::Int(_) => { ty::Int(_) => {
let layout = tcx.layout_of(ty).ok()?; let layout = tcx.layout_of(ty).ok()?;
assert!(layout.abi.is_signed()); assert!(layout.abi.is_signed());
let a = sign_extend(a, layout.size); let a = sign_extend(a, layout.size);
let b = sign_extend(b, layout.size); let b = sign_extend(b, layout.size);
Some((a as i128).cmp(&(b as i128))) Some((a as i128).cmp(&(b as i128)))
}, }
_ => Some(a.cmp(&b)), _ => Some(a.cmp(&b)),
} }
} }

View file

@ -10,6 +10,7 @@ use rustc::mir::interpret::{
GlobalId, AllocId, InboundsCheck, GlobalId, AllocId, InboundsCheck,
ConstValue, Pointer, Scalar, ConstValue, Pointer, Scalar,
EvalResult, EvalErrorKind, EvalResult, EvalErrorKind,
sign_extend, truncate,
}; };
use super::{ use super::{
EvalContext, Machine, AllocMap, Allocation, AllocationExtra, EvalContext, Machine, AllocMap, Allocation, AllocationExtra,
@ -633,20 +634,17 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
Err(_) => return err!(InvalidDiscriminant(raw_discr.erase_tag())), Err(_) => return err!(InvalidDiscriminant(raw_discr.erase_tag())),
}; };
let real_discr = if discr_val.layout.ty.is_signed() { let real_discr = if discr_val.layout.ty.is_signed() {
let i = bits_discr as i128;
// going from layout tag type to typeck discriminant type // going from layout tag type to typeck discriminant type
// requires first sign extending with the layout discriminant // requires first sign extending with the layout discriminant
let shift = 128 - discr_val.layout.size.bits(); let sexted = sign_extend(bits_discr, discr_val.layout.size) as i128;
let sexted = (i << shift) >> shift;
// and then zeroing with the typeck discriminant type // and then zeroing with the typeck discriminant type
let discr_ty = rval.layout.ty let discr_ty = rval.layout.ty
.ty_adt_def().expect("tagged layout corresponds to adt") .ty_adt_def().expect("tagged layout corresponds to adt")
.repr .repr
.discr_type(); .discr_type();
let discr_ty = layout::Integer::from_attr(self, discr_ty); let size = layout::Integer::from_attr(self, discr_ty).size();
let shift = 128 - discr_ty.size().bits();
let truncatee = sexted as u128; let truncatee = sexted as u128;
(truncatee << shift) >> shift truncate(truncatee, size)
} else { } else {
bits_discr bits_discr
}; };

View file

@ -49,8 +49,11 @@ pub struct AbiSpace(pub Abi);
pub struct Function<'a> { pub struct Function<'a> {
/// The declaration to emit. /// The declaration to emit.
pub decl: &'a clean::FnDecl, pub decl: &'a clean::FnDecl,
/// The length of the function's "name", used to determine line-wrapping. /// The length of the function header and name. In other words, the number of characters in the
pub name_len: usize, /// function declaration up to but not including the parentheses.
///
/// Used to determine line-wrapping.
pub header_len: usize,
/// The number of spaces to indent each successive line with, if line-wrapping is necessary. /// The number of spaces to indent each successive line with, if line-wrapping is necessary.
pub indent: usize, pub indent: usize,
/// Whether the function is async or not. /// Whether the function is async or not.
@ -675,7 +678,11 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
} }
} }
clean::ImplTrait(ref bounds) => { clean::ImplTrait(ref bounds) => {
write!(f, "impl {}", GenericBounds(bounds)) if f.alternate() {
write!(f, "impl {:#}", GenericBounds(bounds))
} else {
write!(f, "impl {}", GenericBounds(bounds))
}
} }
clean::QPath { ref name, ref self_type, ref trait_ } => { clean::QPath { ref name, ref self_type, ref trait_ } => {
let should_show_cast = match *trait_ { let should_show_cast = match *trait_ {
@ -844,7 +851,7 @@ impl fmt::Display for clean::FnDecl {
impl<'a> fmt::Display for Function<'a> { impl<'a> fmt::Display for Function<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let &Function { decl, name_len, indent, asyncness } = self; let &Function { decl, header_len, indent, asyncness } = self;
let amp = if f.alternate() { "&" } else { "&amp;" }; let amp = if f.alternate() { "&" } else { "&amp;" };
let mut args = String::new(); let mut args = String::new();
let mut args_plain = String::new(); let mut args_plain = String::new();
@ -899,6 +906,8 @@ impl<'a> fmt::Display for Function<'a> {
} }
} }
let mut args_plain = format!("({})", args_plain);
if decl.variadic { if decl.variadic {
args.push_str(",<br> ..."); args.push_str(",<br> ...");
args_plain.push_str(", ..."); args_plain.push_str(", ...");
@ -917,13 +926,8 @@ impl<'a> fmt::Display for Function<'a> {
output.to_string() output.to_string()
}; };
let pad = " ".repeat(name_len); let declaration_len = header_len + args_plain.len() + arrow_plain.len();
let plain = format!("{pad}({args}){arrow}", let output = if declaration_len > 80 {
pad = pad,
args = args_plain,
arrow = arrow_plain);
let output = if plain.len() > 80 {
let full_pad = format!("<br>{}", "&nbsp;".repeat(indent + 4)); let full_pad = format!("<br>{}", "&nbsp;".repeat(indent + 4));
let close_pad = format!("<br>{}", "&nbsp;".repeat(indent)); let close_pad = format!("<br>{}", "&nbsp;".repeat(indent));
format!("({args}{close}){arrow}", format!("({args}{close}){arrow}",

View file

@ -2787,8 +2787,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
<tr class='{stab}{add}module-item'>\ <tr class='{stab}{add}module-item'>\
<td><a class=\"{class}\" href=\"{href}\" \ <td><a class=\"{class}\" href=\"{href}\" \
title='{title}'>{name}</a>{unsafety_flag}</td>\ title='{title}'>{name}</a>{unsafety_flag}</td>\
<td class='docblock-short'>{stab_tags}{docs}\ <td class='docblock-short'>{stab_tags}{docs}</td>\
</td>\
</tr>", </tr>",
name = *myitem.name.as_ref().unwrap(), name = *myitem.name.as_ref().unwrap(),
stab_tags = stability_tags(myitem), stab_tags = stability_tags(myitem),
@ -2985,14 +2984,16 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
f: &clean::Function) -> fmt::Result { f: &clean::Function) -> fmt::Result {
let name_len = format!("{}{}{}{}{:#}fn {}{:#}", let header_len = format!(
VisSpace(&it.visibility), "{}{}{}{}{:#}fn {}{:#}",
ConstnessSpace(f.header.constness), VisSpace(&it.visibility),
UnsafetySpace(f.header.unsafety), ConstnessSpace(f.header.constness),
AsyncSpace(f.header.asyncness), UnsafetySpace(f.header.unsafety),
AbiSpace(f.header.abi), AsyncSpace(f.header.asyncness),
it.name.as_ref().unwrap(), AbiSpace(f.header.abi),
f.generics).len(); it.name.as_ref().unwrap(),
f.generics
).len();
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it)?)?; write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it)?)?;
render_attributes(w, it)?; render_attributes(w, it)?;
write!(w, write!(w,
@ -3008,7 +3009,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true }, where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true },
decl = Function { decl = Function {
decl: &f.decl, decl: &f.decl,
name_len, header_len,
indent: 0, indent: 0,
asyncness: f.header.asyncness, asyncness: f.header.asyncness,
})?; })?;
@ -3423,16 +3424,18 @@ fn render_assoc_item(w: &mut fmt::Formatter,
href(did).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor) href(did).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor)
} }
}; };
let mut head_len = format!("{}{}{}{}{:#}fn {}{:#}", let mut header_len = format!(
VisSpace(&meth.visibility), "{}{}{}{}{:#}fn {}{:#}",
ConstnessSpace(header.constness), VisSpace(&meth.visibility),
UnsafetySpace(header.unsafety), ConstnessSpace(header.constness),
AsyncSpace(header.asyncness), UnsafetySpace(header.unsafety),
AbiSpace(header.abi), AsyncSpace(header.asyncness),
name, AbiSpace(header.abi),
*g).len(); name,
*g
).len();
let (indent, end_newline) = if parent == ItemType::Trait { let (indent, end_newline) = if parent == ItemType::Trait {
head_len += 4; header_len += 4;
(4, false) (4, false)
} else { } else {
(0, true) (0, true)
@ -3450,7 +3453,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
generics = *g, generics = *g,
decl = Function { decl = Function {
decl: d, decl: d,
name_len: head_len, header_len,
indent, indent,
asyncness: header.asyncness, asyncness: header.asyncness,
}, },

View file

@ -1196,7 +1196,7 @@ if (!DOMTokenList.prototype.remove) {
var actives = [[], [], []]; var actives = [[], [], []];
// "current" is used to know which tab we're looking into. // "current" is used to know which tab we're looking into.
var current = 0; var current = 0;
onEachLazy(document.getElementsByClassName("search-results"), function(e) { onEachLazy(document.getElementById("results").childNodes, function(e) {
onEachLazy(e.getElementsByClassName("highlighted"), function(e) { onEachLazy(e.getElementsByClassName("highlighted"), function(e) {
actives[current].push(e); actives[current].push(e);
}); });
@ -1213,7 +1213,7 @@ if (!DOMTokenList.prototype.remove) {
removeClass(actives[currentTab][0], "highlighted"); removeClass(actives[currentTab][0], "highlighted");
} else if (e.which === 40) { // down } else if (e.which === 40) { // down
if (!actives[currentTab].length) { if (!actives[currentTab].length) {
var results = document.getElementsByClassName("search-results"); var results = document.getElementById("results").childNodes;
if (results.length > 0) { if (results.length > 0) {
var res = results[currentTab].getElementsByClassName("result"); var res = results[currentTab].getElementsByClassName("result");
if (res.length > 0) { if (res.length > 0) {

View file

@ -424,7 +424,8 @@ h4 > code, h3 > code, .invisible > code {
.docblock table { .docblock table {
margin: .5em 0; margin: .5em 0;
width: 100%; width: calc(100% - 2px);
border: 1px dashed;
} }
.docblock table td { .docblock table td {
@ -657,7 +658,7 @@ a {
transition: border-color 300ms ease; transition: border-color 300ms ease;
transition: border-radius 300ms ease-in-out; transition: border-radius 300ms ease-in-out;
transition: box-shadow 300ms ease-in-out; transition: box-shadow 300ms ease-in-out;
width: 100%; width: calc(100% - 32px);
} }
#crate-search + .search-input { #crate-search + .search-input {

View file

@ -68,20 +68,10 @@ pre {
border-bottom-color: #DDD; border-bottom-color: #DDD;
} }
.docblock table { .docblock table, .docblock table td, .docblock table th {
border-color: #ddd; border-color: #ddd;
} }
.docblock table td {
border-top-color: #ddd;
border-bottom-color: #ddd;
}
.docblock table th {
border-top-color: #ddd;
border-bottom-color: #ddd;
}
.content .method .where, .content .method .where,
.content .fn .where, .content .fn .where,
.content .where.fmt-newline { .content .where.fmt-newline {
@ -190,15 +180,15 @@ a.test-arrow {
box-shadow: 1px 0 0 1px #000, 0 0 0 2px transparent; box-shadow: 1px 0 0 1px #000, 0 0 0 2px transparent;
} }
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #404040; }
.stab.internal { background: #FFB9B3; border-color: #B71C1C; color: #404040; }
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #404040; }
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #404040; }
.module-item .stab { .module-item .stab {
color: #ddd; color: #ddd;
} }
.stab.unstable {background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
.stab.internal { background: #FFB9B3; border-color: #B71C1C; color: #2f2f2f; }
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #2f2f2f; }
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; }
#help > div { #help > div {
background: #4d4d4d; background: #4d4d4d;
border-color: #bfbfbf; border-color: #bfbfbf;

View file

@ -67,23 +67,13 @@ pre {
} }
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { .docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
border-bottom-color: #DDD; border-bottom-color: #ddd;
} }
.docblock table { .docblock table, .docblock table td, .docblock table th {
border-color: #ddd; border-color: #ddd;
} }
.docblock table td {
border-top-color: #ddd;
border-bottom-color: #ddd;
}
.docblock table th {
border-top-color: #ddd;
border-bottom-color: #ddd;
}
.content .method .where, .content .method .where,
.content .fn .where, .content .fn .where,
.content .where.fmt-newline { .content .where.fmt-newline {
@ -191,15 +181,15 @@ a.test-arrow {
box-shadow: 1px 0 0 1px #e0e0e0, 0 0 0 2px transparent; box-shadow: 1px 0 0 1px #e0e0e0, 0 0 0 2px transparent;
} }
.module-item .stab {
color: #000;
}
.stab.unstable { background: #FFF5D6; border-color: #FFC600; } .stab.unstable { background: #FFF5D6; border-color: #FFC600; }
.stab.internal { background: #FFB9B3; border-color: #B71C1C; } .stab.internal { background: #FFB9B3; border-color: #B71C1C; }
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; } .stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; } .stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
.module-item .stab {
color: #000;
}
#help > div { #help > div {
background: #e9e9e9; background: #e9e9e9;
border-color: #bfbfbf; border-color: #bfbfbf;

View file

@ -517,13 +517,19 @@ pub fn make_test(s: &str,
} }
} }
if dont_insert_main || already_has_main { // FIXME: This code cannot yet handle no_std test cases yet
if dont_insert_main || already_has_main || prog.contains("![no_std]") {
prog.push_str(everything_else); prog.push_str(everything_else);
} else { } else {
prog.push_str("fn main() {\n"); let returns_result = everything_else.trim_end().ends_with("(())");
let (main_pre, main_post) = if returns_result {
("fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> {",
"}\n_inner().unwrap() }")
} else {
("fn main() {\n", "\n}")
};
prog.extend([main_pre, everything_else, main_post].iter().cloned());
line_offset += 1; line_offset += 1;
prog.push_str(everything_else);
prog.push_str("\n}");
} }
debug!("final doctest:\n{}", prog); debug!("final doctest:\n{}", prog);

View file

@ -1641,7 +1641,7 @@ impl<K, V, S> Default for HashMap<K, V, S>
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap<K, V, S> impl<K, Q: ?Sized, V, S> Index<&Q> for HashMap<K, V, S>
where K: Eq + Hash + Borrow<Q>, where K: Eq + Hash + Borrow<Q>,
Q: Eq + Hash, Q: Eq + Hash,
S: BuildHasher S: BuildHasher
@ -1673,14 +1673,14 @@ pub struct Iter<'a, K: 'a, V: 'a> {
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Iter<'a, K, V> { impl<K, V> Clone for Iter<'_, K, V> {
fn clone(&self) -> Iter<'a, K, V> { fn clone(&self) -> Self {
Iter { inner: self.inner.clone() } Iter { inner: self.inner.clone() }
} }
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K: Debug, V: Debug> fmt::Debug for Iter<'a, K, V> { impl<K: Debug, V: Debug> fmt::Debug for Iter<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list() f.debug_list()
.entries(self.clone()) .entries(self.clone())
@ -1726,14 +1726,14 @@ pub struct Keys<'a, K: 'a, V: 'a> {
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Keys<'a, K, V> { impl<K, V> Clone for Keys<'_, K, V> {
fn clone(&self) -> Keys<'a, K, V> { fn clone(&self) -> Self {
Keys { inner: self.inner.clone() } Keys { inner: self.inner.clone() }
} }
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K: Debug, V> fmt::Debug for Keys<'a, K, V> { impl<K: Debug, V> fmt::Debug for Keys<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list() f.debug_list()
.entries(self.clone()) .entries(self.clone())
@ -1755,14 +1755,14 @@ pub struct Values<'a, K: 'a, V: 'a> {
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Values<'a, K, V> { impl<K, V> Clone for Values<'_, K, V> {
fn clone(&self) -> Values<'a, K, V> { fn clone(&self) -> Self {
Values { inner: self.inner.clone() } Values { inner: self.inner.clone() }
} }
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K, V: Debug> fmt::Debug for Values<'a, K, V> { impl<K, V: Debug> fmt::Debug for Values<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list() f.debug_list()
.entries(self.clone()) .entries(self.clone())
@ -2241,7 +2241,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
} }
#[unstable(feature = "hash_raw_entry", issue = "56167")] #[unstable(feature = "hash_raw_entry", issue = "56167")]
impl<'a, K, V, S> Debug for RawEntryBuilderMut<'a, K, V, S> { impl<K, V, S> Debug for RawEntryBuilderMut<'_, K, V, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RawEntryBuilder") f.debug_struct("RawEntryBuilder")
.finish() .finish()
@ -2249,7 +2249,7 @@ impl<'a, K, V, S> Debug for RawEntryBuilderMut<'a, K, V, S> {
} }
#[unstable(feature = "hash_raw_entry", issue = "56167")] #[unstable(feature = "hash_raw_entry", issue = "56167")]
impl<'a, K: Debug, V: Debug, S> Debug for RawEntryMut<'a, K, V, S> { impl<K: Debug, V: Debug, S> Debug for RawEntryMut<'_, K, V, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
RawEntryMut::Vacant(ref v) => { RawEntryMut::Vacant(ref v) => {
@ -2267,7 +2267,7 @@ impl<'a, K: Debug, V: Debug, S> Debug for RawEntryMut<'a, K, V, S> {
} }
#[unstable(feature = "hash_raw_entry", issue = "56167")] #[unstable(feature = "hash_raw_entry", issue = "56167")]
impl<'a, K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'a, K, V> { impl<K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RawOccupiedEntryMut") f.debug_struct("RawOccupiedEntryMut")
.field("key", self.key()) .field("key", self.key())
@ -2277,7 +2277,7 @@ impl<'a, K: Debug, V: Debug> Debug for RawOccupiedEntryMut<'a, K, V> {
} }
#[unstable(feature = "hash_raw_entry", issue = "56167")] #[unstable(feature = "hash_raw_entry", issue = "56167")]
impl<'a, K, V, S> Debug for RawVacantEntryMut<'a, K, V, S> { impl<K, V, S> Debug for RawVacantEntryMut<'_, K, V, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RawVacantEntryMut") f.debug_struct("RawVacantEntryMut")
.finish() .finish()
@ -2285,7 +2285,7 @@ impl<'a, K, V, S> Debug for RawVacantEntryMut<'a, K, V, S> {
} }
#[unstable(feature = "hash_raw_entry", issue = "56167")] #[unstable(feature = "hash_raw_entry", issue = "56167")]
impl<'a, K, V, S> Debug for RawEntryBuilder<'a, K, V, S> { impl<K, V, S> Debug for RawEntryBuilder<'_, K, V, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RawEntryBuilder") f.debug_struct("RawEntryBuilder")
.finish() .finish()
@ -2312,7 +2312,7 @@ pub enum Entry<'a, K: 'a, V: 'a> {
} }
#[stable(feature= "debug_hash_map", since = "1.12.0")] #[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for Entry<'a, K, V> { impl<K: Debug, V: Debug> Debug for Entry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
Vacant(ref v) => { Vacant(ref v) => {
@ -2340,7 +2340,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
} }
#[stable(feature= "debug_hash_map", since = "1.12.0")] #[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for OccupiedEntry<'a, K, V> { impl<K: Debug, V: Debug> Debug for OccupiedEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("OccupiedEntry") f.debug_struct("OccupiedEntry")
.field("key", self.key()) .field("key", self.key())
@ -2361,7 +2361,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> {
} }
#[stable(feature= "debug_hash_map", since = "1.12.0")] #[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<'a, K: 'a + Debug, V: 'a> Debug for VacantEntry<'a, K, V> { impl<K: Debug, V> Debug for VacantEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("VacantEntry") f.debug_tuple("VacantEntry")
.field(self.key()) .field(self.key())
@ -2448,7 +2448,7 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> { impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() self.inner.len()
@ -2456,7 +2456,7 @@ impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Iter<'a, K, V> {} impl<K, V> FusedIterator for Iter<'_, K, V> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Iterator for IterMut<'a, K, V> { impl<'a, K, V> Iterator for IterMut<'a, K, V> {
@ -2472,17 +2472,17 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> { impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() self.inner.len()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {} impl<K, V> FusedIterator for IterMut<'_, K, V> {}
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K, V> fmt::Debug for IterMut<'a, K, V> impl<K, V> fmt::Debug for IterMut<'_, K, V>
where K: fmt::Debug, where K: fmt::Debug,
V: fmt::Debug, V: fmt::Debug,
{ {
@ -2539,14 +2539,14 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> { impl<K, V> ExactSizeIterator for Keys<'_, K, V> {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() self.inner.len()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Keys<'a, K, V> {} impl<K, V> FusedIterator for Keys<'_, K, V> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Iterator for Values<'a, K, V> { impl<'a, K, V> Iterator for Values<'a, K, V> {
@ -2562,14 +2562,14 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> { impl<K, V> ExactSizeIterator for Values<'_, K, V> {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() self.inner.len()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Values<'a, K, V> {} impl<K, V> FusedIterator for Values<'_, K, V> {}
#[stable(feature = "map_values_mut", since = "1.10.0")] #[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> Iterator for ValuesMut<'a, K, V> { impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
@ -2585,17 +2585,17 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
} }
} }
#[stable(feature = "map_values_mut", since = "1.10.0")] #[stable(feature = "map_values_mut", since = "1.10.0")]
impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> { impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() self.inner.len()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for ValuesMut<'a, K, V> {} impl<K, V> FusedIterator for ValuesMut<'_, K, V> {}
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K, V> fmt::Debug for ValuesMut<'a, K, V> impl<K, V> fmt::Debug for ValuesMut<'_, K, V>
where K: fmt::Debug, where K: fmt::Debug,
V: fmt::Debug, V: fmt::Debug,
{ {
@ -2620,17 +2620,17 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
} }
} }
#[stable(feature = "drain", since = "1.6.0")] #[stable(feature = "drain", since = "1.6.0")]
impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> { impl<K, V> ExactSizeIterator for Drain<'_, K, V> {
#[inline] #[inline]
fn len(&self) -> usize { fn len(&self) -> usize {
self.inner.len() self.inner.len()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K, V> FusedIterator for Drain<'a, K, V> {} impl<K, V> FusedIterator for Drain<'_, K, V> {}
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K, V> fmt::Debug for Drain<'a, K, V> impl<K, V> fmt::Debug for Drain<'_, K, V>
where K: fmt::Debug, where K: fmt::Debug,
V: fmt::Debug, V: fmt::Debug,
{ {

View file

@ -1112,8 +1112,8 @@ impl<T, S> IntoIterator for HashSet<T, S>
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K> Clone for Iter<'a, K> { impl<K> Clone for Iter<'_, K> {
fn clone(&self) -> Iter<'a, K> { fn clone(&self) -> Self {
Iter { iter: self.iter.clone() } Iter { iter: self.iter.clone() }
} }
} }
@ -1129,16 +1129,16 @@ impl<'a, K> Iterator for Iter<'a, K> {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K> ExactSizeIterator for Iter<'a, K> { impl<K> ExactSizeIterator for Iter<'_, K> {
fn len(&self) -> usize { fn len(&self) -> usize {
self.iter.len() self.iter.len()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K> FusedIterator for Iter<'a, K> {} impl<K> FusedIterator for Iter<'_, K> {}
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K: fmt::Debug> fmt::Debug for Iter<'a, K> { impl<K: fmt::Debug> fmt::Debug for Iter<'_, K> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish() f.debug_list().entries(self.clone()).finish()
} }
@ -1187,16 +1187,16 @@ impl<'a, K> Iterator for Drain<'a, K> {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K> ExactSizeIterator for Drain<'a, K> { impl<K> ExactSizeIterator for Drain<'_, K> {
fn len(&self) -> usize { fn len(&self) -> usize {
self.iter.len() self.iter.len()
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, K> FusedIterator for Drain<'a, K> {} impl<K> FusedIterator for Drain<'_, K> {}
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, K: fmt::Debug> fmt::Debug for Drain<'a, K> { impl<K: fmt::Debug> fmt::Debug for Drain<'_, K> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let entries_iter = self.iter let entries_iter = self.iter
.inner .inner
@ -1207,8 +1207,8 @@ impl<'a, K: fmt::Debug> fmt::Debug for Drain<'a, K> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T, S> Clone for Intersection<'a, T, S> { impl<T, S> Clone for Intersection<'_, T, S> {
fn clone(&self) -> Intersection<'a, T, S> { fn clone(&self) -> Self {
Intersection { iter: self.iter.clone(), ..*self } Intersection { iter: self.iter.clone(), ..*self }
} }
} }
@ -1236,7 +1236,7 @@ impl<'a, T, S> Iterator for Intersection<'a, T, S>
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, T, S> fmt::Debug for Intersection<'a, T, S> impl<T, S> fmt::Debug for Intersection<'_, T, S>
where T: fmt::Debug + Eq + Hash, where T: fmt::Debug + Eq + Hash,
S: BuildHasher S: BuildHasher
{ {
@ -1246,15 +1246,15 @@ impl<'a, T, S> fmt::Debug for Intersection<'a, T, S>
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, T, S> FusedIterator for Intersection<'a, T, S> impl<T, S> FusedIterator for Intersection<'_, T, S>
where T: Eq + Hash, where T: Eq + Hash,
S: BuildHasher S: BuildHasher
{ {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T, S> Clone for Difference<'a, T, S> { impl<T, S> Clone for Difference<'_, T, S> {
fn clone(&self) -> Difference<'a, T, S> { fn clone(&self) -> Self {
Difference { iter: self.iter.clone(), ..*self } Difference { iter: self.iter.clone(), ..*self }
} }
} }
@ -1282,14 +1282,14 @@ impl<'a, T, S> Iterator for Difference<'a, T, S>
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, T, S> FusedIterator for Difference<'a, T, S> impl<T, S> FusedIterator for Difference<'_, T, S>
where T: Eq + Hash, where T: Eq + Hash,
S: BuildHasher S: BuildHasher
{ {
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, T, S> fmt::Debug for Difference<'a, T, S> impl<T, S> fmt::Debug for Difference<'_, T, S>
where T: fmt::Debug + Eq + Hash, where T: fmt::Debug + Eq + Hash,
S: BuildHasher S: BuildHasher
{ {
@ -1299,8 +1299,8 @@ impl<'a, T, S> fmt::Debug for Difference<'a, T, S>
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T, S> Clone for SymmetricDifference<'a, T, S> { impl<T, S> Clone for SymmetricDifference<'_, T, S> {
fn clone(&self) -> SymmetricDifference<'a, T, S> { fn clone(&self) -> Self {
SymmetricDifference { iter: self.iter.clone() } SymmetricDifference { iter: self.iter.clone() }
} }
} }
@ -1321,14 +1321,14 @@ impl<'a, T, S> Iterator for SymmetricDifference<'a, T, S>
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, T, S> FusedIterator for SymmetricDifference<'a, T, S> impl<T, S> FusedIterator for SymmetricDifference<'_, T, S>
where T: Eq + Hash, where T: Eq + Hash,
S: BuildHasher S: BuildHasher
{ {
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, T, S> fmt::Debug for SymmetricDifference<'a, T, S> impl<T, S> fmt::Debug for SymmetricDifference<'_, T, S>
where T: fmt::Debug + Eq + Hash, where T: fmt::Debug + Eq + Hash,
S: BuildHasher S: BuildHasher
{ {
@ -1338,21 +1338,21 @@ impl<'a, T, S> fmt::Debug for SymmetricDifference<'a, T, S>
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T, S> Clone for Union<'a, T, S> { impl<T, S> Clone for Union<'_, T, S> {
fn clone(&self) -> Union<'a, T, S> { fn clone(&self) -> Self {
Union { iter: self.iter.clone() } Union { iter: self.iter.clone() }
} }
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a, T, S> FusedIterator for Union<'a, T, S> impl<T, S> FusedIterator for Union<'_, T, S>
where T: Eq + Hash, where T: Eq + Hash,
S: BuildHasher S: BuildHasher
{ {
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, T, S> fmt::Debug for Union<'a, T, S> impl<T, S> fmt::Debug for Union<'_, T, S>
where T: fmt::Debug + Eq + Hash, where T: fmt::Debug + Eq + Hash,
S: BuildHasher S: BuildHasher
{ {

View file

@ -296,7 +296,7 @@ pub trait Put<K, V> {
} }
impl<'t, K, V> Put<K, V> for &'t mut RawTable<K, V> { impl<K, V> Put<K, V> for &mut RawTable<K, V> {
unsafe fn borrow_table_mut(&mut self) -> &mut RawTable<K, V> { unsafe fn borrow_table_mut(&mut self) -> &mut RawTable<K, V> {
*self *self
} }
@ -865,8 +865,8 @@ struct RawBuckets<'a, K, V> {
} }
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
impl<'a, K, V> Clone for RawBuckets<'a, K, V> { impl<K, V> Clone for RawBuckets<'_, K, V> {
fn clone(&self) -> RawBuckets<'a, K, V> { fn clone(&self) -> Self {
RawBuckets { RawBuckets {
raw: self.raw, raw: self.raw,
elems_left: self.elems_left, elems_left: self.elems_left,
@ -901,7 +901,7 @@ impl<'a, K, V> Iterator for RawBuckets<'a, K, V> {
} }
} }
impl<'a, K, V> ExactSizeIterator for RawBuckets<'a, K, V> { impl<K, V> ExactSizeIterator for RawBuckets<'_, K, V> {
fn len(&self) -> usize { fn len(&self) -> usize {
self.elems_left self.elems_left
} }
@ -912,12 +912,12 @@ pub struct Iter<'a, K: 'a, V: 'a> {
iter: RawBuckets<'a, K, V>, iter: RawBuckets<'a, K, V>,
} }
unsafe impl<'a, K: Sync, V: Sync> Sync for Iter<'a, K, V> {} unsafe impl<K: Sync, V: Sync> Sync for Iter<'_, K, V> {}
unsafe impl<'a, K: Sync, V: Sync> Send for Iter<'a, K, V> {} unsafe impl<K: Sync, V: Sync> Send for Iter<'_, K, V> {}
// FIXME(#26925) Remove in favor of `#[derive(Clone)]` // FIXME(#26925) Remove in favor of `#[derive(Clone)]`
impl<'a, K, V> Clone for Iter<'a, K, V> { impl<K, V> Clone for Iter<'_, K, V> {
fn clone(&self) -> Iter<'a, K, V> { fn clone(&self) -> Self {
Iter { Iter {
iter: self.iter.clone(), iter: self.iter.clone(),
} }
@ -931,10 +931,10 @@ pub struct IterMut<'a, K: 'a, V: 'a> {
_marker: marker::PhantomData<&'a mut V>, _marker: marker::PhantomData<&'a mut V>,
} }
unsafe impl<'a, K: Sync, V: Sync> Sync for IterMut<'a, K, V> {} unsafe impl<K: Sync, V: Sync> Sync for IterMut<'_, K, V> {}
// Both K: Sync and K: Send are correct for IterMut's Send impl, // Both K: Sync and K: Send are correct for IterMut's Send impl,
// but Send is the more useful bound // but Send is the more useful bound
unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {} unsafe impl<K: Send, V: Send> Send for IterMut<'_, K, V> {}
impl<'a, K: 'a, V: 'a> IterMut<'a, K, V> { impl<'a, K: 'a, V: 'a> IterMut<'a, K, V> {
pub fn iter(&self) -> Iter<K, V> { pub fn iter(&self) -> Iter<K, V> {
@ -968,8 +968,8 @@ pub struct Drain<'a, K: 'a, V: 'a> {
marker: marker::PhantomData<&'a RawTable<K, V>>, marker: marker::PhantomData<&'a RawTable<K, V>>,
} }
unsafe impl<'a, K: Sync, V: Sync> Sync for Drain<'a, K, V> {} unsafe impl<K: Sync, V: Sync> Sync for Drain<'_, K, V> {}
unsafe impl<'a, K: Send, V: Send> Send for Drain<'a, K, V> {} unsafe impl<K: Send, V: Send> Send for Drain<'_, K, V> {}
impl<'a, K, V> Drain<'a, K, V> { impl<'a, K, V> Drain<'a, K, V> {
pub fn iter(&self) -> Iter<K, V> { pub fn iter(&self) -> Iter<K, V> {
@ -994,7 +994,7 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> {
} }
} }
impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> { impl<K, V> ExactSizeIterator for Iter<'_, K, V> {
fn len(&self) -> usize { fn len(&self) -> usize {
self.iter.len() self.iter.len()
} }
@ -1015,7 +1015,7 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
} }
} }
impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> { impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
fn len(&self) -> usize { fn len(&self) -> usize {
self.iter.len() self.iter.len()
} }
@ -1064,13 +1064,13 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
} }
} }
impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> { impl<K, V> ExactSizeIterator for Drain<'_, K, V> {
fn len(&self) -> usize { fn len(&self) -> usize {
self.iter.len() self.iter.len()
} }
} }
impl<'a, K: 'a, V: 'a> Drop for Drain<'a, K, V> { impl<K, V> Drop for Drain<'_, K, V> {
fn drop(&mut self) { fn drop(&mut self) {
self.for_each(drop); self.for_each(drop);
} }

View file

@ -399,7 +399,7 @@ impl<'a> Iterator for SplitPaths<'a> {
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a> fmt::Debug for SplitPaths<'a> { impl fmt::Debug for SplitPaths<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("SplitPaths { .. }") f.pad("SplitPaths { .. }")
} }

View file

@ -659,8 +659,8 @@ impl fmt::Debug for CStr {
} }
#[stable(feature = "cstr_default", since = "1.10.0")] #[stable(feature = "cstr_default", since = "1.10.0")]
impl<'a> Default for &'a CStr { impl Default for &CStr {
fn default() -> &'a CStr { fn default() -> Self {
const SLICE: &[c_char] = &[0]; const SLICE: &[c_char] = &[0];
unsafe { CStr::from_ptr(SLICE.as_ptr()) } unsafe { CStr::from_ptr(SLICE.as_ptr()) }
} }

View file

@ -778,10 +778,10 @@ impl Default for Box<OsStr> {
} }
#[stable(feature = "osstring_default", since = "1.9.0")] #[stable(feature = "osstring_default", since = "1.9.0")]
impl<'a> Default for &'a OsStr { impl Default for &OsStr {
/// Creates an empty `OsStr`. /// Creates an empty `OsStr`.
#[inline] #[inline]
fn default() -> &'a OsStr { fn default() -> Self {
OsStr::new("") OsStr::new("")
} }
} }

View file

@ -254,10 +254,13 @@ fn initial_buffer_size(file: &File) -> usize {
/// ``` /// ```
#[stable(feature = "fs_read_write_bytes", since = "1.26.0")] #[stable(feature = "fs_read_write_bytes", since = "1.26.0")]
pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> { pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
let mut file = File::open(path)?; fn inner(path: &Path) -> io::Result<Vec<u8>> {
let mut bytes = Vec::with_capacity(initial_buffer_size(&file)); let mut file = File::open(path)?;
file.read_to_end(&mut bytes)?; let mut bytes = Vec::with_capacity(initial_buffer_size(&file));
Ok(bytes) file.read_to_end(&mut bytes)?;
Ok(bytes)
}
inner(path.as_ref())
} }
/// Read the entire contents of a file into a string. /// Read the entire contents of a file into a string.
@ -296,10 +299,13 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
/// ``` /// ```
#[stable(feature = "fs_read_write", since = "1.26.0")] #[stable(feature = "fs_read_write", since = "1.26.0")]
pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> { pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
let mut file = File::open(path)?; fn inner(path: &Path) -> io::Result<String> {
let mut string = String::with_capacity(initial_buffer_size(&file)); let mut file = File::open(path)?;
file.read_to_string(&mut string)?; let mut string = String::with_capacity(initial_buffer_size(&file));
Ok(string) file.read_to_string(&mut string)?;
Ok(string)
}
inner(path.as_ref())
} }
/// Write a slice as the entire contents of a file. /// Write a slice as the entire contents of a file.
@ -326,7 +332,10 @@ pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
/// ``` /// ```
#[stable(feature = "fs_read_write_bytes", since = "1.26.0")] #[stable(feature = "fs_read_write_bytes", since = "1.26.0")]
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> { pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> {
File::create(path)?.write_all(contents.as_ref()) fn inner(path: &Path, contents: &[u8]) -> io::Result<()> {
File::create(path)?.write_all(contents)
}
inner(path.as_ref(), contents.as_ref())
} }
impl File { impl File {
@ -618,7 +627,7 @@ impl Seek for File {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Read for &'a File { impl Read for &File {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.read(buf) self.inner.read(buf)
} }
@ -629,14 +638,14 @@ impl<'a> Read for &'a File {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Write for &'a File { impl Write for &File {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.write(buf) self.inner.write(buf)
} }
fn flush(&mut self) -> io::Result<()> { self.inner.flush() } fn flush(&mut self) -> io::Result<()> { self.inner.flush() }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Seek for &'a File { impl Seek for &File {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
self.inner.seek(pos) self.inner.seek(pos)
} }

View file

@ -1174,7 +1174,7 @@ mod tests {
// Issue #32085 // Issue #32085
struct FailFlushWriter<'a>(&'a mut Vec<u8>); struct FailFlushWriter<'a>(&'a mut Vec<u8>);
impl<'a> Write for FailFlushWriter<'a> { impl Write for FailFlushWriter<'_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.0.extend_from_slice(buf); self.0.extend_from_slice(buf);
Ok(buf.len()) Ok(buf.len())

View file

@ -279,7 +279,7 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec<u8>, buf: &[u8]) -> io::Result<usi
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Write for Cursor<&'a mut [u8]> { impl Write for Cursor<&mut [u8]> {
#[inline] #[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
slice_write(&mut self.pos, self.inner, buf) slice_write(&mut self.pos, self.inner, buf)
@ -288,7 +288,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> {
} }
#[stable(feature = "cursor_mut_vec", since = "1.25.0")] #[stable(feature = "cursor_mut_vec", since = "1.25.0")]
impl<'a> Write for Cursor<&'a mut Vec<u8>> { impl Write for Cursor<&mut Vec<u8>> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
vec_write(&mut self.pos, self.inner, buf) vec_write(&mut self.pos, self.inner, buf)
} }

View file

@ -7,7 +7,7 @@ use mem;
// Forwarding implementations // Forwarding implementations
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, R: Read + ?Sized> Read for &'a mut R { impl<R: Read + ?Sized> Read for &mut R {
#[inline] #[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
(**self).read(buf) (**self).read(buf)
@ -34,7 +34,7 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, W: Write + ?Sized> Write for &'a mut W { impl<W: Write + ?Sized> Write for &mut W {
#[inline] #[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) } fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) }
@ -52,12 +52,12 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, S: Seek + ?Sized> Seek for &'a mut S { impl<S: Seek + ?Sized> Seek for &mut S {
#[inline] #[inline]
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) } fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { impl<B: BufRead + ?Sized> BufRead for &mut B {
#[inline] #[inline]
fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
@ -152,7 +152,7 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> {
/// Note that reading updates the slice to point to the yet unread part. /// Note that reading updates the slice to point to the yet unread part.
/// The slice will be empty when EOF is reached. /// The slice will be empty when EOF is reached.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Read for &'a [u8] { impl Read for &[u8] {
#[inline] #[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let amt = cmp::min(buf.len(), self.len()); let amt = cmp::min(buf.len(), self.len());
@ -207,7 +207,7 @@ impl<'a> Read for &'a [u8] {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> BufRead for &'a [u8] { impl BufRead for &[u8] {
#[inline] #[inline]
fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) }
@ -221,7 +221,7 @@ impl<'a> BufRead for &'a [u8] {
/// Note that writing updates the slice to point to the yet unwritten part. /// Note that writing updates the slice to point to the yet unwritten part.
/// The slice will be empty when it has been completely overwritten. /// The slice will be empty when it has been completely overwritten.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Write for &'a mut [u8] { impl Write for &mut [u8] {
#[inline] #[inline]
fn write(&mut self, data: &[u8]) -> io::Result<usize> { fn write(&mut self, data: &[u8]) -> io::Result<usize> {
let amt = cmp::min(data.len(), self.len()); let amt = cmp::min(data.len(), self.len());

View file

@ -299,7 +299,7 @@ const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
struct Guard<'a> { buf: &'a mut Vec<u8>, len: usize } struct Guard<'a> { buf: &'a mut Vec<u8>, len: usize }
impl<'a> Drop for Guard<'a> { impl Drop for Guard<'_> {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { self.buf.set_len(self.len); } unsafe { self.buf.set_len(self.len); }
} }
@ -1114,7 +1114,7 @@ pub trait Write {
error: Result<()>, error: Result<()>,
} }
impl<'a, T: Write + ?Sized> fmt::Write for Adaptor<'a, T> { impl<T: Write + ?Sized> fmt::Write for Adaptor<'_, T> {
fn write_str(&mut self, s: &str) -> fmt::Result { fn write_str(&mut self, s: &str) -> fmt::Result {
match self.inner.write_all(s.as_bytes()) { match self.inner.write_all(s.as_bytes()) {
Ok(()) => Ok(()), Ok(()) => Ok(()),

View file

@ -312,7 +312,7 @@ impl Read for Stdin {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Read for StdinLock<'a> { impl Read for StdinLock<'_> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.read(buf) self.inner.read(buf)
} }
@ -323,13 +323,13 @@ impl<'a> Read for StdinLock<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> BufRead for StdinLock<'a> { impl BufRead for StdinLock<'_> {
fn fill_buf(&mut self) -> io::Result<&[u8]> { self.inner.fill_buf() } fn fill_buf(&mut self) -> io::Result<&[u8]> { self.inner.fill_buf() }
fn consume(&mut self, n: usize) { self.inner.consume(n) } fn consume(&mut self, n: usize) { self.inner.consume(n) }
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a> fmt::Debug for StdinLock<'a> { impl fmt::Debug for StdinLock<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("StdinLock { .. }") f.pad("StdinLock { .. }")
} }
@ -485,7 +485,7 @@ impl Write for Stdout {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Write for StdoutLock<'a> { impl Write for StdoutLock<'_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.borrow_mut().write(buf) self.inner.borrow_mut().write(buf)
} }
@ -495,7 +495,7 @@ impl<'a> Write for StdoutLock<'a> {
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a> fmt::Debug for StdoutLock<'a> { impl fmt::Debug for StdoutLock<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("StdoutLock { .. }") f.pad("StdoutLock { .. }")
} }
@ -638,7 +638,7 @@ impl Write for Stderr {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Write for StderrLock<'a> { impl Write for StderrLock<'_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.borrow_mut().write(buf) self.inner.borrow_mut().write(buf)
} }
@ -648,7 +648,7 @@ impl<'a> Write for StderrLock<'a> {
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a> fmt::Debug for StderrLock<'a> { impl fmt::Debug for StderrLock<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("StderrLock { .. }") f.pad("StderrLock { .. }")
} }

View file

@ -861,7 +861,7 @@ fn resolve_socket_addr(lh: LookupHost) -> io::Result<vec::IntoIter<SocketAddr>>
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> ToSocketAddrs for (&'a str, u16) { impl ToSocketAddrs for (&str, u16) {
type Iter = vec::IntoIter<SocketAddr>; type Iter = vec::IntoIter<SocketAddr>;
fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> { fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
let (host, port) = *self; let (host, port) = *self;
@ -904,7 +904,7 @@ impl<'a> ToSocketAddrs for &'a [SocketAddr] {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T { impl<T: ToSocketAddrs + ?Sized> ToSocketAddrs for &T {
type Iter = T::Iter; type Iter = T::Iter;
fn to_socket_addrs(&self) -> io::Result<T::Iter> { fn to_socket_addrs(&self) -> io::Result<T::Iter> {
(**self).to_socket_addrs() (**self).to_socket_addrs()

View file

@ -329,6 +329,8 @@ impl Ipv4Addr {
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr { pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
// FIXME: should just be u32::from_be_bytes([a, b, c, d]),
// once that method is no longer rustc_const_unstable
Ipv4Addr { Ipv4Addr {
inner: c::in_addr { inner: c::in_addr {
s_addr: u32::to_be( s_addr: u32::to_be(
@ -392,6 +394,7 @@ impl Ipv4Addr {
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn octets(&self) -> [u8; 4] { pub fn octets(&self) -> [u8; 4] {
// This returns the order we want because s_addr is stored in big-endian.
self.inner.s_addr.to_ne_bytes() self.inner.s_addr.to_ne_bytes()
} }
@ -618,9 +621,13 @@ impl Ipv4Addr {
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn to_ipv6_compatible(&self) -> Ipv6Addr { pub fn to_ipv6_compatible(&self) -> Ipv6Addr {
Ipv6Addr::new(0, 0, 0, 0, 0, 0, let octets = self.octets();
((self.octets()[0] as u16) << 8) | self.octets()[1] as u16, Ipv6Addr::from([
((self.octets()[2] as u16) << 8) | self.octets()[3] as u16) 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
octets[0], octets[1], octets[2], octets[3],
])
} }
/// Converts this address to an IPv4-mapped [IPv6 address]. /// Converts this address to an IPv4-mapped [IPv6 address].
@ -639,9 +646,13 @@ impl Ipv4Addr {
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn to_ipv6_mapped(&self) -> Ipv6Addr { pub fn to_ipv6_mapped(&self) -> Ipv6Addr {
Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, let octets = self.octets();
((self.octets()[0] as u16) << 8) | self.octets()[1] as u16, Ipv6Addr::from([
((self.octets()[2] as u16) << 8) | self.octets()[3] as u16) 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0xFF, 0xFF,
octets[0], octets[1], octets[2], octets[3],
])
} }
} }
@ -784,7 +795,7 @@ impl From<Ipv4Addr> for u32 {
/// ``` /// ```
fn from(ip: Ipv4Addr) -> u32 { fn from(ip: Ipv4Addr) -> u32 {
let ip = ip.octets(); let ip = ip.octets();
((ip[0] as u32) << 24) + ((ip[1] as u32) << 16) + ((ip[2] as u32) << 8) + (ip[3] as u32) u32::from_be_bytes(ip)
} }
} }
@ -801,7 +812,7 @@ impl From<u32> for Ipv4Addr {
/// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr); /// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr);
/// ``` /// ```
fn from(ip: u32) -> Ipv4Addr { fn from(ip: u32) -> Ipv4Addr {
Ipv4Addr::new((ip >> 24) as u8, (ip >> 16) as u8, (ip >> 8) as u8, ip as u8) Ipv4Addr::from(ip.to_be_bytes())
} }
} }
@ -909,14 +920,14 @@ impl Ipv6Addr {
pub fn segments(&self) -> [u16; 8] { pub fn segments(&self) -> [u16; 8] {
let arr = &self.inner.s6_addr; let arr = &self.inner.s6_addr;
[ [
(arr[0] as u16) << 8 | (arr[1] as u16), u16::from_be_bytes([arr[0], arr[1]]),
(arr[2] as u16) << 8 | (arr[3] as u16), u16::from_be_bytes([arr[2], arr[3]]),
(arr[4] as u16) << 8 | (arr[5] as u16), u16::from_be_bytes([arr[4], arr[5]]),
(arr[6] as u16) << 8 | (arr[7] as u16), u16::from_be_bytes([arr[6], arr[7]]),
(arr[8] as u16) << 8 | (arr[9] as u16), u16::from_be_bytes([arr[8], arr[9]]),
(arr[10] as u16) << 8 | (arr[11] as u16), u16::from_be_bytes([arr[10], arr[11]]),
(arr[12] as u16) << 8 | (arr[13] as u16), u16::from_be_bytes([arr[12], arr[13]]),
(arr[14] as u16) << 8 | (arr[15] as u16), u16::from_be_bytes([arr[14], arr[15]]),
] ]
} }
@ -1382,21 +1393,43 @@ impl FromInner<c::in6_addr> for Ipv6Addr {
#[stable(feature = "i128", since = "1.26.0")] #[stable(feature = "i128", since = "1.26.0")]
impl From<Ipv6Addr> for u128 { impl From<Ipv6Addr> for u128 {
/// Convert an `Ipv6Addr` into a host byte order `u128`.
///
/// # Examples
///
/// ```
/// use std::net::Ipv6Addr;
///
/// let addr = Ipv6Addr::new(
/// 0x1020, 0x3040, 0x5060, 0x7080,
/// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D,
/// );
/// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr));
/// ```
fn from(ip: Ipv6Addr) -> u128 { fn from(ip: Ipv6Addr) -> u128 {
let ip = ip.segments(); let ip = ip.octets();
((ip[0] as u128) << 112) + ((ip[1] as u128) << 96) + ((ip[2] as u128) << 80) + u128::from_be_bytes(ip)
((ip[3] as u128) << 64) + ((ip[4] as u128) << 48) + ((ip[5] as u128) << 32) +
((ip[6] as u128) << 16) + (ip[7] as u128)
} }
} }
#[stable(feature = "i128", since = "1.26.0")] #[stable(feature = "i128", since = "1.26.0")]
impl From<u128> for Ipv6Addr { impl From<u128> for Ipv6Addr {
/// Convert a host byte order `u128` into an `Ipv6Addr`.
///
/// # Examples
///
/// ```
/// use std::net::Ipv6Addr;
///
/// let addr = Ipv6Addr::from(0x102030405060708090A0B0C0D0E0F00D_u128);
/// assert_eq!(
/// Ipv6Addr::new(
/// 0x1020, 0x3040, 0x5060, 0x7080,
/// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D,
/// ),
/// addr);
/// ```
fn from(ip: u128) -> Ipv6Addr { fn from(ip: u128) -> Ipv6Addr {
Ipv6Addr::new( Ipv6Addr::from(ip.to_be_bytes())
(ip >> 112) as u16, (ip >> 96) as u16, (ip >> 80) as u16,
(ip >> 64) as u16, (ip >> 48) as u16, (ip >> 32) as u16,
(ip >> 16) as u16, ip as u16,
)
} }
} }

View file

@ -580,7 +580,7 @@ impl Write for TcpStream {
fn flush(&mut self) -> io::Result<()> { Ok(()) } fn flush(&mut self) -> io::Result<()> { Ok(()) }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Read for &'a TcpStream { impl Read for &TcpStream {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { self.0.read(buf) } fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { self.0.read(buf) }
#[inline] #[inline]
@ -589,7 +589,7 @@ impl<'a> Read for &'a TcpStream {
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Write for &'a TcpStream { impl Write for &TcpStream {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) } fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
fn flush(&mut self) -> io::Result<()> { Ok(()) } fn flush(&mut self) -> io::Result<()> { Ok(()) }
} }
@ -1187,9 +1187,13 @@ mod tests {
#[test] #[test]
fn double_bind() { fn double_bind() {
each_ip(&mut |addr| { each_ip(&mut |addr| {
let _listener = t!(TcpListener::bind(&addr)); let listener1 = t!(TcpListener::bind(&addr));
match TcpListener::bind(&addr) { match TcpListener::bind(&addr) {
Ok(..) => panic!(), Ok(listener2) => panic!(
"This system (perhaps due to options set by TcpListener::bind) \
permits double binding: {:?} and {:?}",
listener1, listener2
),
Err(e) => { Err(e) => {
assert!(e.kind() == ErrorKind::ConnectionRefused || assert!(e.kind() == ErrorKind::ConnectionRefused ||
e.kind() == ErrorKind::Other || e.kind() == ErrorKind::Other ||

View file

@ -199,9 +199,9 @@ pub struct AssertUnwindSafe<T>(
// * Our custom AssertUnwindSafe wrapper is indeed unwind safe // * Our custom AssertUnwindSafe wrapper is indeed unwind safe
#[stable(feature = "catch_unwind", since = "1.9.0")] #[stable(feature = "catch_unwind", since = "1.9.0")]
impl<'a, T: ?Sized> !UnwindSafe for &'a mut T {} impl<T: ?Sized> !UnwindSafe for &mut T {}
#[stable(feature = "catch_unwind", since = "1.9.0")] #[stable(feature = "catch_unwind", since = "1.9.0")]
impl<'a, T: RefUnwindSafe + ?Sized> UnwindSafe for &'a T {} impl<T: RefUnwindSafe + ?Sized> UnwindSafe for &T {}
#[stable(feature = "catch_unwind", since = "1.9.0")] #[stable(feature = "catch_unwind", since = "1.9.0")]
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for *const T {} impl<T: RefUnwindSafe + ?Sized> UnwindSafe for *const T {}
#[stable(feature = "catch_unwind", since = "1.9.0")] #[stable(feature = "catch_unwind", since = "1.9.0")]
@ -320,7 +320,7 @@ impl<T: fmt::Debug> fmt::Debug for AssertUnwindSafe<T> {
} }
#[unstable(feature = "futures_api", issue = "50547")] #[unstable(feature = "futures_api", issue = "50547")]
impl<'a, F: Future> Future for AssertUnwindSafe<F> { impl<F: Future> Future for AssertUnwindSafe<F> {
type Output = F::Output; type Output = F::Output;
fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> { fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {

View file

@ -457,14 +457,14 @@ impl<'a> cmp::PartialOrd for PrefixComponent<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::Ord for PrefixComponent<'a> { impl cmp::Ord for PrefixComponent<'_> {
fn cmp(&self, other: &PrefixComponent<'a>) -> cmp::Ordering { fn cmp(&self, other: &Self) -> cmp::Ordering {
cmp::Ord::cmp(&self.parsed, &other.parsed) cmp::Ord::cmp(&self.parsed, &other.parsed)
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Hash for PrefixComponent<'a> { impl Hash for PrefixComponent<'_> {
fn hash<H: Hasher>(&self, h: &mut H) { fn hash<H: Hasher>(&self, h: &mut H) {
self.parsed.hash(h); self.parsed.hash(h);
} }
@ -561,14 +561,14 @@ impl<'a> Component<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<OsStr> for Component<'a> { impl AsRef<OsStr> for Component<'_> {
fn as_ref(&self) -> &OsStr { fn as_ref(&self) -> &OsStr {
self.as_os_str() self.as_os_str()
} }
} }
#[stable(feature = "path_component_asref", since = "1.25.0")] #[stable(feature = "path_component_asref", since = "1.25.0")]
impl<'a> AsRef<Path> for Component<'a> { impl AsRef<Path> for Component<'_> {
fn as_ref(&self) -> &Path { fn as_ref(&self) -> &Path {
self.as_os_str().as_ref() self.as_os_str().as_ref()
} }
@ -630,11 +630,11 @@ pub struct Iter<'a> {
} }
#[stable(feature = "path_components_debug", since = "1.13.0")] #[stable(feature = "path_components_debug", since = "1.13.0")]
impl<'a> fmt::Debug for Components<'a> { impl fmt::Debug for Components<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct DebugHelper<'a>(&'a Path); struct DebugHelper<'a>(&'a Path);
impl<'a> fmt::Debug for DebugHelper<'a> { impl fmt::Debug for DebugHelper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list() f.debug_list()
.entries(self.0.components()) .entries(self.0.components())
@ -814,25 +814,25 @@ impl<'a> Components<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<Path> for Components<'a> { impl AsRef<Path> for Components<'_> {
fn as_ref(&self) -> &Path { fn as_ref(&self) -> &Path {
self.as_path() self.as_path()
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<OsStr> for Components<'a> { impl AsRef<OsStr> for Components<'_> {
fn as_ref(&self) -> &OsStr { fn as_ref(&self) -> &OsStr {
self.as_path().as_os_str() self.as_path().as_os_str()
} }
} }
#[stable(feature = "path_iter_debug", since = "1.13.0")] #[stable(feature = "path_iter_debug", since = "1.13.0")]
impl<'a> fmt::Debug for Iter<'a> { impl fmt::Debug for Iter<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct DebugHelper<'a>(&'a Path); struct DebugHelper<'a>(&'a Path);
impl<'a> fmt::Debug for DebugHelper<'a> { impl fmt::Debug for DebugHelper<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list() f.debug_list()
.entries(self.0.iter()) .entries(self.0.iter())
@ -867,14 +867,14 @@ impl<'a> Iter<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<Path> for Iter<'a> { impl AsRef<Path> for Iter<'_> {
fn as_ref(&self) -> &Path { fn as_ref(&self) -> &Path {
self.as_path() self.as_path()
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> AsRef<OsStr> for Iter<'a> { impl AsRef<OsStr> for Iter<'_> {
fn as_ref(&self) -> &OsStr { fn as_ref(&self) -> &OsStr {
self.as_path().as_os_str() self.as_path().as_os_str()
} }
@ -897,7 +897,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a> FusedIterator for Iter<'a> {} impl FusedIterator for Iter<'_> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Iterator for Components<'a> { impl<'a> Iterator for Components<'a> {
@ -1000,7 +1000,7 @@ impl<'a> DoubleEndedIterator for Components<'a> {
} }
#[stable(feature = "fused", since = "1.26.0")] #[stable(feature = "fused", since = "1.26.0")]
impl<'a> FusedIterator for Components<'a> {} impl FusedIterator for Components<'_> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::PartialEq for Components<'a> { impl<'a> cmp::PartialEq for Components<'a> {
@ -1010,7 +1010,7 @@ impl<'a> cmp::PartialEq for Components<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::Eq for Components<'a> {} impl cmp::Eq for Components<'_> {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::PartialOrd for Components<'a> { impl<'a> cmp::PartialOrd for Components<'a> {
@ -1020,8 +1020,8 @@ impl<'a> cmp::PartialOrd for Components<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> cmp::Ord for Components<'a> { impl cmp::Ord for Components<'_> {
fn cmp(&self, other: &Components<'a>) -> cmp::Ordering { fn cmp(&self, other: &Self) -> cmp::Ordering {
Iterator::cmp(self.clone(), other.clone()) Iterator::cmp(self.clone(), other.clone())
} }
} }
@ -1063,7 +1063,7 @@ impl<'a> Iterator for Ancestors<'a> {
} }
#[stable(feature = "path_ancestors", since = "1.28.0")] #[stable(feature = "path_ancestors", since = "1.28.0")]
impl<'a> FusedIterator for Ancestors<'a> {} impl FusedIterator for Ancestors<'_> {}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Basic types and traits // Basic types and traits
@ -1145,6 +1145,33 @@ impl PathBuf {
PathBuf { inner: OsString::new() } PathBuf { inner: OsString::new() }
} }
/// Creates a new `PathBuf` with a given capacity used to create the
/// internal [`OsString`]. See [`with_capacity`] defined on [`OsString`].
///
/// # Examples
///
/// ```
/// #![feature(path_buf_capacity)]
/// use std::path::PathBuf;
///
/// let mut path = PathBuf::with_capacity(10);
/// let capacity = path.capacity();
///
/// // This push is done without reallocating
/// path.push(r"C:\");
///
/// assert_eq!(capacity, path.capacity());
/// ```
///
/// [`with_capacity`]: ../ffi/struct.OsString.html#method.with_capacity
/// [`OsString`]: ../ffi/struct.OsString.html
#[unstable(feature = "path_buf_capacity", issue = "58234")]
pub fn with_capacity(capacity: usize) -> PathBuf {
PathBuf {
inner: OsString::with_capacity(capacity)
}
}
/// Coerces to a [`Path`] slice. /// Coerces to a [`Path`] slice.
/// ///
/// [`Path`]: struct.Path.html /// [`Path`]: struct.Path.html
@ -1373,6 +1400,60 @@ impl PathBuf {
let rw = Box::into_raw(self.inner.into_boxed_os_str()) as *mut Path; let rw = Box::into_raw(self.inner.into_boxed_os_str()) as *mut Path;
unsafe { Box::from_raw(rw) } unsafe { Box::from_raw(rw) }
} }
/// Invokes [`capacity`] on the underlying instance of [`OsString`].
///
/// [`capacity`]: ../ffi/struct.OsString.html#method.capacity
/// [`OsString`]: ../ffi/struct.OsString.html
#[unstable(feature = "path_buf_capacity", issue = "58234")]
pub fn capacity(&self) -> usize {
self.inner.capacity()
}
/// Invokes [`clear`] on the underlying instance of [`OsString`].
///
/// [`clear`]: ../ffi/struct.OsString.html#method.clear
/// [`OsString`]: ../ffi/struct.OsString.html
#[unstable(feature = "path_buf_capacity", issue = "58234")]
pub fn clear(&mut self) {
self.inner.clear()
}
/// Invokes [`reserve`] on the underlying instance of [`OsString`].
///
/// [`reserve`]: ../ffi/struct.OsString.html#method.reserve
/// [`OsString`]: ../ffi/struct.OsString.html
#[unstable(feature = "path_buf_capacity", issue = "58234")]
pub fn reserve(&mut self, additional: usize) {
self.inner.reserve(additional)
}
/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`].
///
/// [`reserve_exact`]: ../ffi/struct.OsString.html#method.reserve_exact
/// [`OsString`]: ../ffi/struct.OsString.html
#[unstable(feature = "path_buf_capacity", issue = "58234")]
pub fn reserve_exact(&mut self, additional: usize) {
self.inner.reserve_exact(additional)
}
/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`].
///
/// [`shrink_to_fit`]: ../ffi/struct.OsString.html#method.shrink_to_fit
/// [`OsString`]: ../ffi/struct.OsString.html
#[unstable(feature = "path_buf_capacity", issue = "58234")]
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit()
}
/// Invokes [`shrink_to`] on the underlying instance of [`OsString`].
///
/// [`shrink_to`]: ../ffi/struct.OsString.html#method.shrink_to
/// [`OsString`]: ../ffi/struct.OsString.html
#[unstable(feature = "path_buf_capacity", issue = "58234")]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.inner.shrink_to(min_capacity)
}
} }
#[stable(feature = "box_from_path", since = "1.17.0")] #[stable(feature = "box_from_path", since = "1.17.0")]
@ -2529,14 +2610,14 @@ pub struct Display<'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> fmt::Debug for Display<'a> { impl fmt::Debug for Display<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.path, f) fmt::Debug::fmt(&self.path, f)
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a> fmt::Display for Display<'a> { impl fmt::Display for Display<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.path.inner.display(f) self.path.inner.display(f)
} }
@ -2590,7 +2671,7 @@ impl AsRef<Path> for OsStr {
} }
#[stable(feature = "cow_os_str_as_ref_path", since = "1.8.0")] #[stable(feature = "cow_os_str_as_ref_path", since = "1.8.0")]
impl<'a> AsRef<Path> for Cow<'a, OsStr> { impl AsRef<Path> for Cow<'_, OsStr> {
fn as_ref(&self) -> &Path { fn as_ref(&self) -> &Path {
Path::new(self) Path::new(self)
} }

View file

@ -321,7 +321,7 @@ impl Drop for Select {
} }
} }
impl<'rx, T: Send> Drop for Handle<'rx, T> { impl<T: Send> Drop for Handle<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { self.remove() } unsafe { self.remove() }
} }
@ -347,7 +347,7 @@ impl fmt::Debug for Select {
} }
} }
impl<'rx, T:Send+'rx> fmt::Debug for Handle<'rx, T> { impl<T: Send> fmt::Debug for Handle<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Handle").finish() f.debug_struct("Handle").finish()
} }

View file

@ -150,9 +150,9 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized> !Send for MutexGuard<'a, T> { } impl<T: ?Sized> !Send for MutexGuard<'_, T> { }
#[stable(feature = "mutexguard", since = "1.19.0")] #[stable(feature = "mutexguard", since = "1.19.0")]
unsafe impl<'a, T: ?Sized + Sync> Sync for MutexGuard<'a, T> { } unsafe impl<T: ?Sized + Sync> Sync for MutexGuard<'_, T> { }
impl<T> Mutex<T> { impl<T> Mutex<T> {
/// Creates a new mutex in an unlocked state ready for use. /// Creates a new mutex in an unlocked state ready for use.
@ -421,7 +421,7 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'mutex, T: ?Sized> Deref for MutexGuard<'mutex, T> { impl<T: ?Sized> Deref for MutexGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &T { fn deref(&self) -> &T {
@ -430,14 +430,14 @@ impl<'mutex, T: ?Sized> Deref for MutexGuard<'mutex, T> {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'mutex, T: ?Sized> DerefMut for MutexGuard<'mutex, T> { impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut T { fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.__lock.data.get() } unsafe { &mut *self.__lock.data.get() }
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { impl<T: ?Sized> Drop for MutexGuard<'_, T> {
#[inline] #[inline]
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
@ -448,14 +448,14 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
} }
#[stable(feature = "std_debug", since = "1.16.0")] #[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> { impl<T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&**self, f) fmt::Debug::fmt(&**self, f)
} }
} }
#[stable(feature = "std_guard_impls", since = "1.20.0")] #[stable(feature = "std_guard_impls", since = "1.20.0")]
impl<'a, T: ?Sized + fmt::Display> fmt::Display for MutexGuard<'a, T> { impl<T: ?Sized + fmt::Display> fmt::Display for MutexGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f) (**self).fmt(f)
} }

Some files were not shown because too many files have changed in this diff Show more