Skip to content

Commit ec38671

Browse files
committed
Auto merge of #146797 - matthiaskrgr:rollup-xy0g8n7, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #146690 (add `[const] PartialEq` bound to `PartialOrd`) - #146776 (fixes for numerous clippy warnings) - #146777 (fix ./x readdir logic when CDPATH is set) - #146781 (mbe: Fix feature gate for `macro_derive`) - #146785 (btree: safety comments for init and new) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0be8e16 + 6f9e6c9 commit ec38671

File tree

7 files changed

+37
-34
lines changed

7 files changed

+37
-34
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ pub fn compile_declarative_macro(
702702
kinds |= MacroKinds::DERIVE;
703703
let derive_keyword_span = p.prev_token.span;
704704
if !features.macro_derive() {
705-
feature_err(sess, sym::macro_attr, span, "`macro_rules!` derives are unstable")
705+
feature_err(sess, sym::macro_derive, span, "`macro_rules!` derives are unstable")
706706
.emit();
707707
}
708708
if let Some(guar) = check_no_eof(sess, &p, "expected `()` after `derive`") {

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21942194
fn suggest_associated_call_syntax(
21952195
&self,
21962196
err: &mut Diag<'_>,
2197-
static_candidates: &Vec<CandidateSource>,
2197+
static_candidates: &[CandidateSource],
21982198
rcvr_ty: Ty<'tcx>,
21992199
source: SelfSource<'tcx>,
22002200
item_name: Ident,
@@ -2422,7 +2422,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24222422

24232423
let span_included = match parent_expr.kind {
24242424
hir::ExprKind::Struct(_, eps, _) => {
2425-
eps.len() > 0 && eps.last().is_some_and(|ep| ep.span.contains(span))
2425+
eps.last().is_some_and(|ep| ep.span.contains(span))
24262426
}
24272427
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
24282428
hir::ExprKind::Call(func, ..) => func.span.contains(span),
@@ -2484,7 +2484,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24842484
simplify_type(tcx, ty, TreatParams::InstantiateWithInfer)
24852485
.and_then(|simp| {
24862486
tcx.incoherent_impls(simp)
2487-
.into_iter()
2487+
.iter()
24882488
.find_map(|&id| self.associated_value(id, item_name))
24892489
})
24902490
.is_some()
@@ -2617,7 +2617,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26172617

26182618
if let Node::Expr(call_expr) = self.tcx.parent_hir_node(seg1.hir_id)
26192619
&& let ControlFlow::Break(Some(expr)) =
2620-
(LetVisitor { ident_name: seg1.ident.name }).visit_body(&body)
2620+
(LetVisitor { ident_name: seg1.ident.name }).visit_body(body)
26212621
&& let Some(self_ty) = self.node_ty_opt(expr.hir_id)
26222622
{
26232623
let probe = self.lookup_probe_for_diagnostic(
@@ -2960,14 +2960,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29602960
.collect::<Vec<_>>()
29612961
.into();
29622962
for pred in &local_preds {
2963-
match pred.self_ty().kind() {
2964-
ty::Adt(def, _) => {
2965-
local_spans.push_span_label(
2966-
self.tcx.def_span(def.did()),
2967-
format!("must implement `{}`", pred.trait_ref.print_trait_sugared()),
2968-
);
2969-
}
2970-
_ => {}
2963+
if let ty::Adt(def, _) = pred.self_ty().kind() {
2964+
local_spans.push_span_label(
2965+
self.tcx.def_span(def.did()),
2966+
format!("must implement `{}`", pred.trait_ref.print_trait_sugared()),
2967+
);
29712968
}
29722969
}
29732970
if local_spans.primary_span().is_some() {
@@ -3006,14 +3003,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
30063003
.collect::<Vec<_>>()
30073004
.into();
30083005
for pred in &foreign_preds {
3009-
match pred.self_ty().kind() {
3010-
ty::Adt(def, _) => {
3011-
foreign_spans.push_span_label(
3012-
self.tcx.def_span(def.did()),
3013-
format!("not implement `{}`", pred.trait_ref.print_trait_sugared()),
3014-
);
3015-
}
3016-
_ => {}
3006+
if let ty::Adt(def, _) = pred.self_ty().kind() {
3007+
foreign_spans.push_span_label(
3008+
self.tcx.def_span(def.did()),
3009+
format!("not implement `{}`", pred.trait_ref.print_trait_sugared()),
3010+
);
30173011
}
30183012
}
30193013
if foreign_spans.primary_span().is_some() {
@@ -3595,7 +3589,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35953589
// would take care of them.
35963590
&& !skippable.contains(&Some(pick.item.container_id(self.tcx)))
35973591
// Do not suggest pinning when the method is directly on `Pin`.
3598-
&& pick.item.impl_container(self.tcx).map_or(true, |did| {
3592+
&& pick.item.impl_container(self.tcx).is_none_or(|did| {
35993593
match self.tcx.type_of(did).skip_binder().kind() {
36003594
ty::Adt(def, _) => Some(def.did()) != self.tcx.lang_items().pin_type(),
36013595
_ => true,
@@ -3653,7 +3647,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
36533647
vec![
36543648
(
36553649
rcvr.span.shrink_to_lo(),
3656-
format!("let mut pinned = std::pin::pin!("),
3650+
"let mut pinned = std::pin::pin!(".to_string(),
36573651
),
36583652
(
36593653
rcvr.span.shrink_to_hi(),
@@ -4128,7 +4122,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41284122
);
41294123
let trait_span = self.tcx.def_span(trait_def_id);
41304124
let mut multi_span: MultiSpan = trait_span.into();
4131-
multi_span.push_span_label(trait_span, format!("this is the trait that is needed"));
4125+
multi_span.push_span_label(trait_span, "this is the trait that is needed".to_string());
41324126
let descr = self.tcx.associated_item(item_def_id).descr();
41334127
let rcvr_ty =
41344128
rcvr_ty.map(|t| format!("`{t}`")).unwrap_or_else(|| "the receiver".to_string());
@@ -4146,7 +4140,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41464140
}
41474141
multi_span.push_span_label(
41484142
self.tcx.def_span(def_id),
4149-
format!("this is the trait that was imported"),
4143+
"this is the trait that was imported".to_string(),
41504144
);
41514145
}
41524146
err.span_note(multi_span, msg);

compiler/rustc_hir_typeck/src/op.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
566566
rhs_ty,
567567
lhs_expr,
568568
lhs_ty,
569-
|lhs_ty, rhs_ty| is_compatible_after_call(lhs_ty, rhs_ty),
569+
is_compatible_after_call,
570570
) {
571571
// Cool
572572
}
@@ -1170,8 +1170,8 @@ fn deref_ty_if_possible(ty: Ty<'_>) -> Ty<'_> {
11701170
}
11711171
}
11721172

1173-
/// Returns `true` if this is a built-in arithmetic operation (e.g., u32
1174-
/// + u32, i16x4 == i16x4) and false if these types would have to be
1173+
/// Returns `true` if this is a built-in arithmetic operation (e.g.,
1174+
/// u32 + u32, i16x4 == i16x4) and false if these types would have to be
11751175
/// overloaded to be legal. There are two reasons that we distinguish
11761176
/// builtin operations from overloaded ones (vs trying to drive
11771177
/// everything uniformly through the trait system and intrinsics or
@@ -1191,7 +1191,7 @@ fn is_builtin_binop<'tcx>(lhs: Ty<'tcx>, rhs: Ty<'tcx>, category: BinOpCategory)
11911191
// (See https://github.com/rust-lang/rust/issues/57447.)
11921192
let (lhs, rhs) = (deref_ty_if_possible(lhs), deref_ty_if_possible(rhs));
11931193

1194-
match category.into() {
1194+
match category {
11951195
BinOpCategory::Shortcircuit => true,
11961196
BinOpCategory::Shift => {
11971197
lhs.references_error()

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ struct LeafNode<K, V> {
6767

6868
impl<K, V> LeafNode<K, V> {
6969
/// Initializes a new `LeafNode` in-place.
70+
///
71+
/// # Safety
72+
///
73+
/// The caller must ensure that `this` points to a (possibly uninitialized) `LeafNode`
7074
unsafe fn init(this: *mut Self) {
7175
// As a general policy, we leave fields uninitialized if they can be, as this should
7276
// be both slightly faster and easier to track in Valgrind.
@@ -79,9 +83,11 @@ impl<K, V> LeafNode<K, V> {
7983

8084
/// Creates a new boxed `LeafNode`.
8185
fn new<A: Allocator + Clone>(alloc: A) -> Box<Self, A> {
86+
let mut leaf = Box::new_uninit_in(alloc);
8287
unsafe {
83-
let mut leaf = Box::new_uninit_in(alloc);
88+
// SAFETY: `leaf` points to a `LeafNode`
8489
LeafNode::init(leaf.as_mut_ptr());
90+
// SAFETY: `leaf` was just initialized
8591
leaf.assume_init()
8692
}
8793
}

library/core/src/cmp.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,9 @@ pub macro Ord($item:item) {
13511351
#[rustc_diagnostic_item = "PartialOrd"]
13521352
#[allow(multiple_supertrait_upcastable)] // FIXME(sized_hierarchy): remove this
13531353
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1354-
pub const trait PartialOrd<Rhs: PointeeSized = Self>: PartialEq<Rhs> + PointeeSized {
1354+
pub const trait PartialOrd<Rhs: PointeeSized = Self>:
1355+
[const] PartialEq<Rhs> + PointeeSized
1356+
{
13551357
/// This method returns an ordering between `self` and `other` values if one exists.
13561358
///
13571359
/// # Examples

tests/ui/feature-gates/feature-gate-macro-derive.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0658]: `macro_rules!` derives are unstable
44
LL | macro_rules! MyDerive { derive() {} => {} }
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
8-
= help: add `#![feature(macro_attr)]` to the crate attributes to enable
7+
= note: see issue #143549 <https://github.com/rust-lang/rust/issues/143549> for more information
8+
= help: add `#![feature(macro_derive)]` to the crate attributes to enable
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error: aborting due to 1 previous error

x

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ realpath() {
1515
if [ -L "$path" ]; then
1616
readlink -f "$path"
1717
elif [ -d "$path" ]; then
18-
(cd -P "$path" && pwd)
18+
# "cd" is not always silent (e.g. when CDPATH is set), so discard its output.
19+
(cd -P "$path" >/dev/null && pwd)
1920
else
2021
echo "$(realpath "$(dirname "$path")")/$(basename "$path")"
2122
fi

0 commit comments

Comments
 (0)