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 #101064

Merged
merged 58 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6af8e46
Finished const_eval module migration, moving onto sibling folders
nidnogg Aug 18, 2022
70ea986
Migrated Unallowed function pointer calls in interpreter/ops
nidnogg Aug 18, 2022
33e8aaf
Migration on ops.rs for unstable const functions
nidnogg Aug 19, 2022
d1f14ee
Added several more migrations under ops.rs, failing some tests though
nidnogg Aug 19, 2022
4c82845
Fixed failing tests (missing labels), added automatic error code in c…
nidnogg Aug 20, 2022
0a58b26
Hotfix ftl err name, added check for err.code in create_feature_err
nidnogg Aug 21, 2022
13abae2
Switched errors to diags according to latest PRs
nidnogg Aug 22, 2022
d197c1e
migrate: `UnknownTool` error to `SessionDiagnostic`
Rejyr Aug 19, 2022
874a79f
migrate: `bad_attr` to `SessionDiagnostic`
Rejyr Aug 19, 2022
6f83ec8
change: diagnostic `String` field to `Symbol`
Rejyr Aug 19, 2022
32e445a
hotfix: add missing import
Rejyr Aug 20, 2022
7a6ae23
migrate: `OverruledAttribute`
Rejyr Aug 20, 2022
5d302d1
migrate: `BuiltinEllipsisInclusiveRangePatterns`
Rejyr Aug 20, 2022
dbe8380
rename: `UnknownTool` to `UnknownToolInScopedLint`
Rejyr Aug 20, 2022
1974186
migrate: `rustc_lint::context`
Rejyr Aug 20, 2022
257cf03
refactor: migrate to kind-less `SessionDiagnostic` derives
Rejyr Aug 22, 2022
649749c
Addressing last comment on PR review
nidnogg Aug 22, 2022
066796c
Addressing tidy check fail
nidnogg Aug 22, 2022
5101688
Addressed trailing newlines, odd whitespace skipped by x.py fmt
nidnogg Aug 22, 2022
73ae38b
Migrate ast_lowering::path to SessionDiagnostic
JeanCASPAR Aug 16, 2022
0043d10
Migrate ast_lowering::lib and ast_lowering::item to SessionDiagnostic
JeanCASPAR Aug 17, 2022
1382d30
Migrate ast_lowering::expr to SessionDiagnostic
JeanCASPAR Aug 17, 2022
d75fd91
Migrate ast_lowering::ast to SessionDiagnostic
JeanCASPAR Aug 17, 2022
5164966
Migrate ast_lowering::pat to SessionDiagnostic
JeanCASPAR Aug 18, 2022
e701c72
Migrate all span_err(...) in ast_lowering to SessionDiagnostic
JeanCASPAR Aug 18, 2022
9472df1
Changes made in response to feedback
JeanCASPAR Aug 19, 2022
5fef1b8
Resolve conflicts
JeanCASPAR Aug 22, 2022
0005f62
Refactor diagnostics in `handle_errors` function
hampuslidin Aug 21, 2022
83a724e
Refactor more diagnostics in `rustc_attr`
hampuslidin Aug 21, 2022
40c5184
Add internal diagnistics lints
hampuslidin Aug 21, 2022
b3be769
Refactor additional diagnostics in `rustc_attr`
hampuslidin Aug 21, 2022
b731bfa
Refactor 'invalid issue' diagnostic to use labels within the same Flu…
hampuslidin Aug 21, 2022
c4f5960
Refactor remaining diagnostics
hampuslidin Aug 21, 2022
1c28006
Reorder diagnostics in code order, then alphabetical order
hampuslidin Aug 21, 2022
944a3e2
Change to `diag` attributes
hampuslidin Aug 21, 2022
afd3476
Move `LitKind` logic to `session_diagnostics` module
hampuslidin Aug 21, 2022
69715c9
sugg: suggest the usage of boolean value when there is a typo in the …
vincenzopalazzo Aug 20, 2022
ee2b161
Migrate rustc_mir_dataflow to diagnostic structs
5225225 Aug 19, 2022
7f125ed
Remove full stop in diagnostic message
5225225 Aug 23, 2022
f20cc9a
Rename rustc_mir_dataflow diagnostic to mir_dataflow
5225225 Aug 23, 2022
1693993
cleanup: commented lints
Rejyr Aug 23, 2022
dbe39d8
Start moving rustc_driver to SessionDiagnostic
adriantombu Aug 22, 2022
e7ded92
Fixes fmt & SessionDiagnostic structs
adriantombu Aug 23, 2022
1c575c5
Use std::io::Error and remove useless to_string
adriantombu Aug 24, 2022
3f883b8
Start adding enum errors for deserialize_rlink
adriantombu Aug 24, 2022
bf7ce6a
Replace spaghetti with a simple errors enum
adriantombu Aug 25, 2022
d0401f7
Code cleaning
adriantombu Aug 25, 2022
622217d
diag-mig
AndyJado Aug 26, 2022
01c1616
Migrate rustc_ty_utils to use SessionDiagnostic
Facel3ss1 Aug 18, 2022
bc1d205
Rollup merge of #100724 - JeanCASPAR:migrate-ast_lowering-to-session-…
compiler-errors Aug 26, 2022
181b041
Rollup merge of #100735 - Facel3ss1:ty-utils-translation, r=davidtwco
compiler-errors Aug 26, 2022
b543444
Rollup merge of #100738 - nidnogg:diagnostics_migr_const_eval, r=davi…
compiler-errors Aug 26, 2022
93b2acd
Rollup merge of #100744 - 5225225:migrate-rustc-mir-dataflow, r=david…
compiler-errors Aug 26, 2022
389dda1
Rollup merge of #100776 - Rejyr:diagnostic-migration-rustc-lint, r=da…
compiler-errors Aug 26, 2022
5474460
Rollup merge of #100817 - vincenzopalazzo:macros/bool_spelling_sugg, …
compiler-errors Aug 26, 2022
d97e616
Rollup merge of #100836 - hampuslidin:migrate-attr-crate-diagnostics,…
compiler-errors Aug 26, 2022
e7d870b
Rollup merge of #100890 - adriantombu:migrate_diagnostic_rustc_driver…
compiler-errors Aug 26, 2022
96ceadd
Rollup merge of #100900 - AndyJado:diag-migrate, r=davidtwco
compiler-errors Aug 26, 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
6 changes: 6 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3574,6 +3574,7 @@ dependencies = [
"rustc_errors",
"rustc_hir",
"rustc_index",
"rustc_macros",
"rustc_middle",
"rustc_query_system",
"rustc_session",
Expand Down Expand Up @@ -3819,6 +3820,7 @@ dependencies = [
"rustc_interface",
"rustc_lint",
"rustc_log",
"rustc_macros",
"rustc_metadata",
"rustc_middle",
"rustc_parse",
Expand Down Expand Up @@ -4212,11 +4214,14 @@ dependencies = [
"regex",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_graphviz",
"rustc_hir",
"rustc_index",
"rustc_macros",
"rustc_middle",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"smallvec",
Expand Down Expand Up @@ -4600,6 +4605,7 @@ dependencies = [
"rustc_hir",
"rustc_index",
"rustc_infer",
"rustc_macros",
"rustc_middle",
"rustc_session",
"rustc_span",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rustc_target = { path = "../rustc_target" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_index = { path = "../rustc_index" }
rustc_middle = { path = "../rustc_middle" }
rustc_macros = { path = "../rustc_macros" }
rustc_query_system = { path = "../rustc_query_system" }
rustc_span = { path = "../rustc_span" }
rustc_errors = { path = "../rustc_errors" }
Expand Down
179 changes: 74 additions & 105 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt};

use super::errors::{
AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
InvalidAsmTemplateModifierRegClass, InvalidAsmTemplateModifierRegClassSub,
InvalidAsmTemplateModifierSym, InvalidRegister, InvalidRegisterClass, RegisterClassOnlyClobber,
RegisterConflict,
};
use super::LoweringContext;

use rustc_ast::ptr::P;
use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::definitions::DefPathData;
Expand All @@ -26,13 +32,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let asm_arch =
if self.tcx.sess.opts.actually_rustdoc { None } else { self.tcx.sess.asm_arch };
if asm_arch.is_none() && !self.tcx.sess.opts.actually_rustdoc {
struct_span_err!(
self.tcx.sess,
sp,
E0472,
"inline assembly is unsupported on this target"
)
.emit();
self.tcx.sess.emit_err(InlineAsmUnsupportedTarget { span: sp });
}
if let Some(asm_arch) = asm_arch {
// Inline assembly is currently only stable for these architectures.
Expand All @@ -59,10 +59,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&& !matches!(asm_arch, Some(asm::InlineAsmArch::X86 | asm::InlineAsmArch::X86_64))
&& !self.tcx.sess.opts.actually_rustdoc
{
self.tcx
.sess
.struct_span_err(sp, "the `att_syntax` option is only supported on x86")
.emit();
self.tcx.sess.emit_err(AttSyntaxOnlyX86 { span: sp });
}
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
feature_err(
Expand All @@ -82,51 +79,37 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// If the abi was already in the list, emit an error
match clobber_abis.get(&abi) {
Some((prev_name, prev_sp)) => {
let mut err = self.tcx.sess.struct_span_err(
*abi_span,
&format!("`{}` ABI specified multiple times", prev_name),
);
err.span_label(*prev_sp, "previously specified here");

// Multiple different abi names may actually be the same ABI
// If the specified ABIs are not the same name, alert the user that they resolve to the same ABI
let source_map = self.tcx.sess.source_map();
if source_map.span_to_snippet(*prev_sp)
!= source_map.span_to_snippet(*abi_span)
{
err.note("these ABIs are equivalent on the current target");
}
let equivalent = (source_map.span_to_snippet(*prev_sp)
!= source_map.span_to_snippet(*abi_span))
.then_some(());

err.emit();
self.tcx.sess.emit_err(AbiSpecifiedMultipleTimes {
abi_span: *abi_span,
prev_name: *prev_name,
prev_span: *prev_sp,
equivalent,
});
}
None => {
clobber_abis.insert(abi, (abi_name, *abi_span));
clobber_abis.insert(abi, (*abi_name, *abi_span));
}
}
}
Err(&[]) => {
self.tcx
.sess
.struct_span_err(
*abi_span,
"`clobber_abi` is not supported on this target",
)
.emit();
self.tcx.sess.emit_err(ClobberAbiNotSupported { abi_span: *abi_span });
}
Err(supported_abis) => {
let mut err = self
.tcx
.sess
.struct_span_err(*abi_span, "invalid ABI for `clobber_abi`");
let mut abis = format!("`{}`", supported_abis[0]);
for m in &supported_abis[1..] {
let _ = write!(abis, ", `{}`", m);
}
err.note(&format!(
"the following ABIs are supported on this target: {}",
abis
));
err.emit();
self.tcx.sess.emit_err(InvalidAbiClobberAbi {
abi_span: *abi_span,
supported_abis: abis,
});
}
}
}
Expand All @@ -141,24 +124,28 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.iter()
.map(|(op, op_sp)| {
let lower_reg = |reg| match reg {
InlineAsmRegOrRegClass::Reg(s) => {
InlineAsmRegOrRegClass::Reg(reg) => {
asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
asm::InlineAsmReg::parse(asm_arch, s).unwrap_or_else(|e| {
let msg = format!("invalid register `{}`: {}", s, e);
sess.struct_span_err(*op_sp, &msg).emit();
asm::InlineAsmReg::parse(asm_arch, reg).unwrap_or_else(|error| {
sess.emit_err(InvalidRegister { op_span: *op_sp, reg, error });
asm::InlineAsmReg::Err
})
} else {
asm::InlineAsmReg::Err
})
}
InlineAsmRegOrRegClass::RegClass(s) => {
InlineAsmRegOrRegClass::RegClass(reg_class) => {
asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
asm::InlineAsmRegClass::parse(asm_arch, s).unwrap_or_else(|e| {
let msg = format!("invalid register class `{}`: {}", s, e);
sess.struct_span_err(*op_sp, &msg).emit();
asm::InlineAsmRegClass::Err
})
asm::InlineAsmRegClass::parse(asm_arch, reg_class).unwrap_or_else(
|error| {
sess.emit_err(InvalidRegisterClass {
op_span: *op_sp,
reg_class,
error,
});
asm::InlineAsmRegClass::Err
},
)
} else {
asm::InlineAsmRegClass::Err
})
Expand Down Expand Up @@ -282,50 +269,39 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
let valid_modifiers = class.valid_modifiers(asm_arch.unwrap());
if !valid_modifiers.contains(&modifier) {
let mut err = sess.struct_span_err(
placeholder_span,
"invalid asm template modifier for this register class",
);
err.span_label(placeholder_span, "template modifier");
err.span_label(op_sp, "argument");
if !valid_modifiers.is_empty() {
let sub = if !valid_modifiers.is_empty() {
let mut mods = format!("`{}`", valid_modifiers[0]);
for m in &valid_modifiers[1..] {
let _ = write!(mods, ", `{}`", m);
}
err.note(&format!(
"the `{}` register class supports \
the following template modifiers: {}",
class.name(),
mods
));
InvalidAsmTemplateModifierRegClassSub::SupportModifier {
class_name: class.name(),
modifiers: mods,
}
} else {
err.note(&format!(
"the `{}` register class does not support template modifiers",
class.name()
));
}
err.emit();
InvalidAsmTemplateModifierRegClassSub::DoesNotSupportModifier {
class_name: class.name(),
}
};
sess.emit_err(InvalidAsmTemplateModifierRegClass {
placeholder_span,
op_span: op_sp,
sub,
});
}
}
hir::InlineAsmOperand::Const { .. } => {
let mut err = sess.struct_span_err(
sess.emit_err(InvalidAsmTemplateModifierConst {
placeholder_span,
"asm template modifiers are not allowed for `const` arguments",
);
err.span_label(placeholder_span, "template modifier");
err.span_label(op_sp, "argument");
err.emit();
op_span: op_sp,
});
}
hir::InlineAsmOperand::SymFn { .. }
| hir::InlineAsmOperand::SymStatic { .. } => {
let mut err = sess.struct_span_err(
sess.emit_err(InvalidAsmTemplateModifierSym {
placeholder_span,
"asm template modifiers are not allowed for `sym` arguments",
);
err.span_label(placeholder_span, "template modifier");
err.span_label(op_sp, "argument");
err.emit();
op_span: op_sp,
});
}
}
}
Expand All @@ -346,12 +322,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// require that the operand name an explicit register, not a
// register class.
if reg_class.is_clobber_only(asm_arch.unwrap()) && !op.is_clobber() {
let msg = format!(
"register class `{}` can only be used as a clobber, \
not as an input or output",
reg_class.name()
);
sess.struct_span_err(op_sp, &msg).emit();
sess.emit_err(RegisterClassOnlyClobber {
op_span: op_sp,
reg_class_name: reg_class.name(),
});
continue;
}

Expand Down Expand Up @@ -391,16 +365,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
unreachable!();
};

let msg = format!(
"register `{}` conflicts with register `{}`",
reg.name(),
reg2.name()
);
let mut err = sess.struct_span_err(op_sp, &msg);
err.span_label(op_sp, &format!("register `{}`", reg.name()));
err.span_label(op_sp2, &format!("register `{}`", reg2.name()));

match (op, op2) {
let in_out = match (op, op2) {
(
hir::InlineAsmOperand::In { .. },
hir::InlineAsmOperand::Out { late, .. },
Expand All @@ -411,14 +376,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
) => {
assert!(!*late);
let out_op_sp = if input { op_sp2 } else { op_sp };
let msg = "use `lateout` instead of \
`out` to avoid conflict";
err.span_help(out_op_sp, msg);
}
_ => {}
}
Some(out_op_sp)
},
_ => None,
};

err.emit();
sess.emit_err(RegisterConflict {
op_span1: op_sp,
op_span2: op_sp2,
reg1_name: reg.name(),
reg2_name: reg2.name(),
in_out
});
}
Entry::Vacant(v) => {
if r == reg {
Expand Down
Loading