Skip to content

Commit fca2e94

Browse files
committed
Auto merge of #148356 - matthiaskrgr:rollup-mh4l2yi, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #135602 (Tweak output of missing lifetime on associated type) - #139751 (Implement pin-project in pattern matching for `&pin mut|const T`) - #142682 (Update bundled musl to 1.2.5) - #148171 (Simplify code to generate line numbers in highlight) - #148263 (Unpin `libc` and `rustix` in `compiler` and `rustbook`) - #148301 ([rustdoc search] Include extern crates when filtering on `import`) - #148330 (Don't require dlltool with the dummy backend on MinGW) - #148338 (cleanup: upstream dropped amx-transpose functionality) - #148340 (Clippy subtree update) - #148343 (`nonpoison::Condvar` should take `MutexGuard` by reference) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d85276b + 0ed8002 commit fca2e94

File tree

356 files changed

+7946
-3317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+7946
-3317
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
580580

581581
[[package]]
582582
name = "clippy"
583-
version = "0.1.92"
583+
version = "0.1.93"
584584
dependencies = [
585585
"anstream",
586586
"askama",
@@ -607,7 +607,7 @@ dependencies = [
607607

608608
[[package]]
609609
name = "clippy_config"
610-
version = "0.1.92"
610+
version = "0.1.93"
611611
dependencies = [
612612
"clippy_utils",
613613
"itertools",
@@ -630,7 +630,7 @@ dependencies = [
630630

631631
[[package]]
632632
name = "clippy_lints"
633-
version = "0.1.92"
633+
version = "0.1.93"
634634
dependencies = [
635635
"arrayvec",
636636
"cargo_metadata 0.18.1",
@@ -662,7 +662,7 @@ dependencies = [
662662

663663
[[package]]
664664
name = "clippy_utils"
665-
version = "0.1.92"
665+
version = "0.1.93"
666666
dependencies = [
667667
"arrayvec",
668668
"itertools",
@@ -1066,7 +1066,7 @@ dependencies = [
10661066

10671067
[[package]]
10681068
name = "declare_clippy_lint"
1069-
version = "0.1.92"
1069+
version = "0.1.93"
10701070

10711071
[[package]]
10721072
name = "derive-where"
@@ -1288,7 +1288,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
12881288
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
12891289
dependencies = [
12901290
"libc",
1291-
"windows-sys 0.60.2",
1291+
"windows-sys 0.52.0",
12921292
]
12931293

12941294
[[package]]
@@ -2101,9 +2101,9 @@ checksum = "9fa0e2a1fcbe2f6be6c42e342259976206b383122fc152e872795338b5a3f3a7"
21012101

21022102
[[package]]
21032103
name = "libc"
2104-
version = "0.2.174"
2104+
version = "0.2.177"
21052105
source = "registry+https://github.com/rust-lang/crates.io-index"
2106-
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
2106+
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
21072107

21082108
[[package]]
21092109
name = "libdbus-sys"
@@ -2154,7 +2154,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
21542154
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
21552155
dependencies = [
21562156
"cfg-if",
2157-
"windows-targets 0.53.3",
2157+
"windows-targets 0.52.6",
21582158
]
21592159

21602160
[[package]]
@@ -2216,9 +2216,9 @@ dependencies = [
22162216

22172217
[[package]]
22182218
name = "linux-raw-sys"
2219-
version = "0.9.4"
2219+
version = "0.11.0"
22202220
source = "registry+https://github.com/rust-lang/crates.io-index"
2221-
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
2221+
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
22222222

22232223
[[package]]
22242224
name = "litemap"
@@ -4897,15 +4897,15 @@ dependencies = [
48974897

48984898
[[package]]
48994899
name = "rustix"
4900-
version = "1.0.8"
4900+
version = "1.1.2"
49014901
source = "registry+https://github.com/rust-lang/crates.io-index"
4902-
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
4902+
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
49034903
dependencies = [
49044904
"bitflags",
49054905
"errno",
49064906
"libc",
49074907
"linux-raw-sys",
4908-
"windows-sys 0.60.2",
4908+
"windows-sys 0.52.0",
49094909
]
49104910

49114911
[[package]]

compiler/rustc_ast/src/ast.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,14 +789,14 @@ pub struct PatField {
789789
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
790790
#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
791791
pub enum ByRef {
792-
Yes(Mutability),
792+
Yes(Pinnedness, Mutability),
793793
No,
794794
}
795795

796796
impl ByRef {
797797
#[must_use]
798798
pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self {
799-
if let ByRef::Yes(old_mutbl) = &mut self {
799+
if let ByRef::Yes(_, old_mutbl) = &mut self {
800800
*old_mutbl = cmp::min(*old_mutbl, mutbl);
801801
}
802802
self
@@ -814,20 +814,33 @@ pub struct BindingMode(pub ByRef, pub Mutability);
814814

815815
impl BindingMode {
816816
pub const NONE: Self = Self(ByRef::No, Mutability::Not);
817-
pub const REF: Self = Self(ByRef::Yes(Mutability::Not), Mutability::Not);
817+
pub const REF: Self = Self(ByRef::Yes(Pinnedness::Not, Mutability::Not), Mutability::Not);
818+
pub const REF_PIN: Self =
819+
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Not), Mutability::Not);
818820
pub const MUT: Self = Self(ByRef::No, Mutability::Mut);
819-
pub const REF_MUT: Self = Self(ByRef::Yes(Mutability::Mut), Mutability::Not);
820-
pub const MUT_REF: Self = Self(ByRef::Yes(Mutability::Not), Mutability::Mut);
821-
pub const MUT_REF_MUT: Self = Self(ByRef::Yes(Mutability::Mut), Mutability::Mut);
821+
pub const REF_MUT: Self = Self(ByRef::Yes(Pinnedness::Not, Mutability::Mut), Mutability::Not);
822+
pub const REF_PIN_MUT: Self =
823+
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Mut), Mutability::Not);
824+
pub const MUT_REF: Self = Self(ByRef::Yes(Pinnedness::Not, Mutability::Not), Mutability::Mut);
825+
pub const MUT_REF_PIN: Self =
826+
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Not), Mutability::Mut);
827+
pub const MUT_REF_MUT: Self =
828+
Self(ByRef::Yes(Pinnedness::Not, Mutability::Mut), Mutability::Mut);
829+
pub const MUT_REF_PIN_MUT: Self =
830+
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Mut), Mutability::Mut);
822831

823832
pub fn prefix_str(self) -> &'static str {
824833
match self {
825834
Self::NONE => "",
826835
Self::REF => "ref ",
836+
Self::REF_PIN => "ref pin const ",
827837
Self::MUT => "mut ",
828838
Self::REF_MUT => "ref mut ",
839+
Self::REF_PIN_MUT => "ref pin mut ",
829840
Self::MUT_REF => "mut ref ",
841+
Self::MUT_REF_PIN => "mut ref pin ",
830842
Self::MUT_REF_MUT => "mut ref mut ",
843+
Self::MUT_REF_PIN_MUT => "mut ref pin mut ",
831844
}
832845
}
833846
}

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ macro_rules! common_visitor_and_walkers {
368368
crate::tokenstream::TokenStream,
369369
Movability,
370370
Mutability,
371+
Pinnedness,
371372
Result<(), rustc_span::ErrorGuaranteed>,
372373
rustc_data_structures::fx::FxHashMap<Symbol, usize>,
373374
rustc_span::ErrorGuaranteed,

compiler/rustc_ast_ir/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,10 @@ pub enum Pinnedness {
311311
Not,
312312
Pinned,
313313
}
314+
315+
impl Pinnedness {
316+
/// Return `true` if self is pinned
317+
pub fn is_pinned(self) -> bool {
318+
matches!(self, Self::Pinned)
319+
}
320+
}

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,10 +1712,15 @@ impl<'a> State<'a> {
17121712
if mutbl.is_mut() {
17131713
self.word_nbsp("mut");
17141714
}
1715-
if let ByRef::Yes(rmutbl) = by_ref {
1715+
if let ByRef::Yes(pinnedness, rmutbl) = by_ref {
17161716
self.word_nbsp("ref");
1717+
if pinnedness.is_pinned() {
1718+
self.word_nbsp("pin");
1719+
}
17171720
if rmutbl.is_mut() {
17181721
self.word_nbsp("mut");
1722+
} else if pinnedness.is_pinned() {
1723+
self.word_nbsp("const");
17191724
}
17201725
}
17211726
self.print_ident(*ident);

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub(crate) mod must_use;
4848
pub(crate) mod no_implicit_prelude;
4949
pub(crate) mod non_exhaustive;
5050
pub(crate) mod path;
51+
pub(crate) mod pin_v2;
5152
pub(crate) mod proc_macro_attrs;
5253
pub(crate) mod prototype;
5354
pub(crate) mod repr;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use rustc_hir::Target;
2+
use rustc_hir::attrs::AttributeKind;
3+
use rustc_span::{Span, Symbol, sym};
4+
5+
use crate::attributes::{NoArgsAttributeParser, OnDuplicate};
6+
use crate::context::Stage;
7+
use crate::target_checking::AllowedTargets;
8+
use crate::target_checking::Policy::Allow;
9+
10+
pub(crate) struct PinV2Parser;
11+
12+
impl<S: Stage> NoArgsAttributeParser<S> for PinV2Parser {
13+
const PATH: &[Symbol] = &[sym::pin_v2];
14+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
15+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
16+
Allow(Target::Enum),
17+
Allow(Target::Struct),
18+
Allow(Target::Union),
19+
]);
20+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::PinV2;
21+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use crate::attributes::must_use::MustUseParser;
4747
use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser;
4848
use crate::attributes::non_exhaustive::NonExhaustiveParser;
4949
use crate::attributes::path::PathParser as PathAttributeParser;
50+
use crate::attributes::pin_v2::PinV2Parser;
5051
use crate::attributes::proc_macro_attrs::{
5152
ProcMacroAttributeParser, ProcMacroDeriveParser, ProcMacroParser, RustcBuiltinMacroParser,
5253
};
@@ -233,6 +234,7 @@ attribute_parsers!(
233234
Single<WithoutArgs<NonExhaustiveParser>>,
234235
Single<WithoutArgs<ParenSugarParser>>,
235236
Single<WithoutArgs<PassByValueParser>>,
237+
Single<WithoutArgs<PinV2Parser>>,
236238
Single<WithoutArgs<PointeeParser>>,
237239
Single<WithoutArgs<ProcMacroAttributeParser>>,
238240
Single<WithoutArgs<ProcMacroParser>>,

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11881188
}
11891189

11901190
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
1191-
binding_mode: BindingMode(ByRef::Yes(_), _),
1191+
binding_mode: BindingMode(ByRef::Yes(..), _),
11921192
..
11931193
})) => {
11941194
let pattern_span: Span = local_decl.source_info.span;

compiler/rustc_borrowck/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,6 +2582,16 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
25822582
_ => bug!("Deref of unexpected type: {:?}", base_ty),
25832583
}
25842584
}
2585+
// Check as the inner reference type if it is a field projection
2586+
// from the `&pin` pattern
2587+
ProjectionElem::Field(FieldIdx::ZERO, _)
2588+
if let Some(adt) =
2589+
place_base.ty(self.body(), self.infcx.tcx).ty.ty_adt_def()
2590+
&& adt.is_pin()
2591+
&& self.infcx.tcx.features().pin_ergonomics() =>
2592+
{
2593+
self.is_mutable(place_base, is_local_mutation_allowed)
2594+
}
25852595
// All other projections are owned by their base path, so mutable if
25862596
// base path is mutable
25872597
ProjectionElem::Field(..)

0 commit comments

Comments
 (0)