Skip to content

ICE using function pointer to function returning impl Iterator<Item = &&'a str> #50881

@lbcsccrb

Description

@lbcsccrb
struct S<'a> {
    v: Vec<&'a str>
}

impl<'a> S<'a> {
    fn inner_iter(&self) -> impl Iterator<Item = &&'a str> {
        self.v.iter()
    }
}

fn main() {
    let s = S { v: Vec::new() };
    [s].iter()
        .flat_map(S::inner_iter)
        .for_each(|_| {});
}

Error Message:

error: internal compiler error: librustc/infer/canonical.rs:705: failed to lift `QueryResult { var_values: CanonicalVarValues { var_values: ['?0, '?1] }, region_constraints: QueryRegionConstraints { region_outlives: [('?0, '?0), ('?0, '?0), ('?0, '?0), ('?0, '?0), ('?0, '?0), ('?0, '?0), ('?0, '?0), ('?0, '?0), (ReStatic, '?1)], ty_outlives: [] }, certainty: Proven, value: NormalizationResult { normalized_ty: &'_ &'_ str } }`, canonicalized from `QueryResult { var_values: CanonicalVarValues { var_values: ['_#0r, '_#1r] }, region_constraints: QueryRegionConstraints { region_outlives: [('_#0r, '_#2r), ('_#0r, '_#4r), ('_#2r, '_#0r), ('_#2r, '_#3r), ('_#2r, '_#5r), ('_#3r, '_#2r), ('_#4r, '_#0r), ('_#5r, '_#2r), (ReStatic, '_#1r)], ty_outlives: [] }, certainty: Proven, value: NormalizationResult { normalized_ty: &&str } }`

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:543:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.26.0 (a77568041 2018-05-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

https://play.rust-lang.org/?gist=4f2d7ff43b1e5ceb514066159c1ffa63&version=stable&mode=debug

Meta

rustc --version --verbose:
rustc 1.26.0 (a775680 2018-05-07)
binary: rustc
commit-hash: a775680
commit-date: 2018-05-07
host: x86_64-unknown-linux-gnu
release: 1.26.0
LLVM version: 6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, 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