Skip to content

Commit 4267ca4

Browse files
committed
Update our codebase for nightly-2016-07-07
Had to delete the test for the owned value to insert. Message involving the types is now a note not part of the error. Unsure if this is because it *actually* changed to a note, or if it's a quirk in compile_tests 0.2.0 (if I test for the note I need to specify *all* notes and the note on the overflow error is enought o make me not want to do that
1 parent a737308 commit 4267ca4

12 files changed

Lines changed: 37 additions & 55 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dist: trusty
44
rust:
55
- stable
66
- beta
7-
- nightly-2016-05-09
7+
- nightly-2016-07-07
88
- nightly
99
addons:
1010
postgresql: '9.4'

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
2424

2525
### Changed
2626

27+
* Diesel now targets `nightly-2016-07-07`. Future releases will update to a
28+
newer nightly version on the date that Rust releases.
29+
2730
* Most structs that implement `Queryable` will now also need
2831
`#[derive(Identifiable)]`.
2932

diesel_codegen/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ mod inner {
66
use std::env;
77
use std::path::Path;
88

9-
use self::syntax::ast;
109
use self::syntax::codemap::Span;
1110
use self::syntax::ext::base::{self, ExtCtxt};
11+
use self::syntax::tokenstream::TokenTree;
1212

1313
pub fn main() {
1414
let out_dir = env::var_os("OUT_DIR").unwrap();
@@ -19,7 +19,7 @@ mod inner {
1919
fn $name<'cx>(
2020
cx: &'cx mut ExtCtxt,
2121
sp: Span,
22-
tts: &[ast::TokenTree],
22+
tts: &[tokenstream::TokenTree],
2323
) -> Box<base::MacResult + 'cx> {
2424
syntax::ext::quote::$name(cx, sp, tts)
2525
}

diesel_codegen/src/dummy_schema_inference.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use syntax::ast;
21
use syntax::codemap::Span;
32
use syntax::ext::base::*;
3+
use syntax::tokenstream;
44

55
pub fn expand_load_table<'cx>(
66
cx: &'cx mut ExtCtxt,
77
sp: Span,
8-
_tts: &[ast::TokenTree]
8+
_tts: &[tokenstream::TokenTree]
99
) -> Box<MacResult+'cx> {
1010
cx.span_warn(sp, "load_table_from_schema! is only supported on PostgreSQL");
1111
DummyResult::any(sp)
@@ -14,7 +14,7 @@ pub fn expand_load_table<'cx>(
1414
pub fn expand_infer_schema<'cx>(
1515
cx: &'cx mut ExtCtxt,
1616
sp: Span,
17-
_tts: &[ast::TokenTree]
17+
_tts: &[tokenstream::TokenTree]
1818
) -> Box<MacResult+'cx> {
1919
cx.span_warn(sp, "infer_schema! is only supported on PostgreSQL");
2020
DummyResult::any(sp)

diesel_codegen/src/migrations.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ use syntax::ext::base::*;
77
use syntax::util::small_vector::SmallVector;
88
use syntax::ptr::P;
99
use syntax::ext::build::AstBuilder;
10+
use syntax::tokenstream;
1011

1112
pub fn expand_embed_migrations<'cx>(
1213
cx: &'cx mut ExtCtxt,
1314
sp: Span,
14-
tts: &[ast::TokenTree]
15+
tts: &[tokenstream::TokenTree]
1516
) -> Box<MacResult+'cx> {
1617
let migrations_expr = migrations_directory_from_args(cx, sp, tts)
1718
.and_then(|d| migration_literals_from_path(cx, sp, &d));
@@ -67,7 +68,7 @@ pub fn expand_embed_migrations<'cx>(
6768
fn migrations_directory_from_args(
6869
cx: &mut ExtCtxt,
6970
sp: Span,
70-
tts: &[ast::TokenTree],
71+
tts: &[tokenstream::TokenTree],
7172
) -> Result<PathBuf, Box<Error>> {
7273
let callsite_file = cx.codemap().span_to_filename(sp);
7374
let relative_path_to_migrations = if tts.is_empty() {

diesel_codegen/src/schema_inference/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ use syntax::ext::base::*;
1111
use syntax::parse::token::{InternedString, str_to_ident};
1212
use syntax::ptr::P;
1313
use syntax::util::small_vector::SmallVector;
14+
use syntax::tokenstream;
1415

1516
use self::data_structures::*;
1617

1718
pub fn expand_load_table<'cx>(
1819
cx: &'cx mut ExtCtxt,
1920
sp: Span,
20-
tts: &[ast::TokenTree]
21+
tts: &[tokenstream::TokenTree]
2122
) -> Box<MacResult+'cx> {
2223
let mut exprs = match get_exprs_from_tts(cx, sp, tts) {
2324
Some(ref exprs) if exprs.is_empty() => {
@@ -49,7 +50,7 @@ pub fn load_table_body<T: Iterator<Item=P<ast::Expr>>>(
4950
pub fn expand_infer_schema<'cx>(
5051
cx: &'cx mut ExtCtxt,
5152
sp: Span,
52-
tts: &[ast::TokenTree]
53+
tts: &[tokenstream::TokenTree]
5354
) -> Box<MacResult+'cx> {
5455
let mut exprs = match get_exprs_from_tts(cx, sp, tts) {
5556
Some(exprs) => exprs.into_iter(),
@@ -105,7 +106,7 @@ fn table_macro_call(
105106
table_name, primary_keys.len()));
106107
Err(DummyResult::any(sp))
107108
} else {
108-
let tokens = data.iter().map(|a| column_def_tokens(cx, a, &connection))
109+
let tokens = data.iter().map(|a| column_def_tokens(cx, sp, a, &connection))
109110
.collect::<Vec<_>>();
110111
let table_name = str_to_ident(table_name);
111112
let primary_key = str_to_ident(&primary_keys[0]);
@@ -131,11 +132,11 @@ fn next_str_lit<T: Iterator<Item=P<ast::Expr>>>(
131132
}
132133
}
133134

134-
fn column_def_tokens(cx: &mut ExtCtxt, attr: &ColumnInformation, conn: &InferConnection)
135-
-> Vec<ast::TokenTree>
135+
fn column_def_tokens(cx: &mut ExtCtxt, span: Span, attr: &ColumnInformation, conn: &InferConnection)
136+
-> Vec<tokenstream::TokenTree>
136137
{
137138
let column_name = str_to_ident(&attr.column_name);
138-
let tpe = determine_column_type(cx, attr, conn);
139+
let tpe = determine_column_type(cx, span, attr, conn);
139140
quote_tokens!(cx, $column_name -> $tpe,)
140141
}
141142

@@ -202,14 +203,14 @@ fn load_table_names(connection: &InferConnection) -> QueryResult<Vec<String>> {
202203
}
203204
}
204205

205-
fn determine_column_type(cx: &mut ExtCtxt, attr: &ColumnInformation, conn: &InferConnection)
206+
fn determine_column_type(cx: &mut ExtCtxt, span: Span, attr: &ColumnInformation, conn: &InferConnection)
206207
-> P<ast::Ty>
207208
{
208209
match *conn {
209210
#[cfg(feature = "sqlite")]
210-
InferConnection::Sqlite(_) => sqlite::determine_column_type(cx, attr),
211+
InferConnection::Sqlite(_) => sqlite::determine_column_type(cx, span, attr),
211212
#[cfg(feature = "postgres")]
212-
InferConnection::Pg(_) => pg::determine_column_type(cx, attr),
213+
InferConnection::Pg(_) => pg::determine_column_type(cx, span, attr),
213214
}
214215
}
215216

diesel_codegen/src/schema_inference/pg.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use diesel::*;
22
use diesel::pg::PgConnection;
33
use syntax::ast;
4+
use syntax::codemap::Span;
45
use syntax::ext::base::*;
5-
use syntax::ptr::P;
66
use syntax::parse::token::str_to_ident;
7+
use syntax::ptr::P;
78

89
use super::data_structures::*;
910

@@ -45,7 +46,7 @@ table! {
4546
}
4647
}
4748

48-
pub fn determine_column_type(cx: &mut ExtCtxt, attr: &ColumnInformation) -> P<ast::Ty> {
49+
pub fn determine_column_type(cx: &mut ExtCtxt, _span: Span, attr: &ColumnInformation) -> P<ast::Ty> {
4950
let tpe = if attr.type_name.starts_with("_") {
5051
let subtype = str_to_ident(&capitalize(&attr.type_name[1..]));
5152
quote_ty!(cx, Array<$subtype>)

diesel_codegen/src/schema_inference/sqlite.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use diesel::expression::dsl::sql;
33
use diesel::sqlite::{SqliteConnection, Sqlite};
44
use diesel::types::{HasSqlType, FromSqlRow};
55
use syntax::ast;
6+
use syntax::codemap::Span;
67
use syntax::ext::base::*;
78
use syntax::ptr::P;
89

@@ -26,7 +27,7 @@ pub fn get_table_data(conn: &SqliteConnection, table_name: &str)
2627
sql::<pragma_table_info::SqlType>(&query).load(conn)
2728
}
2829

29-
pub fn determine_column_type(cx: &mut ExtCtxt, attr: &ColumnInformation) -> P<ast::Ty> {
30+
pub fn determine_column_type(cx: &mut ExtCtxt, span: Span, attr: &ColumnInformation) -> P<ast::Ty> {
3031
let type_name = attr.type_name.to_lowercase();
3132
let tpe = if is_bool(&type_name) {
3233
quote_ty!(cx, ::diesel::types::Bool)
@@ -45,7 +46,7 @@ pub fn determine_column_type(cx: &mut ExtCtxt, attr: &ColumnInformation) -> P<as
4546
} else if is_double(&type_name) {
4647
quote_ty!(cx, ::diesel::types::Double)
4748
} else {
48-
cx.span_err(cx.original_span(), &format!("Unsupported type: {}", type_name));
49+
cx.span_err(span, &format!("Unsupported type: {}", type_name));
4950
quote_ty!(cx, ())
5051
};
5152

diesel_compile_tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ authors = ["Sean Griffin <sean@seantheprogrammer.com>"]
66
[dependencies]
77
diesel = { path = "../diesel", features = ["sqlite", "postgres"] }
88
diesel_codegen = { path = "../diesel_codegen", default-features = false, features = ["nightly", "postgres", "sqlite"] }
9-
compiletest_rs = "0.1.0"
9+
compiletest_rs = "0.2.0"

diesel_compile_tests/tests/compile-fail/find_requires_correct_type.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ fn main() {
2121
int_primary_key::table.find("1").first(&connection).unwrap();
2222
//~^ ERROR no method named `first` found for type `diesel::query_source::filter::FilteredQuerySource<int_primary_key::table, diesel::expression::predicates::Eq<int_primary_key::columns::id, &str>>` in the current scope
2323
//~| ERROR E0277
24+
//~| ERROR E0277
25+
//~| ERROR E0277
2426
string_primary_key::table.find(1).first(&connection).unwrap();
2527
//~^ ERROR no method named `first` found for type `diesel::query_source::filter::FilteredQuerySource<string_primary_key::table, diesel::expression::predicates::Eq<string_primary_key::columns::id, _>>` in the current scope
2628
//~| ERROR E0277
29+
//~| ERROR E0277
30+
//~| ERROR E0277
31+
//~| ERROR E0277
32+
//~| ERROR E0277
2733
}

0 commit comments

Comments
 (0)