diff options
| author | bors <bors@rust-lang.org> | 2021-01-11 06:09:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-11 06:09:50 +0000 |
| commit | a2cd91ceb0f156cb442d75e12dc77c3d064cdde4 (patch) | |
| tree | 208c016b62b3962a7913c8189d3aa884adf3e6e5 /src | |
| parent | 00c5c3922f5f638b4173bd821f57c94bbb18d43c (diff) | |
| parent | a7f7d70860634b08a1ff9a3de04b7aceaa4f5d9e (diff) | |
| download | rust-a2cd91ceb0f156cb442d75e12dc77c3d064cdde4.tar.gz rust-a2cd91ceb0f156cb442d75e12dc77c3d064cdde4.zip | |
Auto merge of #80905 - JohnTitor:rollup-tmmwmnb, r=JohnTitor
Rollup of 6 pull requests Successful merges: - #80809 (Use standard formatting for "rust-call" ABI message) - #80872 (Fix typo in source-based-code-coverage.md) - #80878 (Add ABI argument to `find_mir_or_eval_fn`) - #80881 ( Fix intra-doc links to `Self` and `crate` ) - #80887 (log-color: Detect TTY based on stderr, not stdout) - #80892 (rustdoc: Remove `*` intra-doc alias for `pointer`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
9 files changed, 40 insertions, 37 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/source-based-code-coverage.md b/src/doc/unstable-book/src/compiler-flags/source-based-code-coverage.md index 98bcadd12ee..8aca0052147 100644 --- a/src/doc/unstable-book/src/compiler-flags/source-based-code-coverage.md +++ b/src/doc/unstable-book/src/compiler-flags/source-based-code-coverage.md @@ -123,7 +123,7 @@ The `rustup` option is guaranteed to install a compatible version of the LLVM to ```shell $ rustup component add llvm-tools-preview $ cargo install cargo-binutils -$ cargo profdata -- --help # note the additional "--" preceeding the tool-specific arguments +$ cargo profdata -- --help # note the additional "--" preceding the tool-specific arguments ``` ## Creating coverage reports diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 11ee59b2401..9cba1b7b0f1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -504,15 +504,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { match res { // FIXME(#76467): make this fallthrough to lookup the associated // item a separate function. - Res::Def(DefKind::AssocFn | DefKind::AssocConst, _) => { - assert_eq!(ns, ValueNS); - } - Res::Def(DefKind::AssocTy, _) => { - assert_eq!(ns, TypeNS); - } - Res::Def(DefKind::Variant, _) => { - return handle_variant(cx, res, extra_fragment); - } + Res::Def(DefKind::AssocFn | DefKind::AssocConst, _) => assert_eq!(ns, ValueNS), + Res::Def(DefKind::AssocTy, _) => assert_eq!(ns, TypeNS), + Res::Def(DefKind::Variant, _) => return handle_variant(cx, res, extra_fragment), // Not a trait item; just return what we found. Res::Primitive(ty) => { if extra_fragment.is_some() { @@ -522,12 +516,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { } return Ok((res, Some(ty.as_str().to_owned()))); } - Res::Def(DefKind::Mod, _) => { - return Ok((res, extra_fragment.clone())); - } - _ => { - return Ok((res, extra_fragment.clone())); - } + _ => return Ok((res, extra_fragment.clone())), } } @@ -1024,12 +1013,18 @@ impl LinkCollector<'_, '_> { let resolved_self; // replace `Self` with suitable item's parent name - if path_str.starts_with("Self::") { + let is_lone_self = path_str == "Self"; + let is_lone_crate = path_str == "crate"; + if path_str.starts_with("Self::") || is_lone_self { if let Some(ref name) = self_name { - resolved_self = format!("{}::{}", name, &path_str[6..]); - path_str = &resolved_self; + if is_lone_self { + path_str = name; + } else { + resolved_self = format!("{}::{}", name, &path_str[6..]); + path_str = &resolved_self; + } } - } else if path_str.starts_with("crate::") { + } else if path_str.starts_with("crate::") || is_lone_crate { use rustc_span::def_id::CRATE_DEF_INDEX; // HACK(jynelson): rustc_resolve thinks that `crate` is the crate currently being documented. @@ -1038,8 +1033,12 @@ impl LinkCollector<'_, '_> { // HACK(jynelson)(2): If we just strip `crate::` then suddenly primitives become ambiguous // (consider `crate::char`). Instead, change it to `self::`. This works because 'self' is now the crate root. // FIXME(#78696): This doesn't always work. - resolved_self = format!("self::{}", &path_str["crate::".len()..]); - path_str = &resolved_self; + if is_lone_crate { + path_str = "self"; + } else { + resolved_self = format!("self::{}", &path_str["crate::".len()..]); + path_str = &resolved_self; + } module_id = DefId { krate, index: CRATE_DEF_INDEX }; } @@ -2092,7 +2091,7 @@ fn resolve_primitive(path_str: &str, ns: Namespace) -> Option<Res> { "array" => Array, "tuple" => Tuple, "unit" => Unit, - "pointer" | "*" | "*const" | "*mut" => RawPointer, + "pointer" | "*const" | "*mut" => RawPointer, "reference" | "&" | "&mut" => Reference, "fn" => Fn, "never" | "!" => Never, diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/self.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/self.rs index cdfe842f3cc..54902f12eb1 100644 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/self.rs +++ b/src/test/rustdoc/intra-doc-crate/auxiliary/self.rs @@ -1,4 +1,7 @@ #![crate_name = "cross_crate_self"] + +/// Link to [Self] +/// Link to [crate] pub struct S; impl S { diff --git a/src/test/rustdoc/intra-doc-crate/self.rs b/src/test/rustdoc/intra-doc-crate/self.rs index 62aef8e85af..4db63b12b6b 100644 --- a/src/test/rustdoc/intra-doc-crate/self.rs +++ b/src/test/rustdoc/intra-doc-crate/self.rs @@ -1,6 +1,9 @@ // aux-build:self.rs +// build-aux-docs extern crate cross_crate_self; // @has self/struct.S.html '//a[@href="../self/struct.S.html#method.f"]' "Self::f" +// @has self/struct.S.html '//a[@href="../self/struct.S.html"]' "Self" +// @has self/struct.S.html '//a[@href="../cross_crate_self/index.html"]' "crate" pub use cross_crate_self::S; diff --git a/src/test/rustdoc/intra-doc/non-path-primitives.rs b/src/test/rustdoc/intra-doc/non-path-primitives.rs index ad4f6ddd9de..a409744e409 100644 --- a/src/test/rustdoc/intra-doc/non-path-primitives.rs +++ b/src/test/rustdoc/intra-doc/non-path-primitives.rs @@ -11,11 +11,9 @@ // @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' 'pointer::is_null' // @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*const::is_null' // @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*mut::is_null' -// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.is_null"]' '*::is_null' //! [pointer::is_null] //! [*const::is_null] //! [*mut::is_null] -//! [*::is_null] // @has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.unit.html"]' 'unit' //! [unit] diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.rs b/src/test/ui/abi/issues/issue-22565-rust-call.rs index 383eaab454e..a08e0bfb5e5 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.rs +++ b/src/test/ui/abi/issues/issue-22565-rust-call.rs @@ -1,25 +1,25 @@ #![feature(unboxed_closures)] extern "rust-call" fn b(_i: i32) {} -//~^ ERROR A function with the "rust-call" ABI must take a single non-self argument that is a tuple +//~^ ERROR functions with the "rust-call" ABI must take a single non-self argument that is a tuple trait Tr { extern "rust-call" fn a(); extern "rust-call" fn b() {} - //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument } struct Foo; impl Foo { extern "rust-call" fn bar() {} - //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument } impl Tr for Foo { extern "rust-call" fn a() {} - //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument } fn main () { diff --git a/src/test/ui/abi/issues/issue-22565-rust-call.stderr b/src/test/ui/abi/issues/issue-22565-rust-call.stderr index f7c3d1de793..3eee10bc5e9 100644 --- a/src/test/ui/abi/issues/issue-22565-rust-call.stderr +++ b/src/test/ui/abi/issues/issue-22565-rust-call.stderr @@ -1,22 +1,22 @@ -error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple +error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple --> $DIR/issue-22565-rust-call.rs:3:1 | LL | extern "rust-call" fn b(_i: i32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple +error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple --> $DIR/issue-22565-rust-call.rs:9:5 | LL | extern "rust-call" fn b() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple +error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple --> $DIR/issue-22565-rust-call.rs:16:5 | LL | extern "rust-call" fn bar() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple +error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple --> $DIR/issue-22565-rust-call.rs:21:5 | LL | extern "rust-call" fn a() {} diff --git a/src/test/ui/overloaded-calls-nontuple.rs b/src/test/ui/overloaded-calls-nontuple.rs index 76b114c5592..07d44ff82b1 100644 --- a/src/test/ui/overloaded-calls-nontuple.rs +++ b/src/test/ui/overloaded-calls-nontuple.rs @@ -11,13 +11,13 @@ impl FnMut<isize> for S { extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { self.x + self.y + z } - //~^^^ ERROR A function with the "rust-call" ABI must take a single non-self argument + //~^^^ ERROR functions with the "rust-call" ABI must take a single non-self argument } impl FnOnce<isize> for S { type Output = isize; extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } - //~^ ERROR A function with the "rust-call" ABI must take a single non-self argument + //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument } fn main() { diff --git a/src/test/ui/overloaded-calls-nontuple.stderr b/src/test/ui/overloaded-calls-nontuple.stderr index bdadb95db29..8f299bc9434 100644 --- a/src/test/ui/overloaded-calls-nontuple.stderr +++ b/src/test/ui/overloaded-calls-nontuple.stderr @@ -1,10 +1,10 @@ -error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple +error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple --> $DIR/overloaded-calls-nontuple.rs:11:5 | LL | extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: A function with the "rust-call" ABI must take a single non-self argument that is a tuple +error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple --> $DIR/overloaded-calls-nontuple.rs:19:5 | LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } |
