use opt_item_name to pattern match items with names
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
parent
959636d531
commit
f77658b470
@ -1995,7 +1995,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Look up the name of a definition across crates. This does not look at HIR.
|
/// Look up the name of a definition across crates. This does not look at HIR.
|
||||||
fn opt_item_name(self, def_id: DefId) -> Option<Symbol> {
|
pub fn opt_item_name(self, def_id: DefId) -> Option<Symbol> {
|
||||||
if let Some(cnum) = def_id.as_crate_root() {
|
if let Some(cnum) = def_id.as_crate_root() {
|
||||||
Some(self.crate_name(cnum))
|
Some(self.crate_name(cnum))
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,8 +58,8 @@ fn entry_point_type(ctxt: &EntryContext<'_>, id: ItemId, at_root: bool) -> Entry
|
|||||||
} else if ctxt.tcx.sess.contains_name(attrs, sym::rustc_main) {
|
} else if ctxt.tcx.sess.contains_name(attrs, sym::rustc_main) {
|
||||||
EntryPointType::MainAttr
|
EntryPointType::MainAttr
|
||||||
} else {
|
} else {
|
||||||
let item = ctxt.tcx.hir().item(id);
|
if let Some(name) = ctxt.tcx.opt_item_name(id.def_id.to_def_id())
|
||||||
if item.ident.name == sym::main {
|
&& name == sym::main {
|
||||||
if at_root {
|
if at_root {
|
||||||
// This is a top-level function so can be `main`.
|
// This is a top-level function so can be `main`.
|
||||||
EntryPointType::MainNamed
|
EntryPointType::MainNamed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user