Skip to content

Commit c325553

Browse files
committed
Convert InternedStrings to Symbols in UnsafetyViolation.
1 parent 02edd14 commit c325553

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/librustc/mir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use std::slice;
3737
use std::vec::IntoIter;
3838
use std::{iter, mem, option, u32};
3939
use syntax::ast::Name;
40-
use syntax::symbol::{InternedString, Symbol};
40+
use syntax::symbol::Symbol;
4141
use syntax_pos::{Span, DUMMY_SP};
4242

4343
pub use crate::mir::interpret::AssertMessage;
@@ -2736,8 +2736,8 @@ pub enum UnsafetyViolationKind {
27362736
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
27372737
pub struct UnsafetyViolation {
27382738
pub source_info: SourceInfo,
2739-
pub description: InternedString,
2740-
pub details: InternedString,
2739+
pub description: Symbol,
2740+
pub details: Symbol,
27412741
pub kind: UnsafetyViolationKind,
27422742
}
27432743

src/librustc_mir/transform/check_unsafety.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc::lint::builtin::{SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, UNUSED_UNSA
1212
use rustc::mir::*;
1313
use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext};
1414

15-
use syntax::symbol::{InternedString, sym};
15+
use syntax::symbol::{Symbol, sym};
1616

1717
use std::ops::Bound;
1818

@@ -167,9 +167,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
167167
(CastTy::FnPtr, CastTy::Int(_)) => {
168168
self.register_violations(&[UnsafetyViolation {
169169
source_info: self.source_info,
170-
description: InternedString::intern("cast of pointer to int"),
171-
details: InternedString::intern(
172-
"casting pointers to integers in constants"),
170+
description: Symbol::intern("cast of pointer to int"),
171+
details: Symbol::intern("casting pointers to integers in constants"),
173172
kind: UnsafetyViolationKind::General,
174173
}], &[]);
175174
},
@@ -185,8 +184,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
185184
if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body, self.tcx).kind {
186185
self.register_violations(&[UnsafetyViolation {
187186
source_info: self.source_info,
188-
description: InternedString::intern("pointer operation"),
189-
details: InternedString::intern("operations on pointers in constants"),
187+
description: Symbol::intern("pointer operation"),
188+
details: Symbol::intern("operations on pointers in constants"),
190189
kind: UnsafetyViolationKind::General,
191190
}], &[]);
192191
}
@@ -219,8 +218,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
219218
self.source_scope_local_data[source_info.scope].lint_root;
220219
self.register_violations(&[UnsafetyViolation {
221220
source_info,
222-
description: InternedString::intern("use of extern static"),
223-
details: InternedString::intern(
221+
description: Symbol::intern("use of extern static"),
222+
details: Symbol::intern(
224223
"extern statics are not controlled by the Rust type system: \
225224
invalid data, aliasing violations or data races will cause \
226225
undefined behavior"),
@@ -240,8 +239,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
240239
self.source_scope_local_data[source_info.scope].lint_root;
241240
self.register_violations(&[UnsafetyViolation {
242241
source_info,
243-
description: InternedString::intern("borrow of packed field"),
244-
details: InternedString::intern(
242+
description: Symbol::intern("borrow of packed field"),
243+
details: Symbol::intern(
245244
"fields of packed structs might be misaligned: dereferencing a \
246245
misaligned pointer or even just creating a misaligned reference \
247246
is undefined behavior"),
@@ -334,8 +333,8 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
334333
let source_info = self.source_info;
335334
self.register_violations(&[UnsafetyViolation {
336335
source_info,
337-
description: InternedString::intern(description),
338-
details: InternedString::intern(details),
336+
description: Symbol::intern(description),
337+
details: Symbol::intern(details),
339338
kind,
340339
}], &[]);
341340
}
@@ -438,8 +437,8 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
438437
let source_info = self.source_info;
439438
self.register_violations(&[UnsafetyViolation {
440439
source_info,
441-
description: InternedString::intern(description),
442-
details: InternedString::intern(details),
440+
description: Symbol::intern(description),
441+
details: Symbol::intern(details),
443442
kind: UnsafetyViolationKind::GeneralAndConstFn,
444443
}], &[]);
445444
}

0 commit comments

Comments
 (0)