Skip to content

Commit 5670d04

Browse files
committed
Auto merge of #64535 - Centril:rollup-wiyxagi, r=Centril
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
2 parents 7ac21e7 + a1fd9ba commit 5670d04

File tree

23 files changed

+627
-458
lines changed

23 files changed

+627
-458
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2182,9 +2182,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
21822182

21832183
[[package]]
21842184
name = "openssl-src"
2185-
version = "111.3.0+1.1.1c"
2185+
version = "111.6.0+1.1.1d"
21862186
source = "registry+https://github.com/rust-lang/crates.io-index"
2187-
checksum = "53ed5f31d294bdf5f7a4ba0a206c2754b0f60e9a63b7e3076babc5317873c797"
2187+
checksum = "b9c2da1de8a7a3f860919c01540b03a6db16de042405a8a07a5e9d0b4b825d9c"
21882188
dependencies = [
21892189
"cc",
21902190
]

src/libcore/option.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<T> Option<T> {
295295
/// [`Pin`]: ../pin/struct.Pin.html
296296
#[inline]
297297
#[stable(feature = "pin", since = "1.33.0")]
298-
pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> {
298+
pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> {
299299
unsafe {
300300
Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x))
301301
}
@@ -306,7 +306,7 @@ impl<T> Option<T> {
306306
/// [`Pin`]: ../pin/struct.Pin.html
307307
#[inline]
308308
#[stable(feature = "pin", since = "1.33.0")]
309-
pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> {
309+
pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> {
310310
unsafe {
311311
Pin::get_unchecked_mut(self).as_mut().map(|x| Pin::new_unchecked(x))
312312
}

src/libcore/pin.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
//! # type Field = i32;
234234
//! # struct Struct { field: Field }
235235
//! impl Struct {
236-
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> &'a mut Field {
236+
//! fn pin_get_field(self: Pin<&mut Self>) -> &mut Field {
237237
//! // This is okay because `field` is never considered pinned.
238238
//! unsafe { &mut self.get_unchecked_mut().field }
239239
//! }
@@ -257,7 +257,7 @@
257257
//! # type Field = i32;
258258
//! # struct Struct { field: Field }
259259
//! impl Struct {
260-
//! fn pin_get_field<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Field> {
260+
//! fn pin_get_field(self: Pin<&mut Self>) -> Pin<&mut Field> {
261261
//! // This is okay because `field` is pinned when `self` is.
262262
//! unsafe { self.map_unchecked_mut(|s| &mut s.field) }
263263
//! }
@@ -549,7 +549,7 @@ impl<P: Deref> Pin<P> {
549549
/// ruled out by the contract of `Pin::new_unchecked`.
550550
#[stable(feature = "pin", since = "1.33.0")]
551551
#[inline(always)]
552-
pub fn as_ref(self: &Pin<P>) -> Pin<&P::Target> {
552+
pub fn as_ref(&self) -> Pin<&P::Target> {
553553
unsafe { Pin::new_unchecked(&*self.pointer) }
554554
}
555555

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

@@ -596,7 +596,7 @@ impl<P: DerefMut> Pin<P> {
596596
/// run before being overwritten, so no pinning guarantee is violated.
597597
#[stable(feature = "pin", since = "1.33.0")]
598598
#[inline(always)]
599-
pub fn set(self: &mut Pin<P>, value: P::Target)
599+
pub fn set(&mut self, value: P::Target)
600600
where
601601
P::Target: Sized,
602602
{
@@ -621,7 +621,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
621621
///
622622
/// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning
623623
#[stable(feature = "pin", since = "1.33.0")]
624-
pub unsafe fn map_unchecked<U, F>(self: Pin<&'a T>, func: F) -> Pin<&'a U> where
624+
pub unsafe fn map_unchecked<U, F>(self, func: F) -> Pin<&'a U> where
625625
F: FnOnce(&T) -> &U,
626626
{
627627
let pointer = &*self.pointer;
@@ -648,7 +648,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
648648
/// ["pinning projections"]: ../../std/pin/index.html#projections-and-structural-pinning
649649
#[stable(feature = "pin", since = "1.33.0")]
650650
#[inline(always)]
651-
pub fn get_ref(self: Pin<&'a T>) -> &'a T {
651+
pub fn get_ref(self) -> &'a T {
652652
self.pointer
653653
}
654654
}
@@ -657,7 +657,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
657657
/// Converts this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
658658
#[stable(feature = "pin", since = "1.33.0")]
659659
#[inline(always)]
660-
pub fn into_ref(self: Pin<&'a mut T>) -> Pin<&'a T> {
660+
pub fn into_ref(self) -> Pin<&'a T> {
661661
Pin { pointer: self.pointer }
662662
}
663663

@@ -672,7 +672,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
672672
/// with the same lifetime as the original `Pin`.
673673
#[stable(feature = "pin", since = "1.33.0")]
674674
#[inline(always)]
675-
pub fn get_mut(self: Pin<&'a mut T>) -> &'a mut T
675+
pub fn get_mut(self) -> &'a mut T
676676
where T: Unpin,
677677
{
678678
self.pointer
@@ -690,7 +690,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
690690
/// instead.
691691
#[stable(feature = "pin", since = "1.33.0")]
692692
#[inline(always)]
693-
pub unsafe fn get_unchecked_mut(self: Pin<&'a mut T>) -> &'a mut T {
693+
pub unsafe fn get_unchecked_mut(self) -> &'a mut T {
694694
self.pointer
695695
}
696696

@@ -710,7 +710,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
710710
///
711711
/// [`pin` module]: ../../std/pin/index.html#projections-and-structural-pinning
712712
#[stable(feature = "pin", since = "1.33.0")]
713-
pub unsafe fn map_unchecked_mut<U, F>(self: Pin<&'a mut T>, func: F) -> Pin<&'a mut U> where
713+
pub unsafe fn map_unchecked_mut<U, F>(self, func: F) -> Pin<&'a mut U> where
714714
F: FnOnce(&mut T) -> &mut U,
715715
{
716716
let pointer = Pin::get_unchecked_mut(self);

src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs

+31-22
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,28 @@ impl NiceRegionError<'me, 'tcx> {
192192
vid, sub_placeholder, sup_placeholder, trait_def_id, expected_substs, actual_substs
193193
);
194194

195-
let mut err = self.tcx().sess.struct_span_err(
196-
cause.span(self.tcx()),
197-
&format!(
198-
"implementation of `{}` is not general enough",
199-
self.tcx().def_path_str(trait_def_id),
200-
),
195+
let span = cause.span(self.tcx());
196+
let msg = format!(
197+
"implementation of `{}` is not general enough",
198+
self.tcx().def_path_str(trait_def_id),
199+
);
200+
let mut err = self.tcx().sess.struct_span_err(span, &msg);
201+
err.span_label(
202+
self.tcx().def_span(trait_def_id),
203+
format!("trait `{}` defined here", self.tcx().def_path_str(trait_def_id)),
201204
);
202205

203-
match cause.code {
204-
ObligationCauseCode::ItemObligation(def_id) => {
205-
err.note(&format!(
206-
"Due to a where-clause on `{}`,",
207-
self.tcx().def_path_str(def_id),
208-
));
209-
}
210-
_ => (),
211-
}
206+
let leading_ellipsis = if let ObligationCauseCode::ItemObligation(def_id) = cause.code {
207+
err.span_label(span, "doesn't satisfy where-clause");
208+
err.span_label(
209+
self.tcx().def_span(def_id),
210+
&format!("due to a where-clause on `{}`...", self.tcx().def_path_str(def_id)),
211+
);
212+
true
213+
} else {
214+
err.span_label(span, &msg);
215+
false
216+
};
212217

213218
let expected_trait_ref = self.infcx.resolve_vars_if_possible(&ty::TraitRef {
214219
def_id: trait_def_id,
@@ -295,6 +300,7 @@ impl NiceRegionError<'me, 'tcx> {
295300
expected_has_vid,
296301
actual_has_vid,
297302
any_self_ty_has_vid,
303+
leading_ellipsis,
298304
);
299305

300306
err
@@ -318,6 +324,7 @@ impl NiceRegionError<'me, 'tcx> {
318324
expected_has_vid: Option<usize>,
319325
actual_has_vid: Option<usize>,
320326
any_self_ty_has_vid: bool,
327+
leading_ellipsis: bool,
321328
) {
322329
// HACK(eddyb) maybe move this in a more central location.
323330
#[derive(Copy, Clone)]
@@ -392,13 +399,15 @@ impl NiceRegionError<'me, 'tcx> {
392399

393400
let mut note = if passive_voice {
394401
format!(
395-
"`{}` would have to be implemented for the type `{}`",
402+
"{}`{}` would have to be implemented for the type `{}`",
403+
if leading_ellipsis { "..." } else { "" },
396404
expected_trait_ref,
397405
expected_trait_ref.map(|tr| tr.self_ty()),
398406
)
399407
} else {
400408
format!(
401-
"`{}` must implement `{}`",
409+
"{}`{}` must implement `{}`",
410+
if leading_ellipsis { "..." } else { "" },
402411
expected_trait_ref.map(|tr| tr.self_ty()),
403412
expected_trait_ref,
404413
)
@@ -407,20 +416,20 @@ impl NiceRegionError<'me, 'tcx> {
407416
match (has_sub, has_sup) {
408417
(Some(n1), Some(n2)) => {
409418
let _ = write!(note,
410-
", for any two lifetimes `'{}` and `'{}`",
419+
", for any two lifetimes `'{}` and `'{}`...",
411420
std::cmp::min(n1, n2),
412421
std::cmp::max(n1, n2),
413422
);
414423
}
415424
(Some(n), _) | (_, Some(n)) => {
416425
let _ = write!(note,
417-
", for any lifetime `'{}`",
426+
", for any lifetime `'{}`...",
418427
n,
419428
);
420429
}
421430
(None, None) => if let Some(n) = expected_has_vid {
422431
let _ = write!(note,
423-
", for some specific lifetime `'{}`",
432+
", for some specific lifetime `'{}`...",
424433
n,
425434
);
426435
},
@@ -439,13 +448,13 @@ impl NiceRegionError<'me, 'tcx> {
439448

440449
let mut note = if passive_voice {
441450
format!(
442-
"but `{}` is actually implemented for the type `{}`",
451+
"...but `{}` is actually implemented for the type `{}`",
443452
actual_trait_ref,
444453
actual_trait_ref.map(|tr| tr.self_ty()),
445454
)
446455
} else {
447456
format!(
448-
"but `{}` actually implements `{}`",
457+
"...but `{}` actually implements `{}`",
449458
actual_trait_ref.map(|tr| tr.self_ty()),
450459
actual_trait_ref,
451460
)

src/librustc_data_structures/indexed_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ macro_rules! newtype_index {
149149

150150
#[inline]
151151
$v const unsafe fn from_u32_unchecked(value: u32) -> Self {
152-
unsafe { $type { private: value } }
152+
$type { private: value }
153153
}
154154

155155
/// Extracts the value of this index as an integer.

src/librustc_data_structures/obligation_forest/graphviz.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ impl<'a, O: ForestObligation + 'a> dot::GraphWalk<'a> for &'a ObligationForest<O
7474
.flat_map(|i| {
7575
let node = &self.nodes[i];
7676

77-
node.parent.iter().map(|p| p.get())
78-
.chain(node.dependents.iter().map(|p| p.get()))
79-
.map(move |p| (p, i))
77+
node.parent.iter()
78+
.chain(node.dependents.iter())
79+
.map(move |p| (p.index(), i))
8080
})
8181
.collect()
8282
}

0 commit comments

Comments
 (0)