Skip to content

Commit c16ba35

Browse files
committed
Auto merge of rust-lang#131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#122670 (Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode) - rust-lang#131095 (Use environment variables instead of command line arguments for merged doctests) - rust-lang#131339 (Expand set_ptr_value / with_metadata_of docs) - rust-lang#131652 (Move polarity into `PolyTraitRef` rather than storing it on the side) - rust-lang#131675 (Update lint message for ABI not supported) - rust-lang#131681 (Fix up-to-date checking for run-make tests) - rust-lang#131702 (Suppress import errors for traits that couldve applied for method lookup error) - rust-lang#131703 (Resolved python deprecation warning in publish_toolstate.py) - rust-lang#131710 (Remove `'apostrophes'` from `rustc_parse_format`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 66359a7 + 5aa3e11 commit c16ba35

9 files changed

+23
-22
lines changed

clippy_lints/src/implied_bounds_in_impls.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds
242242
bounds
243243
.iter()
244244
.filter_map(|bound| {
245-
if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound
245+
if let GenericBound::Trait(poly_trait) = bound
246+
&& let TraitBoundModifier::None = poly_trait.modifiers
246247
&& let [.., path] = poly_trait.trait_ref.path.segments
247248
&& poly_trait.bound_generic_params.is_empty()
248249
&& let Some(trait_def_id) = path.res.opt_def_id()
@@ -307,7 +308,8 @@ fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) {
307308
// This involves some extra logic when generic arguments are present, since
308309
// simply comparing trait `DefId`s won't be enough. We also need to compare the generics.
309310
for (index, bound) in bounds.iter().enumerate() {
310-
if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound
311+
if let GenericBound::Trait(poly_trait) = bound
312+
&& let TraitBoundModifier::None = poly_trait.modifiers
311313
&& let [.., path] = poly_trait.trait_ref.path.segments
312314
&& let implied_args = path.args.map_or([].as_slice(), |a| a.args)
313315
&& let implied_constraints = path.args.map_or([].as_slice(), |a| a.constraints)

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&
310310
if let ty::Alias(_, alias_ty) = ty.kind()
311311
&& let Some(Node::OpaqueTy(opaque)) = cx.tcx.hir().get_if_local(alias_ty.def_id)
312312
&& let OpaqueTyOrigin::AsyncFn { .. } = opaque.origin
313-
&& let [GenericBound::Trait(trait_ref, _)] = &opaque.bounds
313+
&& let [GenericBound::Trait(trait_ref)] = &opaque.bounds
314314
&& let Some(segment) = trait_ref.trait_ref.path.segments.last()
315315
&& let Some(generic_args) = segment.args
316316
&& let [constraint] = generic_args.constraints

clippy_lints/src/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn check_fn_inner<'tcx>(
163163
if visitor.lts.iter().any(|lt| matches!(lt.res, LifetimeName::Param(_))) {
164164
return;
165165
}
166-
if let GenericBound::Trait(ref trait_ref, _) = *bound {
166+
if let GenericBound::Trait(ref trait_ref) = *bound {
167167
let params = &trait_ref
168168
.trait_ref
169169
.path
@@ -438,7 +438,7 @@ impl<'tcx> Visitor<'tcx> for RefVisitor<'_, 'tcx> {
438438
if !lt.is_elided() {
439439
self.unelided_trait_object_lifetime = true;
440440
}
441-
for (bound, _) in bounds {
441+
for bound in bounds {
442442
self.visit_poly_trait_ref(bound);
443443
}
444444
},

clippy_lints/src/manual_async_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn future_trait_ref<'tcx>(
107107
) -> Option<(&'tcx TraitRef<'tcx>, Vec<LifetimeName>)> {
108108
if let TyKind::OpaqueDef(opaque, bounds) = ty.kind
109109
&& let Some(trait_ref) = opaque.bounds.iter().find_map(|bound| {
110-
if let GenericBound::Trait(poly, _) = bound {
110+
if let GenericBound::Trait(poly) = bound {
111111
Some(&poly.trait_ref)
112112
} else {
113113
None

clippy_lints/src/needless_maybe_sized.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct Bound<'tcx> {
4040
ident: Ident,
4141

4242
trait_bound: &'tcx PolyTraitRef<'tcx>,
43-
modifier: TraitBoundModifier,
4443

4544
predicate_pos: usize,
4645
bound_pos: usize,
@@ -65,11 +64,10 @@ fn type_param_bounds<'tcx>(generics: &'tcx Generics<'tcx>) -> impl Iterator<Item
6564
.iter()
6665
.enumerate()
6766
.filter_map(move |(bound_pos, bound)| match bound {
68-
&GenericBound::Trait(ref trait_bound, modifier) => Some(Bound {
67+
&GenericBound::Trait(ref trait_bound) => Some(Bound {
6968
param,
7069
ident,
7170
trait_bound,
72-
modifier,
7371
predicate_pos,
7472
bound_pos,
7573
}),
@@ -120,13 +118,13 @@ impl LateLintPass<'_> for NeedlessMaybeSized {
120118
let maybe_sized_params: DefIdMap<_> = type_param_bounds(generics)
121119
.filter(|bound| {
122120
bound.trait_bound.trait_ref.trait_def_id() == Some(sized_trait)
123-
&& bound.modifier == TraitBoundModifier::Maybe
121+
&& bound.trait_bound.modifiers == TraitBoundModifier::Maybe
124122
})
125123
.map(|bound| (bound.param, bound))
126124
.collect();
127125

128126
for bound in type_param_bounds(generics) {
129-
if bound.modifier == TraitBoundModifier::None
127+
if bound.trait_bound.modifiers == TraitBoundModifier::None
130128
&& let Some(sized_bound) = maybe_sized_params.get(&bound.param)
131129
&& let Some(path) = path_to_sized_bound(cx, bound.trait_bound)
132130
{

clippy_lints/src/trait_bounds.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
182182

183183
// Iterate the bounds and add them to our seen hash
184184
// If we haven't yet seen it, add it to the fixed traits
185-
for (bound, _) in bounds {
185+
for bound in bounds {
186186
let Some(def_id) = bound.trait_ref.trait_def_id() else {
187187
continue;
188188
};
@@ -197,9 +197,9 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
197197
// If the number of unique traits isn't the same as the number of traits in the bounds,
198198
// there must be 1 or more duplicates
199199
if bounds.len() != unique_traits.len() {
200-
let mut bounds_span = bounds[0].0.span;
200+
let mut bounds_span = bounds[0].span;
201201

202-
for (bound, _) in bounds.iter().skip(1) {
202+
for bound in bounds.iter().skip(1) {
203203
bounds_span = bounds_span.to(bound.span);
204204
}
205205

@@ -229,7 +229,8 @@ impl TraitBounds {
229229
/// this MSRV? See <https://github.com/rust-lang/rust-clippy/issues/8772> for details.
230230
fn cannot_combine_maybe_bound(&self, cx: &LateContext<'_>, bound: &GenericBound<'_>) -> bool {
231231
if !self.msrv.meets(msrvs::MAYBE_BOUND_IN_WHERE)
232-
&& let GenericBound::Trait(tr, TraitBoundModifier::Maybe) = bound
232+
&& let GenericBound::Trait(tr) = bound
233+
&& let TraitBoundModifier::Maybe = tr.modifiers
233234
{
234235
cx.tcx.lang_items().get(LangItem::Sized) == tr.trait_ref.path.res.opt_def_id()
235236
} else {
@@ -375,11 +376,11 @@ impl Default for ComparableTraitRef {
375376
}
376377

377378
fn get_trait_info_from_bound<'a>(bound: &'a GenericBound<'_>) -> Option<(Res, &'a [PathSegment<'a>], Span)> {
378-
if let GenericBound::Trait(t, tbm) = bound {
379+
if let GenericBound::Trait(t) = bound {
379380
let trait_path = t.trait_ref.path;
380381
let trait_span = {
381382
let path_span = trait_path.span;
382-
if let TraitBoundModifier::Maybe = tbm {
383+
if let TraitBoundModifier::Maybe = t.modifiers {
383384
path_span.with_lo(path_span.lo() - BytePos(1)) // include the `?`
384385
} else {
385386
path_span
@@ -430,7 +431,7 @@ fn rollup_traits(
430431
let mut repeated_res = false;
431432

432433
let only_comparable_trait_refs = |bound: &GenericBound<'_>| {
433-
if let GenericBound::Trait(t, _) = bound {
434+
if let GenericBound::Trait(t) = bound {
434435
Some((into_comparable_trait_ref(&t.trait_ref), t.span))
435436
} else {
436437
None

clippy_lints/src/types/borrowed_box.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m
8282
// Returns true if given type is `Any` trait.
8383
fn is_any_trait(cx: &LateContext<'_>, t: &hir::Ty<'_>) -> bool {
8484
if let TyKind::TraitObject(traits, ..) = t.kind {
85-
return traits.iter().any(|(bound, _)| {
85+
return traits.iter().any(|bound| {
8686
if let Some(trait_did) = bound.trait_ref.trait_def_id()
8787
&& cx.tcx.is_diagnostic_item(sym::Any, trait_did)
8888
{

clippy_lints/src/types/type_complexity.rs

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
5555
TyKind::TraitObject(param_bounds, _, _) => {
5656
let has_lifetime_parameters = param_bounds.iter().any(|bound| {
5757
bound
58-
.0
5958
.bound_generic_params
6059
.iter()
6160
.any(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))

clippy_utils/src/ast_utils.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ pub fn eq_str_lit(l: &StrLit, r: &StrLit) -> bool {
786786
}
787787

788788
pub fn eq_poly_ref_trait(l: &PolyTraitRef, r: &PolyTraitRef) -> bool {
789-
eq_path(&l.trait_ref.path, &r.trait_ref.path)
789+
l.modifiers == r.modifiers
790+
&& eq_path(&l.trait_ref.path, &r.trait_ref.path)
790791
&& over(&l.bound_generic_params, &r.bound_generic_params, |l, r| {
791792
eq_generic_param(l, r)
792793
})
@@ -820,7 +821,7 @@ pub fn eq_generic_param(l: &GenericParam, r: &GenericParam) -> bool {
820821
pub fn eq_generic_bound(l: &GenericBound, r: &GenericBound) -> bool {
821822
use GenericBound::*;
822823
match (l, r) {
823-
(Trait(ptr1, tbm1), Trait(ptr2, tbm2)) => tbm1 == tbm2 && eq_poly_ref_trait(ptr1, ptr2),
824+
(Trait(ptr1), Trait(ptr2)) => eq_poly_ref_trait(ptr1, ptr2),
824825
(Outlives(l), Outlives(r)) => eq_id(l.ident, r.ident),
825826
_ => false,
826827
}

0 commit comments

Comments
 (0)