diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/types/literal.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/visit.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/inline.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/messages.ftl | 3 | ||||
| -rw-r--r-- | compiler/rustc_session/src/errors.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 3 |
7 files changed, 20 insertions, 9 deletions
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index a9fffcf348b..601d2fbfb67 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -543,7 +543,11 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { lit: &'tcx hir::Lit, negated: bool, ) { - lint_literal(cx, self, hir_id, lit.span, lit, negated) + if negated { + self.negated_expr_id = Some(hir_id); + self.negated_expr_span = Some(lit.span); + } + lint_literal(cx, self, hir_id, lit.span, lit, negated); } fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) { diff --git a/compiler/rustc_lint/src/types/literal.rs b/compiler/rustc_lint/src/types/literal.rs index da98b6461f1..3e4532a6dbe 100644 --- a/compiler/rustc_lint/src/types/literal.rs +++ b/compiler/rustc_lint/src/types/literal.rs @@ -250,12 +250,11 @@ fn lint_int_literal<'tcx>( lit: &hir::Lit, t: ty::IntTy, v: u128, - negated: bool, ) { let int_type = t.normalize(cx.sess().target.pointer_width); let (min, max) = int_ty_range(int_type); let max = max as u128; - let negative = negated ^ (type_limits.negated_expr_id == Some(hir_id)); + let negative = type_limits.negated_expr_id == Some(hir_id); // Detect literal value out of range [min, max] inclusive // avoiding use of -min to prevent overflow/panic @@ -374,7 +373,7 @@ pub(crate) fn lint_literal<'tcx>( ty::Int(t) => { match lit.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_) | ast::LitIntType::Unsuffixed) => { - lint_int_literal(cx, type_limits, hir_id, span, lit, t, v.get(), negated) + lint_int_literal(cx, type_limits, hir_id, span, lit, t, v.get()) } _ => bug!(), }; diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 8d04bbb95bd..8ad88fbda7c 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -527,8 +527,9 @@ macro_rules! make_mir_visitor { target: _, unwind: _, call_source: _, - fn_span: _ + fn_span, } => { + self.visit_span($(& $mutability)? *fn_span); self.visit_operand(func, location); for arg in args { self.visit_operand(&$($mutability)? arg.node, location); @@ -543,8 +544,9 @@ macro_rules! make_mir_visitor { TerminatorKind::TailCall { func, args, - fn_span: _, + fn_span, } => { + self.visit_span($(& $mutability)? *fn_span); self.visit_operand(func, location); for arg in args { self.visit_operand(&$($mutability)? arg.node, location); @@ -853,6 +855,8 @@ macro_rules! make_mir_visitor { local_info: _, } = local_decl; + self.visit_source_info(source_info); + self.visit_ty($(& $mutability)? *ty, TyContext::LocalDecl { local, source_info: *source_info, @@ -862,7 +866,6 @@ macro_rules! make_mir_visitor { self.visit_user_type_projection(user_ty); } } - self.visit_source_info(source_info); } fn super_var_debug_info( diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 07c031e852d..ab617e2ce6f 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -1257,6 +1257,8 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> { // replaced down below anyways). if !matches!(terminator.kind, TerminatorKind::Return) { self.super_terminator(terminator, loc); + } else { + self.visit_source_info(&mut terminator.source_info); } match terminator.kind { diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index eb14b78a003..e5fba8cc5a2 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -133,7 +133,8 @@ session_unstable_virtual_function_elimination = `-Zvirtual-function-elimination` session_unsupported_crate_type_for_target = dropping unsupported crate type `{$crate_type}` for target `{$target_triple}` -session_unsupported_dwarf_version = requested DWARF version {$dwarf_version} is greater than 5 +session_unsupported_dwarf_version = requested DWARF version {$dwarf_version} is not supported +session_unsupported_dwarf_version_help = supported DWARF versions are 2, 3, 4 and 5 session_unsupported_reg_struct_return_arch = `-Zreg-struct-return` is only supported on x86 session_unsupported_regparm = `-Zregparm={$regparm}` is unsupported (valid values 0-3) diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 6c26a781487..75c3b2c7a85 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -161,6 +161,7 @@ pub(crate) struct UnstableVirtualFunctionElimination; #[derive(Diagnostic)] #[diag(session_unsupported_dwarf_version)] +#[help(session_unsupported_dwarf_version_help)] pub(crate) struct UnsupportedDwarfVersion { pub(crate) dwarf_version: u32, } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 0851e859a0f..f795ad1ee17 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1251,7 +1251,8 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } if let Some(dwarf_version) = sess.opts.unstable_opts.dwarf_version { - if dwarf_version > 5 { + // DWARF 1 is not supported by LLVM and DWARF 6 is not yet finalized. + if dwarf_version < 2 || dwarf_version > 5 { sess.dcx().emit_err(errors::UnsupportedDwarfVersion { dwarf_version }); } } |
