-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Visit type parameter in lifetime suggestion
Previously, Rebuilder did not visit type parameters when rebuilding generics and path, so in some cases the suggestion turns out to be erroneous.
- Loading branch information
Showing
3 changed files
with
157 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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. | ||
|
||
// ignore-tidy-linelength | ||
|
||
use std::iter::{Range,range}; | ||
|
||
trait Itble<'r, T, I: Iterator<T>> { fn iter(&'r self) -> I; } | ||
|
||
impl<'r> Itble<'r, uint, Range<uint>> for (uint, uint) { | ||
fn iter(&'r self) -> Range<uint> { | ||
let &(min, max) = self; | ||
range(min, max) | ||
} | ||
} | ||
|
||
fn check<'r, I: Iterator<uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool { | ||
//~^ NOTE: consider using an explicit lifetime parameter as shown: fn check<'a, I: Iterator<uint>, T: Itble<'a, uint, I>>(cont: &'a T) -> bool | ||
let cont_iter = cont.iter(); //~ ERROR: cannot infer | ||
let result = cont_iter.fold(Some(0u16), |state, val| { | ||
state.map_or(None, |mask| { | ||
let bit = 1 << val; | ||
if mask & bit == 0 {Some(mask|bit)} else {None} | ||
}) | ||
}); | ||
result.is_some() | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1d99d37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from pnkfelix
at ktt3ja@1d99d37
1d99d37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging ktt3ja/rust/issue-13058 = 1d99d37 into auto
1d99d37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ktt3ja/rust/issue-13058 = 1d99d37 merged ok, testing candidate = b2b2bbb
1d99d37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5078
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5078
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4170
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4184
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5178
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4265
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4273
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5180
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4265
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4270
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4336
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2065
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5177
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4274
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4285
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/4941
1d99d37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = b2b2bbb