Panic while trying compiler lint plug-in

I got a panic while trying lint plugin.

thread 'rustc' panicked at 'cannot access a scoped thread local variable without calling `set` first', /Users/vsts/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:168:9
stack backtrace:

   0:        0x107359725 - <unknown>
   1:        0x10738ff90 - <unknown>
   2:        0x10734ce4b - <unknown>
   3:        0x10735da6a - <unknown>
   4:        0x10735d775 - <unknown>
   5:        0x1049035f2 - <unknown>
   6:        0x10735e2a2 - <unknown>
   7:        0x10bc6dfa5 - std::panicking::begin_panic::hca84fcd70497f4cf
   8:        0x10bb30e44 - scoped_tls::ScopedKey<T>::with::h05001199e9954d8d
   9:        0x10bb340bd - core::ptr::real_drop_in_place::hdac883c03465eb85
  10:        0x10af93395 - <impl2::Pass as rustc::lint::EarlyLintPass>::check_item::h7abd58079d101600
                               at impl2/src/lib.rs:34
  11:        0x105adbfa0 - <unknown>
  12:        0x104a27f5c - <unknown>
  13:        0x104973e2c - <unknown>
  14:        0x104a25e92 - <unknown>
  15:        0x104a233c8 - <unknown>
  16:        0x104a07202 - <unknown>
  17:        0x1049a36ae - <unknown>
  18:        0x1049db3ce - <unknown>
  19:        0x1049adbbb - <unknown>
  20:        0x1049a217c - <unknown>
  21:        0x1049a0d24 - <unknown>
  22:        0x104a2e30c - <unknown>
  23:        0x1048d7c84 - <unknown>
  24:        0x1049073b4 - <unknown>
  25:        0x1048f6ae2 - <unknown>
  26:        0x104920eb5 - <unknown>
  27:        0x104933ae9 - <unknown>
  28:        0x10736d44f - <unknown>
  29:        0x1048c9dc7 - <unknown>
  30:        0x10733f67e - <unknown>
  31:        0x10736c25e - <unknown>
  32:     0x7fff634ed2eb - <unknown>
  33:     0x7fff634f0249 - <unknown>


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: rustc 1.40.0-nightly (702b45e40 2019-10-01) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `lint1`.

To learn more, run the command again with --verbose.

It seems I am doing something wrong here.

My lint code is this.

#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]

//#![feature(macro_vis_matcher)]
//#![feature(macro_at_most_once_rep)]

extern crate syntax;

// Load rustc as a plugin to get macros
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;

use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
                  EarlyLintPassObject, LintArray};
use rustc_plugin::Registry;
use syntax::ast;

declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");

struct Pass;

impl LintPass for Pass {
    fn name(&self) -> &'static str {
        return "Lint1";
    }
    fn get_lints(&self) -> LintArray {
        lint_array!(TEST_LINT)
    }
}

impl EarlyLintPass for Pass {
    fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
        if it.ident.as_str() == "lintme" {
            cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
        }
    }
}

#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
    reg.register_early_lint_pass(box Pass as EarlyLintPassObject);
}

How can I make it work? I am using lint just to get fully resolved type informations.

I'm guessing there's a bug in rustc or maybe you're not registering the plugin correctly. It almost sounds like it's trying to access a thread-local variable from another thread.

Have you tried mentioning the issue on internals.rust-lang.org? That's a more compiler-centric forum, so there's a good chance the right people (those who frequently work on the compiler) will be able to help you.

Okay. I'll re-post this there. Thanks.