forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#125020 - GuillaumeGomez:rollup-3vxwqef, r=Gui…
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#124807 (Migrate `run-make/rustdoc-io-error` to `rmake.rs`) - rust-lang#124829 (Enable profiler for armv7-unknown-linux-gnueabihf.) - rust-lang#124939 (Always hide private fields in aliased type) - rust-lang#124963 (Migrate `run-make/rustdoc-shared-flags` to rmake) - rust-lang#124981 (Relax allocator requirements on some Rc/Arc APIs.) - rust-lang#125008 (Add test for rust-lang#122775) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
14 changed files
with
181 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use rustc_middle::ty::TyCtxt; | ||
use rustc_middle::ty::Visibility; | ||
|
||
use crate::clean; | ||
use crate::clean::Item; | ||
use crate::core::DocContext; | ||
use crate::fold::{strip_item, DocFolder}; | ||
use crate::passes::Pass; | ||
|
||
pub(crate) const STRIP_ALIASED_NON_LOCAL: Pass = Pass { | ||
name: "strip-aliased-non-local", | ||
run: strip_aliased_non_local, | ||
description: "strips all non-local private aliased items from the output", | ||
}; | ||
|
||
fn strip_aliased_non_local(krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate { | ||
let mut stripper = AliasedNonLocalStripper { tcx: cx.tcx }; | ||
stripper.fold_crate(krate) | ||
} | ||
|
||
struct AliasedNonLocalStripper<'tcx> { | ||
tcx: TyCtxt<'tcx>, | ||
} | ||
|
||
impl<'tcx> DocFolder for AliasedNonLocalStripper<'tcx> { | ||
fn fold_item(&mut self, i: Item) -> Option<Item> { | ||
Some(match *i.kind { | ||
clean::TypeAliasItem(..) => { | ||
let mut stripper = NonLocalStripper { tcx: self.tcx }; | ||
// don't call `fold_item` as that could strip the type-alias it-self | ||
// which we don't want to strip out | ||
stripper.fold_item_recur(i) | ||
} | ||
_ => self.fold_item_recur(i), | ||
}) | ||
} | ||
} | ||
|
||
struct NonLocalStripper<'tcx> { | ||
tcx: TyCtxt<'tcx>, | ||
} | ||
|
||
impl<'tcx> DocFolder for NonLocalStripper<'tcx> { | ||
fn fold_item(&mut self, i: Item) -> Option<Item> { | ||
// If not local, we want to respect the original visibility of | ||
// the field and not the one given by the user for the currrent crate. | ||
// | ||
// FIXME(#125009): Not-local should probably consider same Cargo workspace | ||
if !i.def_id().map_or(true, |did| did.is_local()) { | ||
if i.visibility(self.tcx) != Some(Visibility::Public) || i.is_doc_hidden() { | ||
return Some(strip_item(i)); | ||
} | ||
} | ||
|
||
Some(self.fold_item_recur(i)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// This test verifies that rustdoc doesn't ICE when it encounters an IO error | ||
// while generating files. Ideally this would be a rustdoc-ui test, so we could | ||
// verify the error message as well. | ||
// | ||
// It operates by creating a temporary directory and modifying its | ||
// permissions so that it is not writable. We have to take special care to set | ||
// the permissions back to normal so that it's able to be deleted later. | ||
|
||
use run_make_support::{rustdoc, tmp_dir}; | ||
use std::fs; | ||
|
||
fn main() { | ||
let out_dir = tmp_dir().join("rustdoc-io-error"); | ||
let output = fs::create_dir(&out_dir).unwrap(); | ||
let mut permissions = fs::metadata(&out_dir).unwrap().permissions(); | ||
permissions.set_readonly(true); | ||
fs::set_permissions(&out_dir, permissions.clone()).unwrap(); | ||
|
||
let output = rustdoc().input("foo.rs").output(&out_dir).command_output(); | ||
|
||
// Changing back permissions. | ||
permissions.set_readonly(false); | ||
fs::set_permissions(&out_dir, permissions).unwrap(); | ||
|
||
// Checks that rustdoc failed with the error code 1. | ||
#[cfg(unix)] | ||
assert_eq!(output.status.code().unwrap(), 1); | ||
assert!(!output.status.success()); | ||
let stderr = String::from_utf8(output.stderr).unwrap(); | ||
|
||
assert!(stderr.contains("error: couldn't generate documentation: Permission denied")); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use run_make_support::{rustc, rustdoc, Diff}; | ||
|
||
fn compare_outputs(args: &[&str]) { | ||
let rustc_output = String::from_utf8(rustc().args(args).command_output().stdout).unwrap(); | ||
let rustdoc_output = String::from_utf8(rustdoc().args(args).command_output().stdout).unwrap(); | ||
|
||
Diff::new().expected_text("rustc", rustc_output).actual_text("rustdoc", rustdoc_output).run(); | ||
} | ||
|
||
fn main() { | ||
compare_outputs(&["-C", "help"]); | ||
compare_outputs(&["-Z", "help"]); | ||
compare_outputs(&["-C", "passes=list"]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! This test makes sure that with never show the inner fields in the | ||
//! aliased type view of type alias. | ||
|
||
//@ compile-flags: -Z unstable-options --document-private-items | ||
|
||
#![crate_name = "foo"] | ||
|
||
use std::collections::BTreeMap; | ||
|
||
// @has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' | ||
pub type FooBar = BTreeMap<u32, String>; |
Oops, something went wrong.