Skip to content

Rollup of 7 pull requests #63214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0aa9658
changing the fields of InterpError
saleemjaffer Jul 25, 2019
01859bb
grouping the variants of InterpError
saleemjaffer Jul 26, 2019
fc48f3e
more grouping of the variants in InterpError
saleemjaffer Jul 26, 2019
eeb2335
moving remaining variants to UnsupportedInfo
saleemjaffer Jul 26, 2019
4f0ab6c
code review fixes
saleemjaffer Jul 26, 2019
307798a
fixing fallout due to InterpError refactor
saleemjaffer Jul 27, 2019
aa3d40c
tidy fixes
saleemjaffer Jul 27, 2019
9782b37
implementing Debug for UnsupportedInfo
saleemjaffer Jul 28, 2019
8e9d0fa
adding a err macro for each of the InterpError variants
saleemjaffer Jul 29, 2019
654519d
use PanicInfo and UnsupportedOpInfo
saleemjaffer Jul 29, 2019
03d47be
code review fixes
saleemjaffer Jul 29, 2019
9f8b099
code review fixes
saleemjaffer Jul 29, 2019
5bb06b3
code review fixes
saleemjaffer Jul 29, 2019
9620521
code review fixes
saleemjaffer Jul 30, 2019
2a33fbf
addding an interp_error module
saleemjaffer Jul 30, 2019
69daf84
adding throw_ and err_ macros for InterpError
saleemjaffer Jul 30, 2019
b60a336
tidy fixes
saleemjaffer Jul 30, 2019
fc5df1d
renaming err to err_unsup
saleemjaffer Jul 30, 2019
35417e7
renaming throw_err_* to throw_*
saleemjaffer Jul 30, 2019
5585445
throw_X macros use err_X macros
saleemjaffer Jul 30, 2019
87e73c1
Remove redundant method with const variable resolution
varkor Jul 31, 2019
152f0d3
code review fixes
saleemjaffer Jul 31, 2019
a1e59d1
code review fixes
saleemjaffer Jul 31, 2019
c17d11f
code review fixes
saleemjaffer Jul 31, 2019
0c4513e
code review fixes
saleemjaffer Aug 1, 2019
00d32e8
code review fixes
saleemjaffer Aug 1, 2019
b5c04e6
FixedSizeArray: Add missing links in doc comments.
waywardmonkeys Aug 1, 2019
cbac781
More questionmarks in doctests
llogiq Jul 13, 2019
86633b6
Fix typos in doc comments.
waywardmonkeys Aug 1, 2019
ae65848
Remove extraneous {} in use stmts in doc comments.
waywardmonkeys Aug 1, 2019
325c6a5
Futures: Add link to Waker in trait doc.
waywardmonkeys Aug 1, 2019
cefbf4d
Allow trailing comma in macro 2.0 declarations.
rbartlensky Aug 1, 2019
b3321fb
Fix ICE in #63135
ExpHP Aug 1, 2019
2aa368a
Add check-pass test for #63102.
rbartlensky Aug 1, 2019
7052c35
Make is_mutable use PlaceRef instead of it's fields
spastorino Aug 1, 2019
6b951c2
Rollup merge of #62663 - llogiq:more-questionmark-docs, r=GuillaumeGomez
Centril Aug 2, 2019
51dc78e
Rollup merge of #62969 - saleemjaffer:declutter_interperror, r=RalfJung
Centril Aug 2, 2019
5155c7e
Rollup merge of #63153 - varkor:remove-resolve_const_var, r=cramertj
Centril Aug 2, 2019
dbfe12d
Rollup merge of #63189 - waywardmonkeys:doc-improvements, r=Centril
Centril Aug 2, 2019
89dce46
Rollup merge of #63198 - rbartlensky:fix-macro-trailing-comma, r=petr…
Centril Aug 2, 2019
3396550
Rollup merge of #63202 - exphp-forks:parser-ice-63135, r=estebank
Centril Aug 2, 2019
97098f4
Rollup merge of #63203 - spastorino:is-mutable-use-place-ref, r=oli-obk
Centril Aug 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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