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

nightly doesn't show the line number for some error #51219

Closed
bbigras- opened this issue May 30, 2018 · 9 comments
Closed

nightly doesn't show the line number for some error #51219

bbigras- opened this issue May 30, 2018 · 9 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@bbigras-
Copy link

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.28.0-nightly (524ad9b 2018-05-29)

Here's an error without a line number:

error[E0559]: variant `ldap::LdapError::NotInGroup` has no field named `name`
  |
  = note: available fields are: `group_name`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0559`.
error: Could not compile `some_project`.
@GuillaumeGomez
Copy link
Member

I'll take a look.

@GuillaumeGomez GuillaumeGomez self-assigned this May 31, 2018
@GuillaumeGomez
Copy link
Member

I was able to get the error and I have the expected lines:

fn main() {
    enum Mouth {Foo{x: i32}, Bar};

    let x = Mouth::Foo {y: 0};
}

Can you provide a small code sample with this issue please?

@bbigras-
Copy link
Author

bbigras- commented Jun 1, 2018

It might have something to do with formatting. The following code causes the problem for me but the problem goes away if I format the code using cargo fmt.

deps
[dependencies]
failure = "0.1"
futures-await = "0.1"
ldap3 = "0.6"
tokio-core = "0.1"
code
#![feature(proc_macro, generators)]

extern crate futures_await as futures;
extern crate ldap3;
extern crate tokio_core;

#[macro_use]
extern crate failure;

use tokio_core::reactor::Handle;
use ldap3::{LdapConnAsync, Scope};
use futures::prelude::*;
use failure::Error;

use std::io::Write;

#[derive(Fail)]
enum LdapError {
    #[fail(display = "InvalidCreds: {}", name)]
    InvalidCreds { name: String },

    #[fail(display = "NotInGroup: {}", group_name)]
    NotInGroup { group_name: String },
}

#[async]
fn test_user_has_access(handle: Handle) -> Result<(), Error> {
    let r = LdapConnAsync::new("ldap://localhost:2389", &handle)?
        .map_err(|e| {
            let e2: Error = e.into();
            e2
        })
        .and_then(move |ldap| {
            ldap.simple_bind("bind_user", "bind_pass")
                .map_err(Into::into)
                .and_then(move |ldap2| {
                    let j = if ldap2.rc == 49 {
                        Err(LdapError::InvalidCreds { name: "some_user".to_string() }.into())
                    } else {
                        Ok(())
                    };

                    j.into_future().and_then(|()| {
                        ldap.search("something", Scope::Subtree, "something", vec![])
                            .map_err(Into::into)
                    })
                })
        });

    return Err(LdapError::NotInGroup {
        name: "test".to_string(),
    }.into());
}

fn main() {}

@GuillaumeGomez
Copy link
Member

Ok, I think the problem comes from async/await.

cc @rust-lang/compiler

@estebank
Copy link
Contributor

estebank commented Jun 4, 2018

That output seems consistent with a lack of spans or finding DUMMY_SP in the diagnostic. This can happen when the code is in a separate crate, but the primary span should always be pointing at local code...

@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 4, 2018
@eddyb
Copy link
Member

eddyb commented Jun 4, 2018

@estebank It might be caused, in this case, by macro expansion.

@estebank
Copy link
Contributor

estebank commented Jun 4, 2018

@eddyb that sounds likely.

@Mark-Simulacrum
Copy link
Member

I suspect this is somewhat "unfixable" -- proc macros sometimes just lose spans if they make no effort to preserve them. As such, I'm going to close; if a minimal example can be shown to have a similar error with just macro_rules we can probably reopen.

@estebank
Copy link
Contributor

I don't entirely agree, but we already have #51635 covering related remediations so closing this should be ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

5 participants