Skip to content

Code no longer compiles after -Zdrop-tracking-mir was enabled by default #116242

Closed
@tmandry

Description

@tmandry

Some code that used to compile no longer does after #107421. We don't think was ever supposed to compile. Don't have an MCVE yet.

Snippet:

let selecting_fut = selecting
    .do_selecting(
        &client_config,
        &test_socket_provider,
        &mut rng,
        &time,
        &mut stop_receiver,
    )
    .fuse();

let time = &time;

let wait_fut = async {
    // Wait some arbitrary amount of time to ensure `do_selecting` is waiting on a reply.
    // Note that this is fake time, not 30 actual seconds.
    time.wait_until(std::time::Duration::from_secs(30)).await;
}
.fuse();

pin_mut!(selecting_fut, wait_fut);

let main_future = async {
    select! {
        _ = selecting_fut => unreachable!("should keep retransmitting DHCPDISCOVER forever"),
        () = wait_fut => (),
    }
};
pin_mut!(main_future);

run_with_accelerated_time(&mut executor, time, &mut main_future);

stop_sender.unbounded_send(()).expect("sending stop signal should succeed");

let selecting_result = selecting_fut.now_or_never().expect(
    "selecting_fut should complete after single poll after stop signal has been sent",
);

assert_matches!(selecting_result, Ok(SelectingOutcome::GracefulShutdown));

Full code is here: https://cs.opensource.google/fuchsia/fuchsia/+/main:src/connectivity/network/dhcpv4/client/core/src/client.rs;l=1521-1576;drc=4a7d2eb6793e61c0021f8dd7dab35804590d36b6

I expected to see this happen: compiles as before

Instead, this happened:

error[E0505]: cannot move out of `selecting_fut` because it is borrowed
    --> ../../src/connectivity/network/dhcpv4/client/core/src/client.rs:1571:32
     |
1559 |           let main_future = async {
     |  ___________________________-
1560 | |             select! {
1561 | |                 _ = selecting_fut => unreachable!("should keep retransmitting DHCPDISCOVER forever"),
     | |                     ------------- borrow occurs due to use in generator
1562 | |                 () = wait_fut => (),
1563 | |             }
1564 | |         };
     | |_________- borrow of `selecting_fut` occurs here
...
1571 |           let selecting_result = selecting_fut.now_or_never().expect(
     |                                  ^^^^^^^^^^^^^ move out of `selecting_fut` occurs here
...
1576 |       }
     |       - borrow might be used here, when `main_future` is dropped and runs the destructor for generator

error: aborting due to previous error

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

Version it worked on

It most recently worked on: Nightly 2023-09-22

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions