diff --git a/Cargo.lock b/Cargo.lock index fd8d461c54524..4d7b62e9c559f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -345,7 +345,6 @@ dependencies = [ "libgit2-sys", "log", "memchr", - "num_cpus", "opener", "openssl", "os_info", @@ -1503,9 +1502,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.13.23" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700" +checksum = "6e7d3b96ec1fcaa8431cf04a4f1ef5caafe58d5cf7bcc31f09c1626adddb0ffe" dependencies = [ "bitflags", "libc", @@ -1518,9 +1517,9 @@ dependencies = [ [[package]] name = "git2-curl" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883539cb0ea94bab3f8371a98cd8e937bbe9ee7c044499184aa4c17deb643a50" +checksum = "1ee51709364c341fbb6fe2a385a290fb9196753bdde2fc45447d27cd31b11b13" dependencies = [ "curl", "git2", @@ -1975,9 +1974,9 @@ dependencies = [ [[package]] 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" -checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c" +checksum = "43e598aa7a4faedf1ea1b4608f582b06f0f40211eec551b7ef36019ae3f62def" dependencies = [ "cc", "libc", diff --git a/compiler/rustc_infer/src/infer/glb.rs b/compiler/rustc_infer/src/infer/glb.rs index 381097344ec68..e98f33ea86eef 100644 --- a/compiler/rustc_infer/src/infer/glb.rs +++ b/compiler/rustc_infer/src/infer/glb.rs @@ -1,3 +1,5 @@ +//! Greatest lower bound. See [`lattice`]. + use super::combine::CombineFields; use super::lattice::{self, LatticeDir}; use super::InferCtxt; diff --git a/compiler/rustc_infer/src/infer/lattice.rs b/compiler/rustc_infer/src/infer/lattice.rs index c47d476963772..32affd6a14e1c 100644 --- a/compiler/rustc_infer/src/infer/lattice.rs +++ b/compiler/rustc_infer/src/infer/lattice.rs @@ -1,23 +1,21 @@ -//! # Lattice Variables +//! # Lattice variables //! -//! This file contains generic code for operating on inference variables -//! that are characterized by an upper- and lower-bound. The logic and -//! reasoning is explained in detail in the large comment in `infer.rs`. +//! Generic code for operating on [lattices] of inference variables +//! that are characterized by an upper- and lower-bound. //! -//! 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, //! 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 //! operation on the lattice (GLB vs LUB). //! -//! Although all the functions are generic, we generally write the -//! comments in a way that is specific to type variables and the LUB -//! operation. It's just easier that way. +//! ## Note //! -//! In general all of the functions are defined parametrically -//! over a `LatticeValue`, which is a value defined with respect to -//! a lattice. +//! Although all the functions are generic, for simplicity, comments in the source code +//! generally refer to type variables and the LUB operation. +//! +//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order) use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use super::InferCtxt; @@ -27,6 +25,11 @@ use rustc_middle::ty::relate::{RelateResult, TypeRelation}; use rustc_middle::ty::TyVar; 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> { 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, ()>; } +/// Relates two types using a given lattice. pub fn super_lattice_tys<'a, 'tcx: 'a, L>( this: &mut L, a: Ty<'tcx>, diff --git a/compiler/rustc_infer/src/infer/lub.rs b/compiler/rustc_infer/src/infer/lub.rs index 57cbe2c54f7ae..bc85a4ac609a7 100644 --- a/compiler/rustc_infer/src/infer/lub.rs +++ b/compiler/rustc_infer/src/infer/lub.rs @@ -1,3 +1,5 @@ +//! Least upper bound. See [`lattice`]. + use super::combine::CombineFields; use super::lattice::{self, LatticeDir}; use super::InferCtxt; diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 2202001555084..01b12eec628ec 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1345,7 +1345,7 @@ impl CheckAttrVisitor<'_> { target: Target, item: Option>, ) -> bool { - let is_function = matches!(target, Target::Fn | Target::Method(..)); + let is_function = matches!(target, Target::Fn); if !is_function { self.tcx .sess diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs index 5cef007a46f0d..66608d09082d7 100644 --- a/library/alloc/src/collections/btree/map/entry.rs +++ b/library/alloc/src/collections/btree/map/entry.rs @@ -3,7 +3,7 @@ use core::marker::PhantomData; use core::mem; use super::super::borrow::DormantMutRef; -use super::super::node::{marker, Handle, InsertResult::*, NodeRef}; +use super::super::node::{marker, Handle, NodeRef}; use super::BTreeMap; use Entry::*; @@ -313,13 +313,13 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> { #[stable(feature = "rust1", since = "1.0.0")] pub fn insert(self, value: V) -> &'a mut V { 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. let map = unsafe { self.dormant_map.awaken() }; map.length += 1; val_ptr } - (Split(ins), val_ptr) => { + (Some(ins), val_ptr) => { drop(ins.left); // SAFETY: We have consumed self.handle and the reference returned. let map = unsafe { self.dormant_map.awaken() }; diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index dfce98f97bd44..44f5bc850b852 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -861,11 +861,10 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// this edge. This method splits the node if there isn't enough room. /// /// 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>, *mut V) { if self.node.len() < CAPACITY { let val_ptr = self.insert_fit(key, val); - let kv = unsafe { Handle::new_kv(self.node, self.idx) }; - (InsertResult::Fit(kv), val_ptr) + (None, val_ptr) } else { let (middle_kv_idx, insertion) = splitpoint(self.idx); let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) }; @@ -879,7 +878,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark }, }; 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, K, V, marker::Internal>, key: K, val: V, edge: Root, - ) -> InsertResult<'a, K, V, marker::Internal> { + ) -> Option> { assert!(edge.height == self.node.height - 1); if self.node.len() < CAPACITY { self.insert_fit(key, val, edge); - let kv = unsafe { Handle::new_kv(self.node, self.idx) }; - InsertResult::Fit(kv) + None } else { let (middle_kv_idx, insertion) = splitpoint(self.idx); let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) }; @@ -943,7 +941,7 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Internal>, }, }; insertion_edge.insert_fit(key, val, edge); - InsertResult::Split(result) + Some(result) } } } @@ -953,32 +951,26 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Leaf>, mark /// 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. /// - /// 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 a `Split`, the `left` field will be the root node. - /// The returned pointer points to the inserted value. + /// If the returned result is some `SplitResult`, the `left` field will be the root node. + /// The returned pointer points to the inserted value, which in the case of `SplitResult` + /// is in the `left` or `right` tree. pub fn insert_recursing( self, key: K, value: V, - ) -> (InsertResult<'a, K, V, marker::LeafOrInternal>, *mut V) { + ) -> (Option>, *mut V) { let (mut split, val_ptr) = match self.insert(key, value) { - (InsertResult::Fit(handle), ptr) => { - return (InsertResult::Fit(handle.forget_node_type()), ptr); - } - (InsertResult::Split(split), val_ptr) => (split.forget_node_type(), val_ptr), + (None, val_ptr) => return (None, val_ptr), + (Some(split), val_ptr) => (split.forget_node_type(), val_ptr), }; loop { split = match split.left.ascend() { Ok(parent) => match parent.insert(split.kv.0, split.kv.1, split.right) { - InsertResult::Fit(handle) => { - return (InsertResult::Fit(handle.forget_node_type()), val_ptr); - } - InsertResult::Split(split) => split.forget_node_type(), + None => return (None, val_ptr), + Some(split) => split.forget_node_type(), }, - Err(root) => { - return (InsertResult::Split(SplitResult { left: root, ..split }), val_ptr); - } + Err(root) => return (Some(SplitResult { left: root, ..split }), val_ptr), }; } } @@ -1529,14 +1521,6 @@ impl Handle, marker::K } } -impl Handle, marker::KV> { - pub fn forget_node_type( - self, - ) -> Handle, marker::KV> { - unsafe { Handle::new_kv(self.node.forget_type(), self.idx) } - } -} - impl Handle, Type> { /// Checks whether the underlying node is an `Internal` node or a `Leaf` node. pub fn force( @@ -1621,7 +1605,7 @@ pub enum ForceResult { pub struct SplitResult<'a, K, V, NodeType> { // Altered node in existing tree with elements and edges that belong to the left of `kv`. pub left: NodeRef, 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), // Owned, unattached, new node with elements and edges that belong to the right of `kv`. pub right: NodeRef, @@ -1639,11 +1623,6 @@ impl<'a, K, V> SplitResult<'a, K, V, marker::Internal> { } } -pub enum InsertResult<'a, K, V, NodeType> { - Fit(Handle, K, V, NodeType>, marker::KV>), - Split(SplitResult<'a, K, V, NodeType>), -} - pub mod marker { use core::marker::PhantomData; diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index dc288176346bc..6097e62876847 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -224,8 +224,14 @@ where } as usize; if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER { n *= 2; - } else if k >= n { + } else if k > n { 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 { return Ok(f2(&buf[..k])); } diff --git a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs index 3d8478f06db0e..6eabd9b1015b7 100644 --- a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs +++ b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs @@ -29,6 +29,11 @@ extern { #[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have fn foo8() {} +impl S { + #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function + fn foo9() {} +} + #[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute fn bar1() {} diff --git a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr index 1f55a8e72d2cb..bfe7bb2e10dcc 100644 --- a/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr +++ b/src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr @@ -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.) 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] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` 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] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` @@ -66,6 +66,14 @@ LL | #[rustc_legacy_const_generics(0)] LL | fn foo8() {} | - 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() {} + | ---------------------------- not a function + error: attribute should be applied to a function --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5 | @@ -82,6 +90,6 @@ LL | fn foo7(); | = 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`. diff --git a/src/tools/cargo b/src/tools/cargo index 3d6970d50e30e..65c82664263fe 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34 +Subproject commit 65c82664263feddc5fe2d424be0993c28d46377a diff --git a/triagebot.toml b/triagebot.toml index 276587e7f13fb..f6f1b918f061f 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -73,6 +73,13 @@ Thanks! <3 """ 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] label = "I-prioritize"