Skip to content

Missing filename and line number in error #811

@jminer

Description

@jminer

I don't know if this is a rustc bug or Rocket bug, but since it is happening with a Rocket macro, I thought I'd start here. While updating Rocket to the newest version, I ran into a compile error with no file or line number.

Newest Rocket from git (983ee9b)
Windows 10 64-bit
Rust nightly 8b096314a 2018-11-02
This issue also happened with the Rocket and rustc from a week ago.

#![feature(proc_macro_hygiene, decl_macro)]

use rocket::request::Form};
use rocket::response::content::Plain

#[macro_use]
extern crate rocket;

fn main() {
    rocket::ignite()
        .mount("/", routes![create_account_post])
        .launch();
}

fn create_user(email: &str) -> Result<(), ()> {
    Ok(())
}

#[derive(FromForm)]
struct CreateAccountForm {
    email: String,
}

#[post("/create-account", data = "<form>")]
fn create_account_post(form: Form<CreateAccountForm>) -> Plain<String> {
    let f = form.get();
    match create_user(&f.email) {
        Err(()) => {
            return Plain("".into());
        },
        res @ _ => res.unwrap(),
    }

    Plain("".into())
}

I get this error

error[E0599]: no method named `get` found for type `rocket::request::Form<CreateAccountForm>` in the current scope
  |
  = help: items from traits can only be used if the trait is implemented and in scope
  = note: the following traits define an item `get`, perhaps you need to implement one of them:
          candidate #1: `core::panic::BoxMeUp`
          candidate #2: `std::slice::SliceIndex`

which does not include the file or line number of the error. I've tried making some changes like removing the match so I'm ignoring the return value of create_user(), and then I do get file and line number. But with the code as is, it seems all errors in the function are missing file and line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamAn unresolvable issue: an upstream dependency bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions