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

chore(deps): Upgrade to Rust 1.50.0 #6428

Merged
merged 17 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 12 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
18 changes: 12 additions & 6 deletions lib/prometheus-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ mod test {
assert!(matches!(
error,
ParserError::WithLine {
kind: ErrorKind::ExpectedChar { expected: ',', .. }, ..
kind: ErrorKind::ExpectedChar { expected: ',', .. },
..
}
));

Expand All @@ -329,7 +330,8 @@ mod test {
assert!(matches!(
error,
ParserError::WithLine {
kind: ErrorKind::InvalidMetricKind { .. }, ..
kind: ErrorKind::InvalidMetricKind { .. },
..
}
));

Expand All @@ -339,7 +341,8 @@ mod test {
assert!(matches!(
error,
ParserError::WithLine {
kind: ErrorKind::ExpectedSpace { .. }, ..
kind: ErrorKind::ExpectedSpace { .. },
..
}
));

Expand All @@ -349,7 +352,8 @@ mod test {
assert!(matches!(
error,
ParserError::WithLine {
kind: ErrorKind::ExpectedChar { expected: '"', .. }, ..
kind: ErrorKind::ExpectedChar { expected: '"', .. },
..
}
));

Expand All @@ -359,7 +363,8 @@ mod test {
assert!(matches!(
error,
ParserError::WithLine {
kind: ErrorKind::ExpectedChar { expected: '"', .. }, ..
kind: ErrorKind::ExpectedChar { expected: '"', .. },
..
}
));

Expand All @@ -369,7 +374,8 @@ mod test {
assert!(matches!(
error,
ParserError::WithLine {
kind: ErrorKind::ParseFloatError { .. }, ..
kind: ErrorKind::ParseFloatError { .. },
..
}
));
}
Expand Down
5 changes: 1 addition & 4 deletions lib/prometheus-parser/src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,7 @@ mod test {
let input = wrap(r#"{ a="b" ,, c="d" }"#);
let error = Metric::parse_labels(&input).unwrap_err().into();
println!("{}", error);
assert!(matches!(
error,
ErrorKind::ParseNameError { .. }
));
assert!(matches!(error, ErrorKind::ParseNameError { .. }));
}

#[test]
Expand Down
13 changes: 6 additions & 7 deletions lib/remap-cli/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,13 @@ fn run(opts: &Opts) -> Result<(), Error> {
}
}

#[cfg(feature = "repl")]
fn repl(objects: Vec<Value>) -> Result<(), Error> {
repl::run(objects)
}

#[cfg(not(feature = "repl"))]
fn repl(_: Vec<Value>) -> Result<(), Error> {
Err(Error::ReplFeature)
if cfg!(feature = "repl") {
repl::run(objects);
Ok(())
} else {
Err(Error::ReplFeature)
}
}

fn execute(object: &mut impl Object, source: String) -> Result<Value, Error> {
Expand Down
1 change: 0 additions & 1 deletion lib/remap-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub enum Error {
#[error("json error")]
Json(#[from] serde_json::Error),

#[cfg(not(feature = "repl"))]
#[error("repl feature disabled, program input required")]
ReplFeature,
}
5 changes: 1 addition & 4 deletions lib/remap-cli/src/repl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::Error;
use prettytable::{format, Cell, Row, Table};
use regex::Regex;
use remap::{state, Formatter, Object, Program, Runtime, Value};
Expand All @@ -24,7 +23,7 @@ VRL REPL commands:
const DOCS_URL: &str = "https://vector.dev/docs/reference/vrl";
const FUNCTIONS_ROOT_URL: &str = "https://vector.dev/docs/reference/vrl/functions";

pub(crate) fn run(mut objects: Vec<Value>) -> Result<(), Error> {
pub(crate) fn run(mut objects: Vec<Value>) {
let mut index = 0;
let func_docs_regex = Regex::new(r"^help\sdocs\s(\w{1,})$").unwrap();

Expand Down Expand Up @@ -131,8 +130,6 @@ pub(crate) fn run(mut objects: Vec<Value>) -> Result<(), Error> {
}
}
}

Ok(())
}

fn resolve(
Expand Down
12 changes: 6 additions & 6 deletions lib/remap-functions/src/parse_aws_alb_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ impl Expression for ParseAwsAlbLogFn {
self.value
.type_def(state)
.into_fallible(true) // Log parsing error
.with_inner_type(inner_type_def())
.with_inner_type(Some(inner_type_def()))
.with_constraint(value::Kind::Map)
}
}

/// The type defs of the fields contained by the returned map.
fn inner_type_def() -> Option<InnerTypeDef> {
Some(inner_type_def! ({
fn inner_type_def() -> InnerTypeDef {
inner_type_def! ({
"type": Kind::Bytes,
"timestamp": Kind::Bytes,
"elb": Kind::Bytes,
Expand Down Expand Up @@ -94,7 +94,7 @@ fn inner_type_def() -> Option<InnerTypeDef> {
"target_status_code_list": Kind::Bytes,
"classification": Kind::Bytes,
"classification_reason": Kind::Bytes
}))
})
}

fn parse_log(mut input: &str) -> Result<Value> {
Expand Down Expand Up @@ -240,12 +240,12 @@ mod tests {
remap::test_type_def![
value_string {
expr: |_| ParseAwsAlbLogFn { value: Literal::from("foo").boxed() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}

value_optional {
expr: |_| ParseAwsAlbLogFn { value: Box::new(Noop) },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ impl Expression for ParseAwsCloudWatchLogSubscriptionMessageFn {
self.value
.type_def(state)
.into_fallible(true) // Message parsing error
.with_inner_type(inner_type_def())
.with_inner_type(Some(inner_type_def()))
.with_constraint(value::Kind::Map)
}
}

/// The type defs of the fields contained by the returned map.
fn inner_type_def() -> Option<InnerTypeDef> {
Some(inner_type_def! ({
fn inner_type_def() -> InnerTypeDef {
inner_type_def! ({
"owner": Kind::Bytes,
"message_type": Kind::Bytes,
"log_group": Kind::Bytes,
Expand All @@ -78,7 +78,7 @@ fn inner_type_def() -> Option<InnerTypeDef> {
"timestamp": Kind::Timestamp,
"message": Kind::Bytes,
})))
}))
})
}

#[cfg(test)]
Expand Down Expand Up @@ -150,7 +150,7 @@ mod tests {
def: TypeDef {
fallible: true,
kind: Kind::Map,
inner_type_def: inner_type_def(),
inner_type_def: Some(inner_type_def()),
},
}];
}
17 changes: 9 additions & 8 deletions lib/remap-functions/src/parse_aws_vpc_flow_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ impl Expression for ParseAwsVpcFlowLogFn {
self.value
.type_def(state)
.into_fallible(true) // Log parsin_ error
.with_inner_type(inner_type_def())
.with_inner_type(Some(inner_type_def()))
.with_constraint(value::Kind::Map)
}
}

/// The type defs of the fields contained by the returned map.
fn inner_type_def() -> Option<InnerTypeDef> {
Some(inner_type_def! ({
fn inner_type_def() -> InnerTypeDef {
inner_type_def! ({
"version": Kind::Integer | Kind::Null,
"account_id": Kind::Integer | Kind::Null,
"interface_id": Kind::Bytes | Kind::Null,
Expand All @@ -96,11 +96,12 @@ fn inner_type_def() -> Option<InnerTypeDef> {
"region": Kind::Bytes | Kind::Null,
"az_id": Kind::Bytes | Kind::Null,
"sublocation_type": Kind::Bytes | Kind::Null,
}))
})
}

type ParseResult<T> = std::result::Result<T, String>;

#[allow(clippy::unnecessary_wraps)] // match other parse methods
fn identity<'a>(_key: &'a str, value: &'a str) -> ParseResult<&'a str> {
Ok(value)
}
Expand Down Expand Up @@ -185,22 +186,22 @@ mod tests {
remap::test_type_def![
value_noop {
expr: |_| ParseAwsVpcFlowLogFn::new(Box::new(Noop), None),
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: Some(inner_type_def()) },
}

value_non_string {
expr: |_| ParseAwsVpcFlowLogFn::new(Literal::from(1).boxed(), None),
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: Some(inner_type_def()) },
}

value_string {
expr: |_| ParseAwsVpcFlowLogFn::new(Literal::from("foo").boxed(), None),
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: Some(inner_type_def()) },
}

format_non_string {
expr: |_| ParseAwsVpcFlowLogFn::new(Literal::from("foo").boxed(), Some(Literal::from(1).boxed())),
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: Kind::Map, inner_type_def: Some(inner_type_def()) },
}
];

Expand Down
16 changes: 8 additions & 8 deletions lib/remap-functions/src/parse_common_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ impl Expression for ParseCommonLogFn {
.type_def(state)
.into_fallible(true)
.with_constraint(value::Kind::Map)
.with_inner_type(inner_type_def())
.with_inner_type(Some(inner_type_def()))
}
}

fn inner_type_def() -> Option<InnerTypeDef> {
fn inner_type_def() -> InnerTypeDef {
use value::Kind;

Some(inner_type_def!({
inner_type_def!({
"host": Kind::Bytes | Kind::Null,
"identity": Kind::Bytes | Kind::Null,
"user": Kind::Bytes | Kind::Null,
Expand All @@ -171,7 +171,7 @@ fn inner_type_def() -> Option<InnerTypeDef> {
"protocol": Kind::Bytes | Kind::Null,
"status": Kind::Integer | Kind::Null,
"size": Kind::Integer | Kind::Null,
}))
})
}

#[cfg(test)]
Expand Down Expand Up @@ -242,22 +242,22 @@ mod tests {
test_type_def![
value_string {
expr: |_| ParseCommonLogFn { value: Literal::from("foo").boxed(), timestamp_format: None },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}

value_non_string {
expr: |_| ParseCommonLogFn { value: Literal::from(1).boxed(), timestamp_format: None },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}

timestamp_format_string {
expr: |_| ParseCommonLogFn { value: Literal::from("foo").boxed(), timestamp_format: Some(Literal::from("foo").boxed()) },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}

timestamp_format_non_string {
expr: |_| ParseCommonLogFn { value: Literal::from("foo").boxed(), timestamp_format: Some(Literal::from(1).boxed()) },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}
];
}
14 changes: 7 additions & 7 deletions lib/remap-functions/src/parse_glog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,21 @@ impl Expression for ParseGlogFn {
.type_def(state)
.into_fallible(true)
.with_constraint(value::Kind::Map)
.with_inner_type(inner_type_def())
.with_inner_type(Some(inner_type_def()))
}
}

fn inner_type_def() -> Option<InnerTypeDef> {
fn inner_type_def() -> InnerTypeDef {
use value::Kind;

Some(inner_type_def!({
inner_type_def!({
"level": Kind::Bytes,
"timestamp": Kind::Timestamp,
"id": Kind::Integer,
"file": Kind::Bytes,
"line": Kind::Integer,
"message": Kind::Bytes,
}))
})
}

#[cfg(test)]
Expand Down Expand Up @@ -188,17 +188,17 @@ mod tests {
test_type_def![
value_string {
expr: |_| ParseGlogFn { value: Literal::from("foo").boxed() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}

value_non_string {
expr: |_| ParseGlogFn { value: Literal::from(1).boxed() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}

value_optional {
expr: |_| ParseGlogFn { value: Box::new(Noop) },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: inner_type_def() },
def: TypeDef { fallible: true, kind: value::Kind::Map, inner_type_def: Some(inner_type_def()) },
}
];
}
Loading