Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/mun_codegen/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ impl MockDatabase {
let mut source_root = SourceRoot::default();
let source_root_id = SourceRootId(0);

let text = Arc::new(text.to_owned());
let text = Arc::from(text.to_owned());
let rel_path = RelativePathBuf::from("main.mun");
let file_id = FileId(0);
db.set_file_relative_path(file_id, rel_path.clone());
db.set_file_text(file_id, Arc::new(text.to_string()));
db.set_file_text(file_id, text);
db.set_file_source_root(file_id, source_root_id);
source_root.insert_file(file_id);

Expand Down
2 changes: 1 addition & 1 deletion crates/mun_compiler/src/diagnostics_snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn emit_diagnostic(
/// Will hold all snippets and their relevant information
struct AnnotationFile {
relative_file_path: RelativePathBuf,
source_code: Arc<String>,
source_code: Arc<str>,
line_index: Arc<LineIndex>,
annotations: Vec<mun_diagnostics::SourceAnnotation>,
};
Expand Down
12 changes: 6 additions & 6 deletions crates/mun_compiler/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Driver {
let file_id = FileId(driver.next_file_id as u32);
driver.next_file_id += 1;
driver.db.set_file_relative_path(file_id, rel_path);
driver.db.set_file_text(file_id, Arc::new(text));
driver.db.set_file_text(file_id, Arc::from(text));
driver.db.set_file_source_root(file_id, WORKSPACE);
driver.source_root.insert_file(file_id);
driver
Expand Down Expand Up @@ -138,7 +138,7 @@ impl Driver {
driver
.db
.set_file_relative_path(file_id, relative_path.clone());
driver.db.set_file_text(file_id, Arc::new(file_contents));
driver.db.set_file_text(file_id, Arc::from(file_contents));
driver.db.set_file_source_root(file_id, WORKSPACE);
driver.source_root.insert_file(file_id);
}
Expand Down Expand Up @@ -191,7 +191,7 @@ impl Driver {
/// Sets the contents of a specific file.
pub fn set_file_text<T: AsRef<str>>(&mut self, file_id: FileId, text: T) {
self.db
.set_file_text(file_id, Arc::new(text.as_ref().to_owned()));
.set_file_text(file_id, Arc::from(text.as_ref().to_owned()));
}
}

Expand All @@ -215,7 +215,7 @@ impl Driver {
emit_syntax_error(
syntax_error,
relative_file_path.as_str(),
source_code.as_str(),
&source_code,
&line_index,
emit_colors,
writer,
Expand Down Expand Up @@ -326,7 +326,7 @@ impl Driver {
.path_to_file_id
.get(path.as_ref())
.expect("writing to a file that is not part of the source root should never happen");
self.db.set_file_text(file_id, Arc::new(contents));
self.db.set_file_text(file_id, Arc::from(contents));
file_id
}

Expand All @@ -337,7 +337,7 @@ impl Driver {
// Insert the new file
self.db
.set_file_relative_path(file_id, path.as_ref().to_relative_path_buf());
self.db.set_file_text(file_id, Arc::new(contents));
self.db.set_file_text(file_id, Arc::from(contents));
self.db.set_file_source_root(file_id, WORKSPACE);

// Update the source root
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_hir/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait Upcast<T: ?Sized> {
pub trait SourceDatabase: salsa::Database {
/// Text of the file.
#[salsa::input]
fn file_text(&self, file_id: FileId) -> Arc<String>;
fn file_text(&self, file_id: FileId) -> Arc<str>;

/// Path to a file, relative to the root of its source root.
#[salsa::input]
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_hir/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn with_files(db: &mut dyn SourceDatabase, fixture: &str) -> Vec<FileId> {
for (idx, entry) in fixture.into_iter().enumerate() {
let file_id = FileId(idx.try_into().expect("too many files"));
db.set_file_relative_path(file_id, entry.relative_path);
db.set_file_text(file_id, Arc::new(entry.text));
db.set_file_text(file_id, Arc::from(entry.text));
db.set_file_source_root(file_id, source_root_id);
source_root.insert_file(file_id);
files.push(file_id);
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_hir/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn check_package_defs_does_not_change() {
}
db.set_file_text(
file_id,
Arc::new(
Arc::from(
r#"
fn foo()->i32 {
90
Expand Down
10 changes: 5 additions & 5 deletions crates/mun_language_server/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Arc;
pub struct AnalysisChange {
new_roots: Vec<(hir::SourceRootId, hir::PackageId)>,
roots_changed: HashMap<hir::SourceRootId, RootChange>,
files_changed: Vec<(hir::FileId, Arc<String>)>,
files_changed: Vec<(hir::FileId, Arc<str>)>,
}

impl fmt::Debug for AnalysisChange {
Expand Down Expand Up @@ -45,7 +45,7 @@ impl AnalysisChange {
root_id: hir::SourceRootId,
file_id: hir::FileId,
path: hir::RelativePathBuf,
text: Arc<String>,
text: Arc<str>,
) {
let file = AddFile {
file_id,
Expand All @@ -60,7 +60,7 @@ impl AnalysisChange {
}

/// Records the change of content of a specific file
pub fn change_file(&mut self, file_id: hir::FileId, new_text: Arc<String>) {
pub fn change_file(&mut self, file_id: hir::FileId, new_text: Arc<str>) {
self.files_changed.push((file_id, new_text))
}

Expand All @@ -85,7 +85,7 @@ impl AnalysisChange {
struct AddFile {
file_id: hir::FileId,
path: hir::RelativePathBuf,
text: Arc<String>,
text: Arc<str>,
}

/// Represents the removal of a file from a source root.
Expand Down Expand Up @@ -130,7 +130,7 @@ impl AnalysisDatabase {
source_root.insert_file(add_file.file_id)
}
for remove_file in root_change.removed {
self.set_file_text(remove_file.file_id, Default::default());
self.set_file_text(remove_file.file_id, Arc::from(""));
source_root.remove_file(remove_file.file_id);
}
self.set_source_root(root_id, Arc::new(source_root));
Expand Down
6 changes: 3 additions & 3 deletions crates/mun_language_server/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl LanguageServerState {
hir::SourceRootId(root.0),
hir::FileId(file.0),
path,
text,
Arc::from(text.to_string()),
);
}
}
Expand All @@ -561,7 +561,7 @@ impl LanguageServerState {
hir::SourceRootId(root.0),
hir::FileId(file.0),
path,
text,
Arc::from(text.to_string()),
);
}
VfsChange::RemoveFile { root, file, path } => analysis_change.remove_file(
Expand All @@ -570,7 +570,7 @@ impl LanguageServerState {
path,
),
VfsChange::ChangeFile { file, text } => {
analysis_change.change_file(hir::FileId(file.0), text);
analysis_change.change_file(hir::FileId(file.0), Arc::from(text.to_string()));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/mun_syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use rowan::GreenNode;
#[derive(Debug, PartialEq, Eq)]
pub struct Parse<T> {
green: GreenNode,
errors: Arc<Vec<SyntaxError>>,
errors: Arc<[SyntaxError]>,
_ty: PhantomData<fn() -> T>,
}

Expand All @@ -59,7 +59,7 @@ impl<T> Parse<T> {
fn new(green: GreenNode, errors: Vec<SyntaxError>) -> Parse<T> {
Parse {
green,
errors: Arc::new(errors),
errors: Arc::from(errors),
_ty: PhantomData,
}
}
Expand All @@ -86,7 +86,7 @@ impl<T: AstNode> Parse<T> {
&*self.errors
}

pub fn ok(self) -> Result<T, Arc<Vec<SyntaxError>>> {
pub fn ok(self) -> Result<T, Arc<[SyntaxError]>> {
if self.errors.is_empty() {
Ok(self.tree())
} else {
Expand Down Expand Up @@ -128,7 +128,7 @@ impl SourceFile {
//errors.extend(validation::validate(&SourceFile::new(green.clone())));
Parse {
green,
errors: Arc::new(errors),
errors: Arc::from(errors),
_ty: PhantomData,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_test/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Fixture {
result.push(meta);
} else if let Some(entry) = result.last_mut() {
entry.text.push_str(line);
entry.text.push_str("\n");
entry.text.push('\n');
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.47.0
1.48.0