Skip to content

Commit 1df512f

Browse files
committed
Auto merge of #63214 - Centril:rollup-hdb7dnx, r=Centril
Rollup of 7 pull requests Successful merges: - #62663 (More questionmarks in doctests) - #62969 (Changing the structure of `mir::interpret::InterpError`) - #63153 (Remove redundant method with const variable resolution) - #63189 (Doc improvements) - #63198 (Allow trailing comma in macro 2.0 declarations.) - #63202 (Fix ICE in #63135) - #63203 (Make is_mutable use PlaceRef instead of it's fields) Failed merges: r? @ghost
2 parents fc3ef96 + 97098f4 commit 1df512f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+632
-502
lines changed

src/libcore/array.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ use crate::slice::{Iter, IterMut};
2424
/// layout in memory of a fixed size array (for example, for unsafe
2525
/// initialization).
2626
///
27-
/// Note that the traits AsRef and AsMut provide similar methods for types that
27+
/// Note that the traits [`AsRef`] and [`AsMut`] provide similar methods for types that
2828
/// may not be fixed-size arrays. Implementors should prefer those traits
2929
/// instead.
30+
///
31+
/// [`AsRef`]: ../convert/trait.AsRef.html
32+
/// [`AsMut`]: ../convert/trait.AsMut.html
3033
#[unstable(feature = "fixed_size_array", issue = "27778")]
3134
pub unsafe trait FixedSizeArray<T> {
3235
/// Converts the array to immutable slice

src/libcore/convert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub trait TryInto<T>: Sized {
427427
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
428428
/// is implemented and cannot fail -- the associated `Error` type for
429429
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
430-
/// When the [`!`] type is stablized [`Infallible`] and [`!`] will be
430+
/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be
431431
/// equivalent.
432432
///
433433
/// `TryFrom<T>` can be implemented as follows:

src/libcore/future/future.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ use crate::task::{Context, Poll};
1717
/// final value. This method does not block if the value is not ready. Instead,
1818
/// the current task is scheduled to be woken up when it's possible to make
1919
/// further progress by `poll`ing again. The `context` passed to the `poll`
20-
/// method can provide a `Waker`, which is a handle for waking up the current
20+
/// method can provide a [`Waker`], which is a handle for waking up the current
2121
/// task.
2222
///
2323
/// When using a future, you generally won't call `poll` directly, but instead
2424
/// `.await` the value.
25+
///
26+
/// [`Waker`]: ../task/struct.Waker.html
2527
#[doc(spotlight)]
2628
#[must_use = "futures do nothing unless you `.await` or poll them"]
2729
#[stable(feature = "futures_api", since = "1.36.0")]

src/libcore/macros.rs

+27-16
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,15 @@ macro_rules! r#try {
353353
/// use std::fmt::Write as FmtWrite;
354354
/// use std::io::Write as IoWrite;
355355
///
356-
/// let mut s = String::new();
357-
/// let mut v = Vec::new();
358-
/// write!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
359-
/// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
360-
/// assert_eq!(v, b"s = \"abc 123\"");
356+
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
357+
/// let mut s = String::new();
358+
/// let mut v = Vec::new();
359+
///
360+
/// write!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
361+
/// write!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
362+
/// assert_eq!(v, b"s = \"abc 123\"");
363+
/// Ok(())
364+
/// }
361365
/// ```
362366
///
363367
/// Note: This macro can be used in `no_std` setups as well.
@@ -399,14 +403,17 @@ macro_rules! write {
399403
/// # Examples
400404
///
401405
/// ```
402-
/// use std::io::Write;
406+
/// use std::io::{Write, Result};
403407
///
404-
/// let mut w = Vec::new();
405-
/// writeln!(&mut w).unwrap();
406-
/// writeln!(&mut w, "test").unwrap();
407-
/// writeln!(&mut w, "formatted {}", "arguments").unwrap();
408+
/// fn main() -> Result<()> {
409+
/// let mut w = Vec::new();
410+
/// writeln!(&mut w)?;
411+
/// writeln!(&mut w, "test")?;
412+
/// writeln!(&mut w, "formatted {}", "arguments")?;
408413
///
409-
/// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
414+
/// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
415+
/// Ok(())
416+
/// }
410417
/// ```
411418
///
412419
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
@@ -417,11 +424,15 @@ macro_rules! write {
417424
/// use std::fmt::Write as FmtWrite;
418425
/// use std::io::Write as IoWrite;
419426
///
420-
/// let mut s = String::new();
421-
/// let mut v = Vec::new();
422-
/// writeln!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
423-
/// writeln!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
424-
/// assert_eq!(v, b"s = \"abc 123\\n\"\n");
427+
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
428+
/// let mut s = String::new();
429+
/// let mut v = Vec::new();
430+
///
431+
/// writeln!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
432+
/// writeln!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
433+
/// assert_eq!(v, b"s = \"abc 123\\n\"\n");
434+
/// Ok(())
435+
/// }
425436
/// ```
426437
#[macro_export]
427438
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/mem/maybe_uninit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ impl<T> MaybeUninit<T> {
434434
/// Reads the value from the `MaybeUninit<T>` container. The resulting `T` is subject
435435
/// to the usual drop handling.
436436
///
437-
/// Whenever possible, it is preferrable to use [`assume_init`] instead, which
437+
/// Whenever possible, it is preferable to use [`assume_init`] instead, which
438438
/// prevents duplicating the content of the `MaybeUninit<T>`.
439439
///
440440
/// # Safety

src/libcore/ptr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ impl<T: ?Sized> *const T {
16111611
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
16121612
/// used with the `add` method.
16131613
///
1614-
/// There are no guarantees whatsover that offsetting the pointer will not overflow or go
1614+
/// There are no guarantees whatsoever that offsetting the pointer will not overflow or go
16151615
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that
16161616
/// the returned offset is correct in all terms other than alignment.
16171617
///
@@ -2412,7 +2412,7 @@ impl<T: ?Sized> *mut T {
24122412
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
24132413
/// used with the `add` method.
24142414
///
2415-
/// There are no guarantees whatsover that offsetting the pointer will not overflow or go
2415+
/// There are no guarantees whatsoever that offsetting the pointer will not overflow or go
24162416
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that
24172417
/// the returned offset is correct in all terms other than alignment.
24182418
///

src/librustc/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
693693
const_var: &'tcx ty::Const<'tcx>
694694
) -> &'tcx ty::Const<'tcx> {
695695
let infcx = self.infcx.expect("encountered const-var without infcx");
696-
let bound_to = infcx.resolve_const_var(const_var);
696+
let bound_to = infcx.shallow_resolve(const_var);
697697
if bound_to != const_var {
698698
self.fold_const(bound_to)
699699
} else {

src/librustc/infer/mod.rs

+4-23
Original file line numberDiff line numberDiff line change
@@ -1351,23 +1351,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13511351
}
13521352
}
13531353

1354-
pub fn resolve_const_var(
1355-
&self,
1356-
ct: &'tcx ty::Const<'tcx>
1357-
) -> &'tcx ty::Const<'tcx> {
1358-
if let ty::Const { val: ConstValue::Infer(InferConst::Var(v)), .. } = ct {
1359-
self.const_unification_table
1360-
.borrow_mut()
1361-
.probe_value(*v)
1362-
.val
1363-
.known()
1364-
.map(|c| self.resolve_const_var(c))
1365-
.unwrap_or(ct)
1366-
} else {
1367-
ct
1368-
}
1369-
}
1370-
13711354
pub fn fully_resolve<T: TypeFoldable<'tcx>>(&self, value: &T) -> FixupResult<'tcx, T> {
13721355
/*!
13731356
* Attempts to resolve all type/region/const variables in
@@ -1586,7 +1569,7 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
15861569
// it can be resolved to an int/float variable, which
15871570
// can then be recursively resolved, hence the
15881571
// recursion. Note though that we prevent type
1589-
// variables from unifyxing to other type variables
1572+
// variables from unifying to other type variables
15901573
// directly (though they may be embedded
15911574
// structurally), and we prevent cycles in any case,
15921575
// so this recursion should always be of very limited
@@ -1626,17 +1609,15 @@ impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
16261609
}
16271610

16281611
fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
1629-
match ct {
1630-
ty::Const { val: ConstValue::Infer(InferConst::Var(vid)), .. } => {
1612+
if let ty::Const { val: ConstValue::Infer(InferConst::Var(vid)), .. } = ct {
16311613
self.infcx.const_unification_table
16321614
.borrow_mut()
16331615
.probe_value(*vid)
16341616
.val
16351617
.known()
1636-
.map(|c| self.fold_const(c))
16371618
.unwrap_or(ct)
1638-
}
1639-
_ => ct,
1619+
} else {
1620+
ct
16401621
}
16411622
}
16421623
}

src/librustc/mir/interpret/allocation.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,17 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
235235
{
236236
assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes());
237237
let offset = ptr.offset.bytes() as usize;
238-
match self.bytes[offset..].iter().position(|&c| c == 0) {
238+
Ok(match self.bytes[offset..].iter().position(|&c| c == 0) {
239239
Some(size) => {
240240
let size_with_null = Size::from_bytes((size + 1) as u64);
241241
// Go through `get_bytes` for checks and AllocationExtra hooks.
242242
// We read the null, so we include it in the request, but we want it removed
243243
// from the result, so we do subslicing.
244-
Ok(&self.get_bytes(cx, ptr, size_with_null)?[..size])
244+
&self.get_bytes(cx, ptr, size_with_null)?[..size]
245245
}
246246
// This includes the case where `offset` is out-of-bounds to begin with.
247-
None => err!(UnterminatedCString(ptr.erase_tag())),
248-
}
247+
None => throw_unsup!(UnterminatedCString(ptr.erase_tag())),
248+
})
249249
}
250250

251251
/// Validates that `ptr.offset` and `ptr.offset + size` do not point to the middle of a
@@ -446,7 +446,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
446446
if self.relocations(cx, ptr, size).is_empty() {
447447
Ok(())
448448
} else {
449-
err!(ReadPointerAsBytes)
449+
throw_unsup!(ReadPointerAsBytes)
450450
}
451451
}
452452

@@ -516,7 +516,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
516516
self.undef_mask.is_range_defined(
517517
ptr.offset,
518518
ptr.offset + size,
519-
).or_else(|idx| err!(ReadUndefBytes(idx)))
519+
).or_else(|idx| throw_unsup!(ReadUndefBytes(idx)))
520520
}
521521

522522
pub fn mark_definedness(

0 commit comments

Comments
 (0)