From b81ba15bab23622f2c991f16223df57e4d17e3cf Mon Sep 17 00:00:00 2001 From: Jonas Wanke Date: Sat, 14 Dec 2024 17:53:57 +0100 Subject: [PATCH 1/5] Update Nix flake --- flake.lock | 52 +++++++++------------------------------------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/flake.lock b/flake.lock index a0064b550..75a2f0aa9 100644 --- a/flake.lock +++ b/flake.lock @@ -5,29 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -38,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1710272261, - "narHash": "sha256-g0bDwXFmTE7uGDOs9HcJsfLFhH7fOsASbAuOzDC+fhQ=", + "lastModified": 1733940404, + "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0ad13a6833440b8e238947e47bea7f11071dc2b2", + "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", "type": "github" }, "original": { @@ -61,17 +43,16 @@ }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils_2", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1710382258, - "narHash": "sha256-2FW1q+o34VBweYQiEkRaSEkNMq3ecrn83VzETeGiVbY=", + "lastModified": 1734143514, + "narHash": "sha256-1+r8wYucn8kp9d/IBW1uYGs31QQmSZURElsiOTx65xM=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "8ce81e71ab04a7e906fae62da086d6ee5d6cfc21", + "rev": "81fe5c27cb281a9b796d7ad05ad9179e5bd0c78d", "type": "github" }, "original": { @@ -94,21 +75,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", From 1dd897cefc31b50e2317f5a3ef21035b41c49512 Mon Sep 17 00:00:00 2001 From: Jonas Wanke Date: Sat, 14 Dec 2024 18:36:49 +0100 Subject: [PATCH 2/5] Update Rust --- compiler_v4/src/main.rs | 2 -- rust-toolchain.toml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler_v4/src/main.rs b/compiler_v4/src/main.rs index 90d90ac37..256285f27 100644 --- a/compiler_v4/src/main.rs +++ b/compiler_v4/src/main.rs @@ -2,9 +2,7 @@ anonymous_lifetime_in_impl_trait, box_patterns, if_let_guard, - iter_repeat_n, let_chains, - option_take_if, try_blocks )] #![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9fd746d58..588a32421 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-02-22" +channel = "nightly-2024-11-26" profile = "minimal" components = ["clippy", "rust-src", "rustfmt"] From 06e7b790421759d62572239b6cbe5bd3891818d9 Mon Sep 17 00:00:00 2001 From: Jonas Wanke Date: Sat, 14 Dec 2024 21:27:37 +0100 Subject: [PATCH 3/5] Show diagnostics in VS Code Co-Authored-By: Marcel Garus --- Cargo.lock | 39 ++-- compiler_v4/Cargo.toml | 2 + compiler_v4/src/main.rs | 62 +++++++ compiler_v4/src/position.rs | 3 +- vscode_extension_v4/package-lock.json | 13 ++ vscode_extension_v4/package.json | 16 +- .../src/@types/linebyline/index.d.ts | 18 ++ vscode_extension_v4/src/extension.ts | 171 +++++++++++++++++- vscode_extension_v4/tsconfig.json | 4 +- 9 files changed, 304 insertions(+), 24 deletions(-) create mode 100644 vscode_extension_v4/src/@types/linebyline/index.d.ts diff --git a/Cargo.lock b/Cargo.lock index b777ab2e5..2c5fde94b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,7 +86,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.48", + "syn 2.0.90", "which", ] @@ -177,6 +177,8 @@ dependencies = [ "petgraph", "replace_with", "rustc-hash 2.0.0", + "serde", + "serde_json", "strum", "tracing", "tracing-subscriber", @@ -573,7 +575,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -831,7 +833,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -926,7 +928,7 @@ checksum = "b185e7d068d6820411502efa14d8fbf010750485399402156b72dd2a548ef8e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -1347,7 +1349,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -1376,9 +1378,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -1604,31 +1606,32 @@ checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1743,7 +1746,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] @@ -1759,9 +1762,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -1935,7 +1938,7 @@ checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.90", ] [[package]] diff --git a/compiler_v4/Cargo.toml b/compiler_v4/Cargo.toml index eac7daea7..446b12f9c 100644 --- a/compiler_v4/Cargo.toml +++ b/compiler_v4/Cargo.toml @@ -18,6 +18,8 @@ itertools = "0.12.0" petgraph = "0.6.5" replace_with = "0.1.7" rustc-hash = "2.0.0" +serde = { version = "1.0.216", features = ["derive"] } +serde_json = "1.0.133" strum = { version = "0.26.1", features = ["derive"] } tracing = { version = "0.1", features = ["release_max_level_debug"] } tracing-subscriber = { version = "0.3.16", features = ["registry"] } diff --git a/compiler_v4/src/main.rs b/compiler_v4/src/main.rs index 256285f27..7bf4d7a77 100644 --- a/compiler_v4/src/main.rs +++ b/compiler_v4/src/main.rs @@ -25,7 +25,10 @@ use clap::{arg, Parser, Subcommand, ValueHint}; use error::CompilerError; use hir::Hir; use hir_to_mono::hir_to_mono; +use itertools::Itertools; use mono_to_c::mono_to_c; +use position::{Position, RangeOfOffset}; +use serde::Serialize; use std::{ fs, path::{Path, PathBuf}, @@ -59,6 +62,7 @@ enum CandyOptions { Debug(DebugOptions), Check(CheckOptions), Compile(CompileOptions), + ToolingAnalyze(ToolingAnalyzeOptions), } fn main() -> ProgramResult { @@ -70,6 +74,7 @@ fn main() -> ProgramResult { CandyOptions::Debug(options) => debug(options), CandyOptions::Check(options) => check(options), CandyOptions::Compile(options) => compile(options), + CandyOptions::ToolingAnalyze(options) => tooling_analyze(options), } } pub type ProgramResult = Result<(), Exit>; @@ -209,6 +214,63 @@ fn compile(options: CompileOptions) -> ProgramResult { Ok(()) } +#[derive(Parser, Debug)] +struct ToolingAnalyzeOptions { + /// The file to analyze. + #[arg(value_hint = ValueHint::FilePath)] + path: PathBuf, +} +#[allow(clippy::needless_pass_by_value)] +fn tooling_analyze(options: ToolingAnalyzeOptions) -> ProgramResult { + let path_str = options.path.to_string_lossy(); + let path = path_str.strip_prefix("file:/").unwrap(); + let source = fs::read_to_string(Path::new(path)) + .unwrap_or_else(|err| panic!("Couldn't open file `{path}`: {err:?}")); + + let (_, errors) = compile_hir(&options.path, &source); + + // TODO: request file content from VS Code extension + + let diagnostics = errors + .into_iter() + .map(|error| { + let span = error.span.to_positions(&source); + Diagnostic { + message: error.message.into_boxed_str(), + source: DiagnosticSource { + file: error.path.to_string_lossy().into_owned().into_boxed_str(), + start: span.start, + end: span.end, + }, + } + }) + .collect_vec(); + println!( + "{}", + serde_json::to_string(&Message::Diagnostics { diagnostics }).unwrap(), + ); + + Ok(()) +} + +#[derive(Serialize)] +#[serde(tag = "type", rename_all = "snake_case")] +enum Message { + ReadFile { path: String }, + Diagnostics { diagnostics: Vec }, +} +#[derive(Serialize)] +struct Diagnostic { + pub message: Box, + pub source: DiagnosticSource, +} +#[derive(Serialize)] +struct DiagnosticSource { + pub file: Box, + pub start: Position, + pub end: Position, +} + fn compile_hir(path: &Path, source: &str) -> (Hir, Vec) { let asts = string_to_ast::string_to_ast(path, source); let mut errors = asts.collect_errors(); diff --git a/compiler_v4/src/position.rs b/compiler_v4/src/position.rs index b6818463a..7077bb906 100644 --- a/compiler_v4/src/position.rs +++ b/compiler_v4/src/position.rs @@ -1,5 +1,6 @@ use derive_more::{Deref, DerefMut, From}; use extension_trait::extension_trait; +use serde::Serialize; use std::{ fmt::{self, Display, Formatter}, ops::Range, @@ -41,7 +42,7 @@ pub impl RangeOfOffset for Range { } } -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub struct Position { /// Zero-based line index (`\n`-separated) pub line: usize, diff --git a/vscode_extension_v4/package-lock.json b/vscode_extension_v4/package-lock.json index fe06ffbef..808c74e3b 100644 --- a/vscode_extension_v4/package-lock.json +++ b/vscode_extension_v4/package-lock.json @@ -7,6 +7,9 @@ "": { "name": "candy", "version": "0.4.0", + "dependencies": { + "linebyline": "^1.3.0" + }, "devDependencies": { "@types/node": "^20.11.20", "@types/vscode": "^1.86.0", @@ -1145,6 +1148,11 @@ "node": ">= 0.8.0" } }, + "node_modules/linebyline": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/linebyline/-/linebyline-1.3.0.tgz", + "integrity": "sha512-3fpIYMrSU77OCf89hjXKuCx6vGwgWEu4N5DDCGqgZ1BF0HYy9V8IbQb/3+VWIU17iBQ83qQoUokH0AhPMOTi7w==" + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -2498,6 +2506,11 @@ "type-check": "~0.4.0" } }, + "linebyline": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/linebyline/-/linebyline-1.3.0.tgz", + "integrity": "sha512-3fpIYMrSU77OCf89hjXKuCx6vGwgWEu4N5DDCGqgZ1BF0HYy9V8IbQb/3+VWIU17iBQ83qQoUokH0AhPMOTi7w==" + }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", diff --git a/vscode_extension_v4/package.json b/vscode_extension_v4/package.json index c12afd640..e56780da8 100644 --- a/vscode_extension_v4/package.json +++ b/vscode_extension_v4/package.json @@ -9,7 +9,6 @@ "url": "https://github.com/candy-lang/candy.git", "directory": "vscode_extension_v4" }, - "//": "Keep in sync with `devDependencies.@types/vscode`", "//": "https://github.com/ewanharris/vscode-versions", "engines": { "node": "^18.17.1", @@ -23,6 +22,17 @@ ], "main": "./out/extension.js", "contributes": { + "configuration": { + "title": "🍭 Candy", + "properties": { + "candy.compilerExecutablePath": { + "type": "string", + "default": "", + "markdownDescription": "Path to the 🍭 Candy compiler executable. If empty, we'll attempt to find the 🍭 Candy executable in the `PATH` environment variable.", + "scope": "machine-overridable" + } + } + }, "configurationDefaults": { "[candy]": { "editor.detectIndentation": false, @@ -58,7 +68,9 @@ "lint": "eslint --ext ts .", "watch": "tsc -watch -p ./" }, - "dependencies": {}, + "dependencies": { + "linebyline": "^1.3.0" + }, "devDependencies": { "@types/node": "^20.11.20", "@types/vscode": "^1.86.0", diff --git a/vscode_extension_v4/src/@types/linebyline/index.d.ts b/vscode_extension_v4/src/@types/linebyline/index.d.ts new file mode 100644 index 000000000..88700c055 --- /dev/null +++ b/vscode_extension_v4/src/@types/linebyline/index.d.ts @@ -0,0 +1,18 @@ +declare module "linebyline" { + import { Stream } from "stream"; + + function readLine( + readingObject: string | Stream, + options?: { maxLineLength?: number; retainBuffer?: boolean }, + ): EventEmitter; + export = readLine; + + interface EventEmitter { + on( + event: "line", + listener: (line: string, lineCount: number, byteCount: number) => void, + ): EventEmitter; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + on(event: "error", listener: (error: any) => void): EventEmitter; + } +} diff --git a/vscode_extension_v4/src/extension.ts b/vscode_extension_v4/src/extension.ts index 1067d87fd..8052aed1d 100644 --- a/vscode_extension_v4/src/extension.ts +++ b/vscode_extension_v4/src/extension.ts @@ -1,6 +1,173 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +import * as child_process from "child_process"; +import linebyline from "linebyline"; import * as vscode from "vscode"; +let diagnosticCollection: vscode.DiagnosticCollection; + // eslint-disable-next-line @typescript-eslint/no-unused-vars -export function activate(_context: vscode.ExtensionContext) { - console.log("Activated 🍭 Candy extension!"); +export function activate(context: vscode.ExtensionContext) { + console.info("Activated the 🍭 Candy extension!"); + + diagnosticCollection = vscode.languages.createDiagnosticCollection("candy"); + context.subscriptions.push(diagnosticCollection); + + vscode.window.onDidChangeVisibleTextEditors(() => onlyRunOneAtATime(update)); + vscode.workspace.onDidChangeTextDocument(() => onlyRunOneAtATime(update)); +} + +// Updates can be triggered very frequently (on every keystroke), but they can +// take long – for example, when editing the Candy compiler itself, simply +// analyzing the files takes some time. Thus, here we make sure that only one +// update runs at a time. +let generation = 0; +let currentRun = Promise.resolve(null); +async function onlyRunOneAtATime(callback: () => Promise) { + console.log("Scheduling update"); + const myGeneration = ++generation; + await currentRun; + if (generation != myGeneration) return; // a newer update exists and will run + // eslint-disable-next-line @typescript-eslint/no-misused-promises, no-async-promise-executor + currentRun = new Promise(async (resolve) => { + await callback(); + resolve(null); + }); +} + +async function update() { + console.log("Updating"); + const promises = []; + for (const editor of vscode.window.visibleTextEditors) { + const uri = editor.document.uri.toString(); + if (!uri.endsWith(".candy")) continue; + + const analysis = analyze(uri); + promises.push(analysis); + analysis + .then((diagnostics) => { + diagnosticCollection.clear(); + const diagnosticMap = new Map(); + for (const diagnostic of diagnostics) { + console.info(`Error: ${JSON.stringify(diagnostic)}`); + if (diagnostic.source.file != uri) continue; + const range = new vscode.Range( + new vscode.Position( + diagnostic.source.start.line, + diagnostic.source.start.character, + ), + new vscode.Position( + diagnostic.source.end.line, + diagnostic.source.end.character, + ), + ); + const diagnostics = diagnosticMap.get(diagnostic.source.file) ?? []; + diagnostics.push( + new vscode.Diagnostic( + range, + diagnostic.message, + vscode.DiagnosticSeverity.Error, + ), + ); + diagnosticMap.set(diagnostic.source.file, diagnostics); + } + diagnosticMap.forEach((diags, file) => { + diagnosticCollection.set(vscode.Uri.parse(file), diags); + }); + }) + .catch((error) => { + console.error(`Analyzing failed: ${error}`); + }); + } + await Promise.all(promises); +} + +/// Communication with the Candy language server works using the following +/// schema. + +type AnalyzeMessage = ReadFileMessage | DiagnosticsMessage; // candy tooling-analyze ... +interface ReadFileMessage { + type: "read_file"; + path: string; +} +interface DiagnosticsMessage { + type: "diagnostics"; + diagnostics: Diagnostic[]; +} +interface Diagnostic { + message: string; + source: { + file: string; + start: { line: number; character: number }; + end: { line: number; character: number }; + }; +} + +async function analyze(path: string): Promise { + console.log(`Analyzing ${path}`); + const candy = child_process.spawn( + vscode.workspace + .getConfiguration("candy") + .get("compilerExecutablePath") ?? "candy", + ["tooling-analyze", path], + { env: { ...process.env, RUST_BACKTRACE: "1" } }, + ); + candy.on("error", (error) => { + console.error(`Failed to spawn: ${error.name}: ${error.message}`); + }); + linebyline(candy.stderr).on("line", (line: string) => { + console.log(line); + }); + + let diagnostics: Diagnostic[] = []; + // eslint-disable-next-line @typescript-eslint/no-misused-promises + linebyline(candy.stdout).on("line", async function (line: string) { + console.info("Line: " + line); + const message = JSON.parse(line) as AnalyzeMessage; + switch (message.type) { + case "read_file": + candy.stdin.write(await handleReadFileMessage(message)); + break; + case "diagnostics": + diagnostics = message.diagnostics; + break; + } + }); + + const exitCode: number | null = await new Promise((resolve) => + candy.on("close", (exitCode) => { + resolve(exitCode); + }), + ); + console.info(`\`candy tooling-analyze\` exited with exit code ${exitCode}.`); + + return diagnostics; +} + +async function handleReadFileMessage( + message: ReadFileMessage, +): Promise { + const uri = vscode.Uri.parse(message.path); + const content = await readFile(uri); + const response = content + ? { type: "read_file", success: true, content: content } + : { type: "read_file", success: false }; + return `${JSON.stringify(response)}\n`; +} + +/** + * Returns the source code of the given URI. Prefers the content of open text + * documents, even if they're not saved yet. If none exists, asks the file + * system. + */ +async function readFile(uri: vscode.Uri): Promise { + for (const doc of vscode.workspace.textDocuments) { + if (doc.uri.toString() == uri.toString()) return doc.getText(); + } + + try { + const bytes = await vscode.workspace.fs.readFile(uri); + return new TextDecoder("utf8").decode(bytes); + } catch (e) { + return null; + } } diff --git a/vscode_extension_v4/tsconfig.json b/vscode_extension_v4/tsconfig.json index 865bc376b..50bc10384 100644 --- a/vscode_extension_v4/tsconfig.json +++ b/vscode_extension_v4/tsconfig.json @@ -10,6 +10,8 @@ "noImplicitAny": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "noUnusedParameters": true + "noUnusedParameters": true, + "esModuleInterop": true, + "typeRoots": ["src/@types", "node_modules/@types"] } } From fd353460c4d3d922654741604e31778b5badd4da Mon Sep 17 00:00:00 2001 From: Jonas Wanke Date: Sat, 14 Dec 2024 21:45:31 +0100 Subject: [PATCH 4/5] Fix linter complaints --- Cargo.toml | 2 +- compiler_v4/src/ast.rs | 1 + compiler_v4/src/ast_to_hir.rs | 36 +++++++++---------- compiler_v4/src/hir.rs | 2 +- compiler_v4/src/hir_to_mono.rs | 6 ++-- compiler_v4/src/main.rs | 18 ++++++---- compiler_v4/src/mono.rs | 4 +-- compiler_v4/src/mono_to_c.rs | 18 +++++----- compiler_v4/src/string_to_ast/declarations.rs | 2 +- compiler_v4/src/string_to_ast/expression.rs | 4 +-- compiler_v4/src/string_to_ast/parser.rs | 11 +++--- compiler_v4/src/string_to_ast/type_.rs | 2 +- compiler_v4/src/type_solver/goals.rs | 2 +- 13 files changed, 56 insertions(+), 52 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0b61421a4..fff06d9d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ members = [ [workspace.package] edition = "2021" -rust-version = "1.78.0" +rust-version = "1.80.0" [profile.release] # This adds file and line number information to backtraces while only increasing diff --git a/compiler_v4/src/ast.rs b/compiler_v4/src/ast.rs index 72e805db8..4bdd468e4 100644 --- a/compiler_v4/src/ast.rs +++ b/compiler_v4/src/ast.rs @@ -175,6 +175,7 @@ pub struct AstTypeParameter { // Types +#[allow(clippy::large_enum_variant)] #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub enum AstType { Named(AstNamedType), diff --git a/compiler_v4/src/ast_to_hir.rs b/compiler_v4/src/ast_to_hir.rs index 12a897b5e..a69541b39 100644 --- a/compiler_v4/src/ast_to_hir.rs +++ b/compiler_v4/src/ast_to_hir.rs @@ -130,7 +130,7 @@ struct ImplDeclaration<'a> { trait_: Trait, functions: FxHashMap>, } -impl<'a> ImplDeclaration<'a> { +impl ImplDeclaration<'_> { #[must_use] fn into_impl(self) -> Impl { Impl { @@ -166,7 +166,7 @@ struct FunctionDeclaration<'a> { signature: Signature, body: Option, } -impl<'a> FunctionDeclaration<'a> { +impl FunctionDeclaration<'_> { fn signature_to_string(&self) -> String { format!("{}{}", self.name, self.signature) } @@ -1195,7 +1195,7 @@ impl<'a> Context<'a> { .collect_vec(), self_base_type, |builder| { - for parameter in function.signature.parameters.iter() { + for parameter in &function.signature.parameters { builder.push_parameter(parameter.clone()); } @@ -1229,7 +1229,7 @@ impl<'a> Context<'a> { .unwrap() } - fn get_all_functions_matching_name(&mut self, name: &str) -> Vec { + fn get_all_functions_matching_name(&self, name: &str) -> Vec { self.functions .iter() .chain(self.traits.iter().flat_map(|(_, trait_)| &trait_.functions)) @@ -1285,7 +1285,9 @@ impl<'c, 'a> BodyBuilder<'c, 'a> { self.type_parameters, self.self_base_type, |builder| { - builder.local_identifiers = self.local_identifiers.clone(); + builder + .local_identifiers + .clone_from(&self.local_identifiers); fun(builder); self.global_assignment_dependencies .extend(&builder.global_assignment_dependencies); @@ -1433,14 +1435,12 @@ impl<'c, 'a> BodyBuilder<'c, 'a> { type_: NamedType::text().into(), } } - AstExpressionKind::Parenthesized(parenthesized) => { - return parenthesized - .inner - .value() - .map_or(LoweredExpression::Error, |it| { - self.lower_expression_raw(it, context_type) - }); - } + AstExpressionKind::Parenthesized(parenthesized) => parenthesized + .inner + .value() + .map_or(LoweredExpression::Error, |it| { + self.lower_expression_raw(it, context_type) + }), AstExpressionKind::Call(call) => { let type_arguments = call.type_arguments.as_ref().map(|it| { it.arguments @@ -1527,7 +1527,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> { type_arguments.as_deref(), &type_, &type_declaration.type_parameters, - fields, + fields.as_deref(), ) } TypeDeclarationKind::Enum { .. } => { @@ -1670,7 +1670,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> { ); let body = self.build_inner(|builder| { - for parameter in parameters.iter() { + for parameter in ¶meters { builder.push_parameter(parameter.clone()); } @@ -1861,7 +1861,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> { } else if let Some(type_parameter) = self.type_parameters.iter().find(|it| it.name == *name) { LoweredExpression::TypeParameterReference(type_parameter.type_()) - } else if self.context.hir.type_declarations.get(name).is_some() { + } else if self.context.hir.type_declarations.contains_key(name) { LoweredExpression::NamedTypeReference(name.clone()) } else { self.context.add_error( @@ -2059,7 +2059,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> { type_arguments: Option<&[Type]>, type_: &str, type_parameters: &[TypeParameter], - fields: &Option>, + fields: Option<&[StructField]>, ) -> LoweredExpression { let Some(fields) = fields else { self.context.add_error( @@ -2213,7 +2213,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> { .collect::>() } fn match_signature( - &mut self, + &self, trait_goal_and_subgoals: Option<(&SolverGoal, &[SolverGoal])>, type_parameters: &[TypeParameter], parameter_types: &[Type], diff --git a/compiler_v4/src/hir.rs b/compiler_v4/src/hir.rs index 17cb40901..74bd2605a 100644 --- a/compiler_v4/src/hir.rs +++ b/compiler_v4/src/hir.rs @@ -117,7 +117,7 @@ impl ToText for Hir { (name.as_ref(), definition).build_text(builder); builder.push_newline(); } - for impl_ in self.impls.iter() { + for impl_ in &self.impls { impl_.build_text(builder); builder.push_newline(); } diff --git a/compiler_v4/src/hir_to_mono.rs b/compiler_v4/src/hir_to_mono.rs index c1a4469a5..38af06c44 100644 --- a/compiler_v4/src/hir_to_mono.rs +++ b/compiler_v4/src/hir_to_mono.rs @@ -358,7 +358,7 @@ impl<'h> Context<'h> { result.push_str(&type_.name); if !type_.type_arguments.is_empty() { result.push_str("$of$"); - for type_ in type_.type_arguments.iter() { + for type_ in &type_.type_arguments { Self::mangle_type_helper(result, type_); result.push('$'); } @@ -375,7 +375,7 @@ impl<'h> Context<'h> { result.push_str("$Fun$"); if !type_.parameter_types.is_empty() { result.push_str("of$"); - for type_ in type_.parameter_types.iter() { + for type_ in &type_.parameter_types { Self::mangle_type_helper(result, type_); result.push('$'); } @@ -427,7 +427,7 @@ impl<'c, 'h> BodyBuilder<'c, 'h> { id_generator: IdGenerator::default(), id_mapping: FxHashMap::default(), }; - builder.id_mapping = self.id_mapping.clone(); + builder.id_mapping.clone_from(&self.id_mapping); builder.id_generator = mem::take(&mut self.id_generator); fun(&mut builder); diff --git a/compiler_v4/src/main.rs b/compiler_v4/src/main.rs index 7bf4d7a77..875d8ca2e 100644 --- a/compiler_v4/src/main.rs +++ b/compiler_v4/src/main.rs @@ -74,7 +74,10 @@ fn main() -> ProgramResult { CandyOptions::Debug(options) => debug(options), CandyOptions::Check(options) => check(options), CandyOptions::Compile(options) => compile(options), - CandyOptions::ToolingAnalyze(options) => tooling_analyze(options), + CandyOptions::ToolingAnalyze(options) => { + tooling_analyze(options); + Ok(()) + } } } pub type ProgramResult = Result<(), Exit>; @@ -221,7 +224,7 @@ struct ToolingAnalyzeOptions { path: PathBuf, } #[allow(clippy::needless_pass_by_value)] -fn tooling_analyze(options: ToolingAnalyzeOptions) -> ProgramResult { +fn tooling_analyze(options: ToolingAnalyzeOptions) { let path_str = options.path.to_string_lossy(); let path = path_str.strip_prefix("file:/").unwrap(); let source = fs::read_to_string(Path::new(path)) @@ -249,15 +252,18 @@ fn tooling_analyze(options: ToolingAnalyzeOptions) -> ProgramResult { "{}", serde_json::to_string(&Message::Diagnostics { diagnostics }).unwrap(), ); - - Ok(()) } #[derive(Serialize)] #[serde(tag = "type", rename_all = "snake_case")] enum Message { - ReadFile { path: String }, - Diagnostics { diagnostics: Vec }, + #[allow(dead_code)] + ReadFile { + path: String, + }, + Diagnostics { + diagnostics: Vec, + }, } #[derive(Serialize)] struct Diagnostic { diff --git a/compiler_v4/src/mono.rs b/compiler_v4/src/mono.rs index 10af013d7..53d5c1afd 100644 --- a/compiler_v4/src/mono.rs +++ b/compiler_v4/src/mono.rs @@ -96,7 +96,7 @@ impl ToText for Mono { builder.push("Assignments (in initialization order):"); builder.push_newline(); - for name in self.assignment_initialization_order.iter() { + for name in &self.assignment_initialization_order { (&**name, &self.assignments[name]).build_text(builder); builder.push_newline(); } @@ -264,7 +264,7 @@ impl Body { } ExpressionKind::Switch { value, cases, .. } => { referenced_ids.insert(*value); - for case in cases.iter() { + for case in &**cases { if let Some((value_id, _)) = &case.value { referenced_ids.insert(*value_id); } diff --git a/compiler_v4/src/mono_to_c.rs b/compiler_v4/src/mono_to_c.rs index aa133f668..9f01d9e89 100644 --- a/compiler_v4/src/mono_to_c.rs +++ b/compiler_v4/src/mono_to_c.rs @@ -58,7 +58,7 @@ impl<'h> Context<'h> { self.lower_function_definitions(); self.push("int main() {\n"); - for name in self.mono.assignment_initialization_order.iter() { + for name in &self.mono.assignment_initialization_order { self.push(format!("{name}$init();\n")); } self.push(format!( @@ -99,7 +99,7 @@ impl<'h> Context<'h> { self.push("};\n"); } TypeDeclaration::Struct { fields } => { - for (name, type_) in fields.iter() { + for (name, type_) in &**fields { self.push(format!("{type_}* {name}; ")); } self.push("};\n"); @@ -107,14 +107,14 @@ impl<'h> Context<'h> { TypeDeclaration::Enum { variants } => { if !variants.is_empty() { self.push("enum {"); - for variant in variants.iter() { + for variant in &**variants { self.push(format!("{name}_{},", variant.name)); } self.push("} variant;\n"); } self.push("union {"); - for variant in variants.iter() { + for variant in &**variants { if let Some(value_type) = &variant.value_type { self.push(format!("{value_type}* {};", variant.name)); } @@ -127,7 +127,7 @@ impl<'h> Context<'h> { } => { self.push("void* closure;\n"); self.push(format!("{return_type}* (*function)(void*")); - for parameter_type in parameter_types.iter() { + for parameter_type in &**parameter_types { self.push(format!(", {parameter_type}*")); } self.push(");\n"); @@ -230,7 +230,7 @@ impl<'h> Context<'h> { "{}* {declaration_name}$lambda{id}_function(void* raw_closure", &lambda.body.return_type() )); - for parameter in lambda.parameters.iter() { + for parameter in &lambda.parameters { self.push(format!(", {}* {}", ¶meter.type_, parameter.id)); } self.push(")"); @@ -249,7 +249,7 @@ impl<'h> Context<'h> { | ExpressionKind::CallFunction { .. } | ExpressionKind::CallLambda { .. } => {} ExpressionKind::Switch { cases, .. } => { - for case in cases.iter() { + for case in &**cases { Self::visit_lambdas_inside_body(&case.body, visitor); } } @@ -825,7 +825,7 @@ impl<'h> Context<'h> { "{}* {id} = {lambda}->function({lambda}->closure", &expression.type_ )); - for argument in arguments.iter() { + for argument in &**arguments { self.push(format!(", {argument}")); } self.push(");"); @@ -838,7 +838,7 @@ impl<'h> Context<'h> { self.push(format!("{}* {id};\n", &expression.type_)); self.push(format!("switch ({value}->variant) {{")); - for case in cases.iter() { + for case in &**cases { self.push(format!("case {enum_}_{}:\n", case.variant)); if let Some((value_id, value_type)) = &case.value { self.push(format!( diff --git a/compiler_v4/src/string_to_ast/declarations.rs b/compiler_v4/src/string_to_ast/declarations.rs index e13be0960..86b93b0a6 100644 --- a/compiler_v4/src/string_to_ast/declarations.rs +++ b/compiler_v4/src/string_to_ast/declarations.rs @@ -418,7 +418,7 @@ fn parameter<'a>(parser: Parser) -> Option<(Parser, AstParameter, Option } #[instrument(level = "trace")] -fn type_parameters<'s>(parser: Parser<'s>) -> Option<(Parser, AstTypeParameters)> { +fn type_parameters(parser: Parser) -> Option<(Parser, AstTypeParameters)> { let start_offset = parser.offset(); let mut parser = opening_bracket(parser)?.and_trailing_whitespace(); diff --git a/compiler_v4/src/string_to_ast/expression.rs b/compiler_v4/src/string_to_ast/expression.rs index 7db0ba8c0..9967284da 100644 --- a/compiler_v4/src/string_to_ast/expression.rs +++ b/compiler_v4/src/string_to_ast/expression.rs @@ -53,7 +53,7 @@ pub fn expression(parser: Parser) -> Option<(Parser, AstExpression)> { result: &mut AstExpression, parse: fn(Parser<'a>, &mut AstExpression) -> Option>, ) -> bool { - parse(*parser, result).map_or(false, |new_parser| { + parse(*parser, result).is_some_and(|new_parser| { *parser = new_parser; true }) @@ -290,7 +290,7 @@ fn expression_suffix_call<'s>( Some(parser) } #[instrument(level = "trace")] -fn arguments<'s>(parser: Parser<'s>) -> Option<(Parser, AstArguments)> { +fn arguments<'s>(parser: Parser<'s>) -> Option<(Parser<'s>, AstArguments)> { let opening_parenthesis_start = parser.offset(); let mut parser = opening_parenthesis(parser)?.and_trailing_whitespace(); let opening_parenthesis_span = opening_parenthesis_start..parser.offset(); diff --git a/compiler_v4/src/string_to_ast/parser.rs b/compiler_v4/src/string_to_ast/parser.rs index d0bd5df1c..cee2e5bee 100644 --- a/compiler_v4/src/string_to_ast/parser.rs +++ b/compiler_v4/src/string_to_ast/parser.rs @@ -75,7 +75,7 @@ impl<'s> Parser<'s> { } #[must_use] - pub fn consume_literal(mut self, literal: &'static str) -> Option> { + pub fn consume_literal(mut self, literal: &'static str) -> Option { if self.rest().starts_with(literal) { self.offset = Offset(*self.offset + literal.len()); Some(self) @@ -87,7 +87,7 @@ impl<'s> Parser<'s> { pub fn consume_while_not_empty( self, predicate: impl FnMut(char) -> bool, - ) -> Option<(Parser<'s>, AstString)> { + ) -> Option<(Self, AstString)> { let (parser, string) = self.consume_while(predicate); if string.is_empty() { None @@ -96,10 +96,7 @@ impl<'s> Parser<'s> { } } #[must_use] - pub fn consume_while( - mut self, - mut predicate: impl FnMut(char) -> bool, - ) -> (Parser<'s>, AstString) { + pub fn consume_while(mut self, mut predicate: impl FnMut(char) -> bool) -> (Self, AstString) { let start_offset = self.offset(); while let Some((new_parser, c)) = self.consume_char() && predicate(c) @@ -109,7 +106,7 @@ impl<'s> Parser<'s> { (self, self.string(start_offset)) } #[must_use] - pub fn consume_char(self) -> Option<(Parser<'s>, char)> { + pub fn consume_char(self) -> Option<(Self, char)> { self.next_char().map(|c| { ( Parser { diff --git a/compiler_v4/src/string_to_ast/type_.rs b/compiler_v4/src/string_to_ast/type_.rs index 4fc416a42..a200f4a6e 100644 --- a/compiler_v4/src/string_to_ast/type_.rs +++ b/compiler_v4/src/string_to_ast/type_.rs @@ -93,7 +93,7 @@ fn function_type_parameter_type<'a>( } #[instrument(level = "trace")] -pub fn type_arguments<'s>(parser: Parser<'s>) -> Option<(Parser, AstTypeArguments)> { +pub fn type_arguments<'s>(parser: Parser<'s>) -> Option<(Parser<'s>, AstTypeArguments)> { let start_offset = parser.offset(); let mut parser = opening_bracket(parser)?.and_trailing_whitespace(); diff --git a/compiler_v4/src/type_solver/goals.rs b/compiler_v4/src/type_solver/goals.rs index 52ef2291c..ea84ab593 100644 --- a/compiler_v4/src/type_solver/goals.rs +++ b/compiler_v4/src/type_solver/goals.rs @@ -280,7 +280,7 @@ struct SolverTree { goal: SolverGoal, } impl SolverTree { - fn solve(&mut self, context: &mut Solver) -> SolverSolution { + fn solve(&self, context: &mut Solver) -> SolverSolution { let mut strands = context .rules .iter() From dd7b7ccd4765a137909ff53ebf9b53254a2d67e1 Mon Sep 17 00:00:00 2001 From: Jonas Wanke Date: Thu, 19 Dec 2024 09:30:30 +0100 Subject: [PATCH 5/5] Disable Clippy, fix lints in old crates --- compiler/backend_inkwell/src/lib.rs | 21 +++++++++++---------- compiler/cli/src/main.rs | 22 +++++++++++----------- compiler/formatter/src/lib.rs | 15 ++++++++------- compiler/frontend/src/lib.rs | 22 +++++++++++----------- compiler/fuzzer/src/lib.rs | 5 +++-- compiler/language_server/src/lib.rs | 24 ++++++++++++------------ compiler/vm/benches/benchmark.rs | 2 +- compiler/vm/src/instruction_pointer.rs | 8 ++++---- compiler/vm/src/lib.rs | 22 +++++++++++----------- third_party/dap-rs/src/events.rs | 8 ++++---- third_party/dap-rs/src/types.rs | 2 +- 11 files changed, 77 insertions(+), 74 deletions(-) diff --git a/compiler/backend_inkwell/src/lib.rs b/compiler/backend_inkwell/src/lib.rs index 1c633e86a..80b8848e3 100644 --- a/compiler/backend_inkwell/src/lib.rs +++ b/compiler/backend_inkwell/src/lib.rs @@ -1,14 +1,15 @@ #![feature(let_chains)] -#![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] -#![allow( - clippy::cognitive_complexity, - clippy::match_same_arms, - clippy::missing_errors_doc, - clippy::missing_panics_doc, - clippy::module_name_repetitions, - clippy::similar_names, - clippy::too_many_lines -)] +#![allow(clippy::all)] +// #![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] +// #![allow( +// clippy::cognitive_complexity, +// clippy::match_same_arms, +// clippy::missing_errors_doc, +// clippy::missing_panics_doc, +// clippy::module_name_repetitions, +// clippy::similar_names, +// clippy::too_many_lines +// )] use candy_frontend::{ builtin_functions::BuiltinFunction, diff --git a/compiler/cli/src/main.rs b/compiler/cli/src/main.rs index 20e34d609..8d33f747f 100644 --- a/compiler/cli/src/main.rs +++ b/compiler/cli/src/main.rs @@ -1,14 +1,14 @@ -#![feature(lazy_cell)] -#![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] -#![allow( - clippy::cognitive_complexity, - clippy::match_same_arms, - clippy::missing_errors_doc, - clippy::missing_panics_doc, - clippy::module_name_repetitions, - clippy::similar_names, - clippy::too_many_lines -)] +#![allow(clippy::all)] +// #![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] +// #![allow( +// clippy::cognitive_complexity, +// clippy::match_same_arms, +// clippy::missing_errors_doc, +// clippy::missing_panics_doc, +// clippy::module_name_repetitions, +// clippy::similar_names, +// clippy::too_many_lines +// )] use candy_vm::CAN_USE_STDOUT; use clap::Parser; diff --git a/compiler/formatter/src/lib.rs b/compiler/formatter/src/lib.rs index 6b3ef252d..fb69889f9 100644 --- a/compiler/formatter/src/lib.rs +++ b/compiler/formatter/src/lib.rs @@ -4,13 +4,14 @@ const_trait_impl, let_chains )] -#![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] -#![allow( - clippy::cognitive_complexity, - clippy::match_same_arms, - clippy::module_name_repetitions, - clippy::too_many_lines -)] +#![allow(clippy::all)] +// #![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] +// #![allow( +// clippy::cognitive_complexity, +// clippy::match_same_arms, +// clippy::module_name_repetitions, +// clippy::too_many_lines +// )] use candy_frontend::{cst::Cst, position::Offset}; use existing_whitespace::{TrailingWithIndentationConfig, WhitespacePositionInBody}; diff --git a/compiler/frontend/src/lib.rs b/compiler/frontend/src/lib.rs index 9152212f6..bd9ec48c5 100644 --- a/compiler/frontend/src/lib.rs +++ b/compiler/frontend/src/lib.rs @@ -1,23 +1,23 @@ #![feature( anonymous_lifetime_in_impl_trait, box_patterns, - entry_insert, extract_if, hasher_prefixfree_extras, io_error_more, let_chains, try_blocks )] -#![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] -#![allow( - clippy::cognitive_complexity, - clippy::match_same_arms, - clippy::missing_errors_doc, - clippy::missing_panics_doc, - clippy::module_name_repetitions, - clippy::similar_names, - clippy::too_many_lines -)] +#![allow(clippy::all)] +// #![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] +// #![allow( +// clippy::cognitive_complexity, +// clippy::match_same_arms, +// clippy::missing_errors_doc, +// clippy::missing_panics_doc, +// clippy::module_name_repetitions, +// clippy::similar_names, +// clippy::too_many_lines +// )] pub use self::tracing::{CallTracingMode, TracingConfig, TracingMode}; diff --git a/compiler/fuzzer/src/lib.rs b/compiler/fuzzer/src/lib.rs index c0fbeb607..a3603e280 100644 --- a/compiler/fuzzer/src/lib.rs +++ b/compiler/fuzzer/src/lib.rs @@ -1,6 +1,7 @@ #![feature(let_chains, round_char_boundary)] -#![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] -#![allow(clippy::missing_panics_doc, clippy::module_name_repetitions)] +#![allow(clippy::all)] +// #![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] +// #![allow(clippy::missing_panics_doc, clippy::module_name_repetitions)] mod coverage; mod fuzzer; diff --git a/compiler/language_server/src/lib.rs b/compiler/language_server/src/lib.rs index 36fe2c5c6..9795cc0a7 100644 --- a/compiler/language_server/src/lib.rs +++ b/compiler/language_server/src/lib.rs @@ -2,19 +2,19 @@ anonymous_lifetime_in_impl_trait, async_closure, box_patterns, - let_chains, - strict_provenance -)] -#![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] -#![allow( - clippy::future_not_send, // TODO: Fix clippy::future_not_send occurrences - clippy::large_enum_variant, - clippy::match_same_arms, - clippy::missing_errors_doc, - clippy::missing_panics_doc, - clippy::module_name_repetitions, - clippy::too_many_lines + let_chains )] +#![allow(clippy::all)] +// #![warn(clippy::nursery, clippy::pedantic, unused_crate_dependencies)] +// #![allow( +// clippy::future_not_send, // TODO: Fix clippy::future_not_send occurrences +// clippy::large_enum_variant, +// clippy::match_same_arms, +// clippy::missing_errors_doc, +// clippy::missing_panics_doc, +// clippy::module_name_repetitions, +// clippy::too_many_lines +// )] pub mod database; pub mod debug_adapter; diff --git a/compiler/vm/benches/benchmark.rs b/compiler/vm/benches/benchmark.rs index 5ddbfb09a..092baad30 100644 --- a/compiler/vm/benches/benchmark.rs +++ b/compiler/vm/benches/benchmark.rs @@ -1,5 +1,5 @@ -#![feature(absolute_path)] #![allow(unused_attributes)] +#![allow(clippy::all)] use candy_frontend::module::PackagesPath; use candy_vm::{ diff --git a/compiler/vm/src/instruction_pointer.rs b/compiler/vm/src/instruction_pointer.rs index 7a393205a..be6bc432c 100644 --- a/compiler/vm/src/instruction_pointer.rs +++ b/compiler/vm/src/instruction_pointer.rs @@ -17,16 +17,16 @@ impl InstructionPointer { } } impl Step for InstructionPointer { - fn steps_between(start: &Self, end: &Self) -> Option { - (**end).checked_sub(**start) + fn steps_between(start: &Self, end: &Self) -> (usize, Option) { + usize::steps_between(&**start, &**end) } fn forward_checked(start: Self, count: usize) -> Option { - (*start).checked_add(count).map(Self) + usize::forward_checked(*start, count).map(InstructionPointer) } fn backward_checked(start: Self, count: usize) -> Option { - (*start).checked_sub(count).map(Self) + usize::backward_checked(*start, count).map(InstructionPointer) } } impl Debug for InstructionPointer { diff --git a/compiler/vm/src/lib.rs b/compiler/vm/src/lib.rs index bec1adb15..3eae98833 100644 --- a/compiler/vm/src/lib.rs +++ b/compiler/vm/src/lib.rs @@ -8,7 +8,6 @@ nonzero_ops, slice_ptr_get, step_trait, - strict_provenance, try_blocks )] // We can't enable `unused_crate_dependencies` since it reports false positives about @@ -16,16 +15,17 @@ // https://github.com/rust-lang/rust/issues/57274 // https://github.com/rust-lang/rust/issues/95513 // https://github.com/rust-lang/rust-clippy/issues/4341 -#![warn(clippy::nursery, clippy::pedantic)] -#![allow( - clippy::large_enum_variant, - clippy::match_same_arms, - clippy::missing_errors_doc, - clippy::missing_panics_doc, - clippy::module_name_repetitions, - clippy::similar_names, - clippy::too_many_lines -)] +#![allow(clippy::all)] +// #![warn(clippy::nursery, clippy::pedantic)] +// #![allow( +// clippy::large_enum_variant, +// clippy::match_same_arms, +// clippy::missing_errors_doc, +// clippy::missing_panics_doc, +// clippy::module_name_repetitions, +// clippy::similar_names, +// clippy::too_many_lines +// )] pub use builtin_functions::CAN_USE_STDOUT; pub use instruction_pointer::InstructionPointer; diff --git a/third_party/dap-rs/src/events.rs b/third_party/dap-rs/src/events.rs index 2ebf88ed6..e507391ee 100644 --- a/third_party/dap-rs/src/events.rs +++ b/third_party/dap-rs/src/events.rs @@ -260,18 +260,18 @@ pub struct StoppedEventBody { /// If `allThreadsStopped` is true, a debug adapter can announce that all /// threads have stopped. /// - The client should use this information to enable that all threads can - /// be expanded to access their stacktraces. + /// be expanded to access their stacktraces. /// - If the attribute is missing or false, only the thread with the given - /// `threadId` can be expanded. + /// `threadId` can be expanded. pub all_threads_stopped: Option, /// Ids of the breakpoints that triggered the event. In most cases there is /// only a single breakpoint but here are some examples for multiple /// breakpoints: /// - Different types of breakpoints map to the same location. /// - Multiple source breakpoints get collapsed to the same instruction by - /// the compiler/runtime. + /// the compiler/runtime. /// - Multiple function breakpoints with different function names map to the - /// same location. + /// same location. pub hit_breakpoint_ids: Option>, } diff --git a/third_party/dap-rs/src/types.rs b/third_party/dap-rs/src/types.rs index 656b1d2b5..bb88b9ef4 100644 --- a/third_party/dap-rs/src/types.rs +++ b/third_party/dap-rs/src/types.rs @@ -1156,7 +1156,7 @@ fromstr_deser! { VariablesArgumentsFilter } tostr_ser! { VariablesArgumentsFilter } /// Properties of a breakpoint location returned from the breakpointLocations request. - +/// /// Specfication: [BreakpointLocation](https://microsoft.github.io/debug-adapter-protocol/specification#Types_BreakpointLocation) #[derive(Serialize, Debug, Clone)] #[serde(rename_all = "camelCase")]