Skip to content

Commit 00fa109

Browse files
committed
---
yaml --- r: 125951 b: refs/heads/try c: d799315 h: refs/heads/master i: 125949: 02d01e0 125947: da28054 125943: af607ec 125935: 5769884 125919: 844eb23 125887: 514f303 125823: f3ee14f 125695: 7ee0c8a 125439: 9aaee73 124927: f1baf7a v: v3
1 parent 63ef60c commit 00fa109

File tree

6 files changed

+9
-100
lines changed

6 files changed

+9
-100
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f2fa55903e378368ed9173560f03a0ef16e371c2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5-
refs/heads/try: 70972832b34cdb3965f95ac465701d9a56151500
5+
refs/heads/try: d7993153a49cf849cd41c259037f2d50ec2ab67c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/guide-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ differently.
118118
## Container iterators
119119

120120
Containers implement iteration over the contained elements by returning an
121-
iterator object. For example, vector slices several iterators available:
121+
iterator object. For example, for vector slices several iterators are available:
122122

123123
* `iter()` for immutable references to the elements
124124
* `mut_iter()` for mutable references to the elements
Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
Rust's lexical grammar is not context-free. Raw string literals are the source
22
of the problem. Informally, a raw string literal is an `r`, followed by `N`
33
hashes (where N can be zero), a quote, any characters, then a quote followed
4-
by `N` hashes. Critically, once inside the first pair of quotes,
5-
another quote cannot be followed by `N` consecutive hashes. e.g.
6-
`r###""###"###` is invalid.
7-
8-
This grammar describes this as best possible:
4+
by `N` hashes. This grammar describes this as best possible:
95

106
R -> 'r' S
117
S -> '"' B '"'
@@ -26,39 +22,8 @@ accepted as one by the above grammar, using the derivation:
2622
(Where `T : U` means the rule `T` is applied, and `U` is the remainder of the
2723
string.) The difficulty arises from the fact that it is fundamentally
2824
context-sensitive. In particular, the context needed is the number of hashes.
29-
30-
To prove that Rust's string literals are not context-free, we will use
31-
the fact that context-free languages are closed under intersection with
32-
regular languages, and the
33-
[pumping lemma for context-free languages](https://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_languages).
34-
35-
Consider the regular language `R = r#+""#*"#+`. If Rust's raw string literals are
36-
context-free, then their intersection with `R`, `R'`, should also be context-free.
37-
Therefore, to prove that raw string literals are not context-free,
38-
it is sufficient to prove that `R'` is not context-free.
39-
40-
The language `R'` is `{r#^n""#^m"#^n | m < n}`.
41-
42-
Assume `R'` *is* context-free. Then `R'` has some pumping length `p > 0` for which
43-
the pumping lemma applies. Consider the following string `s` in `R'`:
44-
45-
`r#^p""#^{p-1}"#^p`
46-
47-
e.g. for `p = 2`: `s = r##""#"##`
48-
49-
Then `s = uvwxy` for some choice of `uvwxy` such that `vx` is non-empty,
50-
`|vwx| < p+1`, and `uv^iwx^iy` is in `R'` for all `i >= 0`.
51-
52-
Neither `v` nor `x` can contain a `"` or `r`, as the number of these characters
53-
in any string in `R'` is fixed. So `v` and `x` contain only hashes.
54-
Consequently, of the three sequences of hashes, `v` and `x` combined
55-
can only pump two of them.
56-
If we ever choose the central sequence of hashes, then one of the outer sequences
57-
will not grow when we pump, leading to an imbalance between the outer sequences.
58-
Therefore, we must pump both outer sequences of hashes. However,
59-
there are `p+2` characters between these two sequences of hashes, and `|vwx|` must
60-
be less than `p+1`. Therefore we have a contradiction, and `R'` must not be
61-
context-free.
62-
63-
Since `R'` is not context-free, it follows that the Rust's raw string literals
64-
must not be context-free.
25+
I know of no way to resolve this, but also have not come up with a proof that
26+
it is not context sensitive. Such a proof would probably use the pumping lemma
27+
for context-free languages, but I (cmr) could not come up with a proof after
28+
spending a few hours on it, and decided my time best spent elsewhere. Pull
29+
request welcome!

branches/try/src/libcollections/ringbuf.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use core::cmp;
1919
use core::default::Default;
2020
use core::fmt;
2121
use core::iter::RandomAccessIterator;
22-
use core::iter;
23-
use std::hash::{Writer, Hash};
2422

2523
use {Deque, Collection, Mutable, MutableSeq};
2624
use vec::Vec;
@@ -452,21 +450,6 @@ impl<A: PartialEq> PartialEq for RingBuf<A> {
452450
}
453451
}
454452

455-
impl<A: PartialOrd> PartialOrd for RingBuf<A> {
456-
fn partial_cmp(&self, other: &RingBuf<A>) -> Option<Ordering> {
457-
iter::order::partial_cmp(self.iter(), other.iter())
458-
}
459-
}
460-
461-
impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
462-
fn hash(&self, state: &mut S) {
463-
self.len().hash(state);
464-
for elt in self.iter() {
465-
elt.hash(state);
466-
}
467-
}
468-
}
469-
470453
impl<A> FromIterator<A> for RingBuf<A> {
471454
fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
472455
let (lower, _) = iterator.size_hint();
@@ -502,7 +485,6 @@ mod tests {
502485
use std::fmt::Show;
503486
use std::prelude::*;
504487
use std::gc::{GC, Gc};
505-
use std::hash;
506488
use test::Bencher;
507489
use test;
508490

@@ -930,37 +912,6 @@ mod tests {
930912
assert!(e == RingBuf::new());
931913
}
932914

933-
#[test]
934-
fn test_hash() {
935-
let mut x = RingBuf::new();
936-
let mut y = RingBuf::new();
937-
938-
x.push(1i);
939-
x.push(2);
940-
x.push(3);
941-
942-
y.push(0i);
943-
y.push(1i);
944-
y.pop_front();
945-
y.push(2);
946-
y.push(3);
947-
948-
assert!(hash::hash(&x) == hash::hash(&y));
949-
}
950-
951-
#[test]
952-
fn test_ord() {
953-
let x = RingBuf::new();
954-
let mut y = RingBuf::new();
955-
y.push(1i);
956-
y.push(2);
957-
y.push(3);
958-
assert!(x < y);
959-
assert!(y > x);
960-
assert!(x <= x);
961-
assert!(x >= x);
962-
}
963-
964915
#[test]
965916
fn test_show() {
966917
let ringbuf: RingBuf<int> = range(0i, 10).collect();

branches/try/src/librustdoc/html/render.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,12 +845,8 @@ impl DocFolder for Cache {
845845
}
846846
_ => (None, Some(self.stack.as_slice()))
847847
};
848-
let hidden_field = match item.inner {
849-
clean::StructFieldItem(clean::HiddenStructField) => true,
850-
_ => false
851-
};
852848
match parent {
853-
(parent, Some(path)) if !self.privmod && !hidden_field => {
849+
(parent, Some(path)) if !self.privmod => {
854850
self.search_index.push(IndexItem {
855851
ty: shortty(&item),
856852
name: s.to_string(),

branches/try/src/libstd/collections/hashmap.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,6 @@ impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
18501850
///
18511851
/// # Example
18521852
///
1853-
/// ```
18541853
/// use std::collections::HashSet;
18551854
/// let mut set: HashSet<int> = HashSet::new();
18561855
/// ```
@@ -1864,7 +1863,6 @@ impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
18641863
///
18651864
/// # Example
18661865
///
1867-
/// ```
18681866
/// use std::collections::HashSet;
18691867
/// let mut set: HashSet<int> = HashSet::with_capacity(10);
18701868
/// ```
@@ -1922,7 +1920,6 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
19221920
///
19231921
/// # Example
19241922
///
1925-
/// ```
19261923
/// use std::collections::HashSet;
19271924
/// let mut set: HashSet<int> = HashSet::new();
19281925
/// set.reserve(10);

0 commit comments

Comments
 (0)