Skip to content

Commit abdcbb6

Browse files
committed
Bump rust version to 2024
1 parent e07d8b3 commit abdcbb6

14 files changed

Lines changed: 130 additions & 132 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "typst-package-check"
33
version = "0.4.5"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
casbab = "0.1.1"

src/action.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::{
22
check::TryExt,
33
github::{
4-
api::{pr::PullRequestEvent, GitHubAuth, Installation, Repository},
5-
run_github_check, AppState,
4+
AppState,
5+
api::{GitHubAuth, Installation, Repository, pr::PullRequestEvent},
6+
run_github_check,
67
},
78
};
89

src/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::path::PathBuf;
22

33
use codespan_reporting::diagnostic::Label;
44
use typst::{
5-
syntax::{package::PackageSpec, FileId, Span},
65
WorldExt,
6+
syntax::{FileId, Span, package::PackageSpec},
77
};
88

99
use crate::world::SystemWorld;

src/check/authors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use codespan_reporting::diagnostic::{Diagnostic, Label};
2-
use typst::syntax::{package::PackageSpec, FileId, VirtualPath};
2+
use typst::syntax::{FileId, VirtualPath, package::PackageSpec};
33

44
use crate::{github::git, package::PackageExt};
55

src/check/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use typst::{
77

88
use crate::world::SystemWorld;
99

10-
use super::{label, Diagnostics};
10+
use super::{Diagnostics, label};
1111

1212
pub fn check(diags: &mut Diagnostics, world: &SystemWorld) -> Option<PagedDocument> {
1313
let result = typst::compile(world);

src/check/files.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::path::Path;
44
use codespan_reporting::diagnostic::{Diagnostic, Label};
55
use walkdir::WalkDir;
66

7+
use crate::check::Diagnostics;
78
use crate::check::manifest::Manifest;
89
use crate::check::path::PackagePath;
910
use crate::check::readme::Readme;
10-
use crate::check::Diagnostics;
1111

1212
pub fn check(
1313
diags: &mut Diagnostics,
@@ -218,13 +218,15 @@ fn link_manuals(
218218
let note = (!excluded)
219219
.then(|| "It should also be added to `exclude` in your `typst.toml`.".into());
220220

221-
diags.emit(Diagnostic::warning()
222-
.with_label(Label::primary(path.file_id(), 0..0))
223-
.with_code("files/manual/unlinked")
224-
.with_message(
225-
"This file seems to be a manual/documentation, but isn't linked in the readme. \
221+
diags.emit(
222+
Diagnostic::warning()
223+
.with_label(Label::primary(path.file_id(), 0..0))
224+
.with_code("files/manual/unlinked")
225+
.with_message(
226+
"This file seems to be a manual/documentation, but isn't linked in the readme. \
226227
It will be inacessible on Typst Universe.",
227-
)
228-
.with_notes_iter(note));
228+
)
229+
.with_notes_iter(note),
230+
);
229231
}
230232
}

src/check/imports.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ use std::{
55

66
use codespan_reporting::diagnostic::Diagnostic;
77
use typst::{
8+
World,
89
syntax::{
910
ast::{self, AstNode, ModuleImport},
1011
package::{PackageSpec, PackageVersion, VersionlessPackageSpec},
1112
},
12-
World,
1313
};
1414
use walkdir::WalkDir;
1515

1616
use crate::check::path::PackagePath;
17-
use crate::check::{label, Diagnostics, Result, TryExt};
17+
use crate::check::{Diagnostics, Result, TryExt, label};
1818
use crate::world::SystemWorld;
1919

2020
pub fn check(diags: &mut Diagnostics, package_dir: &Path, world: &SystemWorld) -> Result<()> {
@@ -85,23 +85,18 @@ pub fn check_ast(
8585
)
8686
}
8787

88-
if let Some(all_packages) = all_packages {
89-
if let Ok(import_spec) = PackageSpec::from_str(source_str.get().as_str()) {
90-
if let Some(latest_version) =
91-
latest_package_version(all_packages, import_spec.versionless())
92-
{
93-
if latest_version != import_spec.version {
94-
diags.emit(
95-
Diagnostic::warning()
96-
.with_labels(label(world, import.span()).into_iter().collect())
97-
.with_code("import/outdated")
98-
.with_message(
99-
"This import seems to use an older version of the package.",
100-
),
101-
)
102-
}
103-
}
104-
}
88+
if let Some(all_packages) = all_packages
89+
&& let Ok(import_spec) = PackageSpec::from_str(source_str.get().as_str())
90+
&& let Some(latest_version) =
91+
latest_package_version(all_packages, import_spec.versionless())
92+
&& latest_version != import_spec.version
93+
{
94+
diags.emit(
95+
Diagnostic::warning()
96+
.with_labels(label(world, import.span()).into_iter().collect())
97+
.with_code("import/outdated")
98+
.with_message("This import seems to use an older version of the package."),
99+
)
105100
}
106101
}
107102
}

src/check/kebab_case.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use std::collections::HashSet;
33
use codespan_reporting::diagnostic::{Diagnostic, Severity};
44
use comemo::Track;
55
use typst::{
6+
ROUTINES, World,
67
engine::{Route, Sink, Traced},
78
syntax::{
8-
ast::{self, AstNode},
99
FileId, Source, SyntaxNode,
10+
ast::{self, AstNode},
1011
},
11-
World, ROUTINES,
1212
};
1313

1414
use crate::world::SystemWorld;
1515

16-
use super::{label, Diagnostics};
16+
use super::{Diagnostics, label};
1717

1818
// Check that all public identifiers are in kebab-case
1919
pub fn check(diags: &mut Diagnostics, world: &SystemWorld) -> Option<()> {

src/check/manifest.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use reqwest::StatusCode;
77
use toml_edit::{Array, Item, Table};
88
use tracing::{debug, warn};
99
use typst::syntax::{
10-
package::{PackageSpec, PackageVersion},
1110
FileId, VirtualPath,
11+
package::{PackageSpec, PackageVersion},
1212
};
1313
use walkdir::WalkDir;
1414

@@ -178,20 +178,20 @@ fn check_name(
178178
);
179179
}
180180

181-
if let Some(package_spec) = package_spec {
182-
if name.val != package_spec.name {
183-
diags.emit(
184-
error
185-
.with_code("manifest/package/name/mismatch")
186-
.with_message(format!(
187-
"Unexpected package name. `{name}` was expected. \
181+
if let Some(package_spec) = package_spec
182+
&& name.val != package_spec.name
183+
{
184+
diags.emit(
185+
error
186+
.with_code("manifest/package/name/mismatch")
187+
.with_message(format!(
188+
"Unexpected package name. `{name}` was expected. \
188189
If you want to publish a new package, create a new \
189190
directory in `packages/{namespace}/`.",
190-
name = package_spec.name,
191-
namespace = package_spec.namespace,
192-
)),
193-
)
194-
}
191+
name = package_spec.name,
192+
namespace = package_spec.namespace,
193+
)),
194+
)
195195
}
196196

197197
Some(name.to_owned())
@@ -239,21 +239,21 @@ fn check_version(
239239
return None;
240240
};
241241

242-
if let Some(package_spec) = package_spec {
243-
if version.val != package_spec.version {
244-
diags.emit(
245-
error
246-
.with_code("manifest/package/version/mismatch")
247-
.with_message(format!(
248-
"Unexpected version number. `{version}` was expected. \
242+
if let Some(package_spec) = package_spec
243+
&& version.val != package_spec.version
244+
{
245+
diags.emit(
246+
error
247+
.with_code("manifest/package/version/mismatch")
248+
.with_message(format!(
249+
"Unexpected version number. `{version}` was expected. \
249250
If you want to publish a new version, create a new \
250251
directory in `packages/{namespace}/{name}`.",
251-
version = package_spec.version,
252-
name = package_spec.name,
253-
namespace = package_spec.namespace,
254-
)),
255-
)
256-
}
252+
version = package_spec.version,
253+
name = package_spec.name,
254+
namespace = package_spec.namespace,
255+
)),
256+
)
257257
}
258258

259259
Some(version)
@@ -684,20 +684,20 @@ fn check_thumbnail(diags: &mut Diagnostics, exclude: &Override, template: &Spann
684684
);
685685
}
686686

687-
if let Some(template_path) = &template.path {
688-
if thumbnail_path.full().starts_with(template_path.full()) {
689-
diags.emit(
690-
Diagnostic::error()
691-
.with_label(Label::primary(manifest_id(), thumbnail_path.span()))
692-
.with_code("manifest/template/thumbnail/location")
693-
.with_message(
694-
"The thumbnail file should be outside of the template directory.\n\n\
687+
if let Some(template_path) = &template.path
688+
&& thumbnail_path.full().starts_with(template_path.full())
689+
{
690+
diags.emit(
691+
Diagnostic::error()
692+
.with_label(Label::primary(manifest_id(), thumbnail_path.span()))
693+
.with_code("manifest/template/thumbnail/location")
694+
.with_message(
695+
"The thumbnail file should be outside of the template directory.\n\n\
695696
When your template will be used as a base for users's projects, \
696697
the template directory will be copied as is, and the thumbnail file
697698
is generally not displayed in documents based on your template.",
698-
),
699-
);
700-
}
699+
),
700+
);
701701
}
702702
}
703703

src/check/readme.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use comrak::nodes::{LineColumn, NodeList, NodeValue as MdNode, Sourcepos};
77
use html5ever::tendril::TendrilSink;
88
use regex::Regex;
99
use typst::{
10+
World,
1011
foundations::Bytes,
1112
syntax::{FileId, VirtualPath},
12-
World,
1313
};
1414
use url::Url;
1515

1616
use crate::check::path::PackagePath;
1717
use crate::{
18-
check::{imports, kebab_case, label, Diagnostics, TryExt},
18+
check::{Diagnostics, TryExt, imports, kebab_case, label},
1919
world::SystemWorld,
2020
};
2121

0 commit comments

Comments
 (0)