Auto merge of #104877 - matthiaskrgr:rollup-s7taiq8, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #103648 (Don't set `is_preview` for clippy and rustfmt)
 - #104654 (Add `#![deny(unsafe_op_in_unsafe_fn)]` in liballoc tests)
 - #104793 (unstable-book: Add page for the `abi_efiapi` feature)
 - #104841 (Assert that we don't capture escaping bound vars in `Fn` trait selection)
 - #104849 (Migrate source code elements style to CSS variables)
 - #104873 (RefCell::get_mut: fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-11-25 13:01:45 +00:00
commit e704e95250
19 changed files with 144 additions and 69 deletions

View File

@ -605,8 +605,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
{
debug!(?obligation, "confirm_fn_pointer_candidate");
// Okay to skip binder; it is reintroduced below.
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
let self_ty = self
.infcx
.shallow_resolve(obligation.self_ty().no_bound_vars())
.expect("fn pointer should not capture bound vars from predicate");
let sig = self_ty.fn_sig(self.tcx());
let trait_ref = closure_trait_ref_and_return_type(
self.tcx(),
@ -621,15 +623,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// Confirm the `type Output: Sized;` bound that is present on `FnOnce`
let cause = obligation.derived_cause(BuiltinDerivedObligation);
// The binder on the Fn obligation is "less" important than the one on
// the signature, as evidenced by how we treat it during projection.
// The safe thing to do here is to liberate it, though, which should
// have no worse effect than skipping the binder here.
let liberated_fn_ty =
self.infcx.replace_bound_vars_with_placeholders(obligation.predicate.rebind(self_ty));
let output_ty = self
.infcx
.replace_bound_vars_with_placeholders(liberated_fn_ty.fn_sig(self.tcx()).output());
let output_ty = self.infcx.replace_bound_vars_with_placeholders(sig.output());
let output_ty = normalize_with_depth_to(
self,
obligation.param_env,
@ -693,16 +687,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let gen_sig = substs.as_generator().poly_sig();
// (1) Feels icky to skip the binder here, but OTOH we know
// that the self-type is an generator type and hence is
// NOTE: The self-type is a generator type and hence is
// in fact unparameterized (or at least does not reference any
// regions bound in the obligation). Still probably some
// refactoring could make this nicer.
// regions bound in the obligation).
let self_ty = obligation
.predicate
.self_ty()
.no_bound_vars()
.expect("unboxed closure type should not capture bound vars from the predicate");
let trait_ref = super::util::generator_trait_ref_and_outputs(
self.tcx(),
obligation.predicate.def_id(),
obligation.predicate.skip_binder().self_ty(), // (1)
self_ty,
gen_sig,
)
.map_bound(|(trait_ref, ..)| trait_ref);

View File

@ -2271,15 +2271,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!(?closure_sig);
// (1) Feels icky to skip the binder here, but OTOH we know
// that the self-type is an unboxed closure type and hence is
// NOTE: The self-type is an unboxed closure type and hence is
// in fact unparameterized (or at least does not reference any
// regions bound in the obligation). Still probably some
// refactoring could make this nicer.
// regions bound in the obligation).
let self_ty = obligation
.predicate
.self_ty()
.no_bound_vars()
.expect("unboxed closure type should not capture bound vars from the predicate");
closure_trait_ref_and_return_type(
self.tcx(),
obligation.predicate.def_id(),
obligation.predicate.skip_binder().self_ty(), // (1)
self_ty,
closure_sig,
util::TupleArgumentsFlag::No,
)

View File

@ -298,11 +298,11 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
sig: ty::PolyFnSig<'tcx>,
tuple_arguments: TupleArgumentsFlag,
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>)> {
assert!(!self_ty.has_escaping_bound_vars());
let arguments_tuple = match tuple_arguments {
TupleArgumentsFlag::No => sig.skip_binder().inputs()[0],
TupleArgumentsFlag::Yes => tcx.intern_tup(sig.skip_binder().inputs()),
};
debug_assert!(!self_ty.has_escaping_bound_vars());
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty, arguments_tuple]);
sig.map_bound(|sig| (trait_ref, sig.output()))
}
@ -313,7 +313,7 @@ pub fn generator_trait_ref_and_outputs<'tcx>(
self_ty: Ty<'tcx>,
sig: ty::PolyGenSig<'tcx>,
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> {
debug_assert!(!self_ty.has_escaping_bound_vars());
assert!(!self_ty.has_escaping_bound_vars());
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty, sig.skip_binder().resume_ty]);
sig.map_bound(|sig| (trait_ref, sig.yield_ty, sig.return_ty))
}
@ -324,7 +324,7 @@ pub fn future_trait_ref_and_outputs<'tcx>(
self_ty: Ty<'tcx>,
sig: ty::PolyGenSig<'tcx>,
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>)> {
debug_assert!(!self_ty.has_escaping_bound_vars());
assert!(!self_ty.has_escaping_bound_vars());
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty]);
sig.map_bound(|sig| (trait_ref, sig.return_ty))
}

View File

@ -102,9 +102,19 @@ unsafe impl const Allocator for ConstAllocator {
let new_ptr = self.allocate(new_layout)?;
if new_layout.size() > 0 {
// Safety: `new_ptr` is valid for writes and `ptr` for reads of
// `old_layout.size()`, because `new_layout.size() >=
// old_layout.size()` (which is an invariant that must be upheld by
// callers).
unsafe {
new_ptr.as_mut_ptr().copy_from_nonoverlapping(ptr.as_ptr(), old_layout.size());
}
// Safety: `ptr` is never used again is also an invariant which must
// be upheld by callers.
unsafe {
self.deallocate(ptr, old_layout);
}
}
Ok(new_ptr)
}
@ -114,13 +124,22 @@ unsafe impl const Allocator for ConstAllocator {
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError> {
let new_ptr = self.grow(ptr, old_layout, new_layout)?;
// Safety: Invariants of `grow_zeroed` and `grow` are the same, and must
// be enforced by callers.
let new_ptr = unsafe { self.grow(ptr, old_layout, new_layout)? };
if new_layout.size() > 0 {
let old_size = old_layout.size();
let new_size = new_layout.size();
let raw_ptr = new_ptr.as_mut_ptr();
// Safety:
// - `grow` returned Ok, so the returned pointer must be valid for
// `new_size` bytes
// - `new_size` must be larger than `old_size`, which is an
// invariant which must be upheld by callers.
unsafe {
raw_ptr.add(old_size).write_bytes(0, new_size - old_size);
}
}
Ok(new_ptr)
}
@ -137,9 +156,19 @@ unsafe impl const Allocator for ConstAllocator {
let new_ptr = self.allocate(new_layout)?;
if new_layout.size() > 0 {
// Safety: `new_ptr` and `ptr` are valid for reads/writes of
// `new_layout.size()` because of the invariants of shrink, which
// include `new_layout.size()` being smaller than (or equal to)
// `old_layout.size()`.
unsafe {
new_ptr.as_mut_ptr().copy_from_nonoverlapping(ptr.as_ptr(), new_layout.size());
}
// Safety: `ptr` is never used again is also an invariant which must
// be upheld by callers.
unsafe {
self.deallocate(ptr, old_layout);
}
}
Ok(new_ptr)
}

View File

@ -48,6 +48,7 @@
#![feature(once_cell)]
#![feature(drain_keep_rest)]
#![deny(fuzzy_provenance_casts)]
#![deny(unsafe_op_in_unsafe_fn)]
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

View File

@ -1089,7 +1089,8 @@ fn test_into_iter_drop_allocator() {
}
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
System.deallocate(ptr, layout)
// Safety: Invariants passed to caller.
unsafe { System.deallocate(ptr, layout) }
}
}

View File

@ -1025,7 +1025,7 @@ impl<T: ?Sized> RefCell<T> {
///
/// Since this method borrows `RefCell` mutably, it is statically guaranteed
/// that no borrows to the underlying data exist. The dynamic checks inherent
/// in [`borrow_mut`] and most other methods of `RefCell` are therefor
/// in [`borrow_mut`] and most other methods of `RefCell` are therefore
/// unnecessary.
///
/// This method can only be called if `RefCell` can be mutably borrowed,

View File

@ -1191,7 +1191,6 @@ impl Step for Clippy {
let mut tarball = Tarball::new(builder, "clippy", &target.triple);
tarball.set_overlay(OverlayKind::Clippy);
tarball.is_preview(true);
tarball.add_file(clippy, "bin", 0o755);
tarball.add_file(cargoclippy, "bin", 0o755);
tarball.add_legal_and_readme_to("share/doc/clippy");
@ -1289,7 +1288,6 @@ impl Step for Rustfmt {
.expect("cargo fmt expected to build - essential tool");
let mut tarball = Tarball::new(builder, "rustfmt", &target.triple);
tarball.set_overlay(OverlayKind::Rustfmt);
tarball.is_preview(true);
tarball.add_file(rustfmt, "bin", 0o755);
tarball.add_file(cargofmt, "bin", 0o755);
tarball.add_legal_and_readme_to("share/doc/rustfmt");
@ -1550,8 +1548,6 @@ impl Step for Extended {
format!("{}-{}", name, target.triple)
} else if name == "rust-analyzer" {
"rust-analyzer-preview".to_string()
} else if name == "clippy" {
"clippy-preview".to_string()
} else if name == "rust-demangler" {
"rust-demangler-preview".to_string()
} else if name == "miri" {

View File

@ -326,6 +326,8 @@ impl Config {
}
let filename = format!("rustfmt-{version}-{build}.tar.xz", build = host.triple);
// cfg(bootstrap): will need to be changed from `rustfmt-preview` to `rustfmt` the next time you run `bump-stage0`.
// See <https://github.com/rust-lang/rust/pull/103648>
self.download_component(DownloadSource::Dist, filename, "rustfmt-preview", &date, "stage0");
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustfmt"));

View File

@ -0,0 +1,23 @@
# `abi_efiapi`
The tracking issue for this feature is: [#65815]
[#65815]: https://github.com/rust-lang/rust/issues/65815
------------------------
The `efiapi` calling convention can be used for defining a function with
an ABI compatible with the UEFI Interfaces as defined in the [UEFI
Specification].
Example:
```rust
#![feature(abi_efiapi)]
extern "efiapi" { fn f1(); }
extern "efiapi" fn f2() { todo!() }
```
[UEFI Specification]: https://uefi.org/specs/UEFI/2.10/

View File

@ -1343,6 +1343,13 @@ a.test-arrow:hover {
border-bottom: 1px solid var(--border-color);
margin-bottom: 6px;
}
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: var(--source-sidebar-background-hover);
}
#source-sidebar div.files > a.selected {
background-color: var(--source-sidebar-background-selected);
}
#sidebar-toggle > button {
font-size: inherit;
font-weight: bold;

View File

@ -84,6 +84,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg)
brightness(113%) contrast(76%);
--crate-search-hover-border: #e0e0e0;
--source-sidebar-background-selected: #14191f;
--source-sidebar-background-hover: #14191f;
}
h1, h2, h3, h4 {
@ -208,12 +210,8 @@ pre.rust .kw-2, pre.rust .prelude-ty {}
color: #fff;
}
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #14191f;
color: #ffb44c;
}
#source-sidebar div.files > a:focus, details.dir-entry summary:focus,
#source-sidebar div.files > a.selected {
background-color: #14191f;
color: #ffb44c;
}

View File

@ -79,6 +79,8 @@
--crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg)
brightness(100%) contrast(91%);
--crate-search-hover-border: #2196f3;
--source-sidebar-background-selected: #333;
--source-sidebar-background-hover: #444;
}
.content .item-info::before { color: #ccc; }
@ -105,14 +107,6 @@ details.rustdoc-toggle > summary::before {
color: #888;
}
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #444;
}
#source-sidebar div.files > a.selected {
background-color: #333;
}
.scraped-example-list .scrape-help {
border-color: #aaa;
color: #eee;

View File

@ -76,6 +76,8 @@
--crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg)
brightness(96%) contrast(93%);
--crate-search-hover-border: #717171;
--source-sidebar-background-selected: #fff;
--source-sidebar-background-hover: #e0e0e0;
}
.content .item-info::before { color: #ccc; }
@ -98,13 +100,6 @@ body.source .example-wrap pre.rust a {
color: #888;
}
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: #E0E0E0;
}
#source-sidebar div.files > a.selected {
background-color: #fff;
}
.scraped-example-list .scrape-help {
border-color: #555;
color: #333;

View File

@ -43,16 +43,24 @@ define-function: (
"#source-sidebar details[open] > .files a.selected",
{"color": |color_hover|, "background-color": |background|},
)),
// Without hover or focus.
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle|})),
// With focus.
("focus", "#sidebar-toggle > button"),
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle_hover|})),
("assert-css", (
"#sidebar-toggle > button:focus",
{"background-color": |background_toggle_hover|},
)),
("focus", ".search-input"),
// With hover.
("move-cursor-to", "#sidebar-toggle > button"),
("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle_hover|})),
// Without hover.
("assert-css", (
"#sidebar-toggle > button:hover",
{"background-color": |background_toggle_hover|},
)),
// Without hover or focus.
("assert-css", (
"#source-sidebar details[open] > .files a:not(.selected)",
{"color": |color|, "background-color": |background_toggle|},
@ -60,17 +68,37 @@ define-function: (
// With focus.
("focus", "#source-sidebar details[open] > .files a:not(.selected)"),
("wait-for-css", (
"#source-sidebar details[open] > .files a:not(.selected)",
"#source-sidebar details[open] > .files a:not(.selected):focus",
{"color": |color_hover|, "background-color": |background_hover|},
)),
("focus", ".search-input"),
// With hover.
("move-cursor-to", "#source-sidebar details[open] > .files a:not(.selected)"),
("assert-css", (
"#source-sidebar details[open] > .files a:not(.selected)",
"#source-sidebar details[open] > .files a:not(.selected):hover",
{"color": |color_hover|, "background-color": |background_hover|},
)),
// Without hover.
// Without hover or focus.
("assert-css", (
"#source-sidebar .dir-entry summary",
{"color": |color|, "background-color": |background_toggle|},
)),
// With focus.
("focus", "#source-sidebar .dir-entry summary"),
("wait-for-css", (
"#source-sidebar .dir-entry summary:focus",
{"color": |color_hover|, "background-color": |background_hover|},
)),
("focus", ".search-input"),
// With hover.
("move-cursor-to", "#source-sidebar .dir-entry summary"),
("assert-css", (
"#source-sidebar .dir-entry summary:hover",
{"color": |color_hover|, "background-color": |background_hover|},
)),
// Without hover or focus.
("assert-css", (
"#source-sidebar details[open] > .folders > details > summary",
{"color": |color|, "background-color": |background_toggle|},
@ -78,14 +106,14 @@ define-function: (
// With focus.
("focus", "#source-sidebar details[open] > .folders > details > summary"),
("wait-for-css", (
"#source-sidebar details[open] > .folders > details > summary",
"#source-sidebar details[open] > .folders > details > summary:focus",
{"color": |color_hover|, "background-color": |background_hover|},
)),
("focus", ".search-input"),
// With hover.
("move-cursor-to", "#source-sidebar details[open] > .folders > details > summary"),
("assert-css", (
"#source-sidebar details[open] > .folders > details > summary",
"#source-sidebar details[open] > .folders > details > summary:hover",
{"color": |color_hover|, "background-color": |background_hover|},
)),
],

View File

@ -49,10 +49,10 @@ pkg_type! {
Cargo = "cargo",
HtmlDocs = "rust-docs",
RustAnalysis = "rust-analysis",
Clippy = "clippy",
Rustfmt = "rustfmt",
Rls = "rls"; preview = true,
RustAnalyzer = "rust-analyzer"; preview = true,
Clippy = "clippy"; preview = true,
Rustfmt = "rustfmt"; preview = true,
LlvmTools = "llvm-tools"; preview = true,
Miri = "miri"; preview = true,
JsonDocs = "rust-docs-json"; preview = true,

View File

@ -6,7 +6,7 @@ use std::convert::TryInto;
const PATH: &str = "src/stage0.json";
const COMPILER_COMPONENTS: &[&str] = &["rustc", "rust-std", "cargo"];
const RUSTFMT_COMPONENTS: &[&str] = &["rustfmt-preview"];
const RUSTFMT_COMPONENTS: &[&str] = &["rustfmt"];
struct Tool {
config: Config,

View File

@ -6,7 +6,7 @@ use super::verify_inside_clippy_dir;
/// Rusts setup uses `git rev-parse --git-common-dir` to get the root directory of the repo.
/// I've decided against this for the sake of simplicity and to make sure that it doesn't install
/// the hook if `clippy_dev` would be used in the rust tree. The hook also references this tool
/// for formatting and should therefor only be used in a normal clone of clippy
/// for formatting and should therefore only be used in a normal clone of clippy
const REPO_GIT_DIR: &str = ".git";
const HOOK_SOURCE_FILE: &str = "util/etc/pre-commit.sh";
const HOOK_TARGET_FILE: &str = ".git/hooks/pre-commit";

View File

@ -113,7 +113,7 @@ impl HirEqInterExpr<'_, '_, '_> {
}
}
// eq_pat adds the HirIds to the locals map. We therefor call it last to make sure that
// eq_pat adds the HirIds to the locals map. We therefore call it last to make sure that
// these only get added if the init and type is equal.
both(&l.init, &r.init, |l, r| self.eq_expr(l, r))
&& both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r))