Skip to content

Commit 8586ec6

Browse files
committed
Auto merge of rust-lang#54146 - kennytm:rollup, r=kennytm
Rollup of 15 pull requests Successful merges: - rust-lang#52514 (Fix a few AMDGPU related issues) - rust-lang#53703 (Document .0 to unpack integer from Wrapping) - rust-lang#53777 (Implemented map_or_else for Result<T, E>) - rust-lang#54031 (A few cleanups and minor improvements to rustc_passes) - rust-lang#54046 (Update documentation for fill_buf in std::io::BufRead) - rust-lang#54064 (`&CStr`, not `CStr`, is the counterpart of `&str`) - rust-lang#54072 (Stabilization change for mod.rs) - rust-lang#54073 (docs: Use dollar sign for all bash prompts) - rust-lang#54074 (simplify ordering for Kind) - rust-lang#54085 (Remove documentation about proc_macro being bare-bones) - rust-lang#54087 (rustdoc: Remove generated blanket impls from trait pages) - rust-lang#54106 (Reexport CheckLintNameResult) - rust-lang#54107 (Fix typos in libstd hash map) - rust-lang#54136 (Update LLVM to fix GlobalISel dbg.declare) - rust-lang#54142 (Recover proper regression test for issue rust-lang#16278.) Failed merges: r? @ghost
2 parents a2b991b + 1fed251 commit 8586ec6

File tree

38 files changed

+265
-365
lines changed

38 files changed

+265
-365
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ you have a more recent version installed the build system doesn't understand
125125
then you may need to force rustbuild to use an older version. This can be done
126126
by manually calling the appropriate vcvars file before running the bootstrap.
127127

128-
```
129-
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
130-
python x.py build
128+
```batch
129+
> CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
130+
> python x.py build
131131
```
132132

133133
#### Specifying an ABI

src/bootstrap/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ system.
88

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

11-
```
12-
python ./x.py build
11+
```sh
12+
$ python ./x.py build
1313
```
1414

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

17-
```
18-
./x.py build
17+
```sh
18+
$ ./x.py build
1919
```
2020

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

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

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

142-
```
143-
> ./x.py build --incremental
142+
```sh
143+
$ ./x.py build --incremental
144144
```
145145

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

162-
```
162+
```sh
163163
# Root folder of all output. Everything is scoped underneath here
164164
build/
165165

src/doc/rustc/src/lints/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $ cat main.rs
1212
fn main() {
1313
let x = 5;
1414
}
15-
> rustc main.rs
15+
$ rustc main.rs
1616
warning: unused variable: `x`
1717
--> main.rs:2:9
1818
|

src/doc/rustc/src/lints/levels.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn foo() {
4545

4646
This will produce this warning:
4747

48-
```console
48+
```bash
4949
$ rustc lib.rs --crate-type=lib
5050
warning: unused variable: `x`
5151
--> lib.rs:2:9
@@ -69,7 +69,7 @@ fn main() {
6969
```
7070

7171
```bash
72-
> rustc main.rs
72+
$ rustc main.rs
7373
error: bitshift exceeds the type's number of bits
7474
--> main.rs:2:13
7575
|
@@ -129,7 +129,10 @@ warning: missing documentation for a function
129129
|
130130
1 | pub fn foo() {}
131131
| ^^^^^^^^^^^^
132-
> rustc lib.rs --crate-type=lib -D missing-docs
132+
```
133+
134+
```bash
135+
$ rustc lib.rs --crate-type=lib -D missing-docs
133136
error: missing documentation for crate
134137
--> lib.rs:1:1
135138
|
@@ -150,21 +153,21 @@ error: aborting due to 2 previous errors
150153
You can also pass each flag more than once for changing multiple lints:
151154
152155
```bash
153-
rustc lib.rs --crate-type=lib -D missing-docs -D unused-variables
156+
$ rustc lib.rs --crate-type=lib -D missing-docs -D unused-variables
154157
```
155158
156159
And of course, you can mix these four flags together:
157160
158161
```bash
159-
rustc lib.rs --crate-type=lib -D missing-docs -A unused-variables
162+
$ rustc lib.rs --crate-type=lib -D missing-docs -A unused-variables
160163
```
161164
162165
### Via an attribute
163166
164167
You can also modify the lint level with a crate-wide attribute:
165168
166169
```bash
167-
> cat lib.rs
170+
$ cat lib.rs
168171
#![warn(missing_docs)]
169172
170173
pub fn foo() {}

src/libcore/num/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ nonzero_integers! {
122122
/// all standard arithmetic operations on the underlying value are
123123
/// intended to have wrapping semantics.
124124
///
125+
/// The underlying value can be retrieved through the `.0` index of the
126+
/// `Wrapping` tuple.
127+
///
125128
/// # Examples
126129
///
127130
/// ```

src/libcore/result.rs

+30
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,36 @@ impl<T, E> Result<T, E> {
470470
}
471471
}
472472

473+
/// Maps a `Result<T, E>` to `U` by applying a function to a
474+
/// contained [`Ok`] value, or a fallback function to a
475+
/// contained [`Err`] value.
476+
///
477+
/// This function can be used to unpack a successful result
478+
/// while handling an error.
479+
///
480+
/// [`Ok`]: enum.Result.html#variant.Ok
481+
/// [`Err`]: enum.Result.html#variant.Err
482+
///
483+
/// # Examples
484+
///
485+
/// Basic usage:
486+
///
487+
/// ```
488+
/// #![feature(result_map_or_else)]
489+
/// let k = 21;
490+
///
491+
/// let x : Result<_, &str> = Ok("foo");
492+
/// assert_eq!(x.map_or_else(|e| k * 2, |v| v.len()), 3);
493+
///
494+
/// let x : Result<&str, _> = Err("bar");
495+
/// assert_eq!(x.map_or_else(|e| k * 2, |v| v.len()), 42);
496+
/// ```
497+
#[inline]
498+
#[unstable(feature = "result_map_or_else", issue = "53268")]
499+
pub fn map_or_else<U, M: FnOnce(T) -> U, F: FnOnce(E) -> U>(self, fallback: F, map: M) -> U {
500+
self.map(map).unwrap_or_else(fallback)
501+
}
502+
473503
/// Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
474504
/// contained [`Err`] value, leaving an [`Ok`] value untouched.
475505
///

src/libproc_macro/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
//! function-like macros `#[proc_macro]`, macro attributes `#[proc_macro_attribute]` and
1616
//! custom derive attributes`#[proc_macro_derive]`.
1717
//!
18-
//! Note that this crate is intentionally bare-bones currently.
19-
//! This functionality is intended to be expanded over time as more surface
20-
//! area for macro authors is stabilized.
21-
//!
2218
//! See [the book](../book/first-edition/procedural-macros.html) for more.
2319
2420
#![stable(feature = "proc_macro_lib", since = "1.15.0")]
@@ -73,9 +69,6 @@ use syntax_pos::{Pos, FileName};
7369
///
7470
/// This is both the input and output of `#[proc_macro]`, `#[proc_macro_attribute]`
7571
/// and `#[proc_macro_derive]` definitions.
76-
///
77-
/// The API of this type is intentionally bare-bones, but it'll be expanded over
78-
/// time!
7972
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
8073
#[derive(Clone)]
8174
pub struct TokenStream(tokenstream::TokenStream);

src/librustc/lint/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use ty::query::Providers;
5353
use util::nodemap::NodeMap;
5454

5555
pub use lint::context::{LateContext, EarlyContext, LintContext, LintStore,
56-
check_crate, check_ast_crate,
56+
check_crate, check_ast_crate, CheckLintNameResult,
5757
FutureIncompatibleInfo, BufferedEarlyLint};
5858

5959
/// Specification of a single lint.

src/librustc/ty/subst.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const TAG_MASK: usize = 0b11;
4242
const TYPE_TAG: usize = 0b00;
4343
const REGION_TAG: usize = 0b01;
4444

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

7575
impl<'tcx> Ord for Kind<'tcx> {
7676
fn cmp(&self, other: &Kind) -> Ordering {
77-
match (self.unpack(), other.unpack()) {
78-
(UnpackedKind::Type(_), UnpackedKind::Lifetime(_)) => Ordering::Greater,
79-
80-
(UnpackedKind::Type(ty1), UnpackedKind::Type(ty2)) => {
81-
ty1.sty.cmp(&ty2.sty)
82-
}
83-
84-
(UnpackedKind::Lifetime(reg1), UnpackedKind::Lifetime(reg2)) => reg1.cmp(reg2),
85-
86-
(UnpackedKind::Lifetime(_), UnpackedKind::Type(_)) => Ordering::Less,
87-
}
77+
self.unpack().cmp(&other.unpack())
8878
}
8979
}
9080

src/librustc_codegen_llvm/attributes.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
1616
use rustc::session::Session;
1717
use rustc::session::config::Sanitizer;
1818
use rustc::ty::TyCtxt;
19+
use rustc::ty::layout::HasTyCtxt;
1920
use rustc::ty::query::Providers;
2021
use rustc_data_structures::sync::Lrc;
2122
use rustc_data_structures::fx::FxHashMap;
@@ -32,12 +33,16 @@ use value::Value;
3233

3334
/// Mark LLVM function to use provided inline heuristic.
3435
#[inline]
35-
pub fn inline(val: &'ll Value, inline: InlineAttr) {
36+
pub fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
3637
use self::InlineAttr::*;
3738
match inline {
3839
Hint => Attribute::InlineHint.apply_llfn(Function, val),
3940
Always => Attribute::AlwaysInline.apply_llfn(Function, val),
40-
Never => Attribute::NoInline.apply_llfn(Function, val),
41+
Never => {
42+
if cx.tcx().sess.target.target.arch != "amdgpu" {
43+
Attribute::NoInline.apply_llfn(Function, val);
44+
}
45+
},
4146
None => {
4247
Attribute::InlineHint.unapply_llfn(Function, val);
4348
Attribute::AlwaysInline.unapply_llfn(Function, val);
@@ -143,7 +148,7 @@ pub fn from_fn_attrs(
143148
let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id))
144149
.unwrap_or(CodegenFnAttrs::new());
145150

146-
inline(llfn, codegen_fn_attrs.inline);
151+
inline(cx, llfn, codegen_fn_attrs.inline);
147152

148153
// The `uwtable` attribute according to LLVM is:
149154
//

src/librustc_codegen_llvm/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,14 @@ impl Builder<'a, 'll, 'tcx> {
496496

497497

498498
pub fn range_metadata(&self, load: &'ll Value, range: Range<u128>) {
499+
if self.sess().target.target.arch == "amdgpu" {
500+
// amdgpu/LLVM does something weird and thinks a i64 value is
501+
// split into a v2i32, halving the bitwidth LLVM expects,
502+
// tripping an assertion. So, for now, just disable this
503+
// optimization.
504+
return;
505+
}
506+
499507
unsafe {
500508
let llty = val_ty(load);
501509
let v = [

src/librustc_codegen_llvm/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn get_fn(
9696
debug!("get_fn: not casting pointer!");
9797

9898
if instance.def.is_inline(tcx) {
99-
attributes::inline(llfn, attributes::InlineAttr::Hint);
99+
attributes::inline(cx, llfn, attributes::InlineAttr::Hint);
100100
}
101101
attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id()));
102102

src/librustc_codegen_llvm/mono_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
180180

181181
debug!("predefine_fn: mono_ty = {:?} instance = {:?}", mono_ty, instance);
182182
if instance.def.is_inline(cx.tcx) {
183-
attributes::inline(lldecl, attributes::InlineAttr::Hint);
183+
attributes::inline(cx, lldecl, attributes::InlineAttr::Hint);
184184
}
185185
attributes::from_fn_attrs(cx, lldecl, Some(instance.def.def_id()));
186186

src/librustc_llvm/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn main() {
8181
let is_crossed = target != host;
8282

8383
let mut optional_components =
84-
vec!["x86", "arm", "aarch64", "mips", "powerpc",
84+
vec!["x86", "arm", "aarch64", "amdgpu", "mips", "powerpc",
8585
"systemz", "jsbackend", "webassembly", "msp430", "sparc", "nvptx"];
8686

8787
let mut version_cmd = Command::new(&llvm_config);

0 commit comments

Comments
 (0)