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

Bump rust version to resolve builds #223

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 1 addition & 5 deletions .github/workflows/bvt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ jobs:
uses: actions/checkout@v3
- name: Check
run: |
make deps
make check
make -C compiler check
make -C ttrpc-codegen check
make check-all

make:
name: Build
Expand All @@ -28,7 +25,6 @@ jobs:
uses: actions/checkout@v3
- name: Build
run: |
make deps
make
make -C compiler
make -C ttrpc-codegen
Expand Down
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
RUST_VERSION = 1.66

all: debug test

#
Expand Down Expand Up @@ -35,8 +33,8 @@ check:
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings

.PHONY: deps
deps:
rustup install $(RUST_VERSION)
rustup default $(RUST_VERSION)
rustup component add rustfmt clippy
.PHONY: check-all
check-all:
$(MAKE) check
$(MAKE) -C compiler check
$(MAKE) -C ttrpc-codegen check
2 changes: 1 addition & 1 deletion compiler/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'a> Iterator for NameSpliter<'a> {
let mut meet_lower = false;
for i in self.pos..self.name.len() {
let c = self.name[i];
if (b'A'..=b'Z').contains(&c) {
if c.is_ascii_uppercase() {
if meet_lower {
// So it should be AaA or aaA
pos = i;
Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel="1.77.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that it best not to pin in one version?
Or using https://doc.rust-lang.org/cargo/reference/manifest.html?#the-rust-version-field

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was locked to a version in a previous PR: #179. Whic is causing the failures in #219

Using the toolchain file doesn't force that version, it just determines the toolchain to use if not already overridden. It be overridden via other commands: https://rust-lang.github.io/rustup/overrides.html.

I don't think the rust-version field helps with tool chain installation, but we can certainly set it as a minimal version. Any ideas on the what version it should be set to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the min rust-version

Copy link
Collaborator

@wllenyj wllenyj Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.
The minnest version is the same as home v0.5.9.

error: package `home v0.5.9` cannot be built because it requires rustc 1.70.0 or newer, while the currently active rustc version is 1.66.1

profile="default"
components=["rustfmt", "clippy"]
2 changes: 1 addition & 1 deletion src/asynchronous/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ mod test {
});
notifier.shutdown();
// Elapsed
assert!(matches!(notifier.wait_all_exit().await, Err(_)));
assert!(notifier.wait_all_exit().await.is_err());
task.await.unwrap();
}
}
40 changes: 20 additions & 20 deletions src/sync/sys/windows/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl PipeListener {
let res = unsafe {GetOverlappedResult(np.named_pipe, ol.as_mut_ptr(), &mut bytes_transfered, WAIT_FOR_EVENT) };
match res {
0 => {
return Err(io::Error::last_os_error());
Err(io::Error::last_os_error())
}
_ => {
if let Some(shutdown_signal) = self.handle_shutdown(&np) {
Expand All @@ -129,10 +129,10 @@ impl PipeListener {
Ok(Some(np))
}
e => {
return Err(io::Error::new(
Err(io::Error::new(
io::ErrorKind::Other,
format!("failed to connect pipe: {:?}", e),
));
))
}
}
}
Expand Down Expand Up @@ -165,12 +165,12 @@ impl PipeListener {
// https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights
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())} {
INVALID_HANDLE_VALUE => {
return Err(io::Error::last_os_error())
Err(io::Error::last_os_error())
}
h => {
return Ok(h)
Ok(h)
},
};
}
}

pub fn close(&self) -> Result<()> {
Expand Down Expand Up @@ -208,8 +208,8 @@ impl PipeConnection {
let write_event = create_event()?;
Ok(PipeConnection {
named_pipe: h,
read_event: read_event,
write_event: write_event,
read_event,
write_event,
})
}

Expand All @@ -236,15 +236,15 @@ impl PipeConnection {
let res = unsafe {GetOverlappedResult(self.named_pipe, ol.as_mut_ptr(), &mut bytes_transfered, WAIT_FOR_EVENT) };
match res {
0 => {
return Err(handle_windows_error(io::Error::last_os_error()))
Err(handle_windows_error(io::Error::last_os_error()))
}
_ => {
return Ok(bytes_transfered as usize)
Ok(bytes_transfered as usize)
}
}
}
ref e => {
return Err(Error::Others(format!("failed to read from pipe: {:?}", e)))
Err(Error::Others(format!("failed to read from pipe: {:?}", e)))
}
}
}
Expand All @@ -267,15 +267,15 @@ impl PipeConnection {
let res = unsafe {GetOverlappedResult(self.named_pipe, ol.as_mut_ptr(), &mut bytes_transfered, WAIT_FOR_EVENT) };
match res {
0 => {
return Err(handle_windows_error(io::Error::last_os_error()))
Err(handle_windows_error(io::Error::last_os_error()))
}
_ => {
return Ok(bytes_transfered as usize)
Ok(bytes_transfered as usize)
}
}
}
ref e => {
return Err(Error::Others(format!("failed to write to pipe: {:?}", e)))
Err(Error::Others(format!("failed to write to pipe: {:?}", e)))
}
}
}
Expand Down Expand Up @@ -346,10 +346,10 @@ impl ClientConnection {
.custom_flags(FILE_FLAG_OVERLAPPED);
match opts.open(self.address.as_str()) {
Ok(file) => {
return PipeConnection::new(file.into_raw_handle() as isize)
PipeConnection::new(file.into_raw_handle() as isize)
}
Err(e) => {
return Err(handle_windows_error(e))
Err(handle_windows_error(e))
}
}
}
Expand Down Expand Up @@ -383,7 +383,7 @@ mod test {
let client = ClientConnection::new("non_existent_pipe");
match client.get_pipe_connection() {
Ok(_) => {
assert!(false, "should not be able to get a connection to a non existent pipe");
panic!("should not be able to get a connection to a non existent pipe");
}
Err(e) => {
assert_eq!(e, Error::Windows(ERROR_FILE_NOT_FOUND as i32));
Expand All @@ -404,10 +404,10 @@ mod test {
// pipe is working
}
Ok(None) => {
assert!(false, "should get a working pipe")
panic!("should get a working pipe")
}
Err(e) => {
assert!(false, "should not get error {}", e.to_string())
panic!("should not get error {}", e)
}
}
});
Expand All @@ -425,7 +425,7 @@ mod test {
let quit_flag = Arc::new(AtomicBool::new(false));
match listener_server.accept(&quit_flag) {
Ok(_) => {
assert!(false, "should not get pipe on close")
panic!("should not get pipe on close")
}
Err(e) => {
assert_eq!(e.to_string(), "closing pipe")
Expand Down
1 change: 1 addition & 0 deletions ttrpc-codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dead_code)]
//! API to generate .rs files for ttrpc from protobuf
//!
//!
Expand Down
9 changes: 2 additions & 7 deletions ttrpc-codegen/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ use crate::str_lit::StrLit;
use protobuf_support::lexer::float;

/// Protobox syntax
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
pub enum Syntax {
/// Protobuf syntax [2](https://developers.google.com/protocol-buffers/docs/proto) (default)
#[default]
Proto2,
/// Protobuf syntax [3](https://developers.google.com/protocol-buffers/docs/proto3)
Proto3,
}

impl Default for Syntax {
fn default() -> Syntax {
Syntax::Proto2
}
}

/// A field rule
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub enum Rule {
Expand Down
16 changes: 8 additions & 8 deletions ttrpc-codegen/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ impl<'a> Lexer<'a> {

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

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

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

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

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

fn is_ascii_digit(c: char) -> bool {
('0'..='9').contains(&c)
c.is_ascii_digit()
}

// decimalLit = ( "1" … "9" ) { decimalDigit }
Expand All @@ -458,7 +458,7 @@ impl<'a> Lexer<'a> {
fn next_hex_digit(&mut self) -> ParserResult<u32> {
let mut clone = *self;
let r = match clone.next_char()? {
c if ('0'..='9').contains(&c) => c as u32 - b'0' as u32,
c if c.is_ascii_digit() => c as u32 - b'0' as u32,
c if ('A'..='F').contains(&c) => c as u32 - b'A' as u32 + 10,
c if ('a'..='f').contains(&c) => c as u32 - b'a' as u32 + 10,
_ => return Err(ParserError::ExpectHexDigit),
Expand All @@ -482,7 +482,7 @@ impl<'a> Lexer<'a> {
fn next_decimal_digit(&mut self) -> ParserResult<u32> {
let mut clone = *self;
let r = match clone.next_char()? {
c if ('0'..='9').contains(&c) => c as u32 - '0' as u32,
c if c.is_ascii_digit() => c as u32 - '0' as u32,
_ => return Err(ParserError::ExpectDecDigit),
};
*self = clone;
Expand All @@ -492,7 +492,7 @@ impl<'a> Lexer<'a> {
// decimals = decimalDigit { decimalDigit }
fn next_decimal_digits(&mut self) -> ParserResult<()> {
self.next_decimal_digit()?;
self.take_while(|c| ('0'..='9').contains(&c));
self.take_while(|c| c.is_ascii_digit());
Ok(())
}

Expand Down Expand Up @@ -1029,7 +1029,7 @@ impl<'a> Parser<'a> {
}

fn is_ascii_uppercase(c: char) -> bool {
('A'..='Z').contains(&c)
c.is_ascii_uppercase()
}

// groupName = capitalLetter { letter | decimalDigit | "_" }
Expand Down
Loading