Skip to content

Commit 11de170

Browse files
author
The rustc-josh-sync Cronjob Bot
committed
Merge ref '2dc30247c5d8' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 2dc30247c5d8293aaa31e1d7dae2ed2fde908ada Filtered ref: dab12aee0f52f7b83cc62ae565855c731bed502f Upstream diff: rust-lang/rust@47cd712...2dc3024 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 7b9cee6 + 874a0a1 commit 11de170

269 files changed

Lines changed: 5280 additions & 3369 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/rustdoc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88
CARGO_INCREMENTAL: 0
99
CARGO_NET_RETRY: 10
1010
RUSTFLAGS: "-D warnings -W unreachable-pub"
11+
RUSTDOCFLAGS: "-D warnings"
1112
RUSTUP_MAX_RETRIES: 10
1213

1314
jobs:

crates/base-db/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ vfs.workspace = true
3131
span.workspace = true
3232
intern.workspace = true
3333

34+
[features]
35+
default = []
36+
in-rust-tree = []
37+
3438
[lints]
3539
workspace = true

crates/base-db/src/lib.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! base_db defines basic database traits. The concrete DB is defined by ide.
22
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
5+
#[cfg(feature = "in-rust-tree")]
6+
extern crate rustc_driver as _;
7+
38
pub use salsa;
49
pub use salsa_macros;
510

@@ -59,6 +64,28 @@ macro_rules! impl_intern_key {
5964
};
6065
}
6166

67+
/// # SAFETY
68+
///
69+
/// `old_pointer` must be valid for unique writes
70+
pub unsafe fn unsafe_update_eq<T>(old_pointer: *mut T, new_value: T) -> bool
71+
where
72+
T: PartialEq,
73+
{
74+
// SAFETY: Caller obligation
75+
let old_ref: &mut T = unsafe { &mut *old_pointer };
76+
77+
if *old_ref != new_value {
78+
*old_ref = new_value;
79+
true
80+
} else {
81+
// Subtle but important: Eq impls can be buggy or define equality
82+
// in surprising ways. If it says that the value has not changed,
83+
// we do not modify the existing value, and thus do not have to
84+
// update the revision, as downstream code will not see the new value.
85+
false
86+
}
87+
}
88+
6289
pub const DEFAULT_FILE_TEXT_LRU_CAP: u16 = 16;
6390
pub const DEFAULT_PARSE_LRU_CAP: u16 = 128;
6491
pub const DEFAULT_BORROWCK_LRU_CAP: u16 = 2024;

crates/cfg/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ syntax.workspace = true
3333
# tt is needed for testing
3434
cfg = { path = ".", default-features = false, features = ["tt"] }
3535

36+
[features]
37+
default = []
38+
in-rust-tree = []
39+
3640
[lints]
3741
workspace = true

crates/cfg/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator
22
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
5+
#[cfg(feature = "in-rust-tree")]
6+
extern crate rustc_driver as _;
7+
38
mod cfg_expr;
49
mod dnf;
510
#[cfg(test)]

crates/hir-def/src/attrs.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ use syntax::{
4545
use tt::{TextRange, TextSize};
4646

4747
use crate::{
48-
AdtId, AstIdLoc, AttrDefId, FieldId, FunctionId, GenericDefId, HasModule, InternedModuleId,
49-
LifetimeParamId, LocalFieldId, MacroId, TypeOrConstParamId, VariantId,
48+
AdtId, AstIdLoc, AttrDefId, FieldId, FunctionId, GenericDefId, HasModule, LifetimeParamId,
49+
LocalFieldId, MacroId, ModuleId, TypeOrConstParamId, VariantId,
5050
db::DefDatabase,
5151
hir::generics::{GenericParams, LocalLifetimeParamId, LocalTypeOrConstParamId},
5252
nameres::ModuleOrigin,
@@ -155,6 +155,9 @@ fn match_attr_flags(attr_flags: &mut AttrFlags, attr: Meta) -> ControlFlow<Infal
155155
"rustc_skip_during_method_dispatch" => {
156156
extract_rustc_skip_during_method_dispatch(attr_flags, tt)
157157
}
158+
"rustc_deprecated_safe_2024" => {
159+
attr_flags.insert(AttrFlags::RUSTC_DEPRECATED_SAFE_2024)
160+
}
158161
_ => {}
159162
},
160163
2 => match path.segments[0].text() {
@@ -295,9 +298,8 @@ fn attrs_source(
295298
) -> (InFile<ast::AnyHasAttrs>, Option<InFile<ast::Module>>, Crate) {
296299
let (owner, krate) = match owner {
297300
AttrDefId::ModuleId(id) => {
298-
let id = id.loc(db);
299301
let def_map = id.def_map(db);
300-
let (definition, declaration) = match def_map[id.local_id].origin {
302+
let (definition, declaration) = match def_map[id].origin {
301303
ModuleOrigin::CrateRoot { definition } => {
302304
let file = db.parse(definition).tree();
303305
(InFile::new(definition.into(), ast::AnyHasAttrs::from(file)), None)
@@ -318,7 +320,7 @@ fn attrs_source(
318320
(block.with_value(definition.into()), None)
319321
}
320322
};
321-
return (definition, declaration, id.krate);
323+
return (definition, declaration, def_map.krate());
322324
}
323325
AttrDefId::AdtId(AdtId::StructId(it)) => attrs_from_ast_id_loc(db, it),
324326
AttrDefId::AdtId(AdtId::UnionId(it)) => attrs_from_ast_id_loc(db, it),
@@ -1201,14 +1203,14 @@ impl AttrFlags {
12011203
}
12021204

12031205
#[inline]
1204-
pub fn doc_keyword(db: &dyn DefDatabase, owner: InternedModuleId) -> Option<Symbol> {
1206+
pub fn doc_keyword(db: &dyn DefDatabase, owner: ModuleId) -> Option<Symbol> {
12051207
if !AttrFlags::query(db, AttrDefId::ModuleId(owner)).contains(AttrFlags::HAS_DOC_KEYWORD) {
12061208
return None;
12071209
}
12081210
return doc_keyword(db, owner);
12091211

12101212
#[salsa::tracked]
1211-
fn doc_keyword(db: &dyn DefDatabase, owner: InternedModuleId) -> Option<Symbol> {
1213+
fn doc_keyword(db: &dyn DefDatabase, owner: ModuleId) -> Option<Symbol> {
12121214
collect_attrs(db, AttrDefId::ModuleId(owner), |attr| {
12131215
if let Meta::TokenTree { path, tt } = attr
12141216
&& path.is1("doc")

crates/hir-def/src/db.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ use la_arena::ArenaMap;
88
use triomphe::Arc;
99

1010
use crate::{
11-
AssocItemId, AttrDefId, BlockId, BlockLoc, ConstId, ConstLoc, CrateRootModuleId, DefWithBodyId,
12-
EnumId, EnumLoc, EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId,
13-
ExternCrateLoc, FunctionId, FunctionLoc, GenericDefId, HasModule, ImplId, ImplLoc,
14-
InternedModuleId, LocalFieldId, Macro2Id, Macro2Loc, MacroExpander, MacroId, MacroRulesId,
15-
MacroRulesLoc, MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId, StaticLoc, StructId,
16-
StructLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc, UseId, UseLoc,
17-
VariantId,
11+
AssocItemId, AttrDefId, BlockId, BlockLoc, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc,
12+
EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId, ExternCrateLoc,
13+
FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalFieldId, Macro2Id, Macro2Loc,
14+
MacroExpander, MacroId, MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ProcMacroId,
15+
ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc, TraitId, TraitLoc, TypeAliasId,
16+
TypeAliasLoc, UnionId, UnionLoc, UseId, UseLoc, VariantId,
1817
attrs::AttrFlags,
1918
expr_store::{
2019
Body, BodySourceMap, ExpressionStore, ExpressionStoreSourceMap, scope::ExprScopes,
@@ -276,8 +275,8 @@ fn include_macro_invoc(
276275
}
277276

278277
fn crate_supports_no_std(db: &dyn DefDatabase, crate_id: Crate) -> bool {
279-
let root_module = CrateRootModuleId::from(crate_id).module(db);
280-
let attrs = AttrFlags::query(db, AttrDefId::ModuleId(InternedModuleId::new(db, root_module)));
278+
let root_module = crate_def_map(db, crate_id).root_module_id();
279+
let attrs = AttrFlags::query(db, AttrDefId::ModuleId(root_module));
281280
attrs.contains(AttrFlags::IS_NO_STD)
282281
}
283282

@@ -298,7 +297,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
298297
let loc: Macro2Loc = it.lookup(db);
299298

300299
MacroDefId {
301-
krate: loc.container.krate,
300+
krate: loc.container.krate(db),
302301
kind: kind(loc.expander, loc.id.file_id, loc.id.value.upcast()),
303302
local_inner: false,
304303
allow_internal_unsafe: loc.allow_internal_unsafe,
@@ -309,7 +308,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
309308
let loc: MacroRulesLoc = it.lookup(db);
310309

311310
MacroDefId {
312-
krate: loc.container.krate,
311+
krate: loc.container.krate(db),
313312
kind: kind(loc.expander, loc.id.file_id, loc.id.value.upcast()),
314313
local_inner: loc.flags.contains(MacroRulesLocFlags::LOCAL_INNER),
315314
allow_internal_unsafe: loc
@@ -322,7 +321,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
322321
let loc = it.lookup(db);
323322

324323
MacroDefId {
325-
krate: loc.container.krate,
324+
krate: loc.container.krate(db),
326325
kind: MacroDefKind::ProcMacro(loc.id, loc.expander, loc.kind),
327326
local_inner: false,
328327
allow_internal_unsafe: false,

crates/hir-def/src/expr_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub use self::lower::{
4343
hir_assoc_type_binding_to_ast, hir_generic_arg_to_ast, hir_segment_to_ast_segment,
4444
};
4545

46-
/// A wrapper around [`span::SyntaxContextId`] that is intended only for comparisons.
46+
/// A wrapper around [`span::SyntaxContext`] that is intended only for comparisons.
4747
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4848
pub struct HygieneId(span::SyntaxContext);
4949

0 commit comments

Comments
 (0)