Skip to content

Remove the deprecated log_syntax_violation function for 2.0 #509

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

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 0 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,6 @@ impl<'a> ParseOptions<'a> {
self
}

/// Call the provided function or closure on non-fatal parse errors, passing
/// a static string description. This method is deprecated in favor of
/// `syntax_violation_callback` and is implemented as an adaptor for the
/// latter, passing the `SyntaxViolation` description. Only the last value
/// passed to either method will be used by a parser.
#[deprecated]
pub fn log_syntax_violation(mut self, new: Option<&'a Fn(&'static str)>) -> Self {
self.violation_fn = match new {
Some(f) => ViolationFn::OldFn(f),
None => ViolationFn::NoOp
};
self
}

/// Call the provided function or closure for a non-fatal `SyntaxViolation`
/// when it occurs during parsing. Note that since the provided function is
/// `Fn`, the caller might need to utilize _interior mutability_, such as with
Expand Down
4 changes: 0 additions & 4 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ impl<'i> Iterator for Input<'i> {
#[derive(Copy, Clone)]
pub enum ViolationFn<'a> {
NewFn(&'a (Fn(SyntaxViolation) + 'a)),
OldFn(&'a (Fn(&'static str) + 'a)),
NoOp
}

Expand All @@ -284,7 +283,6 @@ impl<'a> ViolationFn<'a> {
pub fn call(self, v: SyntaxViolation) {
match self {
ViolationFn::NewFn(f) => f(v),
ViolationFn::OldFn(f) => f(v.description()),
ViolationFn::NoOp => {}
}
}
Expand All @@ -296,7 +294,6 @@ impl<'a> ViolationFn<'a> {
{
match self {
ViolationFn::NewFn(f) => if test() { f(v) },
ViolationFn::OldFn(f) => if test() { f(v.description()) },
ViolationFn::NoOp => {} // avoid test
}
}
Expand All @@ -314,7 +311,6 @@ impl<'a> fmt::Debug for ViolationFn<'a> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
ViolationFn::NewFn(_) => write!(f, "NewFn(Fn(SyntaxViolation))"),
ViolationFn::OldFn(_) => write!(f, "OldFn(Fn(&'static str))"),
ViolationFn::NoOp => write!(f, "NoOp")
}
}
Expand Down
15 changes: 0 additions & 15 deletions tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,21 +490,6 @@ fn test_windows_unc_path() {
assert!(url.is_err());
}

// Test the now deprecated log_syntax_violation method for backward
// compatibility
#[test]
#[allow(deprecated)]
fn test_old_log_violation_option() {
let violation = Cell::new(None);
let url = Url::options()
.log_syntax_violation(Some(&|s| violation.set(Some(s.to_owned()))))
.parse("http:////mozilla.org:42").unwrap();
assert_eq!(url.port(), Some(42));

let violation = violation.take();
assert_eq!(violation, Some("expected //".to_string()));
}

#[test]
fn test_syntax_violation_callback() {
use url::SyntaxViolation::*;
Expand Down