Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0380869

Browse files
committed
Auto merge of rust-lang#16145 - Veykril:span-crate, r=Veykril
internal: Split out a span crate Allows getting rid of some of the dependency injection generics that my rewrite introduced
2 parents cfc959d + ec61623 commit 0380869

Some content is hidden

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

51 files changed

+588
-514
lines changed

Cargo.lock

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
7171
profile = { path = "./crates/profile", version = "0.0.0" }
7272
project-model = { path = "./crates/project-model", version = "0.0.0" }
7373
sourcegen = { path = "./crates/sourcegen", version = "0.0.0" }
74+
span = { path = "./crates/span", version = "0.0.0" }
7475
stdx = { path = "./crates/stdx", version = "0.0.0" }
7576
syntax = { path = "./crates/syntax", version = "0.0.0" }
7677
test-utils = { path = "./crates/test-utils", version = "0.0.0" }

crates/base-db/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ profile.workspace = true
2323
stdx.workspace = true
2424
syntax.workspace = true
2525
test-utils.workspace = true
26-
tt.workspace = true
2726
vfs.workspace = true
27+
span.workspace = true

crates/base-db/src/lib.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
mod input;
66
mod change;
7-
pub mod span;
87

98
use std::panic;
109

1110
use rustc_hash::FxHashSet;
12-
use syntax::{ast, Parse, SourceFile, TextRange, TextSize};
11+
use syntax::{ast, Parse, SourceFile};
1312
use triomphe::Arc;
1413

1514
pub use crate::{
@@ -21,6 +20,7 @@ pub use crate::{
2120
},
2221
};
2322
pub use salsa::{self, Cancelled};
23+
pub use span::{FilePosition, FileRange};
2424
pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, FileId, VfsPath};
2525

2626
#[macro_export]
@@ -41,18 +41,6 @@ pub trait Upcast<T: ?Sized> {
4141
fn upcast(&self) -> &T;
4242
}
4343

44-
#[derive(Clone, Copy, Debug)]
45-
pub struct FilePosition {
46-
pub file_id: FileId,
47-
pub offset: TextSize,
48-
}
49-
50-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
51-
pub struct FileRange {
52-
pub file_id: FileId,
53-
pub range: TextRange,
54-
}
55-
5644
pub const DEFAULT_PARSE_LRU_CAP: usize = 128;
5745

5846
pub trait FileLoader {

crates/hir-def/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ mbe.workspace = true
4242
cfg.workspace = true
4343
tt.workspace = true
4444
limit.workspace = true
45+
span.workspace = true
4546

4647

4748
[dev-dependencies]

crates/hir-def/src/attr/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! Currently, it tests `#[doc(hidden)]` and `#[doc(alias)]`.
33
44
use base_db::FileId;
5-
use hir_expand::span::{RealSpanMap, SpanMapRef};
5+
use hir_expand::span_map::{RealSpanMap, SpanMapRef};
66
use mbe::syntax_node_to_token_tree;
77
use syntax::{ast, AstNode};
88

crates/hir-def/src/expander.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use base_db::CrateId;
44
use cfg::CfgOptions;
55
use drop_bomb::DropBomb;
66
use hir_expand::{
7-
attrs::RawAttrs, mod_path::ModPath, span::SpanMap, ExpandError, ExpandResult, HirFileId,
7+
attrs::RawAttrs, mod_path::ModPath, span_map::SpanMap, ExpandError, ExpandResult, HirFileId,
88
InFile, MacroCallId,
99
};
1010
use limit::Limit;

crates/hir-def/src/item_tree.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use std::{
4242
};
4343

4444
use ast::{AstNode, HasName, StructKind};
45-
use base_db::{span::SyntaxContextId, CrateId};
45+
use base_db::CrateId;
4646
use either::Either;
4747
use hir_expand::{
4848
ast_id_map::{AstIdNode, FileAstId},
@@ -55,6 +55,7 @@ use la_arena::{Arena, Idx, IdxRange, RawIdx};
5555
use profile::Count;
5656
use rustc_hash::FxHashMap;
5757
use smallvec::SmallVec;
58+
use span::SyntaxContextId;
5859
use stdx::never;
5960
use syntax::{ast, match_ast, SyntaxKind};
6061
use triomphe::Arc;

crates/hir-def/src/item_tree/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::collections::hash_map::Entry;
44

5-
use hir_expand::{ast_id_map::AstIdMap, span::SpanMapRef, HirFileId};
5+
use hir_expand::{ast_id_map::AstIdMap, span_map::SpanMapRef, HirFileId};
66
use syntax::ast::{self, HasModuleItem, HasTypeBounds};
77

88
use crate::{

crates/hir-def/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use std::{
6363
panic::{RefUnwindSafe, UnwindSafe},
6464
};
6565

66-
use base_db::{impl_intern_key, salsa, span::SyntaxContextId, CrateId};
66+
use base_db::{impl_intern_key, salsa, CrateId};
6767
use hir_expand::{
6868
ast_id_map::{AstIdNode, FileAstId},
6969
attrs::{Attr, AttrId, AttrInput},
@@ -80,6 +80,7 @@ use hir_expand::{
8080
use item_tree::ExternBlock;
8181
use la_arena::Idx;
8282
use nameres::DefMap;
83+
use span::SyntaxContextId;
8384
use stdx::impl_from;
8485
use syntax::{ast, AstNode};
8586

0 commit comments

Comments
 (0)