Skip to content

Commit

Permalink
Raise MSRV to 1.71.0
Browse files Browse the repository at this point in the history
- rustversion seemed to cause slow compile times on 1.56.0 (8x)
- Easier to just raise MSRV rather than have a split story about which
  compiler used
  • Loading branch information
bluk committed Nov 14, 2023
1 parent fc75d60 commit e87b94e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- windows-latest
rust:
- stable
- 1.56.0
- 1.71.0
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- windows-latest
rust:
- stable
- 1.56.0
- 1.71.0
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
Expand Down
5 changes: 1 addition & 4 deletions maybe_xml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ license = "MIT OR Apache-2.0"
name = "maybe_xml"
readme = "README.md"
repository = "https://github.com/bluk/maybe_xml"
rust-version = "1.56.0"
rust-version = "1.71.0"
version = "0.8.0"

[dependencies]
rustversion = "1.0"

[features]
default = ["std"]

Expand Down
3 changes: 1 addition & 2 deletions maybe_xml/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,8 @@ impl<'a> Reader<'a> {
/// assert_eq!(0, pos);
/// assert_ne!(input.len(), pos);
/// ```
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn parse(&self, pos: usize) -> Option<Token<'a>> {
pub const fn parse(&self, pos: usize) -> Option<Token<'a>> {
let input = self.input.as_bytes();

if input.len() == pos {
Expand Down
72 changes: 36 additions & 36 deletions maybe_xml/src/read/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ const fn find_close_tag_char_with_brackets_and_quotes(
#[inline]
#[must_use]
const fn scan_text_content(input: &[u8], pos: usize) -> usize {
// debug_assert!(pos < input.len());
// debug_assert!(input[pos] != b'<');
debug_assert!(pos < input.len());
debug_assert!(input[pos] != b'<');

let mut index = pos + 1;
loop {
Expand All @@ -133,8 +133,8 @@ const fn scan_text_content(input: &[u8], pos: usize) -> usize {
#[inline]
#[must_use]
const fn scan_markup(input: &[u8], pos: usize) -> Option<usize> {
// debug_assert!(pos < input.len());
// debug_assert!(input[pos] == b'<');
debug_assert!(pos < input.len());
debug_assert!(input[pos] == b'<');

let peek = pos + 1;
if input.len() <= peek {
Expand All @@ -156,11 +156,11 @@ const fn scan_start_or_empty_element_tag(input: &[u8], pos: usize) -> Option<usi
const OFFSET: usize = 1;

// Due to scan_mark(), peek2 is already checked
// debug_assert!(pos + 1 < input.len());
// debug_assert!(input[pos] == b'<');
// debug_assert!(input[pos + 1] != b'/');
// debug_assert!(input[pos + 1] != b'?');
// debug_assert!(input[pos + 1] != b'!');
debug_assert!(pos + 1 < input.len());
debug_assert!(input[pos] == b'<');
debug_assert!(input[pos + 1] != b'/');
debug_assert!(input[pos + 1] != b'?');
debug_assert!(input[pos + 1] != b'!');

find_close_tag_char_with_quotes(input, pos + OFFSET)
}
Expand All @@ -171,9 +171,9 @@ const fn scan_end_tag(input: &[u8], pos: usize) -> Option<usize> {
// Skip the head '</'
const OFFSET: usize = 2;

// debug_assert!(pos + 1 < input.len());
// debug_assert!(input[pos] == b'<');
// debug_assert!(input[pos + 1] == b'/');
debug_assert!(pos + 1 < input.len());
debug_assert!(input[pos] == b'<');
debug_assert!(input[pos + 1] == b'/');

find_close_tag_char_with_quotes(input, pos + OFFSET)
}
Expand All @@ -184,9 +184,9 @@ const fn scan_processing_instruction(input: &[u8], pos: usize) -> Option<usize>
// Skip the head '<?'
const OFFSET: usize = 2;

// debug_assert!(pos + 1 < input.len());
// debug_assert!(input[pos] == b'<');
// debug_assert!(input[pos + 1] == b'?');
debug_assert!(pos + 1 < input.len());
debug_assert!(input[pos] == b'<');
debug_assert!(input[pos + 1] == b'?');

// Skip OFFSET + 1 because at the minimum, it must be `<??>`.
// It cannot be `<?>`.
Expand All @@ -212,9 +212,9 @@ const fn scan_declaration_comment_or_cdata(input: &[u8], pos: usize) -> Option<u
// Skip the head '<!'
const OFFSET: usize = 2;

// debug_assert!(pos + 1 < input.len());
// debug_assert!(input[pos] == b'<');
// debug_assert!(input[pos + 1] == b'!');
debug_assert!(pos + 1 < input.len());
debug_assert!(input[pos] == b'<');
debug_assert!(input[pos + 1] == b'!');

let peek = pos + 2;
if input.len() <= peek {
Expand Down Expand Up @@ -257,9 +257,9 @@ const fn scan_declaration(input: &[u8], pos: usize) -> Option<usize> {
// Skip the head '<!'
const OFFSET: usize = 2;

// debug_assert!(pos + 1 < input.len());
// debug_assert!(input[pos] == b'<');
// debug_assert!(input[pos + 1] == b'!');
debug_assert!(pos + 1 < input.len());
debug_assert!(input[pos] == b'<');
debug_assert!(input[pos + 1] == b'!');

find_close_tag_char_with_brackets_and_quotes(input, pos + OFFSET)
}
Expand All @@ -270,11 +270,11 @@ const fn scan_comment(input: &[u8], pos: usize) -> Option<usize> {
// Skip the head '<!--'
const OFFSET: usize = 4;

// debug_assert!(pos + 3 < input.len());
// debug_assert!(input[pos] == b'<');
// debug_assert!(input[pos + 1] == b'!');
// debug_assert!(input[pos + 2] == b'-');
// debug_assert!(input[pos + 3] == b'-');
debug_assert!(pos + 3 < input.len());
debug_assert!(input[pos] == b'<');
debug_assert!(input[pos + 1] == b'!');
debug_assert!(input[pos + 2] == b'-');
debug_assert!(input[pos + 3] == b'-');

// Skip OFFSET + 2 because at the minimum, it must be `<!---->`.
// It cannot be `<!-->`.
Expand All @@ -300,16 +300,16 @@ const fn scan_cdata(input: &[u8]) -> Option<usize> {
// Skip the head '<![CDATA['
const OFFSET: usize = 9;

// debug_assert!(input.len() >= 9);
// debug_assert!(input[0] == b'<');
// debug_assert!(input[1] == b'!');
// debug_assert!(input[2] == b'[');
// debug_assert!(input[3] == b'C');
// debug_assert!(input[4] == b'D');
// debug_assert!(input[5] == b'A');
// debug_assert!(input[6] == b'T');
// debug_assert!(input[7] == b'A');
// debug_assert!(input[8] == b'[');
debug_assert!(9 <= input.len());
debug_assert!(input[0] == b'<');
debug_assert!(input[1] == b'!');
debug_assert!(input[2] == b'[');
debug_assert!(input[3] == b'C');
debug_assert!(input[4] == b'D');
debug_assert!(input[5] == b'A');
debug_assert!(input[6] == b'T');
debug_assert!(input[7] == b'A');
debug_assert!(input[8] == b'[');

// Skip OFFSET + 2 because at the minimum, it must be `<![CDATA[]]>`.

Expand Down
24 changes: 8 additions & 16 deletions maybe_xml/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ pub struct StartTag<'a>(&'a str);

impl<'a> StartTag<'a> {
/// The name of the tag.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn name(&self) -> TagName<'a> {
pub const fn name(&self) -> TagName<'a> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand All @@ -264,9 +263,8 @@ impl<'a> StartTag<'a> {
}

/// The attributes of the tag.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn attributes(&self) -> Option<Attributes<'a>> {
pub const fn attributes(&self) -> Option<Attributes<'a>> {
let bytes = self.0.as_bytes();

let mut index = 0;
Expand Down Expand Up @@ -327,9 +325,8 @@ pub struct EmptyElementTag<'a>(&'a str);

impl<'a> EmptyElementTag<'a> {
/// The name of the tag.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn name(&self) -> TagName<'a> {
pub const fn name(&self) -> TagName<'a> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand All @@ -354,9 +351,8 @@ impl<'a> EmptyElementTag<'a> {
}

/// The attributes of the tag.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn attributes(&self) -> Option<Attributes<'a>> {
pub const fn attributes(&self) -> Option<Attributes<'a>> {
let bytes = self.0.as_bytes();

let mut index = 0;
Expand Down Expand Up @@ -415,9 +411,8 @@ pub struct EndTag<'a>(&'a str);

impl<'a> EndTag<'a> {
/// The name of the tag.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn name(&self) -> TagName<'a> {
pub const fn name(&self) -> TagName<'a> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand Down Expand Up @@ -466,9 +461,8 @@ converters!(ProcessingInstruction);

impl<'a> ProcessingInstruction<'a> {
/// The target of the tag.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn target(&self) -> Target<'a> {
pub const fn target(&self) -> Target<'a> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand All @@ -493,9 +487,8 @@ impl<'a> ProcessingInstruction<'a> {
}

/// The instructions of the tag.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn instructions(&self) -> Option<Instructions<'a>> {
pub const fn instructions(&self) -> Option<Instructions<'a>> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand Down Expand Up @@ -563,9 +556,8 @@ pub struct Cdata<'a>(&'a str);

impl<'a> Cdata<'a> {
/// The text content of the characters.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn content(&self) -> Content<'a> {
pub const fn content(&self) -> Content<'a> {
let bytes = self.0.as_bytes();
let (bytes, _) = bytes.split_at(self.0.len() - "]]>".len());
let (_, bytes) = bytes.split_at("<![CDATA[".len());
Expand Down
24 changes: 8 additions & 16 deletions maybe_xml/src/token/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ impl<'a> TagName<'a> {
/// For example, if `xml:example` was the tag name, then `example` would be
/// the local part of the name. If there is no namespace prefix, the entire
/// name is returned.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn local(&self) -> LocalName<'a> {
pub const fn local(&self) -> LocalName<'a> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand All @@ -106,9 +105,8 @@ impl<'a> TagName<'a> {
///
/// For example if `xml:example` was the tag name, then `xml` would be the
/// namespace prefix.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn namespace_prefix(&self) -> Option<NamespacePrefix<'a>> {
pub const fn namespace_prefix(&self) -> Option<NamespacePrefix<'a>> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand Down Expand Up @@ -213,10 +211,9 @@ impl<'a> Attributes<'a> {
///
/// assert_eq!(None, attributes.parse(pos));
/// ```
#[rustversion::attr(since(1.71), const)]
#[inline]
#[must_use]
pub fn parse(&self, pos: usize) -> Option<Attribute<'a>> {
pub const fn parse(&self, pos: usize) -> Option<Attribute<'a>> {
let input = self.0.as_bytes();

if input.len() == pos {
Expand Down Expand Up @@ -252,9 +249,8 @@ impl<'a> IntoIterator for Attributes<'a> {
}
}

#[rustversion::attr(since(1.71), const)]
#[must_use]
fn iter_attr(index: usize, bytes: &[u8]) -> Option<usize> {
const fn iter_attr(index: usize, bytes: &[u8]) -> Option<usize> {
if bytes.len() <= index {
return None;
}
Expand Down Expand Up @@ -393,9 +389,8 @@ impl<'a> Attribute<'a> {
}

/// The attribute's name.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn name(&self) -> AttributeName<'a> {
pub const fn name(&self) -> AttributeName<'a> {
let bytes = self.0.as_bytes();

let mut begin = 0;
Expand Down Expand Up @@ -462,9 +457,8 @@ impl<'a> Attribute<'a> {
}

/// The optional attribute value with the quotes removed.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn value(&self) -> Option<AttributeValue<'a>> {
pub const fn value(&self) -> Option<AttributeValue<'a>> {
let mut index = 0;
let bytes = self.0.as_bytes();

Expand Down Expand Up @@ -554,9 +548,8 @@ impl<'a> AttributeName<'a> {
/// For example, if `xml:example` was the attribute name, then `example`
/// would be the local part of the name. If there is no namespace prefix,
/// the entire name is returned.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn local(&self) -> LocalName<'a> {
pub const fn local(&self) -> LocalName<'a> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand All @@ -583,9 +576,8 @@ impl<'a> AttributeName<'a> {
///
/// For example if `xml:example` was the attribute name, then `xml` would be
/// the namespace prefix.
#[rustversion::attr(since(1.71), const)]
#[must_use]
pub fn namespace_prefix(&self) -> Option<NamespacePrefix<'a>> {
pub const fn namespace_prefix(&self) -> Option<NamespacePrefix<'a>> {
let mut index = 0;
let bytes = self.0.as_bytes();
loop {
Expand Down

0 comments on commit e87b94e

Please sign in to comment.