Skip to content

Commit dd3e883

Browse files
committed
Auto merge of rust-lang#125725 - matthiaskrgr:rollup-713qn6h, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#107099 (rustdoc: Add support for --remap-path-prefix) - rust-lang#125693 (Format all source files in `tests/coverage/`) - rust-lang#125700 (coverage: Avoid overflow when the MC/DC condition limit is exceeded) - rust-lang#125705 (Reintroduce name resolution check for trying to access locals from an inline const) - rust-lang#125708 (tier 3 target policy: clarify the point about producing assembly) - rust-lang#125715 (remove unneeded extern crate in rmake test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a83f933 + 89e1aad commit dd3e883

Some content is hidden

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

44 files changed

+564
-125
lines changed

Diff for: compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,13 @@ impl MCDCInfoBuilder {
217217
}
218218
_ => {
219219
// Do not generate mcdc mappings and statements for decisions with too many conditions.
220-
let rebase_idx = self.branch_spans.len() - decision.conditions_num + 1;
220+
// Therefore, first erase the condition info of the (N-1) previous branch spans.
221+
let rebase_idx = self.branch_spans.len() - (decision.conditions_num - 1);
221222
for branch in &mut self.branch_spans[rebase_idx..] {
222223
branch.condition_info = None;
223224
}
224225

225-
// ConditionInfo of this branch shall also be reset.
226+
// Then, erase this last branch span's info too, for a total of N.
226227
condition_info = None;
227228

228229
tcx.dcx().emit_warn(MCDCExceedsConditionNumLimit {

Diff for: compiler/rustc_resolve/src/late.rs

+5
Original file line numberDiff line numberDiff line change
@@ -4505,6 +4505,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
45054505
self.visit_expr(elem);
45064506
self.resolve_anon_const(ct, AnonConstKind::ConstArg(IsRepeatExpr::Yes));
45074507
}
4508+
ExprKind::ConstBlock(ref expr) => {
4509+
self.resolve_anon_const_manual(false, AnonConstKind::InlineConst, |this| {
4510+
this.visit_expr(expr)
4511+
});
4512+
}
45084513
ExprKind::Index(ref elem, ref idx, _) => {
45094514
self.resolve_expr(elem, Some(expr));
45104515
self.visit_expr(idx);

Diff for: src/doc/rustc/src/target-tier-policy.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ approved by the appropriate team for that shared code before acceptance.
247247
target may not have; use conditional compilation or runtime detection, as
248248
appropriate, to let each target run code supported by that target.
249249
- Tier 3 targets must be able to produce assembly using at least one of
250-
rustc's supported backends from any host target.
250+
rustc's supported backends from any host target. (Having support in a fork
251+
of the backend is not sufficient, it must be upstream.)
251252

252253
If a tier 3 target stops meeting these requirements, or the target maintainers
253254
no longer have interest or time, or the target shows no signs of activity and

Diff for: src/librustdoc/config.rs

+26
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ pub(crate) struct Options {
128128
pub(crate) enable_per_target_ignores: bool,
129129
/// Do not run doctests, compile them if should_test is active.
130130
pub(crate) no_run: bool,
131+
/// What sources are being mapped.
132+
pub(crate) remap_path_prefix: Vec<(PathBuf, PathBuf)>,
131133

132134
/// The path to a rustc-like binary to build tests with. If not set, we
133135
/// default to loading from `$sysroot/bin/rustc`.
@@ -211,6 +213,7 @@ impl fmt::Debug for Options {
211213
.field("run_check", &self.run_check)
212214
.field("no_run", &self.no_run)
213215
.field("test_builder_wrappers", &self.test_builder_wrappers)
216+
.field("remap-file-prefix", &self.remap_path_prefix)
214217
.field("nocapture", &self.nocapture)
215218
.field("scrape_examples_options", &self.scrape_examples_options)
216219
.field("unstable_features", &self.unstable_features)
@@ -372,6 +375,13 @@ impl Options {
372375
let codegen_options = CodegenOptions::build(early_dcx, matches);
373376
let unstable_opts = UnstableOptions::build(early_dcx, matches);
374377

378+
let remap_path_prefix = match parse_remap_path_prefix(&matches) {
379+
Ok(prefix_mappings) => prefix_mappings,
380+
Err(err) => {
381+
early_dcx.early_fatal(err);
382+
}
383+
};
384+
375385
let dcx = new_dcx(error_format, None, diagnostic_width, &unstable_opts);
376386

377387
// check for deprecated options
@@ -772,6 +782,7 @@ impl Options {
772782
run_check,
773783
no_run,
774784
test_builder_wrappers,
785+
remap_path_prefix,
775786
nocapture,
776787
crate_name,
777788
output_format,
@@ -820,6 +831,21 @@ impl Options {
820831
}
821832
}
822833

834+
fn parse_remap_path_prefix(
835+
matches: &getopts::Matches,
836+
) -> Result<Vec<(PathBuf, PathBuf)>, &'static str> {
837+
matches
838+
.opt_strs("remap-path-prefix")
839+
.into_iter()
840+
.map(|remap| {
841+
remap
842+
.rsplit_once('=')
843+
.ok_or("--remap-path-prefix must contain '=' between FROM and TO")
844+
.map(|(from, to)| (PathBuf::from(from), PathBuf::from(to)))
845+
})
846+
.collect()
847+
}
848+
823849
/// Prints deprecation warnings for deprecated options
824850
fn check_deprecated_options(matches: &getopts::Matches, dcx: &rustc_errors::DiagCtxt) {
825851
let deprecated_flags = [];

Diff for: src/librustdoc/doctest.rs

+14-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_session::config::{self, CrateType, ErrorOutputType};
1616
use rustc_session::parse::ParseSess;
1717
use rustc_session::{lint, Session};
1818
use rustc_span::edition::Edition;
19-
use rustc_span::source_map::SourceMap;
19+
use rustc_span::source_map::{FilePathMapping, SourceMap};
2020
use rustc_span::symbol::sym;
2121
use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP};
2222
use rustc_target::spec::{Target, TargetTriple};
@@ -128,6 +128,7 @@ pub(crate) fn run(
128128
edition: options.edition,
129129
target_triple: options.target.clone(),
130130
crate_name: options.crate_name.clone(),
131+
remap_path_prefix: options.remap_path_prefix.clone(),
131132
..config::Options::default()
132133
};
133134

@@ -612,7 +613,6 @@ pub(crate) fn make_test(
612613
use rustc_errors::emitter::{Emitter, HumanEmitter};
613614
use rustc_errors::DiagCtxt;
614615
use rustc_parse::parser::ForceCollect;
615-
use rustc_span::source_map::FilePathMapping;
616616

617617
let filename = FileName::anon_source_code(s);
618618
let source = crates + everything_else;
@@ -803,7 +803,6 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
803803
rustc_span::create_session_if_not_set_then(edition, |_| {
804804
use rustc_errors::emitter::HumanEmitter;
805805
use rustc_errors::DiagCtxt;
806-
use rustc_span::source_map::FilePathMapping;
807806

808807
let filename = FileName::anon_source_code(source);
809808
// Any errors in parsing should also appear when the doctest is compiled for real, so just
@@ -1066,7 +1065,7 @@ impl Collector {
10661065
if !item_path.is_empty() {
10671066
item_path.push(' ');
10681067
}
1069-
format!("{} - {item_path}(line {line})", filename.prefer_local())
1068+
format!("{} - {item_path}(line {line})", filename.prefer_remapped_unconditionaly())
10701069
}
10711070

10721071
pub(crate) fn set_position(&mut self, position: Span) {
@@ -1076,11 +1075,15 @@ impl Collector {
10761075
fn get_filename(&self) -> FileName {
10771076
if let Some(ref source_map) = self.source_map {
10781077
let filename = source_map.span_to_filename(self.position);
1079-
if let FileName::Real(ref filename) = filename
1080-
&& let Ok(cur_dir) = env::current_dir()
1081-
&& let Some(local_path) = filename.local_path()
1082-
&& let Ok(path) = local_path.strip_prefix(&cur_dir)
1083-
{
1078+
if let FileName::Real(ref filename) = filename {
1079+
let path = filename.remapped_path_if_available();
1080+
1081+
// Strip the cwd prefix from the path. This will likely exist if
1082+
// the path was not remapped.
1083+
let path = env::current_dir()
1084+
.map(|cur_dir| path.strip_prefix(&cur_dir).unwrap_or(path))
1085+
.unwrap_or(path);
1086+
10841087
return path.to_owned().into();
10851088
}
10861089
filename
@@ -1107,20 +1110,13 @@ impl Tester for Collector {
11071110
}
11081111

11091112
let path = match &filename {
1110-
FileName::Real(path) => {
1111-
if let Some(local_path) = path.local_path() {
1112-
local_path.to_path_buf()
1113-
} else {
1114-
// Somehow we got the filename from the metadata of another crate, should never happen
1115-
unreachable!("doctest from a different crate");
1116-
}
1117-
}
1113+
FileName::Real(path) => path.remapped_path_if_available().to_path_buf(),
11181114
_ => PathBuf::from(r"doctest.rs"),
11191115
};
11201116

11211117
// For example `module/file.rs` would become `module_file_rs`
11221118
let file = filename
1123-
.prefer_local()
1119+
.prefer_remapped_unconditionaly()
11241120
.to_string_lossy()
11251121
.chars()
11261122
.map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })

Diff for: src/librustdoc/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,14 @@ fn opts() -> Vec<RustcOptGroup> {
556556
unstable("no-run", |o| {
557557
o.optflagmulti("", "no-run", "Compile doctests without running them")
558558
}),
559+
unstable("remap-path-prefix", |o| {
560+
o.optmulti(
561+
"",
562+
"remap-path-prefix",
563+
"Remap source names in compiler messages",
564+
"FROM=TO",
565+
)
566+
}),
559567
unstable("show-type-layout", |o| {
560568
o.optflagmulti("", "show-type-layout", "Include the memory layout of types in the docs")
561569
}),

Diff for: tests/coverage/auxiliary/used_crate.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ pub fn used_function() {
1717
}
1818

1919
pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
20-
println!("used_only_from_bin_crate_generic_function with {:?}", arg);
20+
println!("used_only_from_bin_crate_generic_function with {arg:?}");
2121
}
2222
// Expect for above function: `Unexecuted instantiation` (see below)
2323
pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
24-
println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
24+
println!("used_only_from_this_lib_crate_generic_function with {arg:?}");
2525
}
2626

2727
pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
28-
println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
28+
println!("used_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
2929
}
3030

3131
pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
32-
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
32+
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
3333
}
3434

3535
pub fn unused_generic_function<T: Debug>(arg: T) {
36-
println!("unused_generic_function with {:?}", arg);
36+
println!("unused_generic_function with {arg:?}");
3737
}
3838

3939
pub fn unused_function() {

Diff for: tests/coverage/auxiliary/used_inline_crate.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ pub fn used_inline_function() {
3131

3232
#[inline(always)]
3333
pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
34-
println!("used_only_from_bin_crate_generic_function with {:?}", arg);
34+
println!("used_only_from_bin_crate_generic_function with {arg:?}");
3535
}
3636
// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`)
3737

3838
#[inline(always)]
3939
pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
40-
println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
40+
println!("used_only_from_this_lib_crate_generic_function with {arg:?}");
4141
}
4242

4343
#[inline(always)]
4444
pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
45-
println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
45+
println!("used_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
4646
}
4747

4848
#[inline(always)]
4949
pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
50-
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
50+
println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {arg:?}");
5151
}
5252

5353
#[inline(always)]
5454
pub fn unused_generic_function<T: Debug>(arg: T) {
55-
println!("unused_generic_function with {:?}", arg);
55+
println!("unused_generic_function with {arg:?}");
5656
}
5757

5858
#[inline(always)]

Diff for: tests/coverage/coroutine.cov-map

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Number of file 0 mappings: 4
1212
- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2)
1313

1414
Function name: coroutine::main
15-
Raw bytes (65): 0x[01, 01, 08, 07, 0d, 05, 09, 11, 15, 1e, 19, 11, 15, 15, 19, 1e, 19, 11, 15, 09, 01, 13, 01, 02, 16, 01, 07, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 03, 01, 0e, 00, 35, 11, 02, 0b, 00, 2e, 1e, 01, 22, 00, 27, 1a, 00, 2c, 00, 2e, 17, 01, 0e, 00, 35, 1a, 02, 01, 00, 02]
15+
Raw bytes (65): 0x[01, 01, 08, 07, 0d, 05, 09, 11, 15, 1e, 19, 11, 15, 15, 19, 1e, 19, 11, 15, 09, 01, 13, 01, 02, 16, 01, 08, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 03, 01, 0e, 00, 35, 11, 02, 0b, 00, 2e, 1e, 01, 22, 00, 27, 1a, 00, 2c, 00, 2e, 17, 01, 0e, 00, 35, 1a, 02, 01, 00, 02]
1616
Number of files: 1
1717
- file 0 => global file 1
1818
Number of expressions: 8
@@ -26,7 +26,7 @@ Number of expressions: 8
2626
- expression 7 operands: lhs = Counter(4), rhs = Counter(5)
2727
Number of file 0 mappings: 9
2828
- Code(Counter(0)) at (prev + 19, 1) to (start + 2, 22)
29-
- Code(Counter(0)) at (prev + 7, 11) to (start + 0, 46)
29+
- Code(Counter(0)) at (prev + 8, 11) to (start + 0, 46)
3030
- Code(Counter(4)) at (prev + 1, 43) to (start + 0, 45)
3131
- Code(Expression(0, Add)) at (prev + 1, 14) to (start + 0, 53)
3232
= ((c1 + c2) + c3)
@@ -41,11 +41,11 @@ Number of file 0 mappings: 9
4141
= ((c4 - c5) - c6)
4242

4343
Function name: coroutine::main::{closure#0}
44-
Raw bytes (14): 0x[01, 01, 00, 02, 01, 15, 29, 01, 1f, 05, 02, 10, 01, 06]
44+
Raw bytes (14): 0x[01, 01, 00, 02, 01, 16, 08, 01, 1f, 05, 02, 10, 01, 06]
4545
Number of files: 1
4646
- file 0 => global file 1
4747
Number of expressions: 0
4848
Number of file 0 mappings: 2
49-
- Code(Counter(0)) at (prev + 21, 41) to (start + 1, 31)
49+
- Code(Counter(0)) at (prev + 22, 8) to (start + 1, 31)
5050
- Code(Counter(1)) at (prev + 2, 16) to (start + 1, 6)
5151

Diff for: tests/coverage/coroutine.coverage

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
LL| |// to handle this condition, and still report dead block coverage.
1111
LL| 1|fn get_u32(val: bool) -> Result<u32, String> {
1212
LL| 1| if val {
13-
LL| 1| Ok(1)
13+
LL| 1| Ok(1) //
1414
LL| | } else {
15-
LL| 0| Err(String::from("some error"))
15+
LL| 0| Err(String::from("some error")) //
1616
LL| | }
1717
LL| 1|}
1818
LL| |
1919
LL| 1|fn main() {
2020
LL| 1| let is_true = std::env::args().len() == 1;
21-
LL| 1| let mut coroutine = #[coroutine] || {
21+
LL| 1| let mut coroutine = #[coroutine]
22+
LL| 1| || {
2223
LL| 1| yield get_u32(is_true);
2324
LL| 1| return "foo";
2425
LL| 1| };

Diff for: tests/coverage/coroutine.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ use std::pin::Pin;
1010
// to handle this condition, and still report dead block coverage.
1111
fn get_u32(val: bool) -> Result<u32, String> {
1212
if val {
13-
Ok(1)
13+
Ok(1) //
1414
} else {
15-
Err(String::from("some error"))
15+
Err(String::from("some error")) //
1616
}
1717
}
1818

1919
fn main() {
2020
let is_true = std::env::args().len() == 1;
21-
let mut coroutine = #[coroutine] || {
21+
let mut coroutine = #[coroutine]
22+
|| {
2223
yield get_u32(is_true);
2324
return "foo";
2425
};

Diff for: tests/coverage/inline-dead.coverage

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
LL| |#[inline]
1515
LL| 1|fn live<const B: bool>() -> u32 {
1616
LL| 1| if B {
17-
LL| 0| dead()
17+
LL| 0| dead() //
1818
LL| | } else {
1919
LL| 1| 0
2020
LL| | }

Diff for: tests/coverage/inline-dead.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {
1313
#[inline]
1414
fn live<const B: bool>() -> u32 {
1515
if B {
16-
dead()
16+
dead() //
1717
} else {
1818
0
1919
}

Diff for: tests/coverage/inner_items.coverage

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
^0
5353
LL| |
5454
LL| 1| let mut val = InStruct {
55-
LL| 1| in_struct_field: 101,
55+
LL| 1| in_struct_field: 101, //
5656
LL| 1| };
5757
LL| 1|
5858
LL| 1| val.default_trait_func();

Diff for: tests/coverage/inner_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main() {
5050
}
5151

5252
let mut val = InStruct {
53-
in_struct_field: 101,
53+
in_struct_field: 101, //
5454
};
5555

5656
val.default_trait_func();

Diff for: tests/coverage/let_else_loop.cov-map

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Function name: let_else_loop::_if (unused)
2-
Raw bytes (19): 0x[01, 01, 00, 03, 00, 16, 01, 01, 0c, 00, 02, 09, 00, 10, 00, 02, 09, 00, 10]
2+
Raw bytes (19): 0x[01, 01, 00, 03, 00, 16, 01, 01, 0c, 00, 01, 0f, 00, 16, 00, 00, 20, 00, 27]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 0
66
Number of file 0 mappings: 3
77
- Code(Zero) at (prev + 22, 1) to (start + 1, 12)
8-
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
9-
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
8+
- Code(Zero) at (prev + 1, 15) to (start + 0, 22)
9+
- Code(Zero) at (prev + 0, 32) to (start + 0, 39)
1010

1111
Function name: let_else_loop::_loop_either_way (unused)
1212
Raw bytes (19): 0x[01, 01, 00, 03, 00, 0f, 01, 01, 14, 00, 01, 1c, 00, 23, 00, 01, 05, 00, 0c]

Diff for: tests/coverage/let_else_loop.coverage

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
LL| |// Variant using regular `if` instead of let-else.
2222
LL| |// This doesn't trigger the original ICE, but might help detect regressions.
2323
LL| 0|fn _if(cond: bool) {
24-
LL| 0| if cond {
25-
LL| 0| loop {}
26-
LL| | } else {
27-
LL| 0| loop {}
28-
LL| | }
24+
LL| 0| if cond { loop {} } else { loop {} }
2925
LL| |}
3026
LL| |
3127
LL| |#[coverage(off)]

0 commit comments

Comments
 (0)