Skip to content

Commit

Permalink
Auto merge of rust-lang#13086 - flip1995:rustup, r=flip1995
Browse files Browse the repository at this point in the history
Rustup

r? `@ghost`

changelog: none
  • Loading branch information
bors committed Jul 11, 2024
2 parents ef3cfaa + 3b1266c commit b794b8e
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 64 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/assigning_clones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
},
_ => return,
}
&& let Ok(Some(resolved_fn)) = Instance::resolve(cx.tcx, cx.param_env, fn_id, fn_gen_args)
&& let Ok(Some(resolved_fn)) = Instance::try_resolve(cx.tcx, cx.param_env, fn_id, fn_gen_args)
// TODO: This check currently bails if the local variable has no initializer.
// That is overly conservative - the lint should fire even if there was no initializer,
// but the variable has been initialized before `lhs` was evaluated.
Expand Down
33 changes: 17 additions & 16 deletions clippy_lints/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use clippy_utils::ty::is_type_diagnostic_item;
use clippy_utils::visitors::Visitable;
use clippy_utils::{in_constant, is_entrypoint_fn, is_trait_impl_item, method_chain_args};
use pulldown_cmark::Event::{
Code, End, FootnoteReference, HardBreak, Html, Rule, SoftBreak, Start, TaskListMarker, Text,
Code, DisplayMath, End, FootnoteReference, HardBreak, Html, InlineHtml, InlineMath, Rule, SoftBreak, Start,
TaskListMarker, Text,
};
use pulldown_cmark::Tag::{BlockQuote, CodeBlock, FootnoteDefinition, Heading, Item, Link, Paragraph};
use pulldown_cmark::{BrokenLink, CodeBlockKind, CowStr, Options};
use pulldown_cmark::{BrokenLink, CodeBlockKind, CowStr, Options, TagEnd};
use rustc_ast::ast::Attribute;
use rustc_data_structures::fx::FxHashSet;
use rustc_hir::intravisit::{self, Visitor};
Expand Down Expand Up @@ -659,7 +660,7 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize

while let Some((event, range)) = events.next() {
match event {
Html(tag) => {
Html(tag) | InlineHtml(tag) => {
if tag.starts_with("<code") {
code_level += 1;
} else if tag.starts_with("</code") {
Expand All @@ -670,11 +671,11 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
blockquote_level -= 1;
}
},
Start(BlockQuote) => {
Start(BlockQuote(_)) => {
blockquote_level += 1;
containers.push(Container::Blockquote);
},
End(BlockQuote) => {
End(TagEnd::BlockQuote) => {
blockquote_level -= 1;
containers.pop();
},
Expand All @@ -699,15 +700,15 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
}
}
},
End(CodeBlock(_)) => {
End(TagEnd::CodeBlock) => {
in_code = false;
is_rust = false;
ignore = false;
},
Start(Link(_, url, _)) => in_link = Some(url),
End(Link(..)) => in_link = None,
Start(Heading(_, _, _) | Paragraph | Item) => {
if let Start(Heading(_, _, _)) = event {
Start(Link { dest_url, .. }) => in_link = Some(dest_url),
End(TagEnd::Link) => in_link = None,
Start(Heading { .. } | Paragraph | Item) => {
if let Start(Heading { .. }) = event {
in_heading = true;
}
if let Start(Item) = event {
Expand All @@ -720,11 +721,11 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
ticks_unbalanced = false;
paragraph_range = range;
},
End(Heading(_, _, _) | Paragraph | Item) => {
if let End(Heading(_, _, _)) = event {
End(TagEnd::Heading(_) | TagEnd::Paragraph | TagEnd::Item) => {
if let End(TagEnd::Heading(_)) = event {
in_heading = false;
}
if let End(Item) = event {
if let End(TagEnd::Item) = event {
containers.pop();
}
if ticks_unbalanced && let Some(span) = fragments.span(cx, paragraph_range.clone()) {
Expand All @@ -746,8 +747,9 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
text_to_check = Vec::new();
},
Start(FootnoteDefinition(..)) => in_footnote_definition = true,
End(FootnoteDefinition(..)) => in_footnote_definition = false,
Start(_tag) | End(_tag) => (), // We don't care about other tags
End(TagEnd::FootnoteDefinition) => in_footnote_definition = false,
Start(_) | End(_) // We don't care about other tags
| TaskListMarker(_) | Code(_) | Rule | InlineMath(..) | DisplayMath(..) => (),
SoftBreak | HardBreak => {
if !containers.is_empty()
&& let Some((next_event, next_range)) = events.peek()
Expand All @@ -766,7 +768,6 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
);
}
},
TaskListMarker(_) | Code(_) | Rule => (),
FootnoteReference(text) | Text(text) => {
paragraph_range.end = range.end;
let range_ = range.clone();
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/empty_with_brackets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare_clippy_lint! {
/// and it may be desirable to do so consistently for style.
///
/// However, removing the brackets also introduces a public constant named after the struct,
/// so this is not just a syntactic simplification but an an API change, and adding them back
/// so this is not just a syntactic simplification but an API change, and adding them back
/// is a *breaking* API change.
///
/// ### Example
Expand Down Expand Up @@ -44,7 +44,7 @@ declare_clippy_lint! {
/// and it may be desirable to do so consistently for style.
///
/// However, removing the brackets also introduces a public constant named after the variant,
/// so this is not just a syntactic simplification but an an API change, and adding them back
/// so this is not just a syntactic simplification but an API change, and adding them back
/// is a *breaking* API change.
///
/// ### Example
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_middle::ty::{
use rustc_session::declare_lint_pass;
use rustc_span::symbol::sym;
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
use rustc_trait_selection::error_reporting::traits::InferCtxtExt as _;

declare_clippy_lint! {
/// ### What it does
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_middle::ty::{self, AliasTy, ClauseKind, PredicateKind};
use rustc_session::declare_lint_pass;
use rustc_span::def_id::LocalDefId;
use rustc_span::{sym, Span};
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
use rustc_trait_selection::error_reporting::traits::suggestions::TypeErrCtxtExt;
use rustc_trait_selection::traits::{self, FulfillmentError, ObligationCtxt};

declare_clippy_lint! {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/implied_bounds_in_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds
&& let [.., path] = poly_trait.trait_ref.path.segments
&& poly_trait.bound_generic_params.is_empty()
&& let Some(trait_def_id) = path.res.opt_def_id()
&& let predicates = cx.tcx.super_predicates_of(trait_def_id).predicates
&& let predicates = cx.tcx.explicit_super_predicates_of(trait_def_id).predicates
// If the trait has no supertrait, there is no need to collect anything from that bound
&& !predicates.is_empty()
{
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/type_id_on_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn is_subtrait_of_any(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
cx.tcx.is_diagnostic_item(sym::Any, tr.def_id)
|| cx
.tcx
.super_predicates_of(tr.def_id)
.explicit_super_predicates_of(tr.def_id)
.predicates
.iter()
.any(|(clause, _)| {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_maybe_sized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn path_to_sized_bound(cx: &LateContext<'_>, trait_bound: &PolyTraitRef<'_>) ->
return true;
}

for &(predicate, _) in cx.tcx.super_predicates_of(trait_def_id).predicates {
for &(predicate, _) in cx.tcx.explicit_super_predicates_of(trait_def_id).predicates {
if let ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder()
&& trait_predicate.polarity == PredicatePolarity::Positive
&& !path.contains(&trait_predicate.def_id())
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'tcx> NonCopyConst<'tcx> {
// e.g. implementing `has_frozen_variant` described above, and not running this function
// when the type doesn't have any frozen variants would be the 'correct' way for the 2nd
// case (that actually removes another suboptimal behavior (I won't say 'false positive') where,
// similar to 2., but with the a frozen variant) (e.g. borrowing
// similar to 2., but with a frozen variant) (e.g. borrowing
// `borrow_interior_mutable_const::enums::AssocConsts::TO_BE_FROZEN_VARIANT`).
// I chose this way because unfrozen enums as assoc consts are rare (or, hopefully, none).
matches!(err, ErrorHandled::TooGeneric(..))
Expand Down Expand Up @@ -293,7 +293,7 @@ impl<'tcx> NonCopyConst<'tcx> {
ct: ty::UnevaluatedConst<'tcx>,
span: Span,
) -> EvalToValTreeResult<'tcx> {
match ty::Instance::resolve(tcx, param_env, ct.def, ct.args) {
match ty::Instance::try_resolve(tcx, param_env, ct.def, ct.args) {
Ok(Some(instance)) => {
let cid = GlobalId {
instance,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/suspicious_operation_groupings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ fn ident_difference_expr_with_base_location(
| (Assign(_, _, _), Assign(_, _, _))
| (TryBlock(_), TryBlock(_))
| (Await(_, _), Await(_, _))
| (Gen(_, _, _), Gen(_, _, _))
| (Gen(_, _, _, _), Gen(_, _, _, _))
| (Block(_, _), Block(_, _))
| (Closure(_), Closure(_))
| (Match(_, _, _), Match(_, _, _))
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unconditional_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_middle::ty::{self, AssocKind, Ty, TyCtxt};
use rustc_session::impl_lint_pass;
use rustc_span::symbol::{kw, Ident};
use rustc_span::{sym, Span};
use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor;

declare_clippy_lint! {
/// ### What it does
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/ast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
&& eq_fn_decl(lf, rf)
&& eq_expr(le, re)
},
(Gen(lc, lb, lk), Gen(rc, rb, rk)) => lc == rc && eq_block(lb, rb) && lk == rk,
(Gen(lc, lb, lk, _), Gen(rc, rb, rk, _)) => lc == rc && eq_block(lb, rb) && lk == rk,
(Range(lf, lt, ll), Range(rf, rt, rl)) => ll == rl && eq_expr_opt(lf, rf) && eq_expr_opt(lt, rt),
(AddrOf(lbk, lm, le), AddrOf(rbk, rm, re)) => lbk == rbk && lm == rm && eq_expr(le, re),
(Path(lq, lp), Path(rq, rp)) => both(lq, rq, eq_qself) && eq_path(lp, rp),
Expand Down
3 changes: 2 additions & 1 deletion clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ fn check_terminator<'tcx>(
target: _,
unwind: _,
fn_span: _,
} => {
}
| TerminatorKind::TailCall { func, args, fn_span: _ } => {
let fn_ty = func.ty(body, tcx);
if let ty::FnDef(fn_def_id, _) = *fn_ty.kind() {
if !is_const_fn(tcx, fn_def_id, msrv) {
Expand Down
6 changes: 1 addition & 5 deletions clippy_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
return false;
}

for (predicate, _span) in cx
.tcx
.explicit_item_super_predicates(def_id)
.instantiate_identity_iter_copied()
{
for (predicate, _span) in cx.tcx.explicit_item_super_predicates(def_id).iter_identity_copied() {
match predicate.kind().skip_binder() {
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
// and check substitutions to find `U`.
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-06-27"
channel = "nightly-2024-07-11"
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
profile = "minimal"
2 changes: 0 additions & 2 deletions tests/ui/dbg_macro/dbg_macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ LL | dbg!();
help: remove the invocation before committing it to a version control system
|
LL - dbg!();
LL +
|

error: the `dbg!` macro is intended as a debugging tool
Expand Down Expand Up @@ -146,7 +145,6 @@ LL | expand_to_dbg!();
help: remove the invocation before committing it to a version control system
|
LL - dbg!();
LL +
|

error: the `dbg!` macro is intended as a debugging tool
Expand Down
1 change: 0 additions & 1 deletion tests/ui/dbg_macro/dbg_macro_unfixable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ LL | dbg!();
help: remove the invocation before committing it to a version control system
|
LL - dbg!();
LL +
|

error: the `dbg!` macro is intended as a debugging tool
Expand Down
10 changes: 0 additions & 10 deletions tests/ui/manual_split_once.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,10 @@ LL | let (l, r) = "a.b.c".split_once('.').unwrap();
help: remove the `iter` usages
|
LL - let l = iter.next().unwrap();
LL +
|
help: remove the `iter` usages
|
LL - let r = iter.next().unwrap();
LL +
|

error: manual implementation of `split_once`
Expand All @@ -121,12 +119,10 @@ LL | let (l, r) = "a.b.c".split_once('.')?;
help: remove the `iter` usages
|
LL - let l = iter.next()?;
LL +
|
help: remove the `iter` usages
|
LL - let r = iter.next()?;
LL +
|

error: manual implementation of `rsplit_once`
Expand All @@ -146,12 +142,10 @@ LL | let (l, r) = "a.b.c".rsplit_once('.').unwrap();
help: remove the `iter` usages
|
LL - let r = iter.next().unwrap();
LL +
|
help: remove the `iter` usages
|
LL - let l = iter.next().unwrap();
LL +
|

error: manual implementation of `rsplit_once`
Expand All @@ -171,12 +165,10 @@ LL | let (l, r) = "a.b.c".rsplit_once('.')?;
help: remove the `iter` usages
|
LL - let r = iter.next()?;
LL +
|
help: remove the `iter` usages
|
LL - let l = iter.next()?;
LL +
|

error: manual implementation of `split_once`
Expand All @@ -202,12 +194,10 @@ LL | let (a, b) = "a.b.c".split_once('.').unwrap();
help: remove the `iter` usages
|
LL - let a = iter.next().unwrap();
LL +
|
help: remove the `iter` usages
|
LL - let b = iter.next().unwrap();
LL +
|

error: aborting due to 19 previous errors
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/missing_const_for_fn/could_be_const.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,18 @@ fn main() {}

struct D;

/* FIXME(effects)
impl const Drop for D {
fn drop(&mut self) {
todo!();
}
}
*/

// Lint this, since it can be dropped in const contexts
// FIXME(effects)
fn d(this: D) {}
const fn d(this: D) {}
//~^ ERROR: this could be a `const fn`

mod msrv {
struct Foo(*const u8, &'static u8);
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/missing_const_for_fn/could_be_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,18 @@ fn main() {}

struct D;

/* FIXME(effects)
impl const Drop for D {
fn drop(&mut self) {
todo!();
}
}
*/

// Lint this, since it can be dropped in const contexts
// FIXME(effects)
fn d(this: D) {}
//~^ ERROR: this could be a `const fn`

mod msrv {
struct Foo(*const u8, &'static u8);
Expand Down
Loading

0 comments on commit b794b8e

Please sign in to comment.