diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-12-02 17:36:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-02 17:36:11 +0100 |
| commit | 4c68112df14dca6186be968a0c063f7573ff3666 (patch) | |
| tree | 8f2915b4daf698505b284b44c18e0ae9d4c3ca66 /compiler/rustc_lint/src/internal.rs | |
| parent | 7c92266fdee746d56e1cfaacebd068acf9fd975f (diff) | |
| parent | e089bead327795727e1a72fd276776f12f186cea (diff) | |
| download | rust-4c68112df14dca6186be968a0c063f7573ff3666.tar.gz rust-4c68112df14dca6186be968a0c063f7573ff3666.zip | |
Rollup merge of #133751 - lcnr:no-trait-solving-on-type, r=compiler-errors
remove `Ty::is_copy_modulo_regions` Using these functions is likely incorrect if an `InferCtxt` is available, I moved this function to `TyCtxt` (and added it to `LateContext`) and added a note to the documentation that one should prefer `Infer::type_is_copy_modulo_regions` instead. I didn't yet move `is_sized` and `is_freeze`, though I think we should move these as well. r? `@compiler-errors` cc #132279
Diffstat (limited to 'compiler/rustc_lint/src/internal.rs')
| -rw-r--r-- | compiler/rustc_lint/src/internal.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 38c38b59bc5..7c8a65059d1 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -242,17 +242,10 @@ fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, path: &Path<'_>) -> Option<String> { } // Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait. Res::SelfTyAlias { alias_to: did, is_trait_impl: false, .. } => { - if let ty::Adt(adt, args) = cx.tcx.type_of(did).instantiate_identity().kind() { - if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(adt.did()) - { - // NOTE: This path is currently unreachable as `Ty<'tcx>` is - // defined as a type alias meaning that `impl<'tcx> Ty<'tcx>` - // is not actually allowed. - // - // I(@lcnr) still kept this branch in so we don't miss this - // if we ever change it in the future. - return Some(format!("{}<{}>", name, args[0])); - } + if let ty::Adt(adt, args) = cx.tcx.type_of(did).instantiate_identity().kind() + && let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(adt.did()) + { + return Some(format!("{}<{}>", name, args[0])); } } _ => (), |
