Skip to content

Commit 269379e

Browse files
authored
fix: qualify ToProto calls on foreign receivers (#7437)
Calls such as `self.code.to_proto()` rely on inference to pick the `ToProto<T>` impl for a type defined in another crate. If a future release of that crate adds a second impl for the same type, these calls become ambiguous and stop compiling. Name the trait parameter explicitly, as the generated code already does. For #7284
1 parent 5544fcd commit 269379e

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎src/firestore/src/status.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ impl ToProto<google::rpc::Status> for Status {
2323
type Output = google::rpc::Status;
2424
fn to_proto(self) -> Result<Self::Output, ConvertError> {
2525
Ok(Self::Output {
26-
code: self.code.to_proto()?,
27-
message: self.message.to_proto()?,
26+
code: ToProto::<i32>::to_proto(self.code)?,
27+
message: ToProto::<String>::to_proto(self.message)?,
2828
details: self.details.into_iter().filter_map(any_to_prost).collect(),
2929
})
3030
}

‎src/pubsub/src/publisher/publish_telemetry.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ pub(crate) fn format_pubsub_client_telemetry_header(
3939
let p = PubsubClientTelemetry {
4040
operation: Some(Operation::PublishOperation(PublishOperation {
4141
hedged_attempt_count: attempt_count,
42-
publish_start_time: start_time.and_then(|t| t.to_proto().ok()),
42+
publish_start_time: start_time
43+
.and_then(|t| ToProto::<prost_types::Timestamp>::to_proto(t).ok()),
4344
})),
4445
};
4546

‎src/storage/src/control/convert.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ToProto<google::longrunning::Operation> for google_cloud_longrunning::model
4545
let result = self
4646
.result
4747
.map(|result| match result {
48-
M::Error(status) => status.to_proto().map(P::Error),
48+
M::Error(status) => ToProto::<google::rpc::Status>::to_proto(*status).map(P::Error),
4949
M::Response(any) => lro_any_to_prost(*any).map(P::Response),
5050
_ => unreachable!(),
5151
})

‎src/storage/src/control/status.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ impl ToProto<google::rpc::Status> for Status {
2121
type Output = google::rpc::Status;
2222
fn to_proto(self) -> Result<Self::Output, ConvertError> {
2323
Ok(Self::Output {
24-
code: self.code.to_proto()?,
25-
message: self.message.to_proto()?,
24+
code: ToProto::<i32>::to_proto(self.code)?,
25+
message: ToProto::<String>::to_proto(self.message)?,
2626
details: self.details.into_iter().filter_map(any_to_prost).collect(),
2727
})
2828
}

0 commit comments

Comments
 (0)