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

Macro ICE "expected (), found found core::result::Result<(), core::fmt::Error> #26048

Closed
nielsle opened this issue Jun 6, 2015 · 1 comment
Closed

Comments

@nielsle
Copy link
Contributor

nielsle commented Jun 6, 2015

The following code gives an ICE

#![allow(unused_must_use)]
#![feature(trace_macros)]

trace_macros!(true);

macro_rules! write_html {
    ($w:expr, ) => (());

    ($w:expr, $tag:ident [] $($rest:tt)*) => (
        write!($w, "hello");
        write_html!($w,);
    );
}

fn main() {
    use std::fmt::Write;
    let mut out = String::new();
    write_html!(&mut out,html[]);
}

Error messages in stable

write_html! { & mut out , html [  ] }
write! { &mut out , "hello" }
write_html! { &mut out , }
<anon>:18:17: 2:54 error: mismatched types:
 expected `()`,
    found `core::result::Result<(), core::fmt::Error>`
(expected (),
    found enum `core::result::Result`) [E0308]
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/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'capacity overflow', /home/rustbuild/src/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/option.rs:330

playpen: application terminated with error code 101

Error message on nighly

write_html! { & mut out , html [  ] }
write! { &mut out , "hello" }
write_html! { &mut out , }
<anon>:18:17: 2:54 error: mismatched types:
 expected `()`,
    found `core::result::Result<(), core::fmt::Error>`
(expected (),
    found enum `core::result::Result`) [E0308]
(internal compiler error: unprintable span)
<std macros>:1:1: 2:56 note: in expansion of write!
<anon>:10:9: 10:28 note: expansion site
<anon>:6:1: 13:2 note: in expansion of write_html!
<anon>:18:5: 18:34 note: expansion site
<anon>:18:17: 2:54 help: see the detailed explanation for E0308
error: aborting due to previous error
playpen: application terminated with error code 101

I cannot judge if this has already been reported.

@mitaa
Copy link
Contributor

mitaa commented Jun 6, 2015

This is a dup of #25385.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants