diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-04-01 22:32:37 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-04-10 07:52:46 -0700 |
| commit | 3322595e896e95c3e19ca33c854ad529f2ef3c19 (patch) | |
| tree | f785d8bc645c7fa424ef1487e617e054415f883d /src/libcore/str.rs | |
| parent | 5606fc0c90461db40faeca16d7bffd9e61c2be73 (diff) | |
Reason about nested free variables that appear in a function
signature. In a nutshell, the idea is to (1) report an error if, for a region pointer `'a T`, the lifetime `'a` is longer than any lifetimes that appear in `T` (in other words, if a borrowed pointer outlives any portion of its contents) and then (2) use this to assume that in a function like `fn(self: &'a &'b T)`, the relationship `'a <= 'b` holds. This is needed for #5656. Fixes #5728.
Diffstat (limited to 'src/libcore/str.rs')
| -rw-r--r-- | src/libcore/str.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs index f1605309fb4..8d15d6afbda 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -301,7 +301,11 @@ pub fn slice_shift_char<'a>(s: &'a str) -> (char, &'a str) { /// Prepend a char to a string pub fn unshift_char(s: &mut ~str, ch: char) { - *s = from_char(ch) + *s; + // This could be more efficient. + let mut new_str = ~""; + new_str.push_char(ch); + new_str.push_str(*s); + *s = new_str; } /** |
