Skip to content

Commit 367e783

Browse files
committed
Auto merge of #56557 - pietroalbini:rollup, r=pietroalbini
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
2 parents 128a1fa + cd1ee5e commit 367e783

File tree

100 files changed

+700
-400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+700
-400
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,6 @@ dependencies = [
23522352
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
23532353
"rustc 0.0.0",
23542354
"rustc_data_structures 0.0.0",
2355-
"rustc_mir 0.0.0",
23562355
"rustc_target 0.0.0",
23572356
"syntax 0.0.0",
23582357
"syntax_pos 0.0.0",

src/bootstrap/doc.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,6 @@ impl Step for Rustc {
697697
return;
698698
}
699699

700-
// Build libstd docs so that we generate relative links.
701-
builder.ensure(Std { stage, target });
702-
703700
// Build rustc.
704701
builder.ensure(compile::Rustc { compiler, target });
705702

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

719716
// Find dependencies for top level crates.
720717
let mut compiler_crates = HashSet::new();
721-
for root_crate in &["rustc", "rustc_driver", "rustc_codegen_llvm"] {
718+
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
722719
let interned_root_crate = INTERNER.intern_str(root_crate);
723720
find_compiler_crates(builder, &interned_root_crate, &mut compiler_crates);
724721
}
725722

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

@@ -797,8 +798,8 @@ impl Step for Rustdoc {
797798
return;
798799
}
799800

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

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

826+
// Only include compiler crates, no dependencies of those, such as `libc`.
827+
cargo.arg("--no-deps");
828+
cargo.arg("-p").arg("rustdoc");
829+
825830
cargo.env("RUSTDOCFLAGS", "--document-private-items");
826831
builder.run(&mut cargo);
827832
}

src/grammar/parser-lalr.y

+2-2
Original file line numberDiff line numberDiff line change
@@ -741,14 +741,14 @@ fn_anon_params
741741
;
742742

743743
fn_params_with_self
744-
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
744+
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
745745
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
746746
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
747747
| '(' maybe_params ')' { $$ = mk_node("SelfStatic", 1, $2); }
748748
;
749749

750750
fn_anon_params_with_self
751-
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfValue", 3, $2, $4, $5); }
751+
: '(' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfLower", 3, $2, $4, $5); }
752752
| '(' '&' maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 3, $3, $5, $6); }
753753
| '(' '&' lifetime maybe_mut SELF maybe_ty_ascription maybe_comma_anon_params ')' { $$ = mk_node("SelfRegion", 4, $3, $4, $6, $7); }
754754
| '(' maybe_anon_params ')' { $$ = mk_node("SelfStatic", 1, $2); }

src/liballoc/string.rs

+30-19
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl String {
577577
return Cow::Borrowed("");
578578
};
579579

580-
const REPLACEMENT: &'static str = "\u{FFFD}";
580+
const REPLACEMENT: &str = "\u{FFFD}";
581581

582582
let mut res = String::with_capacity(v.len());
583583
res.push_str(first_valid);
@@ -1732,18 +1732,37 @@ impl<'a> FromIterator<&'a str> for String {
17321732
#[stable(feature = "extend_string", since = "1.4.0")]
17331733
impl FromIterator<String> for String {
17341734
fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> String {
1735-
let mut buf = String::new();
1736-
buf.extend(iter);
1737-
buf
1735+
let mut iterator = iter.into_iter();
1736+
1737+
// Because we're iterating over `String`s, we can avoid at least
1738+
// one allocation by getting the first string from the iterator
1739+
// and appending to it all the subsequent strings.
1740+
match iterator.next() {
1741+
None => String::new(),
1742+
Some(mut buf) => {
1743+
buf.extend(iterator);
1744+
buf
1745+
}
1746+
}
17381747
}
17391748
}
17401749

17411750
#[stable(feature = "herd_cows", since = "1.19.0")]
17421751
impl<'a> FromIterator<Cow<'a, str>> for String {
17431752
fn from_iter<I: IntoIterator<Item = Cow<'a, str>>>(iter: I) -> String {
1744-
let mut buf = String::new();
1745-
buf.extend(iter);
1746-
buf
1753+
let mut iterator = iter.into_iter();
1754+
1755+
// Because we're iterating over CoWs, we can (potentially) avoid at least
1756+
// one allocation by getting the first item and appending to it all the
1757+
// subsequent items.
1758+
match iterator.next() {
1759+
None => String::new(),
1760+
Some(cow) => {
1761+
let mut buf = cow.into_owned();
1762+
buf.extend(iterator);
1763+
buf
1764+
}
1765+
}
17471766
}
17481767
}
17491768

@@ -1753,9 +1772,7 @@ impl Extend<char> for String {
17531772
let iterator = iter.into_iter();
17541773
let (lower_bound, _) = iterator.size_hint();
17551774
self.reserve(lower_bound);
1756-
for ch in iterator {
1757-
self.push(ch)
1758-
}
1775+
iterator.for_each(move |c| self.push(c));
17591776
}
17601777
}
17611778

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

17781793
#[stable(feature = "extend_string", since = "1.4.0")]
17791794
impl Extend<String> for String {
17801795
fn extend<I: IntoIterator<Item = String>>(&mut self, iter: I) {
1781-
for s in iter {
1782-
self.push_str(&s)
1783-
}
1796+
iter.into_iter().for_each(move |s| self.push_str(&s));
17841797
}
17851798
}
17861799

17871800
#[stable(feature = "herd_cows", since = "1.19.0")]
17881801
impl<'a> Extend<Cow<'a, str>> for String {
17891802
fn extend<I: IntoIterator<Item = Cow<'a, str>>>(&mut self, iter: I) {
1790-
for s in iter {
1791-
self.push_str(&s)
1792-
}
1803+
iter.into_iter().for_each(move |s| self.push_str(&s));
17931804
}
17941805
}
17951806

src/libcore/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ impl<'a> Formatter<'a> {
13811381
for part in formatted.parts {
13821382
match *part {
13831383
flt2dec::Part::Zero(mut nzeroes) => {
1384-
const ZEROES: &'static str = // 64 zeroes
1384+
const ZEROES: &str = // 64 zeroes
13851385
"0000000000000000000000000000000000000000000000000000000000000000";
13861386
while nzeroes > ZEROES.len() {
13871387
self.buf.write_str(ZEROES)?;

src/libcore/unicode/printable.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub(crate) fn is_printable(x: char) -> bool {
8080
}
8181
}
8282

83-
const SINGLETONS0U: &'static [(u8, u8)] = &[
83+
const SINGLETONS0U: &[(u8, u8)] = &[
8484
(0x00, 1),
8585
(0x03, 5),
8686
(0x05, 6),
@@ -122,7 +122,7 @@ const SINGLETONS0U: &'static [(u8, u8)] = &[
122122
(0xfe, 3),
123123
(0xff, 9),
124124
];
125-
const SINGLETONS0L: &'static [u8] = &[
125+
const SINGLETONS0L: &[u8] = &[
126126
0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
127127
0x58, 0x8b, 0x8c, 0x90, 0x1c, 0x1d, 0xdd, 0x0e,
128128
0x0f, 0x4b, 0x4c, 0xfb, 0xfc, 0x2e, 0x2f, 0x3f,
@@ -162,7 +162,7 @@ const SINGLETONS0L: &'static [u8] = &[
162162
0x91, 0xfe, 0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9,
163163
0xd0, 0xd1, 0xd8, 0xd9, 0xe7, 0xfe, 0xff,
164164
];
165-
const SINGLETONS1U: &'static [(u8, u8)] = &[
165+
const SINGLETONS1U: &[(u8, u8)] = &[
166166
(0x00, 6),
167167
(0x01, 1),
168168
(0x03, 1),
@@ -197,7 +197,7 @@ const SINGLETONS1U: &'static [(u8, u8)] = &[
197197
(0xf0, 4),
198198
(0xf9, 4),
199199
];
200-
const SINGLETONS1L: &'static [u8] = &[
200+
const SINGLETONS1L: &[u8] = &[
201201
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
202202
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
203203
0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36,
@@ -219,7 +219,7 @@ const SINGLETONS1L: &'static [u8] = &[
219219
0x78, 0x7d, 0x7f, 0x8a, 0xa4, 0xaa, 0xaf, 0xb0,
220220
0xc0, 0xd0, 0x3f, 0x71, 0x72, 0x7b,
221221
];
222-
const NORMAL0: &'static [u8] = &[
222+
const NORMAL0: &[u8] = &[
223223
0x00, 0x20,
224224
0x5f, 0x22,
225225
0x82, 0xdf, 0x04,
@@ -363,7 +363,7 @@ const NORMAL0: &'static [u8] = &[
363363
0x1b, 0x03,
364364
0x0f, 0x0d,
365365
];
366-
const NORMAL1: &'static [u8] = &[
366+
const NORMAL1: &[u8] = &[
367367
0x5e, 0x22,
368368
0x7b, 0x05,
369369
0x03, 0x04,

src/librustc/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ macro_rules! define_dep_nodes {
381381
#[allow(dead_code, non_upper_case_globals)]
382382
pub mod label_strs {
383383
$(
384-
pub const $variant: &'static str = stringify!($variant);
384+
pub const $variant: &str = stringify!($variant);
385385
)*
386386
}
387387
);

src/librustc/hir/lowering.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ impl<'a> LoweringContext<'a> {
12011201
None,
12021202
P(hir::Path {
12031203
def: self.expect_full_def(t.id),
1204-
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfType.ident())],
1204+
segments: hir_vec![hir::PathSegment::from_ident(keywords::SelfUpper.ident())],
12051205
span: t.span,
12061206
}),
12071207
)),
@@ -2425,7 +2425,7 @@ impl<'a> LoweringContext<'a> {
24252425
// Don't expose `Self` (recovered "keyword used as ident" parse error).
24262426
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
24272427
// Instead, use gensym("Self") to create a distinct name that looks the same.
2428-
let ident = if param.ident.name == keywords::SelfType.name() {
2428+
let ident = if param.ident.name == keywords::SelfUpper.name() {
24292429
param.ident.gensym()
24302430
} else {
24312431
param.ident
@@ -2981,7 +2981,7 @@ impl<'a> LoweringContext<'a> {
29812981

29822982
// Correctly resolve `self` imports
29832983
if path.segments.len() > 1
2984-
&& path.segments.last().unwrap().ident.name == keywords::SelfValue.name()
2984+
&& path.segments.last().unwrap().ident.name == keywords::SelfLower.name()
29852985
{
29862986
let _ = path.segments.pop();
29872987
if rename.is_none() {

src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl<'hir> Map<'hir> {
475475

476476
pub fn ty_param_name(&self, id: NodeId) -> Name {
477477
match self.get(id) {
478-
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfType.name(),
478+
Node::Item(&Item { node: ItemKind::Trait(..), .. }) => keywords::SelfUpper.name(),
479479
Node::GenericParam(param) => param.name.ident().name,
480480
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
481481
}

src/librustc/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ pub struct Path {
311311

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

src/librustc/hir/print.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait PpAnn {
6565

6666
pub struct NoAnn;
6767
impl PpAnn for NoAnn {}
68-
pub const NO_ANN: &'static dyn PpAnn = &NoAnn;
68+
pub const NO_ANN: &dyn PpAnn = &NoAnn;
6969

7070
impl PpAnn for hir::Crate {
7171
fn try_fetch_item(&self, item: ast::NodeId) -> Option<&hir::Item> {
@@ -1622,7 +1622,7 @@ impl<'a> State<'a> {
16221622
if i > 0 {
16231623
self.s.word("::")?
16241624
}
1625-
if segment.ident.name != keywords::CrateRoot.name() &&
1625+
if segment.ident.name != keywords::PathRoot.name() &&
16261626
segment.ident.name != keywords::DollarCrate.name() {
16271627
self.print_ident(segment.ident)?;
16281628
segment.with_generic_args(|generic_args| {
@@ -1636,7 +1636,7 @@ impl<'a> State<'a> {
16361636
}
16371637

16381638
pub fn print_path_segment(&mut self, segment: &hir::PathSegment) -> io::Result<()> {
1639-
if segment.ident.name != keywords::CrateRoot.name() &&
1639+
if segment.ident.name != keywords::PathRoot.name() &&
16401640
segment.ident.name != keywords::DollarCrate.name() {
16411641
self.print_ident(segment.ident)?;
16421642
segment.with_generic_args(|generic_args| {
@@ -1664,7 +1664,7 @@ impl<'a> State<'a> {
16641664
if i > 0 {
16651665
self.s.word("::")?
16661666
}
1667-
if segment.ident.name != keywords::CrateRoot.name() &&
1667+
if segment.ident.name != keywords::PathRoot.name() &&
16681668
segment.ident.name != keywords::DollarCrate.name() {
16691669
self.print_ident(segment.ident)?;
16701670
segment.with_generic_args(|generic_args| {

src/librustc/ich/impls_syntax.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,10 @@ impl_stable_hash_for!(struct ::syntax::attr::Stability {
134134
const_stability
135135
});
136136

137-
impl<'a> HashStable<StableHashingContext<'a>>
138-
for ::syntax::edition::Edition {
139-
fn hash_stable<W: StableHasherResult>(&self,
140-
hcx: &mut StableHashingContext<'a>,
141-
hasher: &mut StableHasher<W>) {
142-
mem::discriminant(self).hash_stable(hcx, hasher);
143-
}
144-
}
137+
impl_stable_hash_for!(enum ::syntax::edition::Edition {
138+
Edition2015,
139+
Edition2018,
140+
});
145141

146142
impl<'a> HashStable<StableHashingContext<'a>>
147143
for ::syntax::attr::StabilityLevel {

src/librustc/ich/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ mod impls_misc;
2424
mod impls_ty;
2525
mod impls_syntax;
2626

27-
pub const ATTR_DIRTY: &'static str = "rustc_dirty";
28-
pub const ATTR_CLEAN: &'static str = "rustc_clean";
29-
pub const ATTR_IF_THIS_CHANGED: &'static str = "rustc_if_this_changed";
30-
pub const ATTR_THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need";
31-
pub const ATTR_PARTITION_REUSED: &'static str = "rustc_partition_reused";
32-
pub const ATTR_PARTITION_CODEGENED: &'static str = "rustc_partition_codegened";
33-
pub const ATTR_EXPECTED_CGU_REUSE: &'static str = "rustc_expected_cgu_reuse";
27+
pub const ATTR_DIRTY: &str = "rustc_dirty";
28+
pub const ATTR_CLEAN: &str = "rustc_clean";
29+
pub const ATTR_IF_THIS_CHANGED: &str = "rustc_if_this_changed";
30+
pub const ATTR_THEN_THIS_WOULD_NEED: &str = "rustc_then_this_would_need";
31+
pub const ATTR_PARTITION_REUSED: &str = "rustc_partition_reused";
32+
pub const ATTR_PARTITION_CODEGENED: &str = "rustc_partition_codegened";
33+
pub const ATTR_EXPECTED_CGU_REUSE: &str = "rustc_expected_cgu_reuse";
3434

35-
pub const IGNORED_ATTRIBUTES: &'static [&'static str] = &[
35+
pub const IGNORED_ATTRIBUTES: &[&str] = &[
3636
"cfg",
3737
ATTR_IF_THIS_CHANGED,
3838
ATTR_THEN_THIS_WOULD_NEED,

src/librustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15751575
let sp = ident.span;
15761576
let var = self.variable(hir_id, sp);
15771577
// Ignore unused self.
1578-
if ident.name != keywords::SelfValue.name() {
1578+
if ident.name != keywords::SelfLower.name() {
15791579
if !self.warn_about_unused(sp, hir_id, entry_ln, var) {
15801580
if self.live_on_entry(entry_ln, var).is_none() {
15811581
self.report_dead_assign(hir_id, sp, var, true);

0 commit comments

Comments
 (0)