-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Normalize substs before resolving instance in NoopMethodCall
lint
#102489
Conversation
if substs.needs_subst() { | ||
// We can't resolve on types that require monomorphization, so we don't handle them if | ||
// we need to perform substitution. | ||
return; | ||
} | ||
let param_env = cx.tcx.param_env(trait_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it made sense to use the param-env of the trait here...?
let substs = cx.typeck_results().node_substs(expr.hir_id); | ||
let substs = cx | ||
.tcx | ||
.normalize_erasing_regions(cx.param_env, cx.typeck_results().node_substs(expr.hir_id)); | ||
if substs.needs_subst() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is this true? We should be able to trigger this lint if we have, e.g. a clone call like <&T as Clone>::clone(..)
which is still a no-op...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instance::resolve
should not panic if substs.needs_subst
, it should return a non Ok(Some(_))
value. Removing that check should be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, and it also fixes a exactly the case that was missing a warning in the original noop-method-call ui test 😸
This might also close #97725 :3 |
3e70086
to
b1839d9
Compare
b1839d9
to
587b589
Compare
587b589
to
e1b313a
Compare
@bors r+ rollup |
Rollup of 6 pull requests Successful merges: - rust-lang#101189 (Implement `Ready::into_inner()`) - rust-lang#101642 (Fix in-place collection leak when remaining element destructor panic) - rust-lang#102489 (Normalize substs before resolving instance in `NoopMethodCall` lint) - rust-lang#102559 (Don't ICE when trying to copy unsized value in const prop) - rust-lang#102568 (Lint against nested opaque types that don't satisfy associated type bounds) - rust-lang#102633 (Fix rustdoc ICE in invalid_rust_codeblocks lint) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #102074
r? types