-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
f1b4337
to
9ec1eb2
Compare
This comment has been minimized.
This comment has been minimized.
9ec1eb2
to
d7787bb
Compare
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.
r=me modulo the question below
@@ -148,11 +152,28 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { | |||
ExprKind::Call { fun, ty: _, args: _, from_hir_call: _, fn_span: _ } => { | |||
if self.thir[fun].ty.fn_sig(self.tcx).unsafety() == hir::Unsafety::Unsafe { | |||
self.requires_unsafe(expr.span, CallToUnsafeFunction); | |||
} else if let &ty::FnDef(func_did, _) = self.thir[fun].ty.kind() { |
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
if !tcx.features().target_feature_11 { | |
let mut err = feature_err( | |
&tcx.sess.parse_sess, | |
sym::target_feature_11, | |
attr.span, | |
"`#[target_feature(..)]` can only be applied to `unsafe` functions", | |
); | |
err.span_label(tcx.def_span(id), "not an `unsafe` function"); | |
err.emit(); |
@bors r+ |
📌 Commit d7787bb has been approved by |
…komatsakis Add DerefOfRawPointer and CallToFunctionWith to THIR unsafeck Extends THIR unsafeck to check for two more cases of unsafe operations: dereferences of raw pointers and calls to functions with `#[target_feature]` (RFC 2396). The check for the latter is pretty much copy-pasted from the existing MIR equivalent. This will clash with rust-lang#83842 and rust-lang#85273 which are arguably more important, let's maybe focus on getting those merged first, this can wait. r? `@nikomatsakis` cc rust-lang/project-thir-unsafeck#7
Whoops |
…komatsakis Check for more things in THIR unsafeck Reunion of rust-lang#85306, rust-lang#85381 and rust-lang#85419 with conflicts resolved. r? `@nikomatsakis`
Extends THIR unsafeck to check for two more cases of unsafe operations: dereferences of raw pointers and calls to functions with
#[target_feature]
(RFC 2396). The check for the latter is pretty much copy-pasted from the existing MIR equivalent.This will clash with #83842 and #85273 which are arguably more important, let's maybe focus on getting those merged first, this can wait.
r? @nikomatsakis
cc rust-lang/project-thir-unsafeck#7