Skip to content

Commit 44b31f7

Browse files
authored
Merge pull request #223 from jsturtevant/bump-rust-version
Bump rust version to resolve builds
2 parents 6f12d9c + 486b4e8 commit 44b31f7

File tree

10 files changed

+44
-49
lines changed

10 files changed

+44
-49
lines changed

.github/workflows/bvt.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ jobs:
1212
uses: actions/checkout@v3
1313
- name: Check
1414
run: |
15-
make deps
16-
make check
17-
make -C compiler check
18-
make -C ttrpc-codegen check
15+
make check-all
1916
2017
make:
2118
name: Build
@@ -28,7 +25,6 @@ jobs:
2825
uses: actions/checkout@v3
2926
- name: Build
3027
run: |
31-
make deps
3228
make
3329
make -C compiler
3430
make -C ttrpc-codegen

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ readme = "README.md"
99
repository = "https://github.com/containerd/ttrpc-rust"
1010
homepage = "https://github.com/containerd/ttrpc-rust"
1111
description = "A Rust version of ttrpc."
12+
rust-version = "1.70"
1213

1314
[dependencies]
1415
protobuf = { version = "3.1.0" }

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
RUST_VERSION = 1.66
2-
31
all: debug test
42

53
#
@@ -35,8 +33,8 @@ check:
3533
cargo fmt --all -- --check
3634
cargo clippy --all-targets --all-features -- -D warnings
3735

38-
.PHONY: deps
39-
deps:
40-
rustup install $(RUST_VERSION)
41-
rustup default $(RUST_VERSION)
42-
rustup component add rustfmt clippy
36+
.PHONY: check-all
37+
check-all:
38+
$(MAKE) check
39+
$(MAKE) -C compiler check
40+
$(MAKE) -C ttrpc-codegen check

compiler/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a> Iterator for NameSpliter<'a> {
4848
let mut meet_lower = false;
4949
for i in self.pos..self.name.len() {
5050
let c = self.name[i];
51-
if (b'A'..=b'Z').contains(&c) {
51+
if c.is_ascii_uppercase() {
5252
if meet_lower {
5353
// So it should be AaA or aaA
5454
pos = i;

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel="1.77.0"
3+
profile="default"
4+
components=["rustfmt", "clippy"]

src/asynchronous/shutdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ mod test {
305305
});
306306
notifier.shutdown();
307307
// Elapsed
308-
assert!(matches!(notifier.wait_all_exit().await, Err(_)));
308+
assert!(notifier.wait_all_exit().await.is_err());
309309
task.await.unwrap();
310310
}
311311
}

src/sync/sys/windows/net.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl PipeListener {
112112
let res = unsafe {GetOverlappedResult(np.named_pipe, ol.as_mut_ptr(), &mut bytes_transfered, WAIT_FOR_EVENT) };
113113
match res {
114114
0 => {
115-
return Err(io::Error::last_os_error());
115+
Err(io::Error::last_os_error())
116116
}
117117
_ => {
118118
if let Some(shutdown_signal) = self.handle_shutdown(&np) {
@@ -129,10 +129,10 @@ impl PipeListener {
129129
Ok(Some(np))
130130
}
131131
e => {
132-
return Err(io::Error::new(
132+
Err(io::Error::new(
133133
io::ErrorKind::Other,
134134
format!("failed to connect pipe: {:?}", e),
135-
));
135+
))
136136
}
137137
}
138138
}
@@ -165,12 +165,12 @@ impl PipeListener {
165165
// https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights
166166
match unsafe { CreateNamedPipeW(name.as_ptr(), open_mode, PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS, PIPE_UNLIMITED_INSTANCES, PIPE_BUFFER_SIZE, PIPE_BUFFER_SIZE, 0, std::ptr::null_mut())} {
167167
INVALID_HANDLE_VALUE => {
168-
return Err(io::Error::last_os_error())
168+
Err(io::Error::last_os_error())
169169
}
170170
h => {
171-
return Ok(h)
171+
Ok(h)
172172
},
173-
};
173+
}
174174
}
175175

176176
pub fn close(&self) -> Result<()> {
@@ -208,8 +208,8 @@ impl PipeConnection {
208208
let write_event = create_event()?;
209209
Ok(PipeConnection {
210210
named_pipe: h,
211-
read_event: read_event,
212-
write_event: write_event,
211+
read_event,
212+
write_event,
213213
})
214214
}
215215

@@ -236,15 +236,15 @@ impl PipeConnection {
236236
let res = unsafe {GetOverlappedResult(self.named_pipe, ol.as_mut_ptr(), &mut bytes_transfered, WAIT_FOR_EVENT) };
237237
match res {
238238
0 => {
239-
return Err(handle_windows_error(io::Error::last_os_error()))
239+
Err(handle_windows_error(io::Error::last_os_error()))
240240
}
241241
_ => {
242-
return Ok(bytes_transfered as usize)
242+
Ok(bytes_transfered as usize)
243243
}
244244
}
245245
}
246246
ref e => {
247-
return Err(Error::Others(format!("failed to read from pipe: {:?}", e)))
247+
Err(Error::Others(format!("failed to read from pipe: {:?}", e)))
248248
}
249249
}
250250
}
@@ -267,15 +267,15 @@ impl PipeConnection {
267267
let res = unsafe {GetOverlappedResult(self.named_pipe, ol.as_mut_ptr(), &mut bytes_transfered, WAIT_FOR_EVENT) };
268268
match res {
269269
0 => {
270-
return Err(handle_windows_error(io::Error::last_os_error()))
270+
Err(handle_windows_error(io::Error::last_os_error()))
271271
}
272272
_ => {
273-
return Ok(bytes_transfered as usize)
273+
Ok(bytes_transfered as usize)
274274
}
275275
}
276276
}
277277
ref e => {
278-
return Err(Error::Others(format!("failed to write to pipe: {:?}", e)))
278+
Err(Error::Others(format!("failed to write to pipe: {:?}", e)))
279279
}
280280
}
281281
}
@@ -346,10 +346,10 @@ impl ClientConnection {
346346
.custom_flags(FILE_FLAG_OVERLAPPED);
347347
match opts.open(self.address.as_str()) {
348348
Ok(file) => {
349-
return PipeConnection::new(file.into_raw_handle() as isize)
349+
PipeConnection::new(file.into_raw_handle() as isize)
350350
}
351351
Err(e) => {
352-
return Err(handle_windows_error(e))
352+
Err(handle_windows_error(e))
353353
}
354354
}
355355
}
@@ -383,7 +383,7 @@ mod test {
383383
let client = ClientConnection::new("non_existent_pipe");
384384
match client.get_pipe_connection() {
385385
Ok(_) => {
386-
assert!(false, "should not be able to get a connection to a non existent pipe");
386+
panic!("should not be able to get a connection to a non existent pipe");
387387
}
388388
Err(e) => {
389389
assert_eq!(e, Error::Windows(ERROR_FILE_NOT_FOUND as i32));
@@ -404,10 +404,10 @@ mod test {
404404
// pipe is working
405405
}
406406
Ok(None) => {
407-
assert!(false, "should get a working pipe")
407+
panic!("should get a working pipe")
408408
}
409409
Err(e) => {
410-
assert!(false, "should not get error {}", e.to_string())
410+
panic!("should not get error {}", e)
411411
}
412412
}
413413
});
@@ -425,7 +425,7 @@ mod test {
425425
let quit_flag = Arc::new(AtomicBool::new(false));
426426
match listener_server.accept(&quit_flag) {
427427
Ok(_) => {
428-
assert!(false, "should not get pipe on close")
428+
panic!("should not get pipe on close")
429429
}
430430
Err(e) => {
431431
assert_eq!(e.to_string(), "closing pipe")

ttrpc-codegen/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(dead_code)]
12
//! API to generate .rs files for ttrpc from protobuf
23
//!
34
//!

ttrpc-codegen/src/model.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@ use crate::str_lit::StrLit;
88
use protobuf_support::lexer::float;
99

1010
/// Protobox syntax
11-
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
11+
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
1212
pub enum Syntax {
1313
/// Protobuf syntax [2](https://developers.google.com/protocol-buffers/docs/proto) (default)
14+
#[default]
1415
Proto2,
1516
/// Protobuf syntax [3](https://developers.google.com/protocol-buffers/docs/proto3)
1617
Proto3,
1718
}
1819

19-
impl Default for Syntax {
20-
fn default() -> Syntax {
21-
Syntax::Proto2
22-
}
23-
}
24-
2520
/// A field rule
2621
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
2722
pub enum Rule {

ttrpc-codegen/src/parser.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,11 @@ impl<'a> Lexer<'a> {
387387

388388
// capitalLetter = "A" … "Z"
389389
fn _next_capital_letter_opt(&mut self) -> Option<char> {
390-
self.next_char_if(|c| ('A'..='Z').contains(&c))
390+
self.next_char_if(|c| c.is_ascii_uppercase())
391391
}
392392

393393
fn is_ascii_alphanumeric(c: char) -> bool {
394-
('a'..='z').contains(&c) || ('A'..='Z').contains(&c) || ('0'..='9').contains(&c)
394+
c.is_ascii_lowercase() || c.is_ascii_uppercase() || c.is_ascii_digit()
395395
}
396396

397397
fn next_ident_part(&mut self) -> Option<char> {
@@ -417,7 +417,7 @@ impl<'a> Lexer<'a> {
417417
// Integer literals
418418

419419
fn is_ascii_hexdigit(c: char) -> bool {
420-
('0'..='9').contains(&c) || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
420+
c.is_ascii_digit() || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
421421
}
422422

423423
// hexLit = "0" ( "x" | "X" ) hexDigit { hexDigit }
@@ -433,7 +433,7 @@ impl<'a> Lexer<'a> {
433433
}
434434

435435
fn is_ascii_digit(c: char) -> bool {
436-
('0'..='9').contains(&c)
436+
c.is_ascii_digit()
437437
}
438438

439439
// decimalLit = ( "1" … "9" ) { decimalDigit }
@@ -458,7 +458,7 @@ impl<'a> Lexer<'a> {
458458
fn next_hex_digit(&mut self) -> ParserResult<u32> {
459459
let mut clone = *self;
460460
let r = match clone.next_char()? {
461-
c if ('0'..='9').contains(&c) => c as u32 - b'0' as u32,
461+
c if c.is_ascii_digit() => c as u32 - b'0' as u32,
462462
c if ('A'..='F').contains(&c) => c as u32 - b'A' as u32 + 10,
463463
c if ('a'..='f').contains(&c) => c as u32 - b'a' as u32 + 10,
464464
_ => return Err(ParserError::ExpectHexDigit),
@@ -482,7 +482,7 @@ impl<'a> Lexer<'a> {
482482
fn next_decimal_digit(&mut self) -> ParserResult<u32> {
483483
let mut clone = *self;
484484
let r = match clone.next_char()? {
485-
c if ('0'..='9').contains(&c) => c as u32 - '0' as u32,
485+
c if c.is_ascii_digit() => c as u32 - '0' as u32,
486486
_ => return Err(ParserError::ExpectDecDigit),
487487
};
488488
*self = clone;
@@ -492,7 +492,7 @@ impl<'a> Lexer<'a> {
492492
// decimals = decimalDigit { decimalDigit }
493493
fn next_decimal_digits(&mut self) -> ParserResult<()> {
494494
self.next_decimal_digit()?;
495-
self.take_while(|c| ('0'..='9').contains(&c));
495+
self.take_while(|c| c.is_ascii_digit());
496496
Ok(())
497497
}
498498

@@ -1029,7 +1029,7 @@ impl<'a> Parser<'a> {
10291029
}
10301030

10311031
fn is_ascii_uppercase(c: char) -> bool {
1032-
('A'..='Z').contains(&c)
1032+
c.is_ascii_uppercase()
10331033
}
10341034

10351035
// groupName = capitalLetter { letter | decimalDigit | "_" }

0 commit comments

Comments
 (0)