- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Rollup of 7 pull requests #148456
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
Rollup of 7 pull requests #148456
Conversation
Also, add reference id
When a binding needs to be mutably reborrowed multiple times, suggesting removing `&mut` will lead to follow up errors. Instead suggest both making the binding mutable and removing the reborrow.
```
error[E0596]: cannot borrow `outer` as mutable, as it is not declared as mutable
 --> f14.rs:2:12
  |
2 |     match (&mut outer, 23) {
  |            ^^^^^^^^^^ cannot borrow as mutable
  |
note: the binding is already a mutable borrow
 --> f14.rs:1:16
  |
1 | fn test(outer: &mut Option<i32>) {
  |                ^^^^^^^^^^^^^^^^
help: consider making the binding mutable if you need to reborrow multiple times
  |
1 | fn test(mut outer: &mut Option<i32>) {
  |         +++
help: if there is only one mutable reborrow, remove the `&mut`
  |
2 -     match (&mut outer, 23) {
2 +     match (outer, 23) {
  |
```
    This commit fixes an accidental regression from 144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes 148347
```
error[E0401]: can't use `Self` from outer item
  --> $DIR/E0401.rs:22:25
   |
LL | impl<T> Iterator for A<T> {
   | ---- `Self` type implicitly declared here, by this `impl`
...
LL |         fn helper(sel: &Self) -> u8 {
   |            ------       ^^^^ use of `Self` from outer item
   |            |
   |            `Self` used in this inner function
   |
help: refer to the type directly here instead
   |
LL -         fn helper(sel: &Self) -> u8 {
LL +         fn helper(sel: &A<T>) -> u8 {
   |
```
    Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Suggest making binding `mut` on `&mut` reborrow
When a binding needs to be mutably reborrowed multiple times, suggesting removing `&mut` will lead to follow up errors. Instead suggest both making the binding mutable and removing the reborrow.
```
error[E0596]: cannot borrow `outer` as mutable, as it is not declared as mutable
 --> f14.rs:2:12
  |
2 |     match (&mut outer, 23) {
  |            ^^^^^^^^^^ cannot borrow as mutable
  |
note: the binding is already a mutable borrow
 --> f14.rs:1:16
  |
1 | fn test(outer: &mut Option<i32>) {
  |                ^^^^^^^^^^^^^^^^
help: consider making the binding mutable if you need to reborrow multiple times
  |
1 | fn test(mut outer: &mut Option<i32>) {
  |         +++
help: if there is only one mutable reborrow, remove the `&mut`
  |
2 -     match (&mut outer, 23) {
2 +     match (outer, 23) {
  |
```
Address rust-lang#81059.
    …zelmann Port `cfg!()` macro to the new attribute parsing system r? ``@jdonszelmann``
…avidtwco Add check for `+=` typo in let chains Fixes rust-lang#147664 it does affect only cases where variable exist in scope, because if the variable is not exist in scope, the suggestion will not make any sense I wanted to add suggestion for case where variable does not in scope to fix `y += 1` to `let y = 1` but I guess it's too much (not too much work, but too much wild predict of what user wants)? if it's good addition in your opinion I can add this in follow up in other things I guess impl is pretty much self-explanatory, if you see there is some possibilities to improve code or/and some _edge-cases_ that I could overlooked feel free to tell about it ah, also about why I think this change is good and why I originally took it, so it seems to me that this is possible to make this typo (I explained this in comment a little), like, both `+` and `=` is the same button (in most of layouts) and for this reasons I didn't added something like `-=` it seems more harder to make this typo r? diagnostics
…ributes, r=estebank fix: Only special case single line item attribute suggestions `rustc` currently special cases suggestions to add [`#[derive(_)]\n` and other attributes](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L2288C36-L2288C72), to add more context to the suggestions. > // The suggestion adds an entire line of code, ending on a newline, so we'll also > // print the *following* line, to provide context of what we're advising people to > // do. Otherwise you would only see contextless code that can be confused for > // already existing code, despite the colors and UI elements. > // We special case `#[derive(_)]\n` and other attribute suggestions, because those > // are the ones where context is most useful. This special case is a bit broad at the moment and applies to suggestions just to add an attribute, as well as suggestions that contain an attribute and other code, i.e. ```rust #[derive(Clone)] ``` and ```rust #[cfg(not(test))] impl Default for NewWithCfg { fn default() -> Self { Self::new() } } ``` In the latter case, adding a line for context after the suggestion doesn't provide much benefit. Example:  This PR makes it so that this special case only applies to suggestions that just add an attribute and nothing else. This will also make `rustc`'s output match `annotate-snippets`.
reflect that type and const parameter can be intermixed Also, add reference id
…=jackh726 Fix `wasm_import_module` attribute cross-crate This commit fixes an accidental regression from rust-lang#144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes rust-lang#148347
Tweak E0401 More accurate span pointing at use place of outer param (at ident instead of full path). Add note explaining why outer item params can't be used in inner item. Use structured suggestion for what `Self` should have been. Follow up to rust-lang#148370. Fix rust-lang#37892.
| 
           @bors r+ rollup=never p=5  | 
    
| 
           ☀️ Test successful - checks-actions  | 
    
| 
           📌 Perf builds for each rolled up PR: 
 previous master: 20383c9f1d In the case of a perf regression, run the following command for each PR you suspect might be the cause:   | 
    
          What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 20383c9 (parent) -> 5f9dd05 (this PR) Test differencesShow 38 test diffsStage 1
 Stage 2
 Additionally, 30 doctest diffs were found. These are ignored, as they are noisy. Job group index 
 Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 5f9dd05862d2e4bceb3be1031b6c936e35671501 --output-dir test-dashboardAnd then open  Job duration changes
 How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance  | 
    
Successful merges:
muton&mutreborrow #147141 (Suggest making bindingmuton&mutreborrow)cfg!()macro to the new attribute parsing system #147945 (Portcfg!()macro to the new attribute parsing system )+=typo in let chains #147951 (Add check for+=typo in let chains)wasm_import_moduleattribute cross-crate #148363 (Fixwasm_import_moduleattribute cross-crate)r? @ghost
@rustbot modify labels: rollup
Create a similar rollup