about summary refs log tree commit diff
path: root/src/libdebug
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-08-28 15:01:39 +0000
committerbors <bors@rust-lang.org>2014-08-28 15:01:39 +0000
commitb5165321e48c1fd8422803fb40693afab7939c8c (patch)
treea3206dbc34acc88311a3ec676155240681784906 /src/libdebug
parent0d3bd7720c50e3ada4bac77331d43926493be4fe (diff)
parent1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f (diff)
downloadrust-b5165321e48c1fd8422803fb40693afab7939c8c.tar.gz
rust-b5165321e48c1fd8422803fb40693afab7939c8c.zip
auto merge of #16453 : nikomatsakis/rust/type-bounds-3, r=pcwalton
Implements https://github.com/rust-lang/rfcs/pull/192.

In particular:

1. type parameters can have lifetime bounds and objects can close over borrowed values, presuming that they have suitable bounds.
2. objects must have a bound, though it may be derived from the trait itself or from a `Send` bound.
3. all types must be well-formed.
4. type parameters and lifetime parameters may themselves have lifetimes as bounds. Something like `T:'a` means "the type T outlives 'a`" and something like `'a:'b`" means "'a outlives 'b". Outlives here means "all borrowed data has a lifetime at least as long".

This is a [breaking-change]. The most common things you have to fix after this change are:

1. Introduce lifetime bounds onto type parameters if your type (directly or indirectly) contains a reference. Thus a struct like `struct Ref<'a, T> { x: &'a T }` would be changed to `struct Ref<'a, T:'a> { x: &'a T }`.
2. Introduce lifetime bounds onto lifetime parameters if your type contains a double reference. Thus a type like `struct RefWrapper<'a, 'b> { r: &'a Ref<'b, int> }` (where `Ref` is defined as before) would need to be changed to `struct RefWrapper<'a, 'b:'a> { ... }`.
2. Explicitly give object lifetimes in structure definitions. Most commonly, this means changing something like `Box<Reader>` to `Box<Reader+'static>`, so as to indicate that this is a reader without any borrowed data. (Note: you may wish to just change to `Box<Reader+Send>` while you're at it; it's a more restrictive type, technically, but means you can send the reader between threads.)

The intuition for points 1 and 2 is that a reference must never outlive its referent (the thing it points at). Therefore, if you have a type `&'a T`, we must know that `T` (whatever it is) outlives `'a`. And so on.

Closes #5723.
Diffstat (limited to 'src/libdebug')
-rw-r--r--src/libdebug/lib.rs2
-rw-r--r--src/libdebug/repr.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/libdebug/lib.rs b/src/libdebug/lib.rs
index 6341a380563..cc97eeffe7a 100644
--- a/src/libdebug/lib.rs
+++ b/src/libdebug/lib.rs
@@ -25,7 +25,7 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/master/")]
 #![experimental]
-#![feature(managed_boxes, macro_rules)]
+#![feature(managed_boxes, macro_rules, issue_5723_bootstrap)]
 #![allow(experimental)]
 
 pub mod fmt;
diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs
index 20f96d24a5f..dbd2c09497b 100644
--- a/src/libdebug/repr.rs
+++ b/src/libdebug/repr.rs
@@ -95,7 +95,7 @@ pub struct ReprVisitor<'a> {
     ptr: *const u8,
     ptr_stk: Vec<*const u8>,
     var_stk: Vec<VariantState>,
-    writer: &'a mut io::Writer,
+    writer: &'a mut io::Writer+'a,
     last_err: Option<io::IoError>,
 }