Skip to content

Commit

Permalink
Auto merge of #56557 - pietroalbini:rollup, r=pietroalbini
Browse files Browse the repository at this point in the history
Rollup of 11 pull requests

Successful merges:

 - #56315 (Rustdoc inline macro reexport)
 - #56332 ([rustdoc] Specific crate search)
 - #56362 (Stabilise exhaustive integer patterns)
 - #56426 (libsyntax_pos: A few tweaks)
 - #56441 (rustbuild: Fix issues with compiler docs)
 - #56446 (pass the parameter environment to `traits::find_associated_item`)
 - #56500 (cleanup: remove static lifetimes from consts)
 - #56525 (Avoid extra copy and syscall in std::env::current_exe)
 - #56528 (Remove unused dependency (rustc_lint -> rustc_mir))
 - #56548 (Optimized string FromIterator + Extend impls)
 - #56553 (Don't print the profiling summary to stdout when -Zprofile-json is set)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Dec 6, 2018
2 parents 128a1fa + cd1ee5e commit 367e783
Show file tree
Hide file tree
Showing 100 changed files with 700 additions and 400 deletions.
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,6 @@ dependencies = [
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_mir 0.0.0",
"rustc_target 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
Expand Down
17 changes: 11 additions & 6 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,6 @@ impl Step for Rustc {
return;
}

// Build libstd docs so that we generate relative links.
builder.ensure(Std { stage, target });

// Build rustc.
builder.ensure(compile::Rustc { compiler, target });

Expand All @@ -718,12 +715,16 @@ impl Step for Rustc {

// Find dependencies for top level crates.
let mut compiler_crates = HashSet::new();
for root_crate in &["rustc", "rustc_driver", "rustc_codegen_llvm"] {
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
let interned_root_crate = INTERNER.intern_str(root_crate);
find_compiler_crates(builder, &interned_root_crate, &mut compiler_crates);
}

for krate in &compiler_crates {
// Create all crate output directories first to make sure rustdoc uses
// relative links.
// FIXME: Cargo should probably do this itself.
t!(fs::create_dir_all(out_dir.join(krate)));
cargo.arg("-p").arg(krate);
}

Expand Down Expand Up @@ -797,8 +798,8 @@ impl Step for Rustdoc {
return;
}

// Build libstd docs so that we generate relative links.
builder.ensure(Std { stage, target });
// Build rustc docs so that we generate relative links.
builder.ensure(Rustc { stage, target });

// Build rustdoc.
builder.ensure(tool::Rustdoc { host: compiler.host });
Expand All @@ -822,6 +823,10 @@ impl Step for Rustdoc {
&[]
);

// Only include compiler crates, no dependencies of those, such as `libc`.
cargo.arg("--no-deps");
cargo.arg("-p").arg("rustdoc");

cargo.env("RUSTDOCFLAGS", "--document-private-items");
builder.run(&mut cargo);
}
Expand Down
4 changes: 2 additions & 2 deletions src/grammar/parser-lalr.y
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,14 @@ fn_anon_params
;

fn_params_with_self
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
| '(' maybe_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
;

fn_anon_params_with_self
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
| '(' maybe_anon_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
Expand Down
49 changes: 30 additions & 19 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl String {
return Cow::Borrowed("");
};

const REPLACEMENT: &'static str = "\u{FFFD}";
const REPLACEMENT: &str = "\u{FFFD}";

let mut res = String::with_capacity(v.len());
res.push_str(first_valid);
Expand Down Expand Up @@ -1732,18 +1732,37 @@ impl<'a> FromIterator<&'a str> for String {
#[stable(feature = "extend_string", since = "1.4.0")]
impl FromIterator<String> for String {
fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> String {
let mut buf = String::new();
buf.extend(iter);
buf
let mut iterator = iter.into_iter();

// Because we're iterating over `String`s, we can avoid at least
// one allocation by getting the first string from the iterator
// and appending to it all the subsequent strings.
match iterator.next() {
None => String::new(),
Some(mut buf) => {
buf.extend(iterator);
buf
}
}
}
}

#[stable(feature = "herd_cows", since = "1.19.0")]
impl<'a> FromIterator<Cow<'a, str>> for String {
fn from_iter<I: IntoIterator<Item = Cow<'a, str>>>(iter: I) -> String {
let mut buf = String::new();
buf.extend(iter);
buf
let mut iterator = iter.into_iter();

// Because we're iterating over CoWs, we can (potentially) avoid at least
// one allocation by getting the first item and appending to it all the
// subsequent items.
match iterator.next() {
None => String::new(),
Some(cow) => {
let mut buf = cow.into_owned();
buf.extend(iterator);
buf
}
}
}
}

Expand All @@ -1753,9 +1772,7 @@ impl Extend<char> for String {
let iterator = iter.into_iter();
let (lower_bound, _) = iterator.size_hint();
self.reserve(lower_bound);
for ch in iterator {
self.push(ch)
}
iterator.for_each(move |c| self.push(c));
}
}

Expand All @@ -1769,27 +1786,21 @@ impl<'a> Extend<&'a char> for String {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Extend<&'a str> for String {
fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I) {
for s in iter {
self.push_str(s)
}
iter.into_iter().for_each(move |s| self.push_str(s));
}
}

#[stable(feature = "extend_string", since = "1.4.0")]
impl Extend<String> for String {
fn extend<I: IntoIterator<Item = String>>(&mut self, iter: I) {
for s in iter {
self.push_str(&s)
}
iter.into_iter().for_each(move |s| self.push_str(&s));
}
}

#[stable(feature = "herd_cows", since = "1.19.0")]
impl<'a> Extend<Cow<'a, str>> for String {
fn extend<I: IntoIterator<Item = Cow<'a, str>>>(&mut self, iter: I) {
for s in iter {
self.push_str(&s)
}
iter.into_iter().for_each(move |s| self.push_str(&s));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ impl<'a> Formatter<'a> {
for part in formatted.parts {
match *part {
flt2dec::Part::Zero(mut nzeroes) => {
const ZEROES: &'static str = // 64 zeroes
const ZEROES: &str = // 64 zeroes
"0000000000000000000000000000000000000000000000000000000000000000";
while nzeroes > ZEROES.len() {
self.buf.write_str(ZEROES)?;
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/unicode/printable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub(crate) fn is_printable(x: char) -> bool {
}
}

const SINGLETONS0U: &'static [(u8, u8)] = &[
const SINGLETONS0U: &[(u8, u8)] = &[
(0x00, 1),
(0x03, 5),
(0x05, 6),
Expand Down Expand Up @@ -122,7 +122,7 @@ const SINGLETONS0U: &'static [(u8, u8)] = &[
(0xfe, 3),
(0xff, 9),
];
const SINGLETONS0L: &'static [u8] = &[
const SINGLETONS0L: &[u8] = &[
0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
0x58, 0x8b, 0x8c, 0x90, 0x1c, 0x1d, 0xdd, 0x0e,
0x0f, 0x4b, 0x4c, 0xfb, 0xfc, 0x2e, 0x2f, 0x3f,
Expand Down Expand Up @@ -162,7 +162,7 @@ const SINGLETONS0L: &'static [u8] = &[
0x91, 0xfe, 0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9,
0xd0, 0xd1, 0xd8, 0xd9, 0xe7, 0xfe, 0xff,
];
const SINGLETONS1U: &'static [(u8, u8)] = &[
const SINGLETONS1U: &[(u8, u8)] = &[
(0x00, 6),
(0x01, 1),
(0x03, 1),
Expand Down Expand Up @@ -197,7 +197,7 @@ const SINGLETONS1U: &'static [(u8, u8)] = &[
(0xf0, 4),
(0xf9, 4),
];
const SINGLETONS1L: &'static [u8] = &[
const SINGLETONS1L: &[u8] = &[
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36,
Expand All @@ -219,7 +219,7 @@ const SINGLETONS1L: &'static [u8] = &[
0x78, 0x7d, 0x7f, 0x8a, 0xa4, 0xaa, 0xaf, 0xb0,
0xc0, 0xd0, 0x3f, 0x71, 0x72, 0x7b,
];
const NORMAL0: &'static [u8] = &[
const NORMAL0: &[u8] = &[
0x00, 0x20,
0x5f, 0x22,
0x82, 0xdf, 0x04,
Expand Down Expand Up @@ -363,7 +363,7 @@ const NORMAL0: &'static [u8] = &[
0x1b, 0x03,
0x0f, 0x0d,
];
const NORMAL1: &'static [u8] = &[
const NORMAL1: &[u8] = &[
0x5e, 0x22,
0x7b, 0x05,
0x03, 0x04,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ macro_rules! define_dep_nodes {
#[allow(dead_code, non_upper_case_globals)]
pub mod label_strs {
$(
pub const $variant: &'static str = stringify!($variant);
pub const $variant: &str = stringify!($variant);
)*
}
);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ impl<'a> LoweringContext<'a> {
None,
P(hir::Path {
def: self.expect_full_def(t.id),
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfType.ident())],
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfUpper.ident())],
span: t.span,
}),
)),
Expand Down Expand Up @@ -2425,7 +2425,7 @@ impl<'a> LoweringContext<'a> {
// Don't expose `Self` (recovered "keyword used as ident" parse error).
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
// Instead, use gensym("Self") to create a distinct name that looks the same.
let ident = if param.ident.name == keywords::SelfType.name() {
let ident = if param.ident.name == keywords::SelfUpper.name() {
param.ident.gensym()
} else {
param.ident
Expand Down Expand Up @@ -2981,7 +2981,7 @@ impl<'a> LoweringContext<'a> {

// Correctly resolve `self` imports
if path.segments.len() > 1
&& path.segments.last().unwrap().ident.name == keywords::SelfValue.name()
&& path.segments.last().unwrap().ident.name == keywords::SelfLower.name()
{
let _ = path.segments.pop();
if rename.is_none() {
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 @@ -475,7 +475,7 @@ impl<'hir> Map<'hir> {

pub fn ty_param_name(&self, id: NodeId) -> Name {
match self.get(id) {
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfType.name(),
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfUpper.name(),
Node::GenericParam(param) => param.name.ident().name,
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub struct Path {

impl Path {
pub fn is_global(&self) -> bool {
!self.segments.is_empty() && self.segments[0].ident.name == keywords::CrateRoot.name()
!self.segments.is_empty() && self.segments[0].ident.name == keywords::PathRoot.name()
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub trait PpAnn {

pub struct NoAnn;
impl PpAnn for NoAnn {}
pub const NO_ANN: &'static dyn PpAnn = &NoAnn;
pub const NO_ANN: &dyn PpAnn = &NoAnn;

impl PpAnn for hir::Crate {
fn try_fetch_item(&self, item: ast::NodeId) -> Option<&hir::Item> {
Expand Down Expand Up @@ -1622,7 +1622,7 @@ impl<'a> State<'a> {
if i > 0 {
self.s.word("::")?
}
if segment.ident.name != keywords::CrateRoot.name() &&
if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
Expand All @@ -1636,7 +1636,7 @@ impl<'a> State<'a> {
}

pub fn print_path_segment(&mut self, segment: &hir::PathSegment) -> io::Result<()> {
if segment.ident.name != keywords::CrateRoot.name() &&
if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
Expand Down Expand Up @@ -1664,7 +1664,7 @@ impl<'a> State<'a> {
if i > 0 {
self.s.word("::")?
}
if segment.ident.name != keywords::CrateRoot.name() &&
if segment.ident.name != keywords::PathRoot.name() &&
segment.ident.name != keywords::DollarCrate.name() {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
Expand Down
12 changes: 4 additions & 8 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,10 @@ impl_stable_hash_for!(struct ::syntax::attr::Stability {
const_stability
});

impl<'a> HashStable<StableHashingContext<'a>>
for ::syntax::edition::Edition {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
mem::discriminant(self).hash_stable(hcx, hasher);
}
}
impl_stable_hash_for!(enum ::syntax::edition::Edition {
Edition2015,
Edition2018,
});

impl<'a> HashStable<StableHashingContext<'a>>
for ::syntax::attr::StabilityLevel {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/ich/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ mod impls_misc;
mod impls_ty;
mod impls_syntax;

pub const ATTR_DIRTY: &'static str = "rustc_dirty";
pub const ATTR_CLEAN: &'static str = "rustc_clean";
pub const ATTR_IF_THIS_CHANGED: &'static str = "rustc_if_this_changed";
pub const ATTR_THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need";
pub const ATTR_PARTITION_REUSED: &'static str = "rustc_partition_reused";
pub const ATTR_PARTITION_CODEGENED: &'static str = "rustc_partition_codegened";
pub const ATTR_EXPECTED_CGU_REUSE: &'static str = "rustc_expected_cgu_reuse";
pub const ATTR_DIRTY: &str = "rustc_dirty";
pub const ATTR_CLEAN: &str = "rustc_clean";
pub const ATTR_IF_THIS_CHANGED: &str = "rustc_if_this_changed";
pub const ATTR_THEN_THIS_WOULD_NEED: &str = "rustc_then_this_would_need";
pub const ATTR_PARTITION_REUSED: &str = "rustc_partition_reused";
pub const ATTR_PARTITION_CODEGENED: &str = "rustc_partition_codegened";
pub const ATTR_EXPECTED_CGU_REUSE: &str = "rustc_expected_cgu_reuse";

pub const IGNORED_ATTRIBUTES: &'static [&'static str] = &[
pub const IGNORED_ATTRIBUTES: &[&str] = &[
"cfg",
ATTR_IF_THIS_CHANGED,
ATTR_THEN_THIS_WOULD_NEED,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let sp = ident.span;
let var = self.variable(hir_id, sp);
// Ignore unused self.
if ident.name != keywords::SelfValue.name() {
if ident.name != keywords::SelfLower.name() {
if !self.warn_about_unused(sp, hir_id, entry_ln, var) {
if self.live_on_entry(entry_ln, var).is_none() {
self.report_dead_assign(hir_id, sp, var, true);
Expand Down
Loading

0 comments on commit 367e783

Please sign in to comment.