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

the compiler unexpectedly panicked #43210

Closed
lagudomeze opened this issue Jul 13, 2017 · 3 comments
Closed

the compiler unexpectedly panicked #43210

lagudomeze opened this issue Jul 13, 2017 · 3 comments

Comments

@lagudomeze
Copy link

I tried this code:

extern crate nanomsg;
extern crate futures;

use std::sync::mpsc::*;
use std::thread::{Thread, current};

pub use self::futures::{Future, Poll, Async};

pub use self::nanomsg::{PollFd, Socket, PollRequest, PollInOut};

type Notify = (PollFd, Thread);

pub struct NanoCore {
tx: Sender,
rx: Receiver
}

pub enum NanoCoreError {
NanoError(nanomsg::Error),
SendError(SendError),
RecvError(RecvError),
}

impl Fromnanomsg::Error for NanoCoreError {
fn from(e: nanomsg::Error) -> Self {
NanoCoreError::NanoError(e)
}
}

impl From<SendError> for NanoCoreError {
fn from(e: SendError) -> Self {
NanoCoreError::SendError(e)
}
}

impl From for NanoCoreError {
fn from(e: RecvError) -> Self {
NanoCoreError::RecvError(e)
}
}

struct ReadReady {
socket: Socket,
sender: Sender<(PollFd, Thread)>,
}

impl ReadReady {
fn new(socket: Socket, core: &NanoCore) -> ReadReady {
ReadReady { socket: socket, sender: core.tx.clone() }
}

fn new_poll_fd(&self) -> PollFd {
    self.socket.new_pollfd(PollInOut::In)
}

}

impl Future for ReadReady {
type Item = Socket;
type Error = NanoCoreError;

fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
    self.sender.send((self.new_poll_fd(), current()))?;
    Ok(Async::NotReady)
}

}

impl NanoCore {
pub fn new() -> NanoCore {
let (tx, rx) = channel();
NanoCore {
tx: tx,
rx: rx
}
}

pub fn poll(&self) -> nanomsg::Result<()> {
    let timeout = 10;

    Ok(())
}

}

I expected to see this happen:

Instead, this happened:

Meta

rustc --version --verbose:

rustc 1.18.0 (03fc9d6 2017-06-06)
binary: rustc
commit-hash: 03fc9d6
commit-date: 2017-06-06
host: x86_64-pc-windows-msvc
release: 1.18.0
LLVM version: 3.9

Backtrace:

thread 'rustc' panicked at 'invalid lint-id trivial_numeric_casts', src\librustc\lint\context.rs:1322
stack backtrace:
0: <std::time::SystemTimeError as core::fmt::Display>::fmt
1: std::panicking::Location::line
2: std::panicking::Location::line
3: std::panicking::rust_panic_with_hook
4: std::panicking::begin_panic_fmt
5: std::panicking::begin_panic_fmt
6:
7: rustc_metadata::decoder::::item_body_tables
8: rustc_metadata::cstore_impl::provide
9: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::try_get
10: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::get
11: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::item_tables
12: rustc_const_eval::eval::provide
13: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
14: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::get
15: rustc::ty::layout::Layout::compute_uncached
16: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::needs_drop_uncached
17:
18:
19: rustc::ty::layout::Layout::compute_uncached
20:
21:
22:
23:
24: rustc::ty::layout::Layout::compute_uncached
25: <rustc_lint::types::VariantSizeDifferences as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
26: rustc::lint::context::gather_attrs
27: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
28: rustc::hir::intravisit::NestedVisitorMap::inter
29: rustc::lint::context::gather_attrs
30: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
31: rustc::lint::context::check_crate
32: rustc_driver::driver::count_nodes
33:
34: rustc_driver::driver::count_nodes
35: rustc_driver::driver::compile_input
36: rustc_driver::run_compiler
37:
38: _rust_maybe_catch_panic
39:
40: std::sys::imp::thread::Thread::new
41: BaseThreadInitThunk

@lagudomeze
Copy link
Author

cased by
pub enum NanoCoreError {
NanoError(nanomsg::Error),

@kennytm
Copy link
Member

kennytm commented Jul 13, 2017

Please try if it crashes on 1.19-beta or nightly. If it doesn't, then this issue is a duplicate of #42007 and #42546 which has been fixed.

@lagudomeze
Copy link
Author

thx.

can be fixed by this.

impl Fromnanomsg::Error for NanoCoreError {
fn from(e: nanomsg::Error) -> Self {
NanoCoreError::NanoError(e.to_raw() as isize)
}
}

it could cased by nanomsg::Error define

pub enum Error {
Unknown = 0 as isize,

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

2 participants