Skip to content
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

Rollup of 11 pull requests #65559

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3b0fd82
Disable Go and OCaml bindings when building LLVM
tmiasko Oct 8, 2019
88b5e94
Make <*const/mut T>::offset_from `const fn`
oli-obk Aug 20, 2019
c716be6
show up some extra info when t!() fails
Oct 17, 2019
83e97c6
properly document panics in div_euclid and rem_euclid
tspiteri Oct 17, 2019
a4d9492
add option to ping llvm ice-breakers to triagebot
nikomatsakis Oct 17, 2019
5fe88ab
save-analysis: Nest tables when processing impl items
Xanewok Oct 17, 2019
ad6ce46
save-analysis: Add a relevant test case
Xanewok Oct 17, 2019
4e6efe4
reorder fmt docs for more clarity
RalfJung Oct 17, 2019
5487994
Update triagebot.toml
nikomatsakis Oct 17, 2019
c0b7e76
example for padding any format
RalfJung Oct 17, 2019
c9b27d1
doc: make BitSet intro more short
tshepang Oct 17, 2019
5de9cb0
super_ty on MutVisitor is empty so avoid the call
spastorino Oct 7, 2019
e069e9c
Prepare promote_consts MutVisitor to have projections interned
spastorino Oct 7, 2019
591cc9a
Prepare simplify MutVisitor to have projections interned
spastorino Oct 7, 2019
bb7d6d1
Prepare renumber MutVisitor to have projections interned
spastorino Oct 7, 2019
e3e9951
Prepare inline MutVisitor to have projections interned
spastorino Oct 7, 2019
0fc063f
Prepare generator MutVisitor to have projections interned
spastorino Oct 7, 2019
39c9ed3
Prepare erase_regions MutVisitor to have projections interned
spastorino Oct 7, 2019
2b2e35b
Prepare def_use MutVisitor to have projections interned
spastorino Oct 8, 2019
4f2a110
Remove unneeded callback and just use the new_local value
spastorino Oct 8, 2019
7fa3425
Setup a different visit place set of methods for mutable and immutabl…
spastorino Oct 8, 2019
d53fc9c
Add process_* place hooks to improve code reutilization
spastorino Oct 8, 2019
769e75b
Fix left/right shift typo in wrapping rotate docs
t-rapp Oct 18, 2019
9617014
Clarify diagnostics when using `~` as a unary op
JohnTitor Oct 18, 2019
4a51801
Use dedicated method for getting the type size
oli-obk Oct 18, 2019
94a6d4b
Adjust const eval code to reflect `offset_from` docs
oli-obk Oct 18, 2019
4834996
Use Cow to handle modifications of projection in preparation for inte…
spastorino Oct 9, 2019
1c9d889
Review nit
oli-obk Oct 18, 2019
58b17d5
Rollup merge of #63810 - oli-obk:const_offset_from, r=RalfJung,nikic
Centril Oct 18, 2019
33197c7
Rollup merge of #65197 - spastorino:place-mut-visitor-adjusts2, r=oli…
Centril Oct 18, 2019
1e9fd2b
Rollup merge of #65201 - tmiasko:no-bindings, r=rkruppe
Centril Oct 18, 2019
ea6d132
Rollup merge of #65496 - tspiteri:euc-div-panic, r=KodrAus
Centril Oct 18, 2019
28386e6
Rollup merge of #65508 - rust-lang:llvm-icebreakers-ping-1, r=simulacrum
Centril Oct 18, 2019
d08536c
Rollup merge of #65511 - Xanewok:sa-nest-in-impls, r=pnkfelix
Centril Oct 18, 2019
835a359
Rollup merge of #65513 - RalfJung:fmt, r=Mark-Simulacrum
Centril Oct 18, 2019
c4f5203
Rollup merge of #65532 - tshepang:shorten-intro, r=Dylan-DPC
Centril Oct 18, 2019
b85d26a
Rollup merge of #65540 - guanqun:extend-t-macro, r=nikomatsakis
Centril Oct 18, 2019
f8663c4
Rollup merge of #65549 - t-rapp:tr-wrapping-rotate-docs, r=jonas-schi…
Centril Oct 18, 2019
4c317fb
Rollup merge of #65552 - JohnTitor:use-bitwise-not, r=Dylan-DPC
Centril Oct 18, 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
2 changes: 1 addition & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ impl Build {
}

let mut paths = Vec::new();
let contents = t!(fs::read(stamp));
let contents = t!(fs::read(stamp), &stamp);
// This is the method we use for extracting paths from the stamp file passed to us. See
// run_cargo for more information (in compile.rs).
for part in contents.split(|b| *b == 0) {
Expand Down
10 changes: 1 addition & 9 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ impl Step for Llvm {
.define("WITH_POLLY", "OFF")
.define("LLVM_ENABLE_TERMINFO", "OFF")
.define("LLVM_ENABLE_LIBEDIT", "OFF")
.define("LLVM_ENABLE_BINDINGS", "OFF")
.define("LLVM_ENABLE_Z3_SOLVER", "OFF")
.define("LLVM_PARALLEL_COMPILE_JOBS", builder.jobs().to_string())
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
Expand All @@ -169,15 +170,6 @@ impl Step for Llvm {
}
}

// By default, LLVM will automatically find OCaml and, if it finds it,
// install the LLVM bindings in LLVM_OCAML_INSTALL_PATH, which defaults
// to /usr/bin/ocaml.
// This causes problem for non-root builds of Rust. Side-step the issue
// by setting LLVM_OCAML_INSTALL_PATH to a relative path, so it installs
// in the prefix.
cfg.define("LLVM_OCAML_INSTALL_PATH",
env::var_os("LLVM_OCAML_INSTALL_PATH").unwrap_or_else(|| "usr/lib/ocaml".into()));

let want_lldb = builder.config.lldb_enabled && !self.emscripten;

// This setting makes the LLVM tools link to the dynamic LLVM library,
Expand Down
7 changes: 7 additions & 0 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ macro_rules! t {
Err(e) => panic!("{} failed with {}", stringify!($e), e),
}
};
// it can show extra info in the second parameter
($e:expr, $extra:expr) => {
match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {} ({:?})", stringify!($e), e, $extra),
}
};
}

// Because Cargo adds the compiler's dylib path to our library search path, llvm-config may
Expand Down
111 changes: 67 additions & 44 deletions src/liballoc/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,74 @@
//! parameters (corresponding to `format_spec` in the syntax above). These
//! parameters affect the string representation of what's being formatted.
//!
//! ## Width
//!
//! ```
//! // All of these print "Hello x !"
//! println!("Hello {:5}!", "x");
//! println!("Hello {:1$}!", "x", 5);
//! println!("Hello {1:0$}!", 5, "x");
//! println!("Hello {:width$}!", "x", width = 5);
//! ```
//!
//! This is a parameter for the "minimum width" that the format should take up.
//! If the value's string does not fill up this many characters, then the
//! padding specified by fill/alignment will be used to take up the required
//! space (see below).
//!
//! The value for the width can also be provided as a [`usize`] in the list of
//! parameters by adding a postfix `$`, indicating that the second argument is
//! a [`usize`] specifying the width.
//!
//! Referring to an argument with the dollar syntax does not affect the "next
//! argument" counter, so it's usually a good idea to refer to arguments by
//! position, or use named arguments.
//!
//! ## Fill/Alignment
//!
//! The fill character is provided normally in conjunction with the
//! [`width`](#width)
//! parameter. This indicates that if the value being formatted is smaller than
//! `width` some extra characters will be printed around it. The extra
//! characters are specified by `fill`, and the alignment can be one of the
//! following options:
//! ```
//! assert_eq!(format!("Hello {:<5}!", "x"), "Hello x !");
//! assert_eq!(format!("Hello {:-<5}!", "x"), "Hello x----!");
//! assert_eq!(format!("Hello {:^5}!", "x"), "Hello x !");
//! assert_eq!(format!("Hello {:>5}!", "x"), "Hello x!");
//! ```
//!
//! * `<` - the argument is left-aligned in `width` columns
//! * `^` - the argument is center-aligned in `width` columns
//! * `>` - the argument is right-aligned in `width` columns
//! The optional fill character and alignment is provided normally in conjunction with the
//! [`width`](#width) parameter. It must be defined before `width`, right after the `:`.
//! This indicates that if the value being formatted is smaller than
//! `width` some extra characters will be printed around it.
//! Filling comes in the following variants for different alignments:
//!
//! * `[fill]<` - the argument is left-aligned in `width` columns
//! * `[fill]^` - the argument is center-aligned in `width` columns
//! * `[fill]>` - the argument is right-aligned in `width` columns
//!
//! The default [fill/alignment](#fillalignment) for non-numerics is a space and
//! left-aligned. The
//! defaults for numeric formatters is also a space but with right-alignment. If
//! the `0` flag (see below) is specified for numerics, then the implicit fill character is
//! `0`.
//!
//! Note that alignment may not be implemented by some types. In particular, it
//! is not generally implemented for the `Debug` trait. A good way to ensure
//! padding is applied is to format your input, then use this resulting string
//! to pad your output.
//! padding is applied is to format your input, then pad this resulting string
//! to obtain your output:
//!
//! ```
//! println!("Hello {:^15}!", format!("{:?}", Some("hi"))); // => "Hello Some("hi") !"
//! ```
//!
//! ## Sign/`#`/`0`
//!
//! These can all be interpreted as flags for a particular formatter.
//! ```
//! assert_eq!(format!("Hello {:+}!", 5), "Hello +5!");
//! assert_eq!(format!("{:#x}!", 27), "0x1b!");
//! assert_eq!(format!("Hello {:05}!", 5), "Hello 00005!");
//! assert_eq!(format!("Hello {:05}!", -5), "Hello -0005!");
//! assert_eq!(format!("{:#010x}!", 27), "0x0000001b!");
//! ```
//!
//! These are all flags altering the behavior of the formatter.
//!
//! * `+` - This is intended for numeric types and indicates that the sign
//! should always be printed. Positive signs are never printed by
Expand All @@ -121,44 +168,15 @@
//! * `#X` - precedes the argument with a `0x`
//! * `#b` - precedes the argument with a `0b`
//! * `#o` - precedes the argument with a `0o`
//! * `0` - This is used to indicate for integer formats that the padding should
//! * `0` - This is used to indicate for integer formats that the padding to `width` should
//! both be done with a `0` character as well as be sign-aware. A format
//! like `{:08}` would yield `00000001` for the integer `1`, while the
//! same format would yield `-0000001` for the integer `-1`. Notice that
//! the negative version has one fewer zero than the positive version.
//! Note that padding zeroes are always placed after the sign (if any)
//! and before the digits. When used together with the `#` flag, a similar
//! rule applies: padding zeroes are inserted after the prefix but before
//! the digits.
//!
//! ## Width
//!
//! This is a parameter for the "minimum width" that the format should take up.
//! If the value's string does not fill up this many characters, then the
//! padding specified by fill/alignment will be used to take up the required
//! space.
//!
//! The default [fill/alignment](#fillalignment) for non-numerics is a space and
//! left-aligned. The
//! defaults for numeric formatters is also a space but with right-alignment. If
//! the `0` flag is specified for numerics, then the implicit fill character is
//! `0`.
//!
//! The value for the width can also be provided as a [`usize`] in the list of
//! parameters by using the dollar syntax indicating that the second argument is
//! a [`usize`] specifying the width, for example:
//!
//! ```
//! // All of these print "Hello x !"
//! println!("Hello {:5}!", "x");
//! println!("Hello {:1$}!", "x", 5);
//! println!("Hello {1:0$}!", 5, "x");
//! println!("Hello {:width$}!", "x", width = 5);
//! ```
//!
//! Referring to an argument with the dollar syntax does not affect the "next
//! argument" counter, so it's usually a good idea to refer to arguments by
//! position, or use named arguments.
//! the digits. The prefix is included in the total width.
//!
//! ## Precision
//!
Expand Down Expand Up @@ -235,9 +253,14 @@
//! them with the same character. For example, the `{` character is escaped with
//! `{{` and the `}` character is escaped with `}}`.
//!
//! ```
//! assert_eq!(format!("Hello {{}}"), "Hello {}");
//! assert_eq!(format!("{{ Hello"), "{ Hello");
//! ```
//!
//! # Syntax
//!
//! To summarize, you can find the full grammar of format strings.
//! To summarize, here you can find the full grammar of format strings.
//! The syntax for the formatting language used is drawn from other languages,
//! so it should not be too alien. Arguments are formatted with Python-like
//! syntax, meaning that arguments are surrounded by `{}` instead of the C-like
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,10 @@ extern "rust-intrinsic" {
/// Emits a `!nontemporal` store according to LLVM (see their docs).
/// Probably will never become stable.
pub fn nontemporal_store<T>(ptr: *mut T, val: T);

/// See documentation of `<*const T>::offset_from` for details.
#[cfg(not(bootstrap))]
pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;
}

// Some functions are defined here because they accidentally got made
Expand Down
12 changes: 10 additions & 2 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ if `self < 0`, this is equal to round towards +/- infinity.

# Panics

This function will panic if `rhs` is 0.
This function will panic if `rhs` is 0 or the division results in overflow.

# Examples

Expand Down Expand Up @@ -1903,7 +1903,7 @@ This is done as if by the Euclidean division algorithm -- given

# Panics

This function will panic if `rhs` is 0.
This function will panic if `rhs` is 0 or the division results in overflow.

# Examples

Expand Down Expand Up @@ -3694,6 +3694,10 @@ Since, for the positive integers, all common
definitions of division are equal, this
is exactly equal to `self / rhs`.

# Panics

This function will panic if `rhs` is 0.

# Examples

Basic usage:
Expand All @@ -3719,6 +3723,10 @@ Since, for the positive integers, all common
definitions of division are equal, this
is exactly equal to `self % rhs`.

# Panics

This function will panic if `rhs` is 0.

# Examples

Basic usage:
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ assert_eq!(n.trailing_zeros(), 3);
/// wrapping the truncated bits to the end of the resulting
/// integer.
///
/// Please note this isn't the same operation as the `>>` shifting
/// Please note this isn't the same operation as the `<<` shifting
/// operator!
///
/// # Examples
Expand All @@ -463,7 +463,7 @@ assert_eq!(n.trailing_zeros(), 3);
/// wrapping the truncated bits to the beginning of the resulting
/// integer.
///
/// Please note this isn't the same operation as the `<<` shifting
/// Please note this isn't the same operation as the `>>` shifting
/// operator!
///
/// # Examples
Expand Down
18 changes: 17 additions & 1 deletion src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,22 @@ impl<T: ?Sized> *const T {
/// }
/// ```
#[unstable(feature = "ptr_offset_from", issue = "41079")]
#[cfg(not(bootstrap))]
#[rustc_const_unstable(feature = "const_ptr_offset_from")]
#[inline]
pub const unsafe fn offset_from(self, origin: *const T) -> isize where T: Sized {
let pointee_size = mem::size_of::<T>();
let ok = 0 < pointee_size && pointee_size <= isize::max_value() as usize;
// assert that the pointee size is valid in a const eval compatible way
// FIXME: do this with a real assert at some point
[()][(!ok) as usize];
intrinsics::ptr_offset_from(self, origin)
}

#[unstable(feature = "ptr_offset_from", issue = "41079")]
#[inline]
#[cfg(bootstrap)]
/// bootstrap
pub unsafe fn offset_from(self, origin: *const T) -> isize where T: Sized {
let pointee_size = mem::size_of::<T>();
assert!(0 < pointee_size && pointee_size <= isize::max_value() as usize);
Expand Down Expand Up @@ -2013,8 +2028,9 @@ impl<T: ?Sized> *mut T {
/// }
/// ```
#[unstable(feature = "ptr_offset_from", issue = "41079")]
#[rustc_const_unstable(feature = "const_ptr_offset_from")]
#[inline]
pub unsafe fn offset_from(self, origin: *const T) -> isize where T: Sized {
pub const unsafe fn offset_from(self, origin: *const T) -> isize where T: Sized {
(self as *const T).offset_from(origin)
}

Expand Down
Loading