Skip to content

Commit b203178

Browse files
committed
Auto merge of #58159 - pietroalbini:beta-backports, r=pietroalbini
[beta] Rollup backports Cherry-picked: * #58008: Pass correct arguments to places_conflict * #58007: Don't panic when accessing enum variant ctor using `Self` in match * #57978: Fix bug in integer range matching * #57862: Build the standard library for thumbv7neon-unknown-linux-gnueabihf in CI * #57659: Fix release manifest generation r? @ghost
2 parents 1045131 + 13542d8 commit b203178

File tree

10 files changed

+91
-11
lines changed

10 files changed

+91
-11
lines changed

src/ci/docker/dist-various-1/Dockerfile

+6-2
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,17 @@ ENV TARGETS=$TARGETS,armebv7r-none-eabi
116116
ENV TARGETS=$TARGETS,armebv7r-none-eabihf
117117
ENV TARGETS=$TARGETS,armv7r-none-eabi
118118
ENV TARGETS=$TARGETS,armv7r-none-eabihf
119+
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf
119120

120121
ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
121122
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
122123
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
123124
CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \
124-
CC_armebv7r_none_eabi=arm-none-eabi-gcc
125-
125+
CC_armebv7r_none_eabi=arm-none-eabi-gcc \
126+
CC_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
127+
AR_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar \
128+
CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
129+
126130
ENV RUST_CONFIGURE_ARGS \
127131
--musl-root-armv5te=/musl-armv5te \
128132
--musl-root-arm=/musl-arm \

src/librustc_mir/build/matches/simplify.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,34 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
106106
}
107107

108108
PatternKind::Range(PatternRange { lo, hi, ty, end }) => {
109-
let range = match ty.sty {
109+
let (range, bias) = match ty.sty {
110110
ty::Char => {
111-
Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32)))
111+
(Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0)
112112
}
113113
ty::Int(ity) => {
114114
// FIXME(49937): refactor these bit manipulations into interpret.
115115
let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
116-
let min = 1u128 << (size.bits() - 1);
117-
let max = (1u128 << (size.bits() - 1)) - 1;
118-
Some((min, max, size))
116+
let max = !0u128 >> (128 - size.bits());
117+
let bias = 1u128 << (size.bits() - 1);
118+
(Some((0, max, size)), bias)
119119
}
120120
ty::Uint(uty) => {
121121
// FIXME(49937): refactor these bit manipulations into interpret.
122122
let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size();
123123
let max = !0u128 >> (128 - size.bits());
124-
Some((0, max, size))
124+
(Some((0, max, size)), 0)
125125
}
126-
_ => None,
126+
_ => (None, 0),
127127
};
128128
if let Some((min, max, sz)) = range {
129129
if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) {
130+
// We want to compare ranges numerically, but the order of the bitwise
131+
// representation of signed integers does not match their numeric order.
132+
// Thus, to correct the ordering, we need to shift the range of signed
133+
// integers to correct the comparison. This is achieved by XORing with a
134+
// bias (see pattern/_match.rs for another pertinent example of this
135+
// pattern).
136+
let (lo, hi) = (lo ^ bias, hi ^ bias);
130137
if lo <= min && (hi > max || hi == max && end == RangeEnd::Included) {
131138
// Irrefutable pattern match.
132139
return Ok(());

src/librustc_mir/dataflow/impls/borrows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
215215
if places_conflict::places_conflict(
216216
self.tcx,
217217
self.mir,
218-
place,
219218
&borrow_data.borrowed_place,
219+
place,
220220
places_conflict::PlaceConflictBias::NoOverlap,
221221
) {
222222
debug!(

src/librustc_typeck/check/_match.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
783783
report_unexpected_variant_def(tcx, &def, pat.span, qpath);
784784
return tcx.types.err;
785785
}
786-
Def::VariantCtor(_, CtorKind::Fictive) => {
786+
Def::VariantCtor(_, CtorKind::Fictive) |
787+
Def::VariantCtor(_, CtorKind::Fn) => {
787788
report_unexpected_variant_def(tcx, &def, pat.span, qpath);
788789
return tcx.types.err;
789790
}

src/test/ui/issues/issue-58006.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(type_alias_enum_variants)]
2+
pub enum Enum {
3+
A(usize),
4+
}
5+
6+
impl Enum {
7+
fn foo(&self) -> () {
8+
match self {
9+
Self::A => (),
10+
//~^ ERROR expected unit struct/variant or constant, found tuple variant
11+
}
12+
}
13+
}
14+
15+
fn main() {}

src/test/ui/issues/issue-58006.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0533]: expected unit struct/variant or constant, found tuple variant `<Self>::A`
2+
--> $DIR/issue-58006.rs:9:13
3+
|
4+
LL | Self::A => (),
5+
| ^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0533`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// run-pass
2+
3+
fn main() {
4+
assert_eq!(false, match -50_i8 { -128i8..=-101i8 => true, _ => false, });
5+
6+
assert_eq!(false, if let -128i8..=-101i8 = -50_i8 { true } else { false });
7+
}

src/test/ui/nll/issue-57989.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Test for ICE from issue 57989
2+
3+
#![feature(nll)]
4+
5+
fn f(x: &i32) {
6+
let g = &x;
7+
*x = 0; //~ ERROR cannot assign to `*x` which is behind a `&` reference
8+
//~| ERROR cannot assign to `*x` because it is borrowed
9+
g;
10+
}
11+
12+
fn main() {}

src/test/ui/nll/issue-57989.stderr

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0594]: cannot assign to `*x` which is behind a `&` reference
2+
--> $DIR/issue-57989.rs:7:5
3+
|
4+
LL | fn f(x: &i32) {
5+
| ---- help: consider changing this to be a mutable reference: `&mut i32`
6+
LL | let g = &x;
7+
LL | *x = 0; //~ ERROR cannot assign to `*x` which is behind a `&` reference
8+
| ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written
9+
10+
error[E0506]: cannot assign to `*x` because it is borrowed
11+
--> $DIR/issue-57989.rs:7:5
12+
|
13+
LL | let g = &x;
14+
| -- borrow of `*x` occurs here
15+
LL | *x = 0; //~ ERROR cannot assign to `*x` which is behind a `&` reference
16+
| ^^^^^^ assignment to borrowed `*x` occurs here
17+
LL | //~| ERROR cannot assign to `*x` because it is borrowed
18+
LL | g;
19+
| - borrow later used here
20+
21+
error: aborting due to 2 previous errors
22+
23+
Some errors occurred: E0506, E0594.
24+
For more information about an error, try `rustc --explain E0506`.

src/tools/build-manifest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static TARGETS: &'static [&'static str] = &[
9595
"wasm32-unknown-unknown",
9696
"x86_64-apple-darwin",
9797
"x86_64-apple-ios",
98+
"x86_64-fortanix-unknown-sgx",
9899
"x86_64-fuchsia",
99100
"x86_64-linux-android",
100101
"x86_64-pc-windows-gnu",

0 commit comments

Comments
 (0)