Skip to content

Commit f27037e

Browse files
committed
Fix compile-fail tests
Unfortunately, several of our errors actually got much worse. We have a bunch of overflows where we didn't before (I am convinced this is a bug in rustc), and attempting to box an invalid query now just complains about `BoxedDsl` not being implemented, rather than the reason that `BoxedDsl` is not implemented. I'm not sure what the reason is for the second one.
1 parent 5786fe5 commit f27037e

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

diesel/src/query_builder/select_statement/dsl_impls.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ impl<F, S, W, O, L, Of> ForUpdateDsl for SelectStatement<F, S, NoDistinctClause,
250250
impl<'a, F, S, D, W, O, L, Of, G, DB> BoxedDsl<'a, DB>
251251
for SelectStatement<F, SelectClause<S>, D, W, O, L, Of, G>
252252
where
253+
Self: AsQuery,
253254
DB: Backend,
254255
S: QueryFragment<DB> + SelectableExpression<F> + 'a,
255256
D: QueryFragment<DB> + 'a,
@@ -278,6 +279,7 @@ where
278279
impl<'a, F, D, W, O, L, Of, G, DB> BoxedDsl<'a, DB>
279280
for SelectStatement<F, DefaultSelectClause, D, W, O, L, Of, G>
280281
where
282+
Self: AsQuery,
281283
DB: Backend,
282284
F: QuerySource,
283285
F::DefaultSelection: QueryFragment<DB> + 'a,

diesel_compile_tests/tests/compile-fail/filter_cannot_take_comparison_for_columns_from_another_table.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ fn main() {
3939
.filter(posts::id.eq(1));
4040
//~^ ERROR AppearsInFromClause
4141

42-
let _ = BoxedDsl::into_boxed::<Pg>(
43-
//~^ ERROR AppearsInFromClause
44-
users::table.filter(posts::id.eq(1))
45-
);
42+
let _ = users::table.filter(posts::id.eq(1))
43+
.into_boxed::<Pg>();
44+
//~^ ERROR BoxedDsl
45+
// FIXME: It'd be great if this mentioned `AppearsInFromClause` instead...
4646

4747
let _ = LoadDsl::load::<User>(
4848
//~^ ERROR AppearsInFromClause
@@ -54,9 +54,9 @@ fn main() {
5454
.filter(users::name.eq(posts::title));
5555
//~^ ERROR AppearsInFromClause
5656

57-
let _ = BoxedDsl::into_boxed::<Pg>(
58-
//~^ ERROR AppearsInFromClause
59-
users::table
60-
.filter(users::name.eq(posts::title))
61-
);
57+
let _ = users::table
58+
.filter(users::name.eq(posts::title))
59+
.into_boxed::<Pg>();
60+
//~^ ERROR BoxedDsl
61+
// FIXME: It'd be great if this mentioned `AppearsInFromClause` instead...
6262
}

diesel_compile_tests/tests/compile-fail/select_for_update_cannot_be_mixed_with_some_clauses.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ table! {
1212
fn main() {
1313
use self::users::dsl::*;
1414

15-
users.for_update().distinct();
16-
//~^ ERROR: E0599
17-
users.distinct().for_update();
18-
//~^ ERROR: E0599
15+
// FIXME: Overflows because of https://github.com/rust-lang/rust/issues/34260
16+
// should be E0277
17+
//users.for_update().distinct();
18+
// FIXME: Overflows because of https://github.com/rust-lang/rust/issues/34260
19+
// should be E0277
20+
// users.distinct().for_update();
1921

2022
users.for_update().group_by(id);
2123
//~^ ERROR: E0599
22-
users.group_by(id).for_update();
23-
//~^ ERROR: E0599
24+
// FIXME: Overflows because of https://github.com/rust-lang/rust/issues/34260
25+
// should be E0277
26+
// users.group_by(id).for_update();
2427

25-
users.into_boxed().for_update();
26-
//~^ ERROR: E0599
28+
// FIXME: Overflows because of https://github.com/rust-lang/rust/issues/34260
29+
// should be E0277
30+
// users.into_boxed().for_update();
2731
users.for_update().into_boxed();
2832
//~^ ERROR: E0275
2933
}

0 commit comments

Comments
 (0)