diff --git a/crates/codegen/parser/runtime/src/diagnostic.rs b/crates/codegen/parser/runtime/src/diagnostic.rs index 6e5facf296..049379da7f 100644 --- a/crates/codegen/parser/runtime/src/diagnostic.rs +++ b/crates/codegen/parser/runtime/src/diagnostic.rs @@ -1,5 +1,5 @@ +use std::borrow::Cow; use std::error::Error; -use std::fmt::Display; use crate::text_index::TextRange; @@ -13,7 +13,9 @@ pub enum Severity { pub trait Diagnostic: Error { fn range(&self) -> TextRange; - fn code(&self) -> Box; + fn code(&self) -> Option> { + None + } fn severity(&self) -> Severity; fn message(&self) -> String; } diff --git a/crates/codegen/parser/runtime/src/napi_interface/diagnostic.rs b/crates/codegen/parser/runtime/src/napi_interface/diagnostic.rs index 2e35acd6b7..21ba249115 100644 --- a/crates/codegen/parser/runtime/src/napi_interface/diagnostic.rs +++ b/crates/codegen/parser/runtime/src/napi_interface/diagnostic.rs @@ -46,6 +46,6 @@ impl Diagnostic { #[napi] pub fn code(&self) -> String { - self.0.code().to_string() + self.0.code().unwrap_or_default().into_owned() } } diff --git a/crates/codegen/parser/runtime/src/parse_error.rs b/crates/codegen/parser/runtime/src/parse_error.rs index 54baa77530..c26f9a0e89 100644 --- a/crates/codegen/parser/runtime/src/parse_error.rs +++ b/crates/codegen/parser/runtime/src/parse_error.rs @@ -59,10 +59,6 @@ impl Diagnostic for ParseError { self.text_range.clone() } - fn code(&self) -> Box { - Box::new("ParseError") - } - fn severity(&self) -> diagnostic::Severity { diagnostic::Severity::Error } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/diagnostic.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/diagnostic.rs index 999c05589f..9ccea34247 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/diagnostic.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/diagnostic.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +use std::borrow::Cow; use std::error::Error; -use std::fmt::Display; use crate::text_index::TextRange; @@ -15,7 +15,9 @@ pub enum Severity { pub trait Diagnostic: Error { fn range(&self) -> TextRange; - fn code(&self) -> Box; + fn code(&self) -> Option> { + None + } fn severity(&self) -> Severity; fn message(&self) -> String; } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs index 35830141cd..9659273c99 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs @@ -48,6 +48,6 @@ impl Diagnostic { #[napi] pub fn code(&self) -> String { - self.0.code().to_string() + self.0.code().unwrap_or_default().into_owned() } } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs index cc5c56f48c..b9a1a74eac 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parse_error.rs @@ -61,10 +61,6 @@ impl Diagnostic for ParseError { self.text_range.clone() } - fn code(&self) -> Box { - Box::new("ParseError") - } - fn severity(&self) -> diagnostic::Severity { diagnostic::Severity::Error } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/diagnostic.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/diagnostic.rs index 999c05589f..9ccea34247 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/diagnostic.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/diagnostic.rs @@ -1,7 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +use std::borrow::Cow; use std::error::Error; -use std::fmt::Display; use crate::text_index::TextRange; @@ -15,7 +15,9 @@ pub enum Severity { pub trait Diagnostic: Error { fn range(&self) -> TextRange; - fn code(&self) -> Box; + fn code(&self) -> Option> { + None + } fn severity(&self) -> Severity; fn message(&self) -> String; } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs index 35830141cd..9659273c99 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs @@ -48,6 +48,6 @@ impl Diagnostic { #[napi] pub fn code(&self) -> String { - self.0.code().to_string() + self.0.code().unwrap_or_default().into_owned() } } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs index cc5c56f48c..b9a1a74eac 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parse_error.rs @@ -61,10 +61,6 @@ impl Diagnostic for ParseError { self.text_range.clone() } - fn code(&self) -> Box { - Box::new("ParseError") - } - fn severity(&self) -> diagnostic::Severity { diagnostic::Severity::Error }