Fix fallout of DSTifying PartialEq, PartialOrd, Eq, Ord
This commit is contained in:
parent
2896278313
commit
1e5f311d16
9 changed files with 172 additions and 0 deletions
|
@ -532,10 +532,17 @@ impl<'a> PartialOrd for MaybeOwned<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Ord for MaybeOwned<'a> {
|
impl<'a> Ord for MaybeOwned<'a> {
|
||||||
|
// NOTE(stage0): remove method after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &MaybeOwned) -> Ordering {
|
fn cmp(&self, other: &MaybeOwned) -> Ordering {
|
||||||
self.as_slice().cmp(&other.as_slice())
|
self.as_slice().cmp(&other.as_slice())
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: &MaybeOwned) -> Ordering {
|
||||||
|
self.as_slice().cmp(other.as_slice())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: Str> Equiv<S> for MaybeOwned<'a> {
|
impl<'a, S: Str> Equiv<S> for MaybeOwned<'a> {
|
||||||
|
|
|
@ -506,10 +506,17 @@ impl<T: PartialEq> PartialEq for Vec<T> {
|
||||||
|
|
||||||
#[unstable = "waiting on PartialOrd stability"]
|
#[unstable = "waiting on PartialOrd stability"]
|
||||||
impl<T: PartialOrd> PartialOrd for Vec<T> {
|
impl<T: PartialOrd> PartialOrd for Vec<T> {
|
||||||
|
// NOTE(stage0): remove method after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &Vec<T>) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Vec<T>) -> Option<Ordering> {
|
||||||
self.as_slice().partial_cmp(&other.as_slice())
|
self.as_slice().partial_cmp(&other.as_slice())
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
#[inline]
|
||||||
|
fn partial_cmp(&self, other: &Vec<T>) -> Option<Ordering> {
|
||||||
|
self.as_slice().partial_cmp(other.as_slice())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable = "waiting on Eq stability"]
|
#[unstable = "waiting on Eq stability"]
|
||||||
|
@ -523,10 +530,17 @@ impl<T: PartialEq, V: AsSlice<T>> Equiv<V> for Vec<T> {
|
||||||
|
|
||||||
#[unstable = "waiting on Ord stability"]
|
#[unstable = "waiting on Ord stability"]
|
||||||
impl<T: Ord> Ord for Vec<T> {
|
impl<T: Ord> Ord for Vec<T> {
|
||||||
|
// NOTE(stage0): remove method after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cmp(&self, other: &Vec<T>) -> Ordering {
|
fn cmp(&self, other: &Vec<T>) -> Ordering {
|
||||||
self.as_slice().cmp(&other.as_slice())
|
self.as_slice().cmp(&other.as_slice())
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
#[inline]
|
||||||
|
fn cmp(&self, other: &Vec<T>) -> Ordering {
|
||||||
|
self.as_slice().cmp(other.as_slice())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: #13996: need a way to mark the return value as `noalias`
|
// FIXME: #13996: need a way to mark the return value as `noalias`
|
||||||
|
|
|
@ -76,15 +76,27 @@ impl<'a, T: PartialEq> PartialEq for MaybeOwnedVector<'a, T> {
|
||||||
impl<'a, T: Eq> Eq for MaybeOwnedVector<'a, T> {}
|
impl<'a, T: Eq> Eq for MaybeOwnedVector<'a, T> {}
|
||||||
|
|
||||||
impl<'a, T: PartialOrd> PartialOrd for MaybeOwnedVector<'a, T> {
|
impl<'a, T: PartialOrd> PartialOrd for MaybeOwnedVector<'a, T> {
|
||||||
|
// NOTE(stage0): remove method after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
fn partial_cmp(&self, other: &MaybeOwnedVector<T>) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &MaybeOwnedVector<T>) -> Option<Ordering> {
|
||||||
self.as_slice().partial_cmp(&other.as_slice())
|
self.as_slice().partial_cmp(&other.as_slice())
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
fn partial_cmp(&self, other: &MaybeOwnedVector<T>) -> Option<Ordering> {
|
||||||
|
self.as_slice().partial_cmp(other.as_slice())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> {
|
impl<'a, T: Ord> Ord for MaybeOwnedVector<'a, T> {
|
||||||
|
// NOTE(stage0): remove method after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
fn cmp(&self, other: &MaybeOwnedVector<T>) -> Ordering {
|
fn cmp(&self, other: &MaybeOwnedVector<T>) -> Ordering {
|
||||||
self.as_slice().cmp(&other.as_slice())
|
self.as_slice().cmp(&other.as_slice())
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
fn cmp(&self, other: &MaybeOwnedVector<T>) -> Ordering {
|
||||||
|
self.as_slice().cmp(other.as_slice())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: PartialEq, V: AsSlice<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
|
impl<'a, T: PartialEq, V: AsSlice<T>> Equiv<V> for MaybeOwnedVector<'a, T> {
|
||||||
|
|
|
@ -1020,6 +1020,8 @@ fn is_valid_cap(c: char) -> bool {
|
||||||
|| (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
|| (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(stage0): remove function after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
fn find_class(classes: NamedClasses, name: &str) -> Option<Vec<(char, char)>> {
|
fn find_class(classes: NamedClasses, name: &str) -> Option<Vec<(char, char)>> {
|
||||||
match classes.binary_search(|&(s, _)| s.cmp(&name)) {
|
match classes.binary_search(|&(s, _)| s.cmp(&name)) {
|
||||||
slice::Found(i) => Some(classes[i].val1().to_vec()),
|
slice::Found(i) => Some(classes[i].val1().to_vec()),
|
||||||
|
@ -1027,6 +1029,14 @@ fn find_class(classes: NamedClasses, name: &str) -> Option<Vec<(char, char)>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
fn find_class(classes: NamedClasses, name: &str) -> Option<Vec<(char, char)>> {
|
||||||
|
match classes.binary_search(|&(s, _)| s.cmp(name)) {
|
||||||
|
slice::Found(i) => Some(classes[i].val1().to_vec()),
|
||||||
|
slice::NotFound(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type Class = &'static [(char, char)];
|
type Class = &'static [(char, char)];
|
||||||
type NamedClasses = &'static [(&'static str, &'static Class)];
|
type NamedClasses = &'static [(&'static str, &'static Class)];
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,8 @@ Available lint options:
|
||||||
|
|
||||||
");
|
");
|
||||||
|
|
||||||
|
// NOTE(stage0): remove function after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
fn sort_lints(lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> {
|
fn sort_lints(lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> {
|
||||||
let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect();
|
let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect();
|
||||||
lints.sort_by(|x: &&Lint, y: &&Lint| {
|
lints.sort_by(|x: &&Lint, y: &&Lint| {
|
||||||
|
@ -194,6 +196,21 @@ Available lint options:
|
||||||
lints
|
lints
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
fn sort_lints(lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> {
|
||||||
|
let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect();
|
||||||
|
lints.sort_by(|x: &&Lint, y: &&Lint| {
|
||||||
|
match x.default_level.cmp(&y.default_level) {
|
||||||
|
// The sort doesn't case-fold but it's doubtful we care.
|
||||||
|
Equal => x.name.cmp(y.name),
|
||||||
|
r => r,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
lints
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE(stage0): remove function after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
|
fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
|
||||||
-> Vec<(&'static str, Vec<lint::LintId>)> {
|
-> Vec<(&'static str, Vec<lint::LintId>)> {
|
||||||
let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect();
|
let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect();
|
||||||
|
@ -204,6 +221,17 @@ Available lint options:
|
||||||
lints
|
lints
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
|
||||||
|
-> Vec<(&'static str, Vec<lint::LintId>)> {
|
||||||
|
let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect();
|
||||||
|
lints.sort_by(|&(x, _): &(&'static str, Vec<lint::LintId>),
|
||||||
|
&(y, _): &(&'static str, Vec<lint::LintId>)| {
|
||||||
|
x.cmp(y)
|
||||||
|
});
|
||||||
|
lints
|
||||||
|
}
|
||||||
|
|
||||||
let (plugin, builtin) = lint_store.get_lints().partitioned(|&(_, p)| p);
|
let (plugin, builtin) = lint_store.get_lints().partitioned(|&(_, p)| p);
|
||||||
let plugin = sort_lints(plugin);
|
let plugin = sort_lints(plugin);
|
||||||
let builtin = sort_lints(builtin);
|
let builtin = sort_lints(builtin);
|
||||||
|
|
|
@ -121,10 +121,17 @@ impl PartialEq for CString {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialOrd for CString {
|
impl PartialOrd for CString {
|
||||||
|
// NOTE(stage0): remove method after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &CString) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &CString) -> Option<Ordering> {
|
||||||
self.as_bytes().partial_cmp(&other.as_bytes())
|
self.as_bytes().partial_cmp(&other.as_bytes())
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
#[inline]
|
||||||
|
fn partial_cmp(&self, other: &CString) -> Option<Ordering> {
|
||||||
|
self.as_bytes().partial_cmp(other.as_bytes())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for CString {}
|
impl Eq for CString {}
|
||||||
|
|
|
@ -890,6 +890,8 @@ impl Json {
|
||||||
|
|
||||||
/// If the Json value is an Object, returns the value associated with the provided key.
|
/// If the Json value is an Object, returns the value associated with the provided key.
|
||||||
/// Otherwise, returns None.
|
/// Otherwise, returns None.
|
||||||
|
// NOTE(stage0): remove function after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{
|
pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{
|
||||||
match self {
|
match self {
|
||||||
&Object(ref map) => map.find_with(|s| key.cmp(&s.as_slice())),
|
&Object(ref map) => map.find_with(|s| key.cmp(&s.as_slice())),
|
||||||
|
@ -897,6 +899,16 @@ impl Json {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the Json value is an Object, returns the value associated with the provided key.
|
||||||
|
/// Otherwise, returns None.
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{
|
||||||
|
match self {
|
||||||
|
&Object(ref map) => map.find_with(|s| key.cmp(s.as_slice())),
|
||||||
|
_ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Attempts to get a nested Json Object for each key in `keys`.
|
/// Attempts to get a nested Json Object for each key in `keys`.
|
||||||
/// If any key is found not to exist, find_path will return None.
|
/// If any key is found not to exist, find_path will return None.
|
||||||
/// Otherwise, it will return the Json value associated with the final key.
|
/// Otherwise, it will return the Json value associated with the final key.
|
||||||
|
@ -914,6 +926,8 @@ impl Json {
|
||||||
/// If the Json value is an Object, performs a depth-first search until
|
/// If the Json value is an Object, performs a depth-first search until
|
||||||
/// a value associated with the provided key is found. If no value is found
|
/// a value associated with the provided key is found. If no value is found
|
||||||
/// or the Json value is not an Object, returns None.
|
/// or the Json value is not an Object, returns None.
|
||||||
|
// NOTE(stage0): remove function after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
|
pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
|
||||||
match self {
|
match self {
|
||||||
&Object(ref map) => {
|
&Object(ref map) => {
|
||||||
|
@ -934,6 +948,30 @@ impl Json {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the Json value is an Object, performs a depth-first search until
|
||||||
|
/// a value associated with the provided key is found. If no value is found
|
||||||
|
/// or the Json value is not an Object, returns None.
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
|
||||||
|
match self {
|
||||||
|
&Object(ref map) => {
|
||||||
|
match map.find_with(|s| key.cmp(s.as_slice())) {
|
||||||
|
Some(json_value) => Some(json_value),
|
||||||
|
None => {
|
||||||
|
for (_, v) in map.iter() {
|
||||||
|
match v.search(key) {
|
||||||
|
x if x.is_some() => return x,
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the Json value is an Object. Returns false otherwise.
|
/// Returns true if the Json value is an Object. Returns false otherwise.
|
||||||
pub fn is_object<'a>(&'a self) -> bool {
|
pub fn is_object<'a>(&'a self) -> bool {
|
||||||
self.as_object().is_some()
|
self.as_object().is_some()
|
||||||
|
|
|
@ -97,9 +97,15 @@ pub struct RcStr {
|
||||||
impl Eq for RcStr {}
|
impl Eq for RcStr {}
|
||||||
|
|
||||||
impl Ord for RcStr {
|
impl Ord for RcStr {
|
||||||
|
// NOTE(stage0): remove method after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
fn cmp(&self, other: &RcStr) -> Ordering {
|
fn cmp(&self, other: &RcStr) -> Ordering {
|
||||||
self.as_slice().cmp(&other.as_slice())
|
self.as_slice().cmp(&other.as_slice())
|
||||||
}
|
}
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
fn cmp(&self, other: &RcStr) -> Ordering {
|
||||||
|
self.as_slice().cmp(other.as_slice())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Str for RcStr {
|
impl Str for RcStr {
|
||||||
|
|
|
@ -973,6 +973,8 @@ fn get_concurrency() -> uint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(stage0): remove function after a snapshot
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> {
|
pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> {
|
||||||
let mut filtered = tests;
|
let mut filtered = tests;
|
||||||
|
|
||||||
|
@ -1020,6 +1022,54 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
|
||||||
|
pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> {
|
||||||
|
let mut filtered = tests;
|
||||||
|
|
||||||
|
// Remove tests that don't match the test filter
|
||||||
|
filtered = match opts.filter {
|
||||||
|
None => filtered,
|
||||||
|
Some(ref re) => {
|
||||||
|
filtered.into_iter()
|
||||||
|
.filter(|test| re.is_match(test.desc.name.as_slice())).collect()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Maybe pull out the ignored test and unignore them
|
||||||
|
filtered = if !opts.run_ignored {
|
||||||
|
filtered
|
||||||
|
} else {
|
||||||
|
fn filter(test: TestDescAndFn) -> Option<TestDescAndFn> {
|
||||||
|
if test.desc.ignore {
|
||||||
|
let TestDescAndFn {desc, testfn} = test;
|
||||||
|
Some(TestDescAndFn {
|
||||||
|
desc: TestDesc {ignore: false, ..desc},
|
||||||
|
testfn: testfn
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
filtered.into_iter().filter_map(|x| filter(x)).collect()
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sort the tests alphabetically
|
||||||
|
filtered.sort_by(|t1, t2| t1.desc.name.as_slice().cmp(t2.desc.name.as_slice()));
|
||||||
|
|
||||||
|
// Shard the remaining tests, if sharding requested.
|
||||||
|
match opts.test_shard {
|
||||||
|
None => filtered,
|
||||||
|
Some((a,b)) => {
|
||||||
|
filtered.into_iter().enumerate()
|
||||||
|
// note: using a - 1 so that the valid shards, for example, are
|
||||||
|
// 1.2 and 2.2 instead of 0.2 and 1.2
|
||||||
|
.filter(|&(i,_)| i % b == (a - 1))
|
||||||
|
.map(|(_,t)| t)
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_test(opts: &TestOpts,
|
pub fn run_test(opts: &TestOpts,
|
||||||
force_ignore: bool,
|
force_ignore: bool,
|
||||||
test: TestDescAndFn,
|
test: TestDescAndFn,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue