Skip to content

Commit 6045c34

Browse files
committed
Auto merge of rust-lang#94761 - Dylan-DPC:rollup-v4emqsy, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#94312 (Edit `rustc_trait_selection::infer::lattice` docs) - rust-lang#94583 (Add a team for '`@rustbot` ping fuchsia') - rust-lang#94686 (Do not allow `#[rustc_legacy_const_generics]` on methods) - rust-lang#94699 (BTree: remove dead data needlessly complicating insert) - rust-lang#94756 (Use `unreachable!` for an unreachable code path) - rust-lang#94759 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 163c207 + 822c4b6 commit 6045c34

File tree

12 files changed

+77
-65
lines changed

12 files changed

+77
-65
lines changed

Cargo.lock

+6-7
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ dependencies = [
345345
"libgit2-sys",
346346
"log",
347347
"memchr",
348-
"num_cpus",
349348
"opener",
350349
"openssl",
351350
"os_info",
@@ -1503,9 +1502,9 @@ dependencies = [
15031502

15041503
[[package]]
15051504
name = "git2"
1506-
version = "0.13.23"
1505+
version = "0.14.1"
15071506
source = "registry+https://github.com/rust-lang/crates.io-index"
1508-
checksum = "2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700"
1507+
checksum = "6e7d3b96ec1fcaa8431cf04a4f1ef5caafe58d5cf7bcc31f09c1626adddb0ffe"
15091508
dependencies = [
15101509
"bitflags",
15111510
"libc",
@@ -1518,9 +1517,9 @@ dependencies = [
15181517

15191518
[[package]]
15201519
name = "git2-curl"
1521-
version = "0.14.1"
1520+
version = "0.15.0"
15221521
source = "registry+https://github.com/rust-lang/crates.io-index"
1523-
checksum = "883539cb0ea94bab3f8371a98cd8e937bbe9ee7c044499184aa4c17deb643a50"
1522+
checksum = "1ee51709364c341fbb6fe2a385a290fb9196753bdde2fc45447d27cd31b11b13"
15241523
dependencies = [
15251524
"curl",
15261525
"git2",
@@ -1975,9 +1974,9 @@ dependencies = [
19751974

19761975
[[package]]
19771976
name = "libgit2-sys"
1978-
version = "0.12.24+1.3.0"
1977+
version = "0.13.1+1.4.2"
19791978
source = "registry+https://github.com/rust-lang/crates.io-index"
1980-
checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c"
1979+
checksum = "43e598aa7a4faedf1ea1b4608f582b06f0f40211eec551b7ef36019ae3f62def"
19811980
dependencies = [
19821981
"cc",
19831982
"libc",

compiler/rustc_infer/src/infer/glb.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Greatest lower bound. See [`lattice`].
2+
13
use super::combine::CombineFields;
24
use super::lattice::{self, LatticeDir};
35
use super::InferCtxt;

compiler/rustc_infer/src/infer/lattice.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
//! # Lattice Variables
1+
//! # Lattice variables
22
//!
3-
//! This file contains generic code for operating on inference variables
4-
//! that are characterized by an upper- and lower-bound. The logic and
5-
//! reasoning is explained in detail in the large comment in `infer.rs`.
3+
//! Generic code for operating on [lattices] of inference variables
4+
//! that are characterized by an upper- and lower-bound.
65
//!
7-
//! The code in here is defined quite generically so that it can be
6+
//! The code is defined quite generically so that it can be
87
//! applied both to type variables, which represent types being inferred,
98
//! and fn variables, which represent function types being inferred.
10-
//! It may eventually be applied to their types as well, who knows.
9+
//! (It may eventually be applied to their types as well.)
1110
//! In some cases, the functions are also generic with respect to the
1211
//! operation on the lattice (GLB vs LUB).
1312
//!
14-
//! Although all the functions are generic, we generally write the
15-
//! comments in a way that is specific to type variables and the LUB
16-
//! operation. It's just easier that way.
13+
//! ## Note
1714
//!
18-
//! In general all of the functions are defined parametrically
19-
//! over a `LatticeValue`, which is a value defined with respect to
20-
//! a lattice.
15+
//! Although all the functions are generic, for simplicity, comments in the source code
16+
//! generally refer to type variables and the LUB operation.
17+
//!
18+
//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
2119
2220
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
2321
use super::InferCtxt;
@@ -27,6 +25,11 @@ use rustc_middle::ty::relate::{RelateResult, TypeRelation};
2725
use rustc_middle::ty::TyVar;
2826
use rustc_middle::ty::{self, Ty};
2927

28+
/// Trait for returning data about a lattice, and for abstracting
29+
/// over the "direction" of the lattice operation (LUB/GLB).
30+
///
31+
/// GLB moves "down" the lattice (to smaller values); LUB moves
32+
/// "up" the lattice (to bigger values).
3033
pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
3134
fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>;
3235

@@ -41,6 +44,7 @@ pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
4144
fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>;
4245
}
4346

47+
/// Relates two types using a given lattice.
4448
pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
4549
this: &mut L,
4650
a: Ty<'tcx>,

compiler/rustc_infer/src/infer/lub.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Least upper bound. See [`lattice`].
2+
13
use super::combine::CombineFields;
24
use super::lattice::{self, LatticeDir};
35
use super::InferCtxt;

compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ impl CheckAttrVisitor<'_> {
13451345
target: Target,
13461346
item: Option<ItemLike<'_>>,
13471347
) -> bool {
1348-
let is_function = matches!(target, Target::Fn | Target::Method(..));
1348+
let is_function = matches!(target, Target::Fn);
13491349
if !is_function {
13501350
self.tcx
13511351
.sess

library/alloc/src/collections/btree/map/entry.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::marker::PhantomData;
33
use core::mem;
44

55
use super::super::borrow::DormantMutRef;
6-
use super::super::node::{marker, Handle, InsertResult::*, NodeRef};
6+
use super::super::node::{marker, Handle, NodeRef};
77
use super::BTreeMap;
88

99
use Entry::*;
@@ -313,13 +313,13 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
313313
#[stable(feature = "rust1", since = "1.0.0")]
314314
pub fn insert(self, value: V) -> &'a mut V {
315315
let out_ptr = match self.handle.insert_recursing(self.key, value) {
316-
(Fit(_), val_ptr) => {
316+
(None, val_ptr) => {
317317
// SAFETY: We have consumed self.handle and the handle returned.
318318
let map = unsafe { self.dormant_map.awaken() };
319319
map.length += 1;
320320
val_ptr
321321
}
322-
(Split(ins), val_ptr) => {
322+
(Some(ins), val_ptr) => {
323323
drop(ins.left);
324324
// SAFETY: We have consumed self.handle and the reference returned.
325325
let map = unsafe { self.dormant_map.awaken() };

library/alloc/src/collections/btree/node.rs

+16-37
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,10 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
861861
/// this edge. This method splits the node if there isn't enough room.
862862
///
863863
/// The returned pointer points to the inserted value.
864-
fn insert(mut self, key: K, val: V) -> (InsertResult<'a, K, V, marker::Leaf>, *mut V) {
864+
fn insert(mut self, key: K, val: V) -> (Option<SplitResult<'a, K, V, marker::Leaf>>, *mut V) {
865865
if self.node.len() < CAPACITY {
866866
let val_ptr = self.insert_fit(key, val);
867-
let kv = unsafe { Handle::new_kv(self.node, self.idx) };
868-
(InsertResult::Fit(kv), val_ptr)
867+
(None, val_ptr)
869868
} else {
870869
let (middle_kv_idx, insertion) = splitpoint(self.idx);
871870
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
879878
},
880879
};
881880
let val_ptr = insertion_edge.insert_fit(key, val);
882-
(InsertResult::Split(result), val_ptr)
881+
(Some(result), val_ptr)
883882
}
884883
}
885884
}
@@ -923,13 +922,12 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
923922
key: K,
924923
val: V,
925924
edge: Root<K, V>,
926-
) -> InsertResult<'a, K, V, marker::Internal> {
925+
) -> Option<SplitResult<'a, K, V, marker::Internal>> {
927926
assert!(edge.height == self.node.height - 1);
928927

929928
if self.node.len() < CAPACITY {
930929
self.insert_fit(key, val, edge);
931-
let kv = unsafe { Handle::new_kv(self.node, self.idx) };
932-
InsertResult::Fit(kv)
930+
None
933931
} else {
934932
let (middle_kv_idx, insertion) = splitpoint(self.idx);
935933
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>,
943941
},
944942
};
945943
insertion_edge.insert_fit(key, val, edge);
946-
InsertResult::Split(result)
944+
Some(result)
947945
}
948946
}
949947
}
@@ -953,32 +951,26 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
953951
/// this edge. This method splits the node if there isn't enough room, and tries to
954952
/// insert the split off portion into the parent node recursively, until the root is reached.
955953
///
956-
/// If the returned result is a `Fit`, its handle's node can be this edge's node or an ancestor.
957-
/// If the returned result is a `Split`, the `left` field will be the root node.
958-
/// The returned pointer points to the inserted value.
954+
/// If the returned result is some `SplitResult`, the `left` field will be the root node.
955+
/// The returned pointer points to the inserted value, which in the case of `SplitResult`
956+
/// is in the `left` or `right` tree.
959957
pub fn insert_recursing(
960958
self,
961959
key: K,
962960
value: V,
963-
) -> (InsertResult<'a, K, V, marker::LeafOrInternal>, *mut V) {
961+
) -> (Option<SplitResult<'a, K, V, marker::LeafOrInternal>>, *mut V) {
964962
let (mut split, val_ptr) = match self.insert(key, value) {
965-
(InsertResult::Fit(handle), ptr) => {
966-
return (InsertResult::Fit(handle.forget_node_type()), ptr);
967-
}
968-
(InsertResult::Split(split), val_ptr) => (split.forget_node_type(), val_ptr),
963+
(None, val_ptr) => return (None, val_ptr),
964+
(Some(split), val_ptr) => (split.forget_node_type(), val_ptr),
969965
};
970966

971967
loop {
972968
split = match split.left.ascend() {
973969
Ok(parent) => match parent.insert(split.kv.0, split.kv.1, split.right) {
974-
InsertResult::Fit(handle) => {
975-
return (InsertResult::Fit(handle.forget_node_type()), val_ptr);
976-
}
977-
InsertResult::Split(split) => split.forget_node_type(),
970+
None => return (None, val_ptr),
971+
Some(split) => split.forget_node_type(),
978972
},
979-
Err(root) => {
980-
return (InsertResult::Split(SplitResult { left: root, ..split }), val_ptr);
981-
}
973+
Err(root) => return (Some(SplitResult { left: root, ..split }), val_ptr),
982974
};
983975
}
984976
}
@@ -1529,14 +1521,6 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::K
15291521
}
15301522
}
15311523

1532-
impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Internal>, marker::KV> {
1533-
pub fn forget_node_type(
1534-
self,
1535-
) -> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, marker::KV> {
1536-
unsafe { Handle::new_kv(self.node.forget_type(), self.idx) }
1537-
}
1538-
}
1539-
15401524
impl<BorrowType, K, V, Type> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, Type> {
15411525
/// Checks whether the underlying node is an `Internal` node or a `Leaf` node.
15421526
pub fn force(
@@ -1621,7 +1605,7 @@ pub enum ForceResult<Leaf, Internal> {
16211605
pub struct SplitResult<'a, K, V, NodeType> {
16221606
// Altered node in existing tree with elements and edges that belong to the left of `kv`.
16231607
pub left: NodeRef<marker::Mut<'a>, K, V, NodeType>,
1624-
// Some key and value split off, to be inserted elsewhere.
1608+
// Some key and value that existed before and were split off, to be inserted elsewhere.
16251609
pub kv: (K, V),
16261610
// Owned, unattached, new node with elements and edges that belong to the right of `kv`.
16271611
pub right: NodeRef<marker::Owned, K, V, NodeType>,
@@ -1639,11 +1623,6 @@ impl<'a, K, V> SplitResult<'a, K, V, marker::Internal> {
16391623
}
16401624
}
16411625

1642-
pub enum InsertResult<'a, K, V, NodeType> {
1643-
Fit(Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, marker::KV>),
1644-
Split(SplitResult<'a, K, V, NodeType>),
1645-
}
1646-
16471626
pub mod marker {
16481627
use core::marker::PhantomData;
16491628

library/std/src/sys/windows/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,14 @@ where
224224
} as usize;
225225
if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
226226
n *= 2;
227-
} else if k >= n {
227+
} else if k > n {
228228
n = k;
229+
} else if k == n {
230+
// It is impossible to reach this point.
231+
// On success, k is the returned string length excluding the null.
232+
// On failure, k is the required buffer length including the null.
233+
// Therefore k never equals n.
234+
unreachable!();
229235
} else {
230236
return Ok(f2(&buf[..k]));
231237
}

src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ extern {
2929
#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have
3030
fn foo8<X>() {}
3131

32+
impl S {
33+
#[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function
34+
fn foo9<const X: usize>() {}
35+
}
36+
3237
#[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute
3338
fn bar1() {}
3439

src/test/ui/invalid/invalid-rustc_legacy_const_generics-arguments.stderr

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ LL | #[rustc_legacy_const_generics(0usize)]
77
= help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
88

99
error: malformed `rustc_legacy_const_generics` attribute input
10-
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:32:1
10+
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:37:1
1111
|
1212
LL | #[rustc_legacy_const_generics]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
1414

1515
error: malformed `rustc_legacy_const_generics` attribute input
16-
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:35:1
16+
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:40:1
1717
|
1818
LL | #[rustc_legacy_const_generics = 1]
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
@@ -66,6 +66,14 @@ LL | #[rustc_legacy_const_generics(0)]
6666
LL | fn foo8<X>() {}
6767
| - non-const generic parameter
6868

69+
error: attribute should be applied to a function
70+
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:33:5
71+
|
72+
LL | #[rustc_legacy_const_generics(0)]
73+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74+
LL | fn foo9<const X: usize>() {}
75+
| ---------------------------- not a function
76+
6977
error: attribute should be applied to a function
7078
--> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5
7179
|
@@ -82,6 +90,6 @@ LL | fn foo7<const X: usize>();
8290
|
8391
= help: replace the const parameters with concrete consts
8492

85-
error: aborting due to 12 previous errors
93+
error: aborting due to 13 previous errors
8694

8795
For more information about this error, try `rustc --explain E0044`.

triagebot.toml

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ Thanks! <3
7373
"""
7474
label = "O-riscv"
7575

76+
[ping.fuchsia]
77+
message = """\
78+
Hey friends of Fuchsia! This issue could use some guidance on how this should be
79+
resolved/implemented on Fuchsia. Could one of you weigh in?
80+
"""
81+
label = "O-fuchsia"
82+
7683
[prioritize]
7784
label = "I-prioritize"
7885

0 commit comments

Comments
 (0)