-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add DerefOfRawPointer and CallToFunctionWith to THIR unsafeck #85306
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion
2
...or/issue-45729-unsafe-in-generator.stderr → ...ssue-45729-unsafe-in-generator.mir.stderr
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Z thir-unsafeck | ||
|
||
#![feature(generators)] | ||
|
||
fn main() { | ||
|
11 changes: 11 additions & 0 deletions
11
src/test/ui/generator/issue-45729-unsafe-in-generator.thir.stderr
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,11 @@ | ||
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block | ||
--> $DIR/issue-45729-unsafe-in-generator.rs:8:9 | ||
| | ||
LL | *(1 as *mut u32) = 42; | ||
| ^^^^^^^^^^^^^^^^ dereference of raw pointer | ||
| | ||
= note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0133`. |
4 changes: 2 additions & 2 deletions
4
src/test/ui/issues/issue-47412.stderr → src/test/ui/issues/issue-47412.mir.stderr
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,11 @@ | ||
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block | ||
--> $DIR/issue-47412.rs:21:11 | ||
| | ||
LL | match *ptr {} | ||
| ^^^^ dereference of raw pointer | ||
| | ||
= note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior | ||
|
||
error: aborting due to previous error | ||
|
||
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
2 changes: 2 additions & 0 deletions
2
src/test/ui/rfcs/rfc-2396-target_feature-11/closures-inherit-target_feature.rs
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
2 changes: 1 addition & 1 deletion
2
.../rfc-2396-target_feature-11/fn-ptr.stderr → ...-2396-target_feature-11/fn-ptr.mir.stderr
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Z thir-unsafeck | ||
// only-x86_64 | ||
|
||
#![feature(target_feature_11)] | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.thir.stderr
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,18 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/fn-ptr.rs:11:21 | ||
| | ||
LL | #[target_feature(enable = "sse2")] | ||
| ---------------------------------- `#[target_feature]` added here | ||
... | ||
LL | let foo: fn() = foo; | ||
| ---- ^^^ cannot coerce functions with `#[target_feature]` to safe function pointers | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected fn pointer `fn()` | ||
found fn item `fn() {foo}` | ||
= note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
20 changes: 10 additions & 10 deletions
20
...-2396-target_feature-11/safe-calls.stderr → ...6-target_feature-11/safe-calls.mir.stderr
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Z thir-unsafeck | ||
// only-x86_64 | ||
|
||
#![feature(target_feature_11)] | ||
|
83 changes: 83 additions & 0 deletions
83
src/test/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr
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,83 @@ | ||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:23:5 | ||
| | ||
LL | sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:24:5 | ||
| | ||
LL | avx_bmi2(); | ||
| ^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:25:5 | ||
| | ||
LL | Quux.avx_bmi2(); | ||
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:30:5 | ||
| | ||
LL | avx_bmi2(); | ||
| ^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:31:5 | ||
| | ||
LL | Quux.avx_bmi2(); | ||
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:36:5 | ||
| | ||
LL | sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:37:5 | ||
| | ||
LL | avx_bmi2(); | ||
| ^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:38:5 | ||
| | ||
LL | Quux.avx_bmi2(); | ||
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:44:5 | ||
| | ||
LL | sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block | ||
--> $DIR/safe-calls.rs:47:18 | ||
| | ||
LL | const name: () = sse2(); | ||
| ^^^^^^ call to function with `#[target_feature]` | ||
| | ||
= note: can only be called if the required target features are available | ||
|
||
error: aborting due to 10 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0133`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as I know, target features 1.1 is not stable #69098 -- is this instability enforced at the declaration site? I guess probably so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the check is here:
rust/compiler/rustc_typeck/src/collect.rs
Lines 2773 to 2781 in 1773f14