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#125028 - matthiaskrgr:rollup-3qk782d, r=matth…
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#124096 (Clean up users of rust_dbg_call) - 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
20 changed files
with
205 additions
and
209 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 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,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>; |
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,9 @@ | ||
//! This test makes sure that with never show the inner fields in the | ||
//! aliased type view of type alias. | ||
#![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>; |
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 |
---|---|---|
@@ -1,28 +1,21 @@ | ||
#![crate_name = "externcallback"] | ||
#![crate_type = "lib"] | ||
#![feature(rustc_private)] | ||
|
||
extern crate libc; | ||
|
||
pub mod rustrt { | ||
extern crate libc; | ||
|
||
#[link(name = "rust_test_helpers", kind = "static")] | ||
extern "C" { | ||
pub fn rust_dbg_call( | ||
cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, | ||
data: libc::uintptr_t, | ||
) -> libc::uintptr_t; | ||
} | ||
#[link(name = "rust_test_helpers", kind = "static")] | ||
extern "C" { | ||
pub fn rust_dbg_call( | ||
cb: extern "C" fn(u64) -> u64, | ||
data: u64, | ||
) -> u64; | ||
} | ||
|
||
pub fn fact(n: libc::uintptr_t) -> libc::uintptr_t { | ||
pub fn fact(n: u64) -> u64 { | ||
unsafe { | ||
println!("n = {}", n); | ||
rustrt::rust_dbg_call(cb, n) | ||
rust_dbg_call(cb, n) | ||
} | ||
} | ||
|
||
pub extern "C" fn cb(data: libc::uintptr_t) -> libc::uintptr_t { | ||
pub extern "C" fn cb(data: u64) -> u64 { | ||
if data == 1 { data } else { fact(data - 1) * data } | ||
} |
Oops, something went wrong.