Skip to content

resolve: Do not finalize shadowed bindings #145113

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::{
AttrStyle, Attribute, Block, Error, Expr, Ident, Pat, ReturnType, Token, Type, braced,
parenthesized, parse_macro_input, parse_quote, token,
parenthesized, parse_macro_input, token,
};

mod kw {
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
_ => Err(Determinacy::Determined),
},
Scope::Module(module, derive_fallback_lint_id) => {
// FIXME: use `finalize_scope` here.
let (adjusted_parent_scope, adjusted_finalize) =
if matches!(scope_set, ScopeSet::ModuleAndExternPrelude(..)) {
(parent_scope, finalize)
(parent_scope, finalize_scope!())
} else {
(
&ParentScope { module, ..*parent_scope },
finalize.map(|f| Finalize { used: Used::Scope, ..f }),
finalize_scope!().map(|f| Finalize { used: Used::Scope, ..f }),
)
};
let binding = this.reborrow().resolve_ident_in_module_unadjusted(
Expand Down Expand Up @@ -574,8 +573,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
None => Err(Determinacy::Determined),
},
Scope::ExternPreludeItems => {
// FIXME: use `finalize_scope` here.
match this.reborrow().extern_prelude_get_item(ident, finalize.is_some()) {
match this
.reborrow()
.extern_prelude_get_item(ident, finalize_scope!().is_some())
{
Some(binding) => Ok((binding, Flags::empty())),
None => Err(Determinacy::determined(
this.graph_root.unexpanded_invocations.borrow().is_empty(),
Expand Down
1 change: 0 additions & 1 deletion library/alloctests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#![deny(unsafe_op_in_unsafe_fn)]

extern crate alloc;
extern crate test;

use std::hash::{DefaultHasher, Hash, Hasher};

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/unix/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod imp {
use crate::sync::OnceLock;
use crate::sync::atomic::{Atomic, AtomicBool, AtomicPtr, AtomicUsize, Ordering};
use crate::sys::pal::unix::os;
use crate::{io, mem, panic, ptr};
use crate::{io, mem, ptr};

// Signal handler for the SIGSEGV and SIGBUS handlers. We've got guard pages
// (unmapped pages) at the end of every thread's stack, so if a thread ends
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/useless_attribute.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub mod redundant_imports_issue {
() => {};
}

#[expect(redundant_imports)]
#[expect(unused_imports)]
pub(crate) use empty;

empty!();
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/useless_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub mod redundant_imports_issue {
() => {};
}

#[expect(redundant_imports)]
#[expect(unused_imports)]
pub(crate) use empty;

empty!();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracing::debug;

use crate::{
ExpandError, ExpandResult, MacroCallId,
builtin::quote::{dollar_crate, quote},
builtin::quote::dollar_crate,
db::ExpandDatabase,
hygiene::span_with_def_site_ctxt,
name::{self, AsName, Name},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use syntax_bridge::syntax_node_to_token_tree;

use crate::{
EditionedFileId, ExpandError, ExpandResult, Lookup as _, MacroCallId,
builtin::quote::{WithDelimiter, dollar_crate, quote},
builtin::quote::{WithDelimiter, dollar_crate},
db::ExpandDatabase,
hygiene::{span_with_call_site_ctxt, span_with_def_site_ctxt},
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ mod tests {
use span::{Edition, ROOT_ERASED_FILE_AST_ID, SpanAnchor, SyntaxContext};
use syntax::{TextRange, TextSize};

use super::quote;

const DUMMY: tt::Span = tt::Span {
range: TextRange::empty(TextSize::new(0)),
anchor: SpanAnchor {
Expand Down
1 change: 0 additions & 1 deletion src/tools/rustfmt/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ mod test {
#[allow(dead_code)]
mod mock {
use super::super::*;
use crate::config_option_with_style_edition_default;
use rustfmt_config_proc_macro::config_type;

#[config_type]
Expand Down
Loading