Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign updiesel_codegen_syntex panics with underflow #416
Comments
This comment has been minimized.
|
TL;DR: Not sure if this is a bug in Diesel or rustc but we should see if we can fix it on our end, and there's a pretty straightforward way to do that. The rest of this comment are technical details on the issue which you may or may not find interesting. Possibly boring technical details about the issueSo this actually has little to do with syntex, this bug can be reproduced with nightly and rustc plugins as well. I'm really not sure if this is a bug in rustc, Diesel, or neither. The issue comes from the code that we're generating. When building an AST everything takes a span which is basically a byte offset into a file. For code generation from derive, the span is pretty much always the span of the derive attribute itself, which in this case is byte 0. The code we'll be generating for that struct is: impl<__ST, __DB> Queryable<__ST, __DB> for T where
__DB: Backend + HasSqlType<__ST>,
((),): FromSqlRow<__ST, __DB>,
{
type Row = ((),);
fn build(row: Self::Row) -> Self {
T {
_dummy: row.0,
}
}
}(Yes I suspect that the assumptions the compiler is making about the span are incorrect. But that doesn't matter, as we can't demonstrate this as an issue through any public APIs and this is a private, internal API for rustc. Interestingly, this code differs from what we would generate using our stable macro, which would be: impl<__ST, __DB> Queryable for T where
__DB: Backend + HasSqlType<__ST>,
((),): FromSqlRow<__ST, __DB>,
{
type Row = ((),);
fn build(row: Self::Row) -> Self {
let (_dummy,) = row;
T {
_dummy: _dummy,
}
}
}I've been changing all of our syntex/nightly macros to be implemented purely in terms of the stable macro form in order to get access to |
sgrif
added this to the
0.8 milestone
Aug 25, 2016
This comment has been minimized.
|
I've submitted a fix upstream either way. rust-lang/rust#35990 |
This comment has been minimized.
|
This is a Rust issue not a diesel issue. rust-lang/rust#36081 |
overdrivenpotato commentedAug 24, 2016
•
edited
Example repository: https://github.com/overdrivenpotato/dcs_underflow
cargo buildfails with an underflow error:Seems to be caused by
#[derive(Queryable)]being the first line in a file, adding a space or anything else before the#prevents the issue.I'm not sure if this is a bug with diesel or syntex, let me know if I should move this over to the syntex issue tracker.