-
-
Save xcv-/c0a79259a7b1280578e5 to your computer and use it in GitHub Desktop.
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
sudoku.rs:72:29: 72:34 error: internal compiler error: Cannot relate bound region: ReInfer(53) <= ReLateBound(284, BrNamed(syntax::ast::DefId{crate: 0u32, node: 303u32}, r)) | |
This message reflects a bug in the Rust compiler. | |
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report | |
sudoku.rs:72 self.rows_iter().all(|row| check(&row)) && | |
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
#0 0xb7b2a144 in rust_begin_unwind () from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#1 0xb7a535cb in rt::task::Unwinder::begin_unwind::h17a2150c59de0f8CiaO::v0.9.pre () | |
from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#2 0xb710a5a6 in ?? () from /usr/lib/libsyntax-2bb2d559d93ae8f0-0.9-pre.so | |
#3 0xb7116d49 in diagnostic::span_handler$CodemapT::span_fatal::h1e479c4b6afd9924zwa0::v0.9.pre () | |
from /usr/lib/libsyntax-2bb2d559d93ae8f0-0.9-pre.so | |
#4 0xb711800e in diagnostic::span_handler$CodemapT::span_bug::h27826be29cd0685ezwal::v0.9.pre () | |
from /usr/lib/libsyntax-2bb2d559d93ae8f0-0.9-pre.so | |
#5 0xb652583a in driver::session::Session_::span_bug::h61fc68e448dc98biraY::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#6 0xb684554e in middle::typeck::infer::region_inference::RegionVarBindings::make_subregion::hd9dd53a5181367b3UQa1::v0.9.pre () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#7 0xb682951d in middle::typeck::infer::sub::Combine$Sub::regions::he0cb54e470e99758Oqah::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#8 0xb68570a3 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#9 0xb686b8aa in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#10 0xb686ae2e in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#11 0xb686a4a5 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#12 0xb686abaa in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#13 0xb686a4a5 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#14 0xb677b253 in middle::typeck::infer::mk_sub_trait_refs::hd2796fb0db8cbc38a9::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#15 0xb677a9ce in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#16 0xb6778314 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#17 0xb66ce933 in middle::ty::each_bound_trait_and_supertraits::h4262d25687faaa1::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#18 0xb6776bdb in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#19 0xb677593a in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#20 0xb67810ec in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#21 0xb6780989 in middle::typeck::check::FnCtxt::opt_node_ty_substs::hd4fd9284948831ekdan::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#22 0xb677f033 in middle::typeck::check::vtable::early_resolve_expr::h1b3b84488785bedaV::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#23 0xb67fc120 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#24 0xb67f3462 in middle::typeck::check::check_expr_with_unifier::hee825eaba2e7f910aq::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#25 0xb67fb1f1 in middle::typeck::check::check_expr_with_opt_hint::hee8ee2c1325aba3ba7::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#26 0xb67d0e95 in middle::typeck::check::check_block_with_expected::hbacac6d8a91be452ag::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#27 0xb67ca8f5 in middle::typeck::check::check_fn::h67f0a78fc25f9f68ac::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#28 0xb6800b2d in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#29 0xb67ed94f in middle::typeck::check::check_expr_with_unifier::hee825eaba2e7f910aq::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#30 0xb67fae87 in middle::typeck::check::check_expr_coercable_to_type::he951b712d44452a8a4::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#31 0xb67fc2f7 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#32 0xb67fb900 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#33 0xb67f048a in middle::typeck::check::check_expr_with_unifier::hee825eaba2e7f910aq::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#34 0xb67fb357 in middle::typeck::check::check_expr::hc83cf6505e7a2e8az::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#35 0xb67fe3bc in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#36 0xb67ec8cc in middle::typeck::check::check_expr_with_unifier::hee825eaba2e7f910aq::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#37 0xb67fb357 in middle::typeck::check::check_expr::hc83cf6505e7a2e8az::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#38 0xb67fe3bc in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#39 0xb67ec8cc in middle::typeck::check::check_expr_with_unifier::hee825eaba2e7f910aq::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#40 0xb67fb1f1 in middle::typeck::check::check_expr_with_opt_hint::hee8ee2c1325aba3ba7::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#41 0xb67d0e95 in middle::typeck::check::check_block_with_expected::hbacac6d8a91be452ag::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
---Type <return> to continue, or q <return> to quit--- | |
#42 0xb67ca8f5 in middle::typeck::check::check_fn::h67f0a78fc25f9f68ac::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#43 0xb67c920f in middle::typeck::check::check_bare_fn::h15fbff936255b11eaI::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#44 0xb67d6cf7 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#45 0xb67c38ff in middle::typeck::check::check_item::hcf93a787ce721831aK::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#46 0xb67c1efd in middle::typeck::check::Visitor$CheckItemTypesVisitor::visit_item::h45eab47ca34be2847haJ::v0.9.pre () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#47 0xb67c880d in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#48 0xb67c8fe2 in middle::typeck::check::check_item_types::ha43d8d26be9c206dai::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#49 0xb68b0bbb in middle::typeck::check_crate::h4fab64a52d7581aaM::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#50 0xb6b98101 in driver::driver::phase_3_run_analysis_passes::ha311a62de90136ab::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#51 0xb6b9b949 in driver::driver::compile_input::hda9e416b69a6be50a5::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#52 0xb6bbd32c in run_compiler::he4a5f9439240b24fa3::v0.9.pre () | |
from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#53 0xb6bc8a25 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#54 0xb6bc7132 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#55 0xb6bc5224 in ?? () from /usr/lib/librustc-8581899a03b03e-0.9-pre.so | |
#56 0xb7b119ee in ?? () from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#57 0xb7b10583 in ?? () from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#58 0xb7b11c33 in ?? () from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#59 0xb7b2a0e3 in rust_try () from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#60 0xb7b104aa in rt::task::Unwinder::try::h1c9515fcec939d6Ciae::v0.9.pre () | |
from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#61 0xb7b0ff2d in rt::task::Task::run::hd0e519ec68192e6dG2ac::v0.9.pre () | |
from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#62 0xb7b10fbd in ?? () from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#63 0xb7b17805 in ?? () from /usr/lib/libstd-6425b930ca146ae9-0.9-pre.so | |
#64 0x00000000 in ?? () |
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
type Pos = (uint, uint); | |
struct Sudoku9 { data: [uint, ..9*9] } | |
impl Sudoku9 { | |
fn view<'r>(&'r mut self) -> SudokuView<'r> { | |
let len = self.data.len(); | |
SudokuView { | |
data: self.data, | |
side: (len as f32).sqrt() as uint, | |
offset: (0,0) | |
} | |
} | |
} | |
struct SudokuView<'self> { | |
data: &'self mut [uint], | |
side: uint, | |
offset: Pos | |
} | |
struct SudokuViewElemsIter<'self> { | |
view: &'self SudokuView<'self>, | |
index: uint | |
} | |
struct SudokuViewRow<'self> { | |
view: &'self SudokuView<'self>, | |
index: uint | |
} | |
struct SudokuViewRowsIter<'self>(SudokuViewRow<'self>); | |
struct SudokuViewRowIter<'self> { | |
row: &'self SudokuViewRow<'self>, | |
index: uint | |
} | |
struct SudokuViewCol<'self> { | |
view: &'self SudokuView<'self>, | |
index: uint | |
} | |
struct SudokuViewColsIter<'self>(SudokuViewCol<'self>); | |
struct SudokuViewColIter<'self> { | |
col: &'self SudokuViewCol<'self>, | |
index: uint | |
} | |
impl<'self> Index<Pos, uint> for SudokuView<'self> { | |
fn index(&self, &(x0,y0): &Pos) -> uint { | |
let (off_x, off_y) = self.offset; | |
let (x,y) = (x0 + off_x, y0 + off_y); | |
self.data[y * self.side + x] | |
} | |
} | |
impl<'self> SudokuView<'self> { | |
fn len(&mut self) -> uint { | |
self.data.len() | |
} | |
fn is_valid(&self) -> bool { | |
self.rows_iter().all(|row| check(&row)) && | |
self.cols_iter().all(|col| check(&col)) && | |
self.check(self) | |
} | |
fn rows_iter<'r>(&'r self) -> SudokuViewRowsIter<'r> { | |
SudokuViewRowsIter(SudokuViewRow { view: self, index: -1 }) | |
} | |
fn cols_iter<'r>(&'r self) -> SudokuViewColsIter<'r> { | |
SudokuViewColsIter(SudokuViewCol { view: self, index: -1 }) | |
} | |
} | |
fn check<'r, I: Iterator<uint>, T: Iterable<'r, uint, I>>(cont: &T) -> bool { | |
cont.iter().foldl(Some(0u16), |state, val| { | |
if val == 0 { | |
state | |
} else { | |
state.map(|mask| { | |
let bit = 1 << val; | |
if mask&bit == 0 {Some(mask|bit)} else {None} | |
}) | |
} | |
}).is_some() | |
} | |
trait Iterable<'r, T, I: Iterator<T>> { | |
fn iter(&'r self) -> I; | |
} | |
impl<'self> Iterable<'self, uint, SudokuViewElemsIter<'self>> for SudokuView<'self> { | |
fn iter(&'self self) -> SudokuViewElemsIter<'self> { | |
SudokuViewElemsIter { view: self, index: -1 } | |
} | |
} | |
impl<'self> Iterator<uint> for SudokuViewElemsIter<'self> { | |
fn next(&mut self) -> Option<uint> { | |
self.index += 1; | |
if self.index < self.view.side * self.view.side { | |
Some(self.view.data[self.index]) | |
} else { | |
None | |
} | |
} | |
} | |
impl<'self> Iterable<'self, uint, SudokuViewRowIter<'self>> for SudokuViewRow<'self> { | |
fn iter(&'self self) -> SudokuViewRowIter<'self> { | |
SudokuViewRowIter { row: self, index: -1 } | |
} | |
} | |
impl<'self> Iterator<SudokuViewRow<'self>> for SudokuViewRowsIter<'self> { | |
fn next(&mut self) -> Option<SudokuViewRow<'self>> { | |
(**self).index += 1; | |
if (**self).index < self.view.side { | |
Some(**self) | |
} else { | |
None | |
} | |
} | |
} | |
impl<'self> Iterator<uint> for SudokuViewRowIter<'self> { | |
fn next(&mut self) -> Option<uint> { | |
self.index += 1; | |
if self.index < self.row.view.side { | |
Some(self.row.view[(self.index, self.row.index)]) | |
} else { | |
None | |
} | |
} | |
} | |
impl<'self> Iterable<'self, uint, SudokuViewColIter<'self>> for SudokuViewCol<'self> { | |
fn iter(&'self self) -> SudokuViewColIter<'self> { | |
SudokuViewColIter { col: self, index: -1 } | |
} | |
} | |
impl<'self> Iterator<SudokuViewCol<'self>> for SudokuViewColsIter<'self> { | |
fn next(&mut self) -> Option<SudokuViewCol<'self>> { | |
(**self).index += 1; | |
if (**self).index < self.view.side { | |
Some(**self) | |
} else { | |
None | |
} | |
} | |
} | |
impl<'self> Iterator<uint> for SudokuViewColIter<'self> { | |
fn next(&mut self) -> Option<uint> { | |
self.index += 1; | |
if self.index < self.col.view.side { | |
Some(self.col.view[(self.col.index, self.index)]) | |
} else { | |
None | |
} | |
} | |
} | |
fn main() { | |
let mut test = Sudoku9 { | |
data: | |
[1,2,3, 4,5,6, 7,8,9 | |
,2,3,4, 5,6,7, 8,9,1 | |
,3,4,5, 6,7,8, 9,1,2 | |
,4,5,6, 7,8,9, 1,2,3 | |
,5,6,7, 8,9,1, 2,3,4 | |
,6,7,8, 9,1,2, 3,4,5 | |
,7,8,9, 1,2,3, 4,5,6 | |
,8,9,1, 2,3,4, 5,6,7 | |
,9,1,2, 3,4,5, 6,7,8] | |
}; | |
println!("{}", test.view().is_valid()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment