Skip to content
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

Rollup of 8 pull requests #38320

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8b0b2b6
Add more examples to UpdSocket
GuillaumeGomez Nov 29, 2016
bee82e8
Avoid using locally installed Source Code Pro font (fixes #24355).
sourcefrog Dec 4, 2016
78fd220
ICH: Add test case for closure expressions.
michaelwoerister Dec 6, 2016
45b89b8
ICH: Add test case sensitive to function bodies in metadata.
michaelwoerister Dec 6, 2016
277675c
ICH: Add test case for indexing expressions.
michaelwoerister Dec 6, 2016
5c3a69e
ICH: Add test case for enum constructor expressions.
michaelwoerister Dec 6, 2016
9ccd5c5
ICH: Add missing annotations for struct constructor expr test case.
michaelwoerister Dec 6, 2016
f78aa4d
Run rustfmt on librustc_mir/hair/cx
srinivasreddy Oct 9, 2016
cf9ad0a
Indicate `BTreeSet` in docs is code-like.
frewsxcv Dec 7, 2016
57f998a
Improve and fix mpsc documentation
Cobrand Nov 22, 2016
d301dff
Document how `BTreeSet` iterator structures are created.
frewsxcv Dec 7, 2016
429f1d9
Simplify `BTreeSet::iter` doc example.
frewsxcv Dec 7, 2016
457c282
Indicate that `BTreeSet::iter` returns values in ascending order.
frewsxcv Dec 7, 2016
c6c3a27
rustdoc: Remove broken src links from reexported items from macros
ollie27 Dec 9, 2016
b7cd840
Handle Ctrl+C in the build script
achanda Dec 11, 2016
0bc2234
Rollup merge of #37052 - srinivasreddy:hair_cx, r=pnkfelix
frewsxcv Dec 12, 2016
0b815c2
Rollup merge of #37941 - Cobrand:docfix-issue-37915, r=GuillaumeGomez
frewsxcv Dec 12, 2016
79a478f
Rollup merge of #38067 - GuillaumeGomez:udp-doc, r=frewsxcv,nagisa
frewsxcv Dec 12, 2016
37036aa
Rollup merge of #38164 - sourcefrog:fonts, r=GuillaumeGomez
frewsxcv Dec 12, 2016
56cec2e
Rollup merge of #38202 - michaelwoerister:closure-ich-test, r=nikomat…
frewsxcv Dec 12, 2016
68654b9
Rollup merge of #38208 - frewsxcv:btreesetdocs, r=GuillaumeGomez
frewsxcv Dec 12, 2016
1702795
Rollup merge of #38264 - ollie27:rustdoc_src_macro, r=brson
frewsxcv Dec 12, 2016
1a2e37c
Rollup merge of #38299 - achanda:ctrl-c, r=brson
frewsxcv Dec 12, 2016
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
4 changes: 3 additions & 1 deletion src/doc/rust.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
src: local('Source Code Pro'), url("SourceCodePro-Regular.woff") format('woff');
/* Avoid using locally installed font because bad versions are in circulation:
* see https://github.com/rust-lang/rust/issues/24355 */
src: url("SourceCodePro-Regular.woff") format('woff');
}

*:not(body) {
Expand Down
71 changes: 60 additions & 11 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,53 +74,91 @@ pub struct BTreeSet<T> {
map: BTreeMap<T, ()>,
}

/// An iterator over a BTreeSet's items.
/// An iterator over a `BTreeSet`'s items.
///
/// This structure is created by the [`iter()`] method on [`BTreeSet`].
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`iter()`]: struct.BTreeSet.html#method.iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Iter<'a, T: 'a> {
iter: Keys<'a, T, ()>,
}

/// An owning iterator over a BTreeSet's items.
/// An owning iterator over a `BTreeSet`'s items.
///
/// This structure is created by the [`into_iter()`] method on [`BTreeSet`]
/// [`BTreeSet`] (provided by the [`IntoIterator`] trait).
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`IntoIterator`]: ../../iter/trait.IntoIterator.html
/// [`into_iter()`]: ../../iter/trait.IntoIterator.html#tymethod.into_iter
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<T> {
iter: ::btree_map::IntoIter<T, ()>,
}

/// An iterator over a sub-range of BTreeSet's items.
/// An iterator over a sub-range of `BTreeSet`'s items.
///
/// This structure is created by the [`range()`] method on [`BTreeSet`].
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`range()`]: struct.BTreeSet.html#method.range
pub struct Range<'a, T: 'a> {
iter: ::btree_map::Range<'a, T, ()>,
}

/// A lazy iterator producing elements in the set difference (in-order).
///
/// This structure is created by the [`difference()`] method on [`BTreeSet`].
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`difference()`]: struct.BTreeSet.html#method.difference
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Difference<'a, T: 'a> {
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}

/// A lazy iterator producing elements in the set symmetric difference (in-order).
///
/// This structure is created by the [`symmetric_difference()`] method on
/// [`BTreeSet`].
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`symmetric_difference()`]: struct.BTreeSet.html#method.symmetric_difference
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SymmetricDifference<'a, T: 'a> {
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}

/// A lazy iterator producing elements in the set intersection (in-order).
///
/// This structure is created by the [`intersection()`] method on [`BTreeSet`].
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`intersection()`]: struct.BTreeSet.html#method.intersection
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Intersection<'a, T: 'a> {
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}

/// A lazy iterator producing elements in the set union (in-order).
///
/// This structure is created by the [`union()`] method on [`BTreeSet`].
///
/// [`BTreeSet`]: struct.BTreeSet.html
/// [`union()`]: struct.BTreeSet.html#method.union
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Union<'a, T: 'a> {
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}

impl<T: Ord> BTreeSet<T> {
/// Makes a new BTreeSet with a reasonable choice of B.
/// Makes a new `BTreeSet` with a reasonable choice of B.
///
/// # Examples
///
Expand All @@ -137,21 +175,32 @@ impl<T: Ord> BTreeSet<T> {
}

impl<T> BTreeSet<T> {
/// Gets an iterator over the BTreeSet's contents.
/// Gets an iterator that visits the values in the `BTreeSet` in ascending order.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeSet;
///
/// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().cloned().collect();
/// let set: BTreeSet<usize> = [1, 2, 3].iter().cloned().collect();
/// let mut set_iter = set.iter();
/// assert_eq!(set_iter.next(), Some(&1));
/// assert_eq!(set_iter.next(), Some(&2));
/// assert_eq!(set_iter.next(), Some(&3));
/// assert_eq!(set_iter.next(), None);
/// ```
///
/// for x in set.iter() {
/// println!("{}", x);
/// }
/// Values returned by the iterator are returned in ascending order:
///
/// let v: Vec<_> = set.iter().cloned().collect();
/// assert_eq!(v, [1, 2, 3, 4]);
/// ```
/// use std::collections::BTreeSet;
///
/// let set: BTreeSet<usize> = [3, 1, 2].iter().cloned().collect();
/// let mut set_iter = set.iter();
/// assert_eq!(set_iter.next(), Some(&1));
/// assert_eq!(set_iter.next(), Some(&2));
/// assert_eq!(set_iter.next(), Some(&3));
/// assert_eq!(set_iter.next(), None);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter(&self) -> Iter<T> {
Expand Down
55 changes: 30 additions & 25 deletions src/librustc_mir/hair/cx/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,52 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
extent: cx.tcx.region_maps.node_extent(self.id),
span: self.span,
stmts: stmts,
expr: self.expr.to_ref()
expr: self.expr.to_ref(),
}
}
}

fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
block_id: ast::NodeId,
stmts: &'tcx [hir::Stmt])
-> Vec<StmtRef<'tcx>>
{
-> Vec<StmtRef<'tcx>> {
let mut result = vec![];
for (index, stmt) in stmts.iter().enumerate() {
match stmt.node {
hir::StmtExpr(ref expr, id) | hir::StmtSemi(ref expr, id) =>
hir::StmtExpr(ref expr, id) |
hir::StmtSemi(ref expr, id) => {
result.push(StmtRef::Mirror(Box::new(Stmt {
span: stmt.span,
kind: StmtKind::Expr {
scope: cx.tcx.region_maps.node_extent(id),
expr: expr.to_ref()
expr: expr.to_ref(),
},
})))
}
hir::StmtDecl(ref decl, id) => {
match decl.node {
hir::DeclItem(..) => {
// ignore for purposes of the MIR
}
}))),
hir::StmtDecl(ref decl, id) => match decl.node {
hir::DeclItem(..) => { /* ignore for purposes of the MIR */ }
hir::DeclLocal(ref local) => {
let remainder_extent = CodeExtentData::Remainder(BlockRemainder {
block: block_id,
first_statement_index: index as u32,
});
let remainder_extent =
cx.tcx.region_maps.lookup_code_extent(remainder_extent);
hir::DeclLocal(ref local) => {
let remainder_extent = CodeExtentData::Remainder(BlockRemainder {
block: block_id,
first_statement_index: index as u32,
});
let remainder_extent =
cx.tcx.region_maps.lookup_code_extent(remainder_extent);

let pattern = Pattern::from_hir(cx.tcx, &local.pat);
result.push(StmtRef::Mirror(Box::new(Stmt {
span: stmt.span,
kind: StmtKind::Let {
remainder_scope: remainder_extent,
init_scope: cx.tcx.region_maps.node_extent(id),
pattern: pattern,
initializer: local.init.to_ref(),
},
})));
let pattern = Pattern::from_hir(cx.tcx, &local.pat);
result.push(StmtRef::Mirror(Box::new(Stmt {
span: stmt.span,
kind: StmtKind::Let {
remainder_scope: remainder_extent,
init_scope: cx.tcx.region_maps.node_extent(id),
pattern: pattern,
initializer: local.init.to_ref(),
},
})));
}
}
}
}
Expand Down
Loading