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 11 pull requests #120852

Merged
merged 114 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
b587871
Simplify `get_enclosing_loop_or_multi_call_closure`
Jarcho Nov 15, 2023
cdc4c69
Make `expr_use_ctxt` always return `Some` unless the syntax context c…
Jarcho Nov 15, 2023
57dd25e
FP: `needless_return_with_question_mark` with implicit Error Conversion
m-rph Dec 26, 2023
090c228
Fix/Issue11932: assert* in multi-condition after unrolling will cause…
cocodery Jan 3, 2024
b5a2192
fix: incorrect suggestions generated by `manual_retain` lint
yuxqiu Jan 3, 2024
03b3a16
test: add more test cases
yuxqiu Jan 4, 2024
bd6e920
modify check that any macros will be ingored in this lint, and add test
cocodery Jan 6, 2024
e0228ee
Fixes FP in `redundant_closure_call` when closures are passed to macros
m-rph Jan 3, 2024
3b8f62f
Add new `unnecessary_result_map_or_else` lint
GuillaumeGomez Jan 18, 2024
32bbeba
Add ui test for `unnecessary_result_map_or_else`
GuillaumeGomez Jan 18, 2024
e86da9e
Update CHANGELOG
GuillaumeGomez Jan 18, 2024
0b6cf3b
We don't look into static items anymore during const prop
oli-obk Jan 8, 2024
99d8d33
remove StructuralEq trait
RalfJung Sep 26, 2023
9cbc582
Rename the unescaping functions.
nnethercote Jan 24, 2024
e456c28
Don't warn about modulo arithmetic when comparing to zero
mdm Jan 19, 2024
58de630
Remove an unused error count check
oli-obk Jan 25, 2024
798865c
Merge commit '66c29b973b3b10278bd39f4e26b08522a379c2c9' into clippy-s…
flip1995 Jan 25, 2024
42d13f8
[`unconditional_recursion`]: compare by types instead of `DefId`s
y21 Jan 20, 2024
87a6300
add a test for rust-lang/rust-clippy#12181
y21 Jan 21, 2024
fd3e966
avoid linting on `#[track_caller]` functions in `redundant_closure`
y21 Jan 25, 2024
a65fe78
Auto merge of #116167 - RalfJung:structural-eq, r=lcnr
bors Jan 26, 2024
ed74c22
Auto merge of #12202 - y21:issue12199, r=Jarcho
bors Jan 26, 2024
9ce0b83
Clippy: Fix empty suggestion in from_over_into
flip1995 Jan 26, 2024
14e1520
Warn if an item coming from more recent version than MSRV is used
GuillaumeGomez Jan 17, 2024
8de9d8c
Auto merge of #12160 - GuillaumeGomez:incompatible-msrv, r=blyxyas
bors Jan 26, 2024
f096e91
Rollup merge of #120329 - nnethercote:3349-precursors, r=fee1-dead
matthiaskrgr Jan 26, 2024
57f63a3
Rollup merge of #120345 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Jan 26, 2024
1d94cc3
remove illegal_floating_point_literal_pattern lint
RalfJung Jan 6, 2024
f58950d
correct lint case
m-rph Jan 26, 2024
6d76d14
add to_string_trait_impl lint
andrewbanchich Jan 10, 2024
8905f78
Auto merge of #12082 - PartiallyTyped:1553, r=dswij
bors Jan 27, 2024
855aa08
Auto merge of #12178 - mdm:modulo-arithmetic-comparison-to-zero, r=ll…
bors Jan 27, 2024
79f10cf
Auto merge of #12122 - andrewbanchich:tostring-impl, r=llogiq
bors Jan 27, 2024
85e08cd
Auto merge of #12169 - GuillaumeGomez:unnecessary_result_map_or_else,…
bors Jan 27, 2024
a51fc2a
Fix `NonZero` clippy lints.
reitermarkus May 12, 2023
ff5afac
[`never_loop`]: recognize `?` desugaring in try blocks
y21 Jan 27, 2024
18e1f25
Auto merge of #12206 - y21:issue12205, r=Alexendoo
bors Jan 27, 2024
276ce39
Auto merge of #12083 - cocodery:fix/issue11932, r=Alexendoo
bors Jan 27, 2024
8ccf6a6
Auto merge of #12084 - yuxqiu:manual_retain, r=Alexendoo
bors Jan 27, 2024
3aa2c27
rewrote to match only Result::err cons
m-rph Jan 28, 2024
e7a3cb7
Auto merge of #12021 - PartiallyTyped:11982, r=flip1995
bors Jan 29, 2024
b3d5377
Make `redundant_closure_for_method_calls` suggest relative paths
modelflat Aug 21, 2023
b2f2080
Add regression test for #2371
GuillaumeGomez Jan 29, 2024
ce8b4b6
Remove fixed FIXME
GuillaumeGomez Jan 29, 2024
3cd713a
Auto merge of #11370 - modelflat:suggest-relpath-in-redundant-closure…
bors Jan 29, 2024
73706e8
Makes clippy-driver check for --sysroot in arg files
Jan 26, 2024
1156375
Auto merge of #12203 - daivinhtran:fix-clippy-driver-to-accept-param-…
bors Jan 29, 2024
455c07b
Auto merge of #12210 - GuillaumeGomez:add-regression-test-2371, r=bly…
bors Jan 29, 2024
d02df12
add configuration for [`wildcard_imports`] to ignore certain imports
J-ZhengLi Dec 18, 2023
314bdde
add more test cases & improve docs & replace `Vec` with `FxHashSet` f…
J-ZhengLi Jan 29, 2024
c0f49a9
hir: Simplify `hir_owner_nodes` query
petrochenkov Jan 25, 2024
7539054
hir: Add non-optional `hir_owner_nodes` for real `OwnerId`s
petrochenkov Jan 25, 2024
233c8c9
hir: Remove `hir::Map::{owner,expect_owner}`
petrochenkov Jan 25, 2024
f0dbf68
Rollup merge of #120342 - oli-obk:track_errors6, r=nnethercote
GuillaumeGomez Jan 30, 2024
3106219
Don't lint slice type annotations for byte strings
bpandreotti Jan 30, 2024
ae0f0fd
Don't hash lints differently to non-lints.
nnethercote Jan 30, 2024
9e3bb89
Auto merge of #120346 - petrochenkov:ownodes, r=oli-obk
bors Jan 31, 2024
7836678
Rollup merge of #120490 - nnethercote:Diagnostic-hashing, r=estebank
Nadrieril Jan 31, 2024
6619e8c
Add `lint_groups_priority` lint
Alexendoo Jan 31, 2024
b58b88c
Auto merge of #11832 - Alexendoo:lint-groups-priority, r=flip1995
bors Jan 31, 2024
fe8c2e2
Fixed FP in `unused_io_amount` for `Ok(lit)`, `unrachable!`
m-rph Jan 30, 2024
46dd826
rename conf option to `allowed_wildcard_imports`
J-ZhengLi Feb 2, 2024
9b6f866
Auto merge of #12217 - PartiallyTyped:12208, r=blyxyas
bors Feb 2, 2024
c82162e
Auto merge of #11979 - J-ZhengLi:issue11428, r=Alexendoo
bors Feb 2, 2024
abced20
Avoid deleting labeled blocks
sanxiyn Jan 31, 2024
9fb4107
Auto merge of #12219 - sanxiyn:labeled-block, r=blyxyas
bors Feb 3, 2024
be47e32
Update version attributes for 1.76 lints
xFrednet Feb 4, 2024
aa1de4d
Changelog for Clippy 1.76 :cat2:
xFrednet Feb 4, 2024
a3baebc
Add ref_as_ptr lint
marcin-serwin Jan 2, 2024
34e4c9f
Auto merge of #12087 - marcin-serwin:ref_as_ptr_cast, r=blyxyas
bors Feb 4, 2024
7c3908f
[`redundant_locals`]: take by-value closure captures into account
y21 Feb 4, 2024
8baeb26
Auto merge of #12224 - xFrednet:chaneglog-1-76, r=Manishearth
bors Feb 5, 2024
d13ce19
Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillot
matthiaskrgr Feb 5, 2024
77fb540
extend docs for `predicate_must_hold_considering_regions`
Feb 5, 2024
0c1f401
old solver: improve normalization of `Pointee::Metadata`
Feb 5, 2024
6807977
also check for coroutines
y21 Feb 5, 2024
42cc1d2
new solver: improve normalization of `Pointee::Metadata`
Feb 5, 2024
7f80b44
new lint: `manual_c_str_literals`
y21 Dec 3, 2023
005b6c2
Auto merge of #11919 - y21:manual_c_str_literals, r=xFrednet
bors Feb 5, 2024
fdf819d
Auto merge of #12227 - y21:issue12225, r=Manishearth
bors Feb 5, 2024
7895b98
Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs
compiler-errors Jan 24, 2024
36f7248
Fix release year in CHANGELOG.md
nyurik Feb 6, 2024
d910f77
Auto merge of #12235 - nyurik:patch-1, r=flip1995
bors Feb 6, 2024
b1e5a58
Auto merge of #11812 - Jarcho:issue_11786, r=Alexendoo
bors Feb 6, 2024
15ffe83
add fixme
Feb 6, 2024
08c8cd5
Auto merge of #12216 - bpandreotti:redundant-type-annotations-fix, r=…
bors Feb 7, 2024
62dcbd6
Auto merge of #12177 - y21:issue12154, r=Jarcho
bors Feb 7, 2024
c0d9776
std: move path into `sys`
joboet Feb 8, 2024
8801144
better error message on download CI LLVM failure
onur-ozkan Feb 8, 2024
d2f76f7
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Feb 8, 2024
031c46d
Bump nightly version -> 2024-02-08
flip1995 Feb 8, 2024
2ca6c84
Bump Clippy version -> 0.1.78
flip1995 Feb 8, 2024
92d4060
Implement SystemTime for UEFI
Ayush1325 Jan 25, 2024
60cb29c
Auto merge of #12246 - flip1995:rustup, r=flip1995
bors Feb 8, 2024
beb4f7d
Merge commit '60cb29c5e4f9772685c9873752196725c946a849' into clippyup
flip1995 Feb 8, 2024
4ec9eec
Update Cargo.lock
flip1995 Feb 8, 2024
6e37f95
Emit more specific diagnostics when enums fail to cast with `as`
gurry Feb 9, 2024
bc31920
Print image input file and checksum in CI only
DianQK Feb 9, 2024
a913c24
add comment
lcnr Feb 9, 2024
5051637
hide impls if trait bound is proven from env
lcnr Feb 9, 2024
e9059cb
Improve Option::inspect docs
camsteffen Feb 8, 2024
34ed554
Build DebugInfo for coroutine-closure
compiler-errors Feb 9, 2024
b860e23
Remove duplicate release note
carols10cents Feb 9, 2024
1e3d2fb
Rollup merge of #120351 - Ayush1325:uefi-time, r=m-ou-se
matthiaskrgr Feb 9, 2024
99bafad
Rollup merge of #120354 - lukas-code:metadata-normalize, r=lcnr
matthiaskrgr Feb 9, 2024
434f080
Rollup merge of #120776 - joboet:move_pal_path, r=ChrisDenton
matthiaskrgr Feb 9, 2024
c874b1a
Rollup merge of #120790 - onur-ozkan:better-error-message, r=wesleywiser
matthiaskrgr Feb 9, 2024
5250aba
Rollup merge of #120806 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Feb 9, 2024
40f998d
Rollup merge of #120815 - camsteffen:inspect-docs, r=m-ou-se
matthiaskrgr Feb 9, 2024
d9a957b
Rollup merge of #120822 - gurry:120756-terse-non-prim-cast-diag, r=pe…
matthiaskrgr Feb 9, 2024
c938624
Rollup merge of #120827 - DianQK:docker-run-local, r=Kobzol
matthiaskrgr Feb 9, 2024
2515845
Rollup merge of #120836 - lcnr:param-env-hide-impl, r=BoxyUwU
matthiaskrgr Feb 9, 2024
aa0b0b6
Rollup merge of #120844 - compiler-errors:async-di, r=oli-obk
matthiaskrgr Feb 9, 2024
3c1b7a7
Rollup merge of #120851 - carols10cents:patch-1, r=Mark-Simulacrum
matthiaskrgr Feb 9, 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
10 changes: 5 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"

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

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

[[package]]
name = "clippy_lints"
version = "0.1.77"
version = "0.1.78"
dependencies = [
"arrayvec",
"cargo_metadata 0.18.0",
Expand All @@ -632,7 +632,7 @@ dependencies = [

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

[[package]]
name = "declare_clippy_lint"
version = "0.1.77"
version = "0.1.78"
dependencies = [
"itertools",
"quote",
Expand Down
1 change: 0 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Language
--------
- [Document Rust ABI compatibility between various types](https://github.com/rust-lang/rust/pull/115476/)
- [Also: guarantee that char and u32 are ABI-compatible](https://github.com/rust-lang/rust/pull/118032/)
- [Warn against ambiguous wide pointer comparisons](https://github.com/rust-lang/rust/pull/117758/)
- [Add lint `ambiguous_wide_pointer_comparisons` that supersedes `clippy::vtable_address_comparisons`](https://github.com/rust-lang/rust/pull/117758)

<a id="1.76.0-Compiler"></a>
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
}
ty::FnDef(..) | ty::FnPtr(_) => build_subroutine_type_di_node(cx, unique_type_id),
ty::Closure(..) => build_closure_env_di_node(cx, unique_type_id),
ty::CoroutineClosure(..) => build_closure_env_di_node(cx, unique_type_id),
ty::Coroutine(..) => enums::build_coroutine_di_node(cx, unique_type_id),
ty::Adt(def, ..) => match def.adt_kind() {
AdtKind::Struct => build_struct_type_di_node(cx, unique_type_id),
Expand Down Expand Up @@ -1068,6 +1069,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
let (&def_id, up_var_tys) = match closure_or_coroutine_ty.kind() {
ty::Coroutine(def_id, args) => (def_id, args.as_coroutine().prefix_tys()),
ty::Closure(def_id, args) => (def_id, args.as_closure().upvar_tys()),
ty::CoroutineClosure(def_id, args) => (def_id, args.as_coroutine_closure().upvar_tys()),
_ => {
bug!(
"build_upvar_field_di_nodes() called with non-closure-or-coroutine-type: {:?}",
Expand Down Expand Up @@ -1153,7 +1155,8 @@ fn build_closure_env_di_node<'ll, 'tcx>(
unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> {
let closure_env_type = unique_type_id.expect_ty();
let &ty::Closure(def_id, _args) = closure_env_type.kind() else {
let &(ty::Closure(def_id, _) | ty::CoroutineClosure(def_id, _)) = closure_env_type.kind()
else {
bug!("build_closure_env_di_node() called with non-closure-type: {:?}", closure_env_type)
};
let containing_scope = get_namespace_for_item(cx, def_id);
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1985,10 +1985,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(

match in_elem.kind() {
ty::RawPtr(p) => {
let (metadata, check_sized) = p.ty.ptr_metadata_ty(bx.tcx, |ty| {
let metadata = p.ty.ptr_metadata_ty(bx.tcx, |ty| {
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
});
assert!(!check_sized); // we are in codegen, so we shouldn't see these types
require!(
metadata.is_unit(),
InvalidMonomorphization::CastFatPointer { span, name, ty: in_elem }
Expand All @@ -2000,10 +1999,9 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
}
match out_elem.kind() {
ty::RawPtr(p) => {
let (metadata, check_sized) = p.ty.ptr_metadata_ty(bx.tcx, |ty| {
let metadata = p.ty.ptr_metadata_ty(bx.tcx, |ty| {
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
});
assert!(!check_sized); // we are in codegen, so we shouldn't see these types
require!(
metadata.is_unit(),
InvalidMonomorphization::CastFatPointer { span, name, ty: out_elem }
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_const_eval/src/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// to fields, which can yield non-normalized types. So we need to provide a
// normalization function.
let normalize = |ty| self.tcx.normalize_erasing_regions(self.param_env, ty);
let (meta, only_if_sized) = ty.ptr_metadata_ty(*self.tcx, normalize);
assert!(
!only_if_sized,
"there should be no more 'maybe has that metadata' types during interpretation"
);
meta
ty.ptr_metadata_ty(*self.tcx, normalize)
};
return Ok(meta_ty(caller) == meta_ty(callee));
}
Expand Down
26 changes: 24 additions & 2 deletions compiler/rustc_hir_typeck/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,35 @@ impl<'a, 'tcx> CastCheck<'tcx> {
);
}
}
let msg = "an `as` expression can only be used to convert between primitive \
types or to coerce to a specific trait object";

let (msg, note) = if let ty::Adt(adt, _) = self.expr_ty.kind()
&& adt.is_enum()
&& self.cast_ty.is_numeric()
{
(
"an `as` expression can be used to convert enum types to numeric \
types only if the enum type is unit-only or field-less",
Some(
"see https://doc.rust-lang.org/reference/items/enumerations.html#casting for more information",
),
)
} else {
(
"an `as` expression can only be used to convert between primitive \
types or to coerce to a specific trait object",
None,
)
};

if label {
err.span_label(self.span, msg);
} else {
err.note(msg);
}

if let Some(note) = note {
err.note(note);
}
} else {
err.span_label(self.span, "invalid cast");
}
Expand Down
48 changes: 32 additions & 16 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2279,12 +2279,12 @@ impl<'tcx> Ty<'tcx> {
}

/// Returns the type of metadata for (potentially fat) pointers to this type,
/// and a boolean signifying if this is conditional on this type being `Sized`.
pub fn ptr_metadata_ty(
/// or the struct tail if the metadata type cannot be determined.
pub fn ptr_metadata_ty_or_tail(
self,
tcx: TyCtxt<'tcx>,
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
) -> (Ty<'tcx>, bool) {
) -> Result<Ty<'tcx>, Ty<'tcx>> {
let tail = tcx.struct_tail_with_normalize(self, normalize, || {});
match tail.kind() {
// Sized types
Expand All @@ -2307,31 +2307,47 @@ impl<'tcx> Ty<'tcx> {
| ty::Error(_)
// Extern types have metadata = ().
| ty::Foreign(..)
// `dyn*` has no metadata
// `dyn*` has metadata = ().
| ty::Dynamic(_, _, ty::DynStar)
// If returned by `struct_tail_without_normalization` this is a unit struct
// If returned by `struct_tail_with_normalize` this is a unit struct
// without any fields, or not a struct, and therefore is Sized.
| ty::Adt(..)
// If returned by `struct_tail_without_normalization` this is the empty tuple,
// If returned by `struct_tail_with_normalize` this is the empty tuple,
// a.k.a. unit type, which is Sized
| ty::Tuple(..) => (tcx.types.unit, false),
| ty::Tuple(..) => Ok(tcx.types.unit),

ty::Str | ty::Slice(_) => Ok(tcx.types.usize),

ty::Str | ty::Slice(_) => (tcx.types.usize, false),
ty::Dynamic(_, _, ty::Dyn) => {
let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, None);
(tcx.type_of(dyn_metadata).instantiate(tcx, &[tail.into()]), false)
},
Ok(tcx.type_of(dyn_metadata).instantiate(tcx, &[tail.into()]))
}

// type parameters only have unit metadata if they're sized, so return true
// to make sure we double check this during confirmation
ty::Param(_) | ty::Alias(..) => (tcx.types.unit, true),
// We don't know the metadata of `self`, but it must be equal to the
// metadata of `tail`.
ty::Param(_) | ty::Alias(..) => Err(tail),

ty::Infer(ty::TyVar(_))
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
bug!("`ptr_metadata_ty` applied to unexpected type: {:?} (tail = {:?})", self, tail)
}
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => bug!(
"`ptr_metadata_ty_or_tail` applied to unexpected type: {self:?} (tail = {tail:?})"
),
}
}

/// Returns the type of metadata for (potentially fat) pointers to this type.
/// Causes an ICE if the metadata type cannot be determined.
pub fn ptr_metadata_ty(
self,
tcx: TyCtxt<'tcx>,
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
) -> Ty<'tcx> {
match self.ptr_metadata_ty_or_tail(tcx, normalize) {
Ok(metadata) => metadata,
Err(tail) => bug!(
"`ptr_metadata_ty` failed to get metadata for type: {self:?} (tail = {tail:?})"
),
}
}

Expand Down
Loading
Loading