Skip to content

Commit

Permalink
Address nits by @pnkfelix
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Feb 16, 2015
1 parent d0ef166 commit 503e15b
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/librustc/middle/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
infer::RelateRegionParamBound(span) => {
self.tcx.sess.span_err(
span,
"declared lifetime bound not satisfied");
"lifetime bound not satisfied");
note_and_explain_region(
self.tcx,
"lifetime parameter instantiated with ",
Expand Down Expand Up @@ -1629,7 +1629,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
self.tcx.sess.span_note(
span,
&format!("...so that the type `{}` \
will meet the declared lifetime bounds",
will meet its required lifetime bounds",
self.ty_to_string(t))[]);
}
infer::RelateDefaultParamBound(span, t) => {
Expand Down
6 changes: 6 additions & 0 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,12 @@ fn compute_object_lifetime_bound<'tcx>(
return r;
}

/// Given an object type like `SomeTrait+Send`, computes the lifetime
/// bounds that must hold on the elided self type. These are derived
/// from the declarations of `SomeTrait`, `Send`, and friends -- if
/// they declare `trait SomeTrait : 'static`, for example, then
/// `'static` would appear in the list. The hard work is done by
/// `ty::required_region_bounds`, see that for more information.
pub fn object_region_bounds<'tcx>(
tcx: &ty::ctxt<'tcx>,
principal: &ty::PolyTraitRef<'tcx>,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub fn regionck_ensure_component_tys_wf<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// empty region is a subregion of all others, this can't fail
// unless the type does not meet the well-formedness
// requirements.
type_must_outlive(&mut rcx, infer::RelateRegionParamBound(span),
type_must_outlive(&mut rcx, infer::RelateParamBound(span, component_ty),
component_ty, ty::ReEmpty);
}
}
Expand Down Expand Up @@ -305,7 +305,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
debug!("visit_region_obligations: r_o={}",
r_o.repr(self.tcx()));
let sup_type = self.resolve_type(r_o.sup_type);
let origin = infer::RelateRegionParamBound(r_o.cause.span);
let origin = infer::RelateParamBound(r_o.cause.span, sup_type);
type_must_outlive(self, origin, sup_type, r_o.sub_region);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/builtin-superkinds-simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
trait Foo : Send { }

impl <'a> Foo for &'a mut () { }
//~^ ERROR declared lifetime bound not satisfied
//~^ ERROR the type `&'a mut ()` does not fulfill the required lifetime

fn main() { }
2 changes: 1 addition & 1 deletion src/test/compile-fail/kindck-impl-type-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn g<T>(val: T) {
fn foo<'a>() {
let t: S<&'a isize> = S;
let a = &t as &Gettable<&'a isize>;
//~^ ERROR declared lifetime bound not satisfied
//~^ ERROR the type `&'a isize` does not fulfill the required lifetime
}

fn foo2<'a>() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/kindck-send-object1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn test51<'a>() {
}
fn test52<'a>() {
assert_send::<&'a (Dummy+Send)>();
//~^ ERROR declared lifetime bound not satisfied
//~^ ERROR does not fulfill the required lifetime
}

// ...unless they are properly bounded
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/kindck-send-owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn test32() { assert_send::<Vec<isize> >(); }

// but not if they own a bad thing
fn test40<'a>(_: &'a isize) {
assert_send::<Box<&'a isize>>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
}

fn main() { }
6 changes: 3 additions & 3 deletions src/test/compile-fail/kindck-send-region-pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ fn test10() { assert_send::<&'static mut isize>(); }

// otherwise lifetime pointers are not ok
fn test20<'a>(_: &'a isize) {
assert_send::<&'a isize>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
}
fn test21<'a>(_: &'a isize) {
assert_send::<&'a str>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
}
fn test22<'a>(_: &'a isize) {
assert_send::<&'a [isize]>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
}

fn main() { }
3 changes: 2 additions & 1 deletion src/test/compile-fail/object-lifetime-default-ambiguous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ fn d(t: Ref2<Ref1<Test>>) {
fn e(t: Ref2<Ref0<Test>>) {
//~^ ERROR lifetime bound for this object type cannot be deduced from context
//
// In this case, Ref0 just inherits.
// In this case, Ref2 is ambiguous, and Ref0 inherits the
// ambiguity.
}

fn f(t: &Ref2<Test>) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail/region-object-lifetime-in-coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ trait Foo {}
impl<'a> Foo for &'a [u8] {}

fn a(v: &[u8]) -> Box<Foo + 'static> {
let x: Box<Foo + 'static> = box v; //~ ERROR declared lifetime bound not satisfied
let x: Box<Foo + 'static> = box v; //~ ERROR does not fulfill the required lifetime
x
}

fn b(v: &[u8]) -> Box<Foo + 'static> {
box v //~ ERROR declared lifetime bound not satisfied
box v //~ ERROR does not fulfill the required lifetime
}

fn c(v: &[u8]) -> Box<Foo> {
// same as previous case due to RFC 599

box v //~ ERROR declared lifetime bound not satisfied
box v //~ ERROR does not fulfill the required lifetime
}

fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> {
box v //~ ERROR declared lifetime bound not satisfied
box v //~ ERROR does not fulfill the required lifetime
}

fn e<'a:'b,'b>(v: &'a [u8]) -> Box<Foo+'b> {
Expand Down
10 changes: 5 additions & 5 deletions src/test/compile-fail/regions-bounded-by-send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) {
// otherwise lifetime pointers are not ok

fn param_not_ok<'a>(x: &'a isize) {
assert_send::<&'a isize>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
}

fn param_not_ok1<'a>(_: &'a isize) {
assert_send::<&'a str>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
}

fn param_not_ok2<'a>(_: &'a isize) {
assert_send::<&'a [isize]>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
}

// boxes are ok
Expand All @@ -54,7 +54,7 @@ fn box_ok() {
// but not if they own a bad thing

fn box_with_region_not_ok<'a>() {
assert_send::<Box<&'a isize>>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
}

// objects with insufficient bounds no ok
Expand All @@ -66,7 +66,7 @@ fn object_with_random_bound_not_ok<'a>() {

fn object_with_send_bound_not_ok<'a>() {
assert_send::<&'a (Dummy+Send)>();
//~^ ERROR declared lifetime bound not satisfied
//~^ ERROR does not fulfill the required lifetime
}

// unsafe pointers are ok unless they point at unsendable things
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) {
// otherwise lifetime pointers are not ok

fn param_not_ok<'a>(x: &'a isize) {
assert_send::<&'a isize>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
}

fn param_not_ok1<'a>(_: &'a isize) {
assert_send::<&'a str>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
}

fn param_not_ok2<'a>(_: &'a isize) {
assert_send::<&'a [isize]>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
}

// boxes are ok
Expand All @@ -51,7 +51,7 @@ fn box_ok() {
// but not if they own a bad thing

fn box_with_region_not_ok<'a>() {
assert_send::<Box<&'a isize>>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
}

// unsafe pointers are ok unless they point at unsendable things
Expand All @@ -62,11 +62,11 @@ fn unsafe_ok1<'a>(_: &'a isize) {
}

fn unsafe_ok2<'a>(_: &'a isize) {
assert_send::<*const &'a isize>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime
}

fn unsafe_ok3<'a>(_: &'a isize) {
assert_send::<*mut &'a isize>(); //~ ERROR declared lifetime bound not satisfied
assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime
}

fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Foo {

fn caller<'a>(x: &isize) {
Foo.some_method::<&'a isize>();
//~^ ERROR declared lifetime bound not satisfied
//~^ ERROR does not fulfill the required lifetime
}

fn main() { }

0 comments on commit 503e15b

Please sign in to comment.