Skip to content

Commit

Permalink
Auto merge of #54146 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 15 pull requests

Successful merges:

 - #52514 (Fix a few AMDGPU related issues)
 - #53703 (Document .0 to unpack integer from Wrapping)
 - #53777 (Implemented map_or_else for Result<T, E>)
 - #54031 (A few cleanups and minor improvements to rustc_passes)
 - #54046 (Update documentation for fill_buf in std::io::BufRead)
 - #54064 (`&CStr`, not `CStr`, is the counterpart of `&str`)
 - #54072 (Stabilization change for mod.rs)
 - #54073 (docs: Use dollar sign for all bash prompts)
 - #54074 (simplify ordering for Kind)
 - #54085 (Remove documentation about proc_macro being bare-bones)
 - #54087 (rustdoc: Remove generated blanket impls from trait pages)
 - #54106 (Reexport CheckLintNameResult)
 - #54107 (Fix typos in libstd hash map)
 - #54136 (Update LLVM to fix GlobalISel dbg.declare)
 - #54142 (Recover proper regression test for issue #16278.)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Sep 12, 2018
2 parents a2b991b + 1fed251 commit 8586ec6
Show file tree
Hide file tree
Showing 38 changed files with 265 additions and 365 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ you have a more recent version installed the build system doesn't understand
then you may need to force rustbuild to use an older version. This can be done
by manually calling the appropriate vcvars file before running the bootstrap.

```
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
python x.py build
```batch
> CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
> python x.py build
```

#### Specifying an ABI
Expand Down
18 changes: 9 additions & 9 deletions src/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ system.

The rustbuild build system has a primary entry point, a top level `x.py` script:

```
python ./x.py build
```sh
$ python ./x.py build
```

Note that if you're on Unix you should be able to execute the script directly:

```
./x.py build
```sh
$ ./x.py build
```

The script accepts commands, flags, and arguments to determine what to do:
Expand Down Expand Up @@ -129,18 +129,18 @@ To follow this course of action, first thing you will want to do is to
install a nightly, presumably using `rustup`. You will then want to
configure your directory to use this build, like so:

```
```sh
# configure to use local rust instead of downloading a beta.
# `--local-rust-root` is optional here. If elided, we will
# use whatever rustc we find on your PATH.
> ./configure --local-rust-root=~/.cargo/ --enable-local-rebuild
$ ./configure --local-rust-root=~/.cargo/ --enable-local-rebuild
```

After that, you can use the `--incremental` flag to actually do
incremental builds:

```
> ./x.py build --incremental
```sh
$ ./x.py build --incremental
```

The `--incremental` flag will store incremental compilation artifacts
Expand All @@ -159,7 +159,7 @@ will still be using the local nightly as your bootstrap).
This build system houses all output under the `build` directory, which looks
like this:

```
```sh
# Root folder of all output. Everything is scoped underneath here
build/

Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/lints/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $ cat main.rs
fn main() {
let x = 5;
}
> rustc main.rs
$ rustc main.rs
warning: unused variable: `x`
--> main.rs:2:9
|
Expand Down
15 changes: 9 additions & 6 deletions src/doc/rustc/src/lints/levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn foo() {

This will produce this warning:

```console
```bash
$ rustc lib.rs --crate-type=lib
warning: unused variable: `x`
--> lib.rs:2:9
Expand All @@ -69,7 +69,7 @@ fn main() {
```

```bash
> rustc main.rs
$ rustc main.rs
error: bitshift exceeds the type's number of bits
--> main.rs:2:13
|
Expand Down Expand Up @@ -129,7 +129,10 @@ warning: missing documentation for a function
|
1 | pub fn foo() {}
| ^^^^^^^^^^^^
> rustc lib.rs --crate-type=lib -D missing-docs
```
```bash
$ rustc lib.rs --crate-type=lib -D missing-docs
error: missing documentation for crate
--> lib.rs:1:1
|
Expand All @@ -150,21 +153,21 @@ error: aborting due to 2 previous errors
You can also pass each flag more than once for changing multiple lints:
```bash
rustc lib.rs --crate-type=lib -D missing-docs -D unused-variables
$ rustc lib.rs --crate-type=lib -D missing-docs -D unused-variables
```
And of course, you can mix these four flags together:
```bash
rustc lib.rs --crate-type=lib -D missing-docs -A unused-variables
$ rustc lib.rs --crate-type=lib -D missing-docs -A unused-variables
```
### Via an attribute
You can also modify the lint level with a crate-wide attribute:
```bash
> cat lib.rs
$ cat lib.rs
#![warn(missing_docs)]
pub fn foo() {}
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ nonzero_integers! {
/// all standard arithmetic operations on the underlying value are
/// intended to have wrapping semantics.
///
/// The underlying value can be retrieved through the `.0` index of the
/// `Wrapping` tuple.
///
/// # Examples
///
/// ```
Expand Down
30 changes: 30 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,36 @@ impl<T, E> Result<T, E> {
}
}

/// Maps a `Result<T, E>` to `U` by applying a function to a
/// contained [`Ok`] value, or a fallback function to a
/// contained [`Err`] value.
///
/// This function can be used to unpack a successful result
/// while handling an error.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(result_map_or_else)]
/// let k = 21;
///
/// let x : Result<_, &str> = Ok("foo");
/// assert_eq!(x.map_or_else(|e| k * 2, |v| v.len()), 3);
///
/// let x : Result<&str, _> = Err("bar");
/// assert_eq!(x.map_or_else(|e| k * 2, |v| v.len()), 42);
/// ```
#[inline]
#[unstable(feature = "result_map_or_else", issue = "53268")]
pub fn map_or_else<U, M: FnOnce(T) -> U, F: FnOnce(E) -> U>(self, fallback: F, map: M) -> U {
self.map(map).unwrap_or_else(fallback)
}

/// Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
/// contained [`Err`] value, leaving an [`Ok`] value untouched.
///
Expand Down
7 changes: 0 additions & 7 deletions src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
//! function-like macros `#[proc_macro]`, macro attributes `#[proc_macro_attribute]` and
//! custom derive attributes`#[proc_macro_derive]`.
//!
//! Note that this crate is intentionally bare-bones currently.
//! This functionality is intended to be expanded over time as more surface
//! area for macro authors is stabilized.
//!
//! See [the book](../book/first-edition/procedural-macros.html) for more.

#![stable(feature = "proc_macro_lib", since = "1.15.0")]
Expand Down Expand Up @@ -73,9 +69,6 @@ use syntax_pos::{Pos, FileName};
///
/// This is both the input and output of `#[proc_macro]`, `#[proc_macro_attribute]`
/// and `#[proc_macro_derive]` definitions.
///
/// The API of this type is intentionally bare-bones, but it'll be expanded over
/// time!
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
#[derive(Clone)]
pub struct TokenStream(tokenstream::TokenStream);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use ty::query::Providers;
use util::nodemap::NodeMap;

pub use lint::context::{LateContext, EarlyContext, LintContext, LintStore,
check_crate, check_ast_crate,
check_crate, check_ast_crate, CheckLintNameResult,
FutureIncompatibleInfo, BufferedEarlyLint};

/// Specification of a single lint.
Expand Down
14 changes: 2 additions & 12 deletions src/librustc/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const TAG_MASK: usize = 0b11;
const TYPE_TAG: usize = 0b00;
const REGION_TAG: usize = 0b01;

#[derive(Debug, RustcEncodable, RustcDecodable)]
#[derive(Debug, RustcEncodable, RustcDecodable, PartialEq, Eq, PartialOrd, Ord)]
pub enum UnpackedKind<'tcx> {
Lifetime(ty::Region<'tcx>),
Type(Ty<'tcx>),
Expand Down Expand Up @@ -74,17 +74,7 @@ impl<'tcx> UnpackedKind<'tcx> {

impl<'tcx> Ord for Kind<'tcx> {
fn cmp(&self, other: &Kind) -> Ordering {
match (self.unpack(), other.unpack()) {
(UnpackedKind::Type(_), UnpackedKind::Lifetime(_)) => Ordering::Greater,

(UnpackedKind::Type(ty1), UnpackedKind::Type(ty2)) => {
ty1.sty.cmp(&ty2.sty)
}

(UnpackedKind::Lifetime(reg1), UnpackedKind::Lifetime(reg2)) => reg1.cmp(reg2),

(UnpackedKind::Lifetime(_), UnpackedKind::Type(_)) => Ordering::Less,
}
self.unpack().cmp(&other.unpack())
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::session::Session;
use rustc::session::config::Sanitizer;
use rustc::ty::TyCtxt;
use rustc::ty::layout::HasTyCtxt;
use rustc::ty::query::Providers;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::fx::FxHashMap;
Expand All @@ -32,12 +33,16 @@ use value::Value;

/// Mark LLVM function to use provided inline heuristic.
#[inline]
pub fn inline(val: &'ll Value, inline: InlineAttr) {
pub fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
use self::InlineAttr::*;
match inline {
Hint => Attribute::InlineHint.apply_llfn(Function, val),
Always => Attribute::AlwaysInline.apply_llfn(Function, val),
Never => Attribute::NoInline.apply_llfn(Function, val),
Never => {
if cx.tcx().sess.target.target.arch != "amdgpu" {
Attribute::NoInline.apply_llfn(Function, val);
}
},
None => {
Attribute::InlineHint.unapply_llfn(Function, val);
Attribute::AlwaysInline.unapply_llfn(Function, val);
Expand Down Expand Up @@ -143,7 +148,7 @@ pub fn from_fn_attrs(
let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id))
.unwrap_or(CodegenFnAttrs::new());

inline(llfn, codegen_fn_attrs.inline);
inline(cx, llfn, codegen_fn_attrs.inline);

// The `uwtable` attribute according to LLVM is:
//
Expand Down
8 changes: 8 additions & 0 deletions src/librustc_codegen_llvm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,14 @@ impl Builder<'a, 'll, 'tcx> {


pub fn range_metadata(&self, load: &'ll Value, range: Range<u128>) {
if self.sess().target.target.arch == "amdgpu" {
// amdgpu/LLVM does something weird and thinks a i64 value is
// split into a v2i32, halving the bitwidth LLVM expects,
// tripping an assertion. So, for now, just disable this
// optimization.
return;
}

unsafe {
let llty = val_ty(load);
let v = [
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn get_fn(
debug!("get_fn: not casting pointer!");

if instance.def.is_inline(tcx) {
attributes::inline(llfn, attributes::InlineAttr::Hint);
attributes::inline(cx, llfn, attributes::InlineAttr::Hint);
}
attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id()));

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,

debug!("predefine_fn: mono_ty = {:?} instance = {:?}", mono_ty, instance);
if instance.def.is_inline(cx.tcx) {
attributes::inline(lldecl, attributes::InlineAttr::Hint);
attributes::inline(cx, lldecl, attributes::InlineAttr::Hint);
}
attributes::from_fn_attrs(cx, lldecl, Some(instance.def.def_id()));

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn main() {
let is_crossed = target != host;

let mut optional_components =
vec!["x86", "arm", "aarch64", "mips", "powerpc",
vec!["x86", "arm", "aarch64", "amdgpu", "mips", "powerpc",
"systemz", "jsbackend", "webassembly", "msp430", "sparc", "nvptx"];

let mut version_cmd = Command::new(&llvm_config);
Expand Down
Loading

0 comments on commit 8586ec6

Please sign in to comment.