rust-test-generator-Update-dependencies.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From b78145bfb6a6f81425dfd6fbacb9c03624e79b2c Mon Sep 17 00:00:00 2001
  2. From: Sven Neumann <sven@svenfoo.org>
  3. Date: Fri, 16 Oct 2020 18:03:24 +0200
  4. Subject: [PATCH] Port to recent versions of the quote, syn and proc_macro2
  5. crates
  6. Upstream: <https://github.com/frehberg/test-generator/pull/9>.
  7. Rebased locally for 0.3.
  8. ---
  9. Cargo.toml.orig | 6 +++---
  10. src/lib.rs | 16 ++++++++--------
  11. 2 files changed, 11 insertions(+), 11 deletions(-)
  12. diff --git a/Cargo.toml.orig b/Cargo.toml.orig
  13. index ac14d48..e7b45b0 100644
  14. --- a/Cargo.toml.orig
  15. +++ b/Cargo.toml.orig
  16. @@ -16,6 +16,6 @@ proc-macro = true
  17. [dependencies]
  18. glob = "^0.3"
  19. -quote = "0.6"
  20. -syn = { version="^0.15", features=["full"] }
  21. -proc-macro2 = "^0.4"
  22. +quote = "1.0"
  23. +syn = { version="1.0", features=["full"] }
  24. +proc-macro2 = "1.0"
  25. diff --git a/src/lib.rs b/src/lib.rs
  26. index 7428d02..176592c 100644
  27. --- a/src/lib.rs
  28. +++ b/src/lib.rs
  29. @@ -185,8 +185,8 @@ pub fn test_resources(attrs: TokenStream, func: TokenStream) -> TokenStream {
  30. Lit::Byte(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  31. Lit::ByteStr(_) => panic!("expected string parameter, got byte-string"),
  32. Lit::Char(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  33. - Lit::Int(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  34. - Lit::Float(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  35. + Lit::Int(l) => panic!(format!("expected string parameter, got '{}'", l)),
  36. + Lit::Float(l) => panic!(format!("expected string parameter, got '{}'", l)),
  37. _ => panic!("expected string parameter"),
  38. };
  39. @@ -195,7 +195,7 @@ pub fn test_resources(attrs: TokenStream, func: TokenStream) -> TokenStream {
  40. let func_ast: ItemFn = syn::parse(func)
  41. .expect("failed to parse tokens as a function");
  42. - let func_ident = func_ast.ident;
  43. + let func_ident = func_ast.sig.ident;
  44. let paths: Paths = glob(&pattern).expect(&format!("No such file or directory {}", &pattern));
  45. @@ -264,8 +264,8 @@ pub fn bench_resources(attrs: TokenStream, func: TokenStream) -> TokenStream {
  46. Lit::Byte(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  47. Lit::ByteStr(_) => panic!("expected string parameter, got byte-string"),
  48. Lit::Char(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  49. - Lit::Int(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  50. - Lit::Float(l) => panic!(format!("expected string parameter, got '{}'", &l.value())),
  51. + Lit::Int(l) => panic!(format!("expected string parameter, got '{}'", l)),
  52. + Lit::Float(l) => panic!(format!("expected string parameter, got '{}'", l)),
  53. _ => panic!("expected string parameter"),
  54. };
  55. @@ -274,7 +274,7 @@ pub fn bench_resources(attrs: TokenStream, func: TokenStream) -> TokenStream {
  56. let func_ast: ItemFn = syn::parse(func)
  57. .expect("failed to parse tokens as a function");
  58. - let func_ident = func_ast.ident;
  59. + let func_ident = func_ast.sig.ident;
  60. let paths: Paths = glob(&pattern).expect(&format!("No such file or directory {}", &pattern));
  61. @@ -400,7 +400,7 @@ fn expr_stringified(expr: &Expr, int_as_hex: bool) -> String {
  62. attrs: _,
  63. } => match litval {
  64. Lit::Int(lit) => {
  65. - let val = lit.value();
  66. + let val: u64 = lit.base10_parse().unwrap();
  67. if int_as_hex {
  68. // if u8-range, use two digits, otherwise 16
  69. if val > 255 {
  70. @@ -422,7 +422,7 @@ fn expr_stringified(expr: &Expr, int_as_hex: bool) -> String {
  71. val
  72. }
  73. Lit::Float(lit) => {
  74. - let val = lit.value();
  75. + let val: f64 = lit.base10_parse().unwrap();
  76. format!("{}", val)
  77. }
  78. _ => panic!(),