Skip to content

Commit 0a3a46d

Browse files
committed
tidy things up a bit
1 parent e06cd31 commit 0a3a46d

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

src/librustc/traits/object_safety.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ impl ObjectSafetyViolation {
5959
ObjectSafetyViolation::Method(name, MethodViolationCode::Generic) =>
6060
format!("method `{}` has generic type parameters", name).into(),
6161
ObjectSafetyViolation::Method(name, MethodViolationCode::NonStandardSelfType) =>
62-
format!("method `{}` has a non-standard `self` type. Only `&self`, `&mut self`, and `Box<Self>` are currently supported for trait objects", name).into(),
62+
format!("method `{}` has a non-standard `self` type. Only `&self`, \
63+
`&mut self`, and `Box<Self>` are currently supported \
64+
for trait objects", name).into(),
6365
ObjectSafetyViolation::AssociatedConst(name) =>
6466
format!("the trait cannot contain associated consts like `{}`", name).into(),
6567
}

src/librustc/ty/util.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,9 @@ impl<'tcx> ExplicitSelf<'tcx> {
12221222

12231223
match self_arg_ty.sty {
12241224
_ if is_self_ty(self_arg_ty) => ByValue,
1225-
ty::TyRef(region, ty::TypeAndMut { ty, mutbl}) if is_self_ty(ty) => ByReference(region, mutbl),
1225+
ty::TyRef(region, ty::TypeAndMut { ty, mutbl}) if is_self_ty(ty) => {
1226+
ByReference(region, mutbl)
1227+
}
12261228
ty::TyAdt(def, _) if def.is_box() && is_self_ty(self_arg_ty.boxed_ty()) => ByBox,
12271229
_ => Other
12281230
}

src/librustc_typeck/check/wfcheck.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
487487

488488
loop {
489489
if let Some((potential_self_ty, _)) = autoderef.next() {
490-
debug!("check_method_receiver: potential self type `{:?}` to match `{:?}`", potential_self_ty, self_ty);
490+
debug!("check_method_receiver: potential self type `{:?}` to match `{:?}`",
491+
potential_self_ty, self_ty);
491492

492493
if fcx.infcx.can_eq(fcx.param_env, self_ty, potential_self_ty).is_ok() {
493494
autoderef.finalize();
@@ -497,7 +498,8 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
497498
break
498499
}
499500
} else {
500-
fcx.tcx.sess.diagnostic().mut_span_err(span, &format!("invalid `self` type: {:?}", self_arg_ty))
501+
fcx.tcx.sess.diagnostic().mut_span_err(
502+
span, &format!("invalid `self` type: {:?}", self_arg_ty))
501503
.note(&format!("type must be `{:?}` or a type that dereferences to it`", self_ty))
502504
.help("consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`")
503505
.code(DiagnosticId::Error("E0307".into()))

src/test/compile-fail/arbitrary-self-types-not-object-safe.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
110
#![feature(arbitrary_self_types)]
211

312
use std::rc::Rc;
@@ -35,7 +44,8 @@ fn make_foo() {
3544
//~| ERROR E0038
3645
//~| NOTE method `foo` has a non-standard `self` type
3746
//~| NOTE the trait `Foo` cannot be made into an object
38-
//~| NOTE required because of the requirements on the impl of `std::ops::CoerceUnsized<std::boxed::Box<Foo>>` for `std::boxed::Box<usize>`
47+
//~| NOTE required because of the requirements on the impl of
48+
//~| `std::ops::CoerceUnsized<std::boxed::Box<Foo>>` for `std::boxed::Box<usize>`
3949
}
4050

4151
fn make_bar() {

src/test/compile-fail/feature-gate-arbitrary-self-types.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
111
use std::rc::Rc;
212

313
trait Foo {

0 commit comments

Comments
 (0)