Skip to content

Commit 503e15b

Browse files
committed
Address nits by @pnkfelix
1 parent d0ef166 commit 503e15b

13 files changed

+35
-28
lines changed

src/librustc/middle/infer/error_reporting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
619619
infer::RelateRegionParamBound(span) => {
620620
self.tcx.sess.span_err(
621621
span,
622-
"declared lifetime bound not satisfied");
622+
"lifetime bound not satisfied");
623623
note_and_explain_region(
624624
self.tcx,
625625
"lifetime parameter instantiated with ",
@@ -1629,7 +1629,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
16291629
self.tcx.sess.span_note(
16301630
span,
16311631
&format!("...so that the type `{}` \
1632-
will meet the declared lifetime bounds",
1632+
will meet its required lifetime bounds",
16331633
self.ty_to_string(t))[]);
16341634
}
16351635
infer::RelateDefaultParamBound(span, t) => {

src/librustc_typeck/astconv.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,12 @@ fn compute_object_lifetime_bound<'tcx>(
17541754
return r;
17551755
}
17561756

1757+
/// Given an object type like `SomeTrait+Send`, computes the lifetime
1758+
/// bounds that must hold on the elided self type. These are derived
1759+
/// from the declarations of `SomeTrait`, `Send`, and friends -- if
1760+
/// they declare `trait SomeTrait : 'static`, for example, then
1761+
/// `'static` would appear in the list. The hard work is done by
1762+
/// `ty::required_region_bounds`, see that for more information.
17571763
pub fn object_region_bounds<'tcx>(
17581764
tcx: &ty::ctxt<'tcx>,
17591765
principal: &ty::PolyTraitRef<'tcx>,

src/librustc_typeck/check/regionck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn regionck_ensure_component_tys_wf<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
154154
// empty region is a subregion of all others, this can't fail
155155
// unless the type does not meet the well-formedness
156156
// requirements.
157-
type_must_outlive(&mut rcx, infer::RelateRegionParamBound(span),
157+
type_must_outlive(&mut rcx, infer::RelateParamBound(span, component_ty),
158158
component_ty, ty::ReEmpty);
159159
}
160160
}
@@ -305,7 +305,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
305305
debug!("visit_region_obligations: r_o={}",
306306
r_o.repr(self.tcx()));
307307
let sup_type = self.resolve_type(r_o.sup_type);
308-
let origin = infer::RelateRegionParamBound(r_o.cause.span);
308+
let origin = infer::RelateParamBound(r_o.cause.span, sup_type);
309309
type_must_outlive(self, origin, sup_type, r_o.sub_region);
310310
}
311311

src/test/compile-fail/builtin-superkinds-simple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
trait Foo : Send { }
1515

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

1919
fn main() { }

src/test/compile-fail/kindck-impl-type-params.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn g<T>(val: T) {
3636
fn foo<'a>() {
3737
let t: S<&'a isize> = S;
3838
let a = &t as &Gettable<&'a isize>;
39-
//~^ ERROR declared lifetime bound not satisfied
39+
//~^ ERROR the type `&'a isize` does not fulfill the required lifetime
4040
}
4141

4242
fn foo2<'a>() {

src/test/compile-fail/kindck-send-object1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn test51<'a>() {
2222
}
2323
fn test52<'a>() {
2424
assert_send::<&'a (Dummy+Send)>();
25-
//~^ ERROR declared lifetime bound not satisfied
25+
//~^ ERROR does not fulfill the required lifetime
2626
}
2727

2828
// ...unless they are properly bounded

src/test/compile-fail/kindck-send-owned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn test32() { assert_send::<Vec<isize> >(); }
1919

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

2525
fn main() { }

src/test/compile-fail/kindck-send-region-pointers.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ fn test10() { assert_send::<&'static mut isize>(); }
2222

2323
// otherwise lifetime pointers are not ok
2424
fn test20<'a>(_: &'a isize) {
25-
assert_send::<&'a isize>(); //~ ERROR declared lifetime bound not satisfied
25+
assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
2626
}
2727
fn test21<'a>(_: &'a isize) {
28-
assert_send::<&'a str>(); //~ ERROR declared lifetime bound not satisfied
28+
assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
2929
}
3030
fn test22<'a>(_: &'a isize) {
31-
assert_send::<&'a [isize]>(); //~ ERROR declared lifetime bound not satisfied
31+
assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
3232
}
3333

3434
fn main() { }

src/test/compile-fail/object-lifetime-default-ambiguous.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ fn d(t: Ref2<Ref1<Test>>) {
4949
fn e(t: Ref2<Ref0<Test>>) {
5050
//~^ ERROR lifetime bound for this object type cannot be deduced from context
5151
//
52-
// In this case, Ref0 just inherits.
52+
// In this case, Ref2 is ambiguous, and Ref0 inherits the
53+
// ambiguity.
5354
}
5455

5556
fn f(t: &Ref2<Test>) {

src/test/compile-fail/region-object-lifetime-in-coercion.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ trait Foo {}
1717
impl<'a> Foo for &'a [u8] {}
1818

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

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

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

31-
box v //~ ERROR declared lifetime bound not satisfied
31+
box v //~ ERROR does not fulfill the required lifetime
3232
}
3333

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

3838
fn e<'a:'b,'b>(v: &'a [u8]) -> Box<Foo+'b> {

src/test/compile-fail/regions-bounded-by-send.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) {
3232
// otherwise lifetime pointers are not ok
3333

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

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

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

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

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

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

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

7272
// unsafe pointers are ok unless they point at unsendable things

src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) {
2929
// otherwise lifetime pointers are not ok
3030

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

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

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

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

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

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

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

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

7272
fn main() {

src/test/compile-fail/regions-bounded-method-type-parameters.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Foo {
2020

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

2626
fn main() { }

0 commit comments

Comments
 (0)