Skip to content

Commit

Permalink
Auto merge of #64535 - Centril:rollup-wiyxagi, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - #64085 (Tweak unsatisfied HRTB errors)
 - #64380 (Update bundled OpenSSL to 1.1.1d)
 - #64416 (Various refactorings to clean up nll diagnostics)
 - #64500 (Various `ObligationForest` improvements)
 - #64530 (Elide lifetimes in `Pin<&(mut) Self>`)
 - #64531 (Use shorthand syntax in the self parameter of methods of Pin)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Sep 17, 2019
2 parents 7ac21e7 + a1fd9ba commit 5670d04
Show file tree
Hide file tree
Showing 23 changed files with 627 additions and 458 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2182,9 +2182,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"

[[package]]
name = "openssl-src"
version = "111.3.0+1.1.1c"
version = "111.6.0+1.1.1d"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53ed5f31d294bdf5f7a4ba0a206c2754b0f60e9a63b7e3076babc5317873c797"
checksum = "b9c2da1de8a7a3f860919c01540b03a6db16de042405a8a07a5e9d0b4b825d9c"
dependencies = [
"cc",
]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<T> Option<T> {
/// [`Pin`]: ../pin/struct.Pin.html
#[inline]
#[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> {
pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> {
unsafe {
Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x))
}
Expand All @@ -306,7 +306,7 @@ impl<T> Option<T> {
/// [`Pin`]: ../pin/struct.Pin.html
#[inline]
#[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> {
pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> {
unsafe {
Pin::get_unchecked_mut(self).as_mut().map(|x| Pin::new_unchecked(x))
}
Expand Down
22 changes: 11 additions & 11 deletions src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
//! # type Field = i32;
//! # struct Struct { field: Field }
//! impl Struct {
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> &'a mut Field {
//! fn pin_get_field(self: Pin<&mut Self>) -> &mut Field {
//! // This is okay because `field` is never considered pinned.
//! unsafe { &mut self.get_unchecked_mut().field }
//! }
Expand All @@ -257,7 +257,7 @@
//! # type Field = i32;
//! # struct Struct { field: Field }
//! impl Struct {
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Field> {
//! fn pin_get_field(self: Pin<&mut Self>) -> Pin<&mut Field> {
//! // This is okay because `field` is pinned when `self` is.
//! unsafe { self.map_unchecked_mut(|s| &mut s.field) }
//! }
Expand Down Expand Up @@ -549,7 +549,7 @@ impl<P: Deref> Pin<P> {
/// ruled out by the contract of `Pin::new_unchecked`.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn as_ref(self: &Pin<P>) -> Pin<&P::Target> {
pub fn as_ref(&self) -> Pin<&P::Target> {
unsafe { Pin::new_unchecked(&*self.pointer) }
}

Expand Down Expand Up @@ -586,7 +586,7 @@ impl<P: DerefMut> Pin<P> {
/// ruled out by the contract of `Pin::new_unchecked`.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn as_mut(self: &mut Pin<P>) -> Pin<&mut P::Target> {
pub fn as_mut(&mut self) -> Pin<&mut P::Target> {
unsafe { Pin::new_unchecked(&mut *self.pointer) }
}

Expand All @@ -596,7 +596,7 @@ impl<P: DerefMut> Pin<P> {
/// run before being overwritten, so no pinning guarantee is violated.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn set(self: &mut Pin<P>, value: P::Target)
pub fn set(&mut self, value: P::Target)
where
P::Target: Sized,
{
Expand All @@ -621,7 +621,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
///
/// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning
#[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked<U, F>(self: Pin<&'a T>, func: F) -> Pin<&'a U> where
pub unsafe fn map_unchecked<U, F>(self, func: F) -> Pin<&'a U> where
F: FnOnce(&T) -> &U,
{
let pointer = &*self.pointer;
Expand All @@ -648,7 +648,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
/// ["pinning projections"]: ../../std/pin/index.html#projections-and-structural-pinning
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn get_ref(self: Pin<&'a T>) -> &'a T {
pub fn get_ref(self) -> &'a T {
self.pointer
}
}
Expand All @@ -657,7 +657,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn into_ref(self: Pin<&'a mut T>) -> Pin<&'a T> {
pub fn into_ref(self) -> Pin<&'a T> {
Pin { pointer: self.pointer }
}

Expand All @@ -672,7 +672,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// with the same lifetime as the original `Pin`.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub fn get_mut(self: Pin<&'a mut T>) -> &'a mut T
pub fn get_mut(self) -> &'a mut T
where T: Unpin,
{
self.pointer
Expand All @@ -690,7 +690,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
/// instead.
#[stable(feature = "pin", since = "1.33.0")]
#[inline(always)]
pub unsafe fn get_unchecked_mut(self: Pin<&'a mut T>) -> &'a mut T {
pub unsafe fn get_unchecked_mut(self) -> &'a mut T {
self.pointer
}

Expand All @@ -710,7 +710,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
///
/// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning
#[stable(feature = "pin", since = "1.33.0")]
pub unsafe fn map_unchecked_mut<U, F>(self: Pin<&'a mut T>, func: F) -> Pin<&'a mut U> where
pub unsafe fn map_unchecked_mut<U, F>(self, func: F) -> Pin<&'a mut U> where
F: FnOnce(&mut T) -> &mut U,
{
let pointer = Pin::get_unchecked_mut(self);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,28 @@ impl NiceRegionError<'me, 'tcx> {
vid, sub_placeholder, sup_placeholder, trait_def_id, expected_substs, actual_substs
);

let mut err = self.tcx().sess.struct_span_err(
cause.span(self.tcx()),
&format!(
"implementation of `{}` is not general enough",
self.tcx().def_path_str(trait_def_id),
),
let span = cause.span(self.tcx());
let msg = format!(
"implementation of `{}` is not general enough",
self.tcx().def_path_str(trait_def_id),
);
let mut err = self.tcx().sess.struct_span_err(span, &msg);
err.span_label(
self.tcx().def_span(trait_def_id),
format!("trait `{}` defined here", self.tcx().def_path_str(trait_def_id)),
);

match cause.code {
ObligationCauseCode::ItemObligation(def_id) => {
err.note(&format!(
"Due to a where-clause on `{}`,",
self.tcx().def_path_str(def_id),
));
}
_ => (),
}
let leading_ellipsis = if let ObligationCauseCode::ItemObligation(def_id) = cause.code {
err.span_label(span, "doesn't satisfy where-clause");
err.span_label(
self.tcx().def_span(def_id),
&format!("due to a where-clause on `{}`...", self.tcx().def_path_str(def_id)),
);
true
} else {
err.span_label(span, &msg);
false
};

let expected_trait_ref = self.infcx.resolve_vars_if_possible(&ty::TraitRef {
def_id: trait_def_id,
Expand Down Expand Up @@ -295,6 +300,7 @@ impl NiceRegionError<'me, 'tcx> {
expected_has_vid,
actual_has_vid,
any_self_ty_has_vid,
leading_ellipsis,
);

err
Expand All @@ -318,6 +324,7 @@ impl NiceRegionError<'me, 'tcx> {
expected_has_vid: Option<usize>,
actual_has_vid: Option<usize>,
any_self_ty_has_vid: bool,
leading_ellipsis: bool,
) {
// HACK(eddyb) maybe move this in a more central location.
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -392,13 +399,15 @@ impl NiceRegionError<'me, 'tcx> {

let mut note = if passive_voice {
format!(
"`{}` would have to be implemented for the type `{}`",
"{}`{}` would have to be implemented for the type `{}`",
if leading_ellipsis { "..." } else { "" },
expected_trait_ref,
expected_trait_ref.map(|tr| tr.self_ty()),
)
} else {
format!(
"`{}` must implement `{}`",
"{}`{}` must implement `{}`",
if leading_ellipsis { "..." } else { "" },
expected_trait_ref.map(|tr| tr.self_ty()),
expected_trait_ref,
)
Expand All @@ -407,20 +416,20 @@ impl NiceRegionError<'me, 'tcx> {
match (has_sub, has_sup) {
(Some(n1), Some(n2)) => {
let _ = write!(note,
", for any two lifetimes `'{}` and `'{}`",
", for any two lifetimes `'{}` and `'{}`...",
std::cmp::min(n1, n2),
std::cmp::max(n1, n2),
);
}
(Some(n), _) | (_, Some(n)) => {
let _ = write!(note,
", for any lifetime `'{}`",
", for any lifetime `'{}`...",
n,
);
}
(None, None) => if let Some(n) = expected_has_vid {
let _ = write!(note,
", for some specific lifetime `'{}`",
", for some specific lifetime `'{}`...",
n,
);
},
Expand All @@ -439,13 +448,13 @@ impl NiceRegionError<'me, 'tcx> {

let mut note = if passive_voice {
format!(
"but `{}` is actually implemented for the type `{}`",
"...but `{}` is actually implemented for the type `{}`",
actual_trait_ref,
actual_trait_ref.map(|tr| tr.self_ty()),
)
} else {
format!(
"but `{}` actually implements `{}`",
"...but `{}` actually implements `{}`",
actual_trait_ref.map(|tr| tr.self_ty()),
actual_trait_ref,
)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/indexed_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ macro_rules! newtype_index {

#[inline]
$v const unsafe fn from_u32_unchecked(value: u32) -> Self {
unsafe { $type { private: value } }
$type { private: value }
}

/// Extracts the value of this index as an integer.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_data_structures/obligation_forest/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impl<'a, O: ForestObligation + 'a> dot::GraphWalk<'a> for &'a ObligationForest<O
.flat_map(|i| {
let node = &self.nodes[i];

node.parent.iter().map(|p| p.get())
.chain(node.dependents.iter().map(|p| p.get()))
.map(move |p| (p, i))
node.parent.iter()
.chain(node.dependents.iter())
.map(move |p| (p.index(), i))
})
.collect()
}
Expand Down
Loading

0 comments on commit 5670d04

Please sign in to comment.