Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Check bounds when looking up type parameters
A mismatched type with more type parameters than the expected one causes `typeck` looking up out of the bound of type parameter vector, which leads to ICE. Closes #13466
- Loading branch information
Showing
3 changed files
with
36 additions
and
12 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
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
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,22 @@ | ||
// 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. | ||
|
||
// Regression test for #13466 | ||
|
||
pub fn main() { | ||
// The expected arm type `Option<T>` has one type parameter, while | ||
// the actual arm `Result<T, E>` has two. typeck should not be | ||
// tricked into looking up a non-existing second type parameter. | ||
let _x: uint = match Some(1u) { | ||
//~^ ERROR mismatched types: expected `uint` but found `<generic #0>` | ||
Ok(u) => u, //~ ERROR mismatched types: expected `std::option::Option<uint>` | ||
Err(e) => fail!(e) //~ ERROR mismatched types: expected `std::option::Option<uint>` | ||
}; | ||
} |
fc043c0
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 alexcrichton
at edwardw@fc043c0
fc043c0
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 edwardw/rust/vtable-ice = fc043c0 into auto
fc043c0
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.
edwardw/rust/vtable-ice = fc043c0 merged ok, testing candidate = 3efeac51
fc043c0
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.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4434
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5228
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5225
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4318
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4331
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5327
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4414
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4422
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5329
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4414
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4419
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2214
exception: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5325
fc043c0
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 alexcrichton
at edwardw@fc043c0
fc043c0
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 edwardw/rust/vtable-ice = fc043c0 into auto
fc043c0
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.
edwardw/rust/vtable-ice = fc043c0 merged ok, testing candidate = 347e9e4
fc043c0
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/5240
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5236
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4329
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4342
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5338
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4425
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4433
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5340
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4425
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4430
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4495
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2225
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5336
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4432
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4445
fc043c0
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 = 347e9e4