@@ -42,64 +42,6 @@ pub enum UnsafetyViolationDetails {
42
42
CallToFunctionWith ,
43
43
}
44
44
45
- impl UnsafetyViolationDetails {
46
- pub fn description_and_note ( & self ) -> ( & ' static str , & ' static str ) {
47
- use UnsafetyViolationDetails :: * ;
48
- match self {
49
- CallToUnsafeFunction => (
50
- "call to unsafe function" ,
51
- "consult the function's documentation for information on how to avoid undefined \
52
- behavior",
53
- ) ,
54
- UseOfInlineAssembly => (
55
- "use of inline assembly" ,
56
- "inline assembly is entirely unchecked and can cause undefined behavior" ,
57
- ) ,
58
- InitializingTypeWith => (
59
- "initializing type with `rustc_layout_scalar_valid_range` attr" ,
60
- "initializing a layout restricted type's field with a value outside the valid \
61
- range is undefined behavior",
62
- ) ,
63
- CastOfPointerToInt => {
64
- ( "cast of pointer to int" , "casting pointers to integers in constants" )
65
- }
66
- UseOfMutableStatic => (
67
- "use of mutable static" ,
68
- "mutable statics can be mutated by multiple threads: aliasing violations or data \
69
- races will cause undefined behavior",
70
- ) ,
71
- UseOfExternStatic => (
72
- "use of extern static" ,
73
- "extern statics are not controlled by the Rust type system: invalid data, \
74
- aliasing violations or data races will cause undefined behavior",
75
- ) ,
76
- DerefOfRawPointer => (
77
- "dereference of raw pointer" ,
78
- "raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
79
- and cause data races: all of these are undefined behavior",
80
- ) ,
81
- AccessToUnionField => (
82
- "access to union field" ,
83
- "the field may not be properly initialized: using uninitialized data will cause \
84
- undefined behavior",
85
- ) ,
86
- MutationOfLayoutConstrainedField => (
87
- "mutation of layout constrained field" ,
88
- "mutating layout constrained fields cannot statically be checked for valid values" ,
89
- ) ,
90
- BorrowOfLayoutConstrainedField => (
91
- "borrow of layout constrained field with interior mutability" ,
92
- "references to fields of layout constrained fields lose the constraints. Coupled \
93
- with interior mutability, the field can be changed to invalid values",
94
- ) ,
95
- CallToFunctionWith => (
96
- "call to function with `#[target_feature]`" ,
97
- "can only be called if the required target features are available" ,
98
- ) ,
99
- }
100
- }
101
- }
102
-
103
45
#[ derive( Copy , Clone , PartialEq , TyEncodable , TyDecodable , HashStable , Debug ) ]
104
46
pub struct UnsafetyViolation {
105
47
pub source_info : SourceInfo ,
0 commit comments