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

bootstrap: Fix compile error: unused-mut #110996

Merged
merged 1 commit into from
Apr 30, 2023
Merged

bootstrap: Fix compile error: unused-mut #110996

merged 1 commit into from
Apr 30, 2023

Conversation

heiher
Copy link
Contributor

@heiher heiher commented Apr 29, 2023

Compile errors:

   Compiling bootstrap v0.0.0 (/home/hev/rust/rust/src/bootstrap)
error: variable does not need to be mutable
    --> config.rs:1312:17
     |
1312 |             let mut build_target = config
     |                 ----^^^^^^^^^^^^
     |                 |
     |                 help: remove this `mut`
     |
     = note: `-D unused-mut` implied by `-D warnings`

error: could not compile `bootstrap` (lib) due to previous error

@rustbot
Copy link
Collaborator

rustbot commented Apr 29, 2023

r? @ozkanonur

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 29, 2023
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How exactly are you compiling this project? You shouldn't get an error like that since it's used as mutable couple lines below.

--

But I am curious why this doesn't throw any error when defined as immutable and modified later. Am I missing something here? cc @rust-lang/compiler

@Noratrieb
Copy link
Member

The type of build_target is &mut T: https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.or_insert_with
Which means that you can mutate the T without declaring the binding as mut.

@onur-ozkan
Copy link
Member

The type of build_target is &mut T: https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.or_insert_with Which means that you can mutate the T without declaring the binding as mut.

I didn't know it was possible to mutate any type without declaring mut expilicitly. My bad I guess.

--

I think having mut expilicitly on the variable is better for readibility. I still don't know how you encounter that error. @heiher

@lukas-code
Copy link
Member

This is probably caused by #110960.

Do we not test bootstrap with the stage1/2 compiler?

@onur-ozkan
Copy link
Member

This is probably caused by #110960.

Do we not test bootstrap with the stage1/2 compiler?

We don't. bootstrap is built/tested with beta compiler.

@heiher
Copy link
Contributor Author

heiher commented Apr 30, 2023

Thanks for your review.

How exactly are you compiling this project?

@ozkanonur I cross-compiled the source code for rust/master on x86_64 with the target set to loongarch. However, when I attempted to use the cross-compiled rust toolchain as stage0 for native compilation on the loongarch system, I encountered an error.

Do we not test bootstrap with the stage1/2 compiler?

@lukas-code I suspect that rust/master was not used as stage0 or was downloaded from CI for other targets?

@onur-ozkan
Copy link
Member

onur-ozkan commented Apr 30, 2023

I suspect that rust/master was not used as stage0 or was downloaded from CI for other targets?

stage0 is the pre-compiled beta compiler downloaded from CI

This is probably caused by #110960.

Yeah, seems like. I get that warning on the bootstrap build using stage2 sysroot. We will need this fix once #110960 is on beta.

--

Thank you for catching this! @heiher

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 30, 2023

📌 Commit 489925f has been approved by ozkanonur

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 30, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 30, 2023
…nonur

bootstrap: Fix compile error: unused-mut

Compile errors:

```
   Compiling bootstrap v0.0.0 (/home/hev/rust/rust/src/bootstrap)
error: variable does not need to be mutable
    --> config.rs:1312:17
     |
1312 |             let mut build_target = config
     |                 ----^^^^^^^^^^^^
     |                 |
     |                 help: remove this `mut`
     |
     = note: `-D unused-mut` implied by `-D warnings`

error: could not compile `bootstrap` (lib) due to previous error
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#110118 (download-rustc: Give a better error message if artifacts can't be dowloaded)
 - rust-lang#110631 (rustdoc: catch and don't blow up on impl Trait cycles)
 - rust-lang#110732 (Make ConstProp some tests unit.)
 - rust-lang#110996 (bootstrap: Fix compile error: unused-mut)
 - rust-lang#110999 (Output some bootstrap messages on stderr)
 - rust-lang#111000 (Remove unneeded function call in `core::option`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9b10f98 into rust-lang:master Apr 30, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 30, 2023
@heiher heiher deleted the fix-bootstrap branch May 1, 2023 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants