1
Fork 0

Auto merge of #94761 - Dylan-DPC:rollup-v4emqsy, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #94312 (Edit `rustc_trait_selection::infer::lattice` docs)
 - #94583 (Add a team for '`@rustbot` ping fuchsia')
 - #94686 (Do not allow `#[rustc_legacy_const_generics]` on methods)
 - #94699 (BTree: remove dead data needlessly complicating insert)
 - #94756 (Use `unreachable!` for an unreachable code path)
 - #94759 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-03-09 06:30:19 +00:00
commit 6045c34f15
12 changed files with 77 additions and 65 deletions

View file

@ -345,7 +345,6 @@ dependencies = [
"libgit2-sys", "libgit2-sys",
"log", "log",
"memchr", "memchr",
"num_cpus",
"opener", "opener",
"openssl", "openssl",
"os_info", "os_info",
@ -1503,9 +1502,9 @@ dependencies = [
[[package]] [[package]]
name = "git2" name = "git2"
version = "0.13.23" version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700" checksum = "6e7d3b96ec1fcaa8431cf04a4f1ef5caafe58d5cf7bcc31f09c1626adddb0ffe"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"libc", "libc",
@ -1518,9 +1517,9 @@ dependencies = [
[[package]] [[package]]
name = "git2-curl" name = "git2-curl"
version = "0.14.1" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "883539cb0ea94bab3f8371a98cd8e937bbe9ee7c044499184aa4c17deb643a50" checksum = "1ee51709364c341fbb6fe2a385a290fb9196753bdde2fc45447d27cd31b11b13"
dependencies = [ dependencies = [
"curl", "curl",
"git2", "git2",
@ -1975,9 +1974,9 @@ dependencies = [
[[package]] [[package]]
name = "libgit2-sys" name = "libgit2-sys"
version = "0.12.24+1.3.0" version = "0.13.1+1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c" checksum = "43e598aa7a4faedf1ea1b4608f582b06f0f40211eec551b7ef36019ae3f62def"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",

View file

@ -1,3 +1,5 @@
//! Greatest lower bound. See [`lattice`].
use super::combine::CombineFields; use super::combine::CombineFields;
use super::lattice::{self, LatticeDir}; use super::lattice::{self, LatticeDir};
use super::InferCtxt; use super::InferCtxt;

View file

@ -1,23 +1,21 @@
//! # Lattice Variables //! # Lattice variables
//! //!
//! This file contains generic code for operating on inference variables //! Generic code for operating on [lattices] of inference variables
//! that are characterized by an upper- and lower-bound. The logic and //! that are characterized by an upper- and lower-bound.
//! reasoning is explained in detail in the large comment in `infer.rs`.
//! //!
//! The code in here is defined quite generically so that it can be //! The code is defined quite generically so that it can be
//! applied both to type variables, which represent types being inferred, //! applied both to type variables, which represent types being inferred,
//! and fn variables, which represent function types being inferred. //! and fn variables, which represent function types being inferred.
//! It may eventually be applied to their types as well, who knows. //! (It may eventually be applied to their types as well.)
//! In some cases, the functions are also generic with respect to the //! In some cases, the functions are also generic with respect to the
//! operation on the lattice (GLB vs LUB). //! operation on the lattice (GLB vs LUB).
//! //!
//! Although all the functions are generic, we generally write the //! ## Note
//! comments in a way that is specific to type variables and the LUB
//! operation. It's just easier that way.
//! //!
//! In general all of the functions are defined parametrically //! Although all the functions are generic, for simplicity, comments in the source code
//! over a `LatticeValue`, which is a value defined with respect to //! generally refer to type variables and the LUB operation.
//! a lattice. //!
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use super::InferCtxt; use super::InferCtxt;
@ -27,6 +25,11 @@ use rustc_middle::ty::relate::{RelateResult, TypeRelation};
use rustc_middle::ty::TyVar; use rustc_middle::ty::TyVar;
use rustc_middle::ty::{self, Ty}; use rustc_middle::ty::{self, Ty};
/// Trait for returning data about a lattice, and for abstracting
/// over the "direction" of the lattice operation (LUB/GLB).
///
/// GLB moves "down" the lattice (to smaller values); LUB moves
/// "up" the lattice (to bigger values).
pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> { pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>; fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
@ -41,6 +44,7 @@ pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>; fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>;
} }
/// Relates two types using a given lattice.
pub fn super_lattice_tys<'a, 'tcx: 'a, L>( pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
this: &mut L, this: &mut L,
a: Ty<'tcx>, a: Ty<'tcx>,

View file

@ -1,3 +1,5 @@
//! Least upper bound. See [`lattice`].
use super::combine::CombineFields; use super::combine::CombineFields;
use super::lattice::{self, LatticeDir}; use super::lattice::{self, LatticeDir};
use super::InferCtxt; use super::InferCtxt;

View file

@ -1345,7 +1345,7 @@ impl CheckAttrVisitor<'_> {
target: Target, target: Target,
item: Option<ItemLike<'_>>, item: Option<ItemLike<'_>>,
) -> bool { ) -> bool {
let is_function = matches!(target, Target::Fn | Target::Method(..)); let is_function = matches!(target, Target::Fn);
if !is_function { if !is_function {
self.tcx self.tcx
.sess .sess

View file

@ -3,7 +3,7 @@ use core::marker::PhantomData;
use core::mem; use core::mem;
use super::super::borrow::DormantMutRef; use super::super::borrow::DormantMutRef;
use super::super::node::{marker, Handle, InsertResult::*, NodeRef}; use super::super::node::{marker, Handle, NodeRef};
use super::BTreeMap; use super::BTreeMap;
use Entry::*; use Entry::*;
@ -313,13 +313,13 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn insert(self, value: V) -> &'a mut V { pub fn insert(self, value: V) -> &'a mut V {
let out_ptr = match self.handle.insert_recursing(self.key, value) { let out_ptr = match self.handle.insert_recursing(self.key, value) {
(Fit(_), val_ptr) => { (None, val_ptr) => {
// SAFETY: We have consumed self.handle and the handle returned. // SAFETY: We have consumed self.handle and the handle returned.
let map = unsafe { self.dormant_map.awaken() }; let map = unsafe { self.dormant_map.awaken() };
map.length += 1; map.length += 1;
val_ptr val_ptr
} }
(Split(ins), val_ptr) => { (Some(ins), val_ptr) => {
drop(ins.left); drop(ins.left);
// SAFETY: We have consumed self.handle and the reference returned. // SAFETY: We have consumed self.handle and the reference returned.
let map = unsafe { self.dormant_map.awaken() }; let map = unsafe { self.dormant_map.awaken() };

View file

@ -861,11 +861,10 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
/// this edge. This method splits the node if there isn't enough room. /// this edge. This method splits the node if there isn't enough room.
/// ///
/// The returned pointer points to the inserted value. /// The returned pointer points to the inserted value.
fn insert(mut self, key: K, val: V) -> (InsertResult<'a, K, V, marker::Leaf>, *mut V) { fn insert(mut self, key: K, val: V) -> (Option<SplitResult<'a, K, V, marker::Leaf>>, *mut V) {
if self.node.len() < CAPACITY { if self.node.len() < CAPACITY {
let val_ptr = self.insert_fit(key, val); let val_ptr = self.insert_fit(key, val);
let kv = unsafe { Handle::new_kv(self.node, self.idx) }; (None, val_ptr)
(InsertResult::Fit(kv), val_ptr)
} else { } else {
let (middle_kv_idx, insertion) = splitpoint(self.idx); let (middle_kv_idx, insertion) = splitpoint(self.idx);
let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) }; let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) };
@ -879,7 +878,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
}, },
}; };
let val_ptr = insertion_edge.insert_fit(key, val); let val_ptr = insertion_edge.insert_fit(key, val);
(InsertResult::Split(result), val_ptr) (Some(result), val_ptr)
} }
} }
} }
@ -923,13 +922,12 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
key: K, key: K,
val: V, val: V,
edge: Root<K, V>, edge: Root<K, V>,
) -> InsertResult<'a, K, V, marker::Internal> { ) -> Option<SplitResult<'a, K, V, marker::Internal>> {
assert!(edge.height == self.node.height - 1); assert!(edge.height == self.node.height - 1);
if self.node.len() < CAPACITY { if self.node.len() < CAPACITY {
self.insert_fit(key, val, edge); self.insert_fit(key, val, edge);
let kv = unsafe { Handle::new_kv(self.node, self.idx) }; None
InsertResult::Fit(kv)
} else { } else {
let (middle_kv_idx, insertion) = splitpoint(self.idx); let (middle_kv_idx, insertion) = splitpoint(self.idx);
let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) }; let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) };
@ -943,7 +941,7 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
}, },
}; };
insertion_edge.insert_fit(key, val, edge); insertion_edge.insert_fit(key, val, edge);
InsertResult::Split(result) Some(result)
} }
} }
} }
@ -953,32 +951,26 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
/// this edge. This method splits the node if there isn't enough room, and tries to /// this edge. This method splits the node if there isn't enough room, and tries to
/// insert the split off portion into the parent node recursively, until the root is reached. /// insert the split off portion into the parent node recursively, until the root is reached.
/// ///
/// If the returned result is a `Fit`, its handle's node can be this edge's node or an ancestor. /// If the returned result is some `SplitResult`, the `left` field will be the root node.
/// If the returned result is a `Split`, the `left` field will be the root node. /// The returned pointer points to the inserted value, which in the case of `SplitResult`
/// The returned pointer points to the inserted value. /// is in the `left` or `right` tree.
pub fn insert_recursing( pub fn insert_recursing(
self, self,
key: K, key: K,
value: V, value: V,
) -> (InsertResult<'a, K, V, marker::LeafOrInternal>, *mut V) { ) -> (Option<SplitResult<'a, K, V, marker::LeafOrInternal>>, *mut V) {
let (mut split, val_ptr) = match self.insert(key, value) { let (mut split, val_ptr) = match self.insert(key, value) {
(InsertResult::Fit(handle), ptr) => { (None, val_ptr) => return (None, val_ptr),
return (InsertResult::Fit(handle.forget_node_type()), ptr); (Some(split), val_ptr) => (split.forget_node_type(), val_ptr),
}
(InsertResult::Split(split), val_ptr) => (split.forget_node_type(), val_ptr),
}; };
loop { loop {
split = match split.left.ascend() { split = match split.left.ascend() {
Ok(parent) => match parent.insert(split.kv.0, split.kv.1, split.right) { Ok(parent) => match parent.insert(split.kv.0, split.kv.1, split.right) {
InsertResult::Fit(handle) => { None => return (None, val_ptr),
return (InsertResult::Fit(handle.forget_node_type()), val_ptr); Some(split) => split.forget_node_type(),
}
InsertResult::Split(split) => split.forget_node_type(),
}, },
Err(root) => { Err(root) => return (Some(SplitResult { left: root, ..split }), val_ptr),
return (InsertResult::Split(SplitResult { left: root, ..split }), val_ptr);
}
}; };
} }
} }
@ -1529,14 +1521,6 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::K
} }
} }
impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Internal>, marker::KV> {
pub fn forget_node_type(
self,
) -> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, marker::KV> {
unsafe { Handle::new_kv(self.node.forget_type(), self.idx) }
}
}
impl<BorrowType, K, V, Type> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, Type> { impl<BorrowType, K, V, Type> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, Type> {
/// Checks whether the underlying node is an `Internal` node or a `Leaf` node. /// Checks whether the underlying node is an `Internal` node or a `Leaf` node.
pub fn force( pub fn force(
@ -1621,7 +1605,7 @@ pub enum ForceResult<Leaf, Internal> {
pub struct SplitResult<'a, K, V, NodeType> { pub struct SplitResult<'a, K, V, NodeType> {
// Altered node in existing tree with elements and edges that belong to the left of `kv`. // Altered node in existing tree with elements and edges that belong to the left of `kv`.
pub left: NodeRef<marker::Mut<'a>, K, V, NodeType>, pub left: NodeRef<marker::Mut<'a>, K, V, NodeType>,
// Some key and value split off, to be inserted elsewhere. // Some key and value that existed before and were split off, to be inserted elsewhere.
pub kv: (K, V), pub kv: (K, V),
// Owned, unattached, new node with elements and edges that belong to the right of `kv`. // Owned, unattached, new node with elements and edges that belong to the right of `kv`.
pub right: NodeRef<marker::Owned, K, V, NodeType>, pub right: NodeRef<marker::Owned, K, V, NodeType>,
@ -1639,11 +1623,6 @@ impl<'a, K, V> SplitResult<'a, K, V, marker::Internal> {
} }
} }
pub enum InsertResult<'a, K, V, NodeType> {
Fit(Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, marker::KV>),
Split(SplitResult<'a, K, V, NodeType>),
}
pub mod marker { pub mod marker {
use core::marker::PhantomData; use core::marker::PhantomData;

View file

@ -224,8 +224,14 @@ where
} as usize; } as usize;
if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER { if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
n *= 2; n *= 2;
} else if k >= n { } else if k > n {
n = k; n = k;
} else if k == n {
// It is impossible to reach this point.
// On success, k is the returned string length excluding the null.
// On failure, k is the required buffer length including the null.
// Therefore k never equals n.
unreachable!();
} else { } else {
return Ok(f2(&buf[..k])); return Ok(f2(&buf[..k]));
} }

View file

@ -29,6 +29,11 @@ extern {
#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have #[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have
fn foo8<X>() {} fn foo8<X>() {}
impl S {
#[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function
fn foo9<const X: usize>() {}
}
#[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute #[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute
fn bar1() {} fn bar1() {}

View file

@ -7,13 +7,13 @@ LL | #[rustc_legacy_const_generics(0usize)]
= help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
error: malformed `rustc_legacy_const_generics` attribute input error: malformed `rustc_legacy_const_generics` attribute input
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:32:1 --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:37:1
| |
LL | #[rustc_legacy_const_generics] LL | #[rustc_legacy_const_generics]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
error: malformed `rustc_legacy_const_generics` attribute input error: malformed `rustc_legacy_const_generics` attribute input
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:35:1 --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:40:1
| |
LL | #[rustc_legacy_const_generics = 1] LL | #[rustc_legacy_const_generics = 1]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
@ -66,6 +66,14 @@ LL | #[rustc_legacy_const_generics(0)]
LL | fn foo8<X>() {} LL | fn foo8<X>() {}
| - non-const generic parameter | - non-const generic parameter
error: attribute should be applied to a function
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:33:5
|
LL | #[rustc_legacy_const_generics(0)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn foo9<const X: usize>() {}
| ---------------------------- not a function
error: attribute should be applied to a function error: attribute should be applied to a function
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5 --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5
| |
@ -82,6 +90,6 @@ LL | fn foo7<const X: usize>();
| |
= help: replace the const parameters with concrete consts = help: replace the const parameters with concrete consts
error: aborting due to 12 previous errors error: aborting due to 13 previous errors
For more information about this error, try `rustc --explain E0044`. For more information about this error, try `rustc --explain E0044`.

@ -1 +1 @@
Subproject commit 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34 Subproject commit 65c82664263feddc5fe2d424be0993c28d46377a

View file

@ -73,6 +73,13 @@ Thanks! <3
""" """
label = "O-riscv" label = "O-riscv"
[ping.fuchsia]
message = """\
Hey friends of Fuchsia! This issue could use some guidance on how this should be
resolved/implemented on Fuchsia. Could one of you weigh in?
"""
label = "O-fuchsia"
[prioritize] [prioritize]
label = "I-prioritize" label = "I-prioritize"