You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use modules (while learning rust at RustBridge, thanks for RustFest/RöstiFest ZH), I run into an internal compiler error that used Hmac + SHA256, when placing the use statements in the wrong place.
I tried this code:
externcrate sha2;externcrate hmac;externcrate base64;// Placing the use here is actually a compile error on Rust stable, with// a fine error message. Moving it to the right place (i.e. inside mod foo) it// works properly and gives the right error message and not an internal compiler erroruse hmac::{Hmac,Mac};use sha2::Sha256;use base64::encode;mod foo {pubfnhmac256(input:String,secret:&[u8]) -> String{letmut mac = Hmac::<Sha256>::new(secret);
mac.input(input.as_bytes());let result = mac.result();let bytes = result.code();encode(bytes)}}
I expected to see this happen:
error[E0433]: failed to resolve. Use of undeclared type or module `Hmac`
--> src/lib.rs:12:23
|
12 | let mut mac = Hmac::<Sha256>::new(secret);
| ^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `Hmac`
error[E0433]: failed to resolve. Use of undeclared type or module `Hmac`
--> src/lib.rs:12:23
|
12 | let mut mac = Hmac::<Sha256>::new(secret);
| ^^^^^^^^^^^^^^^^^^^ Use of undeclared type or module `Hmac`
error[E0412]: cannot find type `Sha256` in this scope
--> src/lib.rs:12:30
|
12 | let mut mac = Hmac::<Sha256>::new(secret);
| ^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
9 | use sha2::Sha256;
...and more like these
error: aborting due to 3 previous errors
Instead, this happened:
error[E0433]: failed to resolve. Use of undeclared type or module `Hmac`
--> src/lib.rs:12:23
|
12 | let mut mac = Hmac::<Sha256>::new(secret);
| ^^^^ Use of undeclared type or module `Hmac`
error[E0433]: failed to resolve. Use of undeclared type or module `Hmac`
--> src/lib.rs:12:23
|
12 | let mut mac = Hmac::<Sha256>::new(secret);
| ^^^^ Use of undeclared type or module `Hmac`
error[E0412]: cannot find type `Sha256` in this scope
--> src/lib.rs:12:30
|
12 | let mut mac = Hmac::<Sha256>::new(secret);
| ^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
11 | use sha2::Sha256;
|
error[E0425]: cannot find function `encode` in this scope
--> src/lib.rs:17:9
|
17 | encode(bytes)
| ^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
11 | use base64::encode;
|
warning: unused imports: `Hmac`, `Mac`
--> src/lib.rs:5:12
|
5 | use hmac::{Hmac, Mac};
| ^^^^ ^^^
|
= note: #[warn(unused_imports)] on by default
warning: unused import: `sha2::Sha256`
--> src/lib.rs:6:5
|
6 | use sha2::Sha256;
| ^^^^^^^^^^^^
warning: unused import: `base64::encode`
--> src/lib.rs:7:5
|
7 | use base64::encode;
| ^^^^^^^^^^^^^^
error[E0412]: cannot find type `Sha256` in this scope
--> src/lib.rs:12:30
|
12 | let mut mac = Hmac::<Sha256>::new(secret);
| ^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
11 | use sha2::Sha256;
|
error[E0425]: cannot find function `encode` in this scope
--> src/lib.rs:17:9
|
17 | encode(bytes)
| ^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
11 | use base64::encode;
|
warning: unused imports: `Hmac`, `Mac`
--> src/lib.rs:5:12
|
5 | use hmac::{Hmac, Mac};
| ^^^^ ^^^
|
= note: #[warn(unused_imports)] on by default
warning: unused import: `sha2::Sha256`
--> src/lib.rs:6:5
|
6 | use sha2::Sha256;
| ^^^^^^^^^^^^
warning: unused import: `base64::encode`
--> src/lib.rs:7:5
|
7 | use base64::encode;
| ^^^^^^^^^^^^^^
error: internal compiler error: src/librustc_typeck/check/mod.rs:2015: no type for node 27: type Sha256 (id=27) in fcx 0x700007762468
error: internal compiler error: src/librustc_typeck/check/mod.rs:2015: no type for node 27: type Sha256 (id=27) in fcx 0x700005c7c468
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.22.0-nightly (6f87d20a7 2017-09-29) running on x86_64-apple-darwin
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:492:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.22.0-nightly (6f87d20a7 2017-09-29) running on x86_64-apple-darwin
lwe
changed the title
Internal compiler error: src/librustc_typeck/check/mod.rs:2015: no type for node
ICE on nightly: src/librustc_typeck/check/mod.rs:2015: no type for node
Oct 1, 2017
When trying to use modules (while learning rust at RustBridge, thanks for RustFest/RöstiFest ZH), I run into an internal compiler error that used Hmac + SHA256, when placing the
use
statements in the wrong place.I tried this code:
I expected to see this happen:
Instead, this happened:
Meta
The text was updated successfully, but these errors were encountered: