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 invocations inside impl bodies handled incorrectly #657

Closed
crumblingstatue opened this issue Nov 24, 2015 · 2 comments
Closed

Macro invocations inside impl bodies handled incorrectly #657

crumblingstatue opened this issue Nov 24, 2015 · 2 comments
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@crumblingstatue
Copy link
Contributor

In one of my projects, rustfmt removed a macro invocation inside an impl block:

         try!(writer.write_all(&self.unknown));⏎
         Ok(())⏎
     }⏎
-    chunk_write_impl!();⏎
 }⏎

When I tried creating a test case, rustfmt panicked instead.

struct Foo;

macro_rules! add_fun {
    () => { fn fun() {} }
}

impl Foo { add_fun!(); }

rustfmt backtrace:

thread '<main>' panicked at 'index 0 and/or 1 in `` do not lie on character boundary', ../src/libcore/str/mod.rs:1447
stack backtrace:
   1:     0x5602721f42c0 - sys::backtrace::tracing::imp::write::h064b2475ee0d772cxXt
   2:     0x5602721f6825 - panicking::log_panic::_<closure>::closure.40939
   3:     0x5602721f62a0 - panicking::log_panic::h29f8d24759545d7862x
   4:     0x5602721e87c3 - sys_common::unwind::begin_unwind_inner::hdadcc96a1ecb24974Ps
   5:     0x5602721e8b58 - sys_common::unwind::begin_unwind_fmt::h9442bd88fc02b35caPs
   6:     0x5602721f3921 - rust_begin_unwind
   7:     0x56027222297f - panicking::panic_fmt::h03bdc82f7b816525VFK
   8:     0x560272229a8a - str::slice_error_fail::hc00b53e4559d1b43eWS
   9:     0x56027206034f - visitor::_<impl>::visit_item::hef83e33b67452e74X6d
  10:     0x560272004eca - visitor::_<impl>::format_separate_mod::h55e73f776f9071a6Nme
  11:     0x560272010301 - format::h59de26ef8075f4dec8l
  12:     0x5602720108a3 - run::hbe2cf45382bbd7a7k9l
  13:     0x560271ffb41d - main::h4e74fdf9b0b12376iha
  14:     0x5602721f6044 - sys_common::unwind::try::try_fn::h7625493052369861041
  15:     0x5602721f3768 - __rust_try
  16:     0x5602721f5ce6 - rt::lang_start::h47c94448bf012481e0x
  17:     0x7f9c072e660f - __libc_start_main
  18:     0x560271ff3de8 - _start
  19:                0x0 - <unknown>

@nrc nrc added the bug Panic, non-idempotency, invalid code, etc. label Nov 24, 2015
@nrc
Copy link
Member

nrc commented Nov 24, 2015

This might be fixed by #655

@crumblingstatue
Copy link
Contributor Author

I can confirm that this issue has been fixed by #655.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants