Skip to content

Commit e59b08e

Browse files
committed
Auto merge of rust-lang#74195 - Manishearth:rollup-h3m0sl8, r=Manishearth
Rollup of 14 pull requests Successful merges: - rust-lang#73292 (Fixing broken link for the Eq trait) - rust-lang#73791 (Allow for parentheses after macro intra-doc-links) - rust-lang#74070 ( Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.) - rust-lang#74077 (Use relative path for local links to primitives) - rust-lang#74079 (Eliminate confusing "globals" terminology.) - rust-lang#74107 (Hide `&mut self` methods from Deref in sidebar if there are no `DerefMut` impl for the type.) - rust-lang#74136 (Fix broken link in rustdocdoc) - rust-lang#74137 (Update cargo) - rust-lang#74142 (Liballoc use vec instead of vector) - rust-lang#74143 (Try remove unneeded ToString import in liballoc slice) - rust-lang#74146 (update miri) - rust-lang#74150 (Avoid "blacklist") - rust-lang#74184 (Add docs for intra-doc-links) - rust-lang#74188 (Tweak `::` -> `:` typo heuristic and reduce verbosity) Failed merges: - rust-lang#74122 (Start-up clean-up) - rust-lang#74127 (Avoid "whitelist") r? @ghost
2 parents 5db778a + 9353e21 commit e59b08e

File tree

184 files changed

+587
-445
lines changed

Some content is hidden

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

184 files changed

+587
-445
lines changed

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

+43-31
Original file line numberDiff line numberDiff line change
@@ -38,50 +38,62 @@ future.
3838
Attempting to use these error numbers on stable will result in the code sample being interpreted as
3939
plain text.
4040

41-
### Linking to items by type
41+
### Linking to items by name
4242

43-
As designed in [RFC 1946], Rustdoc can parse paths to items when you use them as links. To resolve
44-
these type names, it uses the items currently in-scope, either by declaration or by `use` statement.
45-
For modules, the "active scope" depends on whether the documentation is written outside the module
46-
(as `///` comments on the `mod` statement) or inside the module (at `//!` comments inside the file
47-
or block). For all other items, it uses the enclosing module's scope.
43+
Rustdoc is capable of directly linking to other rustdoc pages in Markdown documentation using the path of item as a link.
4844

49-
[RFC 1946]: https://github.com/rust-lang/rfcs/pull/1946
50-
51-
For example, in the following code:
45+
For example, in the following code all of the links will link to the rustdoc page for `Bar`:
5246

5347
```rust
54-
/// Does the thing.
55-
pub fn do_the_thing(_: SomeType) {
56-
println!("Let's do the thing!");
57-
}
48+
/// This struct is not [Bar]
49+
pub struct Foo1;
50+
51+
/// This struct is also not [bar](Bar)
52+
pub struct Foo2;
53+
54+
/// This struct is also not [bar][b]
55+
///
56+
/// [b]: Bar
57+
pub struct Foo3;
58+
59+
/// This struct is also not [`Bar`]
60+
pub struct Foo4;
5861

59-
/// Token you use to [`do_the_thing`].
60-
pub struct SomeType;
62+
pub struct Bar;
6163
```
6264

63-
The link to ``[`do_the_thing`]`` in `SomeType`'s docs will properly link to the page for `fn
64-
do_the_thing`. Note that here, rustdoc will insert the link target for you, but manually writing the
65-
target out also works:
65+
You can refer to anything in scope, and use paths, including `Self`. You may also use `foo()` and `foo!()` to refer to methods/functions and macros respectively.
6666

67-
```rust
68-
pub mod some_module {
69-
/// Token you use to do the thing.
70-
pub struct SomeStruct;
71-
}
67+
```rust,edition2018
68+
use std::sync::mpsc::Receiver;
7269
73-
/// Does the thing. Requires one [`SomeStruct`] for the thing to work.
70+
/// This is an version of [`Receiver`], with support for [`std::future`].
7471
///
75-
/// [`SomeStruct`]: some_module::SomeStruct
76-
pub fn do_the_thing(_: some_module::SomeStruct) {
77-
println!("Let's do the thing!");
72+
/// You can obtain a [`std::future::Future`] by calling [`Self::recv()`].
73+
pub struct AsyncReceiver<T> {
74+
sender: Receiver<T>
75+
}
76+
77+
impl<T> AsyncReceiver<T> {
78+
pub async fn recv() -> T {
79+
unimplemented!()
80+
}
7881
}
7982
```
8083

81-
For more details, check out [the RFC][RFC 1946], and see [the tracking issue][43466] for more
82-
information about what parts of the feature are available.
84+
Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@` , `macro@`, or `derive@`:
85+
86+
```rust
87+
/// See also: [`Foo`](struct@Foo)
88+
struct Bar;
89+
90+
/// This is different from [`Foo`](fn@Foo)
91+
struct Foo {}
92+
93+
fn Foo() {}
94+
```
8395

84-
[43466]: https://github.com/rust-lang/rust/issues/43466
96+
Note: Because of how `macro_rules` macros are scoped in Rust, the intra-doc links of a `macro_rules` macro will be resolved relative to the crate root, as opposed to the module it is defined in.
8597

8698
## Extensions to the `#[doc]` attribute
8799

@@ -321,7 +333,7 @@ library, as an equivalent command-line argument is provided to `rustc` when buil
321333
### `--index-page`: provide a top-level landing page for docs
322334

323335
This feature allows you to generate an index-page with a given markdown file. A good example of it
324-
is the [rust documentation index](https://doc.rust-lang.org/index.html).
336+
is the [rust documentation index](https://doc.rust-lang.org/nightly/index.html).
325337

326338
With this, you'll have a page which you can custom as much as you want at the top of your crates.
327339

src/liballoc/slice.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ pub use hack::to_vec;
136136
// `test_permutations` test
137137
mod hack {
138138
use crate::boxed::Box;
139-
#[cfg(test)]
140-
use crate::string::ToString;
141139
use crate::vec::Vec;
142140

143141
// We shouldn't add inline attribute to this since this is used in
@@ -156,9 +154,9 @@ mod hack {
156154
where
157155
T: Clone,
158156
{
159-
let mut vector = Vec::with_capacity(s.len());
160-
vector.extend_from_slice(s);
161-
vector
157+
let mut vec = Vec::with_capacity(s.len());
158+
vec.extend_from_slice(s);
159+
vec
162160
}
163161
}
164162

src/libcore/cmp.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use self::Ordering::*;
3535
///
3636
/// This trait allows for partial equality, for types that do not have a full
3737
/// equivalence relation. For example, in floating point numbers `NaN != NaN`,
38-
/// so floating point types implement `PartialEq` but not [`Eq`].
38+
/// so floating point types implement `PartialEq` but not [`Eq`](Eq).
3939
///
4040
/// Formally, the equality must be (for all `a`, `b` and `c`):
4141
///
@@ -191,7 +191,6 @@ use self::Ordering::*;
191191
/// assert_eq!(x.eq(&y), false);
192192
/// ```
193193
///
194-
/// [`Eq`]: Eq
195194
/// [`eq`]: PartialEq::eq
196195
/// [`ne`]: PartialEq::ne
197196
#[lang = "eq"]

src/librustc_ast/attr/mod.rs

+24-18
Original file line numberDiff line numberDiff line change
@@ -21,55 +21,61 @@ use log::debug;
2121
use std::iter;
2222
use std::ops::DerefMut;
2323

24-
pub struct Globals {
24+
// Per-session global variables: this struct is stored in thread-local storage
25+
// in such a way that it is accessible without any kind of handle to all
26+
// threads within the compilation session, but is not accessible outside the
27+
// session.
28+
pub struct SessionGlobals {
2529
used_attrs: Lock<GrowableBitSet<AttrId>>,
2630
known_attrs: Lock<GrowableBitSet<AttrId>>,
27-
rustc_span_globals: rustc_span::Globals,
31+
span_session_globals: rustc_span::SessionGlobals,
2832
}
2933

30-
impl Globals {
31-
fn new(edition: Edition) -> Globals {
32-
Globals {
34+
impl SessionGlobals {
35+
fn new(edition: Edition) -> SessionGlobals {
36+
SessionGlobals {
3337
// We have no idea how many attributes there will be, so just
3438
// initiate the vectors with 0 bits. We'll grow them as necessary.
3539
used_attrs: Lock::new(GrowableBitSet::new_empty()),
3640
known_attrs: Lock::new(GrowableBitSet::new_empty()),
37-
rustc_span_globals: rustc_span::Globals::new(edition),
41+
span_session_globals: rustc_span::SessionGlobals::new(edition),
3842
}
3943
}
4044
}
4145

42-
pub fn with_globals<R>(edition: Edition, f: impl FnOnce() -> R) -> R {
43-
let globals = Globals::new(edition);
44-
GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals.rustc_span_globals, f))
46+
pub fn with_session_globals<R>(edition: Edition, f: impl FnOnce() -> R) -> R {
47+
let ast_session_globals = SessionGlobals::new(edition);
48+
SESSION_GLOBALS.set(&ast_session_globals, || {
49+
rustc_span::SESSION_GLOBALS.set(&ast_session_globals.span_session_globals, f)
50+
})
4551
}
4652

47-
pub fn with_default_globals<R>(f: impl FnOnce() -> R) -> R {
48-
with_globals(DEFAULT_EDITION, f)
53+
pub fn with_default_session_globals<R>(f: impl FnOnce() -> R) -> R {
54+
with_session_globals(DEFAULT_EDITION, f)
4955
}
5056

51-
scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
57+
scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals);
5258

5359
pub fn mark_used(attr: &Attribute) {
5460
debug!("marking {:?} as used", attr);
55-
GLOBALS.with(|globals| {
56-
globals.used_attrs.lock().insert(attr.id);
61+
SESSION_GLOBALS.with(|session_globals| {
62+
session_globals.used_attrs.lock().insert(attr.id);
5763
});
5864
}
5965

6066
pub fn is_used(attr: &Attribute) -> bool {
61-
GLOBALS.with(|globals| globals.used_attrs.lock().contains(attr.id))
67+
SESSION_GLOBALS.with(|session_globals| session_globals.used_attrs.lock().contains(attr.id))
6268
}
6369

6470
pub fn mark_known(attr: &Attribute) {
6571
debug!("marking {:?} as known", attr);
66-
GLOBALS.with(|globals| {
67-
globals.known_attrs.lock().insert(attr.id);
72+
SESSION_GLOBALS.with(|session_globals| {
73+
session_globals.known_attrs.lock().insert(attr.id);
6874
});
6975
}
7076

7177
pub fn is_known(attr: &Attribute) -> bool {
72-
GLOBALS.with(|globals| globals.known_attrs.lock().contains(attr.id))
78+
SESSION_GLOBALS.with(|session_globals| session_globals.known_attrs.lock().contains(attr.id))
7379
}
7480

7581
pub fn is_known_lint_tool(m_item: Ident) -> bool {

src/librustc_ast/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub mod util {
4343

4444
pub mod ast;
4545
pub mod attr;
46-
pub use attr::{with_default_globals, with_globals, GLOBALS};
46+
pub use attr::{with_default_session_globals, with_session_globals, SESSION_GLOBALS};
4747
pub mod crate_disambiguator;
4848
pub mod entry;
4949
pub mod expand;

src/librustc_ast/util/lev_distance/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fn test_lev_distance() {
2121

2222
#[test]
2323
fn test_find_best_match_for_name() {
24-
use crate::with_default_globals;
25-
with_default_globals(|| {
24+
use crate::with_default_session_globals;
25+
with_default_session_globals(|| {
2626
let input = vec![Symbol::intern("aaab"), Symbol::intern("aaabc")];
2727
assert_eq!(
2828
find_best_match_for_name(input.iter(), "aaaa", None),

src/librustc_ast_pretty/pprust/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22

33
use rustc_ast::ast;
4-
use rustc_ast::with_default_globals;
4+
use rustc_ast::with_default_session_globals;
55
use rustc_span::source_map::respan;
66
use rustc_span::symbol::Ident;
77

@@ -25,7 +25,7 @@ fn variant_to_string(var: &ast::Variant) -> String {
2525

2626
#[test]
2727
fn test_fun_to_string() {
28-
with_default_globals(|| {
28+
with_default_session_globals(|| {
2929
let abba_ident = Ident::from_str("abba");
3030

3131
let decl =
@@ -40,7 +40,7 @@ fn test_fun_to_string() {
4040

4141
#[test]
4242
fn test_variant_to_string() {
43-
with_default_globals(|| {
43+
with_default_session_globals(|| {
4444
let ident = Ident::from_str("principal_skinner");
4545

4646
let var = ast::Variant {

src/librustc_codegen_llvm/attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
342342
}
343343
}
344344

345-
pub fn provide(providers: &mut Providers<'_>) {
345+
pub fn provide(providers: &mut Providers) {
346346
providers.target_features_whitelist = |tcx, cnum| {
347347
assert_eq!(cnum, LOCAL_CRATE);
348348
if tcx.sess.opts.actually_rustdoc {
@@ -360,7 +360,7 @@ pub fn provide(providers: &mut Providers<'_>) {
360360
provide_extern(providers);
361361
}
362362

363-
pub fn provide_extern(providers: &mut Providers<'_>) {
363+
pub fn provide_extern(providers: &mut Providers) {
364364
providers.wasm_import_module_map = |tcx, cnum| {
365365
// Build up a map from DefId to a `NativeLib` structure, where
366366
// `NativeLib` internally contains information about

src/librustc_codegen_llvm/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ impl CodegenBackend for LlvmCodegenBackend {
241241
Box::new(metadata::LlvmMetadataLoader)
242242
}
243243

244-
fn provide(&self, providers: &mut ty::query::Providers<'_>) {
244+
fn provide(&self, providers: &mut ty::query::Providers) {
245245
attributes::provide(providers);
246246
}
247247

248-
fn provide_extern(&self, providers: &mut ty::query::Providers<'_>) {
248+
fn provide_extern(&self, providers: &mut ty::query::Providers) {
249249
attributes::provide_extern(providers);
250250
}
251251

src/librustc_codegen_ssa/back/symbol_export.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
161161
}
162162

163163
fn exported_symbols_provider_local(
164-
tcx: TyCtxt<'_>,
164+
tcx: TyCtxt<'tcx>,
165165
cnum: CrateNum,
166-
) -> &'tcx [(ExportedSymbol<'_>, SymbolExportLevel)] {
166+
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
167167
assert_eq!(cnum, LOCAL_CRATE);
168168

169169
if !tcx.sess.opts.output_types.should_codegen() {
@@ -366,7 +366,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> b
366366
}
367367
}
368368

369-
pub fn provide(providers: &mut Providers<'_>) {
369+
pub fn provide(providers: &mut Providers) {
370370
providers.reachable_non_generics = reachable_non_generics_provider;
371371
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
372372
providers.exported_symbols = exported_symbols_provider_local;
@@ -375,7 +375,7 @@ pub fn provide(providers: &mut Providers<'_>) {
375375
providers.upstream_drop_glue_for = upstream_drop_glue_for_provider;
376376
}
377377

378-
pub fn provide_extern(providers: &mut Providers<'_>) {
378+
pub fn provide_extern(providers: &mut Providers) {
379379
providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern;
380380
providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider;
381381
}

src/librustc_codegen_ssa/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ impl CrateInfo {
853853
}
854854
}
855855

856-
pub fn provide_both(providers: &mut Providers<'_>) {
856+
pub fn provide_both(providers: &mut Providers) {
857857
providers.backend_optimization_level = |tcx, cratenum| {
858858
let for_speed = match tcx.sess.opts.optimize {
859859
// If globally no optimisation is done, #[optimize] has no effect.

src/librustc_codegen_ssa/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ pub struct CodegenResults {
138138
pub crate_info: CrateInfo,
139139
}
140140

141-
pub fn provide(providers: &mut Providers<'_>) {
141+
pub fn provide(providers: &mut Providers) {
142142
crate::back::symbol_export::provide(providers);
143143
crate::base::provide_both(providers);
144144
}
145145

146-
pub fn provide_extern(providers: &mut Providers<'_>) {
146+
pub fn provide_extern(providers: &mut Providers) {
147147
crate::back::symbol_export::provide_extern(providers);
148148
crate::base::provide_both(providers);
149149
}

src/librustc_codegen_ssa/traits/backend.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub trait CodegenBackend {
5555
fn print_version(&self) {}
5656

5757
fn metadata_loader(&self) -> Box<MetadataLoaderDyn>;
58-
fn provide(&self, _providers: &mut Providers<'_>);
59-
fn provide_extern(&self, _providers: &mut Providers<'_>);
58+
fn provide(&self, _providers: &mut Providers);
59+
fn provide_extern(&self, _providers: &mut Providers);
6060
fn codegen_crate<'tcx>(
6161
&self,
6262
tcx: TyCtxt<'tcx>,

src/librustc_error_codes/error_codes/E0570.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The requested ABI is unsupported by the current target.
22

3-
The rust compiler maintains for each target a blacklist of ABIs unsupported on
3+
The rust compiler maintains for each target a list of unsupported ABIs on
44
that target. If an ABI is present in such a list this usually means that the
55
target / ABI combination is currently unsupported by llvm.
66

src/librustc_errors/json/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ impl<T: Write> Write for Shared<T> {
3939
}
4040
}
4141

42-
fn with_default_globals(f: impl FnOnce()) {
43-
let globals = rustc_span::Globals::new(rustc_span::edition::DEFAULT_EDITION);
44-
rustc_span::GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals, f))
42+
fn with_default_session_globals(f: impl FnOnce()) {
43+
let session_globals = rustc_span::SessionGlobals::new(rustc_span::edition::DEFAULT_EDITION);
44+
rustc_span::SESSION_GLOBALS.set(&session_globals, f);
4545
}
4646

4747
/// Test the span yields correct positions in JSON.
4848
fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
4949
let expected_output = TestData { spans: vec![expected_output] };
5050

51-
with_default_globals(|| {
51+
with_default_session_globals(|| {
5252
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
5353
sm.new_source_file(Path::new("test.rs").to_owned().into(), code.to_owned());
5454

0 commit comments

Comments
 (0)