Skip to content

Conversation

@anselbobrow
Copy link
Contributor

Fixes #1922

Previously, this example wasn't compiling because of the deprecated thread_rng and fill functions. Upon making the changes the compiler suggests and swapping usize for u64, the example compiles properly. Here are the compiler errors:

Compiling playground v0.0.1 (/playground)
warning: unused import: `rand::Fill`
 --> src/main.rs:2:5
  |
2 | use rand::Fill;
  |     ^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

warning: use of deprecated function `rand::thread_rng`: Renamed to `rng`
 --> src/main.rs:5:25
  |
5 |     let mut rng = rand::thread_rng();
  |                         ^^^^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

error[E0599]: no method named `try_fill` found for struct `Box<[{integer}; 100]>` in the current scope
 --> src/main.rs:7:11
  |
7 |     boxed.try_fill(&mut rng).unwrap();
  |           ^^^^^^^^
  |
help: there is a method `fill` with a similar name
  |
7 -     boxed.try_fill(&mut rng).unwrap();
7 +     boxed.fill(&mut rng).unwrap();
  |

Previously, this example wasn't compiling because of the deprecated `thread_rng` and `fill` functions. Upon making the changes the compiler suggests and swapping `usize` for `u64`, the example compiles properly. Here are the compile errors:

```sh
Compiling playground v0.0.1 (/playground)
warning: unused import: `rand::Fill`
 --> src/main.rs:2:5
  |
2 | use rand::Fill;
  |     ^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

warning: use of deprecated function `rand::thread_rng`: Renamed to `rng`
 --> src/main.rs:5:25
  |
5 |     let mut rng = rand::thread_rng();
  |                         ^^^^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

error[E0599]: no method named `try_fill` found for struct `Box<[{integer}; 100]>` in the current scope
 --> src/main.rs:7:11
  |
7 |     boxed.try_fill(&mut rng).unwrap();
  |           ^^^^^^^^
  |
help: there is a method `fill` with a similar name
  |
7 -     boxed.try_fill(&mut rng).unwrap();
7 +     boxed.fill(&mut rng).unwrap();
  |

For more information about this error, try `rustc --explain E0599`.
warning: `playground` (bin "playground") generated 2 warnings
error: could not compile `playground` (bin "playground") due to 1 previous error; 2 warnings emitted
```
@rustbot
Copy link
Collaborator

rustbot commented Jan 23, 2026

r? @marioidival

rustbot has assigned @marioidival.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@marioidival marioidival merged commit c5cd6c6 into rust-lang:master Jan 25, 2026
1 check passed
@anselbobrow anselbobrow deleted the patch-1 branch January 26, 2026 20:41
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 26, 2026
Update books

## rust-lang/reference

5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a
2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC

- Rename the ".general" rules (rust-lang/reference#2133)
- Unwrap more chapters (rust-lang/reference#2134)
- Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132)
- Fix spacing with ordered lists (rust-lang/reference#2131)
- Reflect explicit macro import in reference (rust-lang/reference#2077)

## rust-lang/rust-by-example

6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20
2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC

- Update supertraits.md (rust-lang/rust-by-example#1988)
- Update question_mark.md (rust-lang/rust-by-example#1990)
- Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992)
- Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993)
- Fix typo (rust-lang/rust-by-example#1986)
- Korean translation! (rust-lang/rust-by-example#1985)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 26, 2026
Update books

## rust-lang/reference

5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a
2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC

- Rename the ".general" rules (rust-lang/reference#2133)
- Unwrap more chapters (rust-lang/reference#2134)
- Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132)
- Fix spacing with ordered lists (rust-lang/reference#2131)
- Reflect explicit macro import in reference (rust-lang/reference#2077)

## rust-lang/rust-by-example

6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20
2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC

- Update supertraits.md (rust-lang/rust-by-example#1988)
- Update question_mark.md (rust-lang/rust-by-example#1990)
- Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992)
- Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993)
- Fix typo (rust-lang/rust-by-example#1986)
- Korean translation! (rust-lang/rust-by-example#1985)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 26, 2026
Update books

## rust-lang/reference

5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a
2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC

- Rename the ".general" rules (rust-lang/reference#2133)
- Unwrap more chapters (rust-lang/reference#2134)
- Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132)
- Fix spacing with ordered lists (rust-lang/reference#2131)
- Reflect explicit macro import in reference (rust-lang/reference#2077)

## rust-lang/rust-by-example

6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20
2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC

- Update supertraits.md (rust-lang/rust-by-example#1988)
- Update question_mark.md (rust-lang/rust-by-example#1990)
- Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992)
- Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993)
- Fix typo (rust-lang/rust-by-example#1986)
- Korean translation! (rust-lang/rust-by-example#1985)
Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 27, 2026
Update books

## rust-lang/reference

5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a
2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC

- Rename the ".general" rules (rust-lang/reference#2133)
- Unwrap more chapters (rust-lang/reference#2134)
- Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132)
- Fix spacing with ordered lists (rust-lang/reference#2131)
- Reflect explicit macro import in reference (rust-lang/reference#2077)

## rust-lang/rust-by-example

6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20
2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC

- Update supertraits.md (rust-lang/rust-by-example#1988)
- Update question_mark.md (rust-lang/rust-by-example#1990)
- Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992)
- Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993)
- Fix typo (rust-lang/rust-by-example#1986)
- Korean translation! (rust-lang/rust-by-example#1985)
rust-timer added a commit to rust-lang/rust that referenced this pull request Jan 27, 2026
Rollup merge of #151699 - rustbot:docs-update, r=ehuss

Update books

## rust-lang/reference

5 commits in 28b5a54419985f03db5294de5eede71b6665b594..990819b86c22bbf538c0526f0287670f3dc1a67a
2026-01-20 20:46:59 UTC to 2026-01-14 01:48:22 UTC

- Rename the ".general" rules (rust-lang/reference#2133)
- Unwrap more chapters (rust-lang/reference#2134)
- Add missing semicolon to ambiguity.glob-vs-glob (rust-lang/reference#2132)
- Fix spacing with ordered lists (rust-lang/reference#2131)
- Reflect explicit macro import in reference (rust-lang/reference#2077)

## rust-lang/rust-by-example

6 commits in 8de6ff811315ac3a96ebe01d74057382e42ffdee..bac931ef1673af63fb60c3d691633034713cca20
2026-01-25 21:02:15 UTC to 2026-01-14 19:45:27 UTC

- Update supertraits.md (rust-lang/rust-by-example#1988)
- Update question_mark.md (rust-lang/rust-by-example#1990)
- Update deprecated functions in `Box::leak` example (rust-lang/rust-by-example#1992)
- Improve Clone and Copy traits documentation (rust-lang/rust-by-example#1993)
- Fix typo (rust-lang/rust-by-example#1986)
- Korean translation! (rust-lang/rust-by-example#1985)
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

Successfully merging this pull request may close these issues.

compilation failure of example code in 15.4.8 Scoping rules / Lifetimes / Static

3 participants