- Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
//lib.rs use proc_macro::{TokenStream}; use proc_macro2::{Span}; use syn::{parse_macro_input, DeriveInput, Ident}; use quote::quote; #[proc_macro_derive(Builder)] pub fn derive(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); let command = Ident::new(input.ident.to_string().as_str(), Span::call_site()); let cbuilder_name = format!("{}Builder", input.ident.to_string()); let command_builder = Ident::new(cbuilder_name.as_str(), Span::call_site()); let type_definition = quote! { pub struct #command_builder { executable: Option<String>, args: Option<Vec<String>>, env: Option<Vec<String>>, current_dir: Option<String>, } }; let methods = quote! { impl #command { pub fn builder() -> #command_builder { #command_builder { executable: None, args: None, env: None, current_dir: None, } } } impl #command_builder { // use std::error::Error; // type Error: Error; fn executable(&mut self, executable: String) -> &mut Self { self.executable = Some(executable); self } fn args(&mut self, args: Vec<String>) -> &mut Self { self.args = Some(args); self } fn env(&mut self, env: Vec<String>) -> &mut Self { self.env = Some(env); self } fn current_dir(&mut self, current_dir: String) -> &mut Self { self.current_dir = Some(current_dir); self } fn build(&mut self) -> Result<#command, Box<dyn Error>> { let c = #command { executable: self.executable.unwrap().into(), args: self.args.unwrap().into(), env: self.env.unwrap().into(), current_dir: self.current_dir.unwrap().into() }; Ok(c) } } }; let tokens = quote! { #type_definition #methods }; tokens.into() } // tests/progress.rs #[test] fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/01-parse.rs"); t.pass("tests/02-create-builder.rs"); t.pass("tests/03-call-setters.rs"); // t.pass("tests/04-call-build.rs"); //t.pass("tests/05-method-chaining.rs"); //t.pass("tests/06-optional-field.rs"); //t.pass("tests/07-repeated-field.rs"); //t.compile_fail("tests/08-unrecognized-attribute.rs"); //t.pass("tests/09-redefined-prelude-types.rs"); }
Meta
rustc --version --verbose
:
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) binary: rustc commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597 commit-date: 2021-03-24 host: x86_64-unknown-linux-gnu release: 1.53.0-nightly LLVM version: 12.0.0
Error output
thread 'rustc' panicked at 'found unstable fingerprints for predicates_of(core[3998]::convert::From): GenericPredicates { parent: None, predicates: [(Binder(TraitPredicate(<Self as std::marker::Sized>)), /home/tobias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:365:20: 365:25 (#0)), (Binder(TraitPredicate(<T as std::marker::Sized>)), /home/tobias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:365:16: 365:17 (#0)), (Binder(TraitPredicate(<Self as std::convert::From<T>>)), /home/tobias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:365:1: 365:25 (#0))] }', /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/compiler/rustc_query_system/src/query/plumbing.rs:593:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu note: compiler flags: -C prefer-dynamic -C embed-bitcode=no -C debuginfo=2 -C incremental note: some of the compiler flags provided by cargo are hidden
Backtrace
query stack during panic: #0 [predicates_of] computing predicates of `std::convert::From` #1 [typeck] type-checking `derive` end of query stack error: build failed
I am using
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.5 LTS Release: 18.04 Codename: bionic
The error originated when run with cargo test
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.