Skip to content

error[E0713] unexpectedly disappeared between 1.52 and 1.53 #89848

Open
@Tamschi

Description

@Tamschi

Code

I tried this code:

#[must_use]
pub fn make_mut(this: &mut Pin<Self>) -> Pin<&mut T>
where
	T: Sized + Clone,
{
	match this.tip_toe().acquire() {
		AcquireOutcome::Exclusive => (),
		AcquireOutcome::Shared => *this = (&**this).clone().pipe(Self::pin),
	}
	unsafe {
		Pin::new_unchecked(
			//FAULTY!
			mem::transmute_copy::<Pin<Self>, Self>(this)
				.pointer
				.as_mut(),
		)
	}
}

(https://github.com/Tamschi/tiptoe/blob/11e8b4fc7d8e012273df15eb6429999ef98e9682/src/sync.rs#L336-L352)

I expected to see this happen:

The code above is wrong, as it implicitly decrements the Arc's counter. (Self is a custom Arc.)

On Rust 1.52 and earlier, I get the following very helpful error here:

tiptoe on  HEAD (11e8b4f) is 📦 v0.0.1 via 🦀 v1.55.0 
❯ cargo +1.52 check --all-features
    Checking tiptoe v0.0.1 (C:\…\tiptoe)
error[E0713]: borrow may still be in use when destructor runs
   --> src\sync.rs:347:5
    |
337 |        pub fn make_mut(this: &mut Pin<Self>) -> Pin<&mut T>
    |                              - let's call the lifetime of this reference `'1`
...
346 |  /             Pin::new_unchecked(
347 |  |                 mem::transmute_copy::<Pin<Self>, Self>(this)
    |  |_________________^
348 | ||                     .pointer
    | ||____________________________^
349 |  |                     .as_mut(),
350 |  |             )
    |  |_____________- returning this value requires that borrow lasts for `'1`
351 |            }
352 |        }
    |        - here is drop of temporary value; whose type `sync::Arc<T>` implements the `Drop` trait

Instead, this happened:

Starting with Rust 1.53, I get no error:

❯ cargo +1.53 check --all-features
    Checking tiptoe v0.0.1 (C:\…\tiptoe)
    Finished dev [unoptimized + debuginfo] target(s) in 0.85s

Version it worked on

It most recently worked on:

rustc +1.52 --version --verbose

rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: x86_64-pc-windows-msvc
release: 1.52.1
LLVM version: 12.0.0

Version with regression

rustc +1.53 --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-pc-windows-msvc
release: 1.53.0
LLVM version: 12.0.1

Backtrace

Not applicable.

I couldn't find anything related in the release notes, so I assume this is right:
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-releaseRelevant to the release subteam, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions