Skip to content
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

is_some_and taking self demo #99087

Closed

Conversation

camsteffen
Copy link
Contributor

This is just to demo the difference between &self and self as requested. The last commit "Fix is_some_and usages taking by value" is the interesting one.

r? @joshtriplett

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 9, 2022
@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2022

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in need_type_info.rs

cc @lcnr

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred in src/librustdoc/clean/types.rs

cc @camelid

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 9, 2022
@camsteffen camsteffen removed the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 9, 2022
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some formatting-only changes in the Clippy files. Please don't commit those. I think I left a comment for each of those changes.

@@ -79,21 +79,29 @@ impl EarlyLintPass for DuplicateMod {
}

fn check_crate_post(&mut self, cx: &EarlyContext<'_>, _: &Crate) {
for Modules { local_path, spans, lint_levels } in self.modules.values() {
for Modules {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT all changes in this file are formatting changes. Please don't commit formatting changes to Clippy.

@@ -37,8 +37,8 @@ fn parse_repeat_arg(cx: &LateContext<'_>, e: &Expr<'_>) -> Option<RepeatKind> {
} else {
let ty = cx.typeck_results().expr_ty(e);
if is_type_diagnostic_item(cx, ty, sym::String)
|| (is_type_lang_item(cx, ty, LangItem::OwnedBox) && get_ty_param(ty).map_or(false, Ty::is_str))
|| (match_type(cx, ty, &paths::COW) && get_ty_param(ty).map_or(false, Ty::is_str))
|| (is_type_lang_item(cx, ty, LangItem::OwnedBox) && get_ty_param(ty).is_some_and(|ty| ty.is_str()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, shouldn't

Suggested change
|| (is_type_lang_item(cx, ty, LangItem::OwnedBox) && get_ty_param(ty).is_some_and(|ty| ty.is_str()))
|| (is_type_lang_item(cx, ty, LangItem::OwnedBox) && get_ty_param(ty).is_some_and(Ty::is_str)

still work?

@@ -7,7 +7,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::{Expr, ExprKind, PatKind, Stmt, StmtKind};
use rustc_lint::{LateContext, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::{self, Ty, TypeVisitable, TypeSuperVisitable, TypeVisitor};
use rustc_middle::ty::{self, Ty, TypeSuperVisitable, TypeVisitable, TypeVisitor};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting change.

sp: Span,
msg: &str,
) {
pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: &str) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting change.

@@ -93,7 +94,9 @@ use rustc_middle::ty::fast_reject::SimplifiedTypeGen::{
ArraySimplifiedType, BoolSimplifiedType, CharSimplifiedType, FloatSimplifiedType, IntSimplifiedType,
PtrSimplifiedType, SliceSimplifiedType, StrSimplifiedType, UintSimplifiedType,
};
use rustc_middle::ty::{layout::IntegerExt, BorrowKind, DefIdTree, Ty, TyCtxt, TypeAndMut, TypeVisitable, UpvarCapture};
use rustc_middle::ty::{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting change.

@camsteffen
Copy link
Contributor Author

@flip1995 sorry this PR is not intended to be merged. But fwiw the formatting changes are made with cargo fmt -p clippy_lints -p clippy_utils.

@flip1995
Copy link
Member

But fwiw the formatting changes are made with cargo fmt -p clippy_lints -p clippy_utils.

This then probably uses the rust-lang/rust rustfmt.toml file and not the Clippy one? Is this ran automatically by some x.py command?

@camsteffen
Copy link
Contributor Author

But fwiw the formatting changes are made with cargo fmt -p clippy_lints -p clippy_utils.

This then probably uses the rust-lang/rust rustfmt.toml file and not the Clippy one? Is this ran automatically by some x.py command?

No I run it manually when I make Clippy changes to avoid making changes that will be re-formatted. Any unrelated formatting changes that occur I assume are from rustc PR's that occurred since that last clippy sync. I usually don't push the unrelated formatting changes, but keep them in a commit in my local branch while working so that I don't see those changes every time I run cargo fmt.

@bors
Copy link
Contributor

bors commented Jul 13, 2022

☔ The latest upstream changes (presumably #99203) made this pull request unmergeable. Please resolve the merge conflicts.

@joshtriplett
Copy link
Member

@camsteffen I'd be happy to r+ a non-draft version of this; I think we've settled the question of taking self.

@camsteffen
Copy link
Contributor Author

@joshtriplett I reopened #98354.

@camsteffen camsteffen closed this Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants