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 10 pull requests #93616

Closed
wants to merge 24 commits into from
Closed
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
4413141
rustdoc: Fix ICE report
ehuss Dec 27, 2021
34106f8
Stabilize -Z instrument-coverage as -C instrument-coverage
joshtriplett Oct 21, 2021
760c13f
Rewrite instrument-coverage documentation to use LLVM tools directly
joshtriplett Oct 22, 2021
c840003
Update instrument-coverage documentation to document stability and LL…
joshtriplett Oct 26, 2021
e14bd48
Clarify stability expectations for llvm-tools-preview
joshtriplett Oct 27, 2021
6593fcd
Require `-Zunstable-options` for `-C instrument-coverage=except-*` op…
joshtriplett Jan 2, 2022
73ad8df
Deduplicate lines in long const-eval stack trace
compiler-errors Jan 12, 2022
2d7ffbb
Factor convenience functions out of main printer implementation
dtolnay Jan 21, 2022
891368f
Make rustc use `RUST_BACKTRACE=full` by default
Aaron1011 Feb 2, 2022
08be313
Use Option::then in two places
est31 Feb 2, 2022
1dbdfc4
Update browser-ui-test version
GuillaumeGomez Feb 2, 2022
088474a
fix: Remove extra newlines from junit output
last-partizan Feb 1, 2022
547b4e6
Add more *-unwind ABI variants
Amanieu Feb 1, 2022
3b52cca
Correct incorrect description of preorder traversals.
JakobDegen Feb 3, 2022
3681a40
Rollup merge of #90132 - joshtriplett:stabilize-instrument-coverage, …
matthiaskrgr Feb 3, 2022
7f6acba
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
matthiaskrgr Feb 3, 2022
a11629e
Rollup merge of #92802 - compiler-errors:deduplicate-stack-trace, r=o…
matthiaskrgr Feb 3, 2022
2e9f0fa
Rollup merge of #93515 - dtolnay:convenience, r=davidtwco
matthiaskrgr Feb 3, 2022
02873fa
Rollup merge of #93561 - Amanieu:more-unwind-abi, r=nagisa
matthiaskrgr Feb 3, 2022
19e74d6
Rollup merge of #93566 - Aaron1011:rustc-backtrace, r=davidtwco
matthiaskrgr Feb 3, 2022
7dbb270
Rollup merge of #93589 - est31:option_then, r=cjgillot
matthiaskrgr Feb 3, 2022
b0037f4
Rollup merge of #93597 - GuillaumeGomez:update-browser-ui-test, r=jsha
matthiaskrgr Feb 3, 2022
1abc0da
Rollup merge of #93600 - last-partizan:fix-junit-formatter, r=yaahc
matthiaskrgr Feb 3, 2022
d9c74a6
Rollup merge of #93606 - JakobDegen:mischaracterized-preorder, r=oli-obk
matthiaskrgr Feb 3, 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
48 changes: 48 additions & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,54 @@ impl<'a> PostExpansionVisitor<'a> {
"thiscall-unwind ABI is experimental and subject to change"
);
}
"cdecl-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"cdecl-unwind ABI is experimental and subject to change"
);
}
"fastcall-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"fastcall-unwind ABI is experimental and subject to change"
);
}
"vectorcall-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"vectorcall-unwind ABI is experimental and subject to change"
);
}
"aapcs-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"aapcs-unwind ABI is experimental and subject to change"
);
}
"win64-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"win64-unwind ABI is experimental and subject to change"
);
}
"sysv64-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"sysv64-unwind ABI is experimental and subject to change"
);
}
"wasm" => {
gate_feature_post!(
&self,
Expand Down
76 changes: 1 addition & 75 deletions compiler/rustc_ast_pretty/src/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
//! methods called `Printer::scan_*`, and the 'PRINT' process is the
//! method called `Printer::print`.

mod convenience;
mod ring;

use ring::RingBuffer;
Expand Down Expand Up @@ -186,12 +187,6 @@ pub enum Token {
End,
}

impl Token {
pub fn is_hardbreak_tok(&self) -> bool {
matches!(self, Token::Break(BreakToken { offset: 0, blank_space: SIZE_INFINITY }))
}
}

#[derive(Copy, Clone)]
enum PrintFrame {
Fits,
Expand Down Expand Up @@ -441,73 +436,4 @@ impl Printer {
self.out.push_str(string);
self.space -= string.len() as isize;
}

// Convenience functions to talk to the printer.

/// "raw box"
pub fn rbox(&mut self, indent: usize, breaks: Breaks) {
self.scan_begin(BeginToken {
indent: IndentStyle::Block { offset: indent as isize },
breaks,
})
}

/// Inconsistent breaking box
pub fn ibox(&mut self, indent: usize) {
self.rbox(indent, Breaks::Inconsistent)
}

/// Consistent breaking box
pub fn cbox(&mut self, indent: usize) {
self.rbox(indent, Breaks::Consistent)
}

pub fn visual_align(&mut self) {
self.scan_begin(BeginToken { indent: IndentStyle::Visual, breaks: Breaks::Consistent });
}

pub fn break_offset(&mut self, n: usize, off: isize) {
self.scan_break(BreakToken { offset: off, blank_space: n as isize })
}

pub fn end(&mut self) {
self.scan_end()
}

pub fn eof(mut self) -> String {
self.scan_eof();
self.out
}

pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S) {
let string = wrd.into();
self.scan_string(string)
}

fn spaces(&mut self, n: usize) {
self.break_offset(n, 0)
}

pub fn zerobreak(&mut self) {
self.spaces(0)
}

pub fn space(&mut self) {
self.spaces(1)
}

pub fn hardbreak(&mut self) {
self.spaces(SIZE_INFINITY as usize)
}

pub fn is_beginning_of_line(&self) -> bool {
match self.last_token() {
Some(last_token) => last_token.is_hardbreak_tok(),
None => true,
}
}

pub fn hardbreak_tok_offset(off: isize) -> Token {
Token::Break(BreakToken { offset: off, blank_space: SIZE_INFINITY })
}
}
77 changes: 77 additions & 0 deletions compiler/rustc_ast_pretty/src/pp/convenience.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, Token, SIZE_INFINITY};
use std::borrow::Cow;

impl Printer {
/// "raw box"
pub fn rbox(&mut self, indent: usize, breaks: Breaks) {
self.scan_begin(BeginToken {
indent: IndentStyle::Block { offset: indent as isize },
breaks,
})
}

/// Inconsistent breaking box
pub fn ibox(&mut self, indent: usize) {
self.rbox(indent, Breaks::Inconsistent)
}

/// Consistent breaking box
pub fn cbox(&mut self, indent: usize) {
self.rbox(indent, Breaks::Consistent)
}

pub fn visual_align(&mut self) {
self.scan_begin(BeginToken { indent: IndentStyle::Visual, breaks: Breaks::Consistent });
}

pub fn break_offset(&mut self, n: usize, off: isize) {
self.scan_break(BreakToken { offset: off, blank_space: n as isize })
}

pub fn end(&mut self) {
self.scan_end()
}

pub fn eof(mut self) -> String {
self.scan_eof();
self.out
}

pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S) {
let string = wrd.into();
self.scan_string(string)
}

fn spaces(&mut self, n: usize) {
self.break_offset(n, 0)
}

pub fn zerobreak(&mut self) {
self.spaces(0)
}

pub fn space(&mut self) {
self.spaces(1)
}

pub fn hardbreak(&mut self) {
self.spaces(SIZE_INFINITY as usize)
}

pub fn is_beginning_of_line(&self) -> bool {
match self.last_token() {
Some(last_token) => last_token.is_hardbreak_tok(),
None => true,
}
}

pub fn hardbreak_tok_offset(off: isize) -> Token {
Token::Break(BreakToken { offset: off, blank_space: SIZE_INFINITY })
}
}

impl Token {
pub fn is_hardbreak_tok(&self) -> bool {
matches!(self, Token::Break(BreakToken { offset: 0, blank_space: SIZE_INFINITY }))
}
}
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
// LLVM 12.
let version = coverageinfo::mapping_version();
if version < 4 {
tcx.sess.fatal("rustc option `-Z instrument-coverage` requires LLVM 12 or higher.");
tcx.sess.fatal("rustc option `-C instrument-coverage` requires LLVM 12 or higher.");
}

debug!("Generating coverage map for CodegenUnit: `{}`", cx.codegen_unit.name());
Expand Down Expand Up @@ -274,7 +274,7 @@ fn save_function_record(
/// (functions referenced by other "used" or public items). Any other functions considered unused,
/// or "Unreachable", were still parsed and processed through the MIR stage, but were not
/// codegenned. (Note that `-Clink-dead-code` can force some unused code to be codegenned, but
/// that flag is known to cause other errors, when combined with `-Z instrument-coverage`; and
/// that flag is known to cause other errors, when combined with `-C instrument-coverage`; and
/// `-Clink-dead-code` will not generate code for unused generic functions.)
///
/// We can find the unused functions (including generic functions) by the set difference of all MIR
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ pub trait CoverageInfoMethods<'tcx>: BackendTypes {

pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
/// Returns true if the function source hash was added to the coverage map (even if it had
/// already been added, for this instance). Returns false *only* if `-Z instrument-coverage` is
/// already been added, for this instance). Returns false *only* if `-C instrument-coverage` is
/// not enabled (a coverage map is not being generated).
fn set_function_source_hash(
&mut self,
instance: Instance<'tcx>,
function_source_hash: u64,
) -> bool;

/// Returns true if the counter was added to the coverage map; false if `-Z instrument-coverage`
/// Returns true if the counter was added to the coverage map; false if `-C instrument-coverage`
/// is not enabled (a coverage map is not being generated).
fn add_coverage_counter(
&mut self,
Expand All @@ -40,7 +40,7 @@ pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
) -> bool;

/// Returns true if the expression was added to the coverage map; false if
/// `-Z instrument-coverage` is not enabled (a coverage map is not being generated).
/// `-C instrument-coverage` is not enabled (a coverage map is not being generated).
fn add_coverage_counter_expression(
&mut self,
instance: Instance<'tcx>,
Expand All @@ -51,7 +51,7 @@ pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
region: Option<CodeRegion>,
) -> bool;

/// Returns true if the region was added to the coverage map; false if `-Z instrument-coverage`
/// Returns true if the region was added to the coverage map; false if `-C instrument-coverage`
/// is not enabled (a coverage map is not being generated).
fn add_coverage_unreachable(&mut self, instance: Instance<'tcx>, region: CodeRegion) -> bool;
}
30 changes: 29 additions & 1 deletion compiler/rustc_const_eval/src/const_eval/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,37 @@ impl<'tcx> ConstEvalErr<'tcx> {
}
// Add spans for the stacktrace. Don't print a single-line backtrace though.
if self.stacktrace.len() > 1 {
// Helper closure to print duplicated lines.
let mut flush_last_line = |last_frame, times| {
if let Some((line, span)) = last_frame {
err.span_label(span, &line);
// Don't print [... additional calls ...] if the number of lines is small
if times < 3 {
for _ in 0..times {
err.span_label(span, &line);
}
} else {
err.span_label(
span,
format!("[... {} additional calls {} ...]", times, &line),
);
}
}
};

let mut last_frame = None;
let mut times = 0;
for frame_info in &self.stacktrace {
err.span_label(frame_info.span, frame_info.to_string());
let frame = (frame_info.to_string(), frame_info.span);
if last_frame.as_ref() == Some(&frame) {
times += 1;
} else {
flush_last_line(last_frame, times);
last_frame = Some(frame);
times = 0;
}
}
flush_last_line(last_frame, times);
}
// Let the caller finish the job.
emit(err)
Expand Down
51 changes: 30 additions & 21 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub const EXIT_FAILURE: i32 = 1;
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/issues/new\
?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md";

const ICE_REPORT_COMPILER_FLAGS: &[&str] = &["Z", "C", "crate-type"];
const ICE_REPORT_COMPILER_FLAGS: &[&str] = &["-Z", "-C", "--crate-type"];

const ICE_REPORT_COMPILER_FLAGS_EXCLUDE: &[&str] = &["metadata", "extra-filename"];

Expand Down Expand Up @@ -1100,31 +1100,31 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
/// debugging, since some ICEs only happens with non-default compiler flags
/// (and the users don't always report them).
fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
let args = env::args_os().map(|arg| arg.to_string_lossy().to_string()).collect::<Vec<_>>();
let mut args = env::args_os().map(|arg| arg.to_string_lossy().to_string()).peekable();

// Avoid printing help because of empty args. This can suggest the compiler
// itself is not the program root (consider RLS).
if args.len() < 2 {
return None;
}

let matches = handle_options(&args)?;
let mut result = Vec::new();
let mut excluded_cargo_defaults = false;
for flag in ICE_REPORT_COMPILER_FLAGS {
let prefix = if flag.len() == 1 { "-" } else { "--" };

for content in &matches.opt_strs(flag) {
// Split always returns the first element
let name = if let Some(first) = content.split('=').next() { first } else { &content };

let content =
if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.contains(&name) { name } else { content };

if !ICE_REPORT_COMPILER_FLAGS_EXCLUDE.contains(&name) {
result.push(format!("{}{} {}", prefix, flag, content));
while let Some(arg) = args.next() {
if let Some(a) = ICE_REPORT_COMPILER_FLAGS.iter().find(|a| arg.starts_with(*a)) {
let content = if arg.len() == a.len() {
match args.next() {
Some(arg) => arg.to_string(),
None => continue,
}
} else if arg.get(a.len()..a.len() + 1) == Some("=") {
arg[a.len() + 1..].to_string()
} else {
arg[a.len()..].to_string()
};
if ICE_REPORT_COMPILER_FLAGS_EXCLUDE.iter().any(|exc| content.starts_with(exc)) {
excluded_cargo_defaults = true;
} else {
result.push(a.to_string());
match ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.iter().find(|s| content.starts_with(*s))
{
Some(s) => result.push(s.to_string()),
None => result.push(content),
}
}
}
}
Expand Down Expand Up @@ -1240,6 +1240,15 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
///
/// A custom rustc driver can skip calling this to set up a custom ICE hook.
pub fn install_ice_hook() {
// If the user has not explicitly overriden "RUST_BACKTRACE", then produce
// full backtraces. When a compiler ICE happens, we want to gather
// as much information as possible to present in the issue opened
// by the user. Compiler developers and other rustc users can
// opt in to less-verbose backtraces by manually setting "RUST_BACKTRACE"
// (e.g. `RUST_BACKTRACE=1`)
if std::env::var("RUST_BACKTRACE").is_err() {
std::env::set_var("RUST_BACKTRACE", "full");
}
SyncLazy::force(&DEFAULT_HOOK);
}

Expand Down
Loading