Skip to content

Commit b52ac9a

Browse files
committed
Auto merge of rust-lang#125507 - compiler-errors:type-length-limit, r=lcnr
Re-implement a type-size based limit r? lcnr This PR reintroduces the type length limit added in rust-lang#37789, which was accidentally made practically useless by the caching changes to `Ty::walk` in rust-lang#72412, which caused the `walk` function to no longer walk over identical elements. Hitting this length limit is not fatal unless we are in codegen -- so it shouldn't affect passes like the mir inliner which creates potentially very large types (which we observed, for example, when the new trait solver compiles `itertools` in `--release` mode). This also increases the type length limit from `1048576 == 2 ** 20` to `2 ** 24`, which covers all of the code that can be reached with craterbot-check. Individual crates can increase the length limit further if desired. Perf regression is mild and I think we should accept it -- reinstating this limit is important for the new trait solver and to make sure we don't accidentally hit more type-size related regressions in the future. Fixes rust-lang#125460
2 parents f715bfc + cd60231 commit b52ac9a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

clippy_lints/src/assigning_clones.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn extract_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<
103103
let args = cx.typeck_results().node_args(expr.hir_id);
104104

105105
// If we could not resolve the method, don't apply the lint
106-
let Ok(Some(resolved_method)) = Instance::resolve(cx.tcx, cx.param_env, fn_def_id, args) else {
106+
let Ok(Some(resolved_method)) = Instance::try_resolve(cx.tcx, cx.param_env, fn_def_id, args) else {
107107
return None;
108108
};
109109
if is_trait_method(cx, expr, sym::Clone) && path.ident.name == sym::clone {
@@ -119,7 +119,7 @@ fn extract_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<
119119

120120
// If we could not resolve the method, don't apply the lint
121121
let Ok(Some(resolved_method)) = (match kind {
122-
ty::FnDef(_, args) => Instance::resolve(cx.tcx, cx.param_env, fn_def_id, args),
122+
ty::FnDef(_, args) => Instance::try_resolve(cx.tcx, cx.param_env, fn_def_id, args),
123123
_ => Ok(None),
124124
}) else {
125125
return None;

clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<'tcx> NonCopyConst<'tcx> {
293293
ct: ty::UnevaluatedConst<'tcx>,
294294
span: Span,
295295
) -> EvalToValTreeResult<'tcx> {
296-
match ty::Instance::resolve(tcx, param_env, ct.def, ct.args) {
296+
match ty::Instance::try_resolve(tcx, param_env, ct.def, ct.args) {
297297
Ok(Some(instance)) => {
298298
let cid = GlobalId {
299299
instance,

0 commit comments

Comments
 (0)