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

Rollup of 7 pull requests #129006

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
a282e52
Unify run button display with "copy code" button and with mdbook buttons
GuillaumeGomez Jul 30, 2024
be71bd9
Update GUI tests for code example buttons
GuillaumeGomez Jul 30, 2024
e2da2fb
Update rustdoc tests
GuillaumeGomez Jul 30, 2024
59cb159
Prevent clicking on a link or on a button to toggle the code example …
GuillaumeGomez Jul 30, 2024
bb5d83d
Clean up rustdoc make_test function code
GuillaumeGomez Jun 8, 2024
15454a9
Add `DocTest` type
GuillaumeGomez Jun 8, 2024
fd66bc3
Simplify doctest tests
GuillaumeGomez Jun 8, 2024
1f8be6e
Split doctests between standalone and mergeable ones
GuillaumeGomez Jun 8, 2024
4589010
Split standalone and mergeable doctests
GuillaumeGomez Jun 8, 2024
1d44d58
Split doctests into two categories: mergeable ones and standalone ones
GuillaumeGomez Jun 10, 2024
8010f43
Only merge doctests starting 2024 edition
GuillaumeGomez Jun 10, 2024
93e7b82
Add new doc codeblock `standalone` attribute
GuillaumeGomez Jun 10, 2024
9f67385
Add documentation for the doctest `standalone` attribute
GuillaumeGomez Apr 30, 2024
3aa9608
Prevent merged doctests to break stdin if the generated file is too big
GuillaumeGomez Jun 10, 2024
40334f6
If there is any AST error with a doctest, we make it a standalone test
GuillaumeGomez Jun 10, 2024
29f4ee9
Correctly handle the case where there is no doctests to run
GuillaumeGomez Jun 10, 2024
7403c2b
Correctly handle doctests with invalid AST
GuillaumeGomez Jun 10, 2024
8f0c9b2
Add/update `rustdoc-ui` tests to check new merged doctests
GuillaumeGomez Jun 10, 2024
366d78e
Add new `run-make` tests for doctests
GuillaumeGomez Jun 10, 2024
3f899ad
Simplify `has_main_fn` to be a boolean instead of a `Option<Span>`
GuillaumeGomez Jun 10, 2024
8e96523
Greatly improve handling of doctests attributes, making it possible t…
GuillaumeGomez Jun 12, 2024
948d17f
Don't merge doctests with `#[global_allocator]`
GuillaumeGomez Jun 13, 2024
2379d23
Fix weird memory allocation failure in merged doctests by storing doc…
GuillaumeGomez Jun 13, 2024
23dc792
Make merged doctests run in their own process
GuillaumeGomez Jun 13, 2024
5e4aad8
Don't change indent in merged doctests
GuillaumeGomez Jun 14, 2024
9dbc84a
Mark location doctest as standalone since file information will not w…
GuillaumeGomez Jun 14, 2024
3632fcf
Correctly handle `internal_features` attribute
GuillaumeGomez Jun 15, 2024
9448e0e
If no argument is provided to merged doctests binary, they will be ru…
GuillaumeGomez Jun 18, 2024
b1aa96a
Only show rustdoc doctest compilation output if `nocapture` is used
GuillaumeGomez Jun 18, 2024
b7a0d2b
Disable merged doctests by default
GuillaumeGomez Jun 18, 2024
6b57b17
Correctly handle macros using `$crate` in merged doctests
GuillaumeGomez Jun 19, 2024
7286d97
Add 2024 edition doctests to cover corner cases
GuillaumeGomez Jun 19, 2024
7471156
Improve code by removing unneeded function arguments
GuillaumeGomez Jun 20, 2024
b4e3659
Add documentation on `DocTest` and `RunnableDoctest` structs
GuillaumeGomez Jun 20, 2024
486fe80
Run mergeable doctest as part of standalone doctests if there is only…
GuillaumeGomez Jun 20, 2024
b55e9b0
Reduce merged doctest source code size
GuillaumeGomez Jun 20, 2024
59d3b71
Rename `DocTest` into `DocTestBuilder`
GuillaumeGomez Jun 23, 2024
e7ff92f
If there are crate attributes, we prevent doctest to be merged with o…
GuillaumeGomez Jun 23, 2024
0ed4e62
Improve code readability
GuillaumeGomez Jun 24, 2024
b92ad6f
Remove need for `unsafe` code in merged doctests
GuillaumeGomez Jul 8, 2024
c66731f
Don't special-case if there is only one merged doctest
GuillaumeGomez Jul 8, 2024
c8280b4
Unify naming of `DocTest`
GuillaumeGomez Jul 9, 2024
8a065b6
Move `is_multiple_tests` argument into `RunnableDocTest`
GuillaumeGomez Jul 9, 2024
60a7936
Improve documentation for internal doctest API
GuillaumeGomez Jul 9, 2024
530a646
Add more merged doctests tests
GuillaumeGomez Jul 9, 2024
d57e6b5
Add doctest to ensure that doctests with crate-level attributes are n…
GuillaumeGomez Jul 11, 2024
7989409
Only keep "useful" code in `tests/rustdoc-ui/2024-doctests-checks.rs`
GuillaumeGomez Jul 11, 2024
10143bb
Fix commands syntax in rustdoc-ui tests
GuillaumeGomez Jul 12, 2024
80d4ccc
Run fmt
GuillaumeGomez Jul 29, 2024
1a256bf
Update `tests/run-make/doctests-keep-binaries-2024/rmake.rs` test to …
GuillaumeGomez Jul 29, 2024
fcaa14e
Ignore cross compile check for `tests/run-make/doctests-keep-binaries…
GuillaumeGomez Aug 7, 2024
03ee7b5
Move verbose help parsing to `main`
Kobzol Aug 9, 2024
5431a93
Pass `Flags` to `Config::parse` explicitly
Kobzol Aug 9, 2024
f83b085
rustc_attr: remove redundant `#[allow(rustc::untranslatable_diagnosti…
GrigorenkoPV Aug 7, 2024
43f3a21
rustc_const_eval: remove redundant `#[allow(rustc::untranslatable_dia…
GrigorenkoPV Aug 7, 2024
3a18c6b
rustc_const_eval: make message about "const stable" translatable
GrigorenkoPV Aug 7, 2024
a11922d
rustc_const_eval: make LazyLock suggestion translatable
GrigorenkoPV Aug 7, 2024
c36b21a
rustc_attr: make "compact `cfg(target(..))` is unstable" translatable
GrigorenkoPV Aug 7, 2024
334a097
rustc_ast_lowering: make "using `_` for array lengths is unstable" tr…
GrigorenkoPV Aug 7, 2024
290df4f
rustc_ast_lowering: make "yield syntax is experimental" translatable
GrigorenkoPV Aug 7, 2024
6760298
rustc_ast_lowering: make asm-related unstability messages translatable
GrigorenkoPV Aug 7, 2024
48413cf
rustc_borrowck: make dereference suggestion translatable
GrigorenkoPV Aug 8, 2024
446e03e
rustc_borrowck: make suggestion to move closure translatable
GrigorenkoPV Aug 8, 2024
1b6cc24
rustc_borrowck: make some suggestion about static lifetimes translatable
GrigorenkoPV Aug 8, 2024
1481ab3
rustc_borrowck: make "implicit static" suff translatable
GrigorenkoPV Aug 8, 2024
f43cdce
rustc_borrowck: fmt
GrigorenkoPV Aug 8, 2024
fbc2459
rustc_expand: remove some redundant `#[allow(rustc::untranslatable_di…
GrigorenkoPV Aug 8, 2024
1373074
rustc_expand: make a message translatable
GrigorenkoPV Aug 8, 2024
cbae581
rustc_interface: remove a redundant `#[allow(rustc::untranslatable_di…
GrigorenkoPV Aug 8, 2024
2babab6
rustc_lint: remove some redundant `#[allow(rustc::untranslatable_diag…
GrigorenkoPV Aug 8, 2024
d548636
rustc_metadata: remove a redundant `#[allow(rustc::untranslatable_dia…
GrigorenkoPV Aug 8, 2024
007cc2c
rustc_metadata: make "link {arg,cfg} is unstable" translatable
GrigorenkoPV Aug 8, 2024
fcdb374
rustc_passes: remove a redundant `#[allow(rustc::untranslatable_diagn…
GrigorenkoPV Aug 9, 2024
f09a2b0
rustc_passes: make some messages in check_attr translatable
GrigorenkoPV Aug 9, 2024
03b6c2f
Fix and enable disabled codegen-units tests
saethlin Aug 10, 2024
68ff453
std::fs::get_path freebsd update.
devnexen Aug 11, 2024
c361c92
Use assert_matches around the compiler
compiler-errors Aug 11, 2024
0d8f56d
Rollup merge of #126245 - GuillaumeGomez:doctest-improvement-v2, r=t-…
GuillaumeGomez Aug 12, 2024
b7b66a3
Rollup merge of #128394 - GuillaumeGomez:run-button, r=t-rustdoc
GuillaumeGomez Aug 12, 2024
3a64051
Rollup merge of #128878 - Kobzol:refactor-flags, r=onur-ozkan
GuillaumeGomez Aug 12, 2024
418f475
Rollup merge of #128886 - GrigorenkoPV:untranslatable-diagnostic, r=n…
GuillaumeGomez Aug 12, 2024
4009df9
Rollup merge of #128929 - saethlin:enable-codegen-units-tests, r=comp…
GuillaumeGomez Aug 12, 2024
8bbf05c
Rollup merge of #128967 - devnexen:get_path_fbsd_upd, r=joboet
GuillaumeGomez Aug 12, 2024
beea4ff
Rollup merge of #128978 - compiler-errors:assert-matches, r=jieyouxu
GuillaumeGomez Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,23 @@ ast_lowering_template_modifier = template modifier

ast_lowering_this_not_async = this is not `async`

ast_lowering_underscore_array_length_unstable =
using `_` for array lengths is unstable

ast_lowering_underscore_expr_lhs_assign =
in expressions, `_` can only be used on the left-hand side of an assignment
.label = `_` not allowed here

ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
ast_lowering_unstable_inline_assembly_const_operands =
const operands for inline assembly are unstable
ast_lowering_unstable_inline_assembly_label_operands =
label operands for inline assembly are unstable
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable

ast_lowering_use_angle_brackets = use angle brackets instead

ast_lowering_yield = yield syntax is experimental
ast_lowering_yield_in_closure =
`yield` can only be used in `#[coroutine]` closures, or `gen` blocks
.suggestion = use `#[coroutine]` to make this closure a coroutine
21 changes: 14 additions & 7 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ use super::errors::{
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
};
use super::LoweringContext;
use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt};
use crate::{
fluent_generated as fluent, ImplTraitContext, ImplTraitPosition, ParamMode,
ResolverAstLoweringExt,
};

impl<'a, 'hir> LoweringContext<'a, 'hir> {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub(crate) fn lower_inline_asm(
&mut self,
sp: Span,
Expand Down Expand Up @@ -52,7 +54,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&self.tcx.sess,
sym::asm_experimental_arch,
sp,
"inline assembly is not stable yet on this architecture",
fluent::ast_lowering_unstable_inline_assembly,
)
.emit();
}
Expand All @@ -64,8 +66,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp });
}
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
feature_err(&self.tcx.sess, sym::asm_unwind, sp, "the `may_unwind` option is unstable")
.emit();
feature_err(
&self.tcx.sess,
sym::asm_unwind,
sp,
fluent::ast_lowering_unstable_may_unwind,
)
.emit();
}

let mut clobber_abis = FxIndexMap::default();
Expand Down Expand Up @@ -182,7 +189,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
sess,
sym::asm_const,
*op_sp,
"const operands for inline assembly are unstable",
fluent::ast_lowering_unstable_inline_assembly_const_operands,
)
.emit();
}
Expand Down Expand Up @@ -246,7 +253,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
sess,
sym::asm_goto,
*op_sp,
"label operands for inline assembly are unstable",
fluent::ast_lowering_unstable_inline_assembly_label_operands,
)
.emit();
}
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use super::{
ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt,
};
use crate::errors::YieldInClosure;
use crate::{FnDeclKind, ImplTraitPosition};
use crate::{fluent_generated, FnDeclKind, ImplTraitPosition};

impl<'hir> LoweringContext<'_, 'hir> {
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
Expand Down Expand Up @@ -1540,7 +1540,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
let yielded =
opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span));
Expand Down Expand Up @@ -1575,7 +1574,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&self.tcx.sess,
sym::coroutines,
span,
"yield syntax is experimental",
fluent_generated::ast_lowering_yield,
)
.emit();
}
Expand All @@ -1587,7 +1586,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&self.tcx.sess,
sym::coroutines,
span,
"yield syntax is experimental",
fluent_generated::ast_lowering_yield,
)
.emit();
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.expr_block(block)
}

#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> {
match c.value.kind {
ExprKind::Underscore => {
Expand All @@ -2340,7 +2339,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&self.tcx.sess,
sym::generic_arg_infer,
c.value.span,
"using `_` for array lengths is unstable",
fluent_generated::ast_lowering_underscore_array_length_unstable,
)
.stash(c.value.span, StashKey::UnderscoreForArrayLengths);
hir::ArrayLen::Body(self.lower_anon_const_to_const_arg(c))
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_attr/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ attr_unknown_meta_item =
attr_unknown_version_literal =
unknown version literal format, assuming it refers to a future version

attr_unstable_cfg_target_compact =
compact `cfg(target(..))` is experimental and subject to change

attr_unsupported_literal_cfg_string =
literal in `cfg` predicate value must be a string
attr_unsupported_literal_deprecated_kv_pair =
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;

use crate::fluent_generated;
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};

/// The version placeholder that recently stabilized features contain inside the
Expand Down Expand Up @@ -521,7 +522,6 @@ pub struct Condition {
}

/// Tests if a cfg-pattern matches the cfg set
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub fn cfg_matches(
cfg: &ast::MetaItem,
sess: &Session,
Expand Down Expand Up @@ -593,7 +593,6 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {

/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
/// evaluate individual items.
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
pub fn eval_condition(
cfg: &ast::MetaItem,
sess: &Session,
Expand Down Expand Up @@ -680,7 +679,7 @@ pub fn eval_condition(
sess,
sym::cfg_target_compact,
cfg.span,
"compact `cfg(target(..))` is experimental and subject to change",
fluent_generated::attr_unstable_cfg_target_compact,
)
.emit();
}
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_borrowck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ borrowck_could_not_normalize =
borrowck_could_not_prove =
could not prove `{$predicate}`

borrowck_dereference_suggestion =
dereference the return value

borrowck_func_take_self_moved_place =
`{$func}` takes ownership of the receiver `self`, which moves {$place_name}

Expand All @@ -74,9 +77,24 @@ borrowck_higher_ranked_lifetime_error =
borrowck_higher_ranked_subtype_error =
higher-ranked subtype error

borrowck_implicit_static =
this has an implicit `'static` lifetime requirement

borrowck_implicit_static_introduced =
calling this method introduces the `impl`'s `'static` requirement

borrowck_implicit_static_relax =
consider relaxing the implicit `'static` requirement

borrowck_lifetime_constraints_error =
lifetime may not live long enough

borrowck_limitations_implies_static =
due to current limitations in the borrow checker, this implies a `'static` lifetime

borrowck_move_closure_suggestion =
consider adding 'move' keyword before the nested closure

borrowck_move_out_place_here =
{$place} is moved here

Expand Down Expand Up @@ -163,6 +181,9 @@ borrowck_partial_var_move_by_use_in_coroutine =
*[false] moved
} due to use in coroutine

borrowck_restrict_to_static =
consider restricting the type parameter to the `'static` lifetime

borrowck_returned_async_block_escaped =
returns an `async` block that contains a reference to a captured variable, which then escapes the closure body

Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]

use std::assert_matches::assert_matches;

use rustc_errors::{Applicability, Diag};
use rustc_hir as hir;
use rustc_hir::intravisit::Visitor;
Expand Down Expand Up @@ -116,7 +118,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
// path_span must be `Some` as otherwise the if condition is true
let path_span = path_span.unwrap();
// path_span is only present in the case of closure capture
assert!(matches!(later_use_kind, LaterUseKind::ClosureCapture));
assert_matches!(later_use_kind, LaterUseKind::ClosureCapture);
if !borrow_span.is_some_and(|sp| sp.overlaps(var_or_use_span)) {
let path_label = "used here by closure";
let capture_kind_label = message;
Expand Down Expand Up @@ -147,7 +149,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
// path_span must be `Some` as otherwise the if condition is true
let path_span = path_span.unwrap();
// path_span is only present in the case of closure capture
assert!(matches!(later_use_kind, LaterUseKind::ClosureCapture));
assert_matches!(later_use_kind, LaterUseKind::ClosureCapture);
if borrow_span.map(|sp| !sp.overlaps(var_or_use_span)).unwrap_or(true) {
let path_label = "used here by closure";
let capture_kind_label = message;
Expand Down
64 changes: 31 additions & 33 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::session_diagnostics::{
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
};
use crate::universal_regions::DefiningTy;
use crate::{borrowck_errors, MirBorrowckCtxt};
use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt};

impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
fn description(&self) -> &'static str {
Expand Down Expand Up @@ -198,7 +198,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait
// and the span which bounded to the trait for adding 'static lifetime suggestion
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn suggest_static_lifetime_for_gat_from_hrtb(
&self,
diag: &mut Diag<'_>,
Expand Down Expand Up @@ -251,23 +250,28 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
debug!(?hrtb_bounds);

hrtb_bounds.iter().for_each(|bound| {
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
diag.span_note(
*trait_span,
"due to current limitations in the borrow checker, this implies a `'static` lifetime"
);
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else {
return;
};
diag.span_note(*trait_span, fluent::borrowck_limitations_implies_static);
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local())
else {
return;
};
let Def(_, trait_res_defid) = trait_ref.path.res else {
return;
};
debug!(?generics_fn);
generics_fn.predicates.iter().for_each(|predicate| {
let BoundPredicate(
WhereBoundPredicate {
span: bounded_span,
bounded_ty,
bounds,
..
}
) = predicate else { return; };
let BoundPredicate(WhereBoundPredicate {
span: bounded_span,
bounded_ty,
bounds,
..
}) = predicate
else {
return;
};
bounds.iter().for_each(|bd| {
if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd
&& let Def(_, res_defid) = tr_ref.path.res
Expand All @@ -277,16 +281,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
&& generics_fn.params
.iter()
.rfind(|param| param.def_id.to_def_id() == defid)
.is_some() {
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
}
.is_some()
{
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
}
});
});
});
if suggestions.len() > 0 {
suggestions.dedup();
diag.multipart_suggestion_verbose(
"consider restricting the type parameter to the `'static` lifetime",
fluent::borrowck_restrict_to_static,
suggestions,
Applicability::MaybeIncorrect,
);
Expand Down Expand Up @@ -976,7 +981,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
}

#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
#[instrument(skip(self, err), level = "debug")]
fn suggest_constrain_dyn_trait_in_impl(
&self,
Expand All @@ -994,16 +998,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
debug!("trait spans found: {:?}", traits);
for span in &traits {
let mut multi_span: MultiSpan = vec![*span].into();
multi_span
.push_span_label(*span, "this has an implicit `'static` lifetime requirement");
multi_span.push_span_label(
ident.span,
"calling this method introduces the `impl`'s `'static` requirement",
);
multi_span.push_span_label(*span, fluent::borrowck_implicit_static);
multi_span.push_span_label(ident.span, fluent::borrowck_implicit_static_introduced);
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
err.span_suggestion_verbose(
span.shrink_to_hi(),
"consider relaxing the implicit `'static` requirement",
fluent::borrowck_implicit_static_relax,
" + '_",
Applicability::MaybeIncorrect,
);
Expand Down Expand Up @@ -1045,7 +1045,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
}

#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
/// When encountering a lifetime error caused by the return type of a closure, check the
/// corresponding trait bound and see if dereferencing the closure return value would satisfy
/// them. If so, we produce a structured suggestion.
Expand Down Expand Up @@ -1166,15 +1165,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
if ocx.select_all_or_error().is_empty() && count > 0 {
diag.span_suggestion_verbose(
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
"dereference the return value",
fluent::borrowck_dereference_suggestion,
"*".repeat(count),
Applicability::MachineApplicable,
);
}
}

#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
let map = self.infcx.tcx.hir();
let body = map.body_owned_by(self.mir_def_id());
Expand Down Expand Up @@ -1213,7 +1211,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
if let Some(closure_span) = closure_span {
diag.span_suggestion_verbose(
closure_span,
"consider adding 'move' keyword before the nested closure",
fluent::borrowck_move_closure_suggestion,
"move ",
Applicability::MaybeIncorrect,
);
Expand Down
Loading
Loading