forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#120390 - matthewjasper:inline-constant-pat-mir, r=davidtwco Borrow check inline const patterns Add type annotations to MIR so that borrowck can pass constraints from inline constants in patterns to the containing function. Also enables some inline constant pattern tests that were fixed by the THIR unsafeck stabilization. cc rust-lang#76001
- Loading branch information
Showing
8 changed files
with
178 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
error[E0597]: `y` does not live long enough | ||
--> $DIR/const-match-pat-lifetime-err.rs:29:29 | ||
| | ||
LL | fn match_invariant_ref<'a>() { | ||
| -- lifetime `'a` defined here | ||
LL | let y = (); | ||
| - binding `y` declared here | ||
LL | match InvariantRef::new(&y) { | ||
| ^^ borrowed value does not live long enough | ||
LL | | ||
LL | const { InvariantRef::<'a>::NEW } => (), | ||
| --------------------------------- type annotation requires that `y` is borrowed for `'a` | ||
LL | } | ||
LL | } | ||
| - `y` dropped here while still borrowed | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/const-match-pat-lifetime-err.rs:39:12 | ||
| | ||
LL | fn match_covariant_ref<'a>() { | ||
| -- lifetime `'a` defined here | ||
... | ||
LL | let y: (CovariantRef<'static, _>,) = (CovariantRef(&()),); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
// ignore-test This is currently broken | ||
|
||
#![allow(incomplete_features)] | ||
#![feature(inline_const_pat)] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block | ||
--> $DIR/pat-unsafe-err.rs:11:13 | ||
| | ||
LL | require_unsafe(); | ||
| ^^^^^^^^^^^^^^^^ call to unsafe function | ||
| | ||
= note: consult the function's documentation for information on how to avoid undefined behavior | ||
|
||
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block | ||
--> $DIR/pat-unsafe-err.rs:18:13 | ||
| | ||
LL | require_unsafe() | ||
| ^^^^^^^^^^^^^^^^ call to unsafe function | ||
| | ||
= note: consult the function's documentation for information on how to avoid undefined behavior | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0133`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
// check-pass | ||
// ignore-test This is currently broken | ||
|
||
#![allow(incomplete_features)] | ||
#![warn(unused_unsafe)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
warning: unnecessary `unsafe` block | ||
--> $DIR/pat-unsafe.rs:16:17 | ||
| | ||
LL | unsafe {} | ||
| ^^^^^^ unnecessary `unsafe` block | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/pat-unsafe.rs:4:9 | ||
| | ||
LL | #![warn(unused_unsafe)] | ||
| ^^^^^^^^^^^^^ | ||
|
||
warning: unnecessary `unsafe` block | ||
--> $DIR/pat-unsafe.rs:23:17 | ||
| | ||
LL | unsafe {} | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
warning: 2 warnings emitted | ||
|