-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Rustc does display a correct error message on type missmatch but does not show line numbers #51635
Comments
Can you verify wether you hit the same output on 1.27? |
I can try today in the evening, but I wont be successful with a 99% guarantee as I am dependant on multiple nightly-requiring crates, such as relm. |
Just had the same bug at a different place:
No linenumbers whatsoever. Every other error in the same compilation log displays linenumbers correctly. |
That is odd. Could you provide a repo with a repro case? I'd like to see this for myself to try and identify the source of the problem. |
Sure, I can provide you with the entire repo, the exact commits with the two problems and the excat rustc version when I get home. Could have done this a lot earlier, sorry. |
Ok, so, the commits are: The repo should be publicly accessible. Rustc is: rustc 1.28.0-nightly (86a8f1a 2018-06-17). A simple I hope this helps. |
#![feature(proc_macro, wasm_import_module, wasm_custom_section)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
const MEM_SIZE: usize = 1024 * 1024;
const BLOCK_SIZE: usize = 1024;
const NUM_BLOCKS: usize = MEM_SIZE / BLOCK_SIZE;
struct FAT
{
memory: [[u8; BLOCK_SIZE]; NUM_BLOCKS]
}
#[wasm_bindgen]
impl FAT
{
pub fn new() -> FAT
{
FAT
{
memory: [[0; BLOCK_SIZE], NUM_BLOCKS]
}
}
}
#[cfg(test)]
mod tests
{
use super::*;
#[test]
fn test_new_FAT()
{
let newFS = FAT::new();
for blk in 0..NUM_BLOCKS
{
for b in 0..BLOCK_SIZE
{
assert_eq!(newFS.memory[blk][b], 0);
}
}
}
} seems to trigger the issue too. Courtesy to @Coolerz on #rust. The common denominator of this and my code is |
That is very likely the culprit, as with proc macros we (usually) lose the spans. I'd have to see if we have any other bit of context that could be used instead. |
Yeah, I am sorry, I don't understand too much of it yet ;) Thanks for investigating =) |
Hi, my temporary hack to get better error information until this problem is solved is described in this gist (see the last paragraph of the README.md): https://gist.github.com/p4l1ly/6dbcb40fb3bbb450598876b068762939 |
Still happens for as well, on the latest nightly (1.39). |
Issue in docker image: rust-lang/docker-rust-nightly#17 UPD: it has nothing to do with docker, it is a problem of |
Is anybody working on this problem? Because I can't work on my project. Both nightly docker images I use don't show lines, only errors, it is really very hard to guess what is causing errors and where. |
I don't believe anyone is actively working on this issue, as no one has self-assigned. @petrochenkov might have some insight. @vityafx could you provide more information? Did it not use to happen in previous nightlies? Can you help us identify when it was introduced? What project are you seeing this in? As it stands we have @Yatekii's repro case, but we can't verify that it is the same issue you're seeing, and the underlying solution might be changes to the proc macro you're likely using. |
@estebank I was not using nightly actively for quite a while, but I think I did not have this problem on |
@vityafx could you point us in the direction of the project you're experiencing this with? |
If this can help, right now I am using nightly only for my rocket HTTP server. Code lines are not only invisible in |
One option @vityafx would be to use cargo-bisect-rustc to diagnose the exact nightly which caused the problem. That would be very helpful! |
@nikomatsakis Can do! |
I think this does not show exactly when the problem started to appear. I still need to find an MCVE and repeat the procedure. Because it may be simply hidden by the I'll see what I can do with MCVE and bisecting because I can't really work on the project without this... |
Have found an MCVE, bisecting. |
Could you guys tell me how to specify |
So far, I have only been able to achieve this: #![feature(proc_macro_hygiene, decl_macro)]
type Result<T> = std::result::Result<T, ()>;
pub fn f<T>(f: &dyn Fn() -> Result<T>) -> Result<T> {
f()
}
// Either comment this line below with `rocket::post`...
#[rocket::post("/")]
fn open_session() -> Result<String> {
// ...or comment this if, or don't call "f" function
if let Ok(_) = f(&|| Ok(())) {
// This if also reproduces.
// if let Ok(_) = &|| Ok(()) {
return Ok("2".to_string())
}
Ok("1")
}
fn main() {
} It can be that the minimal example can be still narrowed down. UPD: simplifying the code I've come up with this: #![feature(proc_macro_hygiene, decl_macro)]
// Either comment this line below with `rocket::post`...
#[rocket::post("/")]
fn problem() -> String {
// If I surround the lambda with parens as below, everything is okay.
//
// if let Some(_) = (|| Some(())) {
//
// But if not, the code causing problems is not shown. Also,
// instead of a lambda there can be a function call.
if let Some(_) = || Some(()) {
return "2".to_string()
}
// This should be the line causing the error.
1
}
fn main() {
} |
We should probably look at Modifying the following to unconditionally rust/src/libsyntax/parse/token.rs Lines 806 to 808 in 43a5ff4
but I am looking at whether the "AST modified directly diverges from the pprinted version" problem is actually still happening but I haven't been able to reproduce a real case, and on the contrary some tests actually start behaving correctly (we seem to have had the same issue with |
I couldn't compile the project linked in #51635 (comment) The case in #51635 (comment) is already fixed #51635 (comment) is fixed by #64277, but that PR might need some back and forth before it is mergeable. |
triage: Still needs MCVE; in particular, I think it would be very valuable to have an MCVE that includes its own definition of a proc-macro, rather than relying on some third-party crate to provide it. |
I suggest adding a check into the compiler - if the compiler is unable to deduce context but found an error there, don't just print out the error, print out a message like |
FYI I've got a similar problem (error without line number) in stable rustc 1.41.0 (5e1a799 2020-01-27) |
I'm having this problem too. I made a repo with a minimal reproduction FWIW. I'm not sure if this completely explains the problem, but in this repo I defined two trivial proc macro attributes, one which spits out the code unchanged ( (cross-posted to #68430 (comment)) |
@maackle I cannot reproduce your MCVE with @pnkfelix A simple change however allows to trigger the problem in the example given by @maackle: fn gen<T>() -> Option<T> { None }
#[quoter]
fn beta() {
gen::< Result<(),()> >();
let _ = 1 + 1.0;
} error, has no line numbers and won't show in IDE's:
Change the first line to: gen::<()>(); and line numbers are correctly printed. |
I've been seeing similar issues in a client project for some weeks using recent nightly rusts (up to and including |
The general problem of losing line numbers with proc-macros is tracked at #43081. I suspect that the |
This should be fixed on the latest nightly. |
Confirmed that #51635 (comment) and #51635 (comment) are now fixed on nightly. Couldn't verify #51635 (comment) due to a failure on the Closing on favor of #43081 for any outstanding tasks (namely #80689). |
I have a case where rustc will show me properly that I have a Type missmatch.
Unfortunately it wont show me where exactly it is.
I tracked the error location down in my own code and can safely say that the code attached is the source, but I couldn't reproduce it yet.
Once I am able to reproduce it, I will report it here, but maybe someone already has a clue or similar experiences.
The faulty error report:
And the code that triggers it:
Rustc version is: nightly-x86_64-unknown-linux-gnu rustc 1.28.0-nightly (86a8f1a 2018-06-17)
The text was updated successfully, but these errors were encountered: