Skip to content

Commit cbf666d

Browse files
committed
Auto merge of rust-lang#82241 - Dylan-DPC:rollup-munmzg5, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - rust-lang#77728 (Expose force_quotes on Windows.) - rust-lang#80572 (Add a `Result::into_ok_or_err` method to extract a `T` from `Result<T, T>`) - rust-lang#81860 (Fix SourceMap::start_point) - rust-lang#81869 (Simplify pattern grammar, improve or-pattern diagnostics) - rust-lang#81898 (Fix debug information for function arguments of type &str or slice.) - rust-lang#81972 (Placeholder lifetime error cleanup) - rust-lang#82007 (Implement reborrow for closure captures) - rust-lang#82021 (Spell out nested Self type in lint message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 93f6a4b + f7501b6 commit cbf666d

File tree

73 files changed

+1111
-882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1111
-882
lines changed

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

+25-5
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
320320
) -> Option<IndexVec<mir::Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>> {
321321
let full_debug_info = self.cx.sess().opts.debuginfo == DebugInfo::Full;
322322

323+
let target_is_msvc = self.cx.sess().target.is_like_msvc;
324+
323325
if !full_debug_info && self.cx.sess().fewer_names() {
324326
return None;
325327
}
@@ -341,11 +343,29 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
341343
&& var.source_info.scope == mir::OUTERMOST_SOURCE_SCOPE
342344
{
343345
let arg_index = place.local.index() - 1;
344-
345-
// FIXME(eddyb) shouldn't `ArgumentVariable` indices be
346-
// offset in closures to account for the hidden environment?
347-
// Also, is this `+ 1` needed at all?
348-
VariableKind::ArgumentVariable(arg_index + 1)
346+
if target_is_msvc {
347+
// Rust compiler decomposes every &str or slice argument into two components:
348+
// a pointer to the memory address where the data is stored and a usize representing
349+
// the length of the str (or slice). These components will later be used to reconstruct
350+
// the original argument inside the body of the function that owns it (see the
351+
// definition of debug_introduce_local for more details).
352+
//
353+
// Since the original argument is declared inside a function rather than being passed
354+
// in as an argument, it must be marked as a LocalVariable for MSVC debuggers to visualize
355+
// its data correctly. (See issue #81894 for an in-depth description of the problem).
356+
match *var_ty.kind() {
357+
ty::Ref(_, inner_type, _) => match *inner_type.kind() {
358+
ty::Slice(_) | ty::Str => VariableKind::LocalVariable,
359+
_ => VariableKind::ArgumentVariable(arg_index + 1),
360+
},
361+
_ => VariableKind::ArgumentVariable(arg_index + 1),
362+
}
363+
} else {
364+
// FIXME(eddyb) shouldn't `ArgumentVariable` indices be
365+
// offset in closures to account for the hidden environment?
366+
// Also, is this `+ 1` needed at all?
367+
VariableKind::ArgumentVariable(arg_index + 1)
368+
}
349369
} else {
350370
VariableKind::LocalVariable
351371
};

compiler/rustc_expand/src/expand.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
2222
use rustc_data_structures::sync::Lrc;
2323
use rustc_errors::{Applicability, PResult};
2424
use rustc_feature::Features;
25-
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, Parser};
25+
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, GateOr, Parser, RecoverComma};
2626
use rustc_parse::validate_attr;
2727
use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
2828
use rustc_session::lint::BuiltinLintDiagnostics;
@@ -914,7 +914,9 @@ pub fn parse_ast_fragment<'a>(
914914
}
915915
}
916916
AstFragmentKind::Ty => AstFragment::Ty(this.parse_ty()?),
917-
AstFragmentKind::Pat => AstFragment::Pat(this.parse_pat(None)?),
917+
AstFragmentKind::Pat => {
918+
AstFragment::Pat(this.parse_pat_allow_top_alt(None, GateOr::Yes, RecoverComma::No)?)
919+
}
918920
AstFragmentKind::Arms
919921
| AstFragmentKind::Fields
920922
| AstFragmentKind::FieldPats

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> {
4343
self.infcx.tcx
4444
}
4545

46-
pub fn try_report_from_nll(&self) -> Option<DiagnosticBuilder<'cx>> {
46+
pub fn try_report_from_nll(&self) -> Option<DiagnosticBuilder<'tcx>> {
4747
// Due to the improved diagnostics returned by the MIR borrow checker, only a subset of
4848
// the nice region errors are required when running under the MIR borrow checker.
4949
self.try_report_named_anon_conflict().or_else(|| self.try_report_placeholder_conflict())

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty;
99
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
1010
/// When given a `ConcreteFailure` for a function with parameters containing a named region and
1111
/// an anonymous region, emit an descriptive diagnostic error.
12-
pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'a>> {
12+
pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'tcx>> {
1313
let (span, sub, sup) = self.regions()?;
1414

1515
debug!(

0 commit comments

Comments
 (0)