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 9 pull requests #94514

Merged
merged 24 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
abcccc9
Suggest adding a new lifetime parameter when two elided lifetimes sho…
kckeiks Feb 28, 2022
7aa5ea9
7 - Make more use of `let_chains`
c410-f3r Mar 1, 2022
741553e
Fix panic when intra-doc link comes from a generated doc comment
GuillaumeGomez Mar 1, 2022
885e808
Add test to ensure it does not panic when an intra-doc link is genera…
GuillaumeGomez Mar 1, 2022
eb2b944
compiler: fix some typos
cuishuang Mar 1, 2022
8e04049
Update books
ehuss Mar 1, 2022
270730f
add suggestion to update trait if error is in impl
kckeiks Mar 1, 2022
1b08cba
update (bless) test results
kckeiks Mar 1, 2022
26c5d21
tests: accept llvm intrinsic in align-checking test
durin42 Mar 1, 2022
6fbef7f
tests: avoid problems on 32 bit machines
durin42 Mar 1, 2022
a7b4d66
9 - Make more use of `let_chains`
c410-f3r Mar 1, 2022
0f505c6
Add a copy of cfg_if to core's internal_macros.rs
joshtriplett Mar 2, 2022
335c960
Provide C FFI types via core::ffi, not just in std
joshtriplett Mar 1, 2022
75c3e9c
Temporarily make `CStr` not a link in the `c_char` docs
joshtriplett Mar 2, 2022
50790a9
update Miri
RalfJung Mar 2, 2022
2b72ecb
Rollup merge of #94464 - kckeiks:lifetime-elision-mismatch-hint-for-t…
matthiaskrgr Mar 2, 2022
42596a7
Rollup merge of #94476 - c410-f3r:yet-more-let-chains, r=Dylan-DPC
matthiaskrgr Mar 2, 2022
64e16d3
Rollup merge of #94478 - GuillaumeGomez:macro-generated-intra-doc-lin…
matthiaskrgr Mar 2, 2022
cd6e53d
Rollup merge of #94482 - cuishuang:master, r=Dylan-DPC
matthiaskrgr Mar 2, 2022
823a386
Rollup merge of #94490 - ehuss:update-books, r=ehuss
matthiaskrgr Mar 2, 2022
aabd068
Rollup merge of #94496 - durin42:llvm-15-moar-intrinsic, r=nikic
matthiaskrgr Mar 2, 2022
1ff654a
Rollup merge of #94498 - c410-f3r:chega-ja-deu, r=Dylan-DPC
matthiaskrgr Mar 2, 2022
3ea9eeb
Rollup merge of #94503 - joshtriplett:core-ffi-c, r=Amanieu
matthiaskrgr Mar 2, 2022
e89ab08
Rollup merge of #94513 - RalfJung:miri, r=RalfJung
matthiaskrgr Mar 2, 2022
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
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
generics: &Generics,
itctx: ImplTraitContext<'_, 'hir>,
) -> GenericsCtor<'hir> {
// Error if `?Trait` bounds in where clauses don't refer directly to type paramters.
// Error if `?Trait` bounds in where clauses don't refer directly to type parameters.
// Note: we used to clone these bounds directly onto the type parameter (and avoid lowering
// these into hir when we lower thee where clauses), but this makes it quite difficult to
// keep track of the Span info. Now, `add_implicitly_sized` in `AstConv` checks both param bounds and
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
.find_map(|constraint| {
if let ConstraintCategory::Predicate(predicate_span) = constraint.category {
// We currentl'y doesn't store the `DefId` in the `ConstraintCategory`
// for perforamnce reasons. The error reporting code used by NLL only
// for performances reasons. The error reporting code used by NLL only
// uses the span, so this doesn't cause any problems at the moment.
Some(ObligationCauseCode::BindingObligation(
CRATE_DEF_ID.to_def_id(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl CfgEval<'_, '_> {

// Re-parse the tokens, setting the `capture_cfg` flag to save extra information
// to the captured `AttrAnnotatedTokenStream` (specifically, we capture
// `AttrAnnotatedTokenTree::AttributesData` for all occurences of `#[cfg]` and `#[cfg_attr]`)
// `AttrAnnotatedTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`)
let mut parser =
rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None);
parser.capture_cfg = true;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(

// ... and otherwise we're processing a `*.dwp` packed dwarf file.
//
// We cannot rely on the .o paths in the exectuable because they may have been
// We cannot rely on the .o paths in the executable because they may have been
// remapped by --remap-path-prefix and therefore invalid, so we need to provide
// the .o/.dwo paths explicitly.
SplitDebuginfo::Packed => link_dwarf_object(sess, codegen_results, out_filename),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ impl<'a> Linker for WasmLd<'a> {
}

// LLD will hide these otherwise-internal symbols since it only exports
// symbols explicity passed via the `--export` flags above and hides all
// symbols explicitly passed via the `--export` flags above and hides all
// others. Various bits and pieces of tooling use this, so be sure these
// symbols make their way out of the linker as well.
self.cmd.arg("--export=__heap_base");
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/sso/either_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::iter::Iterator;
/// one of two specific implementations.
///
/// Note: For most methods providing custom
/// implementation may margianlly
/// implementation may marginally
/// improve performance by avoiding
/// doing Left/Right match on every step
/// and doing it only once instead.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl DefPathTable {
// Continuing with colliding DefPathHashes can lead to correctness
// issues. We must abort compilation.
//
// The likelyhood of such a collision is very small, so actually
// The likelihood of such a collision is very small, so actually
// running into one could be indicative of a poor hash function
// being used.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,59 +166,61 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
if lifetime_sub.name.is_elided() && lifetime_sup.name.is_elided() {
if let Some(anon_reg) = self.tcx().is_suitable_region(sub) {
let hir_id = self.tcx().hir().local_def_id_to_hir_id(anon_reg.def_id);
if let hir::Node::Item(&hir::Item {
kind: hir::ItemKind::Fn(_, ref generics, ..),
..
}) = self.tcx().hir().get(hir_id)
{
let (suggestion_param_name, introduce_new) = generics
.params
.iter()
.find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
.and_then(|p| self.tcx().sess.source_map().span_to_snippet(p.span).ok())
.map(|name| (name, false))
.unwrap_or_else(|| ("'a".to_string(), true));

let mut suggestions = vec![
if let hir::LifetimeName::Underscore = lifetime_sub.name {
(lifetime_sub.span, suggestion_param_name.clone())
} else {
(
lifetime_sub.span.shrink_to_hi(),
suggestion_param_name.clone() + " ",
)
},
if let hir::LifetimeName::Underscore = lifetime_sup.name {
(lifetime_sup.span, suggestion_param_name.clone())
} else {
(
lifetime_sup.span.shrink_to_hi(),
suggestion_param_name.clone() + " ",
)
},
];

if introduce_new {
let new_param_suggestion = match &generics.params {
[] => (generics.span, format!("<{}>", suggestion_param_name)),
[first, ..] => (
first.span.shrink_to_lo(),
format!("{}, ", suggestion_param_name),
),
};

suggestions.push(new_param_suggestion);
}

err.multipart_suggestion(
"consider introducing a named lifetime parameter",
suggestions,
Applicability::MaybeIncorrect,
);
err.note(
"each elided lifetime in input position becomes a distinct lifetime",
);

let node = self.tcx().hir().get(hir_id);
let is_impl = matches!(&node, hir::Node::ImplItem(_));
let generics = match node {
hir::Node::Item(&hir::Item {
kind: hir::ItemKind::Fn(_, ref generics, ..),
..
})
| hir::Node::TraitItem(&hir::TraitItem { ref generics, .. })
| hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => generics,
_ => return,
};

let (suggestion_param_name, introduce_new) = generics
.params
.iter()
.find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
.and_then(|p| self.tcx().sess.source_map().span_to_snippet(p.span).ok())
.map(|name| (name, false))
.unwrap_or_else(|| ("'a".to_string(), true));

let mut suggestions = vec![
if let hir::LifetimeName::Underscore = lifetime_sub.name {
(lifetime_sub.span, suggestion_param_name.clone())
} else {
(lifetime_sub.span.shrink_to_hi(), suggestion_param_name.clone() + " ")
},
if let hir::LifetimeName::Underscore = lifetime_sup.name {
(lifetime_sup.span, suggestion_param_name.clone())
} else {
(lifetime_sup.span.shrink_to_hi(), suggestion_param_name.clone() + " ")
},
];

if introduce_new {
let new_param_suggestion = match &generics.params {
[] => (generics.span, format!("<{}>", suggestion_param_name)),
[first, ..] => {
(first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name))
}
};

suggestions.push(new_param_suggestion);
}

let mut sugg = String::from("consider introducing a named lifetime parameter");
if is_impl {
sugg.push_str(" and update trait if needed");
}
err.multipart_suggestion(
sugg.as_str(),
suggestions,
Applicability::MaybeIncorrect,
);
err.note("each elided lifetime in input position becomes a distinct lifetime");
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_mir_transform/src/const_debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ fn find_optimization_oportunities<'tcx>(body: &Body<'tcx>) -> Vec<(Local, Consta

let mut locals_to_debuginfo = BitSet::new_empty(body.local_decls.len());
for debuginfo in &body.var_debug_info {
if let VarDebugInfoContents::Place(p) = debuginfo.value {
if let Some(l) = p.as_local() {
locals_to_debuginfo.insert(l);
}
if let VarDebugInfoContents::Place(p) = debuginfo.value && let Some(l) = p.as_local() {
locals_to_debuginfo.insert(l);
}
}

Expand Down
50 changes: 23 additions & 27 deletions compiler/rustc_mir_transform/src/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,24 +633,22 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
fn propagate_operand(&mut self, operand: &mut Operand<'tcx>) {
match *operand {
Operand::Copy(l) | Operand::Move(l) => {
if let Some(value) = self.get_const(l) {
if self.should_const_prop(&value) {
// FIXME(felix91gr): this code only handles `Scalar` cases.
// For now, we're not handling `ScalarPair` cases because
// doing so here would require a lot of code duplication.
// We should hopefully generalize `Operand` handling into a fn,
// and use it to do const-prop here and everywhere else
// where it makes sense.
if let interpret::Operand::Immediate(interpret::Immediate::Scalar(
ScalarMaybeUninit::Scalar(scalar),
)) = *value
{
*operand = self.operand_from_scalar(
scalar,
value.layout.ty,
self.source_info.unwrap().span,
);
}
if let Some(value) = self.get_const(l) && self.should_const_prop(&value) {
// FIXME(felix91gr): this code only handles `Scalar` cases.
// For now, we're not handling `ScalarPair` cases because
// doing so here would require a lot of code duplication.
// We should hopefully generalize `Operand` handling into a fn,
// and use it to do const-prop here and everywhere else
// where it makes sense.
if let interpret::Operand::Immediate(interpret::Immediate::Scalar(
ScalarMaybeUninit::Scalar(scalar),
)) = *value
{
*operand = self.operand_from_scalar(
scalar,
value.layout.ty,
self.source_info.unwrap().span,
);
}
}
}
Expand Down Expand Up @@ -1086,15 +1084,13 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
// This will return None if the above `const_prop` invocation only "wrote" a
// type whose creation requires no write. E.g. a generator whose initial state
// consists solely of uninitialized memory (so it doesn't capture any locals).
if let Some(ref value) = self.get_const(place) {
if self.should_const_prop(value) {
trace!("replacing {:?} with {:?}", rval, value);
self.replace_with_const(rval, value, source_info);
if can_const_prop == ConstPropMode::FullConstProp
|| can_const_prop == ConstPropMode::OnlyInsideOwnBlock
{
trace!("propagated into {:?}", place);
}
if let Some(ref value) = self.get_const(place) && self.should_const_prop(value) {
trace!("replacing {:?} with {:?}", rval, value);
self.replace_with_const(rval, value, source_info);
if can_const_prop == ConstPropMode::FullConstProp
|| can_const_prop == ConstPropMode::OnlyInsideOwnBlock
{
trace!("propagated into {:?}", place);
}
}
match can_const_prop {
Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_mir_transform/src/coverage/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,12 @@ impl DebugCounters {
if let Some(counters) = &self.some_counters {
if let Some(DebugCounter { counter_kind, some_block_label }) = counters.get(&operand) {
if let CoverageKind::Expression { .. } = counter_kind {
if let Some(block_label) = some_block_label {
if debug_options().counter_format.block {
return format!(
"{}:({})",
block_label,
self.format_counter_kind(counter_kind)
);
}
if let Some(label) = some_block_label && debug_options().counter_format.block {
return format!(
"{}:({})",
label,
self.format_counter_kind(counter_kind)
);
}
return format!("({})", self.format_counter_kind(counter_kind));
}
Expand Down
43 changes: 19 additions & 24 deletions compiler/rustc_mir_transform/src/coverage/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,13 @@ impl CoverageSpan {
/// If the span is part of a macro, and the macro is visible (expands directly to the given
/// body_span), returns the macro name symbol.
pub fn visible_macro(&self, body_span: Span) -> Option<Symbol> {
if let Some(current_macro) = self.current_macro() {
if self
.expn_span
.parent_callsite()
.unwrap_or_else(|| bug!("macro must have a parent"))
.ctxt()
== body_span.ctxt()
{
return Some(current_macro);
}
if let Some(current_macro) = self.current_macro() && self
.expn_span
.parent_callsite()
.unwrap_or_else(|| bug!("macro must have a parent"))
.ctxt() == body_span.ctxt()
{
return Some(current_macro);
}
None
}
Expand Down Expand Up @@ -584,21 +581,19 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
/// In either case, no more spans will match the span of `pending_dups`, so
/// add the `pending_dups` if they don't overlap `curr`, and clear the list.
fn check_pending_dups(&mut self) {
if let Some(dup) = self.pending_dups.last() {
if dup.span != self.prev().span {
debug!(
" SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
previous iteration, or prev started a new disjoint span"
);
if dup.span.hi() <= self.curr().span.lo() {
let pending_dups = self.pending_dups.split_off(0);
for dup in pending_dups.into_iter() {
debug!(" ...adding at least one pending={:?}", dup);
self.push_refined_span(dup);
}
} else {
self.pending_dups.clear();
if let Some(dup) = self.pending_dups.last() && dup.span != self.prev().span {
debug!(
" SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
previous iteration, or prev started a new disjoint span"
);
if dup.span.hi() <= self.curr().span.lo() {
let pending_dups = self.pending_dups.split_off(0);
for dup in pending_dups.into_iter() {
debug!(" ...adding at least one pending={:?}", dup);
self.push_refined_span(dup);
}
} else {
self.pending_dups.clear();
}
}
}
Expand Down
Loading