Skip to content

nightly-2021-12-02 to nightly-2021-12-03 regression (PR #91354): auto-deref on Cow does not seem to work anymore in all circumstances #91489

Closed
@sdroege

Description

@sdroege

Code

See https://github.com/gtk-rs/gtk-rs-core/blob/master/glib-macros/tests/test.rs#L290

This fails with the latest nightly with (run cargo test inside the glib-macros directory).

error[E0599]: no method named `as_str` found for enum `Cow<'static, VariantTy>` in the current scope
   --> glib-macros/tests/test.rs:290:48
    |
290 |     assert_eq!(Variant1::static_variant_type().as_str(), "(si)");
    |                         

Simplified code from gtk-rs / glib which works without problems for some reason so I'm not entirely sure what causes it:

pub struct VariantType;
pub struct VariantTy;

impl Borrow<VariantTy> for VariantType {
    fn borrow(&self) -> &VariantTy {
        todo!()
    }
}

impl ToOwned for VariantTy {
    type Owned = VariantType;

    fn to_owned(&self) -> VariantType {
        todo!()
    }
}

impl VariantTy {
    pub fn as_str(&self) -> &str {
        todo!()
    }
}

let x = Cow::Owned(VariantType);
println!("{}", x.as_str());

Version it worked on

It most recently worked on: 2021-12-02

Version with regression

rustc --version --verbose:

rustc 1.59.0-nightly (acbe4443c 2021-12-02)
binary: rustc
commit-hash: acbe4443cc4c9695c0b74a7b64b60333c990a400
commit-date: 2021-12-02
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0

(note that this is actually the one from today, 2021-12-03, but there's an off-by-one in the version information)

Running cargo bisect-rustc yields:

searched nightlies: from nightly-2021-12-01 to nightly-2021-12-03
regressed nightly: nightly-2021-12-03
searched commits: from https://github.com/rust-lang/rust/commit/48a5999fceeea84a8971634355287faa349909d4 to https://github.com/rust-lang/rust/commit/acbe4443cc4c9695c0b74a7b64b60333c990a400
regressed commit: https://github.com/rust-lang/rust/commit/18bb8c61a975fff6424cda831ace5b0404277145

Which would be this PR: #91354 (CC @fee1-dead).

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions