Skip to content

Rust 2024 and 1.85 #19236

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

Merged
merged 9 commits into from
Mar 15, 2025
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resolver = "2"

[workspace.package]
rust-version = "1.85"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
authors = ["rust-analyzer team"]
repository = "https://github.com/rust-lang/rust-analyzer"
Expand Down
6 changes: 1 addition & 5 deletions crates/base-db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,5 @@ impl FileChange {
}

fn durability(source_root: &SourceRoot) -> Durability {
if source_root.is_library {
Durability::HIGH
} else {
Durability::LOW
}
if source_root.is_library { Durability::HIGH } else { Durability::LOW }
}
84 changes: 48 additions & 36 deletions crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use std::hash::BuildHasherDefault;
use std::{fmt, mem, ops};

use cfg::{CfgOptions, HashableCfgOptions};
use dashmap::mapref::entry::Entry;
use dashmap::DashMap;
use dashmap::mapref::entry::Entry;
use intern::Symbol;
use la_arena::{Arena, Idx, RawIdx};
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
use salsa::{Durability, Setter};
use span::{Edition, EditionedFileId};
use triomphe::Arc;
use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
use vfs::{AbsPathBuf, AnchoredPath, FileId, VfsPath, file_set::FileSet};

use crate::{CrateWorkspaceData, RootQueryDb};

Expand Down Expand Up @@ -110,11 +110,7 @@ impl CrateName {
/// Dashes are not allowed in the crate names,
/// hence the input string is returned as `Err` for those cases.
pub fn new(name: &str) -> Result<CrateName, &str> {
if name.contains('-') {
Err(name)
} else {
Ok(Self(Symbol::intern(name)))
}
if name.contains('-') { Err(name) } else { Ok(Self(Symbol::intern(name))) }
}

/// Creates a crate name, unconditionally replacing the dashes with underscores.
Expand Down Expand Up @@ -922,15 +918,21 @@ mod tests {
None,
empty_ws_data(),
);
assert!(graph
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_ok());
assert!(graph
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
.is_ok());
assert!(graph
.add_dep(crate3, DependencyBuilder::new(CrateName::new("crate1").unwrap(), crate1,))
.is_err());
assert!(
graph
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_ok()
);
assert!(
graph
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
.is_ok()
);
assert!(
graph
.add_dep(crate3, DependencyBuilder::new(CrateName::new("crate1").unwrap(), crate1,))
.is_err()
);
}

#[test]
Expand Down Expand Up @@ -962,12 +964,16 @@ mod tests {
None,
empty_ws_data(),
);
assert!(graph
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_ok());
assert!(graph
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_err());
assert!(
graph
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_ok()
);
assert!(
graph
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_err()
);
}

#[test]
Expand Down Expand Up @@ -1012,12 +1018,16 @@ mod tests {
None,
empty_ws_data(),
);
assert!(graph
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_ok());
assert!(graph
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
.is_ok());
assert!(
graph
.add_dep(crate1, DependencyBuilder::new(CrateName::new("crate2").unwrap(), crate2,))
.is_ok()
);
assert!(
graph
.add_dep(crate2, DependencyBuilder::new(CrateName::new("crate3").unwrap(), crate3,))
.is_ok()
);
}

#[test]
Expand Down Expand Up @@ -1049,15 +1059,17 @@ mod tests {
None,
empty_ws_data(),
);
assert!(graph
.add_dep(
crate1,
DependencyBuilder::new(
CrateName::normalize_dashes("crate-name-with-dashes"),
crate2,
assert!(
graph
.add_dep(
crate1,
DependencyBuilder::new(
CrateName::normalize_dashes("crate-name-with-dashes"),
crate2,
)
)
)
.is_ok());
.is_ok()
);
assert_eq!(
graph.arena[crate1].basic.dependencies,
vec![
Expand Down
6 changes: 3 additions & 3 deletions crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ pub use crate::{
SourceRoot, SourceRootId, TargetLayoutLoadResult, UniqueCrateData,
},
};
use dashmap::{mapref::entry::Entry, DashMap};
use dashmap::{DashMap, mapref::entry::Entry};
pub use query_group::{self};
use rustc_hash::{FxHashSet, FxHasher};
pub use salsa::{self};
use salsa::{Durability, Setter};
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
use syntax::{ast, Parse, SyntaxError};
use syntax::{Parse, SyntaxError, ast};
use triomphe::Arc;
pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, FileId, VfsPath};
pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet};

#[macro_export]
macro_rules! impl_intern_key {
Expand Down
2 changes: 1 addition & 1 deletion crates/cfg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::fmt;

use rustc_hash::FxHashSet;

use intern::{sym, Symbol};
use intern::{Symbol, sym};

pub use cfg_expr::{CfgAtom, CfgExpr};
pub use dnf::DnfExpr;
Expand Down
9 changes: 5 additions & 4 deletions crates/cfg/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use arbitrary::{Arbitrary, Unstructured};
use expect_test::{expect, Expect};
use expect_test::{Expect, expect};
use intern::Symbol;
use syntax::{ast, AstNode, Edition};
use syntax::{AstNode, Edition, ast};
use syntax_bridge::{
dummy_test_span_utils::{DummyTestSpanMap, DUMMY},
syntax_node_to_token_tree, DocCommentDesugarMode,
DocCommentDesugarMode,
dummy_test_span_utils::{DUMMY, DummyTestSpanMap},
syntax_node_to_token_tree,
};

use crate::{CfgAtom, CfgExpr, CfgOptions, DnfExpr};
Expand Down
14 changes: 7 additions & 7 deletions crates/hir-def/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ use base_db::Crate;
use cfg::{CfgExpr, CfgOptions};
use either::Either;
use hir_expand::{
attrs::{collect_attrs, Attr, AttrId, RawAttrs},
HirFileId, InFile,
attrs::{Attr, AttrId, RawAttrs, collect_attrs},
};
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use la_arena::{ArenaMap, Idx, RawIdx};
use mbe::DelimiterKind;
use rustc_abi::ReprOptions;
use syntax::{
ast::{self, HasAttrs},
AstPtr,
ast::{self, HasAttrs},
};
use triomphe::Arc;
use tt::iter::{TtElement, TtIter};

use crate::{
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
VariantId,
db::DefDatabase,
item_tree::{AttrOwner, FieldParent, ItemTreeNode},
lang_item::LangItem,
nameres::{ModuleOrigin, ModuleSource},
src::{HasChildSource, HasSource},
AdtId, AttrDefId, GenericParamId, HasModule, ItemTreeLoc, LocalFieldId, Lookup, MacroId,
VariantId,
};

/// Desugared attributes of an item post `cfg_attr` expansion.
Expand Down Expand Up @@ -770,8 +770,8 @@ mod tests {

use hir_expand::span_map::{RealSpanMap, SpanMap};
use span::FileId;
use syntax::{ast, AstNode, TextRange};
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
use syntax::{AstNode, TextRange, ast};
use syntax_bridge::{DocCommentDesugarMode, syntax_node_to_token_tree};

use crate::attr::{DocAtom, DocExpr};

Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/builtin_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::fmt;

use hir_expand::name::{AsName, Name};
use intern::{sym, Symbol};
use intern::{Symbol, sym};
/// Different signed int types.
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum BuiltinInt {
Expand Down
14 changes: 5 additions & 9 deletions crates/hir-def/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ pub mod adt;

use base_db::Crate;
use hir_expand::name::Name;
use intern::{sym, Symbol};
use intern::{Symbol, sym};
use la_arena::{Idx, RawIdx};
use triomphe::Arc;

use crate::{
ConstId, ExternCrateId, FunctionId, HasModule, ImplId, ItemContainerId, ItemLoc, Lookup,
Macro2Id, MacroRulesId, ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId,
db::DefDatabase,
item_tree::{self, FnFlags, ModItem},
nameres::proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroKind},
nameres::proc_macro::{ProcMacroKind, parse_macro_name_and_helper_attrs},
path::ImportAlias,
type_ref::{TraitRef, TypeBound, TypeRefId, TypesMap},
visibility::RawVisibility,
ConstId, ExternCrateId, FunctionId, HasModule, ImplId, ItemContainerId, ItemLoc, Lookup,
Macro2Id, MacroRulesId, ProcMacroId, StaticId, TraitAliasId, TraitId, TypeAliasId,
};

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -431,11 +431,7 @@ impl ExternCrateDeclData {
Some(krate)
} else {
krate.data(db).dependencies.iter().find_map(|dep| {
if dep.name.symbol() == name.symbol() {
Some(dep.crate_id)
} else {
None
}
if dep.name.symbol() == name.symbol() { Some(dep.crate_id) } else { None }
})
};

Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/data/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use rustc_abi::{IntegerType, ReprOptions};
use triomphe::Arc;

use crate::{
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
db::DefDatabase,
hir::Expr,
item_tree::{
Expand All @@ -20,7 +21,6 @@ use crate::{
nameres::diagnostics::{DefDiagnostic, DefDiagnostics},
type_ref::{TypeRefId, TypesMap},
visibility::RawVisibility,
EnumId, EnumVariantId, LocalFieldId, LocalModuleId, Lookup, StructId, UnionId, VariantId,
};

/// Note that we use `StructData` for unions as well!
Expand Down
26 changes: 13 additions & 13 deletions crates/hir-def/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
//! Defines database & queries for name resolution.
use base_db::{Crate, RootQueryDb, SourceDatabase, Upcast};
use either::Either;
use hir_expand::{db::ExpandDatabase, HirFileId, MacroDefId};
use hir_expand::{HirFileId, MacroDefId, db::ExpandDatabase};
use intern::sym;
use la_arena::ArenaMap;
use span::{EditionedFileId, MacroCallId};
use syntax::{ast, AstPtr};
use syntax::{AstPtr, ast};
use triomphe::Arc;

use crate::{
AttrDefId, BlockId, BlockLoc, ConstBlockId, ConstBlockLoc, ConstId, ConstLoc, DefWithBodyId,
EnumId, EnumLoc, EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId,
ExternCrateLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, InTypeConstId,
InTypeConstLoc, LocalFieldId, Macro2Id, Macro2Loc, MacroId, MacroRulesId, MacroRulesLoc,
MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc,
TraitAliasId, TraitAliasLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc,
UseId, UseLoc, VariantId,
attr::{Attrs, AttrsWithOwner},
data::{
adt::{EnumData, EnumVariantData, EnumVariants, StructData, VariantData},
ConstData, ExternCrateDeclData, FunctionData, ImplData, Macro2Data, MacroRulesData,
ProcMacroData, StaticData, TraitAliasData, TraitData, TypeAliasData,
adt::{EnumData, EnumVariantData, EnumVariants, StructData, VariantData},
},
expr_store::{scope::ExprScopes, Body, BodySourceMap},
expr_store::{Body, BodySourceMap, scope::ExprScopes},
generics::GenericParams,
import_map::ImportMap,
item_tree::{AttrOwner, ItemTree, ItemTreeSourceMaps},
lang_item::{self, LangItem, LangItemTarget, LangItems},
nameres::{
DefMap, LocalDefMap,
assoc::{ImplItems, TraitItems},
diagnostics::DefDiagnostics,
DefMap, LocalDefMap,
},
tt,
type_ref::TypesSourceMap,
visibility::{self, Visibility},
AttrDefId, BlockId, BlockLoc, ConstBlockId, ConstBlockLoc, ConstId, ConstLoc, DefWithBodyId,
EnumId, EnumLoc, EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId,
ExternCrateLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, InTypeConstId,
InTypeConstLoc, LocalFieldId, Macro2Id, Macro2Loc, MacroId, MacroRulesId, MacroRulesLoc,
MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc,
TraitAliasId, TraitAliasLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc,
UseId, UseLoc, VariantId,
};

use salsa::plumbing::AsId;
Expand Down Expand Up @@ -337,7 +337,7 @@ fn crate_supports_no_std(db: &dyn DefDatabase, crate_id: Crate) -> bool {
for output in segments.skip(1) {
match output.flat_tokens() {
[tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.sym == sym::no_std => {
return true
return true;
}
_ => {}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-def/src/dyn_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
pub mod keys {
use std::marker::PhantomData;

use hir_expand::{attrs::AttrId, MacroCallId};
use hir_expand::{MacroCallId, attrs::AttrId};
use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, AstPtr};
use syntax::{AstNode, AstPtr, ast};

use crate::{
dyn_map::{DynMap, Policy},
BlockId, ConstId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId, FieldId, FunctionId,
ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId,
TraitAliasId, TraitId, TypeAliasId, TypeOrConstParamId, UnionId, UseId,
dyn_map::{DynMap, Policy},
};

pub type Key<K, V> = crate::dyn_map::Key<AstPtr<K>, V, AstPtrPolicy<K, V>>;
Expand Down
Loading