Skip to content

Commit f88949a

Browse files
author
Paolo Tranquilli
committed
Rust: emit Const bodies in library mode
1 parent 1110fea commit f88949a

File tree

18 files changed

+16
-88
lines changed

18 files changed

+16
-88
lines changed

rust/ast-generator/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn get_additional_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
262262
"FormatArgsExpr" => vec![FieldInfo::list("args", "FormatArgsArg")],
263263
"ArgList" => vec![FieldInfo::list("args", "Expr")],
264264
"Fn" => vec![FieldInfo::body("body", "BlockExpr")],
265-
"Const" => vec![FieldInfo::body("body", "Expr")],
265+
"Const" => vec![FieldInfo::optional("body", "Expr")],
266266
"Static" => vec![FieldInfo::body("body", "Expr")],
267267
"Param" => vec![FieldInfo::body("pat", "Pat")],
268268
"ClosureExpr" => vec![FieldInfo::optional("body", "Expr")],

rust/downgrades/aa9a0bda17c76b804ad9e108d43da15f6beaf2a7/old.dbscheme renamed to rust/downgrades/4c9e5cb1500c9a87fedcb13a125cb17fa2b21523/old.dbscheme

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,11 +2816,6 @@ const_visibilities(
28162816
int visibility: @visibility ref
28172817
);
28182818

2819-
#keyset[id]
2820-
const_has_implementation(
2821-
int id: @const ref
2822-
);
2823-
28242819
enums(
28252820
unique int id: @enum
28262821
);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
description: Remove `function_has_implementation` table
2+
compatibility: full
3+
4+
function_has_implementation.rel: delete

rust/downgrades/aa9a0bda17c76b804ad9e108d43da15f6beaf2a7/upgrade.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

rust/extractor/src/generated/.generated.list

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

rust/extractor/src/generated/top.rs

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/extractor/src/translate/base.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ macro_rules! post_emit {
8484
(PathSegment, $self:ident, $node:ident, $label:ident) => {
8585
$self.extract_types_from_path_segment($node, $label.into());
8686
};
87-
(Const, $self:ident, $node:ident, $label:ident) => {
88-
$self.emit_const_has_implementation($node, $label);
89-
};
9087
($($_:tt)*) => {};
9188
}
9289

@@ -775,14 +772,4 @@ impl<'a> Translator<'a> {
775772
generated::Function::emit_has_implementation(label, &mut self.trap.writer);
776773
}
777774
}
778-
779-
pub(crate) fn emit_const_has_implementation(
780-
&mut self,
781-
node: &ast::Const,
782-
label: Label<generated::Const>,
783-
) {
784-
if node.body().is_some() {
785-
generated::Const::emit_has_implementation(label, &mut self.trap.writer);
786-
}
787-
}
788775
}

rust/extractor/src/translate/generated.rs

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

rust/ql/.generated.list

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/elements/internal/generated/Const.qll

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/rust.dbscheme

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,11 +2816,6 @@ const_visibilities(
28162816
int visibility: @visibility ref
28172817
);
28182818

2819-
#keyset[id]
2820-
const_has_implementation(
2821-
int id: @const ref
2822-
);
2823-
28242819
enums(
28252820
unique int id: @enum
28262821
);

rust/ql/lib/upgrades/a1005655e9efc9f67d3aa2b7a3128f6b80d405a9/rust.dbscheme

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,11 +2816,6 @@ const_visibilities(
28162816
int visibility: @visibility ref
28172817
);
28182818

2819-
#keyset[id]
2820-
const_has_implementation(
2821-
int id: @const ref
2822-
);
2823-
28242819
enums(
28252820
unique int id: @enum
28262821
);
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
description: Add `function_has_implementation` and `const_has_implementation` tables
1+
description: Add `function_has_implementation` table
22
compatibility: backwards
33

4-
function_has_implementation.rel: run upgrade.ql new_function_has_implementation
5-
const_has_implementation.rel: run upgrade.ql new_const_has_implementation
4+
function_has_implementation.rel: reorder function_bodies.rel (@function id, @block_expr body) id

rust/ql/lib/upgrades/a1005655e9efc9f67d3aa2b7a3128f6b80d405a9/upgrade.ql

Lines changed: 0 additions & 7 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/Const/Const.ql

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/schema/annotations.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,10 +951,6 @@ class _:
951951
todo!()
952952
```
953953
"""
954-
has_implementation: predicate | doc("this constant has an implementation") | desc("""
955-
This is the same as `hasBody` for source code, but for library code (for which we always skip
956-
the body), this will hold when the body was present in the original code.
957-
""") | rust.detach
958954

959955

960956
@annotate(ConstArg)

0 commit comments

Comments
 (0)