only show a simple description in E0133 span label

This commit is contained in:
Emil Gardström 2022-04-24 14:42:30 +02:00
parent 8b8f6653cf
commit 2e47271cb8
No known key found for this signature in database
GPG key ID: 08AABB4F80C3FAC6
33 changed files with 126 additions and 87 deletions

View file

@ -44,6 +44,27 @@ pub enum UnsafetyViolationDetails {
} }
impl UnsafetyViolationDetails { impl UnsafetyViolationDetails {
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) { pub fn description_and_note(&self, tcx: TyCtxt<'_>) -> (Cow<'static, str>, &'static str) {
use UnsafetyViolationDetails::*; use UnsafetyViolationDetails::*;
match self { match self {
@ -51,55 +72,55 @@ impl UnsafetyViolationDetails {
if let Some(did) = did { if let Some(did) = did {
Cow::from(format!("call to unsafe function `{}`", tcx.def_path_str(*did))) Cow::from(format!("call to unsafe function `{}`", tcx.def_path_str(*did)))
} else { } else {
Cow::Borrowed("call to unsafe function") 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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("cast of pointer to int"), Cow::Borrowed(self.simple_description()),
"casting pointers to integers in constants", "casting pointers to integers in constants",
), ),
UseOfMutableStatic => ( UseOfMutableStatic => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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",
), ),

View file

@ -93,7 +93,7 @@ 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();
}, },
@ -110,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();
} }
@ -546,57 +546,75 @@ enum UnsafeOpKind {
use UnsafeOpKind::*; use UnsafeOpKind::*;
impl UnsafeOpKind { impl UnsafeOpKind {
pub fn simple_description(&self) -> &'static str {
match self {
CallToUnsafeFunction(..) => "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) { pub fn description_and_note(&self, tcx: TyCtxt<'_>) -> (Cow<'static, str>, &'static str) {
match self { match self {
CallToUnsafeFunction(did) => ( CallToUnsafeFunction(did) => (
if let Some(did) = did { if let Some(did) = did {
Cow::from(format!("call to unsafe function `{}`", tcx.def_path_str(*did))) Cow::from(format!("call to unsafe function `{}`", tcx.def_path_str(*did)))
} else { } else {
Cow::Borrowed("call to unsafe function") 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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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 => (
Cow::Borrowed("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",
), ),

View file

@ -598,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();
} }

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe funct
--> $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();
| ^^^^^^ call to unsafe function `S::f` | ^^^^^^ 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
@ -10,7 +10,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5 --> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
| |
LL | f(); LL | f();
| ^^^ call to unsafe function `f` | ^^^ 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
@ -18,7 +18,7 @@ error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe funct
--> $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();
| ^^^^^^ call to unsafe function `S::f` | ^^^^^^ 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
@ -26,7 +26,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/async-unsafe-fn-call-in-safe.rs:20:5 --> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
| |
LL | f(); LL | f();
| ^^^ call to unsafe function `f` | ^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `S::f` is unsafe and requires unsafe funct
--> $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();
| ^^^^^^ call to unsafe function `S::f` | ^^^^^^ 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
@ -10,7 +10,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5 --> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
| |
LL | f(); LL | f();
| ^^^ call to unsafe function `f` | ^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `std::pin::Pin::<P>::new_unchecked` is uns
--> $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); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `std::pin::Pin::<P>::new_unchecked` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `Pin::<P>::new_unchecked` is unsafe and re
--> $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); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `Pin::<P>::new_unchecked` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe functi
--> $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()];
| ^^^^^ call to unsafe function `foo` | ^^^^^ 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
@ -10,7 +10,7 @@ error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe functi
--> $DIR/const-extern-fn-requires-unsafe.rs:11:5 --> $DIR/const-extern-fn-requires-unsafe.rs:11:5
| |
LL | foo(); LL | foo();
| ^^^^^ call to unsafe function `foo` | ^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe functi
--> $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()];
| ^^^^^ call to unsafe function `foo` | ^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/E0133.rs:7:5 --> $DIR/E0133.rs:7:5
| |
LL | f(); LL | f();
| ^^^ call to unsafe function `f` | ^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/E0133.rs:7:5 --> $DIR/E0133.rs:7:5
| |
LL | f(); LL | f();
| ^^^ call to unsafe function `f` | ^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `test::free` is unsafe and requires unsafe
--> $DIR/foreign-unsafe-fn-called.rs:11:5 --> $DIR/foreign-unsafe-fn-called.rs:11:5
| |
LL | test::free(); LL | test::free();
| ^^^^^^^^^^^^ call to unsafe function `test::free` | ^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `test::free` is unsafe and requires unsafe
--> $DIR/foreign-unsafe-fn-called.rs:11:5 --> $DIR/foreign-unsafe-fn-called.rs:11:5
| |
LL | test::free(); LL | test::free();
| ^^^^^^^^^^^^ call to unsafe function `test::free` | ^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `std::intrinsics::unchecked_add` is unsafe
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `std::intrinsics::unchecked_add` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
@ -10,7 +10,7 @@ error[E0133]: call to unsafe function `std::intrinsics::unchecked_sub` is unsafe
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `std::intrinsics::unchecked_sub` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
@ -18,7 +18,7 @@ error[E0133]: call to unsafe function `std::intrinsics::unchecked_mul` is unsafe
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `std::intrinsics::unchecked_mul` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `unchecked_add` is unsafe and requires uns
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `unchecked_add` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
@ -10,7 +10,7 @@ error[E0133]: call to unsafe function `unchecked_sub` is unsafe and requires uns
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `unchecked_sub` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
@ -18,7 +18,7 @@ error[E0133]: call to unsafe function `unchecked_mul` is unsafe and requires uns
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `unchecked_mul` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `std::ptr::write` is unsafe and requires u
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `std::ptr::write` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `std::ptr::write` is unsafe and requires u
--> $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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `std::ptr::write` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `X::with` is unsafe and requires unsafe fu
--> $DIR/issue-3080.rs:10:5 --> $DIR/issue-3080.rs:10:5
| |
LL | X(()).with(); LL | X(()).with();
| ^^^^^^^^^^^^ call to unsafe function `X::with` | ^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `X::with` is unsafe and requires unsafe fu
--> $DIR/issue-3080.rs:10:5 --> $DIR/issue-3080.rs:10:5
| |
LL | X(()).with(); LL | X(()).with();
| ^^^^^^^^^^^^ call to unsafe function `X::with` | ^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `issue_5844_aux::rand` is unsafe and requi
--> $DIR/issue-5844.rs:8:5 --> $DIR/issue-5844.rs:8:5
| |
LL | issue_5844_aux::rand(); LL | issue_5844_aux::rand();
| ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `issue_5844_aux::rand` | ^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe funct
--> $DIR/issue-5844.rs:8:5 --> $DIR/issue-5844.rs:8:5
| |
LL | issue_5844_aux::rand(); LL | issue_5844_aux::rand();
| ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `rand` | ^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:23:5 --> $DIR/safe-calls.rs:23:5
| |
LL | sse2(); LL | sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -10,7 +10,7 @@ error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and
--> $DIR/safe-calls.rs:24:5 --> $DIR/safe-calls.rs:24:5
| |
LL | avx_bmi2(); LL | avx_bmi2();
| ^^^^^^^^^^ call to function `avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -18,7 +18,7 @@ error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsa
--> $DIR/safe-calls.rs:25:5 --> $DIR/safe-calls.rs:25:5
| |
LL | Quux.avx_bmi2(); LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function `Quux::avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -26,7 +26,7 @@ error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and
--> $DIR/safe-calls.rs:30:5 --> $DIR/safe-calls.rs:30:5
| |
LL | avx_bmi2(); LL | avx_bmi2();
| ^^^^^^^^^^ call to function `avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -34,7 +34,7 @@ error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsa
--> $DIR/safe-calls.rs:31:5 --> $DIR/safe-calls.rs:31:5
| |
LL | Quux.avx_bmi2(); LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function `Quux::avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -42,7 +42,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:36:5 --> $DIR/safe-calls.rs:36:5
| |
LL | sse2(); LL | sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -50,7 +50,7 @@ error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and
--> $DIR/safe-calls.rs:37:5 --> $DIR/safe-calls.rs:37:5
| |
LL | avx_bmi2(); LL | avx_bmi2();
| ^^^^^^^^^^ call to function `avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -58,7 +58,7 @@ error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsa
--> $DIR/safe-calls.rs:38:5 --> $DIR/safe-calls.rs:38:5
| |
LL | Quux.avx_bmi2(); LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function `Quux::avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -66,7 +66,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:44:5 --> $DIR/safe-calls.rs:44:5
| |
LL | sse2(); LL | sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -74,7 +74,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:47:18 --> $DIR/safe-calls.rs:47:18
| |
LL | const name: () = sse2(); LL | const name: () = sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available

View file

@ -2,7 +2,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:23:5 --> $DIR/safe-calls.rs:23:5
| |
LL | sse2(); LL | sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -10,7 +10,7 @@ error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and
--> $DIR/safe-calls.rs:24:5 --> $DIR/safe-calls.rs:24:5
| |
LL | avx_bmi2(); LL | avx_bmi2();
| ^^^^^^^^^^ call to function `avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -18,7 +18,7 @@ error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsa
--> $DIR/safe-calls.rs:25:5 --> $DIR/safe-calls.rs:25:5
| |
LL | Quux.avx_bmi2(); LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function `Quux::avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -26,7 +26,7 @@ error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and
--> $DIR/safe-calls.rs:30:5 --> $DIR/safe-calls.rs:30:5
| |
LL | avx_bmi2(); LL | avx_bmi2();
| ^^^^^^^^^^ call to function `avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -34,7 +34,7 @@ error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsa
--> $DIR/safe-calls.rs:31:5 --> $DIR/safe-calls.rs:31:5
| |
LL | Quux.avx_bmi2(); LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function `Quux::avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -42,7 +42,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:36:5 --> $DIR/safe-calls.rs:36:5
| |
LL | sse2(); LL | sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -50,7 +50,7 @@ error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and
--> $DIR/safe-calls.rs:37:5 --> $DIR/safe-calls.rs:37:5
| |
LL | avx_bmi2(); LL | avx_bmi2();
| ^^^^^^^^^^ call to function `avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -58,7 +58,7 @@ error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsa
--> $DIR/safe-calls.rs:38:5 --> $DIR/safe-calls.rs:38:5
| |
LL | Quux.avx_bmi2(); LL | Quux.avx_bmi2();
| ^^^^^^^^^^^^^^^ call to function `Quux::avx_bmi2` with `#[target_feature]` | ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -66,7 +66,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:44:5 --> $DIR/safe-calls.rs:44:5
| |
LL | sse2(); LL | sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available
@ -74,7 +74,7 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req
--> $DIR/safe-calls.rs:47:18 --> $DIR/safe-calls.rs:47:18
| |
LL | const name: () = sse2(); LL | const name: () = sse2();
| ^^^^^^ call to function `sse2` with `#[target_feature]` | ^^^^^^ call to function with `#[target_feature]`
| |
= note: can only be called if the required target features are available = note: can only be called if the required target features are available

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `std::thread::__FastLocalKeyInner::<T>::ge
--> $DIR/issue-43733.rs:19:5 --> $DIR/issue-43733.rs:19:5
| |
LL | __KEY.get(Default::default) LL | __KEY.get(Default::default)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `std::thread::__FastLocalKeyInner::<T>::get` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
@ -10,7 +10,7 @@ error[E0133]: call to unsafe function `std::thread::LocalKey::<T>::new` is unsaf
--> $DIR/issue-43733.rs:24:42 --> $DIR/issue-43733.rs:24: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 `std::thread::LocalKey::<T>::new` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `__FastLocalKeyInner::<T>::get` is unsafe
--> $DIR/issue-43733.rs:19:5 --> $DIR/issue-43733.rs:19:5
| |
LL | __KEY.get(Default::default) LL | __KEY.get(Default::default)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function `__FastLocalKeyInner::<T>::get` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
@ -10,7 +10,7 @@ error[E0133]: call to unsafe function `LocalKey::<T>::new` is unsafe and require
--> $DIR/issue-43733.rs:24:42 --> $DIR/issue-43733.rs:24: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 `LocalKey::<T>::new` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -117,7 +117,7 @@ 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();
| ^^^^^^ call to unsafe function `unsf` | ^^^^^^ 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
@ -125,7 +125,7 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe funct
--> $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();
| ^^^^^^ call to unsafe function `unsf` | ^^^^^^ 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

View file

@ -2,7 +2,7 @@ error: call to unsafe function `unsf` is unsafe and requires unsafe block (error
--> $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 `unsf` | ^^^^^^ call to unsafe function
| |
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
@ -43,7 +43,7 @@ error: call to unsafe function `unsf` is unsafe and requires unsafe block (error
--> $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 `unsf` | ^^^^^^ call to unsafe function
| |
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
@ -105,7 +105,7 @@ 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();
| ^^^^^^ call to unsafe function `unsf` | ^^^^^^ 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
@ -113,7 +113,7 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe funct
--> $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();
| ^^^^^^ call to unsafe function `unsf` | ^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `dummy` is unsafe and requires unsafe func
--> $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);
| ^^^^^^^^^^^^^ call to unsafe function `dummy` | ^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `dummy` is unsafe and requires unsafe func
--> $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);
| ^^^^^^^^^^^^^ call to unsafe function `dummy` | ^^^^^^^^^^^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/unsafe-fn-called-from-safe.rs:7:5 --> $DIR/unsafe-fn-called-from-safe.rs:7:5
| |
LL | f(); LL | f();
| ^^^ call to unsafe function `f` | ^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/unsafe-fn-called-from-safe.rs:7:5 --> $DIR/unsafe-fn-called-from-safe.rs:7:5
| |
LL | f(); LL | f();
| ^^^ call to unsafe function `f` | ^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/unsafe-fn-used-as-value.rs:8:5 --> $DIR/unsafe-fn-used-as-value.rs:8:5
| |
LL | x(); LL | x();
| ^^^ call to unsafe function `f` | ^^^ 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

View file

@ -2,7 +2,7 @@ error[E0133]: call to unsafe function `f` is unsafe and requires unsafe function
--> $DIR/unsafe-fn-used-as-value.rs:8:5 --> $DIR/unsafe-fn-used-as-value.rs:8:5
| |
LL | x(); LL | x();
| ^^^ call to unsafe function `f` | ^^^ 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