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 7 pull requests #65878

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6b02362
Add 'must_use' to all functions 'fn(float) -> float'
Aug 24, 2019
ba2a1fa
Add reason for each 'must_use'
Aug 28, 2019
c5b0003
Annotate functions taking extra args
Aug 28, 2019
54cb728
Let 'clamp' be invoked without using return value; used in tests
Aug 28, 2019
1aa5d0c
Restore 'must_use' for 'clamp'; fix warning for tests
Sep 5, 2019
65af429
Stabilize `Option::flatten`
eopb Sep 24, 2019
1632940
syntax/attr: reduce reliance on parser
Centril Oct 9, 2019
fb12c70
rustc, rustc_passes: don't depend on syntax_expand.
Centril Oct 9, 2019
993b920
librustc_lexer: Enhance documentation
popzxc Oct 26, 2019
3f98078
doc: explain why it is unsafe to construct Vec<u8> from Vec<u16>
tesuji Oct 27, 2019
b26ddb8
Point at local similarly named element and tweak references to variants
estebank Oct 15, 2019
b626448
doc: introduce `once` in `iter::chain` document
tesuji Oct 27, 2019
9784aad
Rollup merge of #63871 - BatmanAoD:FloatFnMustUse, r=withoutboats
Centril Oct 27, 2019
ad680c3
Rollup merge of #64747 - ethanboxx:master, r=Centril
Centril Oct 27, 2019
af6b43a
Rollup merge of #65421 - estebank:variants, r=petrochenkov
Centril Oct 27, 2019
7e8599d
Rollup merge of #65792 - Centril:split-syntax-2, r=petrochenkov
Centril Oct 27, 2019
2cee7ba
Rollup merge of #65849 - popzxc:document-librustc_lexer, r=petrochenkov
Centril Oct 27, 2019
5d09591
Rollup merge of #65873 - lzutao:doc-vec-from-raw-parts, r=rkruppe
Centril Oct 27, 2019
e5d8efc
Rollup merge of #65877 - lzutao:iter-chain-once, r=Centril
Centril Oct 27, 2019
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
3 changes: 0 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,6 @@ dependencies = [
"serialize",
"smallvec",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand Down Expand Up @@ -3451,7 +3450,6 @@ dependencies = [
"rustc_target",
"serialize",
"syntax",
"syntax_expand",
"syntax_pos",
"tempfile",
]
Expand Down Expand Up @@ -3707,7 +3705,6 @@ dependencies = [
"rustc_index",
"rustc_target",
"syntax",
"syntax_expand",
"syntax_pos",
]

Expand Down
1 change: 0 additions & 1 deletion src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![feature(drain_filter)]
#![feature(exact_size_is_empty)]
#![feature(new_uninit)]
#![feature(option_flattening)]
#![feature(pattern)]
#![feature(trusted_len)]
#![feature(try_reserve)]
Expand Down
6 changes: 5 additions & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ impl<T> Vec<T> {
///
/// Violating these may cause problems like corrupting the allocator's
/// internal data structures. For example it is **not** safe
/// to build a `Vec<u8>` from a pointer to a C `char` array and a `size_t`.
/// to build a `Vec<u8>` from a pointer to a C `char` array with length `size_t`.
/// It's also not safe to build one from a `Vec<u16>` and its length, because
/// the allocator cares about the alignment, and these two types have different
/// alignments. The buffer was allocated with alignment 2 (for `u16`), but after
/// turning it into a `Vec<u8>` it'll be deallocated with alignment 1.
///
/// The ownership of `ptr` is effectively transferred to the
/// `Vec<T>` which may then deallocate, reallocate or change the
Expand Down
21 changes: 18 additions & 3 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ pub trait Iterator {
///
/// In other words, it links two iterators together, in a chain. 🔗
///
/// [`once`] is commonly used to adapt a single value into a chain of
/// other kinds of iteration.
///
/// # Examples
///
/// Basic usage:
Expand All @@ -408,9 +411,6 @@ pub trait Iterator {
/// [`Iterator`] itself. For example, slices (`&[T]`) implement
/// [`IntoIterator`], and so can be passed to `chain()` directly:
///
/// [`IntoIterator`]: trait.IntoIterator.html
/// [`Iterator`]: trait.Iterator.html
///
/// ```
/// let s1 = &[1, 2, 3];
/// let s2 = &[4, 5, 6];
Expand All @@ -425,6 +425,21 @@ pub trait Iterator {
/// assert_eq!(iter.next(), Some(&6));
/// assert_eq!(iter.next(), None);
/// ```
///
/// If you work with Windows API, you may wish to convert [`OsStr`] to `Vec<u16>`:
///
/// ```
/// #[cfg(windows)]
/// fn os_str_to_utf16(s: &OsStr) -> Vec<u16> {
/// use std::os::windows::ffi::OsStrExt;
/// s.encode_wide().chain(std::iter::once(0)).collect()
/// }
/// ```
///
/// [`once`]: fn.once.html
/// [`Iterator`]: trait.Iterator.html
/// [`IntoIterator`]: trait.IntoIterator.html
/// [`OsStr`]: ../../std/ffi/struct.OsStr.html
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter> where
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,6 @@ impl<T> Option<Option<T>> {
/// # Examples
/// Basic usage:
/// ```
/// #![feature(option_flattening)]
/// let x: Option<Option<u32>> = Some(Some(6));
/// assert_eq!(Some(6), x.flatten());
///
Expand All @@ -1579,13 +1578,12 @@ impl<T> Option<Option<T>> {
/// ```
/// Flattening once only removes one level of nesting:
/// ```
/// #![feature(option_flattening)]
/// let x: Option<Option<Option<u32>>> = Some(Some(Some(6)));
/// assert_eq!(Some(Some(6)), x.flatten());
/// assert_eq!(Some(6), x.flatten().flatten());
/// ```
#[inline]
#[unstable(feature = "option_flattening", issue = "60258")]
#[stable(feature = "option_flattening", since = "1.40.0")]
pub fn flatten(self) -> Option<T> {
self.and_then(convert::identity)
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ rustc_index = { path = "../librustc_index" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
parking_lot = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::ty;
use crate::util::nodemap::DefIdMap;

use syntax::ast;
use syntax_expand::base::MacroKind;
use syntax::ast::NodeId;
use syntax_pos::hygiene::MacroKind;
use syntax_pos::Span;
use rustc_macros::HashStable;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use syntax::ast;
use syntax::ptr::P as AstP;
use syntax::ast::*;
use syntax::errors;
use syntax_expand::base::SpecialDerives;
use syntax::expand::SpecialDerives;
use syntax::print::pprust;
use syntax::parse::token::{self, Nonterminal, Token};
use syntax::tokenstream::{TokenStream, TokenTree};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use smallvec::SmallVec;
use syntax::attr;
use syntax::ast::*;
use syntax::visit::{self, Visitor};
use syntax_expand::base::SpecialDerives;
use syntax::expand::SpecialDerives;
use syntax::source_map::{respan, DesugaringKind, Spanned};
use syntax::symbol::{kw, sym};
use syntax_pos::Span;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::hir::map::definitions::*;
use crate::hir::def_id::DefIndex;

use syntax::ast::*;
use syntax_expand::hygiene::ExpnId;
use syntax::visit;
use syntax::symbol::{kw, sym};
use syntax::parse::token::{self, Token};
use syntax_pos::hygiene::ExpnId;
use syntax_pos::Span;

/// Creates `DefId`s for nodes in the AST.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use std::borrow::Borrow;
use std::fmt::Write;
use std::hash::Hash;
use syntax::ast;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::{Symbol, sym};
use syntax_pos::symbol::{Symbol, sym};
use syntax_pos::hygiene::ExpnId;
use syntax_pos::{Span, DUMMY_SP};

/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_data_structures::svh::Svh;
use rustc_index::vec::IndexVec;
use syntax::ast::{self, Name, NodeId};
use syntax::source_map::Spanned;
use syntax_expand::base::MacroKind;
use syntax_pos::hygiene::MacroKind;
use syntax_pos::{Span, DUMMY_SP};

pub mod blocks;
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ use std::cell::RefCell;

use syntax::ast;
use syntax::source_map::SourceMap;
use syntax_expand::hygiene::SyntaxContext;
use syntax::symbol::Symbol;
use syntax::tokenstream::DelimSpan;
use syntax_pos::{Span, DUMMY_SP};
use syntax_pos::hygiene;
use syntax_pos::hygiene::{self, SyntaxContext};

use rustc_data_structures::stable_hasher::{
HashStable, StableHasher, ToStableHashKey,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl_stable_hash_for!(enum ::syntax::ast::AsmDialect {
Intel
});

impl_stable_hash_for!(enum ::syntax_expand::base::MacroKind {
impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind {
Bang,
Attr,
Derive,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use syntax::ast;
use syntax::source_map::{MultiSpan, ExpnKind, DesugaringKind};
use syntax::early_buffered_lints::BufferedEarlyLintId;
use syntax::edition::Edition;
use syntax_expand::base::MacroKind;
use syntax::symbol::{Symbol, sym};
use syntax_pos::hygiene::MacroKind;
use syntax_pos::Span;

pub use crate::lint::context::{LateContext, EarlyContext, LintContext, LintStore,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use errors::emitter::HumanReadableErrorType;
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
use syntax::ast::{self, NodeId};
use syntax::edition::Edition;
use syntax_expand::allocator::AllocatorKind;
use syntax::expand::allocator::AllocatorKind;
use syntax::feature_gate::{self, AttributeType};
use syntax::json::JsonEmitter;
use syntax::source_map;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ use std::{mem, ptr};
use std::ops::Range;
use syntax::ast::{self, Name, Ident, NodeId};
use syntax::attr;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::{kw, sym, Symbol};
use syntax_pos::symbol::{kw, sym, Symbol};
use syntax_pos::hygiene::ExpnId;
use syntax_pos::Span;

use smallvec;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ffi::CString;
use crate::attributes;
use libc::c_uint;
use rustc::ty::TyCtxt;
use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
use syntax::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};

use crate::ModuleLlvm;
use crate::llvm::{self, False, True};
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_codegen_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ extern crate rustc_driver as _;

#[macro_use] extern crate log;
extern crate syntax;
extern crate syntax_expand;
extern crate syntax_pos;
extern crate rustc_errors as errors;

Expand All @@ -49,7 +48,7 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul
use rustc_codegen_ssa::CompiledModule;
use errors::{FatalError, Handler};
use rustc::dep_graph::WorkProduct;
use syntax_expand::allocator::AllocatorKind;
use syntax::expand::allocator::AllocatorKind;
pub use llvm_util::target_features;
use std::any::Any;
use std::sync::Arc;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ tempfile = "3.1"

rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
rustc = { path = "../librustc" }
rustc_apfloat = { path = "../librustc_apfloat" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc::ty::query::Providers;
use rustc::ty::subst::SubstsRef;
use rustc::util::nodemap::{FxHashMap, DefIdMap};
use rustc_index::vec::IndexVec;
use syntax_expand::allocator::ALLOCATOR_METHODS;
use syntax::expand::allocator::ALLOCATOR_METHODS;

pub type ExportedSymbols = FxHashMap<
CrateNum,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use rustc_errors::{Handler, Level, FatalError, DiagnosticId, SourceMapperDyn};
use rustc_errors::emitter::{Emitter};
use rustc_target::spec::MergeFunctions;
use syntax::attr;
use syntax_expand::hygiene::ExpnId;
use syntax_pos::hygiene::ExpnId;
use syntax_pos::symbol::{Symbol, sym};
use jobserver::{Client, Acquired};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc::ty::TyCtxt;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
use std::sync::Arc;
use std::sync::mpsc;
use syntax_expand::allocator::AllocatorKind;
use syntax::expand::allocator::AllocatorKind;
use syntax_pos::symbol::Symbol;

pub trait BackendTypes {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ pub fn lower_to_hir(

// Discard hygiene data, which isn't required after lowering to HIR.
if !sess.opts.debugging_opts.keep_hygiene_data {
syntax_expand::hygiene::clear_syntax_context_map();
syntax_pos::hygiene::clear_syntax_context_map();
}

Ok(hir_forest)
Expand Down
19 changes: 18 additions & 1 deletion src/librustc_lexer/src/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use std::str::Chars;

/// Peekable iterator over a char sequence.
///
/// Next characters can be peeked via `nth_char` method,
/// and position can be shifted forward via `bump` method.
pub(crate) struct Cursor<'a> {
initial_len: usize,
chars: Chars<'a>,
Expand All @@ -18,7 +22,9 @@ impl<'a> Cursor<'a> {
prev: EOF_CHAR,
}
}

/// For debug assertions only
/// Returns the last eaten symbol (or '\0' in release builds).
pub(crate) fn prev(&self) -> char {
#[cfg(debug_assertions)]
{
Expand All @@ -30,19 +36,30 @@ impl<'a> Cursor<'a> {
'\0'
}
}

/// Returns nth character relative to the current cursor position.
/// If requested position doesn't exist, `EOF_CHAR` is returned.
/// However, getting `EOF_CHAR` doesn't always mean actual end of file,
/// it should be checked with `is_eof` method.
pub(crate) fn nth_char(&self, n: usize) -> char {
self.chars().nth(n).unwrap_or(EOF_CHAR)
}

/// Checks if there is nothing more to consume.
pub(crate) fn is_eof(&self) -> bool {
self.chars.as_str().is_empty()
}

/// Returns amount of already consumed symbols.
pub(crate) fn len_consumed(&self) -> usize {
self.initial_len - self.chars.as_str().len()
}
/// Returns an iterator over the remaining characters.

/// Returns a `Chars` iterator over the remaining characters.
fn chars(&self) -> Chars<'a> {
self.chars.clone()
}

/// Moves to the next character.
pub(crate) fn bump(&mut self) -> Option<char> {
let c = self.chars.next()?;
Expand Down
Loading