Skip to content

Commit cc349e9

Browse files
authored
Merge pull request #1576 from N1ark/consts-rework-6
Make `ConstantExprKind::Str` mean `str` instead of `&str`
2 parents 293a1a7 + 373d840 commit cc349e9

66 files changed

Lines changed: 481 additions & 462 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎charon-ml/src/CharonVersion.ml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(* This is an automatically generated file, generated from `charon/Cargo.toml`. *)
22
(* To re-generate this file, rune `make` in the root directory *)
3-
let supported_charon_version = "0.1.300"
3+
let supported_charon_version = "0.1.301"

‎charon-ml/src/generated/Generated_FullAst.ml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ and cli_options = {
299299
function, as an evaluated value, or as raw bytes. This is always
300300
best-effort: in some cases we only get the evaluated constant, and in
301301
others we cannot evaluate the constant and keep the initializer. *)
302-
unsized_strings : bool;
303-
(** Replace string literal constants with a constant u8 array that gets
304-
unsized, expliciting the fact a string constant has a hidden
305-
reference. *)
306302
reconstruct_fallible_operations : bool;
307303
(** Replace "bound checks followed by UB-on-overflow operation" with the
308304
corresponding panic-on-overflow operation. This loses unwinding

‎charon-ml/src/generated/Generated_OfJson.ml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,6 @@ and cli_options_of_json (ctx : of_json_ctx) (js : json) :
25782578
("raw_consts", raw_consts);
25792579
("inline_anon_consts", inline_anon_consts);
25802580
("consts", consts);
2581-
("unsized_strings", unsized_strings);
25822581
("reconstruct_fallible_operations", reconstruct_fallible_operations);
25832582
("reconstruct_panic_calls", reconstruct_panic_calls);
25842583
("reconstruct_asserts", reconstruct_asserts);
@@ -2658,7 +2657,6 @@ and cli_options_of_json (ctx : of_json_ctx) (js : json) :
26582657
let* raw_consts = bool_of_json ctx raw_consts in
26592658
let* inline_anon_consts = bool_of_json ctx inline_anon_consts in
26602659
let* consts = option_of_json const_handling_of_json ctx consts in
2661-
let* unsized_strings = bool_of_json ctx unsized_strings in
26622660
let* reconstruct_fallible_operations =
26632661
bool_of_json ctx reconstruct_fallible_operations
26642662
in
@@ -2735,7 +2733,6 @@ and cli_options_of_json (ctx : of_json_ctx) (js : json) :
27352733
raw_consts;
27362734
inline_anon_consts;
27372735
consts;
2738-
unsized_strings;
27392736
reconstruct_fallible_operations;
27402737
reconstruct_panic_calls;
27412738
reconstruct_asserts;

‎charon-ml/src/generated/Generated_OfPostcard.ml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,6 @@ and cli_options_of_postcard (ctx : of_postcard_ctx) (st : postcard_state) :
21962196
let* raw_consts = bool_of_postcard ctx st in
21972197
let* inline_anon_consts = bool_of_postcard ctx st in
21982198
let* consts = option_of_postcard const_handling_of_postcard ctx st in
2199-
let* unsized_strings = bool_of_postcard ctx st in
22002199
let* reconstruct_fallible_operations = bool_of_postcard ctx st in
22012200
let* reconstruct_panic_calls = bool_of_postcard ctx st in
22022201
let* reconstruct_asserts = bool_of_postcard ctx st in
@@ -2265,7 +2264,6 @@ and cli_options_of_postcard (ctx : of_postcard_ctx) (st : postcard_state) :
22652264
raw_consts;
22662265
inline_anon_consts;
22672266
consts;
2268-
unsized_strings;
22692267
reconstruct_fallible_operations;
22702268
reconstruct_panic_calls;
22712269
reconstruct_asserts;

‎charon-ml/src/generated/Generated_Types.ml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ and constant_expr_kind =
379379
(** A raw pointer to a constant place.
380380
381381
This is eliminated inside functions if [--raw-consts] is off. *)
382-
| CStr of string (** [str] value. *)
382+
| CStr of string
383+
(** [str] value. This represents an unsized value of type [str] (and not
384+
[&str]). *)
383385
| CByteStr of int list (** Byte string value. *)
384386
| CFnDef of fn_ptr
385387
(** ZST constant corresponding to the unique value of the type of a

‎charon/Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎charon/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tracing = { version = "0.1", features = ["max_level_trace"] }
2828

2929
[package]
3030
name = "charon"
31-
version = "0.1.300"
31+
version = "0.1.301"
3232
authors.workspace = true
3333
edition.workspace = true
3434
license.workspace = true

‎charon/rustc_const_uneval/src/lib.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ pub struct Config {
3030
/// Whether to refer to anonymous allocations (e.g. the bytes of `b"foo"`) as globals, or to
3131
/// inline their contents at each use.
3232
pub anon_allocs_as_globals: bool,
33-
/// Whether to view string data as `[u8; N]`, and make it a global.
34-
pub unsized_strings: bool,
3533
}
3634

3735
/// How we view an anonymous allocation

‎charon/rustc_const_uneval/src/pointer.rs‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,9 @@ impl<'tcx> ConstReader<'tcx> {
207207
}
208208

209209
/// Whether we view a value of the unsized type `ty` at the sized type it was unsized from: a
210-
/// slice or `dyn Trait` value is, and so is a `str` with `unsized_strings`.
210+
/// slice or `dyn Trait` value is, but `str` is not since there's no "fixed-sized `str`" type.
211211
pub(crate) fn is_viewed_unsized_from(&self, ty: Ty<'tcx>) -> bool {
212-
match ty.kind() {
213-
ty::Slice(_) | ty::Dynamic(..) => true,
214-
ty::Str => self.config.unsized_strings,
215-
_ => false,
216-
}
212+
matches!(ty.kind(), ty::Slice(_) | ty::Dynamic(..))
217213
}
218214

219215
/// Express `place`, located `offset` bytes into `global`, as projections from the global, aiming

‎charon/src/ast/bodies/values.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum ConstantExprKind {
4545
///
4646
/// This is eliminated inside functions if `--raw-consts` is off.
4747
Ptr(RefKind, GlobalPlace, Option<UnsizingMetadata>),
48-
/// `str` value.
48+
/// `str` value. This represents an unsized value of type `str` (and not `&str`).
4949
Str(String),
5050
/// Byte string value.
5151
ByteStr(Vec<u8>),

0 commit comments

Comments
 (0)