Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very minor changes causing unrelated module to fail to compile in a nonsense fashion #32222

Closed
sgrif opened this issue Mar 13, 2016 · 4 comments · Fixed by #32227
Closed

Very minor changes causing unrelated module to fail to compile in a nonsense fashion #32222

sgrif opened this issue Mar 13, 2016 · 4 comments · Fixed by #32227

Comments

@sgrif
Copy link
Contributor

sgrif commented Mar 13, 2016

Unfortunately, I can't reproduce this at a smaller scale. This issue occurs with https://github.com/sgrif/diesel as of commit 9084bb62d74f50e5686a85d6145cfe655ee2a3ba. Rust version is rustc 1.9.0-nightly (c9629d61c 2016-03-10)

Currently the tests (run from the diesel_tests directory with cargo test --no-default-features --features "unstable postgres") pass. However, applying the following patch:

diff --git a/diesel_tests/tests/boxed_queries.rs b/diesel_tests/tests/boxed_queries.rs
new file mode 100644
index 0000000..5cb4cbb
--- /dev/null
+++ b/diesel_tests/tests/boxed_queries.rs
@@ -0,0 +1,2 @@
+use super::schema::*;
+use diesel::*;
diff --git a/diesel_tests/tests/lib.rs b/diesel_tests/tests/lib.rs
index aef11d1..901a091 100644
--- a/diesel_tests/tests/lib.rs
+++ b/diesel_tests/tests/lib.rs
@@ -11,6 +11,7 @@ include!("lib.in.rs");
 include!(concat!(env!("OUT_DIR"), "/lib.rs"));

 mod associations;
+mod boxed_queries;
 mod expressions;
 mod connection;
 mod filter;

causes the following compiler error:

tests/types_roundtrip.rs:87:9: 87:18 error: a module named `connection` has already been imported in this module [E0252]
tests/types_roundtrip.rs:87     use super::*;
                                    ^~~~~~~~~
tests/types_roundtrip.rs:87:9: 87:18 help: run `rustc --explain E0252` to see a detailed explanation
tests/types_roundtrip.rs:87:9: 87:18 note: previous import of `connection` here
tests/types_roundtrip.rs:87     use super::*;

which is claiming that an import conflicts with itself. I have pushed up the branch compiler-error-demo with that change applied for easy reproduction. Again, I'm sorry that I cannot provide a report on a smaller scale, but this appears to be some edge case blowing up. I have no clue why adding a module with a few imports and nothing else would be causing this issue.

@sgrif
Copy link
Contributor Author

sgrif commented Mar 13, 2016

Bisecting to find the nightly which caused this

@sgrif
Copy link
Contributor Author

sgrif commented Mar 13, 2016

I can confirm that this issue does not occur on nightly-2016-03-05. Unfortunately, there was a bug that prevented us from compiling on nightly-2016-03-06 that wasn't fixed until nightly-2016-03-11, so I cannot provide anything more specific than that.

sgrif added a commit to diesel-rs/diesel that referenced this issue Mar 13, 2016
This is the first pass of what will be a much larger feature. The
intention is to support cases such as this:

```rust
let mut source = users::table.into_boxed();

if let Some(search) = params.search {
    source = source.filter(name.like(format!("%{}%", search)));
}

if let Some(order) = column_with_name(params.order) {
    source = source.order(order.desc());
}

let users = source.load(&connection);
```

Right now, this is basically impossible, as `source` needs to have the
same type, and each query in diesel has a unique type. This *will*
result in a slowdown of the query builder when used (though I think we
can still work to eliminate this cost through prepared statement
caching). However, this will not affect the performance of anything that
isn't using it.

As of this commit, we do not achieve the above use case, as
`BoxedSelectStatement` doesn't implement any of our query DSLs. The
intent is to have it implement all of them, but this felt like a good
place to cut a first pass.

This will fail to compile due to
rust-lang/rust#32222. We can resolve this by
pointing at `nightly-2016-03-05` if needed, but hopefully that can be
resolved upstream in the next day or two.
@alexcrichton
Copy link
Member

cc @jseyfried

@jseyfried
Copy link
Contributor

@sgrif Thanks for the report!

This bug was introduced in #31726. I diagnosed the issue and will fix it ASAP.

jseyfried added a commit to jseyfried/rust that referenced this issue Mar 13, 2016
jseyfried added a commit to jseyfried/rust that referenced this issue Mar 13, 2016
bors added a commit that referenced this issue Mar 13, 2016
…chton

Fix import resolution bug

This fixes #32222, which was introduced in #31726.
sgrif added a commit to diesel-rs/diesel that referenced this issue Mar 20, 2016
This is the first pass of what will be a much larger feature. The
intention is to support cases such as this:

```rust
let mut source = users::table.into_boxed();

if let Some(search) = params.search {
    source = source.filter(name.like(format!("%{}%", search)));
}

if let Some(order) = column_with_name(params.order) {
    source = source.order(order.desc());
}

let users = source.load(&connection);
```

Right now, this is basically impossible, as `source` needs to have the
same type, and each query in diesel has a unique type. This *will*
result in a slowdown of the query builder when used (though I think we
can still work to eliminate this cost through prepared statement
caching). However, this will not affect the performance of anything that
isn't using it.

As of this commit, we do not achieve the above use case, as
`BoxedSelectStatement` doesn't implement any of our query DSLs. The
intent is to have it implement all of them, but this felt like a good
place to cut a first pass.

This will fail to compile due to
rust-lang/rust#32222. We can resolve this by
pointing at `nightly-2016-03-05` if needed, but hopefully that can be
resolved upstream in the next day or two.
sgrif added a commit to diesel-rs/diesel that referenced this issue Mar 27, 2016
This is the first pass of what will be a much larger feature. The
intention is to support cases such as this:

```rust
let mut source = users::table.into_boxed();

if let Some(search) = params.search {
    source = source.filter(name.like(format!("%{}%", search)));
}

if let Some(order) = column_with_name(params.order) {
    source = source.order(order.desc());
}

let users = source.load(&connection);
```

Right now, this is basically impossible, as `source` needs to have the
same type, and each query in diesel has a unique type. This *will*
result in a slowdown of the query builder when used (though I think we
can still work to eliminate this cost through prepared statement
caching). However, this will not affect the performance of anything that
isn't using it.

As of this commit, we do not achieve the above use case, as
`BoxedSelectStatement` doesn't implement any of our query DSLs. The
intent is to have it implement all of them, but this felt like a good
place to cut a first pass.

This will fail to compile due to
rust-lang/rust#32222. We can resolve this by
pointing at `nightly-2016-03-05` if needed, but hopefully that can be
resolved upstream in the next day or two.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants