Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
c1de8ed
`incompatible_msrv`: Don't check the const version for functions refe…
Jarcho Sep 30, 2025
13ee69d
Update bundled musl to 1.2.5
est31 May 29, 2024
a014a9b
update all other references to musl 1.2.3 to 1.2.5
Gankra Jun 18, 2025
52513ab
bump powerpc64le-unknown-linux-musl's musl to 1.2.5
Gankra Oct 2, 2025
d860954
Remove boxes from ast Pat lists
camsteffen Sep 4, 2025
303a828
pin all musl deconfigs to 1.2.5
Gankra Oct 7, 2025
22e6656
remove references to upstreamed patches
Gankra Oct 7, 2025
b64cdd0
bump musl-cross-make commit to get fixes
Gankra Oct 7, 2025
010b690
fmt
Gankra Oct 7, 2025
813eb08
`clippy_dev`: Move parsing code to it's own module.
Jarcho May 31, 2025
4f403f3
`clippy_dev`: Validate lint name format during argument parsing.
Jarcho Oct 10, 2025
88c0674
`clippy_dev`: Rename `RustSearcher` to `Cursor` and move it to its ow…
Jarcho Oct 10, 2025
5e36990
`clippy_dev`: Use the new ranges.
Jarcho Oct 10, 2025
422d459
`clippy_dev`: Capture token patterns by position and length.
Jarcho Oct 10, 2025
1b31b09
`clippy_dev`: Add specialized helpers for finding identifiers to the …
Jarcho Oct 11, 2025
3e1f862
clean-up tests
ada4a Oct 12, 2025
2fe9d4b
option_option: split part of diagnostic message into help message
ada4a Oct 12, 2025
5f0f7d8
return spans out of is_doc_comment to reduce reliance on .span() on a…
jdonszelmann Oct 14, 2025
1e1c1f3
Add multiple-inherent-impl tests
nickdrozd Oct 14, 2025
14b446c
Rollup merge of #147676 - jdonszelmann:span-is-doc-comment, r=Guillau…
matthiaskrgr Oct 15, 2025
2c8a9e2
Auto merge of #146221 - camsteffen:ast-boxes, r=cjgillot
bors Oct 16, 2025
d449806
`manual_unwrap_or(_default)`: don't lint if not safe to move scrutinee
zihan0822 Oct 4, 2025
8f61305
Merge commit 'd9fb15c4b1ebe9e7dc419e07f53af681d7860cbe' into clippy-s…
flip1995 Oct 16, 2025
6a0aa12
Fix clippy for impl_trait_header changes
camsteffen Oct 7, 2025
269679e
Update link to the Code of Conduct
alex-semenyuk Oct 17, 2025
1ecb18a
Update link to the Code of Conduct (#15903)
Alexendoo Oct 17, 2025
4463ba7
clean-up tests
ada4a Oct 12, 2025
b0ecbdf
fix `option_map_unit_fn_unfixable.rs`
ada4a Oct 12, 2025
98db098
improve the suggestion
ada4a Oct 12, 2025
c6426f5
Revert "fix(elidable_lifetime_names): avoid overlapping spans in sugg…
ada4a Oct 19, 2025
9ee9fd0
refactor(manual_div_ceil): move to under `operators/`
ada4a Oct 19, 2025
70de06f
clean-up a bit
ada4a Oct 19, 2025
c8c23bc
fix(empty_enum): don't lint if all variants happen to be `cfg`-d out
ada4a Oct 19, 2025
1ac3cc1
fix(empty_enum): don't lint if all variants happen to be `cfg`-d out …
samueltardieu Oct 20, 2025
95dd88d
refactor(manual_div_ceil_: move to under `operators/` (#15909)
samueltardieu Oct 20, 2025
5578908
chore(empty_enum): rename to `empty_enums`
ada4a Oct 19, 2025
4e3fa96
refactor(option_as_ref_cloned): move the `method_call` call out of th…
ada4a Oct 20, 2025
0702934
`manual_let_else` fix when expression finishes with '}'
teofr Oct 20, 2025
973e596
`option_option`: split part of diagnostic message into help message (…
Alexendoo Oct 20, 2025
b5c3ed0
refactor: Move to anstream + anstyle for styling
Muscraft Jun 4, 2025
960c01f
Add not-null pointer patterns to pattern types
oli-obk Jan 24, 2025
d9ecbb7
clean-up
ada4a Oct 20, 2025
c5215b6
clean-up a bit
ada4a Oct 21, 2025
a8fa9e1
clean-up
ada4a Oct 21, 2025
91dbaae
improve diagnostics
ada4a Oct 21, 2025
cb33ccd
improve diagnostics
ada4a Oct 21, 2025
97d6049
Mark range expr with desugaring
camsteffen Sep 10, 2025
a6e5159
fix: parenthesise the receiver if needed
ada4a Oct 21, 2025
37ebd4c
move the lint file to under `methods/`
ada4a Oct 21, 2025
81d2300
move to `methods/`, for real this time
ada4a Oct 21, 2025
039b40f
`match_as_ref`: improve diagnostics (#15928)
samueltardieu Oct 21, 2025
fb82de5
`manual_option_as_slice: improve diagnostics (#15926)
samueltardieu Oct 21, 2025
c6c71af
refactor(option_as_ref_cloned): move the `method_call` call out of th…
samueltardieu Oct 21, 2025
17f1942
Adapt the logic from `extra_unused_type_parameters`
ada4a Oct 19, 2025
bab7519
Update mod.rs
ZylosLumen Oct 22, 2025
fd20839
Make docs more clear (#15933)
samueltardieu Oct 22, 2025
5ff804e
misc: move infallible stuff out of the way
ada4a Oct 22, 2025
2bb3d0c
refactor(elidable_lifetimes): harmonize suggestion-building logic wit…
samueltardieu Oct 22, 2025
22bdd9f
fix(match_as_ref): suggest `as_ref` when the reference needs to be cast
ada4a Oct 21, 2025
0c592df
fix(match_as_ref): suggest `as_ref` when the reference needs to be ca…
samueltardieu Oct 22, 2025
2c1ceea
Auto merge of #147207 - Muscraft:anstyle-anstream, r=davidtwco
bors Oct 22, 2025
00f68d5
`clippy_dev`: parsing revamp 1/N (#15866)
samueltardieu Oct 22, 2025
de63d25
fix: Don't add diff symbol to unchanged lines
Muscraft Oct 22, 2025
fcfab5f
`clippy_dev`: Move all parsing within a parse context.
Jarcho Oct 10, 2025
7579e71
`clippy_dev`: Inline and simplify `read_src_with_module`.
Jarcho Oct 11, 2025
bae625f
`clippy_dev`: Allocate onto an arena when parsing.
Jarcho Oct 11, 2025
6026cc9
Replace NullOp::SizeOf and NullOp::AlignOf by lang items.
cjgillot Oct 16, 2025
26b12a9
Retire ast::TyAliasWhereClauses.
cjgillot Oct 15, 2025
cd5b0b6
Auto merge of #147793 - cjgillot:no-null-op, r=scottmcm,oli-obk
bors Oct 23, 2025
ab15129
Rollup merge of #147713 - cjgillot:where-cfg, r=fmease
jhpratt Oct 23, 2025
8d15b5f
Auto merge of #148014 - jhpratt:rollup-aglren3, r=jhpratt
bors Oct 23, 2025
82d729c
`clippy_dev`: Parsing revamp part 2/N (#15921)
samueltardieu Oct 23, 2025
09c3237
chore(empty_enum): rename to `empty_enums` (#15912)
dswij Oct 23, 2025
9fd359b
clean-up
ada4a Oct 21, 2025
9145cee
make the spans more precise
ada4a Oct 21, 2025
c238924
Revert "Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=p…
lqd Oct 23, 2025
0cc1594
Fix trait method checking in book
samueltardieu Oct 23, 2025
9eba2cc
fix: `len_zero` FP on unstable methods
profetia Oct 16, 2025
8ff0cf8
Fix `len_zero` FP on unstable methods (#15894)
samueltardieu Oct 23, 2025
21d3b9d
split test files for `use_debug` and `print_stdout`
ada4a Oct 24, 2025
f975caa
Fix trait method checking in book (#15941)
Jarcho Oct 24, 2025
3dcf399
fix(`manual_let_else`): expressions ending with `'}'` (#15919)
Jarcho Oct 24, 2025
d1b51ea
`{option,result}_map_unit_fn`: fix and clean-up tests, make suggestio…
Jarcho Oct 24, 2025
622a77d
feat(search_is_some): Fix when the closure spans multiple lines
Oct 16, 2025
aae10d7
refactor(double_comparison): clean-up, simplify lint logic
ada4a Oct 26, 2025
ce2ef31
fix(needless_if): don't expand macro invocations in the suggestion
ada4a Oct 26, 2025
0ba9ba7
Prepare for mdbook 0.5
ehuss Oct 26, 2025
25cbcb4
refactor(lines_filter_map_ok): move to under `methods/` (#15925)
Jarcho Oct 26, 2025
05aaed9
Auto merge of #146069 - camsteffen:range-desugar-span, r=SparrowLii
bors Oct 27, 2025
12b011b
Lint precedence possible ambiguity between closure and method call
samueltardieu Mar 16, 2025
da89652
refactor(double_comparison): clean-up, simplify lint logic (#15955)
samueltardieu Oct 27, 2025
c5714b0
Prepare for mdbook 0.5 (#15965)
samueltardieu Oct 27, 2025
a0a347e
fix(needless_if): don't expand macro invocations in the suggestion (#…
samueltardieu Oct 27, 2025
640e118
chore(needless_if): rename to `needless_ifs`
ada4a Oct 26, 2025
d349b20
fix(use_debug): don't get confused by nested `Debug` impls
ada4a Oct 24, 2025
b0d93f1
chore(needless_if): rename to `needless_ifs` (#15961)
Alexendoo Oct 27, 2025
0029a91
Lint precedence possible ambiguity between closure and method call (#…
Alexendoo Oct 27, 2025
a5b3c44
Consider labels of inline asm as conditionally executed
samueltardieu Sep 14, 2025
ca168c0
`unnecessary_{find,filter}_map`: make diagnostic spans more precise (…
dswij Oct 27, 2025
0226fa9
Consider labels of inline asm as conditionally executed (#15676)
Alexendoo Oct 27, 2025
0ff3a38
Improve doc comment code language tag parsing, don't use a full parser
Alexendoo Oct 27, 2025
bc5bd29
Remove QPath::LangItem from for loops
camsteffen Sep 1, 2025
ae9d202
Remove QPath::LangItem from ranges
camsteffen Aug 17, 2025
930dfc8
Remove QPath::LangItem from async
camsteffen Aug 17, 2025
e2b3508
Remove QPath::LangItem from try
camsteffen Sep 1, 2025
a2d8955
Remove QPath::LangItem
camsteffen Sep 1, 2025
f144c6c
feat(search_is_some): Fix when the closure spans multiple lines (#15902)
Jarcho Oct 28, 2025
02e4516
fix(double_parens): don't lint in proc-macros
ada4a Oct 23, 2025
78db66e
Remove AssignDesugar span
camsteffen Oct 28, 2025
97e681f
Changelog for Clippy 1.91
alex-semenyuk Oct 25, 2025
e71b46f
refactor(invalid_upcast_comparisons): move to under `operators`
ada4a Oct 26, 2025
d74200a
refactor(invalid_upcast_comparisons): move to under `operators`, simp…
samueltardieu Oct 28, 2025
7012a5d
`incompatible_msrv`: Don't check the const MSRV for uncalled function…
samueltardieu Oct 29, 2025
90b34cb
put the operators in backticks in the diagnostics
ada4a Oct 25, 2025
967d2b1
chore(integer_division_remainder_used): move to under `operators`
ada4a Oct 25, 2025
35e55a6
`manual_unwrap_or(_default)`: don't lint if not safe to move scrutine…
flip1995 Oct 29, 2025
c95db07
test(while_immutable_condition): call the test file the same as the lint
ada4a Oct 29, 2025
7c86faa
test(while_immutable_condition): call the test file the same as the l…
llogiq Oct 29, 2025
5a90737
Add multiple-inherent-impl tests (#15886)
llogiq Oct 29, 2025
d05f74e
refactor(integer_division_remainder_used): move to under `operators` …
samueltardieu Oct 29, 2025
26f35ae
Implement pattern matching for `&pin mut|const T`
frank-king Apr 13, 2025
9fc1d8a
require `T: !Unpin` for `&pin mut T` to be projected to `&pin mut T.U…
frank-king Jul 19, 2025
7070709
Remove `!Unpin` related bounds
frank-king Aug 3, 2025
cb369ab
Fix `pin_ergonomics` tests
frank-king Aug 3, 2025
b36f15e
Add `#[pin_project]` attribute for structurally pinning
frank-king Sep 27, 2025
ace8345
Rename `#[pin_project]` to `#[pin_v2]` to avoid naming conflicts
frank-king Oct 24, 2025
52fa003
Auto merge of #148193 - camsteffen:remove-qpath-langitem, r=cjgillot
bors Oct 30, 2025
7319811
[rustdoc search] Include extern crates when filtering on `import`
GuillaumeGomez Oct 30, 2025
5e7ce90
Improve doc comment code language tag parsing, don't use a full parse…
dswij Oct 30, 2025
e614ed4
Restrict `#[pin_v2]` test on `global_asm!` to stablized archs only
frank-king Oct 31, 2025
d8ace32
Remove the `#[pin_v2]` test since it produces different errors on dif…
frank-king Oct 31, 2025
b69d2ff
Changelog for Clippy 1.91 🎃 (#15971)
Jarcho Oct 31, 2025
bcc40ce
fix(double_parens): don't lint in proc-macros (#15939)
Jarcho Oct 31, 2025
e415911
fix(use_debug): don't get confused by nested `Debug` impls (#15946)
Jarcho Oct 31, 2025
88554d6
Remove/fix setTimeout logic in lints page
Alexendoo Oct 29, 2025
23edbb6
Don't require dlltool with the dummy backend on MinGW
bjorn3 Oct 31, 2025
04a10f7
Simplify code to generate line numbers in highlight
GuillaumeGomez Oct 27, 2025
5fabd2d
Improve code
GuillaumeGomez Oct 31, 2025
0b784f8
Remove/fix setTimeout logic in lints page (#15983)
Jarcho Oct 31, 2025
efb9a41
cleanup: upstream dropped amx-transpose functionality
durin42 Oct 31, 2025
f64e401
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Oct 31, 2025
2b9c8f1
Bump nightly version -> 2025-10-31
flip1995 Oct 31, 2025
a531040
Bump Clippy version -> 0.1.93
flip1995 Oct 31, 2025
c936595
Rustup (#16000)
flip1995 Oct 31, 2025
534b81c
Merge commit 'c936595d17413c1f08e162e117e504fb4ed126e4' into clippy-s…
flip1995 Oct 31, 2025
be5093e
Update Cargo.lock
flip1995 Oct 31, 2025
af5b798
Add Ord::clamp_min and clamp_max
Kyuuhachi Oct 16, 2025
c169ea0
Unpin `libc` in `compiler` and `rustbook`
clubby789 Oct 29, 2025
7069400
revert combined nonpoison/poison tests for condvar
connortsui20 Oct 31, 2025
3d5a408
update `nonpoison::Condvar` to take guards by reference
connortsui20 Oct 31, 2025
c1153b0
move condvar test from mutex to condvar test file
connortsui20 Oct 31, 2025
2e01acc
Add tests for some cases mentioned in #135589
estebank Jan 16, 2025
8ba2950
Detect case of missing lifetime in assoc type
estebank Jan 16, 2025
1e9e1f2
On unconstrained lifetime on `impl` block, suggest using it if there'…
estebank Jan 16, 2025
75bb675
Do not suggest introducing lifetime in impl assoc type
estebank Jan 16, 2025
8d51667
fix typo
estebank Oct 31, 2025
2a1595e
Add regression test for including extern crates in import filtering
GuillaumeGomez Oct 30, 2025
56247f1
Rollup merge of #135602 - estebank:issue-135589, r=Nadrieril
matthiaskrgr Nov 1, 2025
f38192d
Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril…
matthiaskrgr Nov 1, 2025
331f53d
Rollup merge of #142682 - Gankra:update_musl_1.2.5, r=wesleywiser
matthiaskrgr Nov 1, 2025
5effb6e
Rollup merge of #147786 - Kyuuhachi:clamp-min-max, r=joboet
matthiaskrgr Nov 1, 2025
3e83013
Rollup merge of #148171 - GuillaumeGomez:line-number-highlight, r=yot…
matthiaskrgr Nov 1, 2025
9d70884
Rollup merge of #148263 - clubby789:bump-libc, r=ehuss
matthiaskrgr Nov 1, 2025
e6edc6d
Rollup merge of #148301 - GuillaumeGomez:import-filter, r=notriddle
matthiaskrgr Nov 1, 2025
9cbc1b7
Rollup merge of #148330 - bjorn3:dummy_backend_no_dlltool, r=mati865
matthiaskrgr Nov 1, 2025
bc77e59
Rollup merge of #148338 - durin42:llvm-22-amx-transpose, r=workingjub…
matthiaskrgr Nov 1, 2025
894c723
Rollup merge of #148340 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Nov 1, 2025
c972d22
Rollup merge of #148343 - connortsui20:guard-ref-condvar, r=Amanieu
matthiaskrgr Nov 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 14 additions & 14 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"

[[package]]
name = "clippy"
version = "0.1.92"
version = "0.1.93"
dependencies = [
"anstream",
"askama",
Expand All @@ -607,7 +607,7 @@ dependencies = [

[[package]]
name = "clippy_config"
version = "0.1.92"
version = "0.1.93"
dependencies = [
"clippy_utils",
"itertools",
Expand All @@ -630,7 +630,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.92"
version = "0.1.93"
dependencies = [
"arrayvec",
"cargo_metadata 0.18.1",
Expand Down Expand Up @@ -662,7 +662,7 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.92"
version = "0.1.93"
dependencies = [
"arrayvec",
"itertools",
Expand Down Expand Up @@ -1066,7 +1066,7 @@ dependencies = [

[[package]]
name = "declare_clippy_lint"
version = "0.1.92"
version = "0.1.93"

[[package]]
name = "derive-where"
Expand Down Expand Up @@ -1288,7 +1288,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
dependencies = [
"libc",
"windows-sys 0.60.2",
"windows-sys 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -2101,9 +2101,9 @@ checksum = "9fa0e2a1fcbe2f6be6c42e342259976206b383122fc152e872795338b5a3f3a7"

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

[[package]]
name = "libdbus-sys"
Expand Down Expand Up @@ -2154,7 +2154,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
dependencies = [
"cfg-if",
"windows-targets 0.53.3",
"windows-targets 0.52.6",
]

[[package]]
Expand Down Expand Up @@ -2216,9 +2216,9 @@ dependencies = [

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

[[package]]
name = "litemap"
Expand Down Expand Up @@ -4897,15 +4897,15 @@ dependencies = [

[[package]]
name = "rustix"
version = "1.0.8"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.60.2",
"windows-sys 0.52.0",
]

[[package]]
Expand Down
25 changes: 19 additions & 6 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,14 @@ pub struct PatField {
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
pub enum ByRef {
Yes(Mutability),
Yes(Pinnedness, Mutability),
No,
}

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

impl BindingMode {
pub const NONE: Self = Self(ByRef::No, Mutability::Not);
pub const REF: Self = Self(ByRef::Yes(Mutability::Not), Mutability::Not);
pub const REF: Self = Self(ByRef::Yes(Pinnedness::Not, Mutability::Not), Mutability::Not);
pub const REF_PIN: Self =
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Not), Mutability::Not);
pub const MUT: Self = Self(ByRef::No, Mutability::Mut);
pub const REF_MUT: Self = Self(ByRef::Yes(Mutability::Mut), Mutability::Not);
pub const MUT_REF: Self = Self(ByRef::Yes(Mutability::Not), Mutability::Mut);
pub const MUT_REF_MUT: Self = Self(ByRef::Yes(Mutability::Mut), Mutability::Mut);
pub const REF_MUT: Self = Self(ByRef::Yes(Pinnedness::Not, Mutability::Mut), Mutability::Not);
pub const REF_PIN_MUT: Self =
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Mut), Mutability::Not);
pub const MUT_REF: Self = Self(ByRef::Yes(Pinnedness::Not, Mutability::Not), Mutability::Mut);
pub const MUT_REF_PIN: Self =
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Not), Mutability::Mut);
pub const MUT_REF_MUT: Self =
Self(ByRef::Yes(Pinnedness::Not, Mutability::Mut), Mutability::Mut);
pub const MUT_REF_PIN_MUT: Self =
Self(ByRef::Yes(Pinnedness::Pinned, Mutability::Mut), Mutability::Mut);

pub fn prefix_str(self) -> &'static str {
match self {
Self::NONE => "",
Self::REF => "ref ",
Self::REF_PIN => "ref pin const ",
Self::MUT => "mut ",
Self::REF_MUT => "ref mut ",
Self::REF_PIN_MUT => "ref pin mut ",
Self::MUT_REF => "mut ref ",
Self::MUT_REF_PIN => "mut ref pin ",
Self::MUT_REF_MUT => "mut ref mut ",
Self::MUT_REF_PIN_MUT => "mut ref pin mut ",
}
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ macro_rules! common_visitor_and_walkers {
crate::tokenstream::TokenStream,
Movability,
Mutability,
Pinnedness,
Result<(), rustc_span::ErrorGuaranteed>,
rustc_data_structures::fx::FxHashMap<Symbol, usize>,
rustc_span::ErrorGuaranteed,
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_ast_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,10 @@ pub enum Pinnedness {
Not,
Pinned,
}

impl Pinnedness {
/// Return `true` if self is pinned
pub fn is_pinned(self) -> bool {
matches!(self, Self::Pinned)
}
}
7 changes: 6 additions & 1 deletion compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1712,10 +1712,15 @@ impl<'a> State<'a> {
if mutbl.is_mut() {
self.word_nbsp("mut");
}
if let ByRef::Yes(rmutbl) = by_ref {
if let ByRef::Yes(pinnedness, rmutbl) = by_ref {
self.word_nbsp("ref");
if pinnedness.is_pinned() {
self.word_nbsp("pin");
}
if rmutbl.is_mut() {
self.word_nbsp("mut");
} else if pinnedness.is_pinned() {
self.word_nbsp("const");
}
}
self.print_ident(*ident);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub(crate) mod must_use;
pub(crate) mod no_implicit_prelude;
pub(crate) mod non_exhaustive;
pub(crate) mod path;
pub(crate) mod pin_v2;
pub(crate) mod proc_macro_attrs;
pub(crate) mod prototype;
pub(crate) mod repr;
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/pin_v2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use rustc_hir::Target;
use rustc_hir::attrs::AttributeKind;
use rustc_span::{Span, Symbol, sym};

use crate::attributes::{NoArgsAttributeParser, OnDuplicate};
use crate::context::Stage;
use crate::target_checking::AllowedTargets;
use crate::target_checking::Policy::Allow;

pub(crate) struct PinV2Parser;

impl<S: Stage> NoArgsAttributeParser<S> for PinV2Parser {
const PATH: &[Symbol] = &[sym::pin_v2];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Enum),
Allow(Target::Struct),
Allow(Target::Union),
]);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::PinV2;
}
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use crate::attributes::must_use::MustUseParser;
use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser;
use crate::attributes::non_exhaustive::NonExhaustiveParser;
use crate::attributes::path::PathParser as PathAttributeParser;
use crate::attributes::pin_v2::PinV2Parser;
use crate::attributes::proc_macro_attrs::{
ProcMacroAttributeParser, ProcMacroDeriveParser, ProcMacroParser, RustcBuiltinMacroParser,
};
Expand Down Expand Up @@ -233,6 +234,7 @@ attribute_parsers!(
Single<WithoutArgs<NonExhaustiveParser>>,
Single<WithoutArgs<ParenSugarParser>>,
Single<WithoutArgs<PassByValueParser>>,
Single<WithoutArgs<PinV2Parser>>,
Single<WithoutArgs<PointeeParser>>,
Single<WithoutArgs<ProcMacroAttributeParser>>,
Single<WithoutArgs<ProcMacroParser>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}

LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
binding_mode: BindingMode(ByRef::Yes(_), _),
binding_mode: BindingMode(ByRef::Yes(..), _),
..
})) => {
let pattern_span: Span = local_decl.source_info.span;
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,16 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
_ => bug!("Deref of unexpected type: {:?}", base_ty),
}
}
// Check as the inner reference type if it is a field projection
// from the `&pin` pattern
ProjectionElem::Field(FieldIdx::ZERO, _)
if let Some(adt) =
place_base.ty(self.body(), self.infcx.tcx).ty.ty_adt_def()
&& adt.is_pin()
&& self.infcx.tcx.features().pin_ergonomics() =>
{
self.is_mutable(place_base, is_local_mutation_allowed)
}
// All other projections are owned by their base path, so mutable if
// base path is mutable
ProjectionElem::Field(..)
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,15 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
EncodeCrossCrate::No, loop_match, experimental!(loop_match)
),

// The `#[pin_v2]` attribute is part of the `pin_ergonomics` experiment
// that allows structurally pinning, tracked in:
//
// - https://github.com/rust-lang/rust/issues/130494
gated!(
pin_v2, Normal, template!(Word), ErrorFollowing,
EncodeCrossCrate::Yes, pin_ergonomics, experimental!(pin_v2),
),

// ==========================================================================
// Internal attributes: Stability, deprecation, and unsafe:
// ==========================================================================
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ pub enum AttributeKind {
/// Represents `#[pattern_complexity_limit]`
PatternComplexityLimit { attr_span: Span, limit_span: Span, limit: Limit },

/// Represents `#[pin_v2]`
PinV2(Span),

/// Represents `#[pointee]`
Pointee(Span),

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl AttributeKind {
PassByValue(..) => Yes,
Path(..) => No,
PatternComplexityLimit { .. } => No,
PinV2(..) => Yes,
Pointee(..) => No,
ProcMacro(..) => No,
ProcMacroAttribute(..) => No,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_ast::{
pub use rustc_ast::{
AssignOp, AssignOpKind, AttrId, AttrStyle, BinOp, BinOpKind, BindingMode, BorrowKind,
BoundConstness, BoundPolarity, ByRef, CaptureBy, DelimArgs, ImplPolarity, IsAuto,
MetaItemInner, MetaItemLit, Movability, Mutability, UnOp,
MetaItemInner, MetaItemLit, Movability, Mutability, Pinnedness, UnOp,
};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::sorted_map::SortedMap;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ fn resolve_local<'tcx>(
// & expression, and its lifetime would be extended to the end of the block (due
// to a different rule, not the below code).
match pat.kind {
PatKind::Binding(hir::BindingMode(hir::ByRef::Yes(_), _), ..) => true,
PatKind::Binding(hir::BindingMode(hir::ByRef::Yes(..), _), ..) => true,

PatKind::Struct(_, field_pats, _) => field_pats.iter().any(|fp| is_binding_pat(fp.pat)),

Expand Down
24 changes: 23 additions & 1 deletion compiler/rustc_hir_analysis/src/impl_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ use std::assert_matches::debug_assert_matches;

use min_specialization::check_min_specialization;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::Applicability;
use rustc_errors::codes::*;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_span::ErrorGuaranteed;
use rustc_span::{ErrorGuaranteed, kw};

use crate::constrained_generic_params as cgp;
use crate::errors::UnconstrainedGenericParameter;
Expand Down Expand Up @@ -150,6 +151,27 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained(
const_param_note2: false,
});
diag.code(E0207);
for p in &impl_generics.own_params {
if p.name == kw::UnderscoreLifetime {
let span = tcx.def_span(p.def_id);
let Ok(snippet) = tcx.sess.source_map().span_to_snippet(span) else {
continue;
};

let (span, sugg) = if &snippet == "'_" {
(span, param.name.to_string())
} else {
(span.shrink_to_hi(), format!("{} ", param.name))
};
diag.span_suggestion_verbose(
span,
"consider using the named lifetime here instead of an implicit \
lifetime",
sugg,
Applicability::MaybeIncorrect,
);
}
}
res = Err(diag.emit());
}
}
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1925,10 +1925,15 @@ impl<'a> State<'a> {
if mutbl.is_mut() {
self.word_nbsp("mut");
}
if let ByRef::Yes(rmutbl) = by_ref {
if let ByRef::Yes(pinnedness, rmutbl) = by_ref {
self.word_nbsp("ref");
if pinnedness.is_pinned() {
self.word_nbsp("pin");
}
if rmutbl.is_mut() {
self.word_nbsp("mut");
} else if pinnedness.is_pinned() {
self.word_nbsp("const");
}
}
self.print_ident(ident);
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_hir_typeck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ hir_typeck_pass_to_variadic_function = can't pass `{$ty}` to variadic function
.suggestion = cast the value to `{$cast_ty}`
.teach_help = certain types, like `{$ty}`, must be cast before passing them to a variadic function to match the implicit cast that a C compiler would perform as part of C's numeric promotion rules

hir_typeck_project_on_non_pin_project_type = cannot project on type that is not `#[pin_v2]`
.note = type defined here
.suggestion = add `#[pin_v2]` here

hir_typeck_ptr_cast_add_auto_to_object = cannot add {$traits_len ->
[1] auto trait {$traits}
*[other] auto traits {$traits}
Expand Down
Loading
Loading