Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #98724

Closed
wants to merge 204 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
430575b
add `manual_find` lint for function return case
ebobrow Apr 6, 2022
5a70d88
add vec.capacity() to slow_vec_initialization
DevAccentor Jun 5, 2022
63d1c86
[core] add Exclusive to sync
guswynn Jun 1, 2022
6d6c63e
Lint single_match with Options, Results, and Cows
botahamec Jun 9, 2022
2967127
Refactored the candidate type checking
botahamec Jun 9, 2022
b46f1c4
Don't trigger if a binding is in the else pattern
botahamec Jun 10, 2022
b0c2030
Some refactoring
botahamec Jun 10, 2022
01c75e4
Added tests for Cow and Result
botahamec Jun 10, 2022
f3dc7ae
Fixed up the documentation for a couple functions
botahamec Jun 10, 2022
ded2bb5
Slight documentation change
botahamec Jun 10, 2022
9306e9a
Ignore bodies containing `todo!()` in `clippy::if_same_then_else`
May 18, 2022
7cb4cef
feat(fix): ignore todo! and unimplemented! in if_same_then_else
kyoto7250 Jun 16, 2022
922ff84
bless clippy tests
klensy Jun 15, 2022
4d88993
bless clippy ui tests
WaffleLapkin Jun 16, 2022
f8f9d01
Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' into clippyup
flip1995 Jun 16, 2022
f095f80
Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`
WaffleLapkin Jun 16, 2022
a5b6d25
use get_diagnostic_name for checking macro_call
kyoto7250 Jun 17, 2022
72c73f8
remove the rest of unnecessary `to_string`
TaKO8Ki Jun 17, 2022
51e2d6a
Rollup merge of #97798 - WaffleLapkin:allow_for_suggestions_that_are_…
Dylan-DPC Jun 17, 2022
2cc798b
Rollup merge of #98191 - TaKO8Ki:remove-rest-of-unnecessary-to-string…
Dylan-DPC Jun 17, 2022
2bb8c45
feat(lint): add default_iter_empty
kyoto7250 Jun 12, 2022
697c75e
check only the end
kyoto7250 Jun 17, 2022
09c9301
Auto merge of #97892 - klensy:fix-spaces, r=oli-obk
bors Jun 17, 2022
e933bb6
Auto merge of #8989 - kyoto7250:default_iter_empty, r=Alexendoo
bors Jun 17, 2022
f411c18
check macro_backtrace only
kyoto7250 Jun 18, 2022
7a83809
check only first statement
kyoto7250 Jun 18, 2022
040d45e
check macro in eq_block
kyoto7250 Jun 18, 2022
4a02ae9
cargo dev fmt
kyoto7250 Jun 18, 2022
a9215d9
ignore item in thread_local!
kyoto7250 Jun 16, 2022
eeedf72
Use RefCell in needless_return tests
Alexendoo Jun 18, 2022
4737e9e
Rollup merge of #98165 - WaffleLapkin:once_things_renamings, r=m-ou-se
matthiaskrgr Jun 18, 2022
4e7ed42
Add description meta tag for lint list
unvalley Jun 19, 2022
9395c26
remove `span_lint_and_sugg_for_edges` from clippy utils
WaffleLapkin Jun 19, 2022
ee37029
remove last use of MAX_SUGGESTION_HIGHLIGHT_LINES
WaffleLapkin Jun 19, 2022
9d92af7
Auto merge of #9016 - Alexendoo:needless-return-test, r=giraffate
bors Jun 20, 2022
46d056e
check last statement
kyoto7250 Jun 20, 2022
39ffda0
check macro in HitEqInterExpr
kyoto7250 Jun 20, 2022
4a4b5cf
confirm using chain in collapsible_span_lint_calls
kyoto7250 Jun 20, 2022
195f2cb
Auto merge of #9023 - unvalley:add-meta-tag-for-lint-list, r=xFrednet
bors Jun 20, 2022
a0b107b
unused_async: lint async methods
Alexendoo Jun 20, 2022
97d4513
Auto merge of #9025 - Alexendoo:unused-async-method, r=dswij
bors Jun 20, 2022
93c6f9e
Auto merge of #9006 - kyoto7250:issue-8836-v2, r=Jarcho
bors Jun 20, 2022
6fc84d4
put parentheses around neg_multiply suggestion if needed
hellow554 Jun 20, 2022
2476100
Add details about significant drop in match scrutinees causing deadlocks
PrestonFrom Jun 10, 2022
dc7f227
`For` example should be used instead `while` in WHILE_LET_ON_ITERATOR
alex-semenyuk Jun 18, 2022
2bd1581
Add `dev deprecate`
Serial-ATA May 22, 2022
890fd0e
Remove `cargo_dev` dependency
Serial-ATA Jun 21, 2022
e5ebd3e
Implement manual_rem_euclid lint
Jun 21, 2022
6e1df47
Fix case where suggestion errored for infer type
Jun 21, 2022
ab645bb
enum_variant_names should ignore when all prefixes are _
kyoto7250 Jun 21, 2022
bc0bf06
Auto merge of #9017 - alex-semenyuk:while_let_on_iterator_doc_fix, r=…
bors Jun 22, 2022
f9fea17
Auto merge of #9030 - Serial-ATA:remove-clippy-dev-dep, r=flip1995
bors Jun 22, 2022
b969326
Example for VEC_RESIZE_TO_ZERO
alex-semenyuk Jun 22, 2022
75ed0c9
Prefer `.ok()?` over `.unwrap()`
Jun 22, 2022
93e41d3
Fix case where rem was considered commutative
Jun 22, 2022
c8df6d6
Prefer if let chain over macro
Jun 22, 2022
90f8277
Fix case for function params
Jun 22, 2022
61e1870
Add MSRV check for const rem_euclid
Jun 22, 2022
0447cc7
Simplify with let else
Jun 22, 2022
3d366fc
Auto merge of #9026 - hellow554:neg_multiply_precedence, r=xFrednet
bors Jun 22, 2022
6985e65
Auto merge of #9028 - kyoto7250:issue_8798, r=xFrednet
bors Jun 22, 2022
2cc5211
Auto merge of #9034 - alex-semenyuk:example_vec_resize_to_zero, r=gir…
bors Jun 22, 2022
87eded6
Fix `extra_unused_lifetimes` false positive
smoelius Jun 21, 2022
1f707db
Update messages for clarity when linting
PrestonFrom Jun 23, 2022
4182803
Check for `--force-warn` in Clippy's driver run condition
xFrednet Jun 23, 2022
92704b4
Split constant check functions and simplify
Jun 23, 2022
ebf77f6
Fix ICE when deprecating lints in directories
Serial-ATA Jun 23, 2022
029f9aa
add tracking issue for exclusive
guswynn Jun 23, 2022
df26c3f
Add external macro guard and test middle MSRV
Jun 23, 2022
f718984
Auto merge of #8953 - DevAccentor:slow_vector_initialization, r=Manis…
bors Jun 23, 2022
3f47cd1
Auto merge of #9036 - xFrednet:0000-force-warn-in-driver, r=dswij
bors Jun 24, 2022
1d1ae10
Auto merge of #9037 - smoelius:fix-extra-unused-lifetimes-fp, r=dswij
bors Jun 24, 2022
a8f6824
Add test for `extra_unused_lifetimes` FP on derive
dswij Jun 24, 2022
e17864e
Auto merge of #9031 - evantypanski:manual_rem_euclid, r=Jarcho
bors Jun 24, 2022
aec465c
Add test for [`default_deprecation_reason`]
Serial-ATA Jun 24, 2022
93ebd0e
Auto merge of #9015 - kyoto7250:issue_8493, r=Jarcho
bors Jun 25, 2022
7cdaabc
Suggest `pointer::cast` when possible in `transmute_ptr_to_ref`
Jarcho Jun 4, 2022
e7c55a4
Fix `#[expect]` for `clippy::ptr_arg`
xFrednet Jun 25, 2022
811d73a
Test `#[expect]` for `redundant_clone`
xFrednet Jun 25, 2022
a3c7101
Fix `#[expect]` for `clippy::logic_bug`
xFrednet Jun 25, 2022
b6ee6bb
Fix `#[expect]` for `clippy::nonminimal_bool`
xFrednet Jun 25, 2022
b297698
Fix `#[expect]` for `clippy::boxed_local`
xFrednet Jun 25, 2022
54ad99b
Fix `#[expect]` for `clippy::implicit_return`
xFrednet Jun 25, 2022
bdc6ece
Fix `#[expect]` for `clippy::needless_return`
xFrednet Jun 25, 2022
79fc271
Fix `#[expect]` for `unnecessary_unwrap`, `panicking_unwrap`
xFrednet Jun 25, 2022
ae4900c
Fix `#[expect]` for `clippy::macro_use_imports`
xFrednet Jun 25, 2022
525f5ee
Update `useless_attribute` docs and allow `macro_use_imports`
xFrednet Jun 25, 2022
6427ba4
Fix `#[expect]` for `clippy::manual_non_exhaustive`
xFrednet Jun 25, 2022
4d41a97
Add note to `is_lint_allowed` about lint emission
xFrednet Jun 25, 2022
3a31ef7
Give clippy some Dogfood to make it happy =^.^=
xFrednet Jun 25, 2022
8789f4e
Auto merge of #8985 - botahamec:single-match-option, r=llogiq
bors Jun 25, 2022
bf317a8
treat argument as a slice.
kyoto7250 Jun 26, 2022
d827b83
use all instead of join
kyoto7250 Jun 26, 2022
4065702
STRING_ADD example
alex-semenyuk Jun 26, 2022
1691914
STRING_ADD example
alex-semenyuk Jun 26, 2022
11bf291
update node.js version
kyoto7250 Jun 26, 2022
ab58276
Auto merge of #9055 - kyoto7250:update_nodejs_in_github_action, r=Man…
bors Jun 26, 2022
9b15062
Auto merge of #9032 - kyoto7250:issue_9018, r=llogiq
bors Jun 26, 2022
5f2b8e6
feat(new lint): new lint `use_retain`
kyoto7250 Jun 7, 2022
b20b8f1
Update clippy_lints/src/use_retain.rs
kyoto7250 Jun 9, 2022
e3afc72
remove needless return
kyoto7250 Jun 9, 2022
3953c53
change lint type from style to perf
kyoto7250 Jun 9, 2022
fd629c0
check method
kyoto7250 Jun 9, 2022
1421211
rewrite without if_chain macro
kyoto7250 Jun 9, 2022
4decfde
check msrv
kyoto7250 Jun 10, 2022
dd3d0fd
rename use_retain => manual_retain
kyoto7250 Jun 10, 2022
3a9c0ef
fix for git rebase
kyoto7250 Jun 18, 2022
676af45
cargo dev update_lints
kyoto7250 Jun 26, 2022
88da5f2
Auto merge of #8939 - Jarcho:transmute_ptr_to_ref_lt, r=giraffate
bors Jun 27, 2022
57e7e1d
Auto merge of #8871 - Serial-ATA:cargo-dev-deprecate, r=giraffate
bors Jun 27, 2022
6b762ee
Auto merge of #9054 - alex-semenyuk:string_add_example, r=giraffate
bors Jun 27, 2022
65f700f
Fix `let_undescore_lock` false-positive when binding without locking
tsoutsman Jun 13, 2022
889b361
Auto merge of #8990 - tsoutsman:master, r=llogiq
bors Jun 27, 2022
eaa03ea
Auto merge of #8972 - kyoto7250:use_retain, r=llogiq
bors Jun 27, 2022
c6a2221
Fix example `SELF_ASSIGNMENT`
alex-semenyuk Jun 25, 2022
2315f76
Actually check lifetimes in `trivially_copy_pass_by_ref`
Jarcho Apr 6, 2022
c10101c
Don't lint `trivially_copy_pass_by_ref` when unsafe pointers are used
Jarcho Apr 6, 2022
fdd0e72
Auto merge of #8649 - ebobrow:imperative_find, r=flip1995
bors Jun 27, 2022
d855395
Auto merge of #9045 - alex-semenyuk:self_assignment_example, r=llogiq
bors Jun 27, 2022
af0c1fe
fix data race in thread::scope
RalfJung Jun 25, 2022
3cfd1e5
Make messages more accurate, check lint enabled
PrestonFrom Jun 28, 2022
7bc4096
Run cargo dev fmt
PrestonFrom Jun 28, 2022
81737bf
try reading rust-version from Cargo.toml
hellow554 May 2, 2022
83511d1
update README.md to reflect rust-version in cargo.toml
hellow554 May 10, 2022
6384765
parse `Cargo.toml` file in ui-cargo tests
hellow554 Jun 27, 2022
f0a1cd5
add uitests for cargo rust-version field
hellow554 May 10, 2022
373bb57
Auto merge of #8639 - Jarcho:trivially_copy_pass_by_ref_5953, r=dswij
bors Jun 28, 2022
b776fb8
Auto merge of #8774 - hellow554:cargo-rust-version, r=flip1995
bors Jun 28, 2022
d11618e
Update `boxed_local` expect attribute location
xFrednet Jun 28, 2022
c107c97
Better support projection types when finding the signature for an exp…
Jarcho Jan 25, 2022
8a74d33
Add `explicit_auto_deref` lint
Jarcho Jan 27, 2022
ee532c0
Don't lint `explicit_auto_deref` on reborrows
Jarcho Jan 27, 2022
a187d64
Merge different parent walking loops in `dereference.rs`
Jarcho Jan 28, 2022
20ea262
Lint field accesses in `explicit_auto_deref`
Jarcho Jan 28, 2022
442a68c
Only check parent node once in `dereference.rs`
Jarcho Jan 28, 2022
65bc6cb
Lint `explicit_auto_deref` without a leading borrow
Jarcho Jan 28, 2022
0204b95
Lint `explicit_auto_deref` immediately after `needless_borrow`
Jarcho Jan 29, 2022
0b4ba73
Refactor `dereference.rs`
Jarcho Jan 29, 2022
6d21b79
Fix `needless_borrow` suggestion when calling a trait method taking `…
Jarcho Jan 30, 2022
9788107
Handle future precedence issues in `explicit_auto_deref` + cleanup
Jarcho Jan 31, 2022
15df228
Code cleanup
Jarcho Feb 7, 2022
85c1f74
Add `explicit_auto_deref` test for variadic function
Jarcho Jun 13, 2022
dd78ce7
Add `Operators` lint pass
Jarcho May 31, 2022
448b6f4
Move `Arithmetic` into `Operators` lint pass
Jarcho Jun 1, 2022
751131b
Move `AssignOps` into `Operators` lint pass
Jarcho Jun 1, 2022
68a7fd2
Move `BitMask` into `Operators` lint pass
Jarcho Jun 1, 2022
4ac3626
Move `DoubleComparison` into `Operators` lint pass
Jarcho Jun 1, 2022
732d716
Move `DurationSubsec` into `Operators` lint pass
Jarcho Jun 1, 2022
0adb3c0
Move `EqOp` into `Operators` lint pass
Jarcho Jun 1, 2022
3de70a4
Move `ErasingOp` into `Operators` lint pass
Jarcho Jun 1, 2022
56f50d3
Move `FloatEqualityWithoutAbs` into `Operators` lint pass
Jarcho Jun 1, 2022
83de67c
Move `IdentityOp` into `Operators` lint pass
Jarcho Jun 1, 2022
a8df16a
Move `IntegerDivision` into `Operators` lint pass
Jarcho Jun 1, 2022
c0b0ee5
Move some lints from `Misc` to `Operators`
Jarcho Jun 1, 2022
71c2daa
Move `ModuloArithmetic` into `Operators` lint pass
Jarcho Jun 1, 2022
fc5eac5
Move `NeedlessBitwiseBool` into `Operators` lint pass
Jarcho Jun 1, 2022
92891a0
Move `PtrEq` into `Operators` lin pass
Jarcho Jun 1, 2022
5e2a2d3
Fix dogfood
Jarcho Jun 14, 2022
ffbba85
Move `SelfAssignment` into `Operators` lint pass
Jarcho Jun 1, 2022
23c6765
Auto merge of #8921 - Jarcho:merge_passes, r=llogiq
bors Jun 28, 2022
a4130e1
Auto merge of #8355 - Jarcho:explicit_auto_deref_2, r=flip1995
bors Jun 28, 2022
4995b4e
Auto merge of #9046 - xFrednet:rust-97660-expection-something-somethi…
bors Jun 28, 2022
27ff258
Fix height for the source sidebar in mobile mode
GuillaumeGomez Jun 29, 2022
ea97bdc
Update/add tests for source sidebar in mobile mode
GuillaumeGomez Jun 29, 2022
90227c1
Auto merge of #8981 - PrestonFrom:more_details_for_significant_drop_l…
bors Jun 29, 2022
ad970a7
Fix display of toggle on expanded source sidebar
GuillaumeGomez Jun 29, 2022
be56963
Add test for source sidebar toggle
GuillaumeGomez Jun 29, 2022
70f1d0d
Auto merge of #9043 - dswij:9037-test, r=Manishearth
bors Jun 29, 2022
58434ae
Extract util functions from `redundant_pattern_match`
Jarcho Apr 8, 2022
adbc849
Don't lint `while_let_loop` when drop order would change
Jarcho Apr 8, 2022
afd8cf2
add test for 72793
matthiaskrgr Jun 29, 2022
f60ec83
interpret: add From<&MplaceTy> for PlaceTy
RalfJung Jun 29, 2022
277b77a
Update browser-ui-test version to 0.9.7
GuillaumeGomez Jun 29, 2022
398e778
use "or pattern"
tshepang Jun 30, 2022
5d75a9b
fix
tamaroning Jun 30, 2022
88591ba
Auto merge of #8666 - Jarcho:while_let_loop_7913, r=dswij
bors Jun 30, 2022
5d9e1b6
Update large_const_arrays.rs
tamaroning Jun 30, 2022
ff3964a
Auto merge of #9068 - tamaroning:fix-typo-2022-6-30, r=giraffate,xFre…
bors Jun 30, 2022
f26cf11
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jun 30, 2022
bf9b39a
Fix dogfood
flip1995 Jun 30, 2022
d9b2e21
Bump nightly version -> 2022-06-30
flip1995 Jun 30, 2022
9de1f9f
Bump Clippy version -> 0.1.64
flip1995 Jun 30, 2022
0cb0f76
Auto merge of #9069 - flip1995:rustup, r=flip1995
bors Jun 30, 2022
721d53a
Merge commit '0cb0f7636851f9fcc57085cf80197a2ef6db098f' into clippyup
flip1995 Jun 30, 2022
5fead7a
Update Cargo.lock
flip1995 Jun 30, 2022
be580a0
Remove unneeded methods declaration for old web browsers
GuillaumeGomez Jun 30, 2022
29e0e14
rustdoc: fix 98690
pinkforest Jun 30, 2022
a3a88c7
llvm-wrapper: adapt for LLVMConstExtractValue removal
krasimirgg Jun 29, 2022
72f6322
Fix scroll when source sidebar is open on mobile
GuillaumeGomez Jun 29, 2022
9a1f52d
Add test to ensure that scroll position is kept when opening/closing …
GuillaumeGomez Jun 29, 2022
8515475
get rid of some tidy 'unnecessarily ignored' warnings
RalfJung Jun 30, 2022
15d3ea5
For diagnostic information of Boolean, remind it as use the type: 'bool'
Jun 29, 2022
3d44bc2
Rollup merge of #97629 - guswynn:exclusive_struct, r=m-ou-se
matthiaskrgr Jun 30, 2022
ce6e814
Rollup merge of #98503 - RalfJung:scope-race, r=m-ou-se
matthiaskrgr Jun 30, 2022
33fcf3c
Rollup merge of #98670 - krasimirgg:llvm-15-LLVMConstExtractValue, r=…
matthiaskrgr Jun 30, 2022
5fcd5ac
Rollup merge of #98671 - GuillaumeGomez:source-sidebar-fixes, r=notri…
matthiaskrgr Jun 30, 2022
66dff98
Rollup merge of #98677 - lyming2007:issue-98492-fix, r=lcnr
matthiaskrgr Jun 30, 2022
62d37a4
Rollup merge of #98684 - matthiaskrgr:ice-test-72793, r=oli-obk
matthiaskrgr Jun 30, 2022
bc01f2e
Rollup merge of #98688 - RalfJung:from-mplace, r=oli-obk
matthiaskrgr Jun 30, 2022
f53f1a0
Rollup merge of #98695 - tshepang:or-pattern, r=compiler-errors
matthiaskrgr Jun 30, 2022
ac94a4f
Rollup merge of #98706 - flip1995:clippyup, r=Dylan-DPC
matthiaskrgr Jun 30, 2022
eb3a012
Rollup merge of #98708 - pinkforest:rustdoc-fix-98690, r=GuillaumeGomez
matthiaskrgr Jun 30, 2022
d47c1aa
Rollup merge of #98709 - GuillaumeGomez:rm-decl-for-old-browsers, r=D…
matthiaskrgr Jun 30, 2022
15871b2
Rollup merge of #98717 - RalfJung:make-tidy-less-annoying, r=jyn514
matthiaskrgr Jun 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ dependencies = [

[[package]]
name = "clippy"
version = "0.1.63"
version = "0.1.64"
dependencies = [
"clippy_lints",
"clippy_utils",
Expand All @@ -661,6 +661,7 @@ dependencies = [
"termize",
"tester",
"tokio",
"toml",
]

[[package]]
Expand All @@ -679,10 +680,9 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.63"
version = "0.1.64"
dependencies = [
"cargo_metadata",
"clippy_dev",
"clippy_utils",
"if_chain",
"itertools",
Expand All @@ -702,7 +702,7 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.63"
version = "0.1.64"
dependencies = [
"arrayvec",
"if_chain",
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ impl<'ll> CodegenCx<'ll, '_> {
pub fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
unsafe {
assert_eq!(idx as c_uint as u64, idx);
let us = &[idx as c_uint];
let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint);
let r = llvm::LLVMGetAggregateElement(v, idx as c_uint).unwrap();

debug!("const_get_elt(v={:?}, idx={}, r={:?})", v, idx, r);

Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,11 +1134,7 @@ extern "C" {
pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
pub fn LLVMConstExtractValue(
AggConstant: &Value,
IdxList: *const c_uint,
NumIdx: c_uint,
) -> &Value;
pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;

// Operations on global variables, functions, and aliases (globals)
pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_const_eval/src/const_eval/valtrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ fn valtree_into_mplace<'tcx>(
ty::FnDef(_, _) => {
ecx.write_immediate(
Immediate::Scalar(ScalarMaybeUninit::Scalar(Scalar::ZST)),
&(*place).into(),
&place.into(),
)
.unwrap();
}
Expand All @@ -355,7 +355,7 @@ fn valtree_into_mplace<'tcx>(
debug!("writing trivial valtree {:?} to place {:?}", scalar_int, place);
ecx.write_immediate(
Immediate::Scalar(ScalarMaybeUninit::Scalar(scalar_int.into())),
&(*place).into(),
&place.into(),
)
.unwrap();
}
Expand All @@ -382,7 +382,7 @@ fn valtree_into_mplace<'tcx>(
};
debug!(?imm);

ecx.write_immediate(imm, &(*place).into()).unwrap();
ecx.write_immediate(imm, &place.into()).unwrap();
}
ty::Adt(_, _) | ty::Tuple(_) | ty::Array(_, _) | ty::Str | ty::Slice(_) => {
let branches = valtree.unwrap_branch();
Expand Down Expand Up @@ -464,11 +464,11 @@ fn valtree_into_mplace<'tcx>(

if let Some(variant_idx) = variant_idx {
// don't forget filling the place with the discriminant of the enum
ecx.write_discriminant(variant_idx, &(*place).into()).unwrap();
ecx.write_discriminant(variant_idx, &place.into()).unwrap();
}

debug!("dump of place after writing discriminant:");
dump_place(ecx, (*place).into());
dump_place(ecx, place.into());
}
_ => bug!("shouldn't have created a ValTree for {:?}", ty),
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
let tcx = self.ecx.tcx;
let ty = mplace.layout.ty;
if let ty::Ref(_, referenced_ty, ref_mutability) = *ty.kind() {
let value = self.ecx.read_immediate(&(*mplace).into())?;
let value = self.ecx.read_immediate(&mplace.into())?;
let mplace = self.ecx.ref_to_mplace(&value)?;
assert_eq!(mplace.layout.ty, referenced_ty);
// Handle trait object vtables.
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ impl<'tcx, Tag: Provenance> From<&'_ MPlaceTy<'tcx, Tag>> for OpTy<'tcx, Tag> {
}
}

impl<'tcx, Tag: Provenance> From<&'_ mut MPlaceTy<'tcx, Tag>> for OpTy<'tcx, Tag> {
#[inline(always)]
fn from(mplace: &mut MPlaceTy<'tcx, Tag>) -> Self {
OpTy { op: Operand::Indirect(**mplace), layout: mplace.layout }
}
}

impl<'tcx, Tag: Provenance> From<ImmTy<'tcx, Tag>> for OpTy<'tcx, Tag> {
#[inline(always)]
fn from(val: ImmTy<'tcx, Tag>) -> Self {
Expand Down
16 changes: 15 additions & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,21 @@ impl<'tcx, Tag: Provenance> std::ops::Deref for MPlaceTy<'tcx, Tag> {
impl<'tcx, Tag: Provenance> From<MPlaceTy<'tcx, Tag>> for PlaceTy<'tcx, Tag> {
#[inline(always)]
fn from(mplace: MPlaceTy<'tcx, Tag>) -> Self {
PlaceTy { place: Place::Ptr(mplace.mplace), layout: mplace.layout }
PlaceTy { place: Place::Ptr(*mplace), layout: mplace.layout }
}
}

impl<'tcx, Tag: Provenance> From<&'_ MPlaceTy<'tcx, Tag>> for PlaceTy<'tcx, Tag> {
#[inline(always)]
fn from(mplace: &MPlaceTy<'tcx, Tag>) -> Self {
PlaceTy { place: Place::Ptr(**mplace), layout: mplace.layout }
}
}

impl<'tcx, Tag: Provenance> From<&'_ mut MPlaceTy<'tcx, Tag>> for PlaceTy<'tcx, Tag> {
#[inline(always)]
fn from(mplace: &mut MPlaceTy<'tcx, Tag>) -> Self {
PlaceTy { place: Place::Ptr(**mplace), layout: mplace.layout }
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> Value<'mir, 'tcx, M>
&self,
_ecx: &InterpCx<'mir, 'tcx, M>,
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
Ok((*self).into())
Ok(self.into())
}

#[inline(always)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ impl HandlerInner {
self.flags.treat_err_as_bug.map(|c| c.get()).unwrap_or(0),
) {
(1, 1) => panic!("aborting due to `-Z treat-err-as-bug=1`"),
(0, _) | (1, _) => {}
(0 | 1, _) => {}
(count, as_bug) => panic!(
"aborting after {} errors due to `-Z treat-err-as-bug={}`",
count, as_bug,
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1865,3 +1865,11 @@ extern "C" void LLVMRustGetMangledName(LLVMValueRef V, RustStringRef Str) {
GlobalValue *GV = unwrap<GlobalValue>(V);
Mangler().getNameWithPrefix(OS, GV, true);
}

// LLVMGetAggregateElement was added in LLVM 15. For earlier LLVM versions just
// use its implementation.
#if LLVM_VERSION_LT(15, 0)
extern "C" LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx) {
return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
}
#endif
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
Some(match name {
"byte" => sym::u8, // In Java, bytes are signed, but in practice one almost always wants unsigned bytes.
"short" => sym::i16,
"Bool" => sym::bool,
"Boolean" => sym::bool,
"boolean" => sym::bool,
"int" => sym::i32,
"long" => sym::i64,
Expand Down
173 changes: 173 additions & 0 deletions library/core/src/sync/exclusive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
//! Defines [`Exclusive`].

use core::fmt;
use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};

/// `Exclusive` provides only _mutable_ access, also referred to as _exclusive_
/// access to the underlying value. It provides no _immutable_, or _shared_
/// access to the underlying value.
///
/// While this may seem not very useful, it allows `Exclusive` to _unconditionally_
/// implement [`Sync`]. Indeed, the safety requirements of `Sync` state that for `Exclusive`
/// to be `Sync`, it must be sound to _share_ across threads, that is, it must be sound
/// for `&Exclusive` to cross thread boundaries. By design, a `&Exclusive` has no API
/// whatsoever, making it useless, thus harmless, thus memory safe.
///
/// Certain constructs like [`Future`]s can only be used with _exclusive_ access,
/// and are often `Send` but not `Sync`, so `Exclusive` can be used as hint to the
/// rust compiler that something is `Sync` in practice.
///
/// ## Examples
/// Using a non-`Sync` future prevents the wrapping struct from being `Sync`
/// ```compile_fail
/// use core::cell::Cell;
///
/// async fn other() {}
/// fn assert_sync<T: Sync>(t: T) {}
/// struct State<F> {
/// future: F
/// }
///
/// assert_sync(State {
/// future: async {
/// let cell = Cell::new(1);
/// let cell_ref = &cell;
/// other().await;
/// let value = cell_ref.get();
/// }
/// });
/// ```
///
/// `Exclusive` ensures the struct is `Sync` without stripping the future of its
/// functionality.
/// ```
/// #![feature(exclusive_wrapper)]
/// use core::cell::Cell;
/// use core::sync::Exclusive;
///
/// async fn other() {}
/// fn assert_sync<T: Sync>(t: T) {}
/// struct State<F> {
/// future: Exclusive<F>
/// }
///
/// assert_sync(State {
/// future: Exclusive::new(async {
/// let cell = Cell::new(1);
/// let cell_ref = &cell;
/// other().await;
/// let value = cell_ref.get();
/// })
/// });
/// ```
///
/// ## Parallels with a mutex
/// In some sense, `Exclusive` can be thought of as a _compile-time_ version of
/// a mutex, as the borrow-checker guarantees that only one `&mut` can exist
/// for any value. This is a parallel with the fact that
/// `&` and `&mut` references together can be thought of as a _compile-time_
/// version of a read-write lock.
///
///
/// [`Sync`]: core::marker::Sync
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
#[doc(alias = "SyncWrapper")]
#[doc(alias = "SyncCell")]
#[doc(alias = "Unique")]
// `Exclusive` can't have `PartialOrd`, `Clone`, etc. impls as they would
// use `&` access to the inner value, violating the `Sync` impl's safety
// requirements.
#[derive(Default)]
#[repr(transparent)]
pub struct Exclusive<T: ?Sized> {
inner: T,
}

// See `Exclusive`'s docs for justification.
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
unsafe impl<T: ?Sized> Sync for Exclusive<T> {}

#[unstable(feature = "exclusive_wrapper", issue = "98407")]
impl<T: ?Sized> fmt::Debug for Exclusive<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
f.debug_struct("Exclusive").finish_non_exhaustive()
}
}

impl<T: Sized> Exclusive<T> {
/// Wrap a value in an `Exclusive`
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
#[must_use]
pub const fn new(t: T) -> Self {
Self { inner: t }
}

/// Unwrap the value contained in the `Exclusive`
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
#[must_use]
pub const fn into_inner(self) -> T {
self.inner
}
}

impl<T: ?Sized> Exclusive<T> {
/// Get exclusive access to the underlying value.
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
#[must_use]
pub const fn get_mut(&mut self) -> &mut T {
&mut self.inner
}

/// Get pinned exclusive access to the underlying value.
///
/// `Exclusive` is considered to _structurally pin_ the underlying
/// value, which means _unpinned_ `Exclusive`s can produce _unpinned_
/// access to the underlying value, but _pinned_ `Exclusive`s only
/// produce _pinned_ access to the underlying value.
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
#[must_use]
pub const fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
// SAFETY: `Exclusive` can only produce `&mut T` if itself is unpinned
// `Pin::map_unchecked_mut` is not const, so we do this conversion manually
unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().inner) }
}

/// Build a _mutable_ references to an `Exclusive<T>` from
/// a _mutable_ reference to a `T`. This allows you to skip
/// building an `Exclusive` with [`Exclusive::new`].
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
#[must_use]
pub const fn from_mut(r: &'_ mut T) -> &'_ mut Exclusive<T> {
// SAFETY: repr is ≥ C, so refs have the same layout; and `Exclusive` properties are `&mut`-agnostic
unsafe { &mut *(r as *mut T as *mut Exclusive<T>) }
}

/// Build a _pinned mutable_ references to an `Exclusive<T>` from
/// a _pinned mutable_ reference to a `T`. This allows you to skip
/// building an `Exclusive` with [`Exclusive::new`].
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
#[must_use]
pub const fn from_pin_mut(r: Pin<&'_ mut T>) -> Pin<&'_ mut Exclusive<T>> {
// SAFETY: `Exclusive` can only produce `&mut T` if itself is unpinned
// `Pin::map_unchecked_mut` is not const, so we do this conversion manually
unsafe { Pin::new_unchecked(Self::from_mut(r.get_unchecked_mut())) }
}
}

#[unstable(feature = "exclusive_wrapper", issue = "98407")]
impl<T> From<T> for Exclusive<T> {
fn from(t: T) -> Self {
Self::new(t)
}
}

#[unstable(feature = "exclusive_wrapper", issue = "98407")]
impl<T: Future + ?Sized> Future for Exclusive<T> {
type Output = T::Output;

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.get_pin_mut().poll(cx)
}
}
3 changes: 3 additions & 0 deletions library/core/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#![stable(feature = "rust1", since = "1.0.0")]

pub mod atomic;
mod exclusive;
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
pub use exclusive::Exclusive;
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
#![feature(duration_checked_float)]
#![feature(duration_constants)]
#![feature(exact_size_is_empty)]
#![feature(exclusive_wrapper)]
#![feature(extend_one)]
#![feature(float_minimum_maximum)]
#![feature(hasher_prefixfree_extras)]
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
pub use alloc_crate::sync::{Arc, Weak};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::sync::atomic;
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
pub use core::sync::Exclusive;

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::barrier::{Barrier, BarrierWaitResult};
Expand Down
Loading