Skip to content

Commit 061d843

Browse files
committed
remove uses of as_slice where deref coercions can be used
1 parent 14ce607 commit 061d843

File tree

19 files changed

+39
-39
lines changed

19 files changed

+39
-39
lines changed

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl<'a> CrateReader<'a> {
493493
};
494494

495495
let dylib = library.dylib.clone();
496-
let register = should_link && self.existing_match(info.name.as_slice(),
496+
let register = should_link && self.existing_match(&info.name,
497497
None,
498498
PathKind::Crate).is_none();
499499
let metadata = if register {

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fn check_for_static_nan(cx: &MatchCheckCtxt, pat: &Pat) {
276276
let subspan = p.span.lo <= err.span.lo && err.span.hi <= p.span.hi;
277277
cx.tcx.sess.span_err(err.span,
278278
&format!("constant evaluation error: {}",
279-
err.description().as_slice()));
279+
err.description()));
280280
if !subspan {
281281
cx.tcx.sess.span_note(p.span,
282282
"in pattern here")

src/librustc/middle/const_eval.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<ast::Pat>
204204
pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> const_val {
205205
match eval_const_expr_partial(tcx, e, None) {
206206
Ok(r) => r,
207-
Err(s) => tcx.sess.span_fatal(s.span, s.description().as_slice())
207+
Err(s) => tcx.sess.span_fatal(s.span, &s.description())
208208
}
209209
}
210210

@@ -665,14 +665,14 @@ pub fn compare_lit_exprs<'tcx>(tcx: &ty::ctxt<'tcx>,
665665
let a = match eval_const_expr_partial(tcx, a, ty_hint) {
666666
Ok(a) => a,
667667
Err(e) => {
668-
tcx.sess.span_err(a.span, e.description().as_slice());
668+
tcx.sess.span_err(a.span, &e.description());
669669
return None;
670670
}
671671
};
672672
let b = match eval_const_expr_partial(tcx, b, ty_hint) {
673673
Ok(b) => b,
674674
Err(e) => {
675-
tcx.sess.span_err(b.span, e.description().as_slice());
675+
tcx.sess.span_err(b.span, &e.description());
676676
return None;
677677
}
678678
};

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5485,7 +5485,7 @@ pub fn enum_variants<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
54855485
Err(err) => {
54865486
span_err!(cx.sess, err.span, E0305,
54875487
"constant evaluation error: {}",
5488-
err.description().as_slice());
5488+
err.description());
54895489
}
54905490
}
54915491
} else {

src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
115115
region::CodeExtent::Misc(_) => tag,
116116
region::CodeExtent::DestructionScope(_) => {
117117
new_string = format!("destruction scope surrounding {}", tag);
118-
new_string.as_slice()
118+
&*new_string
119119
}
120120
region::CodeExtent::Remainder(r) => {
121121
new_string = format!("block suffix following statement {}",

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
704704
self.tcx
705705
.sess
706706
.span_err(span,
707-
(format!("partial reinitialization of uninitialized \
707+
&format!("partial reinitialization of uninitialized \
708708
structure `{}`",
709-
self.loan_path_to_string(lp))).as_slice());
709+
self.loan_path_to_string(lp)));
710710
}
711711

712712
pub fn report_reassigned_immutable_variable(&self,

src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ impl LintPass for InvalidNoMangleItems {
20802080
!cx.exported_items.contains(&it.id) {
20812081
let msg = format!("static {} is marked #[no_mangle], but not exported",
20822082
it.ident);
2083-
cx.span_lint(PRIVATE_NO_MANGLE_STATICS, it.span, msg.as_slice());
2083+
cx.span_lint(PRIVATE_NO_MANGLE_STATICS, it.span, &msg);
20842084
}
20852085
},
20862086
ast::ItemConst(..) => {

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
14041404
ast_ty.span.lo <= r.span.lo && r.span.hi <= ast_ty.span.hi;
14051405
span_err!(tcx.sess, r.span, E0250,
14061406
"array length constant evaluation error: {}",
1407-
r.description().as_slice());
1407+
r.description());
14081408
if !subspan {
14091409
span_note!(tcx.sess, ast_ty.span, "for array length here")
14101410
}

src/librustc_typeck/check/dropck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
298298
match rcx.tcx().region_maps.opt_encl_scope(scope) {
299299
Some(parent_scope) => ty::ReScope(parent_scope),
300300
None => rcx.tcx().sess.span_bug(
301-
span, format!("no enclosing scope found for scope: {:?}",
302-
scope).as_slice()),
301+
span, &format!("no enclosing scope found for scope: {:?}",
302+
scope)),
303303
};
304304

305305
regionck::type_must_outlive(rcx, origin(), typ, parent_region);

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4620,7 +4620,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
46204620
Err(ref err) => {
46214621
span_err!(ccx.tcx.sess, err.span, E0080,
46224622
"constant evaluation error: {}",
4623-
err.description().as_slice());
4623+
err.description());
46244624
}
46254625
}
46264626
},

0 commit comments

Comments
 (0)