1# FAQ 2 3### Using nightly to get better error messages 4 5**warning**: this only applies to nom 3. nom 4 uses the 6[compile_error](https://doc.rust-lang.org/std/macro.compile_error.html) macro 7available since Rust 1.20 8 9If you got the following error when compiling your nom parser: 10 11``` 12error[E0425]: cannot find value `INVALID_NOM_SYNTAX_PLEASE_SEE_FAQ` in this scope 13 --> src/lib.rs:111:7 14 | 15111 | INVALID_NOM_SYNTAX_PLEASE_SEE_FAQ //https://github.com/Geal/nom/blob/main/doc/archive/FAQ.md#using-nightly-to-get-better-error-messages 16 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope 17``` 18 19It means that you are using Rust stable, and that one of your nom parsers has an invalid syntax. 20If you can switch to a nightly Rust compiler (as an example, with `rustup default nightly`), 21and if you activate the `nightly` feature on your nom dependency like this: 22 23```toml 24[dependencies.nom] 25version = "^3" 26features = ["nightly"] 27``` 28 29You can get more helpful error messages, such as this one: 30 31``` 32$ cargo test --features nightly 33 Compiling compiler_error v0.1.1 34 Compiling nom v3.0.0 (file:///Users/geal/dev/rust/projects/nom) 35error: "do_parse is missing the return value. A do_parse call must end 36 with a return value between parenthesis, as follows: 37 38 do_parse!( 39 a: tag!(\"abcd\") >> 40 b: tag!(\"efgh\") >> 41 42 ( Value { a: a, b: b } ) 43 " 44 --> src/sequence.rs:368:5 45 | 46368 | / compiler_error!("do_parse is missing the return value. A do_parse call must end 47369 | | with a return value between parenthesis, as follows: 48370 | | 49371 | | do_parse!( 50... | 51375 | | ( Value { a: a, b: b } ) 52376 | | "); 53 | |______^ 54... 55851 | / named!(no_compiler, 56852 | | do_parse!( 57853 | | length: be_u8 >> 58854 | | bytes: take!(length) 59855 | | ) 60856 | | ); 61 | |___- in this macro invocation 62 63error: aborting due to previous error(s) 64 65error: Could not compile `nom`. 66``` 67 68If the error message is not helpful, please reach out on the [Gitter chat](https://gitter.im/Geal/nom?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) or the IRC channel (#nom on freenode), and show 69your code and the error message you got. 70 71### nom 1.0 does not compile on Rust older than 1.4 72 73Typically, the error would look like this: 74 75```ignore 76src/stream.rs:74:44: 74:64 error: the parameter type `E` may not live long enough [E0309] 77src/stream.rs:74 if let &ConsumerState::Done(_,ref o) = self.apply(consumer) { 78 ^~~~~~~~~~~~~~~~~~~~ 79note: in expansion of if let expansion 80src/stream.rs:74:5: 78:6 note: expansion site 81src/stream.rs:74:44: 74:64 help: run `rustc --explain E0309` to see a detailed explanation 82src/stream.rs:74:44: 74:64 help: consider adding an explicit lifetime bound `E: 'b`... 83src/stream.rs:74:44: 74:64 note: ...so that the reference type `&stream::ConsumerState<O, E, M>` does not outlive the data it points at 84src/stream.rs:74 if let &ConsumerState::Done(_,ref o) = self.apply(consumer) { 85 ^~~~~~~~~~~~~~~~~~~~ 86note: in expansion of if let expansion 87src/stream.rs:74:5: 78:6 note: expansion site 88src/stream.rs:74:44: 74:64 error: the parameter type `M` may not live long enough [E0309] 89src/stream.rs:74 if let &ConsumerState::Done(_,ref o) = self.apply(consumer) { 90 ^~~~~~~~~~~~~~~~~~~~ 91note: in expansion of if let expansion 92src/stream.rs:74:5: 78:6 note: expansion site 93src/stream.rs:74:44: 74:64 help: run `rustc --explain E0309` to see a detailed explanation 94src/stream.rs:74:44: 74:64 help: consider adding an explicit lifetime bound `M: 'b`... 95src/stream.rs:74:44: 74:64 note: ...so that the reference type `&stream::ConsumerState<O, E, M>` does not outlive the data it points at 96src/stream.rs:74 if let &ConsumerState::Done(_,ref o) = self.apply(consumer) { 97 ^~~~~~~~~~~~~~~~~~~~ 98note: in expansion of if let expansion 99src/stream.rs:74:5: 78:6 note: expansion site 100error: aborting due to 2 previous errors 101 102Could not compile `nom`. 103``` 104 105This is caused by some lifetime issues that may be fixed in a future version of nom. In the meantime, you can add `default-features=false` to nom's declaration in `Cargo.toml` to deactivate this part of the code: 106 107```toml 108[dependencies.nom] 109version = "~1.0.0" 110default-features = false 111``` 112 113### The compiler indicates `error: expected an item keyword` then points to the function's return type in `named!`: 114 115```ignore 116error: expected an item keyword 117named!(multi<Vec<&str>>, many0!( map_res!(tag!( "abcd" ), str::from_utf8) ) ); 118 ^~~ 119``` 120 121This happens because the macro processor mistakes `>>` for an operator. It will work correctly by adding a space, like this: `named!(multi< Vec<&str> >, ...` 122