Skip to content

Commit

Permalink
fix: update proc-macro2, use new span location API where possible (#801)
Browse files Browse the repository at this point in the history
requires latest* rust nightly version

*latest = 2023-06-28 or something
  • Loading branch information
MingweiSamuel committed Jun 30, 2023
1 parent fa5b180 commit 8d3494b
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions hydroflow/tests/surface_warnings.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// TODO(mingwei): fix line numbers in tests
// https://github.com/hydro-project/hydroflow/issues/729
// https://github.com/rust-lang/rust/pull/111571

use std::cell::RefCell;
use std::rc::Rc;

Expand All @@ -22,7 +26,7 @@ macro_rules! test_warnings {
assert_eq!(diagnostics.len(), expecteds.len(), "Wrong number of diagnostics.");
for (expected, diagnostic) in expecteds.iter().zip(diagnostics.iter()) {
let mut diagnostic = diagnostic.clone();
diagnostic.span.line -= __line;
diagnostic.span.line = diagnostic.span.line.saturating_sub(__line);
assert_eq!(expected.to_string(), diagnostic.to_string().replace(__file, "$FILE"));
}

Expand All @@ -39,7 +43,7 @@ fn test_degenerate_union() {
{
source_iter([1, 2, 3]) -> union() -> for_each(|x| result_send.send(x).unwrap());
},
"Warning: `union` should have at least 2 input(s), actually has 1.\n --> $FILE:2:39",
"Warning: `union` should have at least 2 input(s), actually has 1.\n --> $FILE:0:0",
};
df.run_available();

Expand All @@ -52,7 +56,7 @@ fn test_empty_union() {
{
union() -> for_each(|x: usize| println!("{}", x));
},
"Warning: `union` should have at least 2 input(s), actually has 0.\n --> $FILE:2:13",
"Warning: `union` should have at least 2 input(s), actually has 0.\n --> $FILE:0:0",
};
df.run_available();
}
Expand All @@ -65,7 +69,7 @@ fn test_degenerate_tee() {
{
source_iter([1, 2, 3]) -> tee() -> for_each(|x| result_send.send(x).unwrap());
},
"Warning: `tee` should have at least 2 output(s), actually has 1.\n --> $FILE:2:39"
"Warning: `tee` should have at least 2 output(s), actually has 1.\n --> $FILE:0:0"
};
df.run_available();

Expand All @@ -81,7 +85,7 @@ fn test_empty_tee() {
{
source_iter([1, 2, 3]) -> inspect(|&x| output_inner.borrow_mut().push(x)) -> tee();
},
"Warning: `tee` should have at least 2 output(s), actually has 0.\n --> $FILE:2:90",
"Warning: `tee` should have at least 2 output(s), actually has 0.\n --> $FILE:0:0",
};
df.run_available();

Expand All @@ -108,7 +112,7 @@ pub fn test_warped_diamond() {
nodes -> [0]init;
new_node[1] -> map(|n| (n, 'b')) -> [1]init;
},
"Warning: `union` should have at least 2 input(s), actually has 1.\n --> $FILE:3:21",
"Warning: `union` should have at least 2 input(s), actually has 1.\n --> $FILE:0:0",
};
df.run_available();
}
Expand All @@ -133,8 +137,8 @@ pub fn test_warped_diamond_2() {

ntwk = source_iter([4, 5, 6]) -> tee();
},
"Warning: `union` should have at least 2 input(s), actually has 1.\n --> $FILE:3:21",
"Warning: `tee` should have at least 2 output(s), actually has 0.\n --> $FILE:16:46",
"Warning: `union` should have at least 2 input(s), actually has 1.\n --> $FILE:0:0",
"Warning: `tee` should have at least 2 output(s), actually has 0.\n --> $FILE:0:0",
};
hf.run_available();
}
2 changes: 1 addition & 1 deletion hydroflow_datalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ diagnostics = [ "hydroflow_datalog_core/diagnostics" ]
[dependencies]
quote = "1.0.0"
syn = { version = "2.0.0", features = [ "parsing", "extra-traits" ] }
proc-macro2 = "1.0.27"
proc-macro2 = "1.0.57"
proc-macro-crate = "1.1.0"
# Note: If we ever compile this proc macro crate to WASM (e.g., if we are
# building on a WASM host), we may need to turn diagnostics off for WASM if
Expand Down
2 changes: 1 addition & 1 deletion hydroflow_datalog_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ diagnostics = [ "hydroflow_lang/diagnostics" ]
quote = "1.0.0"
slotmap = "1.0.6"
syn = { version = "2.0.0", features = [ "parsing", "extra-traits" ] }
proc-macro2 = "1.0.27"
proc-macro2 = "1.0.57"
proc-macro-crate = "1.1.0"
rust-sitter = "0.3.2"
hydroflow_lang = { path = "../hydroflow_lang", version = "^0.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion hydroflow_lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ diagnostics = []
auto_impl = "1.0.1"
itertools = "0.10" # TODO(mingwei): remove when `iter_intersperse` is stabilized.
prettyplease = { version = "0.2.0", features = [ "verbatim" ] }
proc-macro2 = { version = "1.0.0", features = ["span-locations"] }
proc-macro2 = { version = "1.0.57", features = ["span-locations"] }
quote = "1.0.0"
regex = "1.7.0"
serde = "1.0.1"
Expand Down
18 changes: 7 additions & 11 deletions hydroflow_lang/src/pretty_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
pub struct PrettySpan(pub proc_macro2::Span);
impl std::fmt::Display for PrettySpan {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let span = self.0;

#[cfg(feature = "diagnostics")]
let path = span.unwrap().source_file().path();
let (path, line, column) = (
self.0.unwrap().source_file().path(),
self.0.unwrap().start().line(),
self.0.unwrap().start().column(),
);
#[cfg(feature = "diagnostics")]
let location = path.display();

#[cfg(not(feature = "diagnostics"))]
let location = "unknown";
let (location, line, column) = ("unknown", 0, 0);

write!(
f,
"{}:{}:{}",
location,
span.start().line,
span.start().column
)
write!(f, "{}:{}:{}", location, line, column)
}
}

Expand Down
2 changes: 1 addition & 1 deletion hydroflow_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ diagnostics = [ "hydroflow_lang/diagnostics" ]
# building on a WASM host), we may need to turn diagnostics off for WASM if
# proc_macro2 still does not support WASM.
hydroflow_lang = { path = "../hydroflow_lang", version = "^0.2.0" }
proc-macro2 = "1.0.0"
proc-macro2 = "1.0.57"
proc-macro-crate = "1.1.0"
quote = "1.0.0"
syn = { version = "2.0.0", features = [ "parsing", "extra-traits" ] }
Expand Down
2 changes: 1 addition & 1 deletion multiplatform_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = "A simple attribute macro to combine `#[test]` and `#[wasm_bindgen
proc-macro = true

[dependencies]
proc-macro2 = "1.0"
proc-macro2 = "1.0.57"
quote = "1.0"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion relalg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"
anyhow = "1.0"
datadriven = "0.6.0"
hydroflow = { path = "../hydroflow" }
proc-macro2 = "1.0"
proc-macro2 = "1.0.57"
quote = "1.0"
syn = { version = "2.0.0", features = [ "parsing", "extra-traits" ] }
prettyplease = "0.2.0"
2 changes: 1 addition & 1 deletion website_playground/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ hydroflow_datalog_core = { path = "../hydroflow_datalog_core" }
hydroflow_lang = { path = "../hydroflow_lang" }
hydroflow = { path = "../hydroflow" }
prettyplease = "0.2.0"
proc-macro2 = "1.0"
proc-macro2 = "1.0.57"
quote = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde-wasm-bindgen = "0.4"
Expand Down

0 comments on commit 8d3494b

Please sign in to comment.