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

add a ui test for .as_ref suggestion #100773

Closed
wants to merge 1 commit into from

Conversation

WaffleLapkin
Copy link
Member

Closes #90286

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 19, 2022
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 19, 2022
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Aug 20, 2022

Thanks! @bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 20, 2022

📌 Commit 622e425 has been approved by TaKO8Ki

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 Aug 20, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 20, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 21, 2022
@matthiaskrgr
Copy link
Member

@bors r- failed in a rollup
https://github.com/rust-lang/rust/runs/7939531718?check_suite_focus=true#step:25:1536
can you check if you can reproduce this? I don't understand why pre-merge ci does not catch that :/

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 21, 2022
@matthiaskrgr matthiaskrgr reopened this Aug 21, 2022
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] src/test/ui/suggestions/option_as_ref.rs stdout ----
diff of stderr:

5    |     ^^^^----------------------
6    |     |   |
7    |     |   `*opt` moved due to this method call
+    |     help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
8    |     move occurs because `*opt` has type `Option<Box<i32>>`, which does not implement the `Copy` trait
9    |
10 note: this function takes ownership of the receiver `self`, which moves `*opt`
12    |
12    |
13 LL |     pub const fn map<U, F>(self, f: F) -> Option<U>
14    |                            ^^^^
- help: consider calling `.as_ref()` to borrow the type's contents
-    |
- LL |     opt.as_ref().map(|x| x.to_string()).unwrap_or_else(String::new)
19 
20 error: aborting due to previous error
21 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/option_as_ref/option_as_ref.stderr
diff of fixed:

1 // run-rustfix
2 
3 fn _foo(opt: &Option<Box<i32>>) -> String {
-     opt.as_ref().map(|x| x.to_string()).unwrap_or_else(String::new)
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
+     opt.map(|x| x.to_string()).unwrap_or_else(String::new)
5     //~^ cannot move out of `*opt` which is behind a shared reference
7 


The actual fixed differed from the expected fixed.
The actual fixed differed from the expected fixed.
Actual fixed saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/option_as_ref/option_as_ref.fixed
To only update this specific test, also pass `--test-args suggestions/option_as_ref.rs`

error: 2 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/suggestions/option_as_ref.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/option_as_ref" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/option_as_ref/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0507]: cannot move out of `*opt` which is behind a shared reference
   |
   |
LL |     opt.map(|x| x.to_string()).unwrap_or_else(String::new)
   |     |   |
   |     |   |
   |     |   `*opt` moved due to this method call
   |     help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
   |     move occurs because `*opt` has type `Option<Box<i32>>`, which does not implement the `Copy` trait
   |
note: this function takes ownership of the receiver `self`, which moves `*opt`
   |
   |
LL |     pub const fn map<U, F>(self, f: F) -> Option<U>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0507`.

@WaffleLapkin
Copy link
Member Author

This was not caught by CI because the changes seem to have occurred after this PR 😄
see #100186 and specifically compiler-errors@e37565d

@WaffleLapkin
Copy link
Member Author

This suggestion already has tests, see #90286 (comment)

@WaffleLapkin WaffleLapkin deleted the addasreftest branch August 25, 2022 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

regression: rustc suggests .as_ref() at incorrect location and other spans have regressed
8 participants