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

Compiler bug with 'println!' followed by 'fail!' when compiling library #13282

Closed
bvssvni opened this issue Apr 3, 2014 · 3 comments
Closed

Comments

@bvssvni
Copy link

bvssvni commented Apr 3, 2014

// rustc 0.10-pre-nightly (7bda3df 2014-04-02 17:51:48 -0700)
// host: x86_64-apple-darwin
//
// Compile with
//  RUST_BACKTRACE=1 rustc lib.rs --crate-type=rlib

#![allow(unreachable_code)]

pub fn foo() {
    fail!("hello");
    println!("hello");
}

COMPILER ERROR:

error: internal compiler error: encode_symbol: id not found 13
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at '~Any', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:123
stack backtrace:
   1:        0x106f425e4 - rt::backtrace::imp::write::h465dd066fae708e1K4b::v0.10.pre
   2:        0x106ea6466 - rt::unwind::begin_unwind_inner::h706b8a82433a867deFb::v0.10.pre
   3:        0x10663cf32 - rt::unwind::begin_unwind::h78c6e0e38e88257f3j2::v0.10.pre
   4:        0x10663db2a - diagnostic::Handler::bug::hed4aac26a1abd0aaYVb::v0.10.pre
   5:        0x104796c2e - metadata::encoder::encode_symbol::hfa747218062fd7deR07::v0.10.pre
   6:        0x1047a20dc - metadata::encoder::encode_info_for_item::he395f425e5fdc83dj48::v0.10.pre
   7:        0x1047a471f - metadata::encoder::my_visit_item::closure.84922
   8:        0x1046d8486 - ast_map::Map::with_path_next::h766f0611a81ad12acVu::v0.10.pre
   9:        0x1046d8454 - ast_map::Map::with_path_next::h766f0611a81ad12acVu::v0.10.pre
  10:        0x1046d8454 - ast_map::Map::with_path_next::h766f0611a81ad12acVu::v0.10.pre
  11:        0x1047a7702 - metadata::encoder::EncodeVisitor$LT$$x27a$C$$x20$x27b$GT$.visit..Visitor$LT$$LP$$RP$$GT$::visit_item::hc83d5b4165d76a87XD9::v0.10.pre
  12:        0x1047a6a91 - visit::walk_decl::h0796691b8f86a337Dwv::v0.10.pre
  13:        0x1047a69be - visit::walk_stmt::h8b4cdaa4d13f25c2rvv::v0.10.pre
  14:        0x1047a6793 - visit::walk_block::h352b671fd4ab74f3mrv::v0.10.pre
  15:        0x1047a5958 - visit::walk_expr::ha9627355b8156d7023u::v0.10.pre
  16:        0x1047a5805 - visit::walk_expr::ha9627355b8156d7023u::v0.10.pre
  17:        0x1047a698f - visit::walk_stmt::h8b4cdaa4d13f25c2rvv::v0.10.pre
  18:        0x1047a6793 - visit::walk_block::h352b671fd4ab74f3mrv::v0.10.pre
  19:        0x1047a7c33 - visit::walk_fn::hebbee6cd8f9e3b69UFv::v0.10.pre
  20:        0x1047a71b1 - metadata::encoder::EncodeVisitor$LT$$x27a$C$$x20$x27b$GT$.visit..Visitor$LT$$LP$$RP$$GT$::visit_item::hc83d5b4165d76a87XD9::v0.10.pre
  21:        0x1047b2871 - metadata::encoder::encode_metadata_inner::hfc230df7a476419b1ca::v0.10.pre
  22:        0x10417baef - metadata::encoder::encode_metadata::h6e5a9b6a4de6d914vca::v0.10.pre
  23:        0x10417aafa - middle::trans::base::write_metadata::h8a372e6fffd01356Krq::v0.10.pre
  24:        0x10417c4a0 - middle::trans::base::trans_crate::hb7feaf7b833fbf06Xvq::v0.10.pre
  25:        0x10485e5ae - driver::driver::phase_4_translate_to_llvm::h70fcfb218b178883aFf::v0.10.pre
  26:        0x10486139d - driver::driver::compile_input::he27246fdf3ebf699ZUf::v0.10.pre
  27:        0x10488671e - run_compiler::hc9b40628b29df06cvyn::v0.10.pre
  28:        0x10489a34d - main_args::closure.92085
  29:        0x104898b62 - monitor::closure.91970
  30:        0x10489470b - task::TaskBuilder::try::closure.91745
  31:        0x10405945c - task::spawn_opts::closure.7920
  32:        0x106f3da08 - rt::task::Task::run::closure.41657
  33:        0x106f483fc - rust_try
  34:        0x106f3d887 - rt::task::Task::run::heda42bba0bf3c293hy9::v0.10.pre
  35:        0x1040592df - task::spawn_opts::closure.7892
  36:        0x106f40fc6 - rt::thread::thread_start::h8efe2212db548d78Yca::v0.10.pre
  37:     0x7fff8ac79899 - _pthread_body
  38:     0x7fff8ac7972a - _pthread_struct_init

@klutzy
Copy link
Contributor

klutzy commented Apr 7, 2014

Simplified:

#![allow(dead_code, unreachable_code)]
#![crate_type = "lib"]
pub fn fall() -> ! {
    unsafe { std::cast::transmute(()) }
}

pub fn foo() {
    fall();
    // dead & unreachable from here
    match () {
        () => {
            static A: int = 3;
        }
    }
}

@ghost
Copy link

ghost commented Aug 26, 2014

This was fixed in #16452.

@alexcrichton
Copy link
Member

It was indeed!

Manishearth pushed a commit to Manishearth/rust that referenced this issue Nov 23, 2022
Support multiple targets for checkOnSave (in conjunction with cargo 1.64.0+)

This PR adds support for the ability to pass multiple `--target` flags when using
`cargo` 1.64.0+.

## Questions

I needed to change the type of two configurations options, but I did not plurialize the names to
avoid too much churn, should I ?

## Zulip thread

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Issue.2013282.20.28supporting.20multiple.20targets.20with.201.2E64.2B.29

## Example

To see it working, on a macOS machine:

```sh
$ cd /tmp
$ cargo new cargo-multiple-targets-support-ra-test
$ cd !$
$ mkdir .cargo
$ echo '
[build]
target = [
    "aarch64-apple-darwin",
    "x86_64-apple-darwin",
]
' > .cargo/config.toml
$ echo '
fn main() {
    #[cfg(all(target_arch = "aarch64", target_os = "macos"))]
    {
        let a = std::fs::read_to_string("/tmp/test-read");
    }

    #[cfg(all(target_arch = "x86_64", target_os = "macos"))]
    {
        let a = std::fs::read_to_string("/tmp/test-read");
    }

    #[cfg(all(target_arch = "x86_64", target_os = "windows"))]
    {
        let a = std::fs::read_to_string("/tmp/test-read");
    }
}
' > src/main.rs
# launch your favorite editor with the version of RA from this PR
#
# You should see warnings under the first two `let a = ...` but not the third
```

## Screen

![Two panes of a terminal emulator, on the left pane is the main.rs file described above, with warnings for the first two let a = declaration, on the right pane is a display of the .cargo/config.toml, an ls of the current files in the directory and a call to cargo build to show the same warnings as in the editor on the left pane](https://user-images.githubusercontent.com/7951708/192122707-7a00606a-e581-4534-b9d5-b81c92694e8e.png)

Helps with rust-lang#13282
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