mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
don't resolve main in lib crates
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility,
|
||||
};
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
use rustc_session::config::CrateType;
|
||||
use rustc_session::lint::builtin::PRIVATE_MACRO_USE;
|
||||
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency};
|
||||
use rustc_span::{DUMMY_SP, Ident, Macros20NormalizedIdent, Span, Symbol, kw, sym};
|
||||
@@ -2430,6 +2431,12 @@ fn legacy_const_generic_args(&mut self, expr: &Expr) -> Option<Vec<usize>> {
|
||||
}
|
||||
|
||||
fn resolve_main(&mut self) {
|
||||
let any_exe = self.tcx.crate_types().contains(&CrateType::Executable);
|
||||
// Don't try to resolve main unless it's an executable
|
||||
if !any_exe {
|
||||
return;
|
||||
}
|
||||
|
||||
let module = self.graph_root;
|
||||
let ident = Ident::with_dummy_span(sym::main);
|
||||
let parent_scope = &ParentScope::module(module, self.arenas);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// Tests that ambiguously glob importing main doesn't fail to compile in non-executable crates
|
||||
// Regression test for #149412
|
||||
//@ check-pass
|
||||
#![crate_type = "lib"]
|
||||
|
||||
mod m1 { pub(crate) fn main() {} }
|
||||
mod m2 { pub(crate) fn main() {} }
|
||||
|
||||
use m1::*;
|
||||
use m2::*;
|
||||
Reference in New Issue
Block a user