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

ICE on nightly: src/librustc_typeck/check/mod.rs:2015: no type for node #44957

Closed
lwe opened this issue Oct 1, 2017 · 2 comments
Closed

ICE on nightly: src/librustc_typeck/check/mod.rs:2015: no type for node #44957

lwe opened this issue Oct 1, 2017 · 2 comments

Comments

@lwe
Copy link

lwe commented 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:

extern crate sha2;
extern crate hmac;
extern crate 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 error
use hmac::{Hmac, Mac};
use sha2::Sha256;
use base64::encode;

mod foo {
    pub fn hmac256(input: String, secret: &[u8]) -> String {
        let mut 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

Meta

rustc 1.22.0-nightly (6f87d20a7 2017-09-29)
binary: rustc
commit-hash: 6f87d20a7cce70b8cc59a1adf3037d14bc83f237
commit-date: 2017-09-29
host: x86_64-apple-darwin
release: 1.22.0-nightly
LLVM version: 4.0
@lwe
Copy link
Author

lwe commented Oct 1, 2017

This could be a duplicate of #44820 and #44814.

@lwe 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
@petrochenkov
Copy link
Contributor

Should be fixed in #44945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants