Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary fix for derived code (fixes #78) #94

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion frontend/exporter/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,49 @@ pub fn inline_macro_invocations<'t, S: BaseState<'t>>(
vis_span: rustc_span::DUMMY_SP.sinto(s),
}]
}
_ => items.map(|item| item.sinto(s)).collect(),
_ => items
// TODO: this filter is temporary, and should be replaced by something better, see issue #88
.filter(|item| {
mod clippy_utils {
/* This is stolen from `clippy_utils`. TODO: use `clippy_utils` directly.
(I was not able to understand how to make cargo to install it) */
use rustc_ast::ast;
use rustc_hir::HirId;
use rustc_middle::ty::TyCtxt;
use rustc_span::{symbol::sym, Symbol};
fn has_attr(attrs: &[ast::Attribute], symbol: Symbol) -> bool {
attrs.iter().any(|attr| attr.has_name(symbol))
}
fn any_parent_has_attr(
tcx: TyCtxt<'_>,
node: HirId,
symbol: Symbol,
) -> bool {
let map = &tcx.hir();
let mut prev_enclosing_node = None;
let mut enclosing_node = node;
while Some(enclosing_node) != prev_enclosing_node {
if has_attr(map.attrs(enclosing_node), symbol) {
return true;
}
prev_enclosing_node = Some(enclosing_node);
enclosing_node = map.get_parent_item(enclosing_node).into();
}

false
}

pub fn any_parent_is_automatically_derived(
tcx: TyCtxt<'_>,
node: HirId,
) -> bool {
any_parent_has_attr(tcx, node, sym::automatically_derived)
}
}
!clippy_utils::any_parent_is_automatically_derived(tcx, item.hir_id())
})
.map(|item| item.sinto(s))
.collect(),
})
.flatten()
.collect()
Expand Down
11 changes: 7 additions & 4 deletions test-harness/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,17 @@ impl Test {
lazy_static! {
// Regex [TIME] matches compile times
static ref TIME: Regex = Regex::new(r"\bin \d+(\.\d+)?s\b").unwrap();
static ref LOCK: Regex = Regex::new(r"Blocking waiting for \w+ lock on (the registry index|build directory|package cache)").unwrap();
}
TIME.replace_all(
s.replace(r"\", "/")
.replace(&workspace, "WORKSPACE_ROOT")
.replace("Blocking waiting for file lock on build directory", "")
.trim(),
LOCK.replace_all(
&s.replace(r"\", "/").replace(&workspace, "WORKSPACE_ROOT"),
"",
)
.as_ref(),
"in XXs",
)
.trim()
.to_string()
};
let serr = cleanup(String::from_utf8_lossy(&out.stderr).to_string());
Expand Down
2 changes: 1 addition & 1 deletion tests/enum-struct-variant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
[dependencies]

[package.metadata.circus-tests]
into."fstar+coq" = {broken = true, snapshot = "none"}
into."fstar+coq" = {broken = false, snapshot = "none"}