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

[beta] Rollup backports #58159

Merged
merged 5 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions src/ci/docker/dist-various-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ ENV TARGETS=$TARGETS,armebv7r-none-eabi
ENV TARGETS=$TARGETS,armebv7r-none-eabihf
ENV TARGETS=$TARGETS,armv7r-none-eabi
ENV TARGETS=$TARGETS,armv7r-none-eabihf
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf

ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \
CC_armebv7r_none_eabi=arm-none-eabi-gcc

CC_armebv7r_none_eabi=arm-none-eabi-gcc \
CC_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
AR_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar \
CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++

ENV RUST_CONFIGURE_ARGS \
--musl-root-armv5te=/musl-armv5te \
--musl-root-arm=/musl-arm \
Expand Down
21 changes: 14 additions & 7 deletions src/librustc_mir/build/matches/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,34 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
}

PatternKind::Range(PatternRange { lo, hi, ty, end }) => {
let range = match ty.sty {
let (range, bias) = match ty.sty {
ty::Char => {
Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32)))
(Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0)
}
ty::Int(ity) => {
// FIXME(49937): refactor these bit manipulations into interpret.
let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
let min = 1u128 << (size.bits() - 1);
let max = (1u128 << (size.bits() - 1)) - 1;
Some((min, max, size))
let max = !0u128 >> (128 - size.bits());
let bias = 1u128 << (size.bits() - 1);
(Some((0, max, size)), bias)
}
ty::Uint(uty) => {
// FIXME(49937): refactor these bit manipulations into interpret.
let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size();
let max = !0u128 >> (128 - size.bits());
Some((0, max, size))
(Some((0, max, size)), 0)
}
_ => None,
_ => (None, 0),
};
if let Some((min, max, sz)) = range {
if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) {
// We want to compare ranges numerically, but the order of the bitwise
// representation of signed integers does not match their numeric order.
// Thus, to correct the ordering, we need to shift the range of signed
// integers to correct the comparison. This is achieved by XORing with a
// bias (see pattern/_match.rs for another pertinent example of this
// pattern).
let (lo, hi) = (lo ^ bias, hi ^ bias);
if lo <= min && (hi > max || hi == max && end == RangeEnd::Included) {
// Irrefutable pattern match.
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
if places_conflict::places_conflict(
self.tcx,
self.mir,
place,
&borrow_data.borrowed_place,
place,
places_conflict::PlaceConflictBias::NoOverlap,
) {
debug!(
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
report_unexpected_variant_def(tcx, &def, pat.span, qpath);
return tcx.types.err;
}
Def::VariantCtor(_, CtorKind::Fictive) => {
Def::VariantCtor(_, CtorKind::Fictive) |
Def::VariantCtor(_, CtorKind::Fn) => {
report_unexpected_variant_def(tcx, &def, pat.span, qpath);
return tcx.types.err;
}
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-58006.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(type_alias_enum_variants)]
pub enum Enum {
A(usize),
}

impl Enum {
fn foo(&self) -> () {
match self {
Self::A => (),
//~^ ERROR expected unit struct/variant or constant, found tuple variant
}
}
}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-58006.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0533]: expected unit struct/variant or constant, found tuple variant `<Self>::A`
--> $DIR/issue-58006.rs:9:13
|
LL | Self::A => (),
| ^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0533`.
7 changes: 7 additions & 0 deletions src/test/ui/match-on-negative-integer-ranges.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// run-pass

fn main() {
assert_eq!(false, match -50_i8 { -128i8..=-101i8 => true, _ => false, });

assert_eq!(false, if let -128i8..=-101i8 = -50_i8 { true } else { false });
}
12 changes: 12 additions & 0 deletions src/test/ui/nll/issue-57989.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Test for ICE from issue 57989

#![feature(nll)]

fn f(x: &i32) {
let g = &x;
*x = 0; //~ ERROR cannot assign to `*x` which is behind a `&` reference
//~| ERROR cannot assign to `*x` because it is borrowed
g;
}

fn main() {}
24 changes: 24 additions & 0 deletions src/test/ui/nll/issue-57989.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
error[E0594]: cannot assign to `*x` which is behind a `&` reference
--> $DIR/issue-57989.rs:7:5
|
LL | fn f(x: &i32) {
| ---- help: consider changing this to be a mutable reference: `&mut i32`
LL | let g = &x;
LL | *x = 0; //~ ERROR cannot assign to `*x` which is behind a `&` reference
| ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written

error[E0506]: cannot assign to `*x` because it is borrowed
--> $DIR/issue-57989.rs:7:5
|
LL | let g = &x;
| -- borrow of `*x` occurs here
LL | *x = 0; //~ ERROR cannot assign to `*x` which is behind a `&` reference
| ^^^^^^ assignment to borrowed `*x` occurs here
LL | //~| ERROR cannot assign to `*x` because it is borrowed
LL | g;
| - borrow later used here

error: aborting due to 2 previous errors

Some errors occurred: E0506, E0594.
For more information about an error, try `rustc --explain E0506`.
1 change: 1 addition & 0 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static TARGETS: &'static [&'static str] = &[
"wasm32-unknown-unknown",
"x86_64-apple-darwin",
"x86_64-apple-ios",
"x86_64-fortanix-unknown-sgx",
"x86_64-fuchsia",
"x86_64-linux-android",
"x86_64-pc-windows-gnu",
Expand Down