cargo clippy --fix

This commit is contained in:
Lukas Wirth 2025-07-31 10:30:22 +02:00
parent 423c7dd23a
commit 8ce30264c8
186 changed files with 3056 additions and 3314 deletions

View file

@ -377,10 +377,10 @@ fn parse_repr_tt(tt: &crate::tt::TopSubtree) -> Option<ReprOptions> {
let mut align = None;
if let Some(TtElement::Subtree(_, mut tt_iter)) = tts.peek() {
tts.next();
if let Some(TtElement::Leaf(tt::Leaf::Literal(lit))) = tt_iter.next() {
if let Ok(a) = lit.symbol.as_str().parse() {
align = Align::from_bytes(a).ok();
}
if let Some(TtElement::Leaf(tt::Leaf::Literal(lit))) = tt_iter.next()
&& let Ok(a) = lit.symbol.as_str().parse()
{
align = Align::from_bytes(a).ok();
}
}
ReprOptions { align, ..Default::default() }

View file

@ -1487,13 +1487,13 @@ impl ExprCollector<'_> {
ast::Expr::UnderscoreExpr(_) => self.alloc_pat_from_expr(Pat::Wild, syntax_ptr),
ast::Expr::ParenExpr(e) => {
// We special-case `(..)` for consistency with patterns.
if let Some(ast::Expr::RangeExpr(range)) = e.expr() {
if range.is_range_full() {
return Some(self.alloc_pat_from_expr(
Pat::Tuple { args: Box::default(), ellipsis: Some(0) },
syntax_ptr,
));
}
if let Some(ast::Expr::RangeExpr(range)) = e.expr()
&& range.is_range_full()
{
return Some(self.alloc_pat_from_expr(
Pat::Tuple { args: Box::default(), ellipsis: Some(0) },
syntax_ptr,
));
}
return e.expr().and_then(|expr| self.maybe_collect_expr_as_pat(&expr));
}
@ -2569,19 +2569,18 @@ impl ExprCollector<'_> {
}
}
RibKind::MacroDef(macro_id) => {
if let Some((parent_ctx, label_macro_id)) = hygiene_info {
if label_macro_id == **macro_id {
// A macro is allowed to refer to labels from before its declaration.
// Therefore, if we got to the rib of its declaration, give up its hygiene
// and use its parent expansion.
if let Some((parent_ctx, label_macro_id)) = hygiene_info
&& label_macro_id == **macro_id
{
// A macro is allowed to refer to labels from before its declaration.
// Therefore, if we got to the rib of its declaration, give up its hygiene
// and use its parent expansion.
hygiene_id =
HygieneId::new(parent_ctx.opaque_and_semitransparent(self.db));
hygiene_info = parent_ctx.outer_expn(self.db).map(|expansion| {
let expansion = self.db.lookup_intern_macro_call(expansion.into());
(parent_ctx.parent(self.db), expansion.def)
});
}
hygiene_id = HygieneId::new(parent_ctx.opaque_and_semitransparent(self.db));
hygiene_info = parent_ctx.outer_expn(self.db).map(|expansion| {
let expansion = self.db.lookup_intern_macro_call(expansion.into());
(parent_ctx.parent(self.db), expansion.def)
});
}
}
_ => {}

View file

@ -259,10 +259,10 @@ impl ExprCollector<'_> {
}
};
if let Some(operand_idx) = operand_idx {
if let Some(position_span) = to_span(arg.position_span) {
mappings.push((position_span, operand_idx));
}
if let Some(operand_idx) = operand_idx
&& let Some(position_span) = to_span(arg.position_span)
{
mappings.push((position_span, operand_idx));
}
}
}

View file

@ -211,16 +211,17 @@ pub(super) fn lower_path(
// Basically, even in rustc it is quite hacky:
// https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456
// We follow what it did anyway :)
if segments.len() == 1 && kind == PathKind::Plain {
if let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) {
let syn_ctxt = collector.expander.ctx_for_range(path.segment()?.syntax().text_range());
if let Some(macro_call_id) = syn_ctxt.outer_expn(collector.db) {
if collector.db.lookup_intern_macro_call(macro_call_id.into()).def.local_inner {
kind = match resolve_crate_root(collector.db, syn_ctxt) {
Some(crate_root) => PathKind::DollarCrate(crate_root),
None => PathKind::Crate,
}
}
if segments.len() == 1
&& kind == PathKind::Plain
&& let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast)
{
let syn_ctxt = collector.expander.ctx_for_range(path.segment()?.syntax().text_range());
if let Some(macro_call_id) = syn_ctxt.outer_expn(collector.db)
&& collector.db.lookup_intern_macro_call(macro_call_id.into()).def.local_inner
{
kind = match resolve_crate_root(collector.db, syn_ctxt) {
Some(crate_root) => PathKind::DollarCrate(crate_root),
None => PathKind::Crate,
}
}
}

View file

@ -900,14 +900,12 @@ impl Printer<'_> {
let field_name = arg.name.display(self.db, edition).to_string();
let mut same_name = false;
if let Pat::Bind { id, subpat: None } = &self.store[arg.pat] {
if let Binding { name, mode: BindingAnnotation::Unannotated, .. } =
if let Pat::Bind { id, subpat: None } = &self.store[arg.pat]
&& let Binding { name, mode: BindingAnnotation::Unannotated, .. } =
&self.store.assert_expr_only().bindings[*id]
{
if name.as_str() == field_name {
same_name = true;
}
}
&& name.as_str() == field_name
{
same_name = true;
}
w!(p, "{}", field_name);

View file

@ -107,11 +107,11 @@ struct FindPathCtx<'db> {
/// Attempts to find a path to refer to the given `item` visible from the `from` ModuleId
fn find_path_inner(ctx: &FindPathCtx<'_>, item: ItemInNs, max_len: usize) -> Option<ModPath> {
// - if the item is a module, jump straight to module search
if !ctx.is_std_item {
if let ItemInNs::Types(ModuleDefId::ModuleId(module_id)) = item {
return find_path_for_module(ctx, &mut FxHashSet::default(), module_id, true, max_len)
.map(|choice| choice.path);
}
if !ctx.is_std_item
&& let ItemInNs::Types(ModuleDefId::ModuleId(module_id)) = item
{
return find_path_for_module(ctx, &mut FxHashSet::default(), module_id, true, max_len)
.map(|choice| choice.path);
}
let may_be_in_scope = match ctx.prefix {
@ -226,15 +226,15 @@ fn find_path_for_module(
}
// - if the module can be referenced as self, super or crate, do that
if let Some(kind) = is_kw_kind_relative_to_from(ctx.from_def_map, module_id, ctx.from) {
if ctx.prefix != PrefixKind::ByCrate || kind == PathKind::Crate {
return Some(Choice {
path: ModPath::from_segments(kind, None),
path_text_len: path_kind_len(kind),
stability: Stable,
prefer_due_to_prelude: false,
});
}
if let Some(kind) = is_kw_kind_relative_to_from(ctx.from_def_map, module_id, ctx.from)
&& (ctx.prefix != PrefixKind::ByCrate || kind == PathKind::Crate)
{
return Some(Choice {
path: ModPath::from_segments(kind, None),
path_text_len: path_kind_len(kind),
stability: Stable,
prefer_due_to_prelude: false,
});
}
// - if the module is in the prelude, return it by that path
@ -604,29 +604,29 @@ fn find_local_import_locations(
&def_map[module.local_id]
};
if let Some((name, vis, declared)) = data.scope.name_of(item) {
if vis.is_visible_from(db, from) {
let is_pub_or_explicit = match vis {
Visibility::Module(_, VisibilityExplicitness::Explicit) => {
cov_mark::hit!(explicit_private_imports);
true
}
Visibility::Module(_, VisibilityExplicitness::Implicit) => {
cov_mark::hit!(discount_private_imports);
false
}
Visibility::PubCrate(_) => true,
Visibility::Public => true,
};
// Ignore private imports unless they are explicit. these could be used if we are
// in a submodule of this module, but that's usually not
// what the user wants; and if this module can import
// the item and we're a submodule of it, so can we.
// Also this keeps the cached data smaller.
if declared || is_pub_or_explicit {
cb(visited_modules, name, module);
if let Some((name, vis, declared)) = data.scope.name_of(item)
&& vis.is_visible_from(db, from)
{
let is_pub_or_explicit = match vis {
Visibility::Module(_, VisibilityExplicitness::Explicit) => {
cov_mark::hit!(explicit_private_imports);
true
}
Visibility::Module(_, VisibilityExplicitness::Implicit) => {
cov_mark::hit!(discount_private_imports);
false
}
Visibility::PubCrate(_) => true,
Visibility::Public => true,
};
// Ignore private imports unless they are explicit. these could be used if we are
// in a submodule of this module, but that's usually not
// what the user wants; and if this module can import
// the item and we're a submodule of it, so can we.
// Also this keeps the cached data smaller.
if declared || is_pub_or_explicit {
cb(visited_modules, name, module);
}
}

View file

@ -510,12 +510,11 @@ impl ItemScope {
id: AttrId,
idx: usize,
) {
if let Some(derives) = self.derive_macros.get_mut(&adt) {
if let Some(DeriveMacroInvocation { derive_call_ids, .. }) =
if let Some(derives) = self.derive_macros.get_mut(&adt)
&& let Some(DeriveMacroInvocation { derive_call_ids, .. }) =
derives.iter_mut().find(|&&mut DeriveMacroInvocation { attr_id, .. }| id == attr_id)
{
derive_call_ids[idx] = Some(call);
}
{
derive_call_ids[idx] = Some(call);
}
}

View file

@ -83,12 +83,12 @@ impl<'a> Ctx<'a> {
.flat_map(|item| self.lower_mod_item(&item))
.collect();
if let Some(ast::Expr::MacroExpr(tail_macro)) = stmts.expr() {
if let Some(call) = tail_macro.macro_call() {
cov_mark::hit!(macro_stmt_with_trailing_macro_expr);
if let Some(mod_item) = self.lower_mod_item(&call.into()) {
self.top_level.push(mod_item);
}
if let Some(ast::Expr::MacroExpr(tail_macro)) = stmts.expr()
&& let Some(call) = tail_macro.macro_call()
{
cov_mark::hit!(macro_stmt_with_trailing_macro_expr);
if let Some(mod_item) = self.lower_mod_item(&call.into()) {
self.top_level.push(mod_item);
}
}
@ -112,12 +112,11 @@ impl<'a> Ctx<'a> {
_ => None,
})
.collect();
if let Some(ast::Expr::MacroExpr(expr)) = block.tail_expr() {
if let Some(call) = expr.macro_call() {
if let Some(mod_item) = self.lower_mod_item(&call.into()) {
self.top_level.push(mod_item);
}
}
if let Some(ast::Expr::MacroExpr(expr)) = block.tail_expr()
&& let Some(call) = expr.macro_call()
&& let Some(mod_item) = self.lower_mod_item(&call.into())
{
self.top_level.push(mod_item);
}
self.tree.vis.arena = self.visibilities.into_iter().collect();
self.tree.top_level = self.top_level.into_boxed_slice();

View file

@ -218,10 +218,10 @@ pub(crate) fn crate_notable_traits(db: &dyn DefDatabase, krate: Crate) -> Option
for (_, module_data) in crate_def_map.modules() {
for def in module_data.scope.declarations() {
if let ModuleDefId::TraitId(trait_) = def {
if db.attrs(trait_.into()).has_doc_notable_trait() {
traits.push(trait_);
}
if let ModuleDefId::TraitId(trait_) = def
&& db.attrs(trait_.into()).has_doc_notable_trait()
{
traits.push(trait_);
}
}
}

View file

@ -221,46 +221,42 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
_ => None,
};
if let Some(src) = src {
if let Some(file_id) = src.file_id.macro_file() {
if let MacroKind::Derive
| MacroKind::DeriveBuiltIn
| MacroKind::Attr
| MacroKind::AttrBuiltIn = file_id.kind(&db)
{
let call = file_id.call_node(&db);
let mut show_spans = false;
let mut show_ctxt = false;
for comment in
call.value.children_with_tokens().filter(|it| it.kind() == COMMENT)
{
show_spans |= comment.to_string().contains("+spans");
show_ctxt |= comment.to_string().contains("+syntaxctxt");
}
let pp = pretty_print_macro_expansion(
src.value,
db.span_map(src.file_id).as_ref(),
show_spans,
show_ctxt,
);
format_to!(expanded_text, "\n{}", pp)
}
if let Some(src) = src
&& let Some(file_id) = src.file_id.macro_file()
&& let MacroKind::Derive
| MacroKind::DeriveBuiltIn
| MacroKind::Attr
| MacroKind::AttrBuiltIn = file_id.kind(&db)
{
let call = file_id.call_node(&db);
let mut show_spans = false;
let mut show_ctxt = false;
for comment in call.value.children_with_tokens().filter(|it| it.kind() == COMMENT) {
show_spans |= comment.to_string().contains("+spans");
show_ctxt |= comment.to_string().contains("+syntaxctxt");
}
let pp = pretty_print_macro_expansion(
src.value,
db.span_map(src.file_id).as_ref(),
show_spans,
show_ctxt,
);
format_to!(expanded_text, "\n{}", pp)
}
}
for impl_id in def_map[local_id].scope.impls() {
let src = impl_id.lookup(&db).source(&db);
if let Some(macro_file) = src.file_id.macro_file() {
if let MacroKind::DeriveBuiltIn | MacroKind::Derive = macro_file.kind(&db) {
let pp = pretty_print_macro_expansion(
src.value.syntax().clone(),
db.span_map(macro_file.into()).as_ref(),
false,
false,
);
format_to!(expanded_text, "\n{}", pp)
}
if let Some(macro_file) = src.file_id.macro_file()
&& let MacroKind::DeriveBuiltIn | MacroKind::Derive = macro_file.kind(&db)
{
let pp = pretty_print_macro_expansion(
src.value.syntax().clone(),
db.span_map(macro_file.into()).as_ref(),
false,
false,
);
format_to!(expanded_text, "\n{}", pp)
}
}

View file

@ -261,20 +261,20 @@ impl<'db> DefCollector<'db> {
// Process other crate-level attributes.
for attr in &*attrs {
if let Some(cfg) = attr.cfg() {
if self.cfg_options.check(&cfg) == Some(false) {
process = false;
break;
}
if let Some(cfg) = attr.cfg()
&& self.cfg_options.check(&cfg) == Some(false)
{
process = false;
break;
}
let Some(attr_name) = attr.path.as_ident() else { continue };
match () {
() if *attr_name == sym::recursion_limit => {
if let Some(limit) = attr.string_value() {
if let Ok(limit) = limit.as_str().parse() {
crate_data.recursion_limit = Some(limit);
}
if let Some(limit) = attr.string_value()
&& let Ok(limit) = limit.as_str().parse()
{
crate_data.recursion_limit = Some(limit);
}
}
() if *attr_name == sym::crate_type => {
@ -1188,56 +1188,44 @@ impl<'db> DefCollector<'db> {
// Multiple globs may import the same item and they may override visibility from
// previously resolved globs. Handle overrides here and leave the rest to
// `ItemScope::push_res_with_import()`.
if let Some(def) = defs.types {
if let Some(prev_def) = prev_defs.types {
if def.def == prev_def.def
&& self.from_glob_import.contains_type(module_id, name.clone())
&& def.vis != prev_def.vis
&& def.vis.max(prev_def.vis, &self.def_map) == Some(def.vis)
{
changed = true;
// This import is being handled here, don't pass it down to
// `ItemScope::push_res_with_import()`.
defs.types = None;
self.def_map.modules[module_id]
.scope
.update_visibility_types(name, def.vis);
}
}
if let Some(def) = defs.types
&& let Some(prev_def) = prev_defs.types
&& def.def == prev_def.def
&& self.from_glob_import.contains_type(module_id, name.clone())
&& def.vis != prev_def.vis
&& def.vis.max(prev_def.vis, &self.def_map) == Some(def.vis)
{
changed = true;
// This import is being handled here, don't pass it down to
// `ItemScope::push_res_with_import()`.
defs.types = None;
self.def_map.modules[module_id].scope.update_visibility_types(name, def.vis);
}
if let Some(def) = defs.values {
if let Some(prev_def) = prev_defs.values {
if def.def == prev_def.def
&& self.from_glob_import.contains_value(module_id, name.clone())
&& def.vis != prev_def.vis
&& def.vis.max(prev_def.vis, &self.def_map) == Some(def.vis)
{
changed = true;
// See comment above.
defs.values = None;
self.def_map.modules[module_id]
.scope
.update_visibility_values(name, def.vis);
}
}
if let Some(def) = defs.values
&& let Some(prev_def) = prev_defs.values
&& def.def == prev_def.def
&& self.from_glob_import.contains_value(module_id, name.clone())
&& def.vis != prev_def.vis
&& def.vis.max(prev_def.vis, &self.def_map) == Some(def.vis)
{
changed = true;
// See comment above.
defs.values = None;
self.def_map.modules[module_id].scope.update_visibility_values(name, def.vis);
}
if let Some(def) = defs.macros {
if let Some(prev_def) = prev_defs.macros {
if def.def == prev_def.def
&& self.from_glob_import.contains_macro(module_id, name.clone())
&& def.vis != prev_def.vis
&& def.vis.max(prev_def.vis, &self.def_map) == Some(def.vis)
{
changed = true;
// See comment above.
defs.macros = None;
self.def_map.modules[module_id]
.scope
.update_visibility_macros(name, def.vis);
}
}
if let Some(def) = defs.macros
&& let Some(prev_def) = prev_defs.macros
&& def.def == prev_def.def
&& self.from_glob_import.contains_macro(module_id, name.clone())
&& def.vis != prev_def.vis
&& def.vis.max(prev_def.vis, &self.def_map) == Some(def.vis)
{
changed = true;
// See comment above.
defs.macros = None;
self.def_map.modules[module_id].scope.update_visibility_macros(name, def.vis);
}
}
@ -1392,15 +1380,14 @@ impl<'db> DefCollector<'db> {
Resolved::Yes
};
if let Some(ident) = path.as_ident() {
if let Some(helpers) = self.def_map.derive_helpers_in_scope.get(&ast_id) {
if helpers.iter().any(|(it, ..)| it == ident) {
cov_mark::hit!(resolved_derive_helper);
// Resolved to derive helper. Collect the item's attributes again,
// starting after the derive helper.
return recollect_without(self);
}
}
if let Some(ident) = path.as_ident()
&& let Some(helpers) = self.def_map.derive_helpers_in_scope.get(&ast_id)
&& helpers.iter().any(|(it, ..)| it == ident)
{
cov_mark::hit!(resolved_derive_helper);
// Resolved to derive helper. Collect the item's attributes again,
// starting after the derive helper.
return recollect_without(self);
}
let def = match resolver_def_id(path) {
@ -1729,12 +1716,12 @@ impl ModCollector<'_, '_> {
let mut process_mod_item = |item: ModItemId| {
let attrs = self.item_tree.attrs(db, krate, item.ast_id());
if let Some(cfg) = attrs.cfg() {
if !self.is_cfg_enabled(&cfg) {
let ast_id = item.ast_id().erase();
self.emit_unconfigured_diagnostic(InFile::new(self.file_id(), ast_id), &cfg);
return;
}
if let Some(cfg) = attrs.cfg()
&& !self.is_cfg_enabled(&cfg)
{
let ast_id = item.ast_id().erase();
self.emit_unconfigured_diagnostic(InFile::new(self.file_id(), ast_id), &cfg);
return;
}
if let Err(()) = self.resolve_attributes(&attrs, item, container) {
@ -1871,14 +1858,13 @@ impl ModCollector<'_, '_> {
if self.def_collector.def_map.block.is_none()
&& self.def_collector.is_proc_macro
&& self.module_id == DefMap::ROOT
&& let Some(proc_macro) = attrs.parse_proc_macro_decl(&it.name)
{
if let Some(proc_macro) = attrs.parse_proc_macro_decl(&it.name) {
self.def_collector.export_proc_macro(
proc_macro,
InFile::new(self.file_id(), id),
fn_id,
);
}
self.def_collector.export_proc_macro(
proc_macro,
InFile::new(self.file_id(), id),
fn_id,
);
}
update_def(self.def_collector, fn_id.into(), &it.name, vis, false);
@ -2419,13 +2405,13 @@ impl ModCollector<'_, '_> {
macro_id,
&self.item_tree[mac.visibility],
);
if let Some(helpers) = helpers_opt {
if self.def_collector.def_map.block.is_none() {
Arc::get_mut(&mut self.def_collector.def_map.data)
.unwrap()
.exported_derives
.insert(macro_id.into(), helpers);
}
if let Some(helpers) = helpers_opt
&& self.def_collector.def_map.block.is_none()
{
Arc::get_mut(&mut self.def_collector.def_map.data)
.unwrap()
.exported_derives
.insert(macro_id.into(), helpers);
}
}

View file

@ -228,15 +228,15 @@ impl<'db> Resolver<'db> {
ResolvePathResultPrefixInfo::default(),
));
}
} else if let &GenericDefId::AdtId(adt) = def {
if *first_name == sym::Self_ {
return Some((
TypeNs::AdtSelfType(adt),
remaining_idx(),
None,
ResolvePathResultPrefixInfo::default(),
));
}
} else if let &GenericDefId::AdtId(adt) = def
&& *first_name == sym::Self_
{
return Some((
TypeNs::AdtSelfType(adt),
remaining_idx(),
None,
ResolvePathResultPrefixInfo::default(),
));
}
if let Some(id) = params.find_type_by_name(first_name, *def) {
return Some((
@ -401,13 +401,13 @@ impl<'db> Resolver<'db> {
handle_macro_def_scope(db, &mut hygiene_id, &mut hygiene_info, macro_id)
}
Scope::GenericParams { params, def } => {
if let &GenericDefId::ImplId(impl_) = def {
if *first_name == sym::Self_ {
return Some((
ResolveValueResult::ValueNs(ValueNs::ImplSelf(impl_), None),
ResolvePathResultPrefixInfo::default(),
));
}
if let &GenericDefId::ImplId(impl_) = def
&& *first_name == sym::Self_
{
return Some((
ResolveValueResult::ValueNs(ValueNs::ImplSelf(impl_), None),
ResolvePathResultPrefixInfo::default(),
));
}
if let Some(id) = params.find_const_by_name(first_name, *def) {
let val = ValueNs::GenericParam(id);
@ -436,14 +436,14 @@ impl<'db> Resolver<'db> {
ResolvePathResultPrefixInfo::default(),
));
}
} else if let &GenericDefId::AdtId(adt) = def {
if *first_name == sym::Self_ {
let ty = TypeNs::AdtSelfType(adt);
return Some((
ResolveValueResult::Partial(ty, 1, None),
ResolvePathResultPrefixInfo::default(),
));
}
} else if let &GenericDefId::AdtId(adt) = def
&& *first_name == sym::Self_
{
let ty = TypeNs::AdtSelfType(adt);
return Some((
ResolveValueResult::Partial(ty, 1, None),
ResolvePathResultPrefixInfo::default(),
));
}
if let Some(id) = params.find_type_by_name(first_name, *def) {
let ty = TypeNs::GenericParam(id);
@ -469,13 +469,14 @@ impl<'db> Resolver<'db> {
// If a path of the shape `u16::from_le_bytes` failed to resolve at all, then we fall back
// to resolving to the primitive type, to allow this to still work in the presence of
// `use core::u16;`.
if path.kind == PathKind::Plain && n_segments > 1 {
if let Some(builtin) = BuiltinType::by_name(first_name) {
return Some((
ResolveValueResult::Partial(TypeNs::BuiltinType(builtin), 1, None),
ResolvePathResultPrefixInfo::default(),
));
}
if path.kind == PathKind::Plain
&& n_segments > 1
&& let Some(builtin) = BuiltinType::by_name(first_name)
{
return Some((
ResolveValueResult::Partial(TypeNs::BuiltinType(builtin), 1, None),
ResolvePathResultPrefixInfo::default(),
));
}
None
@ -660,12 +661,11 @@ impl<'db> Resolver<'db> {
Scope::BlockScope(m) => traits.extend(m.def_map[m.module_id].scope.traits()),
&Scope::GenericParams { def: GenericDefId::ImplId(impl_), .. } => {
let impl_data = db.impl_signature(impl_);
if let Some(target_trait) = impl_data.target_trait {
if let Some(TypeNs::TraitId(trait_)) = self
if let Some(target_trait) = impl_data.target_trait
&& let Some(TypeNs::TraitId(trait_)) = self
.resolve_path_in_type_ns_fully(db, &impl_data.store[target_trait.path])
{
traits.insert(trait_);
}
{
traits.insert(trait_);
}
}
_ => (),
@ -918,17 +918,17 @@ fn handle_macro_def_scope(
hygiene_info: &mut Option<(SyntaxContext, MacroDefId)>,
macro_id: &MacroDefId,
) {
if let Some((parent_ctx, label_macro_id)) = hygiene_info {
if label_macro_id == macro_id {
// A macro is allowed to refer to variables from before its declaration.
// Therefore, if we got to the rib of its declaration, give up its hygiene
// and use its parent expansion.
*hygiene_id = HygieneId::new(parent_ctx.opaque_and_semitransparent(db));
*hygiene_info = parent_ctx.outer_expn(db).map(|expansion| {
let expansion = db.lookup_intern_macro_call(expansion.into());
(parent_ctx.parent(db), expansion.def)
});
}
if let Some((parent_ctx, label_macro_id)) = hygiene_info
&& label_macro_id == macro_id
{
// A macro is allowed to refer to variables from before its declaration.
// Therefore, if we got to the rib of its declaration, give up its hygiene
// and use its parent expansion.
*hygiene_id = HygieneId::new(parent_ctx.opaque_and_semitransparent(db));
*hygiene_info = parent_ctx.outer_expn(db).map(|expansion| {
let expansion = db.lookup_intern_macro_call(expansion.into());
(parent_ctx.parent(db), expansion.def)
});
}
}