Auto merge of #96294 - Emilgardis:def_id-in-unsafetyviolationdetails, r=oli-obk
Display function path in unsafety violations - E0133 adds `DefId` to `UnsafetyViolationDetails` this enables consumers to access the function definition that was reported to be unsafe and also changes the output for some E0133 diagnostics
This commit is contained in:
commit
ec8619dca2
42 changed files with 211 additions and 142 deletions
|
@ -12,6 +12,7 @@ use rustc_index::vec::IndexVec;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::fmt::{self, Debug};
|
use std::fmt::{self, Debug};
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ pub enum UnsafetyViolationKind {
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
|
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
|
||||||
pub enum UnsafetyViolationDetails {
|
pub enum UnsafetyViolationDetails {
|
||||||
CallToUnsafeFunction,
|
CallToUnsafeFunction(Option<DefId>),
|
||||||
UseOfInlineAssembly,
|
UseOfInlineAssembly,
|
||||||
InitializingTypeWith,
|
InitializingTypeWith,
|
||||||
CastOfPointerToInt,
|
CastOfPointerToInt,
|
||||||
|
@ -39,66 +40,95 @@ pub enum UnsafetyViolationDetails {
|
||||||
AccessToUnionField,
|
AccessToUnionField,
|
||||||
MutationOfLayoutConstrainedField,
|
MutationOfLayoutConstrainedField,
|
||||||
BorrowOfLayoutConstrainedField,
|
BorrowOfLayoutConstrainedField,
|
||||||
CallToFunctionWith,
|
CallToFunctionWith(DefId),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnsafetyViolationDetails {
|
impl UnsafetyViolationDetails {
|
||||||
pub fn description_and_note(&self) -> (&'static str, &'static str) {
|
pub fn simple_description(&self) -> &'static str {
|
||||||
|
use UnsafetyViolationDetails::*;
|
||||||
|
|
||||||
|
match self {
|
||||||
|
CallToUnsafeFunction(..) => "call to unsafe function",
|
||||||
|
UseOfInlineAssembly => "use of inline assembly",
|
||||||
|
InitializingTypeWith => "initializing type with `rustc_layout_scalar_valid_range` attr",
|
||||||
|
CastOfPointerToInt => "cast of pointer to int",
|
||||||
|
UseOfMutableStatic => "use of mutable static",
|
||||||
|
UseOfExternStatic => "use of extern static",
|
||||||
|
DerefOfRawPointer => "dereference of raw pointer",
|
||||||
|
AssignToDroppingUnionField => "assignment to union field that might need dropping",
|
||||||
|
AccessToUnionField => "access to union field",
|
||||||
|
MutationOfLayoutConstrainedField => "mutation of layout constrained field",
|
||||||
|
BorrowOfLayoutConstrainedField => {
|
||||||
|
"borrow of layout constrained field with interior mutability"
|
||||||
|
}
|
||||||
|
CallToFunctionWith(..) => "call to function with `#[target_feature]`",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn description_and_note(&self, tcx: TyCtxt<'_>) -> (Cow<'static, str>, &'static str) {
|
||||||
use UnsafetyViolationDetails::*;
|
use UnsafetyViolationDetails::*;
|
||||||
match self {
|
match self {
|
||||||
CallToUnsafeFunction => (
|
CallToUnsafeFunction(did) => (
|
||||||
"call to unsafe function",
|
if let Some(did) = did {
|
||||||
|
Cow::from(format!("call to unsafe function `{}`", tcx.def_path_str(*did)))
|
||||||
|
} else {
|
||||||
|
Cow::Borrowed(self.simple_description())
|
||||||
|
},
|
||||||
"consult the function's documentation for information on how to avoid undefined \
|
"consult the function's documentation for information on how to avoid undefined \
|
||||||
behavior",
|
behavior",
|
||||||
),
|
),
|
||||||
UseOfInlineAssembly => (
|
UseOfInlineAssembly => (
|
||||||
"use of inline assembly",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"inline assembly is entirely unchecked and can cause undefined behavior",
|
"inline assembly is entirely unchecked and can cause undefined behavior",
|
||||||
),
|
),
|
||||||
InitializingTypeWith => (
|
InitializingTypeWith => (
|
||||||
"initializing type with `rustc_layout_scalar_valid_range` attr",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"initializing a layout restricted type's field with a value outside the valid \
|
"initializing a layout restricted type's field with a value outside the valid \
|
||||||
range is undefined behavior",
|
range is undefined behavior",
|
||||||
),
|
),
|
||||||
CastOfPointerToInt => {
|
CastOfPointerToInt => (
|
||||||
("cast of pointer to int", "casting pointers to integers in constants")
|
Cow::Borrowed(self.simple_description()),
|
||||||
}
|
"casting pointers to integers in constants",
|
||||||
|
),
|
||||||
UseOfMutableStatic => (
|
UseOfMutableStatic => (
|
||||||
"use of mutable static",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"mutable statics can be mutated by multiple threads: aliasing violations or data \
|
"mutable statics can be mutated by multiple threads: aliasing violations or data \
|
||||||
races will cause undefined behavior",
|
races will cause undefined behavior",
|
||||||
),
|
),
|
||||||
UseOfExternStatic => (
|
UseOfExternStatic => (
|
||||||
"use of extern static",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"extern statics are not controlled by the Rust type system: invalid data, \
|
"extern statics are not controlled by the Rust type system: invalid data, \
|
||||||
aliasing violations or data races will cause undefined behavior",
|
aliasing violations or data races will cause undefined behavior",
|
||||||
),
|
),
|
||||||
DerefOfRawPointer => (
|
DerefOfRawPointer => (
|
||||||
"dereference of raw pointer",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
|
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
|
||||||
and cause data races: all of these are undefined behavior",
|
and cause data races: all of these are undefined behavior",
|
||||||
),
|
),
|
||||||
AssignToDroppingUnionField => (
|
AssignToDroppingUnionField => (
|
||||||
"assignment to union field that might need dropping",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"the previous content of the field will be dropped, which causes undefined \
|
"the previous content of the field will be dropped, which causes undefined \
|
||||||
behavior if the field was not properly initialized",
|
behavior if the field was not properly initialized",
|
||||||
),
|
),
|
||||||
AccessToUnionField => (
|
AccessToUnionField => (
|
||||||
"access to union field",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"the field may not be properly initialized: using uninitialized data will cause \
|
"the field may not be properly initialized: using uninitialized data will cause \
|
||||||
undefined behavior",
|
undefined behavior",
|
||||||
),
|
),
|
||||||
MutationOfLayoutConstrainedField => (
|
MutationOfLayoutConstrainedField => (
|
||||||
"mutation of layout constrained field",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"mutating layout constrained fields cannot statically be checked for valid values",
|
"mutating layout constrained fields cannot statically be checked for valid values",
|
||||||
),
|
),
|
||||||
BorrowOfLayoutConstrainedField => (
|
BorrowOfLayoutConstrainedField => (
|
||||||
"borrow of layout constrained field with interior mutability",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"references to fields of layout constrained fields lose the constraints. Coupled \
|
"references to fields of layout constrained fields lose the constraints. Coupled \
|
||||||
with interior mutability, the field can be changed to invalid values",
|
with interior mutability, the field can be changed to invalid values",
|
||||||
),
|
),
|
||||||
CallToFunctionWith => (
|
CallToFunctionWith(did) => (
|
||||||
"call to function with `#[target_feature]`",
|
Cow::from(format!(
|
||||||
|
"call to function `{}` with `#[target_feature]`",
|
||||||
|
tcx.def_path_str(*did)
|
||||||
|
)),
|
||||||
"can only be called if the required target features are available",
|
"can only be called if the required target features are available",
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ use rustc_span::def_id::{DefId, LocalDefId};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::ops::Bound;
|
use std::ops::Bound;
|
||||||
|
|
||||||
struct UnsafetyVisitor<'a, 'tcx> {
|
struct UnsafetyVisitor<'a, 'tcx> {
|
||||||
|
@ -70,7 +71,6 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_unsafe(&mut self, span: Span, kind: UnsafeOpKind) {
|
fn requires_unsafe(&mut self, span: Span, kind: UnsafeOpKind) {
|
||||||
let (description, note) = kind.description_and_note();
|
|
||||||
let unsafe_op_in_unsafe_fn_allowed = self.unsafe_op_in_unsafe_fn_allowed();
|
let unsafe_op_in_unsafe_fn_allowed = self.unsafe_op_in_unsafe_fn_allowed();
|
||||||
match self.safety_context {
|
match self.safety_context {
|
||||||
SafetyContext::BuiltinUnsafeBlock => {}
|
SafetyContext::BuiltinUnsafeBlock => {}
|
||||||
|
@ -82,6 +82,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
SafetyContext::UnsafeFn if unsafe_op_in_unsafe_fn_allowed => {}
|
SafetyContext::UnsafeFn if unsafe_op_in_unsafe_fn_allowed => {}
|
||||||
SafetyContext::UnsafeFn => {
|
SafetyContext::UnsafeFn => {
|
||||||
|
let (description, note) = kind.description_and_note(self.tcx);
|
||||||
// unsafe_op_in_unsafe_fn is disallowed
|
// unsafe_op_in_unsafe_fn is disallowed
|
||||||
self.tcx.struct_span_lint_hir(
|
self.tcx.struct_span_lint_hir(
|
||||||
UNSAFE_OP_IN_UNSAFE_FN,
|
UNSAFE_OP_IN_UNSAFE_FN,
|
||||||
|
@ -92,13 +93,14 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
|
||||||
"{} is unsafe and requires unsafe block (error E0133)",
|
"{} is unsafe and requires unsafe block (error E0133)",
|
||||||
description,
|
description,
|
||||||
))
|
))
|
||||||
.span_label(span, description)
|
.span_label(span, kind.simple_description())
|
||||||
.note(note)
|
.note(note)
|
||||||
.emit();
|
.emit();
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
SafetyContext::Safe => {
|
SafetyContext::Safe => {
|
||||||
|
let (description, note) = kind.description_and_note(self.tcx);
|
||||||
let fn_sugg = if unsafe_op_in_unsafe_fn_allowed { " function or" } else { "" };
|
let fn_sugg = if unsafe_op_in_unsafe_fn_allowed { " function or" } else { "" };
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
self.tcx.sess,
|
self.tcx.sess,
|
||||||
|
@ -108,7 +110,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
|
||||||
description,
|
description,
|
||||||
fn_sugg,
|
fn_sugg,
|
||||||
)
|
)
|
||||||
.span_label(span, description)
|
.span_label(span, kind.simple_description())
|
||||||
.note(note)
|
.note(note)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
@ -350,7 +352,12 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
ExprKind::Call { fun, ty: _, args: _, from_hir_call: _, fn_span: _ } => {
|
ExprKind::Call { fun, ty: _, args: _, from_hir_call: _, fn_span: _ } => {
|
||||||
if self.thir[fun].ty.fn_sig(self.tcx).unsafety() == hir::Unsafety::Unsafe {
|
if self.thir[fun].ty.fn_sig(self.tcx).unsafety() == hir::Unsafety::Unsafe {
|
||||||
self.requires_unsafe(expr.span, CallToUnsafeFunction);
|
let func_id = if let ty::FnDef(func_id, _) = self.thir[fun].ty.kind() {
|
||||||
|
Some(*func_id)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
self.requires_unsafe(expr.span, CallToUnsafeFunction(func_id));
|
||||||
} else if let &ty::FnDef(func_did, _) = self.thir[fun].ty.kind() {
|
} else if let &ty::FnDef(func_did, _) = self.thir[fun].ty.kind() {
|
||||||
// If the called function has target features the calling function hasn't,
|
// If the called function has target features the calling function hasn't,
|
||||||
// the call requires `unsafe`. Don't check this on wasm
|
// the call requires `unsafe`. Don't check this on wasm
|
||||||
|
@ -364,7 +371,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
||||||
.iter()
|
.iter()
|
||||||
.all(|feature| self.body_target_features.contains(feature))
|
.all(|feature| self.body_target_features.contains(feature))
|
||||||
{
|
{
|
||||||
self.requires_unsafe(expr.span, CallToFunctionWith);
|
self.requires_unsafe(expr.span, CallToFunctionWith(func_did));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,7 +530,7 @@ impl BodyUnsafety {
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
enum UnsafeOpKind {
|
enum UnsafeOpKind {
|
||||||
CallToUnsafeFunction,
|
CallToUnsafeFunction(Option<DefId>),
|
||||||
UseOfInlineAssembly,
|
UseOfInlineAssembly,
|
||||||
InitializingTypeWith,
|
InitializingTypeWith,
|
||||||
UseOfMutableStatic,
|
UseOfMutableStatic,
|
||||||
|
@ -533,64 +540,89 @@ enum UnsafeOpKind {
|
||||||
AccessToUnionField,
|
AccessToUnionField,
|
||||||
MutationOfLayoutConstrainedField,
|
MutationOfLayoutConstrainedField,
|
||||||
BorrowOfLayoutConstrainedField,
|
BorrowOfLayoutConstrainedField,
|
||||||
CallToFunctionWith,
|
CallToFunctionWith(DefId),
|
||||||
}
|
}
|
||||||
|
|
||||||
use UnsafeOpKind::*;
|
use UnsafeOpKind::*;
|
||||||
|
|
||||||
impl UnsafeOpKind {
|
impl UnsafeOpKind {
|
||||||
pub fn description_and_note(&self) -> (&'static str, &'static str) {
|
pub fn simple_description(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
CallToUnsafeFunction => (
|
CallToUnsafeFunction(..) => "call to unsafe function",
|
||||||
"call to unsafe function",
|
UseOfInlineAssembly => "use of inline assembly",
|
||||||
|
InitializingTypeWith => "initializing type with `rustc_layout_scalar_valid_range` attr",
|
||||||
|
UseOfMutableStatic => "use of mutable static",
|
||||||
|
UseOfExternStatic => "use of extern static",
|
||||||
|
DerefOfRawPointer => "dereference of raw pointer",
|
||||||
|
AssignToDroppingUnionField => "assignment to union field that might need dropping",
|
||||||
|
AccessToUnionField => "access to union field",
|
||||||
|
MutationOfLayoutConstrainedField => "mutation of layout constrained field",
|
||||||
|
BorrowOfLayoutConstrainedField => {
|
||||||
|
"borrow of layout constrained field with interior mutability"
|
||||||
|
}
|
||||||
|
CallToFunctionWith(..) => "call to function with `#[target_feature]`",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn description_and_note(&self, tcx: TyCtxt<'_>) -> (Cow<'static, str>, &'static str) {
|
||||||
|
match self {
|
||||||
|
CallToUnsafeFunction(did) => (
|
||||||
|
if let Some(did) = did {
|
||||||
|
Cow::from(format!("call to unsafe function `{}`", tcx.def_path_str(*did)))
|
||||||
|
} else {
|
||||||
|
Cow::Borrowed(self.simple_description())
|
||||||
|
},
|
||||||
"consult the function's documentation for information on how to avoid undefined \
|
"consult the function's documentation for information on how to avoid undefined \
|
||||||
behavior",
|
behavior",
|
||||||
),
|
),
|
||||||
UseOfInlineAssembly => (
|
UseOfInlineAssembly => (
|
||||||
"use of inline assembly",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"inline assembly is entirely unchecked and can cause undefined behavior",
|
"inline assembly is entirely unchecked and can cause undefined behavior",
|
||||||
),
|
),
|
||||||
InitializingTypeWith => (
|
InitializingTypeWith => (
|
||||||
"initializing type with `rustc_layout_scalar_valid_range` attr",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"initializing a layout restricted type's field with a value outside the valid \
|
"initializing a layout restricted type's field with a value outside the valid \
|
||||||
range is undefined behavior",
|
range is undefined behavior",
|
||||||
),
|
),
|
||||||
UseOfMutableStatic => (
|
UseOfMutableStatic => (
|
||||||
"use of mutable static",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"mutable statics can be mutated by multiple threads: aliasing violations or data \
|
"mutable statics can be mutated by multiple threads: aliasing violations or data \
|
||||||
races will cause undefined behavior",
|
races will cause undefined behavior",
|
||||||
),
|
),
|
||||||
UseOfExternStatic => (
|
UseOfExternStatic => (
|
||||||
"use of extern static",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"extern statics are not controlled by the Rust type system: invalid data, \
|
"extern statics are not controlled by the Rust type system: invalid data, \
|
||||||
aliasing violations or data races will cause undefined behavior",
|
aliasing violations or data races will cause undefined behavior",
|
||||||
),
|
),
|
||||||
DerefOfRawPointer => (
|
DerefOfRawPointer => (
|
||||||
"dereference of raw pointer",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
|
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
|
||||||
and cause data races: all of these are undefined behavior",
|
and cause data races: all of these are undefined behavior",
|
||||||
),
|
),
|
||||||
AssignToDroppingUnionField => (
|
AssignToDroppingUnionField => (
|
||||||
"assignment to union field that might need dropping",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"the previous content of the field will be dropped, which causes undefined \
|
"the previous content of the field will be dropped, which causes undefined \
|
||||||
behavior if the field was not properly initialized",
|
behavior if the field was not properly initialized",
|
||||||
),
|
),
|
||||||
AccessToUnionField => (
|
AccessToUnionField => (
|
||||||
"access to union field",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"the field may not be properly initialized: using uninitialized data will cause \
|
"the field may not be properly initialized: using uninitialized data will cause \
|
||||||
undefined behavior",
|
undefined behavior",
|
||||||
),
|
),
|
||||||
MutationOfLayoutConstrainedField => (
|
MutationOfLayoutConstrainedField => (
|
||||||
"mutation of layout constrained field",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"mutating layout constrained fields cannot statically be checked for valid values",
|
"mutating layout constrained fields cannot statically be checked for valid values",
|
||||||
),
|
),
|
||||||
BorrowOfLayoutConstrainedField => (
|
BorrowOfLayoutConstrainedField => (
|
||||||
"borrow of layout constrained field with interior mutability",
|
Cow::Borrowed(self.simple_description()),
|
||||||
"references to fields of layout constrained fields lose the constraints. Coupled \
|
"references to fields of layout constrained fields lose the constraints. Coupled \
|
||||||
with interior mutability, the field can be changed to invalid values",
|
with interior mutability, the field can be changed to invalid values",
|
||||||
),
|
),
|
||||||
CallToFunctionWith => (
|
CallToFunctionWith(did) => (
|
||||||
"call to function with `#[target_feature]`",
|
Cow::from(format!(
|
||||||
|
"call to function `{}` with `#[target_feature]`",
|
||||||
|
tcx.def_path_str(*did)
|
||||||
|
)),
|
||||||
"can only be called if the required target features are available",
|
"can only be called if the required target features are available",
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,15 +70,17 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
|
||||||
|
|
||||||
TerminatorKind::Call { ref func, .. } => {
|
TerminatorKind::Call { ref func, .. } => {
|
||||||
let func_ty = func.ty(self.body, self.tcx);
|
let func_ty = func.ty(self.body, self.tcx);
|
||||||
|
let func_id =
|
||||||
|
if let ty::FnDef(func_id, _) = func_ty.kind() { Some(func_id) } else { None };
|
||||||
let sig = func_ty.fn_sig(self.tcx);
|
let sig = func_ty.fn_sig(self.tcx);
|
||||||
if let hir::Unsafety::Unsafe = sig.unsafety() {
|
if let hir::Unsafety::Unsafe = sig.unsafety() {
|
||||||
self.require_unsafe(
|
self.require_unsafe(
|
||||||
UnsafetyViolationKind::General,
|
UnsafetyViolationKind::General,
|
||||||
UnsafetyViolationDetails::CallToUnsafeFunction,
|
UnsafetyViolationDetails::CallToUnsafeFunction(func_id.copied()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ty::FnDef(func_id, _) = func_ty.kind() {
|
if let Some(func_id) = func_id {
|
||||||
self.check_target_features(*func_id);
|
self.check_target_features(*func_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,7 +381,7 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
|
||||||
if !callee_features.iter().all(|feature| self_features.contains(feature)) {
|
if !callee_features.iter().all(|feature| self_features.contains(feature)) {
|
||||||
self.require_unsafe(
|
self.require_unsafe(
|
||||||
UnsafetyViolationKind::General,
|
UnsafetyViolationKind::General,
|
||||||
UnsafetyViolationDetails::CallToFunctionWith,
|
UnsafetyViolationDetails::CallToFunctionWith(func_did),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,7 +580,8 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
let UnsafetyCheckResult { violations, unused_unsafes, .. } = tcx.unsafety_check_result(def_id);
|
let UnsafetyCheckResult { violations, unused_unsafes, .. } = tcx.unsafety_check_result(def_id);
|
||||||
|
|
||||||
for &UnsafetyViolation { source_info, lint_root, kind, details } in violations.iter() {
|
for &UnsafetyViolation { source_info, lint_root, kind, details } in violations.iter() {
|
||||||
let (description, note) = details.description_and_note();
|
let (description, note) =
|
||||||
|
ty::print::with_no_trimmed_paths!(details.description_and_note(tcx));
|
||||||
|
|
||||||
// Report an error.
|
// Report an error.
|
||||||
let unsafe_fn_msg =
|
let unsafe_fn_msg =
|
||||||
|
@ -595,7 +598,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
description,
|
description,
|
||||||
unsafe_fn_msg,
|
unsafe_fn_msg,
|
||||||
)
|
)
|
||||||
.span_label(source_info.span, description)
|
.span_label(source_info.span, details.simple_description())
|
||||||
.note(note)
|
.note(note)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
|
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
|
||||||
|
|
|
|
||||||
LL | S::f();
|
LL | S::f();
|
||||||
|
@ -6,7 +6,7 @@ LL | S::f();
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
|
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
|
||||||
|
|
|
|
||||||
LL | f();
|
LL | f();
|
||||||
|
@ -14,7 +14,7 @@ LL | f();
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
|
--> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
|
||||||
|
|
|
|
||||||
LL | S::f();
|
LL | S::f();
|
||||||
|
@ -22,7 +22,7 @@ LL | S::f();
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
|
--> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
|
||||||
|
|
|
|
||||||
LL | f();
|
LL | f();
|
||||||
|
|
|
@ -11,11 +11,11 @@ impl S {
|
||||||
async unsafe fn f() {}
|
async unsafe fn f() {}
|
||||||
|
|
||||||
async fn g() {
|
async fn g() {
|
||||||
S::f(); //~ ERROR call to unsafe function is unsafe
|
S::f(); //~ ERROR call to unsafe function `S::f` is unsafe
|
||||||
f(); //~ ERROR call to unsafe function is unsafe
|
f(); //~ ERROR call to unsafe function `f` is unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
S::f(); //[mir]~ ERROR call to unsafe function is unsafe
|
S::f(); //[mir]~ ERROR call to unsafe function `S::f` is unsafe
|
||||||
f(); //[mir]~ ERROR call to unsafe function is unsafe
|
f(); //[mir]~ ERROR call to unsafe function `f` is unsafe
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
|
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
|
||||||
|
|
|
|
||||||
LL | S::f();
|
LL | S::f();
|
||||||
|
@ -6,7 +6,7 @@ LL | S::f();
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
|
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
|
||||||
|
|
|
|
||||||
LL | f();
|
LL | f();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::pin::Pin::<P>::new_unchecked` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
|
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
|
||||||
|
|
|
|
||||||
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
|
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `Pin::<P>::new_unchecked` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
|
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
|
||||||
|
|
|
|
||||||
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
|
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/const-extern-fn-requires-unsafe.rs:9:17
|
--> $DIR/const-extern-fn-requires-unsafe.rs:9:17
|
||||||
|
|
|
|
||||||
LL | let a: [u8; foo()];
|
LL | let a: [u8; foo()];
|
||||||
|
@ -6,7 +6,7 @@ LL | let a: [u8; foo()];
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/const-extern-fn-requires-unsafe.rs:11:5
|
--> $DIR/const-extern-fn-requires-unsafe.rs:11:5
|
||||||
|
|
|
|
||||||
LL | foo();
|
LL | foo();
|
||||||
|
|
|
@ -7,7 +7,7 @@ const unsafe extern "C" fn foo() -> usize { 5 }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: [u8; foo()];
|
let a: [u8; foo()];
|
||||||
//~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
|
//~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
|
||||||
foo();
|
foo();
|
||||||
//[mir]~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
|
//[mir]~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/const-extern-fn-requires-unsafe.rs:9:17
|
--> $DIR/const-extern-fn-requires-unsafe.rs:9:17
|
||||||
|
|
|
|
||||||
LL | let a: [u8; foo()];
|
LL | let a: [u8; foo()];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/E0133.rs:7:5
|
--> $DIR/E0133.rs:7:5
|
||||||
|
|
|
|
||||||
LL | f();
|
LL | f();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/E0133.rs:7:5
|
--> $DIR/E0133.rs:7:5
|
||||||
|
|
|
|
||||||
LL | f();
|
LL | f();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `test::free` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/foreign-unsafe-fn-called.rs:11:5
|
--> $DIR/foreign-unsafe-fn-called.rs:11:5
|
||||||
|
|
|
|
||||||
LL | test::free();
|
LL | test::free();
|
||||||
|
|
|
@ -9,5 +9,5 @@ mod test {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
test::free();
|
test::free();
|
||||||
//~^ ERROR call to unsafe function is unsafe
|
//~^ ERROR call to unsafe function `test::free` is unsafe
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `test::free` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/foreign-unsafe-fn-called.rs:11:5
|
--> $DIR/foreign-unsafe-fn-called.rs:11:5
|
||||||
|
|
|
|
||||||
LL | test::free();
|
LL | test::free();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::intrinsics::unchecked_add` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unchecked_math_unsafe.rs:8:15
|
--> $DIR/unchecked_math_unsafe.rs:8:15
|
||||||
|
|
|
|
||||||
LL | let add = std::intrinsics::unchecked_add(x, y);
|
LL | let add = std::intrinsics::unchecked_add(x, y);
|
||||||
|
@ -6,7 +6,7 @@ LL | let add = std::intrinsics::unchecked_add(x, y);
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::intrinsics::unchecked_sub` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unchecked_math_unsafe.rs:9:15
|
--> $DIR/unchecked_math_unsafe.rs:9:15
|
||||||
|
|
|
|
||||||
LL | let sub = std::intrinsics::unchecked_sub(x, y);
|
LL | let sub = std::intrinsics::unchecked_sub(x, y);
|
||||||
|
@ -14,7 +14,7 @@ LL | let sub = std::intrinsics::unchecked_sub(x, y);
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::intrinsics::unchecked_mul` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unchecked_math_unsafe.rs:10:15
|
--> $DIR/unchecked_math_unsafe.rs:10:15
|
||||||
|
|
|
|
||||||
LL | let mul = std::intrinsics::unchecked_mul(x, y);
|
LL | let mul = std::intrinsics::unchecked_mul(x, y);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `unchecked_add` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unchecked_math_unsafe.rs:8:15
|
--> $DIR/unchecked_math_unsafe.rs:8:15
|
||||||
|
|
|
|
||||||
LL | let add = std::intrinsics::unchecked_add(x, y);
|
LL | let add = std::intrinsics::unchecked_add(x, y);
|
||||||
|
@ -6,7 +6,7 @@ LL | let add = std::intrinsics::unchecked_add(x, y);
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `unchecked_sub` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unchecked_math_unsafe.rs:9:15
|
--> $DIR/unchecked_math_unsafe.rs:9:15
|
||||||
|
|
|
|
||||||
LL | let sub = std::intrinsics::unchecked_sub(x, y);
|
LL | let sub = std::intrinsics::unchecked_sub(x, y);
|
||||||
|
@ -14,7 +14,7 @@ LL | let sub = std::intrinsics::unchecked_sub(x, y);
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `unchecked_mul` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unchecked_math_unsafe.rs:10:15
|
--> $DIR/unchecked_math_unsafe.rs:10:15
|
||||||
|
|
|
|
||||||
LL | let mul = std::intrinsics::unchecked_mul(x, y);
|
LL | let mul = std::intrinsics::unchecked_mul(x, y);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::ptr::write` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-28776.rs:7:5
|
--> $DIR/issue-28776.rs:7:5
|
||||||
|
|
|
|
||||||
LL | (&ptr::write)(1 as *mut _, 42);
|
LL | (&ptr::write)(1 as *mut _, 42);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::ptr::write` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-28776.rs:7:5
|
--> $DIR/issue-28776.rs:7:5
|
||||||
|
|
|
|
||||||
LL | (&ptr::write)(1 as *mut _, 42);
|
LL | (&ptr::write)(1 as *mut _, 42);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `X::with` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-3080.rs:10:5
|
--> $DIR/issue-3080.rs:10:5
|
||||||
|
|
|
|
||||||
LL | X(()).with();
|
LL | X(()).with();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `X::with` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-3080.rs:10:5
|
--> $DIR/issue-3080.rs:10:5
|
||||||
|
|
|
|
||||||
LL | X(()).with();
|
LL | X(()).with();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `issue_5844_aux::rand` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-5844.rs:8:5
|
--> $DIR/issue-5844.rs:8:5
|
||||||
|
|
|
|
||||||
LL | issue_5844_aux::rand();
|
LL | issue_5844_aux::rand();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-5844.rs:8:5
|
--> $DIR/issue-5844.rs:8:5
|
||||||
|
|
|
|
||||||
LL | issue_5844_aux::rand();
|
LL | issue_5844_aux::rand();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:23:5
|
--> $DIR/safe-calls.rs:23:5
|
||||||
|
|
|
|
||||||
LL | sse2();
|
LL | sse2();
|
||||||
|
@ -6,7 +6,7 @@ LL | sse2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:24:5
|
--> $DIR/safe-calls.rs:24:5
|
||||||
|
|
|
|
||||||
LL | avx_bmi2();
|
LL | avx_bmi2();
|
||||||
|
@ -14,7 +14,7 @@ LL | avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:25:5
|
--> $DIR/safe-calls.rs:25:5
|
||||||
|
|
|
|
||||||
LL | Quux.avx_bmi2();
|
LL | Quux.avx_bmi2();
|
||||||
|
@ -22,7 +22,7 @@ LL | Quux.avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:30:5
|
--> $DIR/safe-calls.rs:30:5
|
||||||
|
|
|
|
||||||
LL | avx_bmi2();
|
LL | avx_bmi2();
|
||||||
|
@ -30,7 +30,7 @@ LL | avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:31:5
|
--> $DIR/safe-calls.rs:31:5
|
||||||
|
|
|
|
||||||
LL | Quux.avx_bmi2();
|
LL | Quux.avx_bmi2();
|
||||||
|
@ -38,7 +38,7 @@ LL | Quux.avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:36:5
|
--> $DIR/safe-calls.rs:36:5
|
||||||
|
|
|
|
||||||
LL | sse2();
|
LL | sse2();
|
||||||
|
@ -46,7 +46,7 @@ LL | sse2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:37:5
|
--> $DIR/safe-calls.rs:37:5
|
||||||
|
|
|
|
||||||
LL | avx_bmi2();
|
LL | avx_bmi2();
|
||||||
|
@ -54,7 +54,7 @@ LL | avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:38:5
|
--> $DIR/safe-calls.rs:38:5
|
||||||
|
|
|
|
||||||
LL | Quux.avx_bmi2();
|
LL | Quux.avx_bmi2();
|
||||||
|
@ -62,7 +62,7 @@ LL | Quux.avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:44:5
|
--> $DIR/safe-calls.rs:44:5
|
||||||
|
|
|
|
||||||
LL | sse2();
|
LL | sse2();
|
||||||
|
@ -70,7 +70,7 @@ LL | sse2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:47:18
|
--> $DIR/safe-calls.rs:47:18
|
||||||
|
|
|
|
||||||
LL | const name: () = sse2();
|
LL | const name: () = sse2();
|
||||||
|
|
|
@ -20,30 +20,30 @@ impl Quux {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo() {
|
fn foo() {
|
||||||
sse2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
sse2(); //~ ERROR call to function `sse2` with `#[target_feature]` is unsafe
|
||||||
avx_bmi2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
avx_bmi2(); //~ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
|
||||||
Quux.avx_bmi2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
Quux.avx_bmi2(); //~ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
#[target_feature(enable = "sse2")]
|
#[target_feature(enable = "sse2")]
|
||||||
fn bar() {
|
fn bar() {
|
||||||
avx_bmi2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
avx_bmi2(); //~ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
|
||||||
Quux.avx_bmi2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
Quux.avx_bmi2(); //~ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
#[target_feature(enable = "avx")]
|
#[target_feature(enable = "avx")]
|
||||||
fn baz() {
|
fn baz() {
|
||||||
sse2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
sse2(); //~ ERROR call to function `sse2` with `#[target_feature]` is unsafe
|
||||||
avx_bmi2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
avx_bmi2(); //~ ERROR call to function `avx_bmi2` with `#[target_feature]` is unsafe
|
||||||
Quux.avx_bmi2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
Quux.avx_bmi2(); //~ ERROR call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
#[target_feature(enable = "avx")]
|
#[target_feature(enable = "avx")]
|
||||||
#[target_feature(enable = "bmi2")]
|
#[target_feature(enable = "bmi2")]
|
||||||
fn qux() {
|
fn qux() {
|
||||||
sse2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
sse2(); //~ ERROR call to function `sse2` with `#[target_feature]` is unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
const name: () = sse2(); //~ ERROR call to function with `#[target_feature]` is unsafe
|
const name: () = sse2(); //~ ERROR call to function `sse2` with `#[target_feature]` is unsafe
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:23:5
|
--> $DIR/safe-calls.rs:23:5
|
||||||
|
|
|
|
||||||
LL | sse2();
|
LL | sse2();
|
||||||
|
@ -6,7 +6,7 @@ LL | sse2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:24:5
|
--> $DIR/safe-calls.rs:24:5
|
||||||
|
|
|
|
||||||
LL | avx_bmi2();
|
LL | avx_bmi2();
|
||||||
|
@ -14,7 +14,7 @@ LL | avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:25:5
|
--> $DIR/safe-calls.rs:25:5
|
||||||
|
|
|
|
||||||
LL | Quux.avx_bmi2();
|
LL | Quux.avx_bmi2();
|
||||||
|
@ -22,7 +22,7 @@ LL | Quux.avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:30:5
|
--> $DIR/safe-calls.rs:30:5
|
||||||
|
|
|
|
||||||
LL | avx_bmi2();
|
LL | avx_bmi2();
|
||||||
|
@ -30,7 +30,7 @@ LL | avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:31:5
|
--> $DIR/safe-calls.rs:31:5
|
||||||
|
|
|
|
||||||
LL | Quux.avx_bmi2();
|
LL | Quux.avx_bmi2();
|
||||||
|
@ -38,7 +38,7 @@ LL | Quux.avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:36:5
|
--> $DIR/safe-calls.rs:36:5
|
||||||
|
|
|
|
||||||
LL | sse2();
|
LL | sse2();
|
||||||
|
@ -46,7 +46,7 @@ LL | sse2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:37:5
|
--> $DIR/safe-calls.rs:37:5
|
||||||
|
|
|
|
||||||
LL | avx_bmi2();
|
LL | avx_bmi2();
|
||||||
|
@ -54,7 +54,7 @@ LL | avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:38:5
|
--> $DIR/safe-calls.rs:38:5
|
||||||
|
|
|
|
||||||
LL | Quux.avx_bmi2();
|
LL | Quux.avx_bmi2();
|
||||||
|
@ -62,7 +62,7 @@ LL | Quux.avx_bmi2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:44:5
|
--> $DIR/safe-calls.rs:44:5
|
||||||
|
|
|
|
||||||
LL | sse2();
|
LL | sse2();
|
||||||
|
@ -70,7 +70,7 @@ LL | sse2();
|
||||||
|
|
|
|
||||||
= note: can only be called if the required target features are available
|
= 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
|
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/safe-calls.rs:47:18
|
--> $DIR/safe-calls.rs:47:18
|
||||||
|
|
|
|
||||||
LL | const name: () = sse2();
|
LL | const name: () = sse2();
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::thread::$LOCALKEYINNER::<T>::get` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-43733.rs:19:5
|
--> $DIR/issue-43733.rs:21:5
|
||||||
|
|
|
|
||||||
LL | __KEY.get(Default::default)
|
LL | __KEY.get(Default::default)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `std::thread::LocalKey::<T>::new` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-43733.rs:22:42
|
--> $DIR/issue-43733.rs:26:42
|
||||||
|
|
|
|
||||||
LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
|
LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// revisions: mir thir
|
// revisions: mir thir
|
||||||
// [thir]compile-flags: -Z thir-unsafeck
|
// [thir]compile-flags: -Z thir-unsafeck
|
||||||
|
// normalize-stderr-test: "__FastLocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get"
|
||||||
|
// normalize-stderr-test: "__OsLocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get"
|
||||||
|
|
||||||
#![feature(thread_local)]
|
#![feature(thread_local)]
|
||||||
#![feature(cfg_target_thread_local, thread_local_internals)]
|
#![feature(cfg_target_thread_local, thread_local_internals)]
|
||||||
|
@ -16,11 +18,14 @@ static __KEY: std::thread::__FastLocalKeyInner<Foo> = std::thread::__FastLocalKe
|
||||||
static __KEY: std::thread::__OsLocalKeyInner<Foo> = std::thread::__OsLocalKeyInner::new();
|
static __KEY: std::thread::__OsLocalKeyInner<Foo> = std::thread::__OsLocalKeyInner::new();
|
||||||
|
|
||||||
fn __getit(_: Option<&mut Option<RefCell<String>>>) -> std::option::Option<&'static Foo> {
|
fn __getit(_: Option<&mut Option<RefCell<String>>>) -> std::option::Option<&'static Foo> {
|
||||||
__KEY.get(Default::default) //~ ERROR call to unsafe function is unsafe
|
__KEY.get(Default::default)
|
||||||
|
//[mir]~^ ERROR call to unsafe function `std::thread::
|
||||||
|
//[thir]~^^ ERROR call to unsafe function `__
|
||||||
}
|
}
|
||||||
|
|
||||||
static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
|
static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
|
||||||
//~^ ERROR call to unsafe function is unsafe
|
//[mir]~^ ERROR call to unsafe function `std::thread::LocalKey::<T>::new` is unsafe
|
||||||
|
//[thir]~^^ ERROR call to unsafe function `LocalKey::<T>::new` is unsafe
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
FOO.with(|foo| println!("{}", foo.borrow()));
|
FOO.with(|foo| println!("{}", foo.borrow()));
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `$LOCALKEYINNER::<T>::get` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-43733.rs:19:5
|
--> $DIR/issue-43733.rs:21:5
|
||||||
|
|
|
|
||||||
LL | __KEY.get(Default::default)
|
LL | __KEY.get(Default::default)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `LocalKey::<T>::new` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/issue-43733.rs:22:42
|
--> $DIR/issue-43733.rs:26:42
|
||||||
|
|
|
|
||||||
LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
|
LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
// no-prefer-dynamic
|
// no-prefer-dynamic
|
||||||
// ignore-emscripten no threads support
|
// ignore-emscripten no threads support
|
||||||
|
|
||||||
static mut HIT: bool = false;
|
static mut HIT: bool = false;
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: call to unsafe function is unsafe and requires unsafe block (error E0133)
|
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:12:5
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:12:5
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
| ^^^^^^ call to unsafe function
|
| ^^^^^^ call to unsafe function `unsf`
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:4:9
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:4:9
|
||||||
|
@ -39,11 +39,11 @@ note: the lint level is defined here
|
||||||
LL | #![deny(unused_unsafe)]
|
LL | #![deny(unused_unsafe)]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: call to unsafe function is unsafe and requires unsafe block (error E0133)
|
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:27:5
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:27:5
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
| ^^^^^^ call to unsafe function
|
| ^^^^^^ call to unsafe function `unsf`
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:25:8
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:25:8
|
||||||
|
@ -113,7 +113,7 @@ note: the lint level is defined here
|
||||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe block
|
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:76:5
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:76:5
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
|
@ -121,7 +121,7 @@ LL | unsf();
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:80:9
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:80:9
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
|
|
|
@ -10,7 +10,7 @@ static mut VOID: () = ();
|
||||||
|
|
||||||
unsafe fn deny_level() {
|
unsafe fn deny_level() {
|
||||||
unsf();
|
unsf();
|
||||||
//~^ ERROR call to unsafe function is unsafe and requires unsafe block
|
//~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe block
|
||||||
*PTR;
|
*PTR;
|
||||||
//~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
|
//~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
|
||||||
VOID = ();
|
VOID = ();
|
||||||
|
@ -25,7 +25,7 @@ unsafe fn deny_level() {
|
||||||
#[deny(warnings)]
|
#[deny(warnings)]
|
||||||
unsafe fn warning_level() {
|
unsafe fn warning_level() {
|
||||||
unsf();
|
unsf();
|
||||||
//~^ ERROR call to unsafe function is unsafe and requires unsafe block
|
//~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe block
|
||||||
*PTR;
|
*PTR;
|
||||||
//~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
|
//~^ ERROR dereference of raw pointer is unsafe and requires unsafe block
|
||||||
VOID = ();
|
VOID = ();
|
||||||
|
@ -74,10 +74,10 @@ unsafe fn nested_allow_level() {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsf();
|
unsf();
|
||||||
//~^ ERROR call to unsafe function is unsafe and requires unsafe block
|
//~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe block
|
||||||
#[allow(unsafe_op_in_unsafe_fn)]
|
#[allow(unsafe_op_in_unsafe_fn)]
|
||||||
{
|
{
|
||||||
unsf();
|
unsf();
|
||||||
//~^ ERROR call to unsafe function is unsafe and requires unsafe function or block
|
//~^ ERROR call to unsafe function `unsf` is unsafe and requires unsafe function or block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: call to unsafe function is unsafe and requires unsafe block (error E0133)
|
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:12:5
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:12:5
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
|
@ -39,7 +39,7 @@ note: the lint level is defined here
|
||||||
LL | #![deny(unused_unsafe)]
|
LL | #![deny(unused_unsafe)]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: call to unsafe function is unsafe and requires unsafe block (error E0133)
|
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:27:5
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:27:5
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
|
@ -101,7 +101,7 @@ LL | unsafe fn nested_allow_level() {
|
||||||
LL | unsafe { unsf() }
|
LL | unsafe { unsf() }
|
||||||
| ^^^^^^ unnecessary `unsafe` block
|
| ^^^^^^ unnecessary `unsafe` block
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe block
|
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:76:5
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:76:5
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
|
@ -109,7 +109,7 @@ LL | unsf();
|
||||||
|
|
|
|
||||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||||
|
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:80:9
|
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:80:9
|
||||||
|
|
|
|
||||||
LL | unsf();
|
LL | unsf();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `dummy` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unsafe-const-fn.rs:10:18
|
--> $DIR/unsafe-const-fn.rs:10:18
|
||||||
|
|
|
|
||||||
LL | const VAL: u32 = dummy(0xFFFF);
|
LL | const VAL: u32 = dummy(0xFFFF);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `dummy` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unsafe-const-fn.rs:10:18
|
--> $DIR/unsafe-const-fn.rs:10:18
|
||||||
|
|
|
|
||||||
LL | const VAL: u32 = dummy(0xFFFF);
|
LL | const VAL: u32 = dummy(0xFFFF);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unsafe-fn-called-from-safe.rs:7:5
|
--> $DIR/unsafe-fn-called-from-safe.rs:7:5
|
||||||
|
|
|
|
||||||
LL | f();
|
LL | f();
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
unsafe fn f() { return; }
|
unsafe fn f() { return; }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
f(); //~ ERROR call to unsafe function is unsafe
|
f(); //~ ERROR call to unsafe function `f` is unsafe
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unsafe-fn-called-from-safe.rs:7:5
|
--> $DIR/unsafe-fn-called-from-safe.rs:7:5
|
||||||
|
|
|
|
||||||
LL | f();
|
LL | f();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unsafe-fn-used-as-value.rs:8:5
|
--> $DIR/unsafe-fn-used-as-value.rs:8:5
|
||||||
|
|
|
|
||||||
LL | x();
|
LL | x();
|
||||||
|
|
|
@ -5,5 +5,5 @@ unsafe fn f() { return; }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = f;
|
let x = f;
|
||||||
x(); //~ ERROR call to unsafe function is unsafe
|
x(); //~ ERROR call to unsafe function `f` is unsafe
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function or block
|
||||||
--> $DIR/unsafe-fn-used-as-value.rs:8:5
|
--> $DIR/unsafe-fn-used-as-value.rs:8:5
|
||||||
|
|
|
|
||||||
LL | x();
|
LL | x();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue