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

Rollup of 7 pull requests #88168

Closed
wants to merge 15 commits into from
Closed
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
10 changes: 5 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2729,9 +2729,9 @@ dependencies = [

[[package]]
name = "psm"
version = "0.1.11"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96e0536f6528466dbbbbe6b986c34175a8d0ff25b794c4bacda22e068cd2f2c5"
checksum = "0617ee61163b5d941d804065ce49040967610a4d4278fae73e096a057b01d358"
dependencies = [
"cc",
]
Expand Down Expand Up @@ -4810,12 +4810,12 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"

[[package]]
name = "stacker"
version = "0.1.12"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21ccb4c06ec57bc82d0f610f1a2963d7648700e43a6f513e564b9c89f7991786"
checksum = "90939d5171a4420b3ff5fbc8954d641e7377335454c259dcb80786f3f21dc9b4"
dependencies = [
"cc",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"libc",
"psm",
"winapi",
Expand Down
13 changes: 4 additions & 9 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,13 @@ Version 1.54.0 (2021-07-29)
Language
-----------------------

- [You can now use macros for values in built-in attribute macros.][83366]
While a seemingly minor addition on its own, this enables a lot of
powerful functionality when combined correctly. Most notably you can
now include external documentation in your crate by writing the following.
- [You can now use macros for values in some built-in attributes.][83366]
This primarily allows you to call macros within the `#[doc]` attribute. For
example, to include external documentation in your crate, you can now write
the following:
```rust
#![doc = include_str!("README.md")]
```
You can also use this to include auto-generated modules:
```rust
#[path = concat!(env!("OUT_DIR"), "/generated.rs")]
mod generated;
```

- [You can now cast between unsized slice types (and types which contain
unsized slices) in `const fn`.][85078]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rustc_index = { path = "../rustc_index", package = "rustc_index" }
bitflags = "1.2.1"
measureme = "9.1.0"
libc = "0.2"
stacker = "0.1.12"
stacker = "0.1.14"
tempfile = "3.2"

[dependencies.parking_lot]
Expand Down
38 changes: 23 additions & 15 deletions compiler/rustc_mir_build/src/build/matches/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ascription: thir::Ascription { variance, user_ty, user_ty_span },
} => {
// Apply the type ascription to the value at `match_pair.place`, which is the
candidate.ascriptions.push(Ascription {
span: user_ty_span,
user_ty,
source: match_pair.place.clone().into_place(self.tcx, self.typeck_results),
variance,
});
if let Ok(place_resolved) =
match_pair.place.clone().try_upvars_resolved(self.tcx, self.typeck_results)
{
candidate.ascriptions.push(Ascription {
span: user_ty_span,
user_ty,
source: place_resolved.into_place(self.tcx, self.typeck_results),
variance,
});
}

candidate.match_pairs.push(MatchPair::new(match_pair.place, subpattern));

Expand All @@ -173,15 +177,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}

PatKind::Binding { name, mutability, mode, var, ty, ref subpattern, is_primary: _ } => {
candidate.bindings.push(Binding {
name,
mutability,
span: match_pair.pattern.span,
source: match_pair.place.clone().into_place(self.tcx, self.typeck_results),
var_id: var,
var_ty: ty,
binding_mode: mode,
});
if let Ok(place_resolved) =
match_pair.place.clone().try_upvars_resolved(self.tcx, self.typeck_results)
{
candidate.bindings.push(Binding {
name,
mutability,
span: match_pair.pattern.span,
source: place_resolved.into_place(self.tcx, self.typeck_results),
var_id: var,
var_ty: ty,
binding_mode: mode,
});
}

if let Some(subpattern) = subpattern.as_ref() {
// this is the `x @ P` case; have to keep matching against `P` now
Expand Down
21 changes: 13 additions & 8 deletions compiler/rustc_mir_build/src/build/matches/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
suffix: &'pat [Pat<'tcx>],
) {
let tcx = self.tcx;
let (min_length, exact_size) = match place
.clone()
.into_place(tcx, self.typeck_results)
.ty(&self.local_decls, tcx)
.ty
.kind()
let (min_length, exact_size) = if let Ok(place_resolved) =
place.clone().try_upvars_resolved(tcx, self.typeck_results)
{
ty::Array(_, length) => (length.eval_usize(tcx, self.param_env), true),
_ => ((prefix.len() + suffix.len()).try_into().unwrap(), false),
match place_resolved
.into_place(tcx, self.typeck_results)
.ty(&self.local_decls, tcx)
.ty
.kind()
{
ty::Array(_, length) => (length.eval_usize(tcx, self.param_env), true),
_ => ((prefix.len() + suffix.len()).try_into().unwrap(), false),
}
} else {
((prefix.len() + suffix.len()).try_into().unwrap(), false)
};

match_pairs.extend(prefix.iter().enumerate().map(|(idx, subpattern)| {
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
if def.variants.len() > 1 {
needs_to_be_read = true;
}
} else {
// If it is not ty::Adt, then it should be read
needs_to_be_read = true;
}
}
PatKind::Lit(_) | PatKind::Range(..) => {
Expand Down
5 changes: 0 additions & 5 deletions src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ pub fn check(build: &mut Build) {
}

for target in &build.targets {
// Can't compile for iOS unless we're on macOS
if target.contains("apple-ios") && !build.build.contains("apple-darwin") {
panic!("the iOS target is only supported on macOS");
}

build
.config
.target_config
Expand Down
1 change: 1 addition & 0 deletions src/test/codegen/naked-noinline.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Checks that naked functions are never inlined.
// compile-flags: -O -Zmir-opt-level=3
// needs-asm-support
// ignore-wasm32
#![crate_type = "lib"]
#![feature(asm)]
Expand Down
30 changes: 30 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/issue-87987.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// run-pass
// edition:2021

struct Props {
field_1: u32, //~ WARNING: field is never read: `field_1`
field_2: u32, //~ WARNING: field is never read: `field_2`
}

fn main() {
// Test 1
let props_2 = Props { //~ WARNING: unused variable: `props_2`
field_1: 1,
field_2: 1,
};

let _ = || {
let _: Props = props_2;
};

// Test 2
let mut arr = [1, 3, 4, 5];

let mref = &mut arr;

let _c = || match arr {
[_, _, _, _] => println!("A")
};

println!("{:#?}", mref);
}
24 changes: 24 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/issue-87987.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
warning: unused variable: `props_2`
--> $DIR/issue-87987.rs:11:9
|
LL | let props_2 = Props {
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_props_2`
|
= note: `#[warn(unused_variables)]` on by default

warning: field is never read: `field_1`
--> $DIR/issue-87987.rs:5:5
|
LL | field_1: u32,
| ^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default

warning: field is never read: `field_2`
--> $DIR/issue-87987.rs:6:5
|
LL | field_2: u32,
| ^^^^^^^^^^^^

warning: 3 warnings emitted

19 changes: 19 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/issue-87988.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// run-pass
// edition:2021

const LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED: i32 = 0x01;
const LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT: i32 = 0x02;

pub fn hotplug_callback(event: i32) {
let _ = || {
match event {
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED => (),
LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT => (),
_ => (),
};
};
}

fn main() {
hotplug_callback(1);
}
44 changes: 44 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/match-edge-cases.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// run-pass
// edition:2021

const PATTERN_REF: &str = "Hello World";
const NUMBER: i32 = 30;
const NUMBER_POINTER: *const i32 = &NUMBER;

pub fn edge_case_ref(event: &str) {
let _ = || {
match event {
PATTERN_REF => (),
_ => (),
};
};
}

pub fn edge_case_str(event: String) {
let _ = || {
match event.as_str() {
"hello" => (),
_ => (),
};
};
}

pub fn edge_case_raw_ptr(event: *const i32) {
let _ = || {
match event {
NUMBER_POINTER => (),
_ => (),
};
};
}

pub fn edge_case_char(event: char) {
let _ = || {
match event {
'a' => (),
_ => (),
};
};
}

fn main() {}
2 changes: 2 additions & 0 deletions src/test/ui/feature-gates/feature-gate-global_asm.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// needs-asm-support

global_asm!(""); //~ ERROR `global_asm!` is not stable

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-global_asm.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature 'global_asm': `global_asm!` is not stable enough for use and is subject to change
--> $DIR/feature-gate-global_asm.rs:1:1
--> $DIR/feature-gate-global_asm.rs:3:1
|
LL | global_asm!("");
| ^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/macros/macro-expanded-include/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore-emscripten no llvm_asm! support
// needs-asm-support
// build-pass (FIXME(62277): could be check-pass?)
#![feature(asm)]
#![allow(unused)]
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/unsafe/inline_asm.mir.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:9:5
--> $DIR/inline_asm.rs:10:5
|
LL | asm!("nop");
| ^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior

error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:10:5
--> $DIR/inline_asm.rs:11:5
|
LL | llvm_asm!("nop");
| ^^^^^^^^^^^^^^^^^ use of inline assembly
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/unsafe/inline_asm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
// needs-asm-support

#![feature(llvm_asm)]
#![feature(asm)]
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/unsafe/inline_asm.thir.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:9:5
--> $DIR/inline_asm.rs:10:5
|
LL | asm!("nop");
| ^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior

error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/inline_asm.rs:10:5
--> $DIR/inline_asm.rs:11:5
|
LL | llvm_asm!("nop");
| ^^^^^^^^^^^^^^^^^ use of inline assembly
Expand Down
Loading