Skip to content

Commit 839d99c

Browse files
committed
Auto merge of #53884 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests Successful merges: - #53076 (set cfg(rustdoc) when rustdoc is running on a crate) - #53622 (cleanup: Add main functions to some UI tests) - #53769 (Also link Clippy repo in the CONTRIBUTING.md file) - #53774 (Add rust-gdbgui script.) - #53781 (bench: libcore: fix build failure of any.rs benchmark (use "dyn Any")) - #53782 (Make Arc cloning mechanics clearer in module docs) - #53790 (Add regression test for issue #52060) - #53801 (Prevent duplicated impl on foreign types) - #53850 (Nuke the `const_to_allocation` query)
2 parents fea32f1 + d0f8cf3 commit 839d99c

File tree

75 files changed

+282
-241
lines changed

Some content is hidden

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

75 files changed

+282
-241
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ before the PR is merged.
405405
[breaking-tools-built-with-the-compiler]: #breaking-tools-built-with-the-compiler
406406

407407
Rust's build system builds a number of tools that make use of the
408-
internals of the compiler. This includes clippy,
408+
internals of the compiler. This includes
409+
[Clippy](https://github.com/rust-lang-nursery/rust-clippy),
409410
[RLS](https://github.com/rust-lang-nursery/rls) and
410411
[rustfmt](https://github.com/rust-lang-nursery/rustfmt). If these tools
411412
break because of your changes, you may run into a sort of "chicken and egg"

src/bootstrap/bin/rustdoc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ fn main() {
3737
let mut dylib_path = bootstrap::util::dylib_path();
3838
dylib_path.insert(0, PathBuf::from(libdir.clone()));
3939

40+
//FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
41+
//arguments here
4042
let mut cmd = Command::new(rustdoc);
4143
cmd.args(&args)
4244
.arg("--cfg")

src/doc/rustdoc/src/unstable-features.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,25 @@ The `#[doc(cfg(...))]` attribute has another effect: When Rustdoc renders docume
106106
item, it will be accompanied by a banner explaining that the item is only available on certain
107107
platforms.
108108

109-
As mentioned earlier, getting the items to Rustdoc requires some extra preparation. The standard
110-
library adds a `--cfg dox` flag to every Rustdoc command, but the same thing can be accomplished by
111-
adding a feature to your Cargo.toml and adding `--feature dox` (or whatever you choose to name the
112-
feature) to your `cargo doc` calls.
109+
For Rustdoc to document an item, it needs to see it, regardless of what platform it's currently
110+
running on. To aid this, Rustdoc sets the flag `#[cfg(rustdoc)]` when running on your crate.
111+
Combining this with the target platform of a given item allows it to appear when building your crate
112+
normally on that platform, as well as when building documentation anywhere.
113113

114-
Either way, once you create an environment for the documentation, you can start to augment your
115-
`#[cfg]` attributes to allow both the target platform *and* the documentation configuration to leave
116-
the item in. For example, `#[cfg(any(windows, feature = "dox"))]` will preserve the item either on
117-
Windows or during the documentation process. Then, adding a new attribute `#[doc(cfg(windows))]`
118-
will tell Rustdoc that the item is supposed to be used on Windows. For example:
114+
For example, `#[cfg(any(windows, rustdoc))]` will preserve the item either on Windows or during the
115+
documentation process. Then, adding a new attribute `#[doc(cfg(windows))]` will tell Rustdoc that
116+
the item is supposed to be used on Windows. For example:
119117

120118
```rust
121119
#![feature(doc_cfg)]
122120

123121
/// Token struct that can only be used on Windows.
124-
#[cfg(any(windows, feature = "dox"))]
122+
#[cfg(any(windows, rustdoc))]
125123
#[doc(cfg(windows))]
126124
pub struct WindowsToken;
127125

128126
/// Token struct that can only be used on Unix.
129-
#[cfg(any(unix, feature = "dox"))]
127+
#[cfg(any(unix, rustdoc))]
130128
#[doc(cfg(unix))]
131129
pub struct UnixToken;
132130
```

src/doc/unstable-book/src/language-features/doc-cfg.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ This attribute has two effects:
1212

1313
2. The item's doc-tests will only run on the specific platform.
1414

15+
In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a
16+
special conditional compilation flag, `#[cfg(rustdoc)]`, set whenever building documentation on your
17+
crate.
18+
1519
This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
1620
standard library be documented.
1721

1822
```rust
1923
#![feature(doc_cfg)]
2024

21-
#[cfg(any(windows, feature = "documentation"))]
25+
#[cfg(any(windows, rustdoc))]
2226
#[doc(cfg(windows))]
2327
/// The application's icon in the notification area (a.k.a. system tray).
2428
///
@@ -39,4 +43,4 @@ pub struct Icon {
3943
```
4044

4145
[#43781]: https://github.com/rust-lang/rust/issues/43781
42-
[#43348]: https://github.com/rust-lang/rust/issues/43348
46+
[#43348]: https://github.com/rust-lang/rust/issues/43348

src/etc/rust-gdbgui

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
# Exit if anything fails
13+
set -e
14+
15+
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
16+
echo "
17+
rust-gdbgui
18+
===========
19+
gdbgui - https://gdbgui.com - is a graphical front-end to GDB
20+
that runs in a browser. This script invokes gdbgui with the Rust
21+
pretty printers loaded.
22+
23+
Simple usage : rust-gdbgui target/debug/myprog
24+
With arguments: rust-gdbgui 'target/debug/myprog arg1 arg2...'
25+
(note the quotes)
26+
27+
28+
Hints
29+
=====
30+
gdbgui won't be able to find the rust 'main' method automatically, so
31+
in its options make sure to disable the 'Add breakpoint to main after
32+
loading executable' setting to avoid a 'File not found: main' warning
33+
on startup.
34+
35+
Instead, type 'main' into gdbgui's file browser and you should get
36+
auto-completion on the filename. Just pick 'main.rs', add a breakpoint
37+
by clicking in the line number gutter, and type 'r' or hit the Restart
38+
icon to start your program running.
39+
"
40+
exit 0
41+
fi
42+
43+
# Find out where the pretty printer Python module is
44+
RUSTC_SYSROOT=`rustc --print=sysroot`
45+
GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
46+
47+
# Set the environment variable `RUST_GDB` to overwrite the call to a
48+
# different/specific command (defaults to `gdb`).
49+
RUST_GDB="${RUST_GDB:-gdb}"
50+
51+
# Set the environment variable `RUST_GDBGUI` to overwrite the call to a
52+
# different/specific command (defaults to `gdbgui`).
53+
RUST_GDBGUI="${RUST_GDBGUI:-gdbgui}"
54+
55+
# These arguments get passed through to GDB and make it load the
56+
# Rust pretty printers.
57+
GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" -iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\""
58+
59+
# Finally we execute gdbgui.
60+
PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \
61+
exec ${RUST_GDBGUI} \
62+
--gdb ${RUST_GDB} \
63+
--gdb-args "${GDB_ARGS}" \
64+
"${@}"
65+

src/liballoc/sync.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
4949
///
5050
/// The type `Arc<T>` provides shared ownership of a value of type `T`,
5151
/// allocated in the heap. Invoking [`clone`][clone] on `Arc` produces
52-
/// a new pointer to the same value in the heap. When the last `Arc`
53-
/// pointer to a given value is destroyed, the pointed-to value is
54-
/// also destroyed.
52+
/// a new `Arc` instance, which points to the same value on the heap as the
53+
/// source `Arc`, while increasing a reference count. When the last `Arc`
54+
/// pointer to a given value is destroyed, the pointed-to value is also
55+
/// destroyed.
5556
///
5657
/// Shared references in Rust disallow mutation by default, and `Arc` is no
5758
/// exception: you cannot generally obtain a mutable reference to something
@@ -107,7 +108,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
107108
/// // The two syntaxes below are equivalent.
108109
/// let a = foo.clone();
109110
/// let b = Arc::clone(&foo);
110-
/// // a and b both point to the same memory location as foo.
111+
/// // a, b, and foo are all Arcs that point to the same memory location
111112
/// ```
112113
///
113114
/// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly

src/libcore/benches/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use test::{Bencher, black_box};
1515
fn bench_downcast_ref(b: &mut Bencher) {
1616
b.iter(|| {
1717
let mut x = 0;
18-
let mut y = &mut x as &mut Any;
18+
let mut y = &mut x as &mut dyn Any;
1919
black_box(&mut y);
2020
black_box(y.downcast_ref::<isize>() == Some(&0));
2121
});

src/libcore/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ macro_rules! unimplemented {
541541
/// into libsyntax itself.
542542
///
543543
/// For more information, see documentation for `std`'s macros.
544-
#[cfg(dox)]
544+
#[cfg(rustdoc)]
545545
mod builtin {
546546

547547
/// Unconditionally causes compilation to fail with the given error message when encountered.

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ use traits::query::{
7575
CanonicalPredicateGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal,
7676
};
7777
use ty::{TyCtxt, FnSig, Instance, InstanceDef,
78-
ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty, self};
78+
ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty};
7979
use ty::subst::Substs;
8080

8181
// erase!() just makes tokens go away. It's used to specify which macro argument
@@ -632,7 +632,6 @@ define_dep_nodes!( <'tcx>
632632
// queries). Making them anonymous avoids hashing the result, which
633633
// may save a bit of time.
634634
[anon] EraseRegionsTy { ty: Ty<'tcx> },
635-
[anon] ConstToAllocation { val: &'tcx ty::Const<'tcx> },
636635

637636
[input] Freevars(DefId),
638637
[input] MaybeUnusedTraitImport(DefId),

src/librustc/ty/query/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,6 @@ impl<'tcx> QueryDescription<'tcx> for queries::super_predicates_of<'tcx> {
198198
}
199199
}
200200

201-
impl<'tcx> QueryDescription<'tcx> for queries::const_to_allocation<'tcx> {
202-
fn describe(_tcx: TyCtxt, val: &'tcx ty::Const<'tcx>) -> String {
203-
format!("converting constant `{:?}` to an allocation", val)
204-
}
205-
}
206-
207201
impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> {
208202
fn describe(_tcx: TyCtxt, ty: Ty<'tcx>) -> String {
209203
format!("erasing regions from `{:?}`", ty)

0 commit comments

Comments
 (0)