-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Called Option::unwrap()
on a None
value, warning in simple hello world Rocket app
#10570
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
Comments
Which rustc version do you use? |
Can reproduce in |
This doesn't look like our panic. We might be missing some part of the |
This is happening to me as well using rust-analyzer 2021-11-08 on arch |
Possibly a dupe of #10710. |
This is still occurring on latest nightly release. |
Here's a smaller reproduction that builds on stable Rust 1.57.0: [package]
name = "macro-test"
version = "0.0.0"
edition = "2021"
publish = false
[lib]
# Needed because `unquote`'s syn dependency isn't set up correctly. It's hopefully not relevant.
proc_macro = true
[dependencies]
quote = "1.0.10"
syn = "1.0.83"
unquote = "0.0.6" use quote::quote;
use syn::parse::ParseStream;
use unquote::unquote;
#[allow(dead_code)]
fn parse(input: ParseStream) -> syn::Result<()> {
unquote!(input, a); // <--
Ok(())
} Settings (not minimal): {
"rust-analyzer.cargo-watch.command": "clippy",
"rust-analyzer.rainbowHighlightingOn": true,
"rust-analyzer.procMacro.enabled": true,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.checkOnSave.command": "clippy",
"rust-analyzer.experimental.procAttrMacros": true,
"rust-analyzer.cargo.allFeatures": true,
"rust-analyzer.checkOnSave.extraArgs": [
"--locked"
],
"rust-analyzer.updates.channel": "nightly"
}
Probably not relevant, but it's a fairly simple macro:#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
use quote::quote;
use syn::parse::ParseStream;
use unquote::unquote;
#[allow(dead_code)]
fn parse(input: ParseStream) -> syn::Result<()> {
let input = input;
let mut prev_span = input.cursor().span();
if input.call(<syn::Ident as syn::ext::IdentExt>::parse_any)?
!= syn::parse::Parser::parse2(<syn::Ident as syn::ext::IdentExt>::parse_any, {
let mut _s = ::quote::__private::TokenStream::new();
::quote::__private::push_ident(&mut _s, "a");
_s
})
.unwrap()
{
return Err(syn::Error::new(input.cursor().span(), "Expected `a`"));
};
Ok(())
}
const _: () = {
extern crate proc_macro;
#[rustc_proc_macro_decls]
#[allow(deprecated)]
static _DECLS: &[proc_macro::bridge::client::ProcMacro] = &[];
}; Error: [{
"resource": "[project directory]/src/lib.rs",
"owner": "rustc",
"code": {
"value": "macro-error",
"target": {
"$mid": 1,
"external": "https://rust-analyzer.github.io/manual.html#macro-error",
"path": "/manual.html",
"scheme": "https",
"authority": "rust-analyzer.github.io",
"fragment": "macro-error"
}
},
"severity": 8,
"message": "called `Option::unwrap()` on a `None` value",
"source": "rust-analyzer",
"startLineNumber": 7,
"startColumn": 5,
"endLineNumber": 7,
"endColumn": 23
}] Rust Analyzer Client output (abbreviated):
Rust Analyzer Language Server Trace appears to be empty. |
Hi, I am having this same issue with rocket. I use |
@MiroFurtado, @Tamschi, @oren0e see #10710 (comment). Updating to a newer version of Rocket might fix it. |
I'm not using Rocket and I'm on stable, so that's not the issue/fix for me, unfortunately. |
(A separate comment since @lnicola already saw the previous reply.) Should I open a separate issue? |
Unfortunately I can't use the rc version of rocket for various stability and dependency reasons, so that fix is not for me either (I use rocket 0.4.10). Any chance to work it out in rust-analyzer itself? |
this also occurred to me with realworld-rust-rocket. Any updates? |
Same Here. |
I hope #11797 has properly fixed this. If not, please leave a comment. |
Not for me. I still have
error in my vim (I use coc.nvim with rust-analyzer) on each one of my endpoints with rocket |
Presumably because of the same issue as #10772 (comment) |
@oren0e If you're still using the same nightly version as in #10570 (comment), it is quite outdated. We can't reasonably support outdated nightly versions. |
This compiles and runs fine but there is a rust-analyzer warning present in 2.776 and 2.768 but not in 2.760 and earlier versions of rust-analyzer.
The text was updated successfully, but these errors were encountered: