profile
viewpoint

Ask questionsRustc overflow its stack when using impl Trait and the struct containing the function itself

<!-- Thank you for filing a bug report! 🐛 Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. -->

I tried this code:

fn main() {
    test();
}

fn test() -> impl P {
    Lazy { f: test }
}

trait P {}

struct Lazy<F> {
    f: F
}

impl<F> P for Lazy<F> {}

Then I got thread 'rustc' has overflowed its stack.

Meta

<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. -->

rustc --version --verbose:

rustc 1.43.0-nightly (07a34df18 2020-02-08)
binary: rustc
commit-hash: 07a34df18b437319a7ff510077bbab95cf7ec6bc
commit-date: 2020-02-08
host: x86_64-pc-windows-gnu
release: 1.43.0-nightly
LLVM version: 9.0

<!-- Include a backtrace in the code block by setting RUST_BACKTRACE=1 in your environment. E.g. RUST_BACKTRACE=1 cargo build. -->

rust-lang/rust

Answer questions pnkfelix

nominating for discussion as part of attempt to burn down set of unassigned P-high issues at an otherwise light triage meeting.

useful!

Related questions

Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 2
using 'cargo install xsv' on windows 10 triggers rustc internal error hot 1
chain() make collect very slow hot 1
if/while Some(n) = &mut foo sugar will leak a temporary mutable borrow to current scope in particular situation hot 1
build an empty project failed (undefined reference to `__onexitbegin') hot 1
Invalid collision with TryFrom implementation? hot 1
Crater runs for Rust 1.38.0 hot 1
Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 1
under latest MinGW, cannot link with C code using stdout hot 1
Archive all nightlies hot 1
Building LLVM with Clang fails hot 1
Internal compiler error: can't buffer lints after HIR lowering hot 1
E0373 help suggests `move async` but the correct syntax is `async move` hot 1
Tracking issue for `Option::contains` and `Result::contains` hot 1
async fn + rustfmt don't "just work" inside of RLS hot 1
Github User Rank List