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

Error for RPIT if they are not defined during MIR borrowck #125285

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

spastorino
Copy link
Member

@spastorino spastorino commented May 19, 2024

r? @lcnr

Fixes #112417

There are some changes in tests that we would need to properly review. I've left some comments on each of them.

@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 May 19, 2024
fn foo() -> impl MyTrait {
//~^ ERROR: the trait bound `(): MyTrait` is not satisfied [E0277]
Copy link
Member Author

Choose a reason for hiding this comment

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

This is unfortunate but not sure how much we should care about this.

@@ -7,6 +6,7 @@ fn f_debug() -> impl Fn() -> impl Debug {
}

fn ff_debug() -> impl Fn() -> impl Fn() -> impl Debug {
//~^ ERROR: expected a `Fn()` closure, found `()` [E0277]
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd need to properly check what's going on here but at a glance this regression seems wrong?

vec![|| println!("woot")].into_iter()
}

fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> {
//~^ ERROR: the trait bound `u32: From<()>` is not satisfied [E0277]
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only relevant change as the rest is rustfmt and seems fine.

@@ -1,11 +1,11 @@
#![deny(unused_must_use)]

fn it() -> impl ExactSizeIterator<Item = ()> {
//~^ ERROR the trait bound `(): ExactSizeIterator` is not satisfied [E0277]
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems like a diagnostics regression.

@spastorino spastorino force-pushed the unchk-region-opaque-deadcode branch from 854e723 to 6a7ad4c Compare May 19, 2024 18:34
@spastorino spastorino force-pushed the unchk-region-opaque-deadcode branch from 6a7ad4c to 3e009ba Compare May 20, 2024 19:26
@rust-log-analyzer

This comment has been minimized.

@spastorino spastorino force-pushed the unchk-region-opaque-deadcode branch from 3e009ba to c130bfb Compare May 20, 2024 19:50
@spastorino
Copy link
Member Author

This is going to fail on https://github.com/rust-lang/rust/blob/master/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed#L21 as cargo fix is going to add impls with todo!() for traits' methods which their return type is impl Trait, so it will produce a fixed rust file that is not going to compile.

@spastorino
Copy link
Member Author

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request May 20, 2024
…ode, r=<try>

 Error for RPIT if they are not defined during MIR borrowck

r? `@lcnr`

Fixes rust-lang#112417

There are some changes in tests that we would need to properly review. I've left some comments on each of them.
@bors
Copy link
Contributor

bors commented May 20, 2024

⌛ Trying commit c130bfb with merge 5ff4501...

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)

     Running tests/compile-test.rs (obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/compile_test-e0af1f18c1597357)

FAILED TEST: tests/ui/new_ret_no_self.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-c5e0235647f00232.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-2964c17de9728d6a.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-e7859c049d6fc5af.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-e1fa4d45c0e68db6.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-ae846d6788d6a9f1.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-e9aa61e1e4ee057e.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-3864f64671f03a2f.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-facaf493acd2f9ad.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-5689c7175177147d.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-d199b1d0494505d0.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps/libserde_derive-82c47a8e64b8c220.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-f7a5efbd7c1bc532.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-e9d338b744af34e7.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui" "tests/ui/new_ret_no_self.rs" "--edition" "2021"
error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/new_ret_no_self.stderr` to the actual output
--- tests/ui/new_ret_no_self.stderr
+++ <stderr output>
+++ <stderr output>
-error: methods called `new` usually return `Self`
-  --> tests/ui/new_ret_no_self.rs:50:5
+  --> tests/ui/new_ret_no_self.rs:393:25
    |
    |
-LL | /     pub fn new(_: String) -> impl R<Item = u32> {
+LL |         fn new(t: T) -> impl Trait2<(), Self> {
+   |                         ^^^^^^^^^^^^^^^^^^^^^
 
 
-error: methods called `new` usually return `Self`
-  --> tests/ui/new_ret_no_self.rs:84:5
+  --> tests/ui/new_ret_no_self.rs:402:25
    |
-LL | /     pub fn new() -> u32 {
-LL | /     pub fn new() -> u32 {
+LL |         fn new(t: T) -> impl Trait2<(), i32> {
+   |                         ^^^^^^^^^^^^^^^^^^^^
 
 
-error: methods called `new` usually return `Self`
 
 
-error: methods called `new` usually return `Self`
-   |
-   |
-LL | /     pub fn new() -> (u32, u32) {
-LL | |         unimplemented!();
-LL | |     }
-   | |_____^
-
-
-error: methods called `new` usually return `Self`
-   |
-   |
-LL | /     pub fn new() -> *mut V {
-LL | |         unimplemented!();
-LL | |     }
-   | |_____^
-
-
-error: methods called `new` usually return `Self`
-   |
-LL | /     pub fn new() -> Option<u32> {
-LL | |
-LL | |         unimplemented!();
-LL | |         unimplemented!();
-LL | |     }
-   | |_____^
-
-error: methods called `new` usually return `Self`
-   |
-LL |         fn new() -> String;
-   |         ^^^^^^^^^^^^^^^^^^^
-
-
-error: methods called `new` usually return `Self`
-   |
-LL |         fn new(_: String) -> String;
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-
-error: methods called `new` usually return `Self`
-   |
-   |
-LL | /         fn new() -> (u32, u32) {
-LL | |             unimplemented!();
-LL | |         }
-   | |_________^
-
-
-error: methods called `new` usually return `Self`
-   |
-   |
-LL | /         fn new() -> *mut V {
-LL | |             unimplemented!();
-LL | |         }
-   | |_________^
-
-
-error: methods called `new` usually return `Self`
-   |
-   |
-LL | /         fn new(t: T) -> impl Into<i32> {
-LL | |             1
-LL | |         }
-   | |_________^
-
-
-error: methods called `new` usually return `Self`
-   |
-   |
-LL | /         fn new(t: T) -> impl Trait2<(), i32> {
-LL | |             unimplemented!()
-LL | |         }
-   | |_________^
-
-
-error: aborting due to 12 previous errors
-


error: `methods called `new` usually return `Self`` not found in diagnostics on line 50
   |
   |
51 |         //~^ ERROR: methods called `new` usually return `Self`
   |


error: ``-D clippy::new-ret-no-self` implied by `-D warnings`` not found in diagnostics on line 50
   |
   |
52 |         //~| NOTE: `-D clippy::new-ret-no-self` implied by `-D warnings`
   |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 84
   |
   |
85 |         //~^ ERROR: methods called `new` usually return `Self`
   |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 94
   |
   |
95 |         //~^ ERROR: methods called `new` usually return `Self`
   |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 131
    |
    |
132 |         //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 159
    |
    |
160 |         //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 178
    |
    |
179 |         //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 232
    |
    |
233 |         //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 245
    |
    |
246 |         //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 281
    |
    |
282 |             //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 309
    |
    |
310 |             //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 380
    |
    |
381 |             //~^ ERROR: methods called `new` usually return `Self`
    |


error: `methods called `new` usually return `Self`` not found in diagnostics on line 402
    |
    |
403 |             //~^ ERROR: methods called `new` usually return `Self`
    |

full stderr:
error: undefined opaque type
error: undefined opaque type
##[error]  --> tests/ui/new_ret_no_self.rs:393:25
   |
LL |         fn new(t: T) -> impl Trait2<(), Self> {

error: undefined opaque type
##[error]  --> tests/ui/new_ret_no_self.rs:402:25
   |
   |
LL |         fn new(t: T) -> impl Trait2<(), i32> {

error: aborting due to 2 previous errors


@bors
Copy link
Contributor

bors commented May 20, 2024

☀️ Try build successful - checks-actions
Build commit: 5ff4501 (5ff4501f5e4c740f37756a1102c0b794291dddaf)

@spastorino
Copy link
Member Author

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-125285 created and queued.
🤖 Automatically detected try build 5ff4501
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 20, 2024
@craterbot
Copy link
Collaborator

🚧 Experiment pr-125285 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-125285 is completed!
📊 502 regressed and 6 fixed (464331 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unchecked region constraints for opaque types in dead code
6 participants