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

Syncc #6

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prost"
version = "0.12.0"
version = "0.12.1"
authors = [
"Dan Burkert <[email protected]>",
"Lucio Franco <[email protected]",
Expand Down Expand Up @@ -49,7 +49,7 @@ std = []

[dependencies]
bytes = { version = "1", default-features = false }
prost-derive = { version = "0.12.0", path = "prost-derive", optional = true }
prost-derive = { version = "0.12.1", path = "prost-derive", optional = true }
uuid = { version = "1", features = ["v4"] }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [ cargo rustc ];
buildInputs = with pkgs; [ pkg-config protobuf curl ];
buildInputs = with pkgs; [ pkg-config protobuf curl cmake ninja ];
};
});
}
6 changes: 3 additions & 3 deletions prost-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prost-build"
version = "0.12.0"
version = "0.12.1"
authors = [
"Dan Burkert <[email protected]>",
"Lucio Franco <[email protected]>",
Expand All @@ -27,8 +27,8 @@ itertools = { version = ">=0.10, <0.12", default-features = false, features = ["
log = "0.4"
multimap = { version = "0.8", default-features = false }
petgraph = { version = "0.6", default-features = false }
prost = { version = "0.12.0", path = "..", default-features = false }
prost-types = { version = "0.12.0", path = "../prost-types", default-features = false }
prost = { version = "0.12.1", path = "..", default-features = false }
prost-types = { version = "0.12.1", path = "../prost-types", default-features = false }
tempfile = "3"
once_cell = "1.17.1"
regex = { version = "1.8.1", default-features = false, features = ["std", "unicode-bool"] }
Expand Down
2 changes: 1 addition & 1 deletion prost-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/prost-build/0.12.0")]
#![doc(html_root_url = "https://docs.rs/prost-build/0.12.1")]
#![allow(clippy::option_as_ref_deref, clippy::format_push_string)]

//! `prost-build` compiles `.proto` files into Rust.
Expand Down
2 changes: 1 addition & 1 deletion prost-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prost-derive"
version = "0.12.0"
version = "0.12.1"
authors = [
"Dan Burkert <[email protected]>",
"Lucio Franco <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions prost-derive/src/field/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,14 @@ impl Field {
#[doc=#get_doc]
pub fn #get(&self, key: #key_ref_ty) -> ::core::option::Option<#ty> {
self.#ident.get(#take_ref key).cloned().and_then(|x| {
let result: Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
let result: ::core::result::Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
result.ok()
})
}
#[doc=#insert_doc]
pub fn #insert(&mut self, key: #key_ty, value: #ty) -> ::core::option::Option<#ty> {
self.#ident.insert(key, value as i32).and_then(|x| {
let result: Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
let result: ::core::result::Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
result.ok()
})
}
Expand Down
6 changes: 3 additions & 3 deletions prost-derive/src/field/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl Field {
struct #wrap_name<'a>(&'a i32);
impl<'a> ::core::fmt::Debug for #wrap_name<'a> {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let res: Result<#ty, _> = ::core::convert::TryFrom::try_from(*self.0);
let res: ::core::result::Result<#ty, _> = ::core::convert::TryFrom::try_from(*self.0);
match res {
Err(_) => ::core::fmt::Debug::fmt(&self.0, f),
Ok(en) => ::core::fmt::Debug::fmt(&en, f),
Expand Down Expand Up @@ -377,7 +377,7 @@ impl Field {
#[doc=#get_doc]
pub fn #get(&self) -> #ty {
self.#ident.and_then(|x| {
let result: Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
let result: ::core::result::Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
result.ok()
}).unwrap_or(#default)
}
Expand All @@ -402,7 +402,7 @@ impl Field {
fn(i32) -> ::core::option::Option<#ty>,
> {
self.#ident.iter().cloned().filter_map(|x| {
let result: Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
let result: ::core::result::Result<#ty, _> = ::core::convert::TryFrom::try_from(x);
result.ok()
})
}
Expand Down
2 changes: 1 addition & 1 deletion prost-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/prost-derive/0.12.0")]
#![doc(html_root_url = "https://docs.rs/prost-derive/0.12.1")]
// The `quote!` macro requires deep recursion.
#![recursion_limit = "4096"]

Expand Down
4 changes: 2 additions & 2 deletions prost-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prost-types"
version = "0.12.0"
version = "0.12.1"
authors = [
"Dan Burkert <[email protected]>",
"Lucio Franco <[email protected]",
Expand All @@ -22,7 +22,7 @@ default = ["std"]
std = ["prost/std"]

[dependencies]
prost = { version = "0.12.0", path = "..", default-features = false, features = ["prost-derive"] }
prost = { version = "0.12.1", path = "..", default-features = false, features = ["prost-derive"] }

[dev-dependencies]
proptest = "1"
10 changes: 9 additions & 1 deletion prost-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/prost-types/0.12.0")]
#![doc(html_root_url = "https://docs.rs/prost-types/0.12.1")]

//! Protocol Buffers well-known types.
//!
Expand Down Expand Up @@ -90,6 +90,14 @@ impl Name for Any {
}
}

#[cfg(feature = "std")]
impl std::hash::Hash for Duration {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.seconds.hash(state);
self.nanos.hash(state);
}
}

impl Duration {
/// Normalizes the duration to a canonical format.
///
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/prost/0.12.0")]
#![doc(html_root_url = "https://docs.rs/prost/0.12.1")]
#![cfg_attr(not(feature = "std"), no_std)]
#![doc = include_str!("../README.md")]

Expand Down
2 changes: 1 addition & 1 deletion src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait Name: Message {
/// Full name of this message type containing both the package name and
/// type name, e.g. `google.protobuf.TypeName`.
fn full_name() -> String {
format!("{}.{}", Self::NAME, Self::PACKAGE)
format!("{}.{}", Self::PACKAGE, Self::NAME)
}

/// Type URL for this message, which by default is the full name with a
Expand Down
16 changes: 16 additions & 0 deletions tests/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ fn main() {
.compile_protos(&[src.join("custom_debug.proto")], includes)
.unwrap();

config
.compile_protos(&[src.join("result_enum.proto")], includes)
.unwrap();

config
.compile_protos(&[src.join("result_struct.proto")], includes)
.unwrap();

config
.compile_protos(&[src.join("option_enum.proto")], includes)
.unwrap();

config
.compile_protos(&[src.join("option_struct.proto")], includes)
.unwrap();

prost_build::Config::new()
.protoc_arg("--experimental_allow_proto3_optional")
.compile_protos(&[src.join("proto3_presence.proto")], includes)
Expand Down
18 changes: 16 additions & 2 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,22 @@ mod no_unused_results;
#[cfg(test)]
#[cfg(feature = "std")]
mod skip_debug;
#[cfg(test)]
mod well_known_types;

mod test_enum_named_option_value {
include!(concat!(env!("OUT_DIR"), "/myenum.optionn.rs"));
}

mod test_enum_named_result_value {
include!(concat!(env!("OUT_DIR"), "/myenum.result.rs"));
}

mod test_result_named_option_value {
include!(concat!(env!("OUT_DIR"), "/mystruct.optionn.rs"));
}

mod test_result_named_result_value {
include!(concat!(env!("OUT_DIR"), "/mystruct.result.rs"));
}

pub mod foo {
pub mod bar_baz {
Expand Down
3 changes: 3 additions & 0 deletions tests/src/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

include!(concat!(env!("OUT_DIR"), "/myenum.result.rs"));
include!(concat!(env!("OUT_DIR"), "/mymessage.result.rs"));
11 changes: 11 additions & 0 deletions tests/src/option_enum.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package myenum.optionn;


enum Option {
HELLO = 0;
}

message FailMessage {
Option result = 1;
}
8 changes: 8 additions & 0 deletions tests/src/option_struct.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";
package mystruct.optionn;


message Option {
string msg = 1;
}

11 changes: 11 additions & 0 deletions tests/src/result_enum.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package myenum.result;


enum Result {
HELLO = 0;
}

message FailMessage {
Result result = 1;
}
8 changes: 8 additions & 0 deletions tests/src/result_struct.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";
package mystruct.result;


message Result {
string msg = 1;
}

Loading