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 9 pull requests #122850

Closed
wants to merge 166 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
a4b413d
Add asm label support to AST and HIR
nbdd0121 Dec 25, 2023
dbfbd0e
feat: add `const_is_empty` lint
samueltardieu Feb 19, 2024
89b334d
chore: update some tests to allow `const_is_empty`
samueltardieu Feb 18, 2024
2884970
feat: extend `const_is_empty` with many kinds of constants
samueltardieu Feb 19, 2024
1159e2c
feat: add more tests for the `const_is_empty` lint
samueltardieu Feb 19, 2024
898ed88
feat: make `const_is_empty` lint ignore external constants
samueltardieu Feb 26, 2024
301d293
Move `iter_nth` to `style`, add machine applicable suggestion
Alexendoo Mar 4, 2024
865ac89
Use `rustc_driver::args::raw_args()` in Clippy
beetrees May 15, 2023
a9858da
Fix dependency specifications
sanxiyn Mar 7, 2024
7e83df4
Merge commit '93f0a9a91f58c9b2153868f458402155fb6265bb' into clippy-s…
flip1995 Mar 7, 2024
43f4ec3
[`unused_enumerate_index`]: Use if-let chain
Ethiraric Mar 7, 2024
f3879b3
[`use_self`]: Make it aware of lifetimes
Ethiraric Feb 29, 2024
3a6cac7
add `rewrite_struct` proc-macro and test case
J-ZhengLi Mar 8, 2024
55b757e
Merge from rustc
Mar 8, 2024
1572279
Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu
matthiaskrgr Mar 8, 2024
adc91e4
support manually search for docs in case attr was removed by proc macros
J-ZhengLi Mar 8, 2024
0b4b684
Auto merge of #12433 - J-ZhengLi:issue12197, r=dswij
bors Mar 8, 2024
1bd7383
Rollup merge of #121194 - beetrees:rustc-raw-args, r=petrochenkov
matthiaskrgr Mar 8, 2024
158b70a
Distinguish between library and lang UB in assert_unsafe_precondition
saethlin Feb 27, 2024
2dd085f
Allow lint where we don't care
Nadrieril Jan 17, 2024
4e95b4a
[`mut_mut`]: Fix duplicate diags
cookie-s Mar 9, 2024
6890407
Auto merge of #118879 - Nadrieril:lint-range-gap, r=estebank
bors Mar 9, 2024
7473f05
[`no_effect_replace`]: Fix duplicate diagnostics
cookie-s Mar 9, 2024
8d78cd1
Fix duplicate lint emission from [`else_if_without_else`]
CBSpeir Mar 9, 2024
4d15a75
Merge from rustc
Mar 9, 2024
453242c
Auto merge of #12310 - samueltardieu:issue-12307, r=xFrednet
bors Mar 9, 2024
f34804d
Add new `duplicated_attributes` lint
GuillaumeGomez Feb 28, 2024
749e225
Add ui test for new `duplicated_attributes` lint
GuillaumeGomez Feb 28, 2024
d57d001
Update `cargo dev update_lints` command to fix new warning emitted by…
GuillaumeGomez Feb 28, 2024
ae52a9d
Update ui tests
GuillaumeGomez Feb 28, 2024
fa4e3aa
add documentation to the `span_lint_hir` functions
y21 Mar 8, 2024
099e2c0
Auto merge of #12443 - cookie-s:noeffectreoplace-fix-dup-diags, r=Ale…
bors Mar 9, 2024
b2f9c4c
Auto merge of #12442 - cookie-s:fix-mutmut-duplicate-diags, r=y21
bors Mar 9, 2024
ced8bc5
use `span_lint_hir` instead of `span_lint` in more lints
y21 Mar 9, 2024
c173ea6
Auto merge of #12446 - y21:check_fn_span_lint, r=xFrednet
bors Mar 9, 2024
b44ab66
Fix #12438 false positive regression
MarcusGrass Mar 9, 2024
eb5ce85
mention `span_lint_hir` in `span_lint` and add a reason to disallowed…
y21 Mar 9, 2024
0e59259
add new lint `zero_repeat_side_effects`
Jacherr Dec 10, 2023
0c82fd0
fix example code
Jacherr Mar 9, 2024
d8a9068
Auto merge of #12449 - Jacherr:issue-6439, r=llogiq
bors Mar 9, 2024
7ee75f8
Auto merge of #12447 - MarcusGrass:mg/fix-12438-regression, r=y21
bors Mar 9, 2024
5b1f95c
apply review suggestions
y21 Mar 9, 2024
a92037f
[`option_option`]: Fix duplicate diagnostics
cookie-s Mar 9, 2024
1abf441
Add new `match_option_and_default` lint
GuillaumeGomez Mar 8, 2024
fadb254
Add new ui test for `match_option_and_default`
GuillaumeGomez Mar 8, 2024
b0f358f
Update ui test
GuillaumeGomez Mar 8, 2024
98ac5f1
Rename into `manual_unwrap_or_default`
GuillaumeGomez Mar 10, 2024
ed6e629
Fix duplicate lint emission from [manual_retain]
CBSpeir Mar 10, 2024
45f87a0
Auto merge of #121662 - saethlin:precondition-unification, r=RalfJung
bors Mar 10, 2024
6d80398
Merge from rustc
Mar 10, 2024
1847904
Auto merge of #122246 - RalfJung:miri, r=RalfJung
bors Mar 10, 2024
81debac
Auto merge of #12440 - GuillaumeGomez:add-match_option_and_default, r…
bors Mar 10, 2024
86717f2
Auto merge of #12445 - y21:document-diagnostic-utils, r=xFrednet
bors Mar 10, 2024
6c863bc
Remove unused structs in clippy
mu001999 Feb 29, 2024
8e55bbf
[`single_match`]: Fix duplicate diagnostics
WeiTheShinobi Mar 9, 2024
9c51fd9
refactor: readability improvement for `seek` lint
hamirmahal Mar 10, 2024
02156dc
Auto merge of #12458 - hamirmahal:refactor/readability-improvement, r…
bors Mar 11, 2024
6ff4e71
Auto merge of #12448 - WeiTheShinobi:fix_single_match, r=dswij
bors Mar 11, 2024
870e016
Auto merge of #12430 - sanxiyn:direct-minimal-versions, r=Alexendoo
bors Mar 11, 2024
d66a0ec
Fix typo in section '6.10. Macro Expansions' of the Clippy Book
CBSpeir Mar 11, 2024
f685a4b
Auto merge of #12378 - GuillaumeGomez:duplicated_attr, r=blyxyas
bors Mar 11, 2024
e22ca03
Auto merge of #12452 - CBSpeir:dedup-manual-retain, r=blyxyas
bors Mar 11, 2024
100ab49
new restriction lint: `division_remainder_used`
Jacherr Mar 10, 2024
edcf10e
update_lints
Jacherr Mar 11, 2024
10677d6
add `with_empty_docs` attr macro & test cases for issue #12377
J-ZhengLi Mar 12, 2024
3cd6fd1
fix [`empty_docs`] trigger in proc-macro
J-ZhengLi Mar 12, 2024
25fb1f0
Merge from rustc
Mar 12, 2024
b205192
Change `DefKind::Static` to a struct variant
oli-obk Feb 23, 2024
013bf92
Add `nested` bool to `DefKind::Static`.
oli-obk Feb 23, 2024
97f2ade
s/mt/mutability/
oli-obk Mar 11, 2024
f472b50
chore: fix some typos
pavedroad Mar 12, 2024
27c49e1
filetime::FileTime::now() is new in 0.2.9
sanxiyn Mar 12, 2024
60f7f06
Auto merge of #12462 - CBSpeir:clippy-book-typo, r=flip1995
bors Mar 12, 2024
a8a7371
Auto merge of #12417 - Alexendoo:iter-nth, r=flip1995
bors Mar 12, 2024
3a14911
Auto merge of #12469 - pavedroad:master, r=y21
bors Mar 12, 2024
244d7da
[`cast_lossless`]: Suggest type alias instead of the aliased type
Centri3 Aug 2, 2023
92ca7c9
Auto merge of #11287 - Centri3:#11285, r=llogiq
bors Mar 12, 2024
99e8000
Auto merge of #12466 - J-ZhengLi:issue12377, r=blyxyas
bors Mar 12, 2024
65defdb
[`unconditional_recursion`]: catch `From` -> `Into` -> `From`
y21 Mar 10, 2024
11c2bad
CI: replace `cancel-outdated-builds` with `concurrency` groupo
Kobzol Mar 13, 2024
73be486
Auto merge of #12459 - y21:unconditional_recursion_from_into, r=Jarcho
bors Mar 13, 2024
11759d1
Don't emit `doc_markdown` lint for missing backticks if it's inside a…
GuillaumeGomez Mar 12, 2024
cd36b25
Add regression test for #10262
GuillaumeGomez Mar 12, 2024
03d7ae8
Also handle `<blockquote>` and `<q>` HTML tags
GuillaumeGomez Mar 13, 2024
660b058
Auto merge of #12470 - sanxiyn:filetime, r=Alexendoo
bors Mar 13, 2024
7cdeac5
[`unused_enumerate_index`]: trigger on method calls
Ethiraric Mar 7, 2024
adcbb4a
move readonly_write_lock to perf
y21 Mar 13, 2024
1fe8844
fix [`dbg_macro`] FN when `dbg` is inside some complex macros
J-ZhengLi Jan 15, 2024
0535f55
lint nested `dbg!` macros, split tests
J-ZhengLi Feb 20, 2024
fe4e0ac
checks `dbg` inside other macros as well (but no ext macro);
J-ZhengLi Mar 6, 2024
20e4c74
Handle false positive with map_clone
maekawatoshiki Feb 12, 2024
560a5a8
Fix logic
maekawatoshiki Feb 13, 2024
c5d3b62
Fix conflict
maekawatoshiki Mar 14, 2024
5f8d8f1
Simplify logic
maekawatoshiki Mar 14, 2024
a75e271
Auto merge of #12282 - maekawatoshiki:fix, r=xFrednet
bors Mar 14, 2024
e77d7a3
Auto merge of #12477 - Kobzol:ci-concurrency-group, r=flip1995
bors Mar 14, 2024
da2795f
Rename `ast::StmtKind::Local` into `ast::StmtKind::Let`
GuillaumeGomez Mar 14, 2024
0e2897f
Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`
GuillaumeGomez Mar 14, 2024
22577e5
Merge from rustc
Mar 14, 2024
8a78128
Auto merge of #12386 - Ethiraric:fix-12381, r=blyxyas
bors Mar 14, 2024
f55a049
hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`
petrochenkov Mar 14, 2024
b667d02
Auto merge of #12472 - GuillaumeGomez:fix-10262, r=blyxyas
bors Mar 14, 2024
dadcd94
[`unused_enumerate_index`]: Keep explicit element type
Ethiraric Mar 13, 2024
5a11fef
Auto merge of #12432 - Ethiraric:fix-12411, r=y21
bors Mar 14, 2024
d3f8f3e
fix span calculation for non-ascii in `needless_return`
y21 Mar 15, 2024
1e30c29
Rollup merge of #122513 - petrochenkov:somehir4, r=fmease
GuillaumeGomez Mar 15, 2024
c9f2482
Auto merge of #12493 - y21:issue12491, r=Alexendoo
bors Mar 15, 2024
9408c59
[`option_option`]: Use span.from_expansion
cookie-s Mar 16, 2024
4e72ca3
[`map_entry`]: call the visitor on the local's `else` block
y21 Mar 16, 2024
59a5ad4
Auto merge of #12441 - CBSpeir:dedup-else-if-without-else, r=dswij
bors Mar 16, 2024
12ecaa8
Auto merge of #12482 - J-ZhengLi:issue12131, r=Jarcho
bors Mar 17, 2024
67fa36a
Auto merge of #12479 - y21:readonly_write_lock_perf, r=Jarcho
bors Mar 17, 2024
d202eb6
Auto merge of #12450 - cookie-s:fix-optopt-duplicate-diags, r=llogiq
bors Mar 17, 2024
e9a50f2
Auto merge of #12451 - Jacherr:issue-12391, r=llogiq
bors Mar 17, 2024
b5dcaae
Auto merge of #12498 - y21:issue12489, r=blyxyas
bors Mar 18, 2024
003c4bc
Avoid various uses of `Option<Span>` in favor of using `DUMMY_SP` in …
oli-obk Mar 14, 2024
8339474
When displaying multispans, ignore empty lines adjacent to `...`
estebank Mar 5, 2024
0dc8769
Deduplicate `associated_body` and `body_id`
oli-obk Mar 5, 2024
83af0e5
Update version attribute for 1.77 lints
xFrednet Mar 18, 2024
87d45e5
Changelog for Clippy 1.77 :school:
xFrednet Mar 18, 2024
56288a7
Auto merge of #122021 - oli-obk:delangitemification, r=compiler-errors
bors Mar 19, 2024
e7c3e04
chore: fix typo
goodmost Mar 19, 2024
3f338b3
Auto merge of #12510 - goodmost:master, r=Alexendoo
bors Mar 19, 2024
21a97f0
Specify an MSRV of 1.63.0 for assigning_clones
humannum14916 Mar 19, 2024
8c866d3
Add test for MSRV checking for assigning_clones
humannum14916 Mar 19, 2024
7c0b2dd
Add assigning_clones to MSRV config option docs
humannum14916 Mar 19, 2024
76096ef
Auto merge of #122029 - estebank:drive-by-ui-test, r=oli-obk
bors Mar 19, 2024
89aba8d
Auto merge of #12511 - humannum14916:assigning_clones_msrv, r=Alexendoo
bors Mar 19, 2024
477108d
FP: `cast_lossless`: disable lint when casting to (u)128 from any (u)…
Jacherr Mar 15, 2024
5f7b3c5
Only enforce MSRV check on .clone_into() suggestions
humannum14916 Mar 20, 2024
db7c9fe
Add UI test for new MSRV check
humannum14916 Mar 20, 2024
19cb05f
std::net: adding acceptfilter feature for netbsd/freebsd.
devnexen Mar 2, 2024
5b7efe8
Auto merge of #12516 - humannum14916:assigning_clones_msrv, r=Alexendoo
bors Mar 20, 2024
34766a6
Auto merge of #12496 - Jacherr:issue-12492, r=blyxyas
bors Mar 20, 2024
a16a9ed
Auto merge of #12509 - xFrednet:changelog-1-77, r=dswij
bors Mar 20, 2024
f6f89dc
BTree(Set|Map): Guarantee that `IntoIter` will iterate in sorted by k…
ultrabear Mar 21, 2024
f8a093c
document iteration ordering on into_iter method instead of IntoIterat…
ultrabear Mar 21, 2024
beb0c22
document into_iter in top level docs iterator ordering guarantees
ultrabear Mar 21, 2024
8ca7aac
Add tests for shortcomings of associated type bounds
compiler-errors Mar 21, 2024
e505408
Add xFrednet back to the reviewing rotation
xFrednet Mar 21, 2024
32799a5
Auto merge of #12520 - xFrednet:lets-review-again, r=xFrednet
bors Mar 21, 2024
796105e
make failure logs less verbose
onur-ozkan Mar 21, 2024
ae4c5c8
Implement `FusedIterator` for `gen` block
ShoyuVanilla Mar 21, 2024
238cd36
Fix documentation typo "appects" > "affects"
Rua Mar 21, 2024
443f459
Auto merge of #12523 - Rua:typo-fix, r=dswij
bors Mar 21, 2024
daa6553
add test for #122549
matthiaskrgr Mar 21, 2024
453676f
Split out ImplPolarity and PredicatePolarity
compiler-errors Mar 21, 2024
76ad048
Use != Positive rather than == Negative
compiler-errors Mar 21, 2024
08d8cd5
Fix clippy
compiler-errors Mar 21, 2024
dae3c43
Further simplifications
compiler-errors Mar 21, 2024
c00920c
Avoid noop rewrite of issues.txt
workingjubilee Mar 21, 2024
7d42d73
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Mar 21, 2024
bb86654
Bump nightly version -> 2024-03-21
flip1995 Mar 21, 2024
e1d15b5
Bump Clippy version -> 0.1.79
flip1995 Mar 21, 2024
9d6f416
Auto merge of #12527 - flip1995:rustup, r=flip1995
bors Mar 21, 2024
5a82d16
Merge commit '9d6f41691ed9dbfaec2a2df2661c42451f2fe0d3' into clippy-s…
flip1995 Mar 21, 2024
8e53d53
Update Cargo.lock
flip1995 Mar 21, 2024
90968ec
Rollup merge of #121881 - devnexen:bsd_acceptfilter, r=Amanieu
matthiaskrgr Mar 21, 2024
e4ee362
Rollup merge of #122817 - ultrabear:ultrabear_btreedoc, r=Nilstrieb
matthiaskrgr Mar 21, 2024
63040a4
Rollup merge of #122826 - compiler-errors:associated-type-bound-tests…
matthiaskrgr Mar 21, 2024
f3d3e00
Rollup merge of #122829 - ShoyuVanilla:gen-block-impl-fused-iter, r=c…
matthiaskrgr Mar 21, 2024
b40dc4a
Rollup merge of #122831 - onur-ozkan:less-verbose-fail-logs, r=clubby789
matthiaskrgr Mar 21, 2024
0e2bb92
Rollup merge of #122837 - matthiaskrgr:fix_122549, r=petrochenkov
matthiaskrgr Mar 21, 2024
70c095e
Rollup merge of #122838 - workingjubilee:less-catholic-blessings-to-p…
matthiaskrgr Mar 21, 2024
e6da4a8
Rollup merge of #122839 - compiler-errors:predicate-polarity, r=lcnr
matthiaskrgr Mar 21, 2024
0a7659e
Rollup merge of #122845 - flip1995:clippy-subtree-update, r=matthiaskrgr
matthiaskrgr Mar 21, 2024
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
12 changes: 6 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"

[[package]]
name = "clippy"
version = "0.1.78"
version = "0.1.79"
dependencies = [
"anstream",
"clippy_config",
Expand Down Expand Up @@ -602,7 +602,7 @@ dependencies = [

[[package]]
name = "clippy_config"
version = "0.1.78"
version = "0.1.79"
dependencies = [
"rustc-semver",
"serde",
Expand All @@ -625,7 +625,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.78"
version = "0.1.79"
dependencies = [
"arrayvec",
"cargo_metadata 0.18.1",
Expand All @@ -650,7 +650,7 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.78"
version = "0.1.79"
dependencies = [
"arrayvec",
"clippy_config",
Expand Down Expand Up @@ -971,7 +971,7 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"

[[package]]
name = "declare_clippy_lint"
version = "0.1.78"
version = "0.1.79"
dependencies = [
"itertools 0.12.1",
"quote",
Expand Down Expand Up @@ -2205,7 +2205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
dependencies = [
"cfg-if",
"windows-targets 0.52.4",
"windows-targets 0.48.5",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
) {
self.prove_predicate(
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Trait(
ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Positive },
ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive },
))),
locations,
category,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ language_item_table! {
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None;

Iterator, sym::iterator, iterator_trait, Target::Trait, GenericRequirement::Exact(0);
FusedIterator, sym::fused_iterator, fused_iterator_trait, Target::Trait, GenericRequirement::Exact(0);
Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
AsyncIterator, sym::async_iterator, async_iterator_trait, Target::Trait, GenericRequirement::Exact(0);

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/astconv/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
let (constness, polarity) = match modifier {
hir::TraitBoundModifier::Const => {
(ty::BoundConstness::Const, ty::ImplPolarity::Positive)
(ty::BoundConstness::Const, ty::PredicatePolarity::Positive)
}
hir::TraitBoundModifier::MaybeConst => {
(ty::BoundConstness::ConstIfConst, ty::ImplPolarity::Positive)
(ty::BoundConstness::ConstIfConst, ty::PredicatePolarity::Positive)
}
hir::TraitBoundModifier::None => {
(ty::BoundConstness::NotConst, ty::ImplPolarity::Positive)
(ty::BoundConstness::NotConst, ty::PredicatePolarity::Positive)
}
hir::TraitBoundModifier::Negative => {
(ty::BoundConstness::NotConst, ty::ImplPolarity::Negative)
(ty::BoundConstness::NotConst, ty::PredicatePolarity::Negative)
}
hir::TraitBoundModifier::Maybe => continue,
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
trait_ref: &hir::TraitRef<'tcx>,
span: Span,
constness: ty::BoundConstness,
polarity: ty::ImplPolarity,
polarity: ty::PredicatePolarity,
self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>,
only_self_bounds: OnlySelfBounds,
Expand Down Expand Up @@ -682,7 +682,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
// Don't register additional associated type bounds for negative bounds,
// since we should have emitten an error for them earlier, and they will
// not be well-formed!
if polarity == ty::ImplPolarity::Negative {
if polarity != ty::PredicatePolarity::Positive {
assert!(
self.tcx().dcx().has_errors().is_some(),
"negative trait bounds should not have bindings",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/astconv/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
&trait_bound.trait_ref,
trait_bound.span,
ty::BoundConstness::NotConst,
ty::ImplPolarity::Positive,
ty::PredicatePolarity::Positive,
dummy_self,
&mut bounds,
// True so we don't populate `bounds` with associated type bounds, even
Expand All @@ -58,7 +58,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
let bound_pred = pred.kind();
match bound_pred.skip_binder() {
ty::ClauseKind::Trait(trait_pred) => {
assert_eq!(trait_pred.polarity, ty::ImplPolarity::Positive);
assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
trait_bounds.push((bound_pred.rebind(trait_pred.trait_ref), span));
}
ty::ClauseKind::Projection(proj) => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'tcx> Bounds<'tcx> {
tcx: TyCtxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
span: Span,
polarity: ty::ImplPolarity,
polarity: ty::PredicatePolarity,
) {
self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
}
Expand All @@ -52,7 +52,7 @@ impl<'tcx> Bounds<'tcx> {
tcx: TyCtxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
span: Span,
polarity: ty::ImplPolarity,
polarity: ty::PredicatePolarity,
) {
self.clauses.push((
trait_ref
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ fn check_impl<'tcx>(
trait_ref,
);
let trait_pred =
ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Positive };
ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive };
let mut obligations = traits::wf::trait_obligations(
wfcx.infcx,
wfcx.param_env,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ fn infringing_fields_error(
}
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
trait_ref,
polarity: ty::ImplPolarity::Positive,
polarity: ty::PredicatePolarity::Positive,
..
})) = error_predicate.kind().skip_binder()
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ pub(super) fn implied_predicates_with_filter(
for &(pred, span) in implied_bounds {
debug!("superbound: {:?}", pred);
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
&& bound.polarity == ty::ImplPolarity::Positive
&& bound.polarity == ty::PredicatePolarity::Positive
{
tcx.at(span).super_predicates_of(bound.def_id());
}
Expand All @@ -634,7 +634,7 @@ pub(super) fn implied_predicates_with_filter(
for &(pred, span) in implied_bounds {
debug!("superbound: {:?}", pred);
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
&& bound.polarity == ty::ImplPolarity::Positive
&& bound.polarity == ty::PredicatePolarity::Positive
{
tcx.at(span).implied_predicates_of(bound.def_id());
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
cause.clone().derived_cause(
ty::Binder::dummy(ty::TraitPredicate {
trait_ref: impl_trait_ref,
polarity: ty::ImplPolarity::Positive,
polarity: ty::PredicatePolarity::Positive,
}),
|derived| {
traits::ImplDerivedObligation(Box::new(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match pred.kind().skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
Some(pred.def_id()) == self.tcx.lang_items().sized_trait()
&& pred.polarity == ty::ImplPolarity::Positive
&& pred.polarity == ty::PredicatePolarity::Positive
}
_ => false,
}
Expand Down Expand Up @@ -3367,7 +3367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
"inherent impls can't be candidates, only trait impls can be",
)
})
.filter(|header| header.polarity == ty::ImplPolarity::Negative)
.filter(|header| header.polarity != ty::ImplPolarity::Positive)
.any(|header| {
let imp = header.trait_ref.instantiate_identity();
let imp_simp =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl<T> Trait<T> for X {
.any(|(pred, _span)| match pred.kind().skip_binder() {
ty::ClauseKind::Trait(trait_predicate)
if trait_predicate.polarity
== ty::ImplPolarity::Positive =>
== ty::PredicatePolarity::Positive =>
{
trait_predicate.def_id() == def_id
}
Expand Down Expand Up @@ -420,7 +420,7 @@ impl<T> Trait<T> for X {
else {
continue;
};
if trait_predicate.polarity != ty::ImplPolarity::Positive {
if trait_predicate.polarity != ty::PredicatePolarity::Positive {
continue;
}
let def_id = trait_predicate.def_id();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<'tcx> FulfillmentError<'tcx> {
}

impl<'tcx> PolyTraitObligation<'tcx> {
pub fn polarity(&self) -> ty::ImplPolarity {
pub fn polarity(&self) -> ty::PredicatePolarity {
self.predicate.skip_binder().polarity
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
match bound_clause.skip_binder() {
ty::ClauseKind::Trait(data) => {
// Negative trait bounds do not imply any supertrait bounds
if data.polarity == ty::ImplPolarity::Negative {
if data.polarity != ty::PredicatePolarity::Positive {
return;
}
// Get predicates implied by the trait, or only super predicates if we only care about self predicates.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ fn type_implements_negative_copy_modulo_regions<'tcx>(
param_env: ty::ParamEnv<'tcx>,
) -> bool {
let trait_ref = ty::TraitRef::new(tcx, tcx.require_lang_item(hir::LangItem::Copy, None), [ty]);
let pred = ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Negative };
let pred = ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Negative };
let obligation = traits::Obligation {
cause: traits::ObligationCause::dummy(),
param_env,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use crate::traits::solve::{
use crate::ty::{
self, AdtDef, AdtDefData, AdtKind, Binder, Clause, Const, ConstData, GenericParamDefKind,
ImplPolarity, List, ParamConst, ParamTy, PolyExistentialPredicate, PolyFnSig, Predicate,
PredicateKind, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVid,
TypeVisitable, Visibility,
PredicateKind, PredicatePolarity, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty,
TyKind, TyVid, TypeVisitable, Visibility,
};
use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
use rustc_ast::{self as ast, attr};
Expand Down Expand Up @@ -1526,7 +1526,7 @@ macro_rules! nop_slice_lift {
nop_slice_lift! {ty::ValTree<'a> => ty::ValTree<'tcx>}

TrivialLiftImpls! {
ImplPolarity, Promoted
ImplPolarity, PredicatePolarity, Promoted
}

macro_rules! sty_debug_print {
Expand Down Expand Up @@ -1833,7 +1833,7 @@ impl<'tcx> TyCtxt<'tcx> {
return false;
};
trait_predicate.trait_ref.def_id == future_trait
&& trait_predicate.polarity == ImplPolarity::Positive
&& trait_predicate.polarity == PredicatePolarity::Positive
})
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<T> ExpectedFound<T> {
pub enum TypeError<'tcx> {
Mismatch,
ConstnessMismatch(ExpectedFound<ty::BoundConstness>),
PolarityMismatch(ExpectedFound<ty::ImplPolarity>),
PolarityMismatch(ExpectedFound<ty::PredicatePolarity>),
UnsafetyMismatch(ExpectedFound<hir::Unsafety>),
AbiMismatch(ExpectedFound<abi::Abi>),
Mutability,
Expand Down
34 changes: 27 additions & 7 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,43 @@ pub enum ImplPolarity {
Reservation,
}

impl ImplPolarity {
impl fmt::Display for ImplPolarity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Positive => f.write_str("positive"),
Self::Negative => f.write_str("negative"),
Self::Reservation => f.write_str("reservation"),
}
}
}

/// Polarity for a trait predicate. May either be negative or positive.
/// Distinguished from [`ImplPolarity`] since we never compute goals with
/// "reservation" level.
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable, Debug)]
#[derive(TypeFoldable, TypeVisitable)]
pub enum PredicatePolarity {
/// `Type: Trait`
Positive,
/// `Type: !Trait`
Negative,
}

impl PredicatePolarity {
/// Flips polarity by turning `Positive` into `Negative` and `Negative` into `Positive`.
pub fn flip(&self) -> Option<ImplPolarity> {
pub fn flip(&self) -> PredicatePolarity {
match self {
ImplPolarity::Positive => Some(ImplPolarity::Negative),
ImplPolarity::Negative => Some(ImplPolarity::Positive),
ImplPolarity::Reservation => None,
PredicatePolarity::Positive => PredicatePolarity::Negative,
PredicatePolarity::Negative => PredicatePolarity::Positive,
}
}
}

impl fmt::Display for ImplPolarity {
impl fmt::Display for PredicatePolarity {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Positive => f.write_str("positive"),
Self::Negative => f.write_str("negative"),
Self::Reservation => f.write_str("reservation"),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/ty/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::cmp::Ordering;
use crate::ty::visit::TypeVisitableExt;
use crate::ty::{
self, AliasTy, Binder, DebruijnIndex, DebugWithInfcx, EarlyBinder, GenericArg, GenericArgs,
GenericArgsRef, ImplPolarity, Term, Ty, TyCtxt, TypeFlags, WithCachedTypeInfo,
GenericArgsRef, PredicatePolarity, Term, Ty, TyCtxt, TypeFlags, WithCachedTypeInfo,
};

pub type ClauseKind<'tcx> = IrClauseKind<TyCtxt<'tcx>>;
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'tcx> Predicate<'tcx> {
polarity,
})) => Some(PredicateKind::Clause(ClauseKind::Trait(TraitPredicate {
trait_ref,
polarity: polarity.flip()?,
polarity: polarity.flip(),
}))),

_ => None,
Expand Down Expand Up @@ -663,7 +663,7 @@ pub struct TraitPredicate<'tcx> {
/// exist via a series of predicates.)
///
/// If polarity is Reserved: that's a bug.
pub polarity: ImplPolarity,
pub polarity: PredicatePolarity,
}

pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>;
Expand Down Expand Up @@ -693,7 +693,7 @@ impl<'tcx> PolyTraitPredicate<'tcx> {
}

#[inline]
pub fn polarity(self) -> ImplPolarity {
pub fn polarity(self) -> PredicatePolarity {
self.skip_binder().polarity
}
}
Expand Down Expand Up @@ -907,7 +907,7 @@ impl<'tcx> ToPredicate<'tcx> for TraitRef<'tcx> {
impl<'tcx> ToPredicate<'tcx, TraitPredicate<'tcx>> for TraitRef<'tcx> {
#[inline(always)]
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> TraitPredicate<'tcx> {
TraitPredicate { trait_ref: self, polarity: ImplPolarity::Positive }
TraitPredicate { trait_ref: self, polarity: PredicatePolarity::Positive }
}
}

Expand Down Expand Up @@ -940,7 +940,7 @@ impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef
fn to_predicate(self, _: TyCtxt<'tcx>) -> PolyTraitPredicate<'tcx> {
self.map_bound(|trait_ref| TraitPredicate {
trait_ref,
polarity: ty::ImplPolarity::Positive,
polarity: ty::PredicatePolarity::Positive,
})
}
}
Expand Down
Loading
Loading