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

Introduce terminating scope for tail expressions of breakable scopes #106493

Closed
wants to merge 1 commit into from

Conversation

b-naber
Copy link
Contributor

@b-naber b-naber commented Jan 5, 2023

Currently we schedule drops for tail expressions of blocks in the surrounding scope of the block. This does, however, cause problems with drops of temporaries and unwind paths in breakable scopes (#104736). More specifically we schedule drops for temporaries only after the exit tree was already built for a breakable scope, which allows for paths in the CFG that include drops for which no StorageLive was ever created. This also causes problems with the caching of unwind drops.

This change is not backwards-compatible though, as we currently allow this to compile:

struct A;

impl Drop for A {
    fn drop(&mut self) {}
}

fn takes_a_ref<'a>(_arg: &'a A) {}

fn returns_a() -> A {
    A
}

fn temporary_drop<'a>(a: &'a A, x: bool) {
    takes_a_ref('scope: {
        if x {
            break 'scope a;
        }

        // fails with a `temporary value dropped while borrowed` with the change
        &returns_a()
    });
}

The following version also fails to compile though:

fn temporary_drop<'a>(a: &'a A, x: bool) {
    takes_a_ref(
        if x {
            a
        } else {
            &returns_a()
        }
    )
}

I think it makes sense to treat the tail expression of a breakable scope similar to the else clause.

Fixes #104736

r? @oli-obk maybe?

@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 Jan 5, 2023
@rust-log-analyzer

This comment has been minimized.

@b-naber b-naber force-pushed the breakable-scope-thir branch from d238916 to 3bf7e84 Compare January 5, 2023 18:08
@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)
Some tests failed in compiletest suite=mir-opt mode=mir-opt host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
i.......i................................
failures:

---- [mir-opt] src/test/mir-opt/building/breakable_scope_drops.rs stdout ----
1 // MIR for `weird_temporary` after built
2 
3 fn weird_temporary(_1: A, _2: B, _3: ((), (), ()), _4: bool) -> ((), (), ()) {
-     debug a => _1;                       // in scope 0 at $DIR/breakable-scope-drops.rs:+0:20: +0:21
-     debug b => _2;                       // in scope 0 at $DIR/breakable-scope-drops.rs:+0:26: +0:27
-     debug nothing => _3;                 // in scope 0 at $DIR/breakable-scope-drops.rs:+0:32: +0:39
-     debug x => _4;                       // in scope 0 at $DIR/breakable-scope-drops.rs:+0:55: +0:56
-     let mut _0: ((), (), ());            // return place in scope 0 at $DIR/breakable-scope-drops.rs:+0:67: +0:79
-     let _5: ((), (), ());                // in scope 0 at $DIR/breakable-scope-drops.rs:+1:9: +1:14
-     let mut _6: ();                      // in scope 0 at $DIR/breakable-scope-drops.rs:+3:13: +8:14
-     let _7: B;                           // in scope 0 at $DIR/breakable-scope-drops.rs:+4:21: +4:23
-     let mut _8: bool;                    // in scope 0 at $DIR/breakable-scope-drops.rs:+5:20: +5:21
-     let mut _9: !;                       // in scope 0 at $DIR/breakable-scope-drops.rs:+5:22: +7:18
-     let mut _10: ();                     // in scope 0 at $DIR/breakable-scope-drops.rs:+9:13: +11:14
-     let mut _11: A;                      // in scope 0 at $DIR/breakable-scope-drops.rs:+9:19: +9:24
-     let mut _12: ();                     // in scope 0 at $DIR/breakable-scope-drops.rs:+12:13: +12:24
+     debug a => _1;                       // in scope 0 at $DIR/breakable_scope_drops.rs:+0:20: +0:21
+     debug b => _2;                       // in scope 0 at $DIR/breakable_scope_drops.rs:+0:26: +0:27
+     debug nothing => _3;                 // in scope 0 at $DIR/breakable_scope_drops.rs:+0:32: +0:39
+     debug x => _4;                       // in scope 0 at $DIR/breakable_scope_drops.rs:+0:55: +0:56
+     let mut _0: ((), (), ());            // return place in scope 0 at $DIR/breakable_scope_drops.rs:+0:67: +0:79
+     let _5: ((), (), ());                // in scope 0 at $DIR/breakable_scope_drops.rs:+1:9: +1:14
+     let mut _6: ();                      // in scope 0 at $DIR/breakable_scope_drops.rs:+3:13: +8:14
+     let _7: B;                           // in scope 0 at $DIR/breakable_scope_drops.rs:+4:21: +4:23
+     let mut _8: bool;                    // in scope 0 at $DIR/breakable_scope_drops.rs:+5:20: +5:21
+     let mut _9: !;                       // in scope 0 at $DIR/breakable_scope_drops.rs:+5:22: +7:18
+     let mut _10: ();                     // in scope 0 at $DIR/breakable_scope_drops.rs:+9:13: +11:14
+     let mut _11: A;                      // in scope 0 at $DIR/breakable_scope_drops.rs:+9:19: +9:24
+     let mut _12: ();                     // in scope 0 at $DIR/breakable_scope_drops.rs:+12:13: +12:24
17     scope 1 {
-         debug _temp => _5;               // in scope 1 at $DIR/breakable-scope-drops.rs:+1:9: +1:14
+         debug _temp => _5;               // in scope 1 at $DIR/breakable_scope_drops.rs:+1:9: +1:14
20     scope 2 {
20     scope 2 {
-         debug _z => _7;                  // in scope 2 at $DIR/breakable-scope-drops.rs:+4:21: +4:23
+         debug _z => _7;                  // in scope 2 at $DIR/breakable_scope_drops.rs:+4:21: +4:23
23 
24     bb0: {


-         StorageLive(_5);                 // scope 0 at $DIR/breakable-scope-drops.rs:+1:9: +1:14
-         StorageLive(_6);                 // scope 0 at $DIR/breakable-scope-drops.rs:+3:13: +8:14
-         StorageLive(_7);                 // scope 0 at $DIR/breakable-scope-drops.rs:+4:21: +4:23
-         _7 = move _2;                    // scope 0 at $DIR/breakable-scope-drops.rs:+4:26: +4:27
-         FakeRead(ForLet(None), _7);      // scope 0 at $DIR/breakable-scope-drops.rs:+4:21: +4:23
-         StorageLive(_8);                 // scope 2 at $DIR/breakable-scope-drops.rs:+5:20: +5:21
-         _8 = _4;                         // scope 2 at $DIR/breakable-scope-drops.rs:+5:20: +5:21
-         switchInt(move _8) -> [0: bb2, otherwise: bb1]; // scope 2 at $DIR/breakable-scope-drops.rs:+5:20: +5:21
+         StorageLive(_5);                 // scope 0 at $DIR/breakable_scope_drops.rs:+1:9: +1:14
+         StorageLive(_6);                 // scope 0 at $DIR/breakable_scope_drops.rs:+3:13: +8:14
+         StorageLive(_7);                 // scope 0 at $DIR/breakable_scope_drops.rs:+4:21: +4:23
+         _7 = move _2;                    // scope 0 at $DIR/breakable_scope_drops.rs:+4:26: +4:27
+         FakeRead(ForLet(None), _7);      // scope 0 at $DIR/breakable_scope_drops.rs:+4:21: +4:23
+         StorageLive(_8);                 // scope 2 at $DIR/breakable_scope_drops.rs:+5:20: +5:21
+         _8 = _4;                         // scope 2 at $DIR/breakable_scope_drops.rs:+5:20: +5:21
+         switchInt(move _8) -> [0: bb2, otherwise: bb1]; // scope 2 at $DIR/breakable_scope_drops.rs:+5:20: +5:21
34 
35     bb1: {


-         _5 = _3;                         // scope 2 at $DIR/breakable-scope-drops.rs:+6:34: +6:41
-         goto -> bb11;                    // scope 2 at $DIR/breakable-scope-drops.rs:+6:21: +6:41
+         _5 = _3;                         // scope 2 at $DIR/breakable_scope_drops.rs:+6:34: +6:41
+         goto -> bb11;                    // scope 2 at $DIR/breakable_scope_drops.rs:+6:21: +6:41
39 
40     bb2: {


-         goto -> bb5;                     // scope 2 at $DIR/breakable-scope-drops.rs:+5:20: +5:21
+         goto -> bb5;                     // scope 2 at $DIR/breakable_scope_drops.rs:+5:20: +5:21
43 
44     bb3: {


-         unreachable;                     // scope 2 at $DIR/breakable-scope-drops.rs:+5:22: +7:18
+         unreachable;                     // scope 2 at $DIR/breakable_scope_drops.rs:+5:22: +7:18
47 
48     bb4: {


-         goto -> bb6;                     // scope 2 at $DIR/breakable-scope-drops.rs:+5:17: +7:18
+         goto -> bb6;                     // scope 2 at $DIR/breakable_scope_drops.rs:+5:17: +7:18
51 
52     bb5: {


-         _6 = const ();                   // scope 2 at $DIR/breakable-scope-drops.rs:+7:18: +7:18
-         goto -> bb6;                     // scope 2 at $DIR/breakable-scope-drops.rs:+5:17: +7:18
+         _6 = const ();                   // scope 2 at $DIR/breakable_scope_drops.rs:+7:18: +7:18
+         goto -> bb6;                     // scope 2 at $DIR/breakable_scope_drops.rs:+5:17: +7:18
56 
57     bb6: {


-         StorageDead(_8);                 // scope 2 at $DIR/breakable-scope-drops.rs:+7:17: +7:18
-         drop(_7) -> [return: bb7, unwind: bb17]; // scope 0 at $DIR/breakable-scope-drops.rs:+8:13: +8:14
+         StorageDead(_8);                 // scope 2 at $DIR/breakable_scope_drops.rs:+7:17: +7:18
+         drop(_7) -> [return: bb7, unwind: bb17]; // scope 0 at $DIR/breakable_scope_drops.rs:+8:13: +8:14
61 
62     bb7: {


-         StorageDead(_7);                 // scope 0 at $DIR/breakable-scope-drops.rs:+8:13: +8:14
-         StorageLive(_10);                // scope 0 at $DIR/breakable-scope-drops.rs:+9:13: +11:14
-         StorageLive(_11);                // scope 0 at $DIR/breakable-scope-drops.rs:+9:19: +9:24
-         _11 = move _1;                   // scope 0 at $DIR/breakable-scope-drops.rs:+9:21: +9:22
-         FakeRead(ForMatchedPlace(None), _11); // scope 0 at $DIR/breakable-scope-drops.rs:+9:19: +9:24
-         _10 = ();                        // scope 0 at $DIR/breakable-scope-drops.rs:+10:22: +10:24
-         goto -> bb8;                     // scope 0 at $DIR/breakable-scope-drops.rs:+10:22: +10:24
+         StorageDead(_7);                 // scope 0 at $DIR/breakable_scope_drops.rs:+8:13: +8:14
+         StorageLive(_10);                // scope 0 at $DIR/breakable_scope_drops.rs:+9:13: +11:14
+         StorageLive(_11);                // scope 0 at $DIR/breakable_scope_drops.rs:+9:19: +9:24
+         _11 = move _1;                   // scope 0 at $DIR/breakable_scope_drops.rs:+9:21: +9:22
+         FakeRead(ForMatchedPlace(None), _11); // scope 0 at $DIR/breakable_scope_drops.rs:+9:19: +9:24
+         _10 = ();                        // scope 0 at $DIR/breakable_scope_drops.rs:+10:22: +10:24
+         goto -> bb8;                     // scope 0 at $DIR/breakable_scope_drops.rs:+10:22: +10:24
71 
72     bb8: {


-         StorageLive(_12);                // scope 0 at $DIR/breakable-scope-drops.rs:+12:13: +12:24
-         _12 = no_unwind() -> [return: bb9, unwind: bb16]; // scope 0 at $DIR/breakable-scope-drops.rs:+12:13: +12:24
+         StorageLive(_12);                // scope 0 at $DIR/breakable_scope_drops.rs:+12:13: +12:24
+         _12 = no_unwind() -> [return: bb9, unwind: bb16]; // scope 0 at $DIR/breakable_scope_drops.rs:+12:13: +12:24
75                                          // mir::Constant
-                                          // + span: $DIR/breakable-scope-drops.rs:29:13: 29:22
+                                          // + span: $DIR/breakable_scope_drops.rs:29:13: 29:22
77                                          // + literal: Const { ty: fn() {no_unwind}, val: Value(<ZST>) }
79 

80     bb9: {
80     bb9: {
-         _5 = (move _6, move _10, move _12); // scope 0 at $DIR/breakable-scope-drops.rs:+2:9: +13:10
-         StorageDead(_12);                // scope 0 at $DIR/breakable-scope-drops.rs:+13:9: +13:10
-         drop(_11) -> [return: bb10, unwind: bb17]; // scope 0 at $DIR/breakable-scope-drops.rs:+13:9: +13:10
+         _5 = (move _6, move _10, move _12); // scope 0 at $DIR/breakable_scope_drops.rs:+2:9: +13:10
+         StorageDead(_12);                // scope 0 at $DIR/breakable_scope_drops.rs:+13:9: +13:10
+         drop(_11) -> [return: bb10, unwind: bb17]; // scope 0 at $DIR/breakable_scope_drops.rs:+13:9: +13:10
85 
86     bb10: {


-         StorageDead(_11);                // scope 0 at $DIR/breakable-scope-drops.rs:+13:9: +13:10
-         StorageDead(_10);                // scope 0 at $DIR/breakable-scope-drops.rs:+13:9: +13:10
-         StorageDead(_6);                 // scope 0 at $DIR/breakable-scope-drops.rs:+13:9: +13:10
-         goto -> bb13;                    // scope 0 at $DIR/breakable-scope-drops.rs:+1:17: +14:6
+         StorageDead(_11);                // scope 0 at $DIR/breakable_scope_drops.rs:+13:9: +13:10
+         StorageDead(_10);                // scope 0 at $DIR/breakable_scope_drops.rs:+13:9: +13:10
+         StorageDead(_6);                 // scope 0 at $DIR/breakable_scope_drops.rs:+13:9: +13:10
+         goto -> bb13;                    // scope 0 at $DIR/breakable_scope_drops.rs:+1:17: +14:6
92 
93     bb11: {


-         StorageDead(_8);                 // scope 2 at $DIR/breakable-scope-drops.rs:+7:17: +7:18
-         drop(_7) -> [return: bb12, unwind: bb17]; // scope 0 at $DIR/breakable-scope-drops.rs:+8:13: +8:14
+         StorageDead(_8);                 // scope 2 at $DIR/breakable_scope_drops.rs:+7:17: +7:18
+         drop(_7) -> [return: bb12, unwind: bb17]; // scope 0 at $DIR/breakable_scope_drops.rs:+8:13: +8:14
97 
98     bb12: {


-         StorageDead(_7);                 // scope 0 at $DIR/breakable-scope-drops.rs:+8:13: +8:14
-         StorageDead(_6);                 // scope 0 at $DIR/breakable-scope-drops.rs:+13:9: +13:10
-         goto -> bb13;                    // scope 0 at $DIR/breakable-scope-drops.rs:+1:17: +14:6
+         StorageDead(_7);                 // scope 0 at $DIR/breakable_scope_drops.rs:+8:13: +8:14
+         StorageDead(_6);                 // scope 0 at $DIR/breakable_scope_drops.rs:+13:9: +13:10
+         goto -> bb13;                    // scope 0 at $DIR/breakable_scope_drops.rs:+1:17: +14:6
103 
104     bb13: {


-         FakeRead(ForLet(None), _5);      // scope 0 at $DIR/breakable-scope-drops.rs:+1:9: +1:14
-         _0 = _3;                         // scope 1 at $DIR/breakable-scope-drops.rs:+16:5: +16:12
-         StorageDead(_5);                 // scope 0 at $DIR/breakable-scope-drops.rs:+17:1: +17:2
-         drop(_2) -> [return: bb14, unwind: bb18]; // scope 0 at $DIR/breakable-scope-drops.rs:+17:1: +17:2
+         FakeRead(ForLet(None), _5);      // scope 0 at $DIR/breakable_scope_drops.rs:+1:9: +1:14
+         _0 = _3;                         // scope 1 at $DIR/breakable_scope_drops.rs:+16:5: +16:12
+         StorageDead(_5);                 // scope 0 at $DIR/breakable_scope_drops.rs:+17:1: +17:2
+         drop(_2) -> [return: bb14, unwind: bb18]; // scope 0 at $DIR/breakable_scope_drops.rs:+17:1: +17:2
110 
111     bb14: {


-         drop(_1) -> [return: bb15, unwind: bb19]; // scope 0 at $DIR/breakable-scope-drops.rs:+17:1: +17:2
+         drop(_1) -> [return: bb15, unwind: bb19]; // scope 0 at $DIR/breakable_scope_drops.rs:+17:1: +17:2
114 
115     bb15: {


-         return;                          // scope 0 at $DIR/breakable-scope-drops.rs:+17:2: +17:2
+         return;                          // scope 0 at $DIR/breakable_scope_drops.rs:+17:2: +17:2
118 
118 
119     bb16 (cleanup): {

-         drop(_11) -> bb17;               // scope 0 at $DIR/breakable-scope-drops.rs:+13:9: +13:10
+         drop(_11) -> bb17;               // scope 0 at $DIR/breakable_scope_drops.rs:+13:9: +13:10
122 
122 
123     bb17 (cleanup): {

-         drop(_2) -> bb18;                // scope 0 at $DIR/breakable-scope-drops.rs:+17:1: +17:2
+         drop(_2) -> bb18;                // scope 0 at $DIR/breakable_scope_drops.rs:+17:1: +17:2
126 
126 
127     bb18 (cleanup): {

-         drop(_1) -> bb19;                // scope 0 at $DIR/breakable-scope-drops.rs:+17:1: +17:2
+         drop(_1) -> bb19;                // scope 0 at $DIR/breakable_scope_drops.rs:+17:1: +17:2
130 
130 
131     bb19 (cleanup): {

-         resume;                          // scope 0 at $DIR/breakable-scope-drops.rs:+0:1: +17:2
+         resume;                          // scope 0 at $DIR/breakable_scope_drops.rs:+0:1: +17:2
134 }
135 


thread '[mir-opt] src/test/mir-opt/building/breakable_scope_drops.rs' panicked at 'Actual MIR output differs from expected MIR output /checkout/src/test/mir-opt/building/breakable_scope_drops.weird_temporary.built.after.mir', src/tools/compiletest/src/runtest.rs:3465:21


failures:
    [mir-opt] src/test/mir-opt/building/breakable_scope_drops.rs

@oli-obk
Copy link
Contributor

oli-obk commented Jan 9, 2023

@bors try

let's crater it at minimum

@bors
Copy link
Contributor

bors commented Jan 9, 2023

⌛ Trying commit 3bf7e84 with merge ebbfb508237d160e7a5e663a930916c87c4a8a45...

@bors
Copy link
Contributor

bors commented Jan 9, 2023

☀️ Try build successful - checks-actions
Build commit: ebbfb508237d160e7a5e663a930916c87c4a8a45 (ebbfb508237d160e7a5e663a930916c87c4a8a45)

@oli-obk
Copy link
Contributor

oli-obk commented Jan 9, 2023

@craterbot check

@craterbot
Copy link
Collaborator

🚨 Error: missing start toolchain

🆘 If you have any trouble with Crater please ping @rust-lang/infra!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@oli-obk
Copy link
Contributor

oli-obk commented Jan 10, 2023

@craterbot check start=2e677c0645862d17a12c6d04b3019203c8e23fcc end=ebbfb508237d160e7a5e663a930916c87c4a8a45

@craterbot
Copy link
Collaborator

👌 Experiment pr-106493 created and queued.
🔍 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 Jan 10, 2023
@craterbot
Copy link
Collaborator

🚧 Experiment pr-106493 is now running

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

@Mark-Simulacrum
Copy link
Member

@craterbot abort

@craterbot
Copy link
Collaborator

🗑️ Experiment pr-106493 deleted!

ℹ️ 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 Jan 10, 2023
@Mark-Simulacrum
Copy link
Member

@craterbot check start=master#2e677c0645862d17a12c6d04b3019203c8e23fcc end=try#ebbfb508237d160e7a5e663a930916c87c4a8a45

@craterbot
Copy link
Collaborator

👌 Experiment pr-106493 created and queued.
🔍 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 Jan 10, 2023
@craterbot
Copy link
Collaborator

🚧 Experiment pr-106493 is now running

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

@craterbot
Copy link
Collaborator

🚨 Report generation of pr-106493 failed: Failed to upload to "try#ebbfb508237d160e7a5e663a930916c87c4a8a45/gh/tjresearch.research-mikail/log.txt": ServiceError(ServiceError { source: PutObjectError { kind: Unhandled(Unhandled { source: Error { code: Some("InternalError"), message: Some("We encountered an internal error. Please try again."), request_id: Some("ZCVABHZTM7HHF5Q8"), extras: {"s3_extended_request_id": "X1LYg7h9ZGOSTNfQ0P4l/w/W0gbHN1dihqFhsxAqv1r2OJDOo7BNbGkLVuplA6I1hjSZENNRx0c="} } }), meta: Error { code: Some("InternalError"), message: Some("We encountered an internal error. Please try again."), request_id: Some("ZCVABHZTM7HHF5Q8"), extras: {"s3_extended_request_id": "X1LYg7h9ZGOSTNfQ0P4l/w/W0gbHN1dihqFhsxAqv1r2OJDOo7BNbGkLVuplA6I1hjSZENNRx0c="} } }, raw: Response { inner: Response { status: 500, version: HTTP/1.1, headers: {"x-amz-request-id": "ZCVABHZTM7HHF5Q8", "x-amz-id-2": "X1LYg7h9ZGOSTNfQ0P4l/w/W0gbHN1dihqFhsxAqv1r2OJDOo7BNbGkLVuplA6I1hjSZENNRx0c=", "content-type": "application/xml", "transfer-encoding": "chunked", "date": "Wed, 11 Jan 2023 18:50:52 GMT", "server": "AmazonS3", "connection": "close"}, body: SdkBody { inner: Once(Some(b"\nInternalErrorWe encountered an internal error. Please try again.ZCVABHZTM7HHF5Q8X1LYg7h9ZGOSTNfQ0P4l/w/W0gbHN1dihqFhsxAqv1r2OJDOo7BNbGkLVuplA6I1hjSZENNRx0c=")), retryable: true } }, properties: SharedPropertyBag(Mutex { data: PropertyBag, poisoned: false, .. }) } })
🛠️ If the error is fixed use the retry-report command.

🆘 Can someone from the infra team check in on this? @rust-lang/infra
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@jyn514
Copy link
Member

jyn514 commented Jan 11, 2023

@craterbot retry-report

@craterbot
Copy link
Collaborator

🛠️ Generation of the report for pr-106493 queued again.

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

@craterbot
Copy link
Collaborator

🚨 Report generation of pr-106493 failed: Failed to upload to "master#2e677c0645862d17a12c6d04b3019203c8e23fcc/gh/ThermalSpan.checkpath/log.txt": ServiceError(ServiceError { source: PutObjectError { kind: Unhandled(Unhandled { source: Error { code: None, message: None, request_id: None, extras: {} } }), meta: Error { code: None, message: None, request_id: None, extras: {} } }, raw: Response { inner: Response { status: 503, version: HTTP/1.1, headers: {"date": "Wed, 11 Jan 23 22:36:46 GMT", "connection": "close", "x-amz-id-2": "h6pPKdJSL6nINEkPSkVnzxno8th5sgvQOjYTwh+7IwE/+e3v0MWFWpfcL0nZa3qTr/sxAQWFd5yg7f4gJp0v6l195xZ4kvR7", "x-amz-request-id": "545B1722F0BF4E35", "content-type": "application/xml", "server": "AmazonS3", "content-length": "0"}, body: SdkBody { inner: Once(Some(b"")), retryable: true } }, properties: SharedPropertyBag(Mutex { data: PropertyBag, poisoned: false, .. }) } })
🛠️ If the error is fixed use the retry-report command.

🆘 Can someone from the infra team check in on this? @rust-lang/infra
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@Mark-Simulacrum
Copy link
Member

@craterbot retry-report

@craterbot
Copy link
Collaborator

🛠️ Generation of the report for pr-106493 queued again.

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

@craterbot
Copy link
Collaborator

🎉 Experiment pr-106493 is completed!
📊 14 regressed and 10 fixed (252128 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 Jan 14, 2023
@oli-obk oli-obk added T-lang Relevant to the language team, which will review and decide on the PR/issue. I-lang-nominated Nominated for discussion during a lang team meeting. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 16, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Jan 16, 2023

Nominating for T-lang FCP. This PR was created to fix an ICE due to a local being accessed outside of its "live region" (between StorageLive and StorageDead). The main post explains where this is a breaking change (none found on crater). The short version is that we accidentally made borrowck think some temporaries lived longer than they did. This was not unsound because we had assertions catching it.

@JakobDegen
Copy link
Contributor

JakobDegen commented Jan 16, 2023

Sorry I haven't been on top of this issue, day job has been kicking my butt. This is not the fix to this issue that I was expecting, but it doesn't seem unreasonable.

@b-naber can you clarify how the reference would have to be updated to reflect the changed semantics here? I'm specifically looking at this and surrounding sections. Are we just adding labeled blocks to the bulleted list?

@b-naber
Copy link
Contributor Author

b-naber commented Jan 17, 2023

Are we just adding labeled blocks to the bulleted list?

Yes, though this change more specifically only includes the tail expression of labeled blocks. We could add a temporary scope for labeled blocks in general by wrapping them in in DropTemps, though that would require us to have a hir representation different from hir::Block for labeled blocks (currently labeled blocks are only encoded through the targeted_by_break flag on that struct) and given that statements have their own temporary scope this isn't strictly necessary. Not sure whether making the temporary scopes for labeled blocks more explicit like that is preferable.

We could in principle also fix this in mir building, e.g. by tracking all temps that are created in a labeled block and then dropping all temps that aren't moved into the destination place of the expr_into_dest call (if called through a expr_into_dest call, otherwise we can just drop all temps afaict). This is, however, orthogonal to how we handle drops in general in mir building and would add additional complexity to an already complex part of the codebase. Given that the breaking change doesn't really seem to have any relevance in real world code and shrinking the temporary scope seems to me to be more consistent with how we handle drops in control flow constructs in general this seems like the most reasonable fix to me.

@scottmcm
Copy link
Member

Yes, though this change more specifically only includes the tail expression of labeled blocks.

This feels somewhat awkward to me? I wouldn't expect that adding an unused label to a block would ever make something change behaviour.

@b-naber
Copy link
Contributor Author

b-naber commented Jan 31, 2023

That's fair, we could easily check for whether a label is unused or not. Is it reasonable to assume different behavior (in terms of the tail expression scope) if the label is used?

@oli-obk oli-obk removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 18, 2023
@nikomatsakis
Copy link
Contributor

We discussed in lang team meeting today. We have a design meeting to cover temporary lifetimes and we'll include some discussion, but a number of us have reservations about the specific approach in this PR because having the label to a block determined when destructors execute seems surprising.

Not inclined to fcp at this time, hence removing nomination.

@rustbot labels -I-lang-nominated

@rustbot rustbot removed the I-lang-nominated Nominated for discussion during a lang team meeting. label Mar 14, 2023
@Dylan-DPC
Copy link
Member

Closing this as it needs to be reworked and there has been no activity since so it is better to do it in a new pr with a link to this one if needed.

@Dylan-DPC Dylan-DPC closed this May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Out of storage use of local for temporary caused by label break