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 8 pull requests #89420

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d3f981b
Move is_const_fn to under TyCtxt
fee1-dead Sep 15, 2021
f8aa73d
Coerce const FnDefs to implement const Fn traits
fee1-dead Sep 15, 2021
d8e9db0
feat(rustc_parse): recover from pre-RFC-2000 const generics syntax
notriddle Sep 16, 2021
db8af3f
Add support for specifying multiple clobber_abi in `asm!`
asquared31415 Sep 28, 2021
42e9dfd
Reapply "Remove optimization_fuel_crate from Session"
bjorn3 Aug 30, 2021
8a7c130
Use less verbose syntax for error annotations
notriddle Sep 28, 2021
befdfb5
Improve error messages for bad type constraints
notriddle Sep 28, 2021
105b60f
feat(rustc_typeck): avoid erroring with "wrong number of generics" if…
notriddle Sep 28, 2021
6490ed3
Improve error message for `printf`-style format strings
FabianWolff Sep 28, 2021
4425fe4
More spans, don't duplicate clobbers
asquared31415 Sep 29, 2021
d90934c
Fix use after drop in self-profile with llvm events
andjo403 Sep 29, 2021
b159d95
Update docs
asquared31415 Sep 30, 2021
09f1542
Implemented -Z randomize-layout
Kixiron Aug 29, 2021
198d907
Add `pie` as another `relocation-model` value
hlopko Sep 10, 2021
11ab736
Rollup merge of #87868 - Kixiron:packing-on-the-pounds, r=eddyb
fee1-dead Oct 1, 2021
d8ffbaf
Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkov
fee1-dead Oct 1, 2021
a91818a
Rollup merge of #88963 - fee1-dead:const-iterator, r=oli-obk
fee1-dead Oct 1, 2021
13c8c32
Rollup merge of #89029 - notriddle:notriddle/issue-89013, r=estebank
fee1-dead Oct 1, 2021
1826030
Rollup merge of #89316 - asquared31415:multiple-clobber-abi, r=Amanieu
fee1-dead Oct 1, 2021
742ee9d
Rollup merge of #89322 - tmiasko:rm-optimization-fuel, r=michaelwoeri…
fee1-dead Oct 1, 2021
5a09551
Rollup merge of #89340 - FabianWolff:issue-89173, r=petrochenkov
fee1-dead Oct 1, 2021
01762f6
Rollup merge of #89376 - andjo403:selfProfileUseAfterDropFix, r=Mark-…
fee1-dead Oct 1, 2021
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
21 changes: 16 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,7 @@ checksum = "3ca8957e71f04a205cb162508f9326aea04676c8dfd0711220190d6b83664f3f"
dependencies = [
"bitmaps",
"rand_core 0.5.1",
"rand_xoshiro",
"rand_xoshiro 0.4.0",
"sized-chunks",
"typenum",
"version_check",
Expand Down Expand Up @@ -2256,7 +2256,7 @@ dependencies = [
"libc",
"log",
"measureme",
"rand 0.8.3",
"rand 0.8.4",
"rustc-workspace-hack",
"rustc_version",
"shell-escape",
Expand Down Expand Up @@ -2852,9 +2852,9 @@ dependencies = [

[[package]]
name = "rand"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha 0.3.0",
Expand Down Expand Up @@ -2945,6 +2945,15 @@ dependencies = [
"rand_core 0.5.1",
]

[[package]]
name = "rand_xoshiro"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
dependencies = [
"rand_core 0.6.2",
]

[[package]]
name = "rayon"
version = "1.3.1"
Expand Down Expand Up @@ -4087,6 +4096,8 @@ dependencies = [
"either",
"gsgdt",
"polonius-engine",
"rand 0.8.4",
"rand_xoshiro 0.6.0",
"rustc-rayon-core",
"rustc_apfloat",
"rustc_arena",
Expand Down Expand Up @@ -5097,7 +5108,7 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
"cfg-if 1.0.0",
"libc",
"rand 0.8.3",
"rand 0.8.4",
"redox_syscall",
"remove_dir_all",
"winapi",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ pub struct InlineAsm {
pub template: Vec<InlineAsmTemplatePiece>,
pub template_strs: Box<[(Symbol, Option<Symbol>, Span)]>,
pub operands: Vec<(InlineAsmOperand, Span)>,
pub clobber_abi: Option<(Symbol, Span)>,
pub clobber_abis: Vec<(Symbol, Span)>,
pub options: InlineAsmOptions,
pub line_spans: Vec<Span>,
}
Expand Down Expand Up @@ -2705,7 +2705,7 @@ pub enum ItemKind {
/// E.g., `extern {}` or `extern "C" {}`.
ForeignMod(ForeignMod),
/// Module-level inline assembly (from `global_asm!()`).
GlobalAsm(InlineAsm),
GlobalAsm(Box<InlineAsm>),
/// A type alias (`type`).
///
/// E.g., `type Foo = Bar<u8>;`.
Expand Down
18 changes: 14 additions & 4 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::LoweringContext;

use rustc_ast::*;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_set::FxHashSet;
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_span::{Span, Symbol};
Expand All @@ -27,11 +28,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.emit();
}

let mut clobber_abi = None;
let mut clobber_abis = FxHashMap::default();
if let Some(asm_arch) = asm_arch {
if let Some((abi_name, abi_span)) = asm.clobber_abi {
for &(abi_name, abi_span) in &asm.clobber_abis {
match asm::InlineAsmClobberAbi::parse(asm_arch, &self.sess.target, abi_name) {
Ok(abi) => clobber_abi = Some((abi, abi_span)),
Ok(abi) => {
clobber_abis.insert(abi, abi_span);
}
Err(&[]) => {
self.sess
.struct_span_err(
Expand Down Expand Up @@ -368,8 +371,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

// If a clobber_abi is specified, add the necessary clobbers to the
// operands list.
if let Some((abi, abi_span)) = clobber_abi {
let mut clobbered = FxHashSet::default();
for (abi, abi_span) in clobber_abis {
for &clobber in abi.clobbered_regs() {
// Don't emit a clobber for a register already clobbered
if clobbered.contains(&clobber) {
continue;
}

let mut output_used = false;
clobber.overlapping_regs(|reg| {
if used_output_regs.contains_key(&reg) {
Expand All @@ -386,6 +395,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
},
self.lower_span(abi_span),
));
clobbered.insert(clobber);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2199,8 +2199,8 @@ impl<'a> State<'a> {

let mut args = vec![AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template))];
args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
if let Some((abi, _)) = asm.clobber_abi {
args.push(AsmArg::ClobberAbi(abi));
for (abi, _) in &asm.clobber_abis {
args.push(AsmArg::ClobberAbi(*abi));
}
if !asm.options.is_empty() {
args.push(AsmArg::Options(asm.options));
Expand Down
34 changes: 16 additions & 18 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct AsmArgs {
operands: Vec<(ast::InlineAsmOperand, Span)>,
named_args: FxHashMap<Symbol, usize>,
reg_args: FxHashSet<usize>,
clobber_abi: Option<(Symbol, Span)>,
clobber_abis: Vec<(Symbol, Span)>,
options: ast::InlineAsmOptions,
options_spans: Vec<Span>,
}
Expand Down Expand Up @@ -64,7 +64,7 @@ fn parse_args<'a>(
operands: vec![],
named_args: FxHashMap::default(),
reg_args: FxHashSet::default(),
clobber_abi: None,
clobber_abis: Vec::new(),
options: ast::InlineAsmOptions::empty(),
options_spans: vec![],
};
Expand Down Expand Up @@ -210,7 +210,7 @@ fn parse_args<'a>(
.span_labels(args.options_spans.clone(), "previous options")
.span_label(span, "argument")
.emit();
} else if let Some((_, abi_span)) = args.clobber_abi {
} else if let Some(&(_, abi_span)) = args.clobber_abis.last() {
ecx.struct_span_err(span, "arguments are not allowed after clobber_abi")
.span_label(abi_span, "clobber_abi")
.span_label(span, "argument")
Expand Down Expand Up @@ -322,10 +322,12 @@ fn parse_args<'a>(
// Bail out now since this is likely to confuse MIR
return Err(err);
}
if let Some((_, abi_span)) = args.clobber_abi {
if args.clobber_abis.len() > 0 {
if is_global_asm {
let err =
ecx.struct_span_err(abi_span, "`clobber_abi` cannot be used with `global_asm!`");
let err = ecx.struct_span_err(
args.clobber_abis.iter().map(|(_, sp)| *sp).collect::<Vec<Span>>(),
"`clobber_abi` cannot be used with `global_asm!`",
);

// Bail out now since this is likely to confuse later stages
return Err(err);
Expand All @@ -335,7 +337,10 @@ fn parse_args<'a>(
regclass_outputs.clone(),
"asm with `clobber_abi` must specify explicit registers for outputs",
)
.span_label(abi_span, "clobber_abi")
.span_labels(
args.clobber_abis.iter().map(|(_, sp)| *sp).collect::<Vec<Span>>(),
"clobber_abi",
)
.span_labels(regclass_outputs, "generic outputs")
.emit();
}
Expand Down Expand Up @@ -453,14 +458,7 @@ fn parse_clobber_abi<'a>(

let new_span = span_start.to(p.prev_token.span);

if let Some((_, prev_span)) = args.clobber_abi {
let mut err = p
.sess
.span_diagnostic
.struct_span_err(new_span, "clobber_abi specified multiple times");
err.span_label(prev_span, "clobber_abi previously specified here");
return Err(err);
} else if !args.options_spans.is_empty() {
if !args.options_spans.is_empty() {
let mut err = p
.sess
.span_diagnostic
Expand All @@ -469,7 +467,7 @@ fn parse_clobber_abi<'a>(
return Err(err);
}

args.clobber_abi = Some((clobber_abi, new_span));
args.clobber_abis.push((clobber_abi, new_span));

Ok(())
}
Expand Down Expand Up @@ -770,7 +768,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
template,
template_strs: template_strs.into_boxed_slice(),
operands: args.operands,
clobber_abi: args.clobber_abi,
clobber_abis: args.clobber_abis,
options: args.options,
line_spans,
})
Expand Down Expand Up @@ -815,7 +813,7 @@ pub fn expand_global_asm<'cx>(
ident: Ident::invalid(),
attrs: Vec::new(),
id: ast::DUMMY_NODE_ID,
kind: ast::ItemKind::GlobalAsm(inline_asm),
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
vis: ast::Visibility {
span: sp.shrink_to_lo(),
kind: ast::VisibilityKind::Inherited,
Expand Down
26 changes: 21 additions & 5 deletions compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,11 +1154,12 @@ pub fn expand_preparsed_format_args(
// account for `"` and account for raw strings `r#`
let padding = str_style.map(|i| i + 2).unwrap_or(1);
for sub in foreign::$kind::iter_subs(fmt_str, padding) {
let trn = match sub.translate() {
Some(trn) => trn,
let (trn, success) = match sub.translate() {
Ok(trn) => (trn, true),
Err(Some(msg)) => (msg, false),

// If it has no translation, don't call it out specifically.
None => continue,
_ => continue,
};

let pos = sub.position();
Expand All @@ -1175,9 +1176,24 @@ pub fn expand_preparsed_format_args(

if let Some(inner_sp) = pos {
let sp = fmt_sp.from_inner(inner_sp);
suggestions.push((sp, trn));

if success {
suggestions.push((sp, trn));
} else {
diag.span_note(
sp,
&format!("format specifiers use curly braces, and {}", trn),
);
}
} else {
diag.help(&format!("`{}` should be written as `{}`", sub, trn));
if success {
diag.help(&format!("`{}` should be written as `{}`", sub, trn));
} else {
diag.note(&format!(
"`{}` should use curly braces, and {}",
sub, trn
));
}
}
}

Expand Down
Loading