diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-12-04 20:06:41 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-10 19:45:19 -0500 |
| commit | ca98fefd04b2a0ccd784f96538c824c49210a418 (patch) | |
| tree | e5230aebe1d9cdd1d53d3f070050869c444c7e08 /src/test | |
| parent | c38e73fef53e8520e5170c40713e32ab965a8abe (diff) | |
| download | rust-ca98fefd04b2a0ccd784f96538c824c49210a418.tar.gz rust-ca98fefd04b2a0ccd784f96538c824c49210a418.zip | |
Fix two bugs in HRTB: 1. Categorize early-vs-late bindings on impls when constructing generics, so that we don't add unnecessary region parameters. 2. Correct the DeBruijn indices when substituting the self type into the method signature.
Previously, the DeBruijn index for the self type was not being adjusted to account for the fn binder. This mean that when late-bound regions were instantiated, you sometimes wind up with two distinct lifetimes. Fixes #19537.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/hrtb-debruijn-in-receiver.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/compile-fail/hrtb-debruijn-in-receiver.rs b/src/test/compile-fail/hrtb-debruijn-in-receiver.rs new file mode 100644 index 00000000000..2dbd16107b0 --- /dev/null +++ b/src/test/compile-fail/hrtb-debruijn-in-receiver.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test the case where the `Self` type has a bound lifetime that must +// be adjusted in the fn signature. Issue #19537. + +use std::collections::HashMap; + +struct Foo<'a> { + map: HashMap<uint, &'a str> +} + +impl<'a> Foo<'a> { + fn new() -> Foo<'a> { panic!() } + fn insert(&'a mut self) { } +} +fn main() { + let mut foo = Foo::new(); + foo.insert(); + foo.insert(); //~ ERROR cannot borrow +} |
