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

regression: cannot return value referencing local variable #82667

Closed
Mark-Simulacrum opened this issue Mar 1, 2021 · 3 comments
Closed

regression: cannot return value referencing local variable #82667

Mark-Simulacrum opened this issue Mar 1, 2021 · 3 comments
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Milestone

Comments

@Mark-Simulacrum
Copy link
Member

https://crater-reports.s3.amazonaws.com/beta-1.51-1/beta-2021-02-14/gh/bow.gtetools/log.txt regressed in the beta crater run. Unfortunately the span points into a quick_error macro call, so hard to say exactly whether this is caused by something wrong in the compiler code or just changes to inference or something like that.

Probably next steps are to bisect and/or get a MCVE of that crate.

@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Mar 1, 2021
@Mark-Simulacrum Mark-Simulacrum added this to the 1.51.0 milestone Mar 1, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 1, 2021
@SNCPlay42
Copy link
Contributor

Reduced:

use std::error::Error;
use std::fmt;

#[derive(Debug)]
pub enum IntervalError {
    InvalidRange,
}
impl fmt::Display for IntervalError {
    fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result {
        unimplemented!()
    }
}

impl Error for IntervalError {}

#[derive(Debug)]
pub enum ModelError {
    InvalidInterval(IntervalError),
}

impl ModelError {
    pub fn description(&self) -> &str {
        match *self {
            ModelError::InvalidInterval(ref err) => match err {
                ref otherwise => otherwise.description(),
            },
        }
    }
}

The type of otherwise is &&IntervalError. Prior to #75180, this was autoderefed; now, &impl Error implements Error so no autoderef happens and so the function returns a value that borrows otherwise.

Similar regressions were observed in #75180's crater run, but this particular repository failed to build on stable in that crater run. Something similar happened to another crate, and the issue was since fixed. It turned out to involve path dependencies, and this crate has one.

In short, this is #81460, which has been declared acceptable breakage.

Bisection points to #75180's rollup.

@rustbot label -E-needs-mcve -E-needs-bisection

@rustbot rustbot removed E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Mar 1, 2021
@apiraino
Copy link
Contributor

apiraino commented Mar 3, 2021

as per the issue analysis (thanks @SNCPlay42 !), removing the prioritize label

@rustbot label -I-prioritize

@rustbot rustbot removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 3, 2021
@Mark-Simulacrum Mark-Simulacrum added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 4, 2021
@JohnTitor
Copy link
Member

Triage: Closing this as another instance of #81460, as mentioned above (#82667 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants