mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Auto merge of #98874 - matthiaskrgr:rollup-0u4hm54, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #98501 (rustc_passes/src/entry.rs: De-duplicate more code with `fn throw_attr_err()`) - #98774 (rustdoc: make source sidebar toggle a real button) - #98806 (Fix long declaration trailing whitespace) - #98823 (Fix rust-call ICE in mir-inliner) - #98870 (Add regression test for #86784) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
9c9ae85a47
compiler
src
librustdoc/html
test
@ -180,16 +180,20 @@ impl<'tcx> Inliner<'tcx> {
|
||||
return Err("failed to normalize return type");
|
||||
}
|
||||
if callsite.fn_sig.abi() == Abi::RustCall {
|
||||
let mut args = args.into_iter();
|
||||
let _ = args.next(); // Skip `self` argument.
|
||||
let arg_tuple_ty = args.next().unwrap().ty(&caller_body.local_decls, self.tcx);
|
||||
assert!(args.next().is_none());
|
||||
let (arg_tuple, skipped_args) = match &args[..] {
|
||||
[arg_tuple] => (arg_tuple, 0),
|
||||
[_, arg_tuple] => (arg_tuple, 1),
|
||||
_ => bug!("Expected `rust-call` to have 1 or 2 args"),
|
||||
};
|
||||
|
||||
let arg_tuple_ty = arg_tuple.ty(&caller_body.local_decls, self.tcx);
|
||||
let ty::Tuple(arg_tuple_tys) = arg_tuple_ty.kind() else {
|
||||
bug!("Closure arguments are not passed as a tuple");
|
||||
};
|
||||
|
||||
for (arg_ty, input) in arg_tuple_tys.iter().zip(callee_body.args_iter().skip(1)) {
|
||||
for (arg_ty, input) in
|
||||
arg_tuple_tys.iter().zip(callee_body.args_iter().skip(skipped_args))
|
||||
{
|
||||
let input_type = callee_body.local_decls[input].ty;
|
||||
if !equal_up_to_regions(self.tcx, self.param_env, arg_ty, input_type) {
|
||||
trace!(?arg_ty, ?input_type);
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_ast::entry::EntryPointType;
|
||||
use rustc_ast::{entry::EntryPointType, Attribute};
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
@ -7,9 +7,8 @@ use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{DefIdTree, TyCtxt};
|
||||
use rustc_session::config::{CrateType, EntryFnType};
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::{Span, Symbol, DUMMY_SP};
|
||||
|
||||
struct EntryContext<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
@ -72,9 +71,16 @@ fn entry_point_type(ctxt: &EntryContext<'_>, id: ItemId, at_root: bool) -> Entry
|
||||
}
|
||||
}
|
||||
|
||||
fn throw_attr_err(sess: &Session, span: Span, attr: &str) {
|
||||
sess.struct_span_err(span, &format!("`{}` attribute can only be used on functions", attr))
|
||||
.emit();
|
||||
fn err_if_attr_found(ctxt: &EntryContext<'_>, attrs: &[Attribute], sym: Symbol) {
|
||||
if let Some(attr) = ctxt.tcx.sess.find_by_name(attrs, sym) {
|
||||
ctxt.tcx
|
||||
.sess
|
||||
.struct_span_err(
|
||||
attr.span,
|
||||
&format!("`{}` attribute can only be used on functions", sym.as_str()),
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
|
||||
@ -84,12 +90,8 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
|
||||
EntryPointType::None => (),
|
||||
_ if !matches!(ctxt.tcx.def_kind(id.def_id), DefKind::Fn) => {
|
||||
let attrs = ctxt.tcx.hir().attrs(id.hir_id());
|
||||
if let Some(attr) = ctxt.tcx.sess.find_by_name(attrs, sym::start) {
|
||||
throw_attr_err(&ctxt.tcx.sess, attr.span, "start");
|
||||
}
|
||||
if let Some(attr) = ctxt.tcx.sess.find_by_name(attrs, sym::rustc_main) {
|
||||
throw_attr_err(&ctxt.tcx.sess, attr.span, "rustc_main");
|
||||
}
|
||||
err_if_attr_found(ctxt, attrs, sym::start);
|
||||
err_if_attr_found(ctxt, attrs, sym::rustc_main);
|
||||
}
|
||||
EntryPointType::MainNamed => (),
|
||||
EntryPointType::OtherMain => {
|
||||
|
@ -1283,10 +1283,6 @@ impl clean::FnDecl {
|
||||
let mut args = Buffer::html();
|
||||
let mut args_plain = Buffer::new();
|
||||
for (i, input) in self.inputs.values.iter().enumerate() {
|
||||
if i == 0 {
|
||||
args.push_str("<br>");
|
||||
}
|
||||
|
||||
if let Some(selfty) = input.to_self() {
|
||||
match selfty {
|
||||
clean::SelfValue => {
|
||||
@ -1312,8 +1308,7 @@ impl clean::FnDecl {
|
||||
}
|
||||
} else {
|
||||
if i > 0 {
|
||||
args.push_str(" <br>");
|
||||
args_plain.push_str(" ");
|
||||
args.push_str("<br>");
|
||||
}
|
||||
if input.is_const {
|
||||
args.push_str("const ");
|
||||
@ -1360,13 +1355,14 @@ impl clean::FnDecl {
|
||||
let full_pad = format!("<br>{}", " ".repeat(indent + 4));
|
||||
let close_pad = format!("<br>{}", " ".repeat(indent));
|
||||
format!(
|
||||
"({args}{close}){arrow}",
|
||||
"({pad}{args}{close}){arrow}",
|
||||
pad = if self.inputs.values.is_empty() { "" } else { &full_pad },
|
||||
args = args.replace("<br>", &full_pad),
|
||||
close = close_pad,
|
||||
arrow = arrow
|
||||
)
|
||||
} else {
|
||||
format!("({args}){arrow}", args = args.replace("<br>", ""), arrow = arrow)
|
||||
format!("({args}){arrow}", args = args.replace("<br>", " "), arrow = arrow)
|
||||
};
|
||||
|
||||
if f.alternate() {
|
||||
|
@ -418,7 +418,7 @@ nav.sub {
|
||||
background-color: var(--sidebar-background-color);
|
||||
}
|
||||
|
||||
#sidebar-toggle:hover {
|
||||
#sidebar-toggle > button:hover, #sidebar-toggle > button:focus {
|
||||
background-color: var(--sidebar-background-color-hover);
|
||||
}
|
||||
|
||||
@ -1401,7 +1401,6 @@ pre.rust {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
left: 0;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-size: 1.25rem;
|
||||
border-bottom: 1px solid;
|
||||
@ -1422,7 +1421,24 @@ pre.rust {
|
||||
border-bottom: 1px solid;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
#sidebar-toggle > button {
|
||||
background: none;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
border: none;
|
||||
outline: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
/* work around button layout strangeness: https://stackoverflow.com/q/7271561 */
|
||||
width: 100%;
|
||||
/* iOS button gradient: https://stackoverflow.com/q/5438567 */
|
||||
-webkit-appearance: none;
|
||||
opacity: 1;
|
||||
}
|
||||
#settings-menu, #help-button {
|
||||
margin-left: 4px;
|
||||
outline: none;
|
||||
|
@ -57,7 +57,7 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
|
||||
}
|
||||
|
||||
function toggleSidebar() {
|
||||
const child = this.children[0];
|
||||
const child = this.parentNode.children[0];
|
||||
if (child.innerText === ">") {
|
||||
if (window.innerWidth < 701) {
|
||||
// This is to keep the scroll position on mobile.
|
||||
@ -86,15 +86,15 @@ function toggleSidebar() {
|
||||
function createSidebarToggle() {
|
||||
const sidebarToggle = document.createElement("div");
|
||||
sidebarToggle.id = "sidebar-toggle";
|
||||
sidebarToggle.onclick = toggleSidebar;
|
||||
|
||||
const inner = document.createElement("div");
|
||||
const inner = document.createElement("button");
|
||||
|
||||
if (getCurrentValue("source-sidebar-show") === "true") {
|
||||
inner.innerText = "<";
|
||||
} else {
|
||||
inner.innerText = ">";
|
||||
}
|
||||
inner.onclick = toggleSidebar;
|
||||
|
||||
sidebarToggle.appendChild(inner);
|
||||
return sidebarToggle;
|
||||
|
@ -30,6 +30,15 @@ assert-css: (
|
||||
"#source-sidebar details[open] > .files a.selected",
|
||||
{"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"},
|
||||
)
|
||||
// Without hover or focus.
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgba(0, 0, 0, 0)"})
|
||||
// With focus.
|
||||
focus: "#sidebar-toggle > button"
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgb(224, 224, 224)"})
|
||||
focus: ".search-input"
|
||||
// With hover.
|
||||
move-cursor-to: "#sidebar-toggle > button"
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgb(224, 224, 224)"})
|
||||
// Without hover.
|
||||
assert-css: (
|
||||
"#source-sidebar details[open] > .files a:not(.selected)",
|
||||
@ -76,6 +85,15 @@ assert-css: (
|
||||
"#source-sidebar details[open] > .files > a.selected",
|
||||
{"color": "rgb(221, 221, 221)", "background-color": "rgb(51, 51, 51)"},
|
||||
)
|
||||
// Without hover or focus.
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgba(0, 0, 0, 0)"})
|
||||
// With focus.
|
||||
focus: "#sidebar-toggle > button"
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgb(103, 103, 103)"})
|
||||
focus: ".search-input"
|
||||
// With hover.
|
||||
move-cursor-to: "#sidebar-toggle > button"
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgb(103, 103, 103)"})
|
||||
// Without hover.
|
||||
assert-css: (
|
||||
"#source-sidebar details[open] > .files > a:not(.selected)",
|
||||
@ -122,6 +140,15 @@ assert-css: (
|
||||
"#source-sidebar details[open] > .files a.selected",
|
||||
{"color": "rgb(255, 180, 76)", "background-color": "rgb(20, 25, 31)"},
|
||||
)
|
||||
// Without hover or focus.
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgba(0, 0, 0, 0)"})
|
||||
// With focus.
|
||||
focus: "#sidebar-toggle > button"
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgba(70, 70, 70, 0.33)"})
|
||||
focus: ".search-input"
|
||||
// With hover.
|
||||
move-cursor-to: "#sidebar-toggle > button"
|
||||
assert-css: ("#sidebar-toggle > button", {"background-color": "rgba(70, 70, 70, 0.33)"})
|
||||
// Without hover.
|
||||
assert-css: (
|
||||
"#source-sidebar details[open] > .files a:not(.selected)",
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
// @has assoc_types/trait.Index.html
|
||||
pub trait Index<I: ?Sized> {
|
||||
// @has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized'
|
||||
// @has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized'
|
||||
type Output: ?Sized;
|
||||
// @has - '//*[@id="tymethod.index"]//h4[@class="code-header"]' \
|
||||
// "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
|
||||
|
@ -0,0 +1,7 @@
|
||||
<code>pub trait Write {
|
||||
fn <a href="#tymethod.poll_write" class="fnname">poll_write</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        buf: &mut [<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]<br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>;
|
||||
<span class="item-spacer" /> fn <a href="#tymethod.poll_flush" class="fnname">poll_flush</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>;
|
||||
<span class="item-spacer" /> fn <a href="#tymethod.poll_close" class="fnname">poll_close</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>;
|
||||
|
||||
fn <a href="#method.poll_write_vectored" class="fnname">poll_write_vectored</a>(<br />        self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>,<br />        bufs: &[<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]<br />    ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>> { ... }
|
||||
}</code>
|
30
src/test/rustdoc/decl-trailing-whitespace.rs
Normal file
30
src/test/rustdoc/decl-trailing-whitespace.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/98803>.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
pub struct Error;
|
||||
|
||||
// @has 'foo/trait.Write.html'
|
||||
|
||||
pub trait Write {
|
||||
// @snapshot 'declaration' - '//*[@class="docblock item-decl"]//code'
|
||||
fn poll_write(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>,
|
||||
buf: &mut [usize]
|
||||
) -> Option<Result<usize, Error>>;
|
||||
fn poll_flush(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>
|
||||
) -> Option<Result<(), Error>>;
|
||||
fn poll_close(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>,
|
||||
) -> Option<Result<(), Error>>;
|
||||
|
||||
fn poll_write_vectored(
|
||||
self: Option<String>,
|
||||
cx: &mut Option<String>,
|
||||
bufs: &[usize]
|
||||
) -> Option<Result<usize, Error>> {}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
// revisions: normal opt
|
||||
// check-pass
|
||||
//[opt] compile-flags: -Zmir-opt-level=3
|
||||
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
extern "rust-call" fn foo<T>(_: T) {}
|
||||
|
2597
src/test/ui/recursion/issue-86784.rs
Normal file
2597
src/test/ui/recursion/issue-86784.rs
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user