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

Rust book : Guessing game doesn't build #34616

Closed
hhnr opened this issue Jul 2, 2016 · 21 comments
Closed

Rust book : Guessing game doesn't build #34616

hhnr opened this issue Jul 2, 2016 · 21 comments

Comments

@hhnr
Copy link
Contributor

hhnr commented Jul 2, 2016

When i try the program in rust playground it shows the following errors

<anon>:9:25: 9:41 error: unresolved name `rand::thread_rng` [E0425]
<anon>:9     let secret_number = rand::thread_rng().gen_range(1, 101);
                                 ^~~~~~~~~~~~~~~~
<anon>:9:25: 9:41 help: see the detailed explanation for E0425
error: aborting due to previous error
@hhnr hhnr changed the title Guessing game doesn't build Rust book : Guessing game doesn't build Jul 2, 2016
@hhnr
Copy link
Contributor Author

hhnr commented Jul 2, 2016

Trying to build the same with Nightly gives the following errors

error: unresolved name `rand::thread_rng` [--explain E0425]
 --> <anon>:9:25
  |>
9 |>     let secret_number = rand::thread_rng().gen_range(1, 101);
  |>                         ^^^^^^^^^^^^^^^^

error: aborting due to previous error

@hanna-kruppe
Copy link
Contributor

hanna-kruppe commented Jul 2, 2016

The playground doesn't have access to crates from crates.io, so normally you'd get an error about the crate not being found. This is know and expected, although it's of course not ideal.

Unfortunately, there is a crate internally used by std which is also called rand (it shares a lineage with the crates.io rand, but is distinct), meaning the import does work but it picks up the wrong crate. Luckily, that crate is unstable, so using it would normally tell you

error: use of unstable library feature 'rand': use `rand` from crates.io (see issue #27703)
 --> <anon>:1:1
  |>
1 |> extern crate rand;
  |> ^^^^^^^^^^^^^^^^^^

However, apparently name resolution errors happen before stability is checked, which obscures the real reason why the program won't run on the playground.

@hhnr
Copy link
Contributor Author

hhnr commented Jul 2, 2016

I'm getting the same error when I run cargo build. Does it build for you?

@hanna-kruppe
Copy link
Contributor

hanna-kruppe commented Jul 2, 2016

Did you add rand to Cargo.toml as described earlier in the tutorial?

[dependencies]

rand="0.3.0"

Edit: Yes, with that it does build for me.

@hhnr
Copy link
Contributor Author

hhnr commented Jul 2, 2016

Yes i have. Can you tell me what's wrong with this project?

@hhnr
Copy link
Contributor Author

hhnr commented Jul 2, 2016

rustc --version
rustc 1.9.0 (e4e8b6668 2016-05-18)

@hanna-kruppe
Copy link
Contributor

That repo uses thread_ng, not thread_rng (main.rs line 13)

@hhnr
Copy link
Contributor Author

hhnr commented Jul 2, 2016

Thanks. That solves the issue.

@hhnr hhnr closed this as completed Jul 2, 2016
@IngmarBitter
Copy link

IngmarBitter commented Feb 6, 2017

I have the same issue with rustc 1.15.0 (10893a9 2017-01-19) on Win10 x64
when following the tutorial

I have in Cargo.toml the section

[dependencies]
rand="0.3.0"

replacing rand::thread_rng with rand::thread_ng removed one build error, but I'm still left with two more:

>cargo build
   Compiling guessing_game v0.1.0 (file:///D:/_git/rust/guessing_game)
error: use of unstable library feature 'rand': use `rand` from crates.io (see issue #27703)
 --> src\main.rs:1:1
  |
1 | extern crate rand;
  | ^^^^^^^^^^^^^^^^^^

error: use of unstable library feature 'rand': use `rand` from crates.io (see issue #27703)
 --> src\main.rs:4:5
  |
4 | use rand::Rng;
  |     ^^^^^^^^^

I also noticed that building with the rand="0.3.0" dependency in Cargo.toml, there was no download of the library nor any addition to Cargo.lock.

What am I missing?

@steveklabnik
Copy link
Member

@IngmarBitter are you sure you saved the toml file? That'd be my first guess.

@IngmarBitter
Copy link

@steveklabnik thanks for making me double check that it was saved right.
It was saved, but in the directory of the previous tutorial step.
Saved in the right location fixed it.
Thanks for the quick response!

@jherrma
Copy link

jherrma commented Dec 15, 2018

I have the same problem as mention above.
My rustc version: 1.30.1
cargo versoin: 1.30.0

I double checked my Cargo.toml
This are my dependencies:
`[dependencies]

rand = "0.6.0"`

cargo does download the crate.

I try to import the rand crate in "main.rs", as described in the tutorial, with use rand::Rng;

The error of the compiler is, that it cannot resolve the import. This is the warning:
error[E0432]: unresolved import rand
--> src/main.rs:3:5
|
3 | use rand::Rng;
| ^^^^ Maybe a missing extern crate rand;?
[...]`

I also tried to import a different crate, but I get the same error.

Edit:
I could resolve this issue by adding the line
extern crate rand

This should be also updated in the book.

@steveklabnik
Copy link
Member

steveklabnik commented Dec 15, 2018 via email

@emacstheviking
Copy link

It's 2019; with a stock as-instructed installation on Ubuntu and following "the book", I get this when trying to use the random library:

7 | let secret_number = rand::thread_ng().gen_range(1,101);
| ^^^^ Use of undeclared type or module rand

warning: unused import: rand::Rng
--> src/main.rs:2:5
|
2 | use rand::Rng;
| ^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
sean in ~/Documents/rust/guessing_game on master ● λ cargo build
Compiling guessing_game v0.1.0 (file:///home/sean/Documents/rust/guessing_game)
error[E0432]: unresolved import rand
--> src/main.rs:2:5
|
2 | use rand::Rng;
| ^^^^ Maybe a missing extern crate rand;?

error[E0433]: failed to resolve. Use of undeclared type or module rand
--> src/main.rs:7:25
|
7 | let secret_number = rand::thread_ng().gen_range(1,101);
| ^^^^ Use of undeclared type or module rand

warning: unused import: rand::Rng
--> src/main.rs:2:5
|
2 | use rand::Rng;
| ^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

error: aborting due to 2 previous errors

error: Could not compile guessing_game.

Cargo config:
[package]
name = "guessing_game"
version = "0.1.0"
authors = ["Sean Charles sean@duesday.com"]
[dependencies]
rand = "0.3.4"

As my first introduction this is not ideal....what is the remedy? Surely the documentation cannot be read with confidence if it fails me on trying to do something this basic? I am using

rustc 1.25.0 (84203ca 2018-03-25)

which was intalled with:

curl https://sh.rustup.rs -sSf | sh

as instructed....TIA

@steveklabnik
Copy link
Member

I'm sorry you're running into this issue!

rustc 1.25.0 (84203ca 2018-03-25)

As I said above,

You need rust 1.31, or to use extern crate.

The book covers Rust 1.31+; you're using an older version. This means that you need to modify the code to include the line

extern crate rand;

at the top. The book covers the newer style of "Rust 2018", which your compiler doesn't support.

@emacstheviking
Copy link

@steveklabnik thanks!
I decided to build from source but...
ANy ideas what I may have done wrong...I literally check out to code and followed the instructions having first set the "extended" feature flag to get all the tools and pointed the installation to /home/sean/rust

Updating only changed submodules
Submodules updated in 0.04 seconds
Finished dev [unoptimized] target(s) in 0.18s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.16s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.17s
Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 codegen artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu, llvm)
Finished release [optimized] target(s) in 0.13s
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.16s
Copying stage1 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.17s
Copying stage1 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage1 codegen artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu, llvm)
Finished release [optimized] target(s) in 0.12s
Assembling stage2 compiler (x86_64-unknown-linux-gnu)
Uplifting stage1 std (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Copying stage2 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage2 tool cargo (x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.17s
Building stage2 tool clippy-driver (x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.14s
Building stage2 tool rls (x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.21s
Building rustdoc for stage2 (x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.14s
Building stage2 tool rustfmt (x86_64-unknown-linux-gnu)
Finished release [optimized] target(s) in 0.16s
Building stage2 tool miri (x86_64-unknown-linux-gnu)
Compiling miri v0.1.0 (/home/sean/Documents/rust/guessing_game/rust/src/tools/miri)
error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/mod.rs:77:34
|
77 | let cur_align = this.memory().get(ptr.alloc_id)?.align.bytes() as usize;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:29:78
|
29 | alloc_env_var(name.as_bytes(), value.as_bytes(), ecx.memory_mut());
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:55:25
|
55 | let name = this.memory().read_c_str(name_ptr)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:74:26
|
74 | let value = this.memory().read_c_str(value_ptr)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:77:29
|
77 | let name = this.memory().read_c_str(name_ptr)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0277]: the size for values of type [u8] cannot be known at compilation time
--> src/tools/miri/src/shims/env.rs:82:22
|
82 | if let Some((name, value)) = new {
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait std::marker::Sized is not implemented for [u8]
= note: to learn more, visit https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature

error[E0277]: the size for values of type [u8] cannot be known at compilation time
--> src/tools/miri/src/shims/env.rs:75:23
|
75 | let mut new = None;
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait std::marker::Sized is not implemented for [u8]
= note: to learn more, visit https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
= note: only the last element of a tuple may have a dynamically sized type

error[E0277]: the size for values of type [u8] cannot be known at compilation time
--> src/tools/miri/src/shims/env.rs:79:23
|
79 | new = Some((name.to_owned(), value.to_owned()));
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait std::marker::Sized is not implemented for [u8]
= note: to learn more, visit https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
= note: only the last element of a tuple may have a dynamically sized type

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:83:61
|
83 | let var_ptr = alloc_env_var(&name, &value, this.memory_mut());
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0277]: the size for values of type [u8] cannot be known at compilation time
--> src/tools/miri/src/shims/env.rs:82:28
|
82 | if let Some((name, value)) = new {
| ^^^^^ doesn't have a size known at compile-time
|
= help: the trait std::marker::Sized is not implemented for [u8]
= note: to learn more, visit https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature

error[E0277]: the size for values of type [u8] cannot be known at compilation time
--> src/tools/miri/src/shims/env.rs:82:16
|
82 | if let Some((name, value)) = new {
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: within ([u8], [u8]), the trait std::marker::Sized is not implemented for [u8]
= note: to learn more, visit https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
= note: required because it appears within the type ([u8], [u8])
= note: required by std::prelude::v1::Some

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:85:22
|
85 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:100:29
|
100 | let name = this.memory().read_c_str(name_ptr)?.to_owned();
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:107:22
|
107 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:145:26
|
145 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/env.rs:166:14
|
166 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:51:18
|
51 | .memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:55:22
|
55 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:69:18
|
69 | this.memory_mut().deallocate(ptr, None, kind.into())?;
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:87:26
|
87 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:93:31
|
93 | let memory = this.memory_mut();
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:182:36
|
182 | let ptr = this.memory_mut().allocate(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:211:32
|
211 | let ptr = this.memory_mut().allocate(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:227:32
|
227 | let ptr = this.memory_mut().allocate(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:233:22
|
233 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:251:22
|
251 | this.memory_mut().deallocate(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:272:36
|
272 | let new_ptr = this.memory_mut().reallocate(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:307:40
|
307 | let symbol_name = this.memory().read_c_str(symbol)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:311:36
|
311 | let ptr = this.memory_mut().create_fn_alloc(FnVal::Other(dlsym));
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:328:39
|
328 | let f_instance = this.memory().get_fn(f)?.as_instance()?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:372:43
|
372 | let left_bytes = this.memory().read_bytes(left, n)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:373:44
|
373 | let right_bytes = this.memory().read_bytes(right, n)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:391:22
|
391 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:409:22
|
409 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:480:41
|
480 | let buf_cont = this.memory().read_bytes(buf, Size::from_bytes(n))?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:512:30
|
512 | let n = this.memory().read_c_str(ptr)?.len();
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:642:49
|
642 | Some(dtor_ptr) => Some(this.memory().get_fn(dtor_ptr)?.as_instance()?),
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:664:22
|
664 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:667:22
|
667 | this.memory_mut().get_mut(key_ptr.alloc_id)?.write_scalar(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:852:22
|
852 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:858:22
|
858 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:913:26
|
913 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:988:14
|
988 | this.memory_mut().get_mut(errno_ptr.alloc_id)?.write_scalar(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/foreign_items.rs:1000:14
|
1000 | this.memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:71:22
|
71 | this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:86:22
|
86 | this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:107:22
|
107 | this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:123:22
|
123 | this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:176:22
|
176 | this.memory().check_ptr_access(place.ptr, place.layout.size, align)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:210:32
|
210 | let src = this.memory().check_ptr_access(src, size, elem_align)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:212:33
|
212 | let dest = this.memory().check_ptr_access(dest, size, elem_align)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:215:26
|
215 | this.memory_mut().copy(
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:362:34
|
362 | ... this.memory_mut().get_mut(ptr.alloc_id)?.write_repeat(tcx, ptr, 0, dest.layout.size)?;
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:551:34
|
551 | ... this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:566:28
|
566 | match this.memory().check_ptr_access(ptr, byte_count, ty_layout.align.abi)? {
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/intrinsics.rs:568:30
|
568 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/fs.rs:71:14
|
71 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/shims/fs.rs:166:22
|
166 | this.memory_mut()
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/shims/fs.rs:200:30
|
200 | let bytes = this.memory().get(buf.alloc_id).and_then(|alloc| {
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/shims/fs.rs:218:14
|
218 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/operator.rs:37:35
|
37 | let (size, _align) = self.memory().get_size_and_align(ptr.alloc_id, AllocCheck::Live)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/helpers.rs:57:45
|
57 | let null = Scalar::from_int(0, this.memory().pointer_size());
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/helpers.rs:94:24
|
94 | let ptr = this.memory().check_ptr_access(
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/helpers.rs:108:28
|
108 | let rng = this.memory_mut().extra.rng.get_mut();
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory_mut found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/helpers.rs:113:14
|
113 | this.memory_mut().get_mut(ptr.alloc_id)?.write_bytes(tcx, ptr, &data)
| ^^^^^^^^^^ method not found in &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>>

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/stacked_borrows.rs:536:24
|
536 | let ptr = this.memory().check_ptr_access(place.ptr, size, place.align)
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/stacked_borrows.rs:543:26
|
543 | let alloc = this.memory().get(ptr.alloc_id)?;
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/stacked_borrows.rs:595:35
|
595 | _ => Tag::Tagged(this.memory().extra.stacked_borrows.borrow_mut().new_ptr()),
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/machine.rs:167:13
|
167 | ecx.memory().extra.validate
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/machine.rs:352:16
|
352 | Ok(ecx.memory().extra.stacked_borrows.borrow_mut().new_call())
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory found for type &mut rustc_mir::interpret::InterpCx<'mir, 'tcx, machine::Evaluator<'tcx>> in the current scope
--> src/tools/miri/src/machine.rs:361:14
|
361 | .memory()
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

error[E0599]: no method named memory_mut found for type rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/eval.rs:96:10
|
96 | .memory_mut()
| ^^^^^^^^^^ method not found in rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>>

error[E0599]: no method named memory_mut found for type rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/eval.rs:131:17
|
131 | ecx.memory_mut()
| ^^^^^^^^^^ method not found in rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>>

error[E0599]: no method named memory_mut found for type rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/eval.rs:145:9
|
145 | ecx.memory_mut()
| ^^^^^^^^^^ method not found in rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>>

error[E0599]: no method named memory_mut found for type rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/eval.rs:160:27
|
160 | let cmd_ptr = ecx.memory_mut().allocate(
| ^^^^^^^^^^ method not found in rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>>

error[E0599]: no method named memory_mut found for type rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/eval.rs:168:29
|
168 | let cmd_alloc = ecx.memory_mut().get_mut(cmd_ptr.alloc_id)?;
| ^^^^^^^^^^ method not found in rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>>

error[E0599]: no method named memory found for type rustc_mir::interpret::InterpCx<'_, '_, machine::Evaluator<'_>> in the current scope
--> src/tools/miri/src/eval.rs:214:29
|
214 | let leaks = ecx.memory().leak_report();
| ^^^^^^-- help: remove the arguments
| |
| field, not a method

warning: unused import: rand::RngCore
--> src/tools/miri/src/helpers.rs:7:5
|
7 | use rand::RngCore;
| ^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

error: aborting due to 77 previous errors

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try rustc --explain E0277.
error: could not compile miri.

To learn more, run the command again with --verbose.
command did not execute successfully: "/home/sean/Documents/rust/guessing_game/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "-Zconfig-profile" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "8" "--release" "--manifest-path" "/home/sean/Documents/rust/guessing_game/rust/src/tools/miri/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit code: 101
Build completed successfully in 0:00:05
sean in ~/Documents/rust/guessing_game/rust on master λ

@steveklabnik
Copy link
Member

This build log looks like you're building Rust itself? manually?

@emacstheviking
Copy link

emacstheviking commented Oct 19, 2019 via email

@mbrowne
Copy link

mbrowne commented Nov 1, 2021

It doesn't build for me with the latest version of Rust either (1.56.0):

error[E0432]: unresolved import `rand`
 --> src/main.rs:1:5
  |
1 | use rand::Rng;
  |     ^^^^ maybe a missing crate `rand`?

@hoaile175
Copy link

It doesn't build for me with the latest version of Rust either (1.56.0):

error[E0432]: unresolved import `rand`
 --> src/main.rs:1:5
  |
1 | use rand::Rng;
  |     ^^^^ maybe a missing crate `rand`?

in Cargo.toml:
add line:
[dependencies]
rand="0.8.4"

Rebuild project!

@mbrowne
Copy link

mbrowne commented Nov 12, 2021

I had that line already. I also tried multiple older versions and still got the same error. I wonder if it's because I'm running macOS Mojave (10.14) and can't upgrade yet for unrelated reasons. Anyway, I seem to be able to compile other rust code, so I guess it's not a blocker for me personally.

It says I have current versions though...

$ cargo version
cargo 1.56.0 (4ed5d137b 2021-10-04)
$ rustc --version
rustc 1.56.0 (09c42c458 2021-10-18)

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

8 participants