Skip to content

Commit 7a0d096

Browse files
committed
add rustc_hir_typeck
1 parent b159d34 commit 7a0d096

40 files changed

+44416
-0
lines changed

source/rustc_hir_typeck/Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "rustc_hir_typeck"
3+
version = "0.0.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
# tidy-alphabetical-start
8+
itertools = "0.12"
9+
rustc_abi = { path = "../rustc_abi" }
10+
rustc_ast = { path = "../rustc_ast" }
11+
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
12+
rustc_data_structures = { path = "../rustc_data_structures" }
13+
rustc_errors = { path = "../rustc_errors" }
14+
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
15+
rustc_hir = { path = "../rustc_hir" }
16+
rustc_hir_analysis = { path = "../rustc_hir_analysis" }
17+
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
18+
rustc_index = { path = "../rustc_index" }
19+
rustc_infer = { path = "../rustc_infer" }
20+
rustc_lint = { path = "../rustc_lint" }
21+
rustc_macros = { path = "../rustc_macros" }
22+
rustc_middle = { path = "../rustc_middle" }
23+
rustc_session = { path = "../rustc_session" }
24+
rustc_span = { path = "../rustc_span" }
25+
rustc_target = { path = "../rustc_target" }
26+
rustc_trait_selection = { path = "../rustc_trait_selection" }
27+
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
28+
tracing = "0.1"
29+
# tidy-alphabetical-end

source/rustc_hir_typeck/messages.ftl

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
hir_typeck_add_missing_parentheses_in_range = you must surround the range in parentheses to call its `{$func_name}` function
2+
3+
hir_typeck_add_return_type_add = try adding a return type
4+
5+
hir_typeck_add_return_type_missing_here = a return type might be missing here
6+
7+
hir_typeck_address_of_temporary_taken = cannot take address of a temporary
8+
.label = temporary value
9+
10+
hir_typeck_arg_mismatch_indeterminate = argument type mismatch was detected, but rustc had trouble determining where
11+
.note = we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new
12+
13+
hir_typeck_as_deref_suggestion = consider using `as_deref` here
14+
hir_typeck_base_expression_double_dot = base expression required after `..`
15+
hir_typeck_base_expression_double_dot_add_expr = add a base expression here
16+
hir_typeck_base_expression_double_dot_enable_default_field_values =
17+
add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields
18+
hir_typeck_base_expression_double_dot_remove = remove the `..` as all the fields are already present
19+
20+
hir_typeck_candidate_trait_note = `{$trait_name}` defines an item `{$item_name}`{$action_or_ty ->
21+
[NONE] {""}
22+
[implement] , perhaps you need to implement it
23+
*[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it
24+
}
25+
26+
hir_typeck_cannot_cast_to_bool = cannot cast `{$expr_ty}` as `bool`
27+
.suggestion = compare with zero instead
28+
.help = compare with zero instead
29+
.label = unsupported cast
30+
31+
hir_typeck_cant_dereference = type `{$ty}` cannot be dereferenced
32+
hir_typeck_cant_dereference_label = can't be dereferenced
33+
34+
hir_typeck_cast_enum_drop = cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`
35+
36+
hir_typeck_cast_thin_pointer_to_wide_pointer = cannot cast thin pointer `{$expr_ty}` to wide pointer `{$cast_ty}`
37+
.teach_help = Thin pointers are "simple" pointers: they are purely a reference to a
38+
memory address.
39+
40+
Wide pointers are pointers referencing "Dynamically Sized Types" (also
41+
called DST). DST don't have a statically known size, therefore they can
42+
only exist behind some kind of pointers that contain additional
43+
information. Slices and trait objects are DSTs. In the case of slices,
44+
the additional information the wide pointer holds is their size.
45+
46+
To fix this error, don't try to cast directly between thin and wide
47+
pointers.
48+
49+
For more information about casts, take a look at The Book:
50+
https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions",
51+
52+
hir_typeck_cast_unknown_pointer = cannot cast {$to ->
53+
[true] to
54+
*[false] from
55+
} a pointer of an unknown kind
56+
.label_to = needs more type information
57+
.note = the type information given here is insufficient to check whether the pointer cast is valid
58+
.label_from = the type information given here is insufficient to check whether the pointer cast is valid
59+
60+
hir_typeck_const_select_must_be_const = this argument must be a `const fn`
61+
.help = consult the documentation on `const_eval_select` for more information
62+
63+
hir_typeck_const_select_must_be_fn = this argument must be a function item
64+
.note = expected a function item, found {$ty}
65+
.help = consult the documentation on `const_eval_select` for more information
66+
67+
hir_typeck_convert_to_str = try converting the passed type into a `&str`
68+
69+
hir_typeck_convert_using_method = try using `{$sugg}` to convert `{$found}` to `{$expected}`
70+
71+
hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private
72+
73+
hir_typeck_dependency_on_unit_never_type_fallback = this function depends on never type fallback being `()`
74+
.note = in edition 2024, the requirement `{$obligation}` will fail
75+
.help = specify the types explicitly
76+
77+
hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty`
78+
79+
hir_typeck_expected_array_or_slice = expected an array or slice, found `{$ty}`
80+
hir_typeck_expected_array_or_slice_label = pattern cannot match with input type `{$ty}`
81+
82+
hir_typeck_expected_default_return_type = expected `()` because of default return type
83+
84+
hir_typeck_expected_return_type = expected `{$expected}` because of return type
85+
86+
hir_typeck_explicit_destructor = explicit use of destructor method
87+
.label = explicit destructor calls not allowed
88+
.suggestion = consider using `drop` function
89+
90+
hir_typeck_field_multiply_specified_in_initializer =
91+
field `{$ident}` specified more than once
92+
.label = used more than once
93+
.previous_use_label = first use of `{$ident}`
94+
95+
hir_typeck_fn_item_to_variadic_function = can't pass a function item to a variadic function
96+
.suggestion = use a function pointer instead
97+
.help = a function item is zero-sized and needs to be cast into a function pointer to be used in FFI
98+
.note = for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html
99+
100+
hir_typeck_fru_expr = this expression does not end in a comma...
101+
hir_typeck_fru_expr2 = ... so this is interpreted as a `..` range expression, instead of functional record update syntax
102+
hir_typeck_fru_note = this expression may have been misinterpreted as a `..` range expression
103+
hir_typeck_fru_suggestion =
104+
to set the remaining fields{$expr ->
105+
[NONE]{""}
106+
*[other] {" "}from `{$expr}`
107+
}, separate the last named field with a comma
108+
109+
hir_typeck_functional_record_update_on_non_struct =
110+
functional record update syntax requires a struct
111+
112+
hir_typeck_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
113+
hir_typeck_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
114+
115+
hir_typeck_int_to_fat = cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
116+
[true] is
117+
*[false] may be
118+
} wide
119+
hir_typeck_int_to_fat_label = creating a `{$cast_ty}` requires both an address and {$metadata}
120+
hir_typeck_int_to_fat_label_nightly = consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
121+
122+
hir_typeck_invalid_callee = expected function, found {$found}
123+
hir_typeck_invalid_defined = `{$path}` defined here
124+
hir_typeck_invalid_defined_kind = {$kind} `{$path}` defined here
125+
hir_typeck_invalid_fn_defined = `{$func}` defined here returns `{$ty}`
126+
hir_typeck_invalid_local = `{$local_name}` has type `{$ty}`
127+
128+
hir_typeck_lossy_provenance_int2ptr =
129+
strict provenance disallows casting integer `{$expr_ty}` to pointer `{$cast_ty}`
130+
.suggestion = use `.with_addr()` to adjust a valid pointer in the same allocation, to this address
131+
.help = if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::with_exposed_provenance()` instead
132+
133+
hir_typeck_lossy_provenance_ptr2int =
134+
under strict provenance it is considered bad style to cast pointer `{$expr_ty}` to integer `{$cast_ty}`
135+
.suggestion = use `.addr()` to obtain the address of a pointer
136+
.help = if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_provenance()` instead
137+
138+
hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty_str}`
139+
140+
hir_typeck_never_type_fallback_flowing_into_unsafe_call = never type fallback affects this call to an `unsafe` function
141+
.help = specify the type explicitly
142+
hir_typeck_never_type_fallback_flowing_into_unsafe_deref = never type fallback affects this raw pointer dereference
143+
.help = specify the type explicitly
144+
hir_typeck_never_type_fallback_flowing_into_unsafe_method = never type fallback affects this call to an `unsafe` method
145+
.help = specify the type explicitly
146+
hir_typeck_never_type_fallback_flowing_into_unsafe_path = never type fallback affects this `unsafe` function
147+
.help = specify the type explicitly
148+
hir_typeck_never_type_fallback_flowing_into_unsafe_union_field = never type fallback affects this union access
149+
.help = specify the type explicitly
150+
151+
hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method ->
152+
[true] {""}
153+
*[other] {" "}in the current scope
154+
}
155+
156+
hir_typeck_no_field_on_type = no field `{$field}` on type `{$ty}`
157+
158+
hir_typeck_no_field_on_variant = no field named `{$field}` on enum variant `{$container}::{$ident}`
159+
hir_typeck_no_field_on_variant_enum = this enum variant...
160+
hir_typeck_no_field_on_variant_field = ...does not have this field
161+
162+
hir_typeck_note_caller_chooses_ty_for_ty_param = the caller chooses a type for `{$ty_param_name}` which can be different from `{$found_ty}`
163+
164+
hir_typeck_note_edition_guide = for more on editions, read https://doc.rust-lang.org/edition-guide
165+
166+
hir_typeck_option_result_asref = use `{$def_path}::as_ref` to convert `{$expected_ty}` to `{$expr_ty}`
167+
hir_typeck_option_result_cloned = use `{$def_path}::cloned` to clone the value inside the `{$def_path}`
168+
hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value inside the `{$def_path}`
169+
170+
hir_typeck_pass_to_variadic_function = can't pass `{$ty}` to variadic function
171+
.suggestion = cast the value to `{$cast_ty}`
172+
.teach_help = certain types, like `{$ty}`, must be casted before passing them to a variadic function, because of arcane ABI rules dictated by the C standard
173+
174+
hir_typeck_ptr_cast_add_auto_to_object = cannot add {$traits_len ->
175+
[1] auto trait {$traits}
176+
*[other] auto traits {$traits}
177+
} to dyn bound via pointer cast
178+
.note = this could allow UB elsewhere
179+
.help = use `transmute` if you're sure this is sound
180+
.label = unsupported cast
181+
182+
hir_typeck_register_type_unstable =
183+
type `{$ty}` cannot be used with this register class in stable
184+
185+
hir_typeck_remove_semi_for_coerce = you might have meant to return the `match` expression
186+
hir_typeck_remove_semi_for_coerce_expr = this could be implicitly returned but it is a statement, not a tail expression
187+
hir_typeck_remove_semi_for_coerce_ret = the `match` arms can conform to this return type
188+
hir_typeck_remove_semi_for_coerce_semi = the `match` is a statement because of this semicolon, consider removing it
189+
hir_typeck_remove_semi_for_coerce_suggestion = remove this semicolon
190+
191+
hir_typeck_replace_comma_with_semicolon = replace the comma with a semicolon to create {$descr}
192+
193+
hir_typeck_return_stmt_outside_of_fn_body =
194+
{$statement_kind} statement outside of function body
195+
.encl_body_label = the {$statement_kind} is part of this body...
196+
.encl_fn_label = ...not the enclosing function body
197+
198+
hir_typeck_rpit_box_return_expr = if you change the return type to expect trait objects, box the returned expressions
199+
200+
hir_typeck_rpit_change_return_type = you could change the return type to be a boxed trait object
201+
202+
hir_typeck_rustcall_incorrect_args =
203+
functions with the "rust-call" ABI must take a single non-self tuple argument
204+
205+
hir_typeck_self_ctor_from_outer_item = can't reference `Self` constructor from outer item
206+
.label = the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference
207+
.suggestion = replace `Self` with the actual type
208+
209+
hir_typeck_slicing_suggestion = consider slicing here
210+
211+
hir_typeck_struct_expr_non_exhaustive =
212+
cannot create non-exhaustive {$what} using struct expression
213+
214+
hir_typeck_suggest_boxing_note = for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
215+
216+
hir_typeck_suggest_boxing_when_appropriate = store this in the heap by calling `Box::new`
217+
218+
hir_typeck_suggest_ptr_null_mut = consider using `core::ptr::null_mut` instead
219+
220+
hir_typeck_supertrait_item_multiple_shadowee = items from several supertraits are shadowed: {$traits}
221+
222+
hir_typeck_supertrait_item_shadowee = item from `{$supertrait}` is shadowed by a subtrait item
223+
224+
hir_typeck_supertrait_item_shadower = item from `{$subtrait}` shadows a supertrait item
225+
226+
hir_typeck_supertrait_item_shadowing = trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait
227+
228+
hir_typeck_trivial_cast = trivial {$numeric ->
229+
[true] numeric cast
230+
*[false] cast
231+
}: `{$expr_ty}` as `{$cast_ty}`
232+
.help = cast can be replaced by coercion; this might require a temporary variable
233+
234+
hir_typeck_union_pat_dotdot = `..` cannot be used in union patterns
235+
236+
hir_typeck_union_pat_multiple_fields = union patterns should have exactly one field
237+
238+
hir_typeck_use_is_empty =
239+
consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything
240+
241+
hir_typeck_yield_expr_outside_of_coroutine =
242+
yield expression outside of coroutine literal

0 commit comments

Comments
 (0)