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 6 pull requests #104877

Merged
merged 16 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
54a6d4e
Add `#![deny(unsafe_op_in_unsafe_fn)]` in liballoc tests
thomcc Nov 20, 2022
bed85a4
unstable-book: Add page for the `abi_efiapi` feature
nicholasbishop Nov 23, 2022
8927135
Assert that we don't capture escaping bound vars in Fn trait selection
compiler-errors Nov 24, 2022
c7330c9
Also check that fn pointer candidates don't have escaping bound vars
compiler-errors Nov 24, 2022
d945967
Remove comment, simplify since we asserted fn ptr Self type has no bo…
compiler-errors Nov 24, 2022
786ec7c
Migrate source code elements style to CSS variables
GuillaumeGomez Nov 24, 2022
6fc52c6
Extend GUI test to include more source code elements checks
GuillaumeGomez Nov 24, 2022
e6a4008
Strenghten GUI test to include extra state in selector
GuillaumeGomez Nov 24, 2022
fb3e724
Don't set `is_preview` for clippy and rustfmt
jyn514 Oct 27, 2022
6ed4f15
RefCell::get_mut: fix typo
RalfJung Nov 25, 2022
a9313e9
Rollup merge of #103648 - jyn514:no-preview, r=Mark-Simulacrum
matthiaskrgr Nov 25, 2022
808157b
Rollup merge of #104654 - thomcc:alloc-tests-unsafe_op_in_unsafe_fn, …
matthiaskrgr Nov 25, 2022
f00c3f0
Rollup merge of #104793 - nicholasbishop:bishop-add-efiapi, r=JohnTitor
matthiaskrgr Nov 25, 2022
34f1de8
Rollup merge of #104841 - compiler-errors:fishy-bound-var, r=jackh726
matthiaskrgr Nov 25, 2022
8babe1c
Rollup merge of #104849 - GuillaumeGomez:source-code-sidebar-css-migr…
matthiaskrgr Nov 25, 2022
f360686
Rollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC
matthiaskrgr Nov 25, 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
29 changes: 13 additions & 16 deletions compiler/rustc_trait_selection/src/traits/select/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_trait_selection/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand All @@ -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))
}
Expand All @@ -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))
}
Expand Down
41 changes: 35 additions & 6 deletions library/alloc/tests/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@ unsafe impl const Allocator for ConstAllocator {

let new_ptr = self.allocate(new_layout)?;
if new_layout.size() > 0 {
new_ptr.as_mut_ptr().copy_from_nonoverlapping(ptr.as_ptr(), old_layout.size());
self.deallocate(ptr, old_layout);
// 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)
}
Expand All @@ -114,12 +124,21 @@ 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();
raw_ptr.add(old_size).write_bytes(0, new_size - old_size);
// 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)
}
Expand All @@ -137,8 +156,18 @@ unsafe impl const Allocator for ConstAllocator {

let new_ptr = self.allocate(new_layout)?;
if new_layout.size() > 0 {
new_ptr.as_mut_ptr().copy_from_nonoverlapping(ptr.as_ptr(), new_layout.size());
self.deallocate(ptr, old_layout);
// 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)
}
Expand Down
1 change: 1 addition & 0 deletions library/alloc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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" {
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
23 changes: 23 additions & 0 deletions src/doc/unstable-book/src/language-features/abi-efiapi.md
Original file line number Diff line number Diff line change
@@ -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/
7 changes: 7 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 2 additions & 8 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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;
Expand Down
9 changes: 2 additions & 7 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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;
Expand Down
Loading