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 14 pull requests #77437

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
84ef603
Fix 'FIXME' about using NonZeroU32 instead of u32.
m-ou-se Sep 17, 2020
323bcd3
unix: Extend UnixStream and UnixDatagram to send and receive file des…
LinkTed Aug 21, 2020
ff87ba1
Split net.rs into multiple files
LinkTed Aug 22, 2020
e7b8925
Add AncillaryError
LinkTed Aug 22, 2020
656d7b9
Add UCred struct
LinkTed Aug 23, 2020
baa7c21
Move `add_to_ancillary_data` and `AncillaryDataIter` to ancillary.rs
LinkTed Aug 23, 2020
b4bc663
Using `read_unaligned` instead of `memcpy`.
LinkTed Aug 25, 2020
383aaac
Replace `TryFrom` of `AncillaryData` with a private method.
LinkTed Aug 25, 2020
83cb075
Add integer overflow check
LinkTed Aug 25, 2020
24938ee
Remove `Clone` trait bound in `add_to_ancillary_data`
LinkTed Aug 25, 2020
acd7dbe
Remove lifetime annotation in `messages` function
LinkTed Aug 25, 2020
5bf5db9
Remove inner function in `bind`, `connect` and `send_to`
LinkTed Aug 25, 2020
7106d76
Use `fill` instead of `memset`
LinkTed Aug 27, 2020
0968853
Remove unnecessary path
LinkTed Aug 27, 2020
1f3f10a
Move conditional compilation to the upper module and sort the target …
LinkTed Aug 28, 2020
748d310
Reduce impl trait by using macro in `raw_fd.rs`
LinkTed Aug 28, 2020
f947d2f
Add doc(cfg(...))
LinkTed Aug 29, 2020
e66b921
Add doc comments
LinkTed Aug 29, 2020
ab469ba
Rename `test.rs` to `tests.rs`
LinkTed Sep 1, 2020
dce9b21
Add `set_passcred` and `passcred` methods to `UnixStream` and `UnixDa…
LinkTed Sep 7, 2020
031521a
Change API to unsafe and add doc comments
LinkTed Sep 12, 2020
e78467b
Change name of struct to SocketCred
LinkTed Sep 16, 2020
263f0b2
Change standard types to libc types
LinkTed Sep 16, 2020
e74dbac
Remove unsupported target_os for SocketCred
LinkTed Sep 17, 2020
e9ff53c
Cast boolean into int directly in function set_passcred
LinkTed Sep 17, 2020
a86761e
Replace `assert` with `unreachable`
LinkTed Sep 18, 2020
05765ac
Add the code of the tracking issue
LinkTed Sep 19, 2020
112b7dc
Remove `target_os`, which does not have `MSG_CMSG_CLOEXEC` constant i…
LinkTed Sep 20, 2020
3806579
Remove `target_os`, which does not have `cmsghdr` struct in `libc`
LinkTed Sep 20, 2020
d5f070b
Remove `target_os`, which does not have `SO_PASSCRED` constant in `libc`
LinkTed Sep 20, 2020
6626e5b
Fix cfg condition for test
LinkTed Sep 20, 2020
b50153d
Add conditional compilation for import
LinkTed Sep 20, 2020
4ee7a85
Fix `MSG_CMSG_CLOEXEC` for macos
LinkTed Sep 22, 2020
d839df3
Fix `SO_PASSCRED` for macos
LinkTed Sep 22, 2020
168d063
Fix unused import for `IoSliceMut` for macos
LinkTed Sep 22, 2020
4e9714b
Remove `SocketCred` for `emscripten`
LinkTed Sep 22, 2020
f289468
Stabilize slice_ptr_range.
m-ou-se Sep 23, 2020
d77477e
Fix type mismatching for different OSes.
LinkTed Sep 25, 2020
3efcf72
Remove unnecessary trailing semicolon
LinkTed Sep 26, 2020
20c88dd
Remove `passcred` for `emscripten`
LinkTed Sep 26, 2020
c297e20
Add accessors to Command.
ehuss Sep 21, 2020
6f6336b
Split sys_common::Mutex in StaticMutex and MovableMutex.
m-ou-se Sep 24, 2020
825dda8
Fix ui test.
m-ou-se Sep 24, 2020
7eea071
Change imports for `cfg(doc)`
LinkTed Sep 27, 2020
6533c29
Remove --cfg dox from rustdoc.rs
jyn514 Sep 29, 2020
351f850
Remove unused --cfg stageN
jyn514 Sep 29, 2020
384eb26
rustc_metadata: Do not forget to encode inherent impls for foreign types
petrochenkov Sep 30, 2020
20202da
Improve the example for ptr::copy
scottmcm Oct 1, 2020
8164218
Fix some clippy issues
jyn514 Oct 1, 2020
e58f3d3
Things are only moved if non-copy
scottmcm Oct 1, 2020
4243475
BTreeMap: use Unique::from to avoid a cast where type information exists
ssomers Sep 26, 2020
8b2bdfd
Improve std::sys::windows::compat.
m-ou-se Sep 20, 2020
93310ef
Use AcquireSRWLockExclusive::is_available() instead of an extra lookup.
m-ou-se Sep 20, 2020
09cbaf4
Formatting.
m-ou-se Sep 20, 2020
63b6007
Work around potential merging/duplication issues in sys/windows/compat.
m-ou-se Oct 1, 2020
2140d80
Add note about possible future improvement
m-ou-se Oct 1, 2020
ca98778
Update stdarch submodule
jyn514 Oct 1, 2020
cd159fd
Uplift drop-bounds lint from clippy
notriddle Aug 19, 2020
4bf5c45
Remove outdated line from `publish_toolstate` hook
LeSeulArtichaut Sep 28, 2020
1c2c336
Link `new` method in `DefautHasher`s doc
WaffleLapkin Oct 1, 2020
a7db0bf
Rollup merge of #69864 - LinkTed:master, r=Amanieu
Dylan-DPC Oct 1, 2020
edf43ea
Rollup merge of #75699 - notriddle:drop-bounds-lint, r=petrochenkov
Dylan-DPC Oct 1, 2020
3f868d2
Rollup merge of #76851 - fusion-engineering-forks:fixme-nonzero, r=pe…
Dylan-DPC Oct 1, 2020
4ded681
Rollup merge of #76979 - fusion-engineering-forks:windows-fallback-ch…
Dylan-DPC Oct 1, 2020
d2e06b7
Rollup merge of #77029 - ehuss:command-access, r=dtolnay
Dylan-DPC Oct 1, 2020
bf59451
Rollup merge of #77111 - fusion-engineering-forks:stabilize-slice-ptr…
Dylan-DPC Oct 1, 2020
5f080bb
Rollup merge of #77147 - fusion-engineering-forks:static-mutex, r=dto…
Dylan-DPC Oct 1, 2020
01ff733
Rollup merge of #77312 - LeSeulArtichaut:toolstate-msg, r=Mark-Simula…
Dylan-DPC Oct 1, 2020
260256b
Rollup merge of #77347 - jyn514:dox, r=Amanieu
Dylan-DPC Oct 1, 2020
9b26c35
Rollup merge of #77375 - petrochenkov:inherext, r=oli-obk
Dylan-DPC Oct 1, 2020
55409cc
Rollup merge of #77385 - scottmcm:fix-77220, r=jyn514
Dylan-DPC Oct 1, 2020
ecfea2f
Rollup merge of #77389 - jyn514:THE-PAPERCLIP-COMETH, r=Mark-Simulacrum
Dylan-DPC Oct 1, 2020
c8440bf
Rollup merge of #77399 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
Dylan-DPC Oct 1, 2020
86e6afa
Rollup merge of #77429 - WaffleLapkin:doc_link_default_hasher_new, r=…
Dylan-DPC Oct 1, 2020
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
4 changes: 2 additions & 2 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! List of the accepted feature gates.

use super::{Feature, State};
use super::{to_nonzero, Feature, State};
use rustc_span::symbol::sym;

macro_rules! declare_features {
Expand All @@ -14,7 +14,7 @@ macro_rules! declare_features {
state: State::Accepted,
name: sym::$feature,
since: $ver,
issue: $issue,
issue: to_nonzero($issue),
edition: None,
description: concat!($($doc,)*),
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! List of the active feature gates.

use super::{Feature, State};
use super::{to_nonzero, Feature, State};

use rustc_span::edition::Edition;
use rustc_span::symbol::{sym, Symbol};
Expand Down Expand Up @@ -29,7 +29,7 @@ macro_rules! declare_features {
state: State::Active { set: set!($feature) },
name: sym::$feature,
since: $ver,
issue: $issue,
issue: to_nonzero($issue),
edition: $edition,
description: concat!($($doc,)*),
}
Expand Down
23 changes: 13 additions & 10 deletions compiler/rustc_feature/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,11 @@ pub struct Feature {
pub state: State,
pub name: Symbol,
pub since: &'static str,
issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
issue: Option<NonZeroU32>,
pub edition: Option<Edition>,
description: &'static str,
}

impl Feature {
fn issue(&self) -> Option<NonZeroU32> {
self.issue.and_then(NonZeroU32::new)
}
}

#[derive(Copy, Clone, Debug)]
pub enum Stability {
Unstable,
Expand Down Expand Up @@ -102,8 +96,8 @@ impl UnstableFeatures {
fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
if let Some(info) = ACTIVE_FEATURES.iter().find(|t| t.name == feature) {
// FIXME (#28244): enforce that active features have issue numbers
// assert!(info.issue().is_some())
info.issue()
// assert!(info.issue.is_some())
info.issue
} else {
// search in Accepted, Removed, or Stable Removed features
let found = ACCEPTED_FEATURES
Expand All @@ -112,12 +106,21 @@ fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
.chain(STABLE_REMOVED_FEATURES)
.find(|t| t.name == feature);
match found {
Some(found) => found.issue(),
Some(found) => found.issue,
None => panic!("feature `{}` is not declared anywhere", feature),
}
}
}

const fn to_nonzero(n: Option<u32>) -> Option<NonZeroU32> {
// Can be replaced with `n.and_then(NonZeroU32::new)` if that is ever usable
// in const context. Requires https://github.com/rust-lang/rfcs/pull/2632.
match n {
None => None,
Some(n) => NonZeroU32::new(n),
}
}

pub enum GateIssue {
Language,
Library(Option<NonZeroU32>),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! List of the removed feature gates.

use super::{Feature, State};
use super::{to_nonzero, Feature, State};
use rustc_span::symbol::sym;

macro_rules! declare_features {
Expand All @@ -14,7 +14,7 @@ macro_rules! declare_features {
state: State::Removed { reason: $reason },
name: sym::$feature,
since: $ver,
issue: $issue,
issue: to_nonzero($issue),
edition: None,
description: concat!($($doc,)*),
}
Expand All @@ -32,7 +32,7 @@ macro_rules! declare_features {
state: State::Stabilized { reason: None },
name: sym::$feature,
since: $ver,
issue: $issue,
issue: to_nonzero($issue),
edition: None,
description: concat!($($doc,)*),
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mod non_ascii_idents;
mod nonstandard_style;
mod passes;
mod redundant_semicolon;
mod traits;
mod types;
mod unused;

Expand All @@ -75,6 +76,7 @@ use internal::*;
use non_ascii_idents::*;
use nonstandard_style::*;
use redundant_semicolon::*;
use traits::*;
use types::*;
use unused::*;

Expand Down Expand Up @@ -157,6 +159,7 @@ macro_rules! late_lint_passes {
MissingDebugImplementations: MissingDebugImplementations::default(),
ArrayIntoIter: ArrayIntoIter,
ClashingExternDeclarations: ClashingExternDeclarations::new(),
DropTraitConstraints: DropTraitConstraints,
]
);
};
Expand Down
79 changes: 79 additions & 0 deletions compiler/rustc_lint/src/traits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use crate::LateContext;
use crate::LateLintPass;
use crate::LintContext;
use rustc_hir as hir;
use rustc_span::symbol::sym;

declare_lint! {
/// The `drop_bounds` lint checks for generics with `std::ops::Drop` as
/// bounds.
///
/// ### Example
///
/// ```rust
/// fn foo<T: Drop>() {}
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// `Drop` bounds do not really accomplish anything. A type may have
/// compiler-generated drop glue without implementing the `Drop` trait
/// itself. The `Drop` trait also only has one method, `Drop::drop`, and
/// that function is by fiat not callable in user code. So there is really
/// no use case for using `Drop` in trait bounds.
///
/// The most likely use case of a drop bound is to distinguish between
/// types that have destructors and types that don't. Combined with
/// specialization, a naive coder would write an implementation that
/// assumed a type could be trivially dropped, then write a specialization
/// for `T: Drop` that actually calls the destructor. Except that doing so
/// is not correct; String, for example, doesn't actually implement Drop,
/// but because String contains a Vec, assuming it can be trivially dropped
/// will leak memory.
pub DROP_BOUNDS,
Warn,
"bounds of the form `T: Drop` are useless"
}

declare_lint_pass!(
/// Lint for bounds of the form `T: Drop`, which usually
/// indicate an attempt to emulate `std::mem::needs_drop`.
DropTraitConstraints => [DROP_BOUNDS]
);

impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
use rustc_middle::ty::PredicateAtom::*;

let def_id = cx.tcx.hir().local_def_id(item.hir_id);
let predicates = cx.tcx.explicit_predicates_of(def_id);
for &(predicate, span) in predicates.predicates {
let trait_predicate = match predicate.skip_binders() {
Trait(trait_predicate, _constness) => trait_predicate,
_ => continue,
};
let def_id = trait_predicate.trait_ref.def_id;
if cx.tcx.lang_items().drop_trait() == Some(def_id) {
// Explicitly allow `impl Drop`, a drop-guards-as-Voldemort-type pattern.
if trait_predicate.trait_ref.self_ty().is_impl_trait() {
continue;
}
cx.struct_span_lint(DROP_BOUNDS, span, |lint| {
let needs_drop = match cx.tcx.get_diagnostic_item(sym::needs_drop) {
Some(needs_drop) => needs_drop,
None => return,
};
let msg = format!(
"bounds on `{}` are useless, consider instead \
using `{}` to detect if a type has a destructor",
predicate,
cx.tcx.def_path_str(needs_drop)
);
lint.build(&msg).emit()
});
}
}
}
}
1 change: 1 addition & 0 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,7 @@ impl EncodeContext<'a, 'tcx> {
self.encode_const_stability(def_id);
self.encode_deprecation(def_id);
self.encode_item_type(def_id);
self.encode_inherent_implementations(def_id);
if let hir::ForeignItemKind::Fn(..) = nitem.kind {
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
self.encode_variances_of(def_id);
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<K, V> BoxedNode<K, V> {
}

fn from_internal(node: Box<InternalNode<K, V>>) -> Self {
BoxedNode { ptr: Box::into_unique(node).cast() }
BoxedNode { ptr: Unique::from(&mut Box::leak(node).data) }
}

unsafe fn from_ptr(ptr: NonNull<LeafNode<K, V>>) -> Self {
Expand Down
12 changes: 11 additions & 1 deletion library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1901,11 +1901,21 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
/// ```
/// use std::ptr;
///
/// /// # Safety:
/// /// * `ptr` must be correctly aligned for its type and non-zero.
/// /// * `ptr` must be valid for reads of `elts` contiguous objects of type `T`.
/// /// * Those elements must not be used after calling this function unless `T: Copy`.
/// # #[allow(dead_code)]
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: usize) -> Vec<T> {
/// let mut dst = Vec::with_capacity(elts);
/// dst.set_len(elts);
///
/// // SAFETY: Our precondition ensures the source is aligned and valid,
/// // and `Vec::with_capacity` ensures that we have usable space to write them.
/// ptr::copy(ptr, dst.as_mut_ptr(), elts);
///
/// // SAFETY: We created it with this much capacity earlier,
/// // and the previous `copy` has initialized these elements.
/// dst.set_len(elts);
/// dst
/// }
/// ```
Expand Down
1 change: 1 addition & 0 deletions library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ pub unsafe fn align_of_val_raw<T: ?Sized>(val: *const T) -> usize {
#[inline]
#[stable(feature = "needs_drop", since = "1.21.0")]
#[rustc_const_stable(feature = "const_needs_drop", since = "1.36.0")]
#[rustc_diagnostic_item = "needs_drop"]
pub const fn needs_drop<T>() -> bool {
intrinsics::needs_drop::<T>()
}
Expand Down
6 changes: 2 additions & 4 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,6 @@ impl<T> [T] {
/// element of this slice:
///
/// ```
/// #![feature(slice_ptr_range)]
///
/// let a = [1, 2, 3];
/// let x = &a[1] as *const _;
/// let y = &5 as *const _;
Expand All @@ -469,7 +467,7 @@ impl<T> [T] {
/// ```
///
/// [`as_ptr`]: #method.as_ptr
#[unstable(feature = "slice_ptr_range", issue = "65807")]
#[stable(feature = "slice_ptr_range", since = "1.48.0")]
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
#[inline]
pub const fn as_ptr_range(&self) -> Range<*const T> {
Expand Down Expand Up @@ -511,7 +509,7 @@ impl<T> [T] {
/// common in C++.
///
/// [`as_mut_ptr`]: #method.as_mut_ptr
#[unstable(feature = "slice_ptr_range", issue = "65807")]
#[stable(feature = "slice_ptr_range", since = "1.48.0")]
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
#[inline]
pub const fn as_mut_ptr_range(&mut self) -> Range<*mut T> {
Expand Down
7 changes: 3 additions & 4 deletions library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2836,11 +2836,10 @@ impl DefaultHasher {

#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
impl Default for DefaultHasher {
// FIXME: here should link `new` to [DefaultHasher::new], but it occurs intra-doc link
// resolution failure when re-exporting libstd items. When #56922 fixed,
// link `new` to [DefaultHasher::new] again.
/// Creates a new `DefaultHasher` using `new`.
/// Creates a new `DefaultHasher` using [`new`].
/// See its documentation for more.
///
/// [`new`]: DefaultHasher::new
fn default() -> DefaultHasher {
DefaultHasher::new()
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
#![feature(rustc_private)]
#![feature(shrink_to)]
#![feature(slice_concat_ext)]
#![feature(slice_fill)]
#![feature(slice_internals)]
#![feature(slice_ptr_get)]
#![feature(slice_ptr_len)]
Expand Down
Loading