Skip to content

Commit 882347d

Browse files
committed
CHECKPOINT to report rust ICE bug. NOT TESTED
error: internal compiler error: get_unique_type_id_of_type() - unexpected type: closure, ty_unboxed_closure(syntax::ast::DefId{krate: 0u32, node: 837u32}, ReScope(836u32)) --HG-- branch : rust-closure-issue
1 parent 7519665 commit 882347d

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

src/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ mod test_opening {
523523
#[cfg(test)]
524524
mod tests {
525525
use super::{DatabaseConnection, SqliteResult, ResultSet};
526+
use super::super::{ResultRowAccess};
526527

527528
#[test]
528529
fn stmt_new_types() {

src/lib.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,23 @@ pub mod ffi;
8989

9090
pub mod access;
9191

92+
pub trait DatabaseUpdate {
93+
fn update<'db, 's>(&'db mut self,
94+
stmt: &'s mut PreparedStatement<'s>,
95+
values: &[&ToSql]) -> SqliteResult<uint>;
96+
}
97+
9298

93-
impl core::DatabaseConnection {
99+
impl DatabaseUpdate for core::DatabaseConnection {
94100
/// Execute a statement after binding any parameters.
95101
///
96102
/// When the statement is done, The [number of rows
97103
/// modified][changes] is reported.
98104
///
99105
/// [changes]: http://www.sqlite.org/c3ref/changes.html
100-
pub fn update<'db, 's>(&'db mut self,
101-
stmt: &'s mut PreparedStatement<'s>,
102-
values: &[&ToSql]) -> SqliteResult<uint> {
106+
fn update<'db, 's>(&'db mut self,
107+
stmt: &'s mut PreparedStatement<'s>,
108+
values: &[&ToSql]) -> SqliteResult<uint> {
103109
let check = {
104110
try!(bind_values(stmt, values));
105111
let mut results = stmt.execute();
@@ -113,12 +119,20 @@ impl core::DatabaseConnection {
113119
}
114120
}
115121

116-
impl<'s> core::PreparedStatement<'s> {
122+
123+
pub trait Query<'s> {
124+
fn query(&'s mut self,
125+
values: &[&ToSql],
126+
each_row: |&mut ResultRow|: 's -> SqliteResult<()>
127+
) -> SqliteResult<()>;
128+
}
129+
130+
impl<'s> Query<'s> for core::PreparedStatement<'s> {
117131
/// Process rows from a query after binding parameters.
118-
pub fn query(&'s mut self,
119-
values: &[&ToSql],
120-
each_row: |&mut ResultRow|: 's -> SqliteResult<()>
121-
) -> SqliteResult<()> {
132+
fn query(&'s mut self,
133+
values: &[&ToSql],
134+
each_row: |&mut ResultRow|: 's -> SqliteResult<()>
135+
) -> SqliteResult<()> {
122136
try!(bind_values(self, values));
123137
let mut results = self.execute();
124138
loop {
@@ -140,15 +154,20 @@ fn bind_values<'db>(s: &'db mut PreparedStatement, values: &[&ToSql]) -> SqliteR
140154
}
141155

142156

143-
impl<'s, 'r> core::ResultRow<'s, 'r> {
144-
pub fn get<I: RowIndex + Show + Clone, T: FromSql>(&mut self, idx: I) -> T {
157+
trait ResultRowAccess {
158+
fn get<I: RowIndex + Show + Clone, T: FromSql>(&mut self, idx: I) -> T;
159+
fn get_opt<I: RowIndex, T: FromSql>(&mut self, idx: I) -> SqliteResult<T>;
160+
}
161+
162+
impl<'s, 'r> ResultRowAccess for core::ResultRow<'s, 'r> {
163+
fn get<I: RowIndex + Show + Clone, T: FromSql>(&mut self, idx: I) -> T {
145164
match self.get_opt(idx.clone()) {
146165
Ok(ok) => ok,
147166
Err(err) => fail!("retrieving column {}: {}", idx, err)
148167
}
149168
}
150169
151-
pub fn get_opt<I: RowIndex, T: FromSql>(&mut self, idx: I) -> SqliteResult<T> {
170+
fn get_opt<I: RowIndex, T: FromSql>(&mut self, idx: I) -> SqliteResult<T> {
152171
match idx.idx(self) {
153172
Some(idx) => FromSql::from_sql(self, idx),
154173
None => Err(SQLITE_MISUSE)
@@ -237,6 +256,7 @@ pub enum ColumnType {
237256
#[cfg(test)]
238257
mod bind_tests {
239258
use super::{DatabaseConnection, ResultSet};
259+
use super::{ResultRowAccess};
240260
use super::{SqliteResult};
241261
242262
#[test]

src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl FromSql for time::Timespec {
124124
mod tests {
125125
use time::Tm;
126126
use super::super::{DatabaseConnection, SqliteResult};
127+
use super::super::{ResultRowAccess};
127128

128129
#[test]
129130
fn get_tm() {

0 commit comments

Comments
 (0)