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 #99726

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
8 changes: 3 additions & 5 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '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".to_string(),
);
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".to_string(),
"calling this method introduces the `impl`'s 'static` requirement",
);
err.span_note(multi_span, "the used `impl` has a `'static` requirement");
err.span_suggestion_verbose(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

// Now determine the actual method to call. We can do that in two different ways and
// compare them to ensure everything fits.
let ty::VtblEntry::Method(fn_inst) = self.get_vtable_entries(vptr)?[idx] else {
span_bug!(self.cur_span(), "dyn call index points at something that is not a method")
let Some(ty::VtblEntry::Method(fn_inst)) = self.get_vtable_entries(vptr)?.get(idx).copied() else {
throw_ub_format!("`dyn` call trying to call something that is not a method")
};
if cfg!(debug_assertions) {
let tcx = *self.tcx;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ fn adt_defined_here<'p, 'tcx>(
let mut span: MultiSpan =
if spans.is_empty() { def_span.into() } else { spans.clone().into() };

span.push_span_label(def_span, String::new());
span.push_span_label(def_span, "");
for pat in spans {
span.push_span_label(pat, "not covered");
}
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_mir_transform/src/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub fn remove_dead_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
/// with `0` executions.
///
/// If there are no live `Counter` `Coverage` statements remaining, we remove
/// dead `Coverage` statements along with the dead blocks. Since at least one
/// `Coverage` statements along with the dead blocks. Since at least one
/// counter per function is required by LLVM (and necessary, to add the
/// `function_hash` to the counter's call to the LLVM intrinsic
/// `instrprof.increment()`).
Expand All @@ -342,6 +342,16 @@ fn save_unreachable_coverage(
}
}

for block in &mut basic_blocks.raw[..first_dead_block] {
for statement in &mut block.statements {
let StatementKind::Coverage(_) = &statement.kind else { continue };
let instance = statement.source_info.scope.inlined_instance(source_scopes);
if !live.contains(&instance) {
statement.make_nop();
}
}
}

if live.is_empty() {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,7 @@ impl<'a> Resolver<'a> {
} else if let Some(sp) = sm.generate_fn_name_span(span) {
err.span_label(
sp,
"try adding a local generic parameter in this method instead"
.to_string(),
"try adding a local generic parameter in this method instead",
);
} else {
err.help("try using a local generic parameter instead");
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_span/src/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,17 +586,6 @@ impl SourceMap {
}
}

/// Returns whether or not this span points into a file
/// in the current crate. This may be `false` for spans
/// produced by a macro expansion, or for spans associated
/// with the definition of an item in a foreign crate
pub fn is_local_span(&self, sp: Span) -> bool {
let local_begin = self.lookup_byte_offset(sp.lo());
let local_end = self.lookup_byte_offset(sp.hi());
// This might be a weird span that covers multiple files
local_begin.sf.src.is_some() && local_end.sf.src.is_some()
}

pub fn is_span_accessible(&self, sp: Span) -> bool {
self.span_to_source(sp, |src, start_index, end_index| {
Ok(src.get(start_index..end_index).is_some())
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/astconv/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_middle::ty;
use rustc_session::parse::feature_err;
use rustc_span::lev_distance::find_best_match_for_name;
use rustc_span::symbol::{sym, Ident};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::{Span, Symbol, DUMMY_SP};

use std::collections::BTreeSet;

Expand All @@ -17,7 +17,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
/// the type parameter's name as a placeholder.
pub(crate) fn complain_about_missing_type_params(
&self,
missing_type_params: Vec<String>,
missing_type_params: Vec<Symbol>,
def_id: DefId,
span: Span,
empty_generic_args: bool,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
def_id: DefId,
generic_args: &'a GenericArgs<'a>,
span: Span,
missing_type_params: Vec<String>,
missing_type_params: Vec<Symbol>,
inferred_params: Vec<Span>,
infer_args: bool,
is_object: bool,
Expand Down Expand Up @@ -514,7 +514,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// defaults. This will lead to an ICE if we are not
// careful!
if self.default_needs_object_self(param) {
self.missing_type_params.push(param.name.to_string());
self.missing_type_params.push(param.name);
tcx.ty_error().into()
} else {
// This is a default type parameter.
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub struct UnconstrainedOpaqueType {
pub struct MissingTypeParams {
pub span: Span,
pub def_span: Span,
pub missing_type_params: Vec<String>,
pub missing_type_params: Vec<Symbol>,
pub empty_generic_args: bool,
}

Expand Down Expand Up @@ -285,7 +285,15 @@ impl<'a> SessionDiagnostic<'a> for MissingTypeParams {
err.span_suggestion(
self.span,
rustc_errors::fluent::typeck::suggestion,
format!("{}<{}>", snippet, self.missing_type_params.join(", ")),
format!(
"{}<{}>",
snippet,
self.missing_type_params
.iter()
.map(|n| n.to_string())
.collect::<Vec<_>>()
.join(", ")
),
Applicability::HasPlaceholders,
);
suggested = true;
Expand Down
10 changes: 5 additions & 5 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,11 @@ use crate::vec::Vec;
///
/// ```text
/// 0
/// 5
/// 10
/// 20
/// 20
/// 40
/// 8
/// 16
/// 16
/// 32
/// 32
/// ```
///
/// At first, we have no memory allocated at all, but as we append to the
Expand Down
Loading