Skip to content

Commit

Permalink
Auto merge of #63214 - Centril:rollup-hdb7dnx, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 2, 2019
2 parents fc3ef96 + 97098f4 commit 1df512f
Show file tree
Hide file tree
Showing 47 changed files with 632 additions and 502 deletions.
5 changes: 4 additions & 1 deletion src/libcore/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ use crate::slice::{Iter, IterMut};
/// layout in memory of a fixed size array (for example, for unsafe
/// initialization).
///
/// Note that the traits AsRef and AsMut provide similar methods for types that
/// Note that the traits [`AsRef`] and [`AsMut`] provide similar methods for types that
/// may not be fixed-size arrays. Implementors should prefer those traits
/// instead.
///
/// [`AsRef`]: ../convert/trait.AsRef.html
/// [`AsMut`]: ../convert/trait.AsMut.html
#[unstable(feature = "fixed_size_array", issue = "27778")]
pub unsafe trait FixedSizeArray<T> {
/// Converts the array to immutable slice
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub trait TryInto<T>: Sized {
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
/// is implemented and cannot fail -- the associated `Error` type for
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
/// When the [`!`] type is stablized [`Infallible`] and [`!`] will be
/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be
/// equivalent.
///
/// `TryFrom<T>` can be implemented as follows:
Expand Down
4 changes: 3 additions & 1 deletion src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ use crate::task::{Context, Poll};
/// final value. This method does not block if the value is not ready. Instead,
/// the current task is scheduled to be woken up when it's possible to make
/// further progress by `poll`ing again. The `context` passed to the `poll`
/// method can provide a `Waker`, which is a handle for waking up the current
/// method can provide a [`Waker`], which is a handle for waking up the current
/// task.
///
/// When using a future, you generally won't call `poll` directly, but instead
/// `.await` the value.
///
/// [`Waker`]: ../task/struct.Waker.html
#[doc(spotlight)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
#[stable(feature = "futures_api", since = "1.36.0")]
Expand Down
43 changes: 27 additions & 16 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,15 @@ macro_rules! r#try {
/// use std::fmt::Write as FmtWrite;
/// use std::io::Write as IoWrite;
///
/// let mut s = String::new();
/// let mut v = Vec::new();
/// write!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
/// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
/// assert_eq!(v, b"s = \"abc 123\"");
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut s = String::new();
/// let mut v = Vec::new();
///
/// write!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
/// write!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
/// assert_eq!(v, b"s = \"abc 123\"");
/// Ok(())
/// }
/// ```
///
/// Note: This macro can be used in `no_std` setups as well.
Expand Down Expand Up @@ -399,14 +403,17 @@ macro_rules! write {
/// # Examples
///
/// ```
/// use std::io::Write;
/// use std::io::{Write, Result};
///
/// let mut w = Vec::new();
/// writeln!(&mut w).unwrap();
/// writeln!(&mut w, "test").unwrap();
/// writeln!(&mut w, "formatted {}", "arguments").unwrap();
/// fn main() -> Result<()> {
/// let mut w = Vec::new();
/// writeln!(&mut w)?;
/// writeln!(&mut w, "test")?;
/// writeln!(&mut w, "formatted {}", "arguments")?;
///
/// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
/// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
/// Ok(())
/// }
/// ```
///
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
Expand All @@ -417,11 +424,15 @@ macro_rules! write {
/// use std::fmt::Write as FmtWrite;
/// use std::io::Write as IoWrite;
///
/// let mut s = String::new();
/// let mut v = Vec::new();
/// writeln!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
/// writeln!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
/// assert_eq!(v, b"s = \"abc 123\\n\"\n");
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut s = String::new();
/// let mut v = Vec::new();
///
/// writeln!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
/// writeln!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
/// assert_eq!(v, b"s = \"abc 123\\n\"\n");
/// Ok(())
/// }
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ impl<T> MaybeUninit<T> {
/// Reads the value from the `MaybeUninit<T>` container. The resulting `T` is subject
/// to the usual drop handling.
///
/// Whenever possible, it is preferrable to use [`assume_init`] instead, which
/// Whenever possible, it is preferable to use [`assume_init`] instead, which
/// prevents duplicating the content of the `MaybeUninit<T>`.
///
/// # Safety
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ impl<T: ?Sized> *const T {
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
/// used with the `add` method.
///
/// There are no guarantees whatsover that offsetting the pointer will not overflow or go
/// There are no guarantees whatsoever that offsetting the pointer will not overflow or go
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that
/// the returned offset is correct in all terms other than alignment.
///
Expand Down Expand Up @@ -2412,7 +2412,7 @@ impl<T: ?Sized> *mut T {
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
/// used with the `add` method.
///
/// There are no guarantees whatsover that offsetting the pointer will not overflow or go
/// There are no guarantees whatsoever that offsetting the pointer will not overflow or go
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that
/// the returned offset is correct in all terms other than alignment.
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
const_var: &'tcx ty::Const<'tcx>
) -> &'tcx ty::Const<'tcx> {
let infcx = self.infcx.expect("encountered const-var without infcx");
let bound_to = infcx.resolve_const_var(const_var);
let bound_to = infcx.shallow_resolve(const_var);
if bound_to != const_var {
self.fold_const(bound_to)
} else {
Expand Down
27 changes: 4 additions & 23 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,23 +1351,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
}

pub fn resolve_const_var(
&self,
ct: &'tcx ty::Const<'tcx>
) -> &'tcx ty::Const<'tcx> {
if let ty::Const { val: ConstValue::Infer(InferConst::Var(v)), .. } = ct {
self.const_unification_table
.borrow_mut()
.probe_value(*v)
.val
.known()
.map(|c| self.resolve_const_var(c))
.unwrap_or(ct)
} else {
ct
}
}

pub fn fully_resolve<T: TypeFoldable<'tcx>>(&self, value: &T) -> FixupResult<'tcx, T> {
/*!
* Attempts to resolve all type/region/const variables in
Expand Down Expand Up @@ -1586,7 +1569,7 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
// it can be resolved to an int/float variable, which
// can then be recursively resolved, hence the
// recursion. Note though that we prevent type
// variables from unifyxing to other type variables
// variables from unifying to other type variables
// directly (though they may be embedded
// structurally), and we prevent cycles in any case,
// so this recursion should always be of very limited
Expand Down Expand Up @@ -1626,17 +1609,15 @@ impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
}

fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
match ct {
ty::Const { val: ConstValue::Infer(InferConst::Var(vid)), .. } => {
if let ty::Const { val: ConstValue::Infer(InferConst::Var(vid)), .. } = ct {
self.infcx.const_unification_table
.borrow_mut()
.probe_value(*vid)
.val
.known()
.map(|c| self.fold_const(c))
.unwrap_or(ct)
}
_ => ct,
} else {
ct
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,17 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
{
assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes());
let offset = ptr.offset.bytes() as usize;
match self.bytes[offset..].iter().position(|&c| c == 0) {
Ok(match self.bytes[offset..].iter().position(|&c| c == 0) {
Some(size) => {
let size_with_null = Size::from_bytes((size + 1) as u64);
// Go through `get_bytes` for checks and AllocationExtra hooks.
// We read the null, so we include it in the request, but we want it removed
// from the result, so we do subslicing.
Ok(&self.get_bytes(cx, ptr, size_with_null)?[..size])
&self.get_bytes(cx, ptr, size_with_null)?[..size]
}
// This includes the case where `offset` is out-of-bounds to begin with.
None => err!(UnterminatedCString(ptr.erase_tag())),
}
None => throw_unsup!(UnterminatedCString(ptr.erase_tag())),
})
}

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

Expand Down Expand Up @@ -516,7 +516,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
self.undef_mask.is_range_defined(
ptr.offset,
ptr.offset + size,
).or_else(|idx| err!(ReadUndefBytes(idx)))
).or_else(|idx| throw_unsup!(ReadUndefBytes(idx)))
}

pub fn mark_definedness(
Expand Down
Loading

0 comments on commit 1df512f

Please sign in to comment.