Skip to content

Commit 9e398f1

Browse files
committed
Acount for API changes
1 parent 93a5041 commit 9e398f1

File tree

7 files changed

+50
-64
lines changed
  • examples

7 files changed

+50
-64
lines changed

examples/experimental/derive_opportunity/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2222
use rustc_errors::Applicability;
2323
use rustc_hir::{def_id::DefId, Item, ItemKind};
2424
use rustc_lint::{LateContext, LateLintPass, LintStore};
25-
use rustc_middle::{
26-
traits::Reveal,
27-
ty::{self, Upcast},
28-
};
25+
use rustc_middle::ty::{self, Upcast};
2926
use rustc_session::{declare_lint, impl_lint_pass, Session};
3027
use rustc_span::{sym, ExpnKind, MacroKind, Symbol};
3128
use serde::Deserialize;
@@ -353,24 +350,24 @@ fn implements_trait_with_bounds<'tcx>(
353350
generics.own_params.len().saturating_sub(1)
354351
];
355352
if let ty::Adt(adt_def, _) = ty.kind() {
356-
let param_env = param_env_with_bounds(cx.tcx, adt_def.did(), trait_id);
353+
let typing_env = typing_env_with_bounds(cx.tcx, adt_def.did(), trait_id);
357354
// smoelius: The decision to pass `adt_def.did()` as the `callee_id` argument is based on
358355
// the following, but I am not sure it is the correct choice:
359356
// https://github.com/rust-lang/rust-clippy/blob/782520088f9c5a0274459060a6fdcd41301f35e2/clippy_lints/src/derive.rs#L453
360357
// See also: https://github.com/rust-lang/rust/pull/118661#discussion_r1449013176
361358
// smoelius: `Some(adt_def.did())` was changed to `None`. See:
362359
// https://github.com/rust-lang/rust/pull/120000
363-
implements_trait_with_env(cx.tcx, param_env, ty, trait_id, None, &args)
360+
implements_trait_with_env(cx.tcx, typing_env, ty, trait_id, None, &args)
364361
} else {
365362
implements_trait(cx, ty, trait_id, &args)
366363
}
367364
}
368365

369-
// smoelius: `param_env_with_bounds` is based on Clippy's `param_env_for_derived_eq`:
366+
// smoelius: `typing_env_with_bounds` is based on Clippy's `param_env_for_derived_eq`:
370367
// https://github.com/rust-lang/rust-clippy/blob/716c552632acb50a524e62284b9ca2446333a626/clippy_lints/src/derive.rs#L493-L529
371368

372369
/// Creates the `ParamEnv` used for the give type's derived impl.
373-
fn param_env_with_bounds(tcx: ty::TyCtxt<'_>, did: DefId, trait_id: DefId) -> ty::ParamEnv<'_> {
370+
fn typing_env_with_bounds(tcx: ty::TyCtxt<'_>, did: DefId, trait_id: DefId) -> ty::TypingEnv<'_> {
374371
// Initial map from generic index to param def.
375372
// Vec<(param_def, needs_bound)>
376373
let mut params = tcx
@@ -391,7 +388,7 @@ fn param_env_with_bounds(tcx: ty::TyCtxt<'_>, did: DefId, trait_id: DefId) -> ty
391388
}
392389
}
393390

394-
ty::ParamEnv::new(
391+
let param_env = ty::ParamEnv::new(
395392
tcx.mk_clauses_from_iter(
396393
ty_predicates.iter().map(|&(p, _)| p).chain(
397394
params
@@ -410,8 +407,11 @@ fn param_env_with_bounds(tcx: ty::TyCtxt<'_>, did: DefId, trait_id: DefId) -> ty
410407
}),
411408
),
412409
),
413-
Reveal::UserFacing,
414-
)
410+
);
411+
ty::TypingEnv {
412+
typing_mode: ty::TypingMode::non_body_analysis(),
413+
param_env,
414+
}
415415
}
416416

417417
impl Macro {

examples/restriction/overscoped_allow/ui_general/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
fn main() {}
44

5+
// smoelius: This test broken around the time `clippy::module_name_repetitions` was moved to
6+
// `restriction`: https://github.com/rust-lang/rust-clippy/pull/13541
7+
// I haven't yet figured out how to fix it.
58
#[allow(clippy::module_name_repetitions)]
69
mod item {
710
pub struct ItemStruct;
@@ -33,6 +36,7 @@ fn block_expr() {
3336
Some(()).unwrap()
3437
}
3538

39+
// smoelius: See comment above re `clippy::module_name_repetitions` moving to `restriction`.
3640
#[allow(clippy::module_name_repetitions)]
3741
mod nested_item {
3842
mod item {
Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,123 @@
11
warning: `allow` could be moved closer to diagnostic source
2-
--> $DIR/main.rs:5:9
3-
|
4-
LL | #[allow(clippy::module_name_repetitions)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
help: `allow` could be moved here
8-
--> $DIR/main.rs:7:5
9-
|
10-
LL | pub struct ItemStruct;
11-
| ^
12-
= note: `#[warn(overscoped_allow)]` on by default
13-
14-
warning: `allow` could be moved closer to diagnostic source
15-
--> $DIR/main.rs:10:9
2+
--> $DIR/main.rs:13:9
163
|
174
LL | #[allow(clippy::wrong_self_convention)]
185
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196
|
207
help: `allow` could be moved here
21-
--> $DIR/main.rs:13:9
8+
--> $DIR/main.rs:16:9
229
|
2310
LL | fn into_foo(&self) {}
2411
| ^
12+
= note: `#[warn(overscoped_allow)]` on by default
2513

2614
warning: `allow` could be moved closer to diagnostic source
27-
--> $DIR/main.rs:20:13
15+
--> $DIR/main.rs:23:13
2816
|
2917
LL | #[allow(clippy::unused_self)]
3018
| ^^^^^^^^^^^^^^^^^^^
3119
|
3220
help: `allow` could be moved here
33-
--> $DIR/main.rs:22:9
21+
--> $DIR/main.rs:25:9
3422
|
3523
LL | fn foo(&self) {}
3624
| ^
3725

3826
warning: `allow` could be moved closer to diagnostic source
39-
--> $DIR/main.rs:26:9
27+
--> $DIR/main.rs:29:9
4028
|
4129
LL | #[allow(clippy::unwrap_used)]
4230
| ^^^^^^^^^^^^^^^^^^^
4331
|
4432
help: `allow` could be moved here
45-
--> $DIR/main.rs:28:5
33+
--> $DIR/main.rs:31:5
4634
|
4735
LL | Some(()).unwrap();
4836
| ^
4937

5038
warning: `allow` could be moved closer to diagnostic source
51-
--> $DIR/main.rs:31:9
39+
--> $DIR/main.rs:34:9
5240
|
5341
LL | #[allow(clippy::unwrap_used)]
5442
| ^^^^^^^^^^^^^^^^^^^
5543
|
5644
help: `allow` could be moved here
57-
--> $DIR/main.rs:33:5
45+
--> $DIR/main.rs:36:5
5846
|
5947
LL | Some(()).unwrap()
6048
| ^
6149

6250
warning: `allow` could be moved closer to diagnostic source
63-
--> $DIR/main.rs:36:9
64-
|
65-
LL | #[allow(clippy::module_name_repetitions)]
66-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67-
|
68-
help: `allow` could be moved here
69-
--> $DIR/main.rs:39:9
70-
|
71-
LL | pub struct ItemStruct;
72-
| ^
73-
74-
warning: `allow` could be moved closer to diagnostic source
75-
--> $DIR/main.rs:43:9
51+
--> $DIR/main.rs:47:9
7652
|
7753
LL | #[allow(clippy::wrong_self_convention)]
7854
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7955
|
8056
help: `allow` could be moved here
81-
--> $DIR/main.rs:47:13
57+
--> $DIR/main.rs:51:13
8258
|
8359
LL | fn into_foo(&self) {}
8460
| ^
8561

8662
warning: `allow` could be moved closer to diagnostic source
87-
--> $DIR/main.rs:53:13
63+
--> $DIR/main.rs:57:13
8864
|
8965
LL | #[allow(clippy::unused_self)]
9066
| ^^^^^^^^^^^^^^^^^^^
9167
|
9268
help: `allow` could be moved here
93-
--> $DIR/main.rs:58:13
69+
--> $DIR/main.rs:62:13
9470
|
9571
LL | fn foo(&self) {}
9672
| ^
9773

9874
warning: `allow` could be moved closer to diagnostic source
99-
--> $DIR/main.rs:63:9
75+
--> $DIR/main.rs:67:9
10076
|
10177
LL | #[allow(clippy::unwrap_used)]
10278
| ^^^^^^^^^^^^^^^^^^^
10379
|
10480
help: `allow` could be moved here
105-
--> $DIR/main.rs:66:9
81+
--> $DIR/main.rs:70:9
10682
|
10783
LL | Some(()).unwrap();
10884
| ^
10985

11086
warning: `allow` could be moved closer to diagnostic source
111-
--> $DIR/main.rs:70:9
87+
--> $DIR/main.rs:74:9
11288
|
11389
LL | #[allow(clippy::unwrap_used)]
11490
| ^^^^^^^^^^^^^^^^^^^
11591
|
11692
help: `allow` could be moved here
117-
--> $DIR/main.rs:73:9
93+
--> $DIR/main.rs:77:9
11894
|
11995
LL | Some(()).unwrap()
12096
| ^
12197

12298
warning: `allow` could be moved closer to diagnostic source
123-
--> $DIR/main.rs:77:25
99+
--> $DIR/main.rs:81:25
124100
|
125101
LL | #[cfg_attr(all(), allow(clippy::unwrap_used))]
126102
| ^^^^^^^^^^^^^^^^^^^
127103
|
128104
help: `allow` could be moved here
129-
--> $DIR/main.rs:79:5
105+
--> $DIR/main.rs:83:5
130106
|
131107
LL | Some(()).unwrap();
132108
| ^
133109

134110
warning: `allow` could be moved closer to diagnostic source
135-
--> $DIR/main.rs:82:42
111+
--> $DIR/main.rs:86:42
136112
|
137113
LL | #[allow(clippy::module_name_repetitions, clippy::unwrap_used)]
138114
| ^^^^^^^^^^^^^^^^^^^
139115
|
140116
help: `allow` could be moved here
141-
--> $DIR/main.rs:84:5
117+
--> $DIR/main.rs:88:5
142118
|
143119
LL | Some(()).unwrap();
144120
| ^
145121

146-
warning: 12 warnings emitted
122+
warning: 10 warnings emitted
147123

examples/restriction/ref_aware_redundant_closure_for_method_calls/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ fn method_name_from_adjustments<'tcx>(
275275
target,
276276
}] if is_copy(cx, *target) => Some("copied"),
277277
[Adjustment {
278-
kind: Adjust::Borrow(AutoBorrow::Ref(_, mutability)),
278+
kind: Adjust::Borrow(AutoBorrow::Ref(mutability)),
279279
..
280280
}] => Some(match mutability {
281281
AutoBorrowMutability::Mut { .. } => "as_mut",
@@ -285,7 +285,7 @@ fn method_name_from_adjustments<'tcx>(
285285
kind: Adjust::Deref(Some(OverloadedDeref { .. })),
286286
..
287287
}, Adjustment {
288-
kind: Adjust::Borrow(AutoBorrow::Ref(_, mutability)),
288+
kind: Adjust::Borrow(AutoBorrow::Ref(mutability)),
289289
..
290290
}] => Some(match mutability {
291291
AutoBorrowMutability::Mut { .. } => "as_deref_mut",
@@ -377,8 +377,8 @@ fn get_ufcs_type_name<'tcx>(
377377
let assoc_item = cx.tcx.associated_item(method_def_id);
378378
let def_id = assoc_item.container_id(cx.tcx);
379379
match assoc_item.container {
380-
ty::TraitContainer => cx.tcx.def_path_str(def_id),
381-
ty::ImplContainer => {
380+
ty::AssocItemContainer::Trait => cx.tcx.def_path_str(def_id),
381+
ty::AssocItemContainer::Impl => {
382382
let ty = cx.tcx.type_of(def_id).instantiate_identity();
383383
match ty.kind() {
384384
ty::Adt(adt, _) => cx.tcx.def_path_str(adt.did()),

examples/restriction/register_lints_warn/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ dylint_linting::declare_late_lint! {
4343
/// # fn name(&self) -> &'static str {
4444
/// # "lint_pass"
4545
/// # }
46+
/// # fn get_lints(&self) -> Vec<&'static rustc_lint::Lint> {
47+
/// # Vec::new()
48+
/// # }
4649
/// # }
4750
/// impl<'tcx> rustc_lint::LateLintPass<'tcx> for LintPass {
4851
/// fn check_crate(&mut self, cx: &rustc_lint::LateContext<'tcx>) {

examples/restriction/register_lints_warn/ui/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ impl rustc_lint::LintPass for LintPass {
1515
fn name(&self) -> &'static str {
1616
"lint_pass"
1717
}
18+
fn get_lints(&self) -> Vec<&'static rustc_lint::Lint> {
19+
Vec::new()
20+
}
1821
}
1922

2023
impl<'tcx> rustc_lint::LateLintPass<'tcx> for LintPass {

examples/supplementary/unnecessary_conversion_for_trait/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ fn inner_arg_implements_traits<'tcx>(
556556
let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate);
557557
cx.tcx
558558
.infer_ctxt()
559-
.build()
559+
.build(cx.typing_mode())
560560
.predicate_must_hold_modulo_regions(&obligation)
561561
})
562562
}
@@ -611,7 +611,7 @@ fn replace_types<'tcx>(
611611

612612
if let Ok(projected_ty) = cx
613613
.tcx
614-
.try_normalize_erasing_regions(cx.param_env, projection)
614+
.try_normalize_erasing_regions(cx.typing_env(), projection)
615615
&& substs[term_param_ty.index as usize]
616616
!= ty::GenericArg::from(projected_ty)
617617
{
@@ -674,7 +674,7 @@ fn adjustment_mutabilities<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> V
674674
.iter()
675675
.map_while(|adjustment| {
676676
if let Adjustment {
677-
kind: Adjust::Borrow(AutoBorrow::Ref(_, mutability)),
677+
kind: Adjust::Borrow(AutoBorrow::Ref(mutability)),
678678
target: _,
679679
} = adjustment
680680
{

0 commit comments

Comments
 (0)