Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #101074

Merged
merged 28 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
152c851
Make forward compatibility lint deprecated_cfg_attr_crate_type_name d…
est31 Jul 26, 2022
8998024
Correct test-args to compiletest on Windows
czzrr Aug 19, 2022
6a1f7af
Use direct pointer to filter_dirs function
est31 Aug 23, 2022
0a6af98
Simplify unicode_downloads.rs
est31 Aug 23, 2022
754b3e7
Change hint to correct path
est31 Aug 23, 2022
a788650
Remove some documentation duplicated between `writeln!` and `write!`
joshtriplett Aug 24, 2022
3c8618f
Update `write!` docs: can now import traits as `_` to avoid conflicts
joshtriplett Aug 24, 2022
589db1f
Expand example to show how to implement qualified trait names
joshtriplett Aug 24, 2022
ae937cc
Clarify comment to fit `as _` better
joshtriplett Aug 24, 2022
ad93272
Stabilize `const_ptr_offset_from`.
fee1-dead Apr 20, 2022
69ad634
Do not include `const_ptr_sub_ptr` in this stabilization
fee1-dead May 12, 2022
e7b7f88
rustdoc: omit start/end tags for empty item description blocks
notriddle Aug 26, 2022
832fd23
rustdoc: remove unused CSS for `hidden-by-*-hider`
notriddle Aug 26, 2022
25eb52f
rustdoc: remove incorrect CSS selector `.impl-items table td`
notriddle Aug 26, 2022
20012ea
Merge implementations of HIR fn_decl and fn_sig.
cjgillot Aug 22, 2022
52582d3
rustdoc: remove empty extern_crates and type="text/javascript" on script
notriddle Aug 26, 2022
a74f453
Merge duplicated CSS rules
GuillaumeGomez Aug 26, 2022
539e408
Rollup merge of #96240 - fee1-dead-contrib:stabilize_const_offset_fro…
JohnTitor Aug 27, 2022
134cc2d
Rollup merge of #99784 - est31:deny_cfg_attr_crate_type_name, r=Mark-…
JohnTitor Aug 27, 2022
7214f0c
Rollup merge of #100811 - czzrr:master, r=Mark-Simulacrum
JohnTitor Aug 27, 2022
e31bedc
Rollup merge of #100924 - est31:closure_to_fn_ptr, r=Mark-Simulacrum
JohnTitor Aug 27, 2022
f4d4a40
Rollup merge of #100953 - joshtriplett:write-docs, r=Mark-Simulacrum
JohnTitor Aug 27, 2022
6ccad25
Rollup merge of #101018 - notriddle:notriddle/item-right-docblock-sho…
JohnTitor Aug 27, 2022
84f5ccd
Rollup merge of #101044 - notriddle:notriddle/css-hidden-by, r=jsha
JohnTitor Aug 27, 2022
0cad274
Rollup merge of #101046 - notriddle:notriddle/table-css, r=jsha
JohnTitor Aug 27, 2022
aa6b750
Rollup merge of #101057 - cjgillot:one-fn-sig, r=compiler-errors
JohnTitor Aug 27, 2022
bdbbbe6
Rollup merge of #101062 - notriddle:notriddle/text-javascript, r=Guil…
JohnTitor Aug 27, 2022
bd89372
Rollup merge of #101063 - GuillaumeGomez:merge-duplicated-css, r=notr…
JohnTitor Aug 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,7 @@ impl<'hir> OwnerNode<'hir> {
}
}

pub fn fn_decl(&self) -> Option<&FnDecl<'hir>> {
pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
match self {
OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
| OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
Expand Down Expand Up @@ -3400,19 +3400,20 @@ impl<'hir> Node<'hir> {
}
}

pub fn fn_decl(&self) -> Option<&'hir FnDecl<'hir>> {
pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
match self {
Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
| Node::Item(Item { kind: ItemKind::Fn(fn_sig, _, _), .. }) => Some(fn_sig.decl),
Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {
Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. })
| Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {
Some(fn_decl)
}
_ => None,
}
}

pub fn fn_sig(&self) -> Option<&'hir FnSig<'hir>> {
pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
match self {
Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3094,7 +3094,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,compile_fail
/// #![cfg_attr(debug_assertions, crate_type = "lib")]
/// ```
///
Expand All @@ -3114,7 +3114,7 @@ declare_lint! {
/// rustc instead of `#![cfg_attr(..., crate_type = "...")]` and
/// `--crate-name` instead of `#![cfg_attr(..., crate_name = "...")]`.
pub DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
Warn,
Deny,
"detects usage of `#![cfg_attr(..., crate_type/crate_name = \"...\")]`",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #91632 <https://github.com/rust-lang/rust/issues/91632>",
Expand Down
26 changes: 2 additions & 24 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,6 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use rustc_target::spec::abi::Abi;

fn fn_decl<'hir>(node: Node<'hir>) -> Option<&'hir FnDecl<'hir>> {
match node {
Node::Item(Item { kind: ItemKind::Fn(sig, _, _), .. })
| Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(sig, _), .. })
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(sig, _), .. }) => Some(&sig.decl),
Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. })
| Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, ..), .. }) => {
Some(fn_decl)
}
_ => None,
}
}

pub fn fn_sig<'hir>(node: Node<'hir>) -> Option<&'hir FnSig<'hir>> {
match &node {
Node::Item(Item { kind: ItemKind::Fn(sig, _, _), .. })
| Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(sig, _), .. })
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(sig, _), .. }) => Some(sig),
_ => None,
}
}

#[inline]
pub fn associated_body<'hir>(node: Node<'hir>) -> Option<BodyId> {
match node {
Expand Down Expand Up @@ -389,15 +367,15 @@ impl<'hir> Map<'hir> {

pub fn fn_decl_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
if let Some(node) = self.find(hir_id) {
fn_decl(node)
node.fn_decl()
} else {
bug!("no node for hir_id `{}`", hir_id)
}
}

pub fn fn_sig_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> {
if let Some(node) = self.find(hir_id) {
fn_sig(node)
node.fn_sig()
} else {
bug!("no node for hir_id `{}`", hir_id)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ fn fn_sig_and_body<'tcx>(
// to HIR for it.
let hir_node = tcx.hir().get_if_local(def_id).expect("expected DefId is local");
let fn_body_id = hir::map::associated_body(hir_node).expect("HIR node is a function with body");
(hir::map::fn_sig(hir_node), tcx.hir().body(fn_body_id))
(hir_node.fn_sig(), tcx.hir().body(fn_body_id))
}

fn get_body_span<'tcx>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use rustc_errors::{
MultiSpan,
};
use rustc_hir as hir;
use rustc_middle::hir::map::fn_sig;
use rustc_middle::ty::{self as ty, AssocItems, AssocKind, TyCtxt};
use rustc_session::Session;
use rustc_span::def_id::DefId;
Expand Down Expand Up @@ -368,7 +367,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
&self,
num_params_to_take: usize,
) -> String {
let fn_sig = self.tcx.hir().get_if_local(self.def_id).and_then(fn_sig);
let fn_sig = self.tcx.hir().get_if_local(self.def_id).and_then(hir::Node::fn_sig);
let is_used_in_input = |def_id| {
fn_sig.map_or(false, |fn_sig| {
fn_sig.decl.inputs.iter().any(|ty| match ty.kind {
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1992,11 +1992,11 @@ extern "rust-intrinsic" {
pub fn nontemporal_store<T>(ptr: *mut T, val: T);

/// See documentation of `<*const T>::offset_from` for details.
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
#[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")]
pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;

/// See documentation of `<*const T>::sub_ptr` for details.
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
pub fn ptr_offset_from_unsigned<T>(ptr: *const T, base: *const T) -> usize;

/// See documentation of `<*const T>::guaranteed_eq` for details.
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
#![feature(const_replace)]
#![feature(const_ptr_as_ref)]
#![feature(const_ptr_is_null)]
#![feature(const_ptr_offset_from)]
#![feature(const_ptr_read)]
#![feature(const_ptr_write)]
#![feature(const_raw_ptr_comparison)]
Expand Down
43 changes: 21 additions & 22 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,12 @@ macro_rules! r#try {
///
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
/// implementing either, as objects do not typically implement both. However, the module must
/// import the traits qualified so their names do not conflict:
/// avoid conflict between the trait names, such as by importing them as `_` or otherwise renaming
/// them:
///
/// ```
/// use std::fmt::Write as FmtWrite;
/// use std::io::Write as IoWrite;
/// use std::fmt::Write as _;
/// use std::io::Write as _;
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut s = String::new();
Expand All @@ -474,6 +475,23 @@ macro_rules! r#try {
/// }
/// ```
///
/// If you also need the trait names themselves, such as to implement one or both on your types,
/// import the containing module and then name them with a prefix:
///
/// ```
/// # #![allow(unused_imports)]
/// use std::fmt::{self, Write as _};
/// use std::io::{self, Write as _};
///
/// struct Example;
///
/// impl fmt::Write for Example {
/// fn write_str(&mut self, _s: &str) -> core::fmt::Result {
/// unimplemented!();
/// }
/// }
/// ```
///
/// Note: This macro can be used in `no_std` setups as well.
/// In a `no_std` setup you are responsible for the implementation details of the components.
///
Expand Down Expand Up @@ -526,25 +544,6 @@ macro_rules! write {
/// Ok(())
/// }
/// ```
///
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
/// implementing either, as objects do not typically implement both. However, the module must
/// import the traits qualified so their names do not conflict:
///
/// ```
/// use std::fmt::Write as FmtWrite;
/// use std::io::Write as IoWrite;
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut s = String::new();
/// let mut v = Vec::new();
///
/// writeln!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
/// writeln!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
/// assert_eq!(v, b"s = \"abc 123\\n\"\n");
/// Ok(())
/// }
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "writeln_macro")]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ impl<T: ?Sized> *const T {
/// }
/// ```
#[stable(feature = "ptr_offset_from", since = "1.47.0")]
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
#[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")]
#[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn offset_from(self, origin: *const T) -> isize
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ impl<T: ?Sized> *mut T {
/// }
/// ```
#[stable(feature = "ptr_offset_from", since = "1.47.0")]
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
#[rustc_const_stable(feature = "const_ptr_offset_from", since = "1.65.0")]
#[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub const unsafe fn offset_from(self, origin: *const T) -> isize
Expand Down
10 changes: 9 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,15 @@ note: if you're sure you want to do this, please open an issue as to why. In the

test_args.append(&mut builder.config.cmd.test_args());

cmd.args(&test_args);
// On Windows, replace forward slashes in test-args by backslashes
// so the correct filters are passed to libtest
if cfg!(windows) {
let test_args_win: Vec<String> =
test_args.iter().map(|s| s.replace("/", "\\")).collect();
cmd.args(&test_args_win);
} else {
cmd.args(&test_args);
}

if builder.is_verbose() {
cmd.arg("--verbose");
Expand Down
24 changes: 18 additions & 6 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,21 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
}
clean::ImportKind::Glob => String::new(),
};
let stab_tags = stab_tags.unwrap_or_default();
let (stab_tags_before, stab_tags_after) = if stab_tags.is_empty() {
("", "")
} else {
("<div class=\"item-right docblock-short\">", "</div>")
};
write!(
w,
"<div class=\"item-left {stab}{add}import-item\"{id}>\
<code>{vis}{imp}</code>\
</div>\
<div class=\"item-right docblock-short\">{stab_tags}</div>",
{stab_tags_before}{stab_tags}{stab_tags_after}",
stab = stab.unwrap_or_default(),
vis = myitem.visibility.print_with_space(myitem.item_id, cx),
imp = import.print(cx),
stab_tags = stab_tags.unwrap_or_default(),
);
w.write_str(ITEM_TABLE_ROW_CLOSE);
}
Expand Down Expand Up @@ -412,6 +417,12 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:

let doc_value = myitem.doc_value().unwrap_or_default();
w.write_str(ITEM_TABLE_ROW_OPEN);
let docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string();
let (docs_before, docs_after) = if docs.is_empty() {
("", "")
} else {
("<div class=\"item-right docblock-short\">", "</div>")
};
write!(
w,
"<div class=\"item-left {stab}{add}module-item\">\
Expand All @@ -420,11 +431,10 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
{unsafety_flag}\
{stab_tags}\
</div>\
<div class=\"item-right docblock-short\">{docs}</div>",
{docs_before}{docs}{docs_after}",
name = myitem.name.unwrap(),
visibility_emoji = visibility_emoji,
stab_tags = extra_info_tags(myitem, item, cx.tcx()),
docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string(),
class = myitem.type_(),
add = add,
stab = stab.unwrap_or_default(),
Expand Down Expand Up @@ -987,7 +997,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
// So C's HTML will have something like this:
//
// ```html
// <script type="text/javascript" src="/implementors/A/trait.Foo.js"
// <script src="/implementors/A/trait.Foo.js"
// data-ignore-extern-crates="A,B" async></script>
// ```
//
Expand All @@ -1013,9 +1023,11 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
.map(|cnum| cx.shared.tcx.crate_name(cnum).to_string())
.collect::<Vec<_>>()
.join(",");
let (extern_before, extern_after) =
if extern_crates.is_empty() { ("", "") } else { (" data-ignore-extern-crates=\"", "\"") };
write!(
w,
"<script type=\"text/javascript\" src=\"{src}\" data-ignore-extern-crates=\"{extern_crates}\" async></script>",
"<script src=\"{src}\"{extern_before}{extern_crates}{extern_after} async></script>",
src = js_src_path.finish(),
);
}
Expand Down
Loading