Skip to content

Commit 5f4abc1

Browse files
committed
Auto merge of #73977 - Manishearth:rollup-2x4s7c6, r=Manishearth
Rollup of 8 pull requests Successful merges: - #73454 (Move contributing.md to rustc-dev-guide and point at getting started) - #73724 (Use WASM's saturating casts if they are available) - #73726 (resolve: disallow labelled breaks/continues through closures/async blocks) - #73753 (Use 'tcx for references to AccessLevels wherever possible.) - #73781 (Update psm version) - #73952 (Add option for local docker testing.) - #73957 (disable BTree min_max test in Miri for now) - #73975 (Document rustc_ast::ast::Pat) Failed merges: r? @ghost
2 parents 3503f56 + 7bd2f97 commit 5f4abc1

File tree

217 files changed

+2550
-2443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+2550
-2443
lines changed

CONTRIBUTING.md

+3-524
Large diffs are not rendered by default.

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2347,9 +2347,9 @@ dependencies = [
23472347

23482348
[[package]]
23492349
name = "psm"
2350-
version = "0.1.8"
2350+
version = "0.1.10"
23512351
source = "registry+https://github.com/rust-lang/crates.io-index"
2352-
checksum = "659ecfea2142a458893bb7673134bad50b752fea932349c213d6a23874ce3aa7"
2352+
checksum = "092d385624a084892d07374caa7b0994956692cf40650419a1f1a787a8d229cf"
23532353
dependencies = [
23542354
"cc",
23552355
]

README.md

+8-21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ standard library, and documentation.
77

88
[Rust]: https://www.rust-lang.org
99

10+
**Note: this README is for _users_ rather than _contributors_.**
11+
1012
## Quick Start
1113

1214
Read ["Installation"] from [The Book].
@@ -16,13 +18,15 @@ Read ["Installation"] from [The Book].
1618

1719
## Installing from Source
1820

19-
_Note: If you wish to contribute to the compiler, you should read [this
20-
chapter][rustcguidebuild] of the rustc-dev-guide instead of this section._
21+
**Note: If you wish to _contribute_ to the compiler, you should read the
22+
[Getting Started][gettingstarted] of the rustc-dev-guide instead of this
23+
section.**
2124

2225
The Rust build system uses a Python script called `x.py` to build the compiler,
2326
which manages the bootstrapping process. More information about it can be found
2427
by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild].
2528

29+
[gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.md
2630
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
2731

2832
### Building on a Unix-like system
@@ -225,10 +229,6 @@ Snapshot binaries are currently built and tested on several platforms:
225229
You may find that other platforms work, but these are our officially
226230
supported build environments that are most likely to work.
227231
228-
There is more advice about hacking on Rust in [CONTRIBUTING.md].
229-
230-
[CONTRIBUTING.md]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md
231-
232232
## Getting Help
233233
234234
The Rust community congregates in a few places:
@@ -243,21 +243,8 @@ The Rust community congregates in a few places:
243243
244244
## Contributing
245245
246-
To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).
247-
248-
Most real-time collaboration happens in a variety of channels on the
249-
[Rust Discord server][rust-discord], with channels dedicated for getting help,
250-
community, documentation, and all major contribution areas in the Rust ecosystem.
251-
A good place to ask for help would be the #help channel.
252-
253-
The [rustc dev guide] might be a good place to start if you want to find out how
254-
various parts of the compiler work.
255-
256-
Also, you may find the [rustdocs for the compiler itself][rustdocs] useful.
257-
258-
[rust-discord]: https://discord.gg/rust-lang
259-
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html
260-
[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/
246+
If you are interested in contributing to the Rust project, please take a look
247+
at the [Getting Started][gettingstarted] guide in the [rustc-dev-guide].
261248
262249
## License
263250

src/ci/docker/run.sh

+31-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,27 @@ set -e
55
export MSYS_NO_PATHCONV=1
66

77
script=`cd $(dirname $0) && pwd`/`basename $0`
8-
image=$1
8+
9+
image=""
10+
dev=0
11+
12+
while [[ $# -gt 0 ]]
13+
do
14+
case "$1" in
15+
--dev)
16+
dev=1
17+
;;
18+
*)
19+
if [ -n "$image" ]
20+
then
21+
echo "expected single argument for the image name"
22+
exit 1
23+
fi
24+
image="$1"
25+
;;
26+
esac
27+
shift
28+
done
929

1030
docker_dir="`dirname $script`"
1131
ci_dir="`dirname $docker_dir`"
@@ -163,6 +183,15 @@ else
163183
args="$args --env LOCAL_USER_ID=`id -u`"
164184
fi
165185

186+
if [ "$dev" = "1" ]
187+
then
188+
# Interactive + TTY
189+
args="$args -it"
190+
command="/bin/bash"
191+
else
192+
command="/checkout/src/ci/run.sh"
193+
fi
194+
166195
docker \
167196
run \
168197
--workdir /checkout/obj \
@@ -183,7 +212,7 @@ docker \
183212
--init \
184213
--rm \
185214
rust-ci \
186-
/checkout/src/ci/run.sh
215+
$command
187216

188217
if [ -f /.dockerenv ]; then
189218
rm -rf $objdir

src/ci/docker/test-various/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1717
wget \
1818
patch
1919

20-
RUN curl -sL https://nodejs.org/dist/v9.2.0/node-v9.2.0-linux-x64.tar.xz | \
20+
RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | \
2121
tar -xJ
2222

2323
WORKDIR /build/
@@ -30,7 +30,7 @@ RUN sh /scripts/sccache.sh
3030

3131
ENV RUST_CONFIGURE_ARGS \
3232
--musl-root-x86_64=/usr/local/x86_64-linux-musl \
33-
--set build.nodejs=/node-v9.2.0-linux-x64/bin/node \
33+
--set build.nodejs=/node-v14.4.0-linux-x64/bin/node \
3434
--set rust.lld
3535

3636
# Some run-make tests have assertions about code size, and enabling debug

src/liballoc/tests/btree/map.rs

+1
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ fn test_iter_mixed() {
310310
}
311311

312312
#[test]
313+
#[cfg_attr(miri, ignore)] // FIXME: fails in Miri <https://github.com/rust-lang/rust/issues/73915>
313314
fn test_iter_min_max() {
314315
let mut a = BTreeMap::new();
315316
assert_eq!(a.iter().min(), None);

src/librustc_ast/ast.rs

+3
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ pub struct Block {
511511
pub span: Span,
512512
}
513513

514+
/// A match pattern.
515+
///
516+
/// Patterns appear in match statements and some other contexts, such as `let` and `if let`.
514517
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
515518
pub struct Pat {
516519
pub id: NodeId,

src/librustc_codegen_llvm/builder.rs

+51
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
1818
use rustc_hir::def_id::DefId;
1919
use rustc_middle::ty::layout::TyAndLayout;
2020
use rustc_middle::ty::{self, Ty, TyCtxt};
21+
use rustc_span::sym;
2122
use rustc_target::abi::{self, Align, Size};
2223
use rustc_target::spec::{HasTargetSpec, Target};
2324
use std::borrow::Cow;
@@ -652,6 +653,56 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
652653
unsafe { llvm::LLVMBuildSExt(self.llbuilder, val, dest_ty, UNNAMED) }
653654
}
654655

656+
fn fptoui_sat(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> Option<&'ll Value> {
657+
// WebAssembly has saturating floating point to integer casts if the
658+
// `nontrapping-fptoint` target feature is activated. We'll use those if
659+
// they are available.
660+
if self.sess().target.target.arch == "wasm32"
661+
&& self.sess().target_features.contains(&sym::nontrapping_fptoint)
662+
{
663+
let src_ty = self.cx.val_ty(val);
664+
let float_width = self.cx.float_width(src_ty);
665+
let int_width = self.cx.int_width(dest_ty);
666+
let name = match (int_width, float_width) {
667+
(32, 32) => Some("llvm.wasm.trunc.saturate.unsigned.i32.f32"),
668+
(32, 64) => Some("llvm.wasm.trunc.saturate.unsigned.i32.f64"),
669+
(64, 32) => Some("llvm.wasm.trunc.saturate.unsigned.i64.f32"),
670+
(64, 64) => Some("llvm.wasm.trunc.saturate.unsigned.i64.f64"),
671+
_ => None,
672+
};
673+
if let Some(name) = name {
674+
let intrinsic = self.get_intrinsic(name);
675+
return Some(self.call(intrinsic, &[val], None));
676+
}
677+
}
678+
None
679+
}
680+
681+
fn fptosi_sat(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> Option<&'ll Value> {
682+
// WebAssembly has saturating floating point to integer casts if the
683+
// `nontrapping-fptoint` target feature is activated. We'll use those if
684+
// they are available.
685+
if self.sess().target.target.arch == "wasm32"
686+
&& self.sess().target_features.contains(&sym::nontrapping_fptoint)
687+
{
688+
let src_ty = self.cx.val_ty(val);
689+
let float_width = self.cx.float_width(src_ty);
690+
let int_width = self.cx.int_width(dest_ty);
691+
let name = match (int_width, float_width) {
692+
(32, 32) => Some("llvm.wasm.trunc.saturate.signed.i32.f32"),
693+
(32, 64) => Some("llvm.wasm.trunc.saturate.signed.i32.f64"),
694+
(64, 32) => Some("llvm.wasm.trunc.saturate.signed.i64.f32"),
695+
(64, 64) => Some("llvm.wasm.trunc.saturate.signed.i64.f64"),
696+
_ => None,
697+
};
698+
if let Some(name) = name {
699+
let intrinsic = self.get_intrinsic(name);
700+
return Some(self.call(intrinsic, &[val], None));
701+
}
702+
}
703+
None
704+
}
705+
655706
fn fptoui(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
656707
unsafe { llvm::LLVMBuildFPToUI(self.llbuilder, val, dest_ty, UNNAMED) }
657708
}

src/librustc_codegen_llvm/context.rs

+9
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,15 @@ impl CodegenCx<'b, 'tcx> {
497497
t_v8f64: t_f64, 8;
498498
}
499499

500+
ifn!("llvm.wasm.trunc.saturate.unsigned.i32.f32", fn(t_f32) -> t_i32);
501+
ifn!("llvm.wasm.trunc.saturate.unsigned.i32.f64", fn(t_f64) -> t_i32);
502+
ifn!("llvm.wasm.trunc.saturate.unsigned.i64.f32", fn(t_f32) -> t_i64);
503+
ifn!("llvm.wasm.trunc.saturate.unsigned.i64.f64", fn(t_f64) -> t_i64);
504+
ifn!("llvm.wasm.trunc.saturate.signed.i32.f32", fn(t_f32) -> t_i32);
505+
ifn!("llvm.wasm.trunc.saturate.signed.i32.f64", fn(t_f64) -> t_i32);
506+
ifn!("llvm.wasm.trunc.saturate.signed.i64.f32", fn(t_f32) -> t_i64);
507+
ifn!("llvm.wasm.trunc.saturate.signed.i64.f64", fn(t_f64) -> t_i64);
508+
500509
ifn!("llvm.trap", fn() -> void);
501510
ifn!("llvm.debugtrap", fn() -> void);
502511
ifn!("llvm.frameaddress", fn(t_i32) -> i8p);

src/librustc_codegen_llvm/llvm_util.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,11 @@ const RISCV_WHITELIST: &[(&str, Option<Symbol>)] = &[
250250
("e", Some(sym::riscv_target_feature)),
251251
];
252252

253-
const WASM_WHITELIST: &[(&str, Option<Symbol>)] =
254-
&[("simd128", Some(sym::wasm_target_feature)), ("atomics", Some(sym::wasm_target_feature))];
253+
const WASM_WHITELIST: &[(&str, Option<Symbol>)] = &[
254+
("simd128", Some(sym::wasm_target_feature)),
255+
("atomics", Some(sym::wasm_target_feature)),
256+
("nontrapping-fptoint", Some(sym::wasm_target_feature)),
257+
];
255258

256259
/// When rustdoc is running, provide a list of all known features so that all their respective
257260
/// primitives may be documented.

src/librustc_codegen_ssa/mir/rvalue.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -774,12 +774,17 @@ fn cast_float_to_int<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
774774
float_ty: Bx::Type,
775775
int_ty: Bx::Type,
776776
) -> Bx::Value {
777-
let fptosui_result = if signed { bx.fptosi(x, int_ty) } else { bx.fptoui(x, int_ty) };
778-
779777
if let Some(false) = bx.cx().sess().opts.debugging_opts.saturating_float_casts {
780-
return fptosui_result;
778+
return if signed { bx.fptosi(x, int_ty) } else { bx.fptoui(x, int_ty) };
779+
}
780+
781+
let try_sat_result = if signed { bx.fptosi_sat(x, int_ty) } else { bx.fptoui_sat(x, int_ty) };
782+
if let Some(try_sat_result) = try_sat_result {
783+
return try_sat_result;
781784
}
782785

786+
let fptosui_result = if signed { bx.fptosi(x, int_ty) } else { bx.fptoui(x, int_ty) };
787+
783788
let int_width = bx.cx().int_width(int_ty);
784789
let float_width = bx.cx().float_width(float_ty);
785790
// LLVM's fpto[su]i returns undef when the input x is infinite, NaN, or does not fit into the

src/librustc_codegen_ssa/traits/builder.rs

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ pub trait BuilderMethods<'a, 'tcx>:
158158

159159
fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
160160
fn sext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
161+
fn fptoui_sat(&mut self, val: Self::Value, dest_ty: Self::Type) -> Option<Self::Value>;
162+
fn fptosi_sat(&mut self, val: Self::Value, dest_ty: Self::Type) -> Option<Self::Value>;
161163
fn fptoui(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
162164
fn fptosi(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
163165
fn uitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;

src/librustc_error_codes/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ E0763: include_str!("./error_codes/E0763.md"),
448448
E0764: include_str!("./error_codes/E0764.md"),
449449
E0765: include_str!("./error_codes/E0765.md"),
450450
E0766: include_str!("./error_codes/E0766.md"),
451+
E0767: include_str!("./error_codes/E0767.md"),
451452
;
452453
// E0006, // merged with E0005
453454
// E0008, // cannot bind by-move into a pattern guard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
An unreachable label was used.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0767
6+
'a: loop {
7+
|| {
8+
loop { break 'a } // error: use of unreachable label `'a`
9+
};
10+
}
11+
```
12+
13+
Ensure that the label is within scope. Labels are not reachable through
14+
functions, closures, async blocks or modules. Example:
15+
16+
```
17+
'a: loop {
18+
break 'a; // ok!
19+
}
20+
```

src/librustc_lint/array_into_iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ declare_lint_pass!(
2121
ArrayIntoIter => [ARRAY_INTO_ITER]
2222
);
2323

24-
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIntoIter {
25-
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'tcx>) {
24+
impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
25+
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {
2626
// We only care about method call expressions.
2727
if let hir::ExprKind::MethodCall(call, span, args, _) = &expr.kind {
2828
if call.ident.name != sym::into_iter {

0 commit comments

Comments
 (0)