Skip to content

Commit cb8534e

Browse files
committed
1. Error correction for "rustc 1.38.0-nightly (c43d03a19 2019-08-14)"
2. Improving the benchmarking example
1 parent ab10f5a commit cb8534e

File tree

10 files changed

+34
-15
lines changed

10 files changed

+34
-15
lines changed

.gitignore

100644100755
File mode changed.

.travis.yml

100644100755
File mode changed.

Cargo.toml

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[package]
22
name = "clucstr"
3-
version = "0.1.7"
3+
version = "1.1.8"
44
authors = ["Денис Котляров <#Ulin Project 18, denis2005991@gmail.com>"]
55
repository = "https://github.com/clucompany/cluCStr.git"
66
edition = "2018"
77

88
license = "Apache-2.0"
99
readme = "README.md"
1010

11-
description = "Safe creation of 'CStr' with zero cost at a compilation stage with check of zero bytes and a possibility of communication of several values."
12-
keywords = ["cstr", "clucstr", "create_cstr", "clucompany"]
11+
description = "Safe creation of CStr with zero cost at the compilation stage with checking for zero bytes and the ability to transfer multiple values."
12+
keywords = ["cstr", "rust-plugin", "create_cstr", "clucompany"]
1313
categories = ["development-tools::ffi"]
1414

1515
[features]

LICENSE

100644100755
File mode changed.

README.md

100644100755
File mode changed.

examples/bench.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11

2-
3-
//RUN cargo bench --example bench
42
#![feature(test)]
5-
63
#![feature(plugin)]
74
#![plugin(clucstr)]
85

@@ -46,4 +43,26 @@ mod tests {
4643
}
4744
});
4845
}
49-
}
46+
}
47+
48+
fn main() {
49+
println!("");
50+
println!("Enter it in the terminal !!");
51+
println!();
52+
println!("=====================");
53+
println!("cargo bench --example bench");
54+
println!("=====================");
55+
}
56+
57+
/*
58+
Compiling clucstr v0.1.7 (/home/pk)
59+
Finished release [optimized] target(s) in 0.40s
60+
Running target/release/examples/bench-99f2dfd5339276ba
61+
62+
running 2 tests
63+
test tests::cstr_macros ... bench: 31 ns/iter (+/- 0)
64+
test tests::cstr_plugin ... bench: 0 ns/iter (+/- 0)
65+
66+
test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out
67+
*/
68+

examples/panic.rs

100644100755
File mode changed.

examples/use.rs

100644100755
File mode changed.

src/lib.rs

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Copyright 2019 #UlinProject Denis Kotlyarov (Денис Котляров)
169169
Licensed under the Apache License, Version 2.0
170170
*/
171171

172-
172+
#![feature(test)]
173173
#![feature(plugin_registrar)]
174174
#![feature(rustc_private)]
175175

@@ -192,3 +192,4 @@ macro_rules! cstr {
192192
($s:expr) => {unimplemented!()};
193193
() => {unimplemented!()};
194194
}
195+

src/nightly.rs

100644100755
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use syntax::source_map::Span;
33
use syntax::tokenstream::TokenTree;
44
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
5-
use syntax::ext::build::AstBuilder;
65
use rustc_plugin::Registry;
76
use syntax::ast::ExprKind;
87
use syntax::ast::LitKind;
@@ -15,9 +14,9 @@ use syntax::ast::BlockCheckMode;
1514
use syntax::ast::UnsafeSource;
1615
use syntax::ast::Block;
1716
use syntax::ptr::P;
18-
use syntax::parse::token::Token;
1917
use syntax::ast;
2018
use syntax::ast::IntTy;
19+
use syntax::parse::token::TokenKind;
2120

2221

2322
#[doc(hidden)]
@@ -27,7 +26,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
2726
}
2827

2928
#[doc(hidden)]
30-
pub fn cstr(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + 'static> {
29+
pub fn cstr(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<dyn MacResult + 'static> {
3130
let mut parser = cx.new_parser_from_tts(args);
3231

3332
let mut args_len = args.len();
@@ -36,12 +35,12 @@ pub fn cstr(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + '
3635
match parser.parse_expr() {
3736
Ok(a) => array_expr.push(a),
3837
Err(_e) => {
39-
cx.span_err(parser.span, "incorrect data, was expected: &[u8], str, u8, i8");
38+
cx.span_err(parser.prev_span, "incorrect data, was expected: &[u8], str, u8, i8");
4039
return DummyResult::any(sp);
4140
}
4241
}
4342
let mut count_elements = 1;
44-
while parser.eat(&Token::Comma) {
43+
while parser.eat(&TokenKind::Comma) {
4544
args_len -= 1;
4645
//del comma
4746

@@ -51,13 +50,13 @@ pub fn cstr(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + '
5150
array_expr.push(a);
5251
},
5352
Err(_e) => {
54-
cx.span_err(parser.span, "incorrect data, was expected: &[u8], str, u8, i8");
53+
cx.span_err(parser.prev_span, "incorrect data, was expected: &[u8], str, u8, i8");
5554
return DummyResult::any(sp);
5655
},
5756
}
5857
}
5958
if count_elements != args_len {
60-
cx.span_err(parser.span, "It was expected ',' or closing of a macro.");
59+
cx.span_err(parser.prev_span, "It was expected ',' or closing of a macro.");
6160
return DummyResult::any(sp);
6261
}
6362
}

0 commit comments

Comments
 (0)