1,452 matches across 25 files for error lang:Rust
snippet_mode: grep · sorted by relevance
1▶use react_compiler_diagnostics::CompilerError;
2use react_compiler_hir::environment::Environment;
3use react_compiler_hir::print::{self, PrintFormatter};
· · ·
674 printer.fmt.line("Environment:");
675 printer.fmt.indent();
676▶ printer.fmt.format_errors(&env.errors);
677 printer.fmt.dedent();
678
· · ·
681
682// =============================================================================
683▶// Error formatting (kept for backward compatibility)
684// =============================================================================
685
· · ·
686▶pub fn format_errors(error: &CompilerError) -> String {
687 let env = Environment::new();
688 let mut fmt = PrintFormatter::new(&env);
· · ·
689▶ fmt.format_errors(error);
690 fmt.to_string_output()
691}
110 timing: Vec<TimingEntry>,
111 },
112▶ /// A fatal error occurred and panicThreshold dictates it should throw.
113 Error {
114 error: CompilerErrorInfo,
· · ·
113▶ Error {
114 error: CompilerErrorInfo,
115 events: Vec<LoggerEvent>,
· · ·
114▶ error: CompilerErrorInfo,
115 events: Vec<LoggerEvent>,
116 #[serde(rename = "orderedLog", skip_serializing_if = "Vec::is_empty")]
· · ·
130}
131
132▶/// Structured error information for the JS shim.
133#[derive(Debug, Clone, Serialize)]
134pub struct CompilerErrorInfo {
· · ·
134▶pub struct CompilerErrorInfo {
135 pub reason: String,
136 #[serde(skip_serializing_if = "Option::is_none")]
+ 20 more matches in this file
14use react_compiler_ast::statements::*;
15use react_compiler_diagnostics::CompilerDiagnostic;
16▶use react_compiler_diagnostics::ErrorCategory;
17
18use super::imports::ProgramContext;
· · ·
80 } else {
81 return Err(CompilerDiagnostic::new(
82▶ ErrorCategory::Invariant,
83 "Expected compiled node type to match input type: \
84 got non-FunctionDeclaration but expected FunctionDeclaration",
· · ·
207 } else {
208 return Err(CompilerDiagnostic::new(
209▶ ErrorCategory::Invariant,
210 "Expected function declaration in export",
211 None,
· · ·
214 } else {
215 return Err(CompilerDiagnostic::new(
216▶ ErrorCategory::Invariant,
217 "Expected declaration in export",
218 None,
· · ·
222 _ => {
223 return Err(CompilerDiagnostic::new(
224▶ ErrorCategory::Invariant,
225 "Expected function declaration at original_index",
226 None,
+ 6 more matches in this file
22use react_compiler_ast::{Program, SourceType};
23use react_compiler_diagnostics::{
24▶ CompilerError, CompilerErrorDetail, ErrorCategory, Position, SourceLocation,
25};
26
· · ·
266
267/// Check for blocklisted import modules.
268▶/// Returns a CompilerError if any blocklisted imports are found.
269pub fn validate_restricted_imports(
270 program: &Program,
· · ·
271 blocklisted: &Option<Vec<String>>,
272▶) -> Option<CompilerError> {
273 let blocklisted = match blocklisted {
274 Some(b) if !b.is_empty() => b,
· · ·
276 };
277 let restricted: FxHashSet<&str> = blocklisted.iter().map(|s| s.as_str()).collect();
278▶ let mut error = CompilerError::new();
279
280 for stmt in &program.body {
· · ·
286 .is_some_and(|v| restricted.contains(v))
287 {
288▶ let mut detail = CompilerErrorDetail::new(
289 ErrorCategory::Todo,
290 "Bailing out due to blocklisted import",
+ 4 more matches in this file
11use indexmap::IndexMap;
12use react_compiler_ast::scope::ScopeInfo;
13▶use react_compiler_diagnostics::CompilerError;
14use react_compiler_hir::ReactFunctionType;
15use react_compiler_hir::environment::Environment;
· · ·
20
21use super::compile_result::CodegenFunction;
22▶use super::compile_result::CompilerErrorDetailInfo;
23use super::compile_result::CompilerErrorItemInfo;
24use super::compile_result::DebugLogEntry;
· · ·
23▶use super::compile_result::CompilerErrorItemInfo;
24use super::compile_result::DebugLogEntry;
25use super::compile_result::LoggerPosition;
· · ·
43 env_config: &EnvironmentConfig,
44 context: &mut ProgramContext,
45▶) -> Result<CodegenFunction, CompilerError> {
46 let mut env = Environment::with_config(env_config.clone());
47 env.fn_type = fn_type;
· · ·
69 }
70
71▶ // Check for Invariant errors after lowering, before logging HIR.
72 // In TS, Invariant errors throw from recordError(), aborting lower() before
73 // the HIR entry is logged. The thrown error contains ONLY the Invariant error,
+ 53 more matches in this file
35use react_compiler_ast::visitor::Visitor;
36use react_compiler_ast::visitor::walk_program_mut;
37▶use react_compiler_diagnostics::CompilerError;
38use react_compiler_diagnostics::CompilerErrorDetail;
39use react_compiler_diagnostics::CompilerErrorOrDiagnostic;
· · ·
38▶use react_compiler_diagnostics::CompilerErrorDetail;
39use react_compiler_diagnostics::CompilerErrorOrDiagnostic;
40use react_compiler_diagnostics::ErrorCategory;
· · ·
39▶use react_compiler_diagnostics::CompilerErrorOrDiagnostic;
40use react_compiler_diagnostics::ErrorCategory;
41use react_compiler_diagnostics::SourceLocation;
· · ·
40▶use react_compiler_diagnostics::ErrorCategory;
41use react_compiler_diagnostics::SourceLocation;
42use react_compiler_hir::ReactFunctionType;
· · ·
47use super::compile_result::CodegenFunction;
48use super::compile_result::CompileResult;
49▶use super::compile_result::CompilerErrorDetailInfo;
50use super::compile_result::CompilerErrorInfo;
51use super::compile_result::CompilerErrorItemInfo;
+ 94 more matches in this file
7use react_compiler_ast::common::{Comment, CommentData};
8use react_compiler_diagnostics::{
9▶ CompilerDiagnostic, CompilerDiagnosticDetail, CompilerError, CompilerSuggestion,
10 CompilerSuggestionOperation, ErrorCategory,
11};
· · ·
10▶ CompilerSuggestionOperation, ErrorCategory,
11};
12
· · ·
87/// Check if a comment value matches a Flow suppression pattern.
88/// Matches: $FlowFixMe[react-rule, $FlowFixMe_xxx[react-rule,
89▶/// $FlowExpectedError[react-rule, $FlowIssue[react-rule
90fn matches_flow_suppression(value: &str) -> bool {
91 // Find "$Flow" anywhere in the value
· · ·
95 let after_dollar_flow = &value[idx + "$Flow".len()..];
96
97▶ // Match FlowFixMe (with optional word chars), FlowExpectedError, or FlowIssue
98 let after_kind = if after_dollar_flow.starts_with("FixMe") {
99 // Skip "FixMe" + any word characters
· · ·
103 .unwrap_or(rest.len());
104 &rest[word_end..]
105▶ } else if after_dollar_flow.starts_with("ExpectedError") {
106 &after_dollar_flow["ExpectedError".len()..]
107 } else if after_dollar_flow.starts_with("Issue") {
+ 11 more matches in this file
22use react_compiler_ast::statements::{ForInOfLeft, ForInit, Statement, VariableDeclaration};
23use react_compiler_diagnostics::{
24▶ CompilerDiagnostic, CompilerDiagnosticDetail, ErrorCategory, Position as DiagPosition,
25 SourceLocation as DiagSourceLocation,
26};
· · ·
131}
132
133▶// ---- Error reporting ----
134
135fn report_missing_location(env: &mut Environment, loc: &AstSourceLocation, node_type: &str) {
· · ·
137 env.record_diagnostic(
138 CompilerDiagnostic::new(
139▶ ErrorCategory::Todo,
140 "Important source location missing in generated code",
141 Some(format!(
· · ·
146 )),
147 )
148▶ .with_detail(CompilerDiagnosticDetail::Error {
149 loc: Some(diag_loc),
150 message: None,
· · ·
165 env.record_diagnostic(
166 CompilerDiagnostic::new(
167▶ ErrorCategory::Todo,
168 "Important source location has wrong node type in generated code",
169 Some(format!(
+ 1 more matches in this file
18
19impl<'de> serde::Deserialize<'de> for RawNode {
20▶ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
21 where
22 D: serde::Deserializer<'de>,
· · ·
24 let mut buf = Vec::new();
25 let mut ser = serde_json::Serializer::new(&mut buf);
26▶ serde_transcode::transcode(deserializer, &mut ser).map_err(serde::de::Error::custom)?;
27 let text = String::from_utf8(buf).map_err(serde::de::Error::custom)?;
28 serde_json::value::RawValue::from_string(text)
· · ·
27▶ let text = String::from_utf8(buf).map_err(serde::de::Error::custom)?;
28 serde_json::value::RawValue::from_string(text)
29 .map(RawNode)
· · ·
30▶ .map_err(serde::de::Error::custom)
31 }
32}
· · ·
91///
92/// Use with `#[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "nullable_value")]`
93▶pub fn nullable_value<'de, D>(deserializer: D) -> Result<Option<RawNode>, D::Error>
94where
95 D: serde::Deserializer<'de>,
70 JSXElement(Box<JSXElement>),
71 JSXFragment(JSXFragment),
72▶ // Pattern (can appear in expression position in error recovery)
73 AssignmentPattern(AssignmentPattern),
74 // TypeScript expressions
3use serde::Serialize;
4use serde::Serializer;
5▶use serde::de::Error as _;
6
7use crate::common::BaseNode;
· · ·
74 ///
75 /// Deserialization dispatches through [`KnownStatement`]: a modeled `type`
76▶ /// whose body is malformed errors with the typed variant's precise message
77 /// rather than degrading to `Unknown`. Adding a variant to this enum
78 /// requires adding it to the `known_statements!` list below, which is the
· · ·
148
149impl Serialize for UnknownStatement {
150▶ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
151 where
152 S: Serializer,
· · ·
157
158impl<'de> Deserialize<'de> for UnknownStatement {
159▶ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
160 where
161 D: Deserializer<'de>,
· · ·
162 {
163 let raw = RawNode::deserialize(deserializer)?;
164▶ Self::from_raw(raw).map_err(D::Error::custom)
165 }
166}
+ 13 more matches in this file
107 Ok(info) => info,
108 Err(e) => {
109▶ failures.push((fixture_name, format!("Scope deserialization error: {e}")));
110 continue;
111 }
· · ·
127 }
128
129▶ let mut consistency_error = None;
130
131 for binding in &scope_info.bindings {
· · ·
132 if binding.scope.0 as usize >= scope_info.scopes.len() {
133▶ consistency_error = Some(format!(
134 "Binding {} has scope {} but only {} scopes exist",
135 binding.name,
· · ·
141 }
142
143▶ if consistency_error.is_none() {
144 for scope in &scope_info.scopes {
145 for (name, &bid) in &scope.bindings {
· · ·
146 if bid.0 as usize >= scope_info.bindings.len() {
147▶ consistency_error = Some(format!(
148 "Scope {} has binding '{}' with id {} but only {} bindings exist",
149 scope.id.0,
+ 17 more matches in this file
5 * LICENSE file in the root directory of this source tree.
6 */
7▶use crate::{CompilerDiagnosticDetail, CompilerError, CompilerErrorOrDiagnostic};
8
9const CODEFRAME_LINES_ABOVE: u32 = 2;
· · ·
88
89 if line_diff > 0 {
90▶ // Multi-line error
91 for i in 0..=line_diff {
92 let line_number = i + start_line;
· · ·
108 }
109 } else {
110▶ // Single-line error
111 if start_column == end_column {
112 if start_column != 0 {
· · ·
321use crate::format_category_heading;
322
323▶/// Format a CompilerError into a message string matching the TS compiler's
324/// CompilerError.printErrorMessage() / formatCompilerError() format.
325///
· · ·
324▶/// CompilerError.printErrorMessage() / formatCompilerError() format.
325///
326/// The source parameter is the full source code of the file being compiled.
+ 9 more matches in this file
243
244impl Serialize for JsString {
245▶ fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
246 serializer.serialize_str(&self.to_marker_string())
247 }
· · ·
249
250impl<'de> Deserialize<'de> for JsString {
251▶ fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
252 let s = String::deserialize(deserializer)?;
253 Ok(JsString::from_marker_string(&s))
6use serde::{Deserialize, Serialize};
7
8▶/// Error categories matching the TS ErrorCategory enum
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
10pub enum ErrorCategory {
· · ·
10▶pub enum ErrorCategory {
11 Hooks,
12 CapitalizedCalls,
· · ·
24 EffectSetState,
25 EffectDerivationsOfState,
26▶ ErrorBoundaries,
27 Purity,
28 RenderSetState,
· · ·
37}
38
39▶/// Error severity levels
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
41pub enum ErrorSeverity {
· · ·
41▶pub enum ErrorSeverity {
42 Error,
43 Warning,
+ 104 more matches in this file
12use rustc_hash::{FxHashMap, FxHashSet};
13
14▶use react_compiler_diagnostics::{CompilerDiagnostic, ErrorCategory};
15
16use crate::visitors::each_terminal_successor;
· · ·
221 None => {
222 return Err(CompilerDiagnostic::new(
223▶ ErrorCategory::Invariant,
224 format!(
225 "At least one predecessor must have been visited for block {:?}",
· · ·
352 assert!(
353 !unconditional.contains(&block_id),
354▶ "Internal error: non-terminating loop in ComputeUnconditionalBlocks"
355 );
356 unconditional.insert(block_id);
2
3use react_compiler_diagnostics::CompilerDiagnostic;
4▶use react_compiler_diagnostics::CompilerError;
5use react_compiler_diagnostics::CompilerErrorDetail;
6use react_compiler_diagnostics::ErrorCategory;
· · ·
5▶use react_compiler_diagnostics::CompilerErrorDetail;
6use react_compiler_diagnostics::ErrorCategory;
7
· · ·
6▶use react_compiler_diagnostics::ErrorCategory;
7
8use crate::default_module_type_provider::default_module_type_provider;
· · ·
51 pub functions: Vec<HirFunction>,
52
53▶ // Error accumulation
54 pub errors: CompilerError,
55
· · ·
54▶ pub errors: CompilerError,
55
56 // Function type classification (Component, Hook, Other)
+ 100 more matches in this file
138/// Convert a user-provided TypeConfig into an internal Type, registering shapes
139/// as needed. Ported from TS `installTypeConfig` in Globals.ts.
140▶/// If `errors` is provided, hook-name vs hook-type consistency validation
141/// errors are collected there.
142pub fn install_type_config(
· · ·
141▶/// errors are collected there.
142pub fn install_type_config(
143 _globals: &mut GlobalRegistry,
· · ·
150}
151
152▶/// Like `install_type_config` but collects validation errors.
153pub fn install_type_config_with_errors(
154 _globals: &mut GlobalRegistry,
· · ·
153▶pub fn install_type_config_with_errors(
154 _globals: &mut GlobalRegistry,
155 shapes: &mut ShapeRegistry,
· · ·
157 module_name: &str,
158 _loc: (),
159▶ errors: &mut Vec<String>,
160) -> Global {
161 install_type_config_inner(
+ 14 more matches in this file
12use indexmap::{IndexMap, IndexSet};
13pub use react_compiler_diagnostics::CompilerDiagnostic;
14▶pub use react_compiler_diagnostics::ErrorCategory;
15pub use react_compiler_diagnostics::GENERATED_SOURCE;
16pub use react_compiler_diagnostics::Position;
· · ·
1436 into: Place,
1437 },
1438▶ /// Mutation of a value known to be frozen (error).
1439 MutateFrozen {
1440 place: Place,
· · ·
1441▶ error: CompilerDiagnostic,
1442 },
1443 /// Mutation of a global value (error).
· · ·
1443▶ /// Mutation of a global value (error).
1444 MutateGlobal {
1445 place: Place,
· · ·
1446▶ error: CompilerDiagnostic,
1447 },
1448 /// Side-effect not safe during render.
+ 1 more matches in this file
11use rustc_hash::FxHashSet;
12
13▶use react_compiler_diagnostics::CompilerError;
14use react_compiler_diagnostics::CompilerErrorOrDiagnostic;
15use react_compiler_diagnostics::SourceLocation;
· · ·
14▶use react_compiler_diagnostics::CompilerErrorOrDiagnostic;
15use react_compiler_diagnostics::SourceLocation;
16
· · ·
385 )
386 }
387▶ AliasingEffect::MutateFrozen { place, error } => {
388 format!(
389 "MutateFrozen {{ place: {}, reason: {:?} }}",
· · ·
390▶ place.identifier.0, error.reason
391 )
392 }
· · ·
393▶ AliasingEffect::MutateGlobal { place, error } => {
394 format!(
395 "MutateGlobal {{ place: {}, reason: {:?} }}",
+ 11 more matches in this file
49 env.identifiers[instr.lvalue.identifier.0 as usize].scope;
50
51▶ // TS: CompilerError.invariant(operandScope != null && lvalueScope != null, ...)
52 let operand_sid = operand_scope.expect(
53 "Internal error: Expected all ObjectExpressions and ObjectMethods to have non-null scope.",
· · ·
53▶ "Internal error: Expected all ObjectExpressions and ObjectMethods to have non-null scope.",
54 );
55 let lvalue_sid = lvalue_scope.expect(
· · ·
56▶ "Internal error: Expected all ObjectExpressions and ObjectMethods to have non-null scope.",
57 );
58 merged_scopes.union(&[operand_sid, lvalue_sid]);
14
15use indexmap::IndexMap;
16▶use react_compiler_diagnostics::{CompilerDiagnostic, ErrorCategory};
17use react_compiler_hir::environment::Environment;
18use rustc_hash::FxHashSet;
· · ·
68 lower_with_mutation_aliasing(&mut inner_func, env, debug_logger)?;
69
70▶ // If an invariant error was recorded, put the function back and stop processing
71 if env.has_invariant_errors() {
72 env.functions[func_id.0 as usize] = inner_func;
· · ·
71▶ if env.has_invariant_errors() {
72 env.functions[func_id.0 as usize] = inner_func;
73 return Ok(());
· · ·
111 crate::infer_mutation_aliasing_effects::infer_mutation_aliasing_effects(func, env, true)?;
112
113▶ // Check for invariant errors (e.g., uninitialized value kind)
114 // In TS, these throw from within inferMutationAliasingEffects, aborting
115 // the rest of the function processing.
· · ·
116▶ if env.has_invariant_errors() {
117 return Ok(());
118 }
+ 2 more matches in this file
27//! Analogous to TS `ReactiveScopes/FlattenScopesWithHooksOrUseHIR.ts`.
28
29▶use react_compiler_diagnostics::{CompilerDiagnostic, ErrorCategory};
30use react_compiler_hir::environment::Environment;
31use react_compiler_hir::{BlockId, HirFunction, InstructionValue, Terminal, Type};
· · ·
100 _ => {
101 return Err(CompilerDiagnostic::new(
102▶ ErrorCategory::Invariant,
103 format!("Expected block bb{} to end in a scope terminal", id.0),
104 None,