Skip to content

Commit 015ea09

Browse files
committed
Mark structs non-exhaustive
1 parent ea4b5e4 commit 015ea09

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

opentelemetry-proto/src/transform/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ pub mod tonic {
152152
Array::I64(vals) => array_into_proto(vals),
153153
Array::F64(vals) => array_into_proto(vals),
154154
Array::String(vals) => array_into_proto(vals),
155+
_ => unreachable!("Nonexistent array type"), // Needs to be updated when new array types are added
155156
})),
157+
_ => unreachable!("Nonexistent value type"), // Needs to be updated when new value types are added
156158
},
157159
}
158160
}

opentelemetry-stdout/src/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ impl From<opentelemetry::Value> for Value {
144144
opentelemetry::Array::String(s) => {
145145
Value::Array(s.into_iter().map(|s| Value::String(s.into())).collect())
146146
}
147+
_ => unreachable!("Nonexistent array type"), // Needs to be updated when new array types are added
147148
},
149+
_ => unreachable!("Nonexistent value type"), // Needs to be updated when new value types are added
148150
}
149151
}
150152
}

opentelemetry/src/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{fmt, hash};
77
/// See the [attribute naming] spec for guidelines.
88
///
99
/// [attribute naming]: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/attribute-naming.md
10+
#[non_exhaustive]
1011
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
1112
pub struct Key(OtelString);
1213

@@ -149,6 +150,7 @@ impl hash::Hash for OtelString {
149150
}
150151

151152
/// A [Value::Array] containing homogeneous values.
153+
#[non_exhaustive]
152154
#[derive(Clone, Debug, PartialEq)]
153155
pub enum Array {
154156
/// Array of bools
@@ -212,6 +214,7 @@ into_array!(
212214
);
213215

214216
/// The value part of attribute [KeyValue] pairs.
217+
#[non_exhaustive]
215218
#[derive(Clone, Debug, PartialEq)]
216219
pub enum Value {
217220
/// bool values
@@ -227,6 +230,7 @@ pub enum Value {
227230
}
228231

229232
/// Wrapper for string-like values
233+
#[non_exhaustive]
230234
#[derive(Clone, PartialEq, Eq, Hash)]
231235
pub struct StringValue(OtelString);
232236

0 commit comments

Comments
 (0)