Skip to content

Commit e6b23da

Browse files
committed
Fix lifetime error to print 'a instead of &'a
This changes certain error messages about lifetimes so that they display lifetimes without an `&`. Fixes #10291.
1 parent 50b26df commit e6b23da

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
145145
}
146146

147147
pub fn bound_region_ptr_to_str(cx: &ctxt, br: BoundRegion) -> StrBuf {
148-
bound_region_to_str(cx, "&", true, br)
148+
bound_region_to_str(cx, "", false, br)
149149
}
150150

151151
pub fn bound_region_to_str(cx: &ctxt,

src/test/compile-fail/issue-10291.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn test<'x>(x: &'x int) { //~ NOTE the lifetime 'x as defined
12+
drop::< <'z>|&'z int| -> &'z int>(|z| {
13+
//~^ ERROR mismatched types
14+
//~^^ ERROR cannot infer an appropriate lifetime
15+
x
16+
});
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)