|
1 | 1 | //! Parse error reporting |
2 | 2 |
|
3 | 3 | use crate::{Parse, RuleResult}; |
4 | | -use std::collections::HashSet; |
5 | 4 | use std::fmt::{self, Debug, Display}; |
6 | 5 |
|
| 6 | +#[cfg(feature = "std")] |
| 7 | +use std::collections::BTreeSet; |
| 8 | + |
| 9 | +#[cfg(not(feature = "std"))] |
| 10 | +use {alloc::collections::BTreeSet, alloc::vec::Vec}; |
| 11 | + |
7 | 12 | /// A set of literals or names that failed to match |
8 | 13 | #[derive(PartialEq, Eq, Debug, Clone)] |
9 | 14 | pub struct ExpectedSet { |
10 | | - expected: HashSet<&'static str>, |
| 15 | + expected: BTreeSet<&'static str>, |
11 | 16 | } |
12 | 17 |
|
13 | 18 | impl ExpectedSet { |
@@ -58,6 +63,7 @@ impl<L: Display> Display for ParseError<L> { |
58 | 63 | } |
59 | 64 | } |
60 | 65 |
|
| 66 | +#[cfg(any(feature = "std", feature = "unstable"))] |
61 | 67 | impl<L: Display + Debug> ::std::error::Error for ParseError<L> { |
62 | 68 | fn description(&self) -> &str { |
63 | 69 | "parse error" |
@@ -88,7 +94,7 @@ impl ErrorState { |
88 | 94 | suppress_fail: 0, |
89 | 95 | reparsing_on_error: false, |
90 | 96 | expected: ExpectedSet { |
91 | | - expected: HashSet::new(), |
| 97 | + expected: BTreeSet::new(), |
92 | 98 | }, |
93 | 99 | } |
94 | 100 | } |
|
0 commit comments