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

Update E0384.md #123849

Merged
merged 1 commit into from Apr 12, 2024
Merged

Update E0384.md #123849

merged 1 commit into from Apr 12, 2024

Conversation

JimmyOhn
Copy link
Contributor

Add an example for the shadowing usage.

@rustbot
Copy link
Collaborator

rustbot commented Apr 12, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 12, 2024
@JimmyOhn
Copy link
Contributor Author

JimmyOhn commented Apr 12, 2024

IMHO, we can use the shadowing instead. I think it's better to understand Rust first time like me.
I tested with my changes as follows.
refer to : https://rustc-dev-guide.rust-lang.org/building/quickstart.html

rustc +stage1 --explain E0384
An immutable variable was reassigned.

Erroneous code example:

fn main() {
    let x = 3;
    x = 5; // error, reassignment of immutable variable
}

By default, variables in Rust are immutable. To fix this error, add the keyword mut after the keyword let when
declaring the variable. For example:

fn main() {
    let mut x = 3;
    x = 5;
}

Otherwise you can use the shadowing instead. declared variable will be destroyed when declaring the same
variable. For example:

fn main() {
    let x = 3;
    let x = 5;
}
(END)

Add an example for the shadowing usage.
@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 12, 2024

📌 Commit 0b5653f has been approved by pnkfelix

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 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 12, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#123204 (rustdoc: point at span in `include_str!`-ed md file)
 - rust-lang#123223 (Fix invalid silencing of parsing error)
 - rust-lang#123249 (do not add prolog for variadic naked functions)
 - rust-lang#123825 (Call the panic hook for non-unwind panics in proc-macros)
 - rust-lang#123833 (Update stdarch submodule)
 - rust-lang#123841 (Improve diagnostic by suggesting to remove visibility qualifier)
 - rust-lang#123849 (Update E0384.md)
 - rust-lang#123852 (fix typo in library/std/src/lib.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 38283bc into rust-lang:master Apr 12, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 12, 2024
Rollup merge of rust-lang#123849 - JimmyOhn:first_contribution, r=pnkfelix

Update E0384.md

Add an example for the shadowing usage.
@JimmyOhn JimmyOhn deleted the first_contribution branch April 13, 2024 04:16
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants