{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreic5faq5mlpdtkz6svvsecbjg7laf2mllrpdbzbjwkcoedqbyn7kaa",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mnzv3rjni262"
  },
  "path": "/t/code-compiles-on-playground-but-fails-when-passed-via-stdin-to-rustc/24393#post_1",
  "publishedAt": "2026-06-11T17:21:59.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "playground"
  ],
  "textContent": "I've run into the following very strange behaviour and am unsure whether it's some kind of weird bug that I should report or a subtle mistake on my part.\n\nThe following code compiles and runs fine on playground (as does an equivalent test locally)\n\n\n    #![allow(stable_features)]\n    #![allow(unused)]\n    #![feature(iterator_try_collect)]\n    fn main() {\n        let foo: Option<Vec<_>> = [Some(1)].into_iter().try_collect();\n        assert_eq!(foo.unwrap().len(), 1);\n    }\n\n\nbut when passed via stdin to `rustc --crate-name flurb --crate-type=lib --out-dir target/flurb --emit=llvm-ir -` it fails with\n\n\n    error[E0277]: the trait bound `&Option<{integer}>: Try` is not satisfied\n        --> <anon>:5:53\n         |\n       5 |     let foo: Option<Vec<_>> = [Some(1)].into_iter().try_collect();\n         |                                                     ^^^^^^^^^^^ the nightly-only, unstable trait `Try` is not implemented for `&Option<{integer}>`\n         |\n    help: the trait `Try` is implemented for `Option<T>`\n        --> /opt/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:2767:1\n         |\n    2767 | impl<T> const ops::Try for Option<T> {\n         | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n    error: aborting due to 1 previous error\n\n    For more information about this error, try `rustc --explain E0277`.\n\n\nIs there a reason for the difference in output from a direct rustc invocation vs a cargo/playground based compilation?",
  "title": "Code compiles on playground but fails when passed via stdin to rustc"
}