Resolve various merge conflicts
This commit is contained in:
parent
e71a722fa6
commit
1bdf112529
5 changed files with 129 additions and 130 deletions
|
@ -292,7 +292,7 @@ mir_build_borrow_of_moved_value = borrow of moved value
|
||||||
.label = value moved into `{$name}` here
|
.label = value moved into `{$name}` here
|
||||||
.occurs_because_label = move occurs because `{$name}` has type `{$ty}` which does not implement the `Copy` trait
|
.occurs_because_label = move occurs because `{$name}` has type `{$ty}` which does not implement the `Copy` trait
|
||||||
.value_borrowed_label = value borrowed here after move
|
.value_borrowed_label = value borrowed here after move
|
||||||
.suggest_borrowing = borrow this binding in the pattern to avoid moving the value
|
.suggestion = borrow this binding in the pattern to avoid moving the value
|
||||||
|
|
||||||
mir_build_multiple_mut_borrows = cannot borrow value as mutable more than once at a time
|
mir_build_multiple_mut_borrows = cannot borrow value as mutable more than once at a time
|
||||||
.label = first mutable borrow, by `{$name}`, occurs here
|
.label = first mutable borrow, by `{$name}`, occurs here
|
||||||
|
|
|
@ -57,8 +57,8 @@ fluent_messages! {
|
||||||
lint => "../locales/en-US/lint.ftl",
|
lint => "../locales/en-US/lint.ftl",
|
||||||
metadata => "../locales/en-US/metadata.ftl",
|
metadata => "../locales/en-US/metadata.ftl",
|
||||||
middle => "../locales/en-US/middle.ftl",
|
middle => "../locales/en-US/middle.ftl",
|
||||||
mir_dataflow => "../locales/en-US/mir_dataflow.ftl",
|
|
||||||
mir_build => "../locales/en-US/mir_build.ftl",
|
mir_build => "../locales/en-US/mir_build.ftl",
|
||||||
|
mir_dataflow => "../locales/en-US/mir_dataflow.ftl",
|
||||||
monomorphize => "../locales/en-US/monomorphize.ftl",
|
monomorphize => "../locales/en-US/monomorphize.ftl",
|
||||||
parse => "../locales/en-US/parse.ftl",
|
parse => "../locales/en-US/parse.ftl",
|
||||||
passes => "../locales/en-US/passes.ftl",
|
passes => "../locales/en-US/passes.ftl",
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
use crate::thir::pattern::MatchCheckCtxt;
|
use crate::thir::pattern::MatchCheckCtxt;
|
||||||
use rustc_errors::{error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
|
use rustc_errors::Handler;
|
||||||
use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
|
use rustc_errors::{
|
||||||
|
error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, MultiSpan,
|
||||||
|
};
|
||||||
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_session::{parse::ParseSess, SessionDiagnostic};
|
|
||||||
use rustc_span::{symbol::Ident, Span};
|
use rustc_span::{symbol::Ident, Span};
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unconditional_recursion)]
|
#[diag(mir_build_unconditional_recursion)]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct UnconditionalRecursion {
|
pub struct UnconditionalRecursion {
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label(mir_build::unconditional_recursion_call_site_label)]
|
#[label(mir_build_unconditional_recursion_call_site_label)]
|
||||||
pub call_sites: Vec<Span>,
|
pub call_sites: Vec<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe<'a> {
|
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe<'a> {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -25,7 +27,7 @@ pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
|
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -33,7 +35,7 @@ pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -41,7 +43,7 @@ pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -49,7 +51,7 @@ pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -57,7 +59,7 @@ pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_extern_static_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -65,7 +67,7 @@ pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -73,7 +75,7 @@ pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_union_field_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -81,7 +83,7 @@ pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -89,14 +91,14 @@ pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe)]
|
||||||
pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)]
|
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
|
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -104,8 +106,8 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe<'a> {
|
||||||
pub function: &'a str,
|
pub function: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::call_to_unsafe_fn_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct CallToUnsafeFunctionRequiresUnsafe<'a> {
|
pub struct CallToUnsafeFunctionRequiresUnsafe<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -114,8 +116,8 @@ pub struct CallToUnsafeFunctionRequiresUnsafe<'a> {
|
||||||
pub function: &'a str,
|
pub function: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::call_to_unsafe_fn_requires_unsafe_nameless, code = "E0133")]
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_nameless, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
|
pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -123,8 +125,8 @@ pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
#[diag(mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -133,9 +135,9 @@ pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
||||||
pub function: &'a str,
|
pub function: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(
|
#[diag(
|
||||||
mir_build::call_to_unsafe_fn_requires_unsafe_nameless_unsafe_op_in_unsafe_fn_allowed,
|
mir_build_call_to_unsafe_fn_requires_unsafe_nameless_unsafe_op_in_unsafe_fn_allowed,
|
||||||
code = "E0133"
|
code = "E0133"
|
||||||
)]
|
)]
|
||||||
#[note]
|
#[note]
|
||||||
|
@ -145,8 +147,8 @@ pub struct CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::inline_assembly_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_inline_assembly_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UseOfInlineAssemblyRequiresUnsafe {
|
pub struct UseOfInlineAssemblyRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -154,8 +156,8 @@ pub struct UseOfInlineAssemblyRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::inline_assembly_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
#[diag(mir_build_inline_assembly_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
pub struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -163,8 +165,8 @@ pub struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::initializing_type_with_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_initializing_type_with_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct InitializingTypeWithRequiresUnsafe {
|
pub struct InitializingTypeWithRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -172,9 +174,9 @@ pub struct InitializingTypeWithRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(
|
#[diag(
|
||||||
mir_build::initializing_type_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
mir_build_initializing_type_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
||||||
code = "E0133"
|
code = "E0133"
|
||||||
)]
|
)]
|
||||||
#[note]
|
#[note]
|
||||||
|
@ -184,8 +186,8 @@ pub struct InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::mutable_static_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_mutable_static_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UseOfMutableStaticRequiresUnsafe {
|
pub struct UseOfMutableStaticRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -193,8 +195,8 @@ pub struct UseOfMutableStaticRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::mutable_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
#[diag(mir_build_mutable_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
pub struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -202,8 +204,8 @@ pub struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::extern_static_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_extern_static_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UseOfExternStaticRequiresUnsafe {
|
pub struct UseOfExternStaticRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -211,8 +213,8 @@ pub struct UseOfExternStaticRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
#[diag(mir_build_extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
pub struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -220,8 +222,8 @@ pub struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::deref_raw_pointer_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_deref_raw_pointer_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct DerefOfRawPointerRequiresUnsafe {
|
pub struct DerefOfRawPointerRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -229,8 +231,8 @@ pub struct DerefOfRawPointerRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::deref_raw_pointer_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
#[diag(mir_build_deref_raw_pointer_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
pub struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -238,8 +240,8 @@ pub struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::union_field_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_union_field_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct AccessToUnionFieldRequiresUnsafe {
|
pub struct AccessToUnionFieldRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -247,8 +249,8 @@ pub struct AccessToUnionFieldRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::union_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
#[diag(mir_build_union_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
pub struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -256,8 +258,8 @@ pub struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::mutation_of_layout_constrained_field_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_mutation_of_layout_constrained_field_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
|
pub struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -265,9 +267,9 @@ pub struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(
|
#[diag(
|
||||||
mir_build::mutation_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
mir_build_mutation_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
||||||
code = "E0133"
|
code = "E0133"
|
||||||
)]
|
)]
|
||||||
#[note]
|
#[note]
|
||||||
|
@ -277,8 +279,8 @@ pub struct MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllow
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::borrow_of_layout_constrained_field_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_borrow_of_layout_constrained_field_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -286,9 +288,9 @@ pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(
|
#[diag(
|
||||||
mir_build::borrow_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
mir_build_borrow_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed,
|
||||||
code = "E0133"
|
code = "E0133"
|
||||||
)]
|
)]
|
||||||
#[note]
|
#[note]
|
||||||
|
@ -298,8 +300,8 @@ pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::call_to_fn_with_requires_unsafe, code = "E0133")]
|
#[diag(mir_build_call_to_fn_with_requires_unsafe, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct CallToFunctionWithRequiresUnsafe<'a> {
|
pub struct CallToFunctionWithRequiresUnsafe<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -308,8 +310,8 @@ pub struct CallToFunctionWithRequiresUnsafe<'a> {
|
||||||
pub function: &'a str,
|
pub function: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
#[diag(mir_build_call_to_fn_with_requires_unsafe_unsafe_op_in_unsafe_fn_allowed, code = "E0133")]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -319,7 +321,7 @@ pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unused_unsafe)]
|
#[diag(mir_build_unused_unsafe)]
|
||||||
pub struct UnusedUnsafe {
|
pub struct UnusedUnsafe {
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
@ -327,14 +329,14 @@ pub struct UnusedUnsafe {
|
||||||
pub enclosing: Option<UnusedUnsafeEnclosing>,
|
pub enclosing: Option<UnusedUnsafeEnclosing>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum UnusedUnsafeEnclosing {
|
pub enum UnusedUnsafeEnclosing {
|
||||||
#[label(mir_build::unused_unsafe_enclosing_block_label)]
|
#[label(mir_build_unused_unsafe_enclosing_block_label)]
|
||||||
Block {
|
Block {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
},
|
},
|
||||||
#[label(mir_build::unused_unsafe_enclosing_fn_label)]
|
#[label(mir_build_unused_unsafe_enclosing_fn_label)]
|
||||||
Function {
|
Function {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -348,11 +350,11 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
|
||||||
pub ty: Ty<'tcx>,
|
pub ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SessionDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
||||||
fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = sess.span_diagnostic.struct_span_err_with_code(
|
let mut diag = handler.struct_span_err_with_code(
|
||||||
self.span,
|
self.span,
|
||||||
rustc_errors::fluent::mir_build::non_exhaustive_patterns_type_not_empty,
|
rustc_errors::fluent::mir_build_non_exhaustive_patterns_type_not_empty,
|
||||||
error_code!(E0004),
|
error_code!(E0004),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -374,7 +376,7 @@ impl<'a> SessionDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_>
|
||||||
let mut span: MultiSpan = def_span.into();
|
let mut span: MultiSpan = def_span.into();
|
||||||
span.push_span_label(def_span, "");
|
span.push_span_label(def_span, "");
|
||||||
|
|
||||||
diag.span_note(span, rustc_errors::fluent::mir_build::def_note);
|
diag.span_note(span, rustc_errors::fluent::def_note);
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_variant_list_non_exhaustive = match self.ty.kind() {
|
let is_variant_list_non_exhaustive = match self.ty.kind() {
|
||||||
|
@ -385,14 +387,14 @@ impl<'a> SessionDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_>
|
||||||
};
|
};
|
||||||
|
|
||||||
if is_variant_list_non_exhaustive {
|
if is_variant_list_non_exhaustive {
|
||||||
diag.note(rustc_errors::fluent::mir_build::non_exhaustive_type_note);
|
diag.note(rustc_errors::fluent::non_exhaustive_type_note);
|
||||||
} else {
|
} else {
|
||||||
diag.note(rustc_errors::fluent::mir_build::type_note);
|
diag.note(rustc_errors::fluent::type_note);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
|
if let ty::Ref(_, sub_ty, _) = self.ty.kind() {
|
||||||
if self.cx.tcx.is_ty_uninhabited_from(self.cx.module, *sub_ty, self.cx.param_env) {
|
if !sub_ty.is_inhabited_from(self.cx.tcx, self.cx.module, self.cx.param_env) {
|
||||||
diag.note(rustc_errors::fluent::mir_build::reference_note);
|
diag.note(rustc_errors::fluent::reference_note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,88 +420,88 @@ impl<'a> SessionDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_>
|
||||||
if let Some((span, sugg)) = suggestion {
|
if let Some((span, sugg)) = suggestion {
|
||||||
diag.span_suggestion_verbose(
|
diag.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
rustc_errors::fluent::mir_build::suggestion,
|
rustc_errors::fluent::suggestion,
|
||||||
sugg,
|
sugg,
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
diag.help(rustc_errors::fluent::mir_build::help);
|
diag.help(rustc_errors::fluent::help);
|
||||||
}
|
}
|
||||||
|
|
||||||
diag
|
diag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::static_in_pattern, code = "E0158")]
|
#[diag(mir_build_static_in_pattern, code = "E0158")]
|
||||||
pub struct StaticInPattern {
|
pub struct StaticInPattern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::assoc_const_in_pattern, code = "E0158")]
|
#[diag(mir_build_assoc_const_in_pattern, code = "E0158")]
|
||||||
pub struct AssocConstInPattern {
|
pub struct AssocConstInPattern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::const_param_in_pattern, code = "E0158")]
|
#[diag(mir_build_const_param_in_pattern, code = "E0158")]
|
||||||
pub struct ConstParamInPattern {
|
pub struct ConstParamInPattern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::non_const_path, code = "E0080")]
|
#[diag(mir_build_non_const_path, code = "E0080")]
|
||||||
pub struct NonConstPath {
|
pub struct NonConstPath {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::unreachable_pattern)]
|
#[diag(mir_build_unreachable_pattern)]
|
||||||
pub struct UnreachablePattern {
|
pub struct UnreachablePattern {
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Option<Span>,
|
pub span: Option<Span>,
|
||||||
#[label(mir_build::catchall_label)]
|
#[label(catchall_label)]
|
||||||
pub catchall: Option<Span>,
|
pub catchall: Option<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::const_pattern_depends_on_generic_parameter)]
|
#[diag(mir_build_const_pattern_depends_on_generic_parameter)]
|
||||||
pub struct ConstPatternDependsOnGenericParameter {
|
pub struct ConstPatternDependsOnGenericParameter {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::could_not_eval_const_pattern)]
|
#[diag(mir_build_could_not_eval_const_pattern)]
|
||||||
pub struct CouldNotEvalConstPattern {
|
pub struct CouldNotEvalConstPattern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::lower_range_bound_must_be_less_than_or_equal_to_upper, code = "E0030")]
|
#[diag(mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper, code = "E0030")]
|
||||||
pub struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
|
pub struct LowerRangeBoundMustBeLessThanOrEqualToUpper {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[note(mir_build::teach_note)]
|
#[note(teach_note)]
|
||||||
pub teach: Option<()>,
|
pub teach: Option<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::lower_range_bound_must_be_less_than_upper, code = "E0579")]
|
#[diag(mir_build_lower_range_bound_must_be_less_than_upper, code = "E0579")]
|
||||||
pub struct LowerRangeBoundMustBeLessThanUpper {
|
pub struct LowerRangeBoundMustBeLessThanUpper {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::leading_irrefutable_let_patterns)]
|
#[diag(mir_build_leading_irrefutable_let_patterns)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct LeadingIrrefutableLetPatterns {
|
pub struct LeadingIrrefutableLetPatterns {
|
||||||
|
@ -507,7 +509,7 @@ pub struct LeadingIrrefutableLetPatterns {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::trailing_irrefutable_let_patterns)]
|
#[diag(mir_build_trailing_irrefutable_let_patterns)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct TrailingIrrefutableLetPatterns {
|
pub struct TrailingIrrefutableLetPatterns {
|
||||||
|
@ -515,7 +517,7 @@ pub struct TrailingIrrefutableLetPatterns {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::bindings_with_variant_name, code = "E0170")]
|
#[diag(mir_build_bindings_with_variant_name, code = "E0170")]
|
||||||
pub struct BindingsWithVariantName {
|
pub struct BindingsWithVariantName {
|
||||||
#[suggestion(code = "{ty_path}::{ident}", applicability = "machine-applicable")]
|
#[suggestion(code = "{ty_path}::{ident}", applicability = "machine-applicable")]
|
||||||
pub suggestion: Option<Span>,
|
pub suggestion: Option<Span>,
|
||||||
|
@ -524,7 +526,7 @@ pub struct BindingsWithVariantName {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::irrefutable_let_patterns_generic_let)]
|
#[diag(mir_build_irrefutable_let_patterns_generic_let)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct IrrefutableLetPatternsGenericLet {
|
pub struct IrrefutableLetPatternsGenericLet {
|
||||||
|
@ -532,7 +534,7 @@ pub struct IrrefutableLetPatternsGenericLet {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::irrefutable_let_patterns_if_let)]
|
#[diag(mir_build_irrefutable_let_patterns_if_let)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct IrrefutableLetPatternsIfLet {
|
pub struct IrrefutableLetPatternsIfLet {
|
||||||
|
@ -540,7 +542,7 @@ pub struct IrrefutableLetPatternsIfLet {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::irrefutable_let_patterns_if_let_guard)]
|
#[diag(mir_build_irrefutable_let_patterns_if_let_guard)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct IrrefutableLetPatternsIfLetGuard {
|
pub struct IrrefutableLetPatternsIfLetGuard {
|
||||||
|
@ -548,7 +550,7 @@ pub struct IrrefutableLetPatternsIfLetGuard {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::irrefutable_let_patterns_let_else)]
|
#[diag(mir_build_irrefutable_let_patterns_let_else)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct IrrefutableLetPatternsLetElse {
|
pub struct IrrefutableLetPatternsLetElse {
|
||||||
|
@ -556,22 +558,22 @@ pub struct IrrefutableLetPatternsLetElse {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(mir_build::irrefutable_let_patterns_while_let)]
|
#[diag(mir_build_irrefutable_let_patterns_while_let)]
|
||||||
#[note]
|
#[note]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct IrrefutableLetPatternsWhileLet {
|
pub struct IrrefutableLetPatternsWhileLet {
|
||||||
pub count: usize,
|
pub count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::borrow_of_moved_value)]
|
#[diag(mir_build_borrow_of_moved_value)]
|
||||||
pub struct BorrowOfMovedValue<'tcx> {
|
pub struct BorrowOfMovedValue<'tcx> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label]
|
#[label]
|
||||||
#[label(mir_build::occurs_because_label)]
|
#[label(occurs_because_label)]
|
||||||
pub binding_span: Span,
|
pub binding_span: Span,
|
||||||
#[label(mir_build::value_borrowed_label)]
|
#[label(value_borrowed_label)]
|
||||||
pub conflicts_ref: Vec<Span>,
|
pub conflicts_ref: Vec<Span>,
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub ty: Ty<'tcx>,
|
pub ty: Ty<'tcx>,
|
||||||
|
@ -579,33 +581,33 @@ pub struct BorrowOfMovedValue<'tcx> {
|
||||||
pub suggest_borrowing: Option<Span>,
|
pub suggest_borrowing: Option<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build::multiple_mut_borrows)]
|
#[diag(mir_build_multiple_mut_borrows)]
|
||||||
pub struct MultipleMutBorrows {
|
pub struct MultipleMutBorrows {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label]
|
#[label]
|
||||||
pub binding_span: Span,
|
pub binding_span: Span,
|
||||||
#[subdiagnostic]
|
#[subdiagnostic(eager)]
|
||||||
pub occurences: Vec<MultipleMutBorrowOccurence>,
|
pub occurences: Vec<MultipleMutBorrowOccurence>,
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum MultipleMutBorrowOccurence {
|
pub enum MultipleMutBorrowOccurence {
|
||||||
#[label(mir_build::mutable_borrow)]
|
#[label(mutable_borrow)]
|
||||||
Mutable {
|
Mutable {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
name_mut: Ident,
|
name_mut: Ident,
|
||||||
},
|
},
|
||||||
#[label(mir_build::immutable_borrow)]
|
#[label(immutable_borrow)]
|
||||||
Immutable {
|
Immutable {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
name_immut: Ident,
|
name_immut: Ident,
|
||||||
},
|
},
|
||||||
#[label(mir_build::moved)]
|
#[label(moved)]
|
||||||
Moved {
|
Moved {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
|
@ -598,11 +598,6 @@ fn irrefutable_let_patterns(
|
||||||
count: usize,
|
count: usize,
|
||||||
span: Span,
|
span: Span,
|
||||||
) {
|
) {
|
||||||
let span = match source {
|
|
||||||
LetSource::LetElse(span) => span,
|
|
||||||
_ => span,
|
|
||||||
};
|
|
||||||
|
|
||||||
macro_rules! emit_diag {
|
macro_rules! emit_diag {
|
||||||
($lint:tt) => {{
|
($lint:tt) => {{
|
||||||
tcx.emit_spanned_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count });
|
tcx.emit_spanned_lint(IRREFUTABLE_LET_PATTERNS, id, span, $lint { count });
|
||||||
|
@ -613,7 +608,7 @@ fn irrefutable_let_patterns(
|
||||||
LetSource::GenericLet => emit_diag!(IrrefutableLetPatternsGenericLet),
|
LetSource::GenericLet => emit_diag!(IrrefutableLetPatternsGenericLet),
|
||||||
LetSource::IfLet => emit_diag!(IrrefutableLetPatternsIfLet),
|
LetSource::IfLet => emit_diag!(IrrefutableLetPatternsIfLet),
|
||||||
LetSource::IfLetGuard => emit_diag!(IrrefutableLetPatternsIfLetGuard),
|
LetSource::IfLetGuard => emit_diag!(IrrefutableLetPatternsIfLetGuard),
|
||||||
LetSource::LetElse(..) => emit_diag!(IrrefutableLetPatternsLetElse),
|
LetSource::LetElse => emit_diag!(IrrefutableLetPatternsLetElse),
|
||||||
LetSource::WhileLet => emit_diag!(IrrefutableLetPatternsWhileLet),
|
LetSource::WhileLet => emit_diag!(IrrefutableLetPatternsWhileLet),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -968,7 +963,10 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_, '_>, pat: &Pa
|
||||||
conflicts_ref,
|
conflicts_ref,
|
||||||
name,
|
name,
|
||||||
ty: typeck_results.node_type(pat.hir_id),
|
ty: typeck_results.node_type(pat.hir_id),
|
||||||
suggest_borrowing: pat.span.contains(binding_span).then(|| binding_span.shrink_to_lo()),
|
suggest_borrowing: pat
|
||||||
|
.span
|
||||||
|
.contains(binding_span)
|
||||||
|
.then(|| binding_span.shrink_to_lo()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1001,16 +999,15 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_, '_>, pat: &Pa
|
||||||
// Report mutability conflicts for e.g. `ref mut x @ Some(ref mut y)`.
|
// Report mutability conflicts for e.g. `ref mut x @ Some(ref mut y)`.
|
||||||
let mut occurences = vec![];
|
let mut occurences = vec![];
|
||||||
|
|
||||||
for (span, name) in conflicts_mut_mut {
|
for (span, name_mut) in conflicts_mut_mut {
|
||||||
occurences.push(MultipleMutBorrowOccurence::Mutable { span, name_mut: name });
|
occurences.push(MultipleMutBorrowOccurence::Mutable { span, name_mut });
|
||||||
}
|
}
|
||||||
for (span, name) in conflicts_mut_ref {
|
for (span, name_immut) in conflicts_mut_ref {
|
||||||
occurences.push(MultipleMutBorrowOccurence::Immutable { span, name_immut: name });
|
occurences.push(MultipleMutBorrowOccurence::Immutable { span, name_immut });
|
||||||
}
|
}
|
||||||
for (span, name) in conflicts_move {
|
for (span, name_moved) in conflicts_move {
|
||||||
occurences.push(MultipleMutBorrowOccurence::Moved { span, name_moved: name });
|
occurences.push(MultipleMutBorrowOccurence::Moved { span, name_moved });
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.emit_err(MultipleMutBorrows { span: pat.span, binding_span, occurences, name });
|
sess.emit_err(MultipleMutBorrows { span: pat.span, binding_span, occurences, name });
|
||||||
} else if !conflicts_mut_ref.is_empty() {
|
} else if !conflicts_mut_ref.is_empty() {
|
||||||
// Report mutability conflicts for e.g. `ref x @ Some(ref mut y)` or the converse.
|
// Report mutability conflicts for e.g. `ref x @ Some(ref mut y)` or the converse.
|
||||||
|
|
|
@ -565,7 +565,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||||
_ => bug!("Expected ConstKind::Param"),
|
_ => bug!("Expected ConstKind::Param"),
|
||||||
},
|
},
|
||||||
mir::ConstantKind::Val(_, _) => self.const_to_pat(value, id, span, false).kind,
|
mir::ConstantKind::Val(_, _) => self.const_to_pat(value, id, span, false).kind,
|
||||||
mir::ConstKind::Unevaluated(_) => {
|
mir::ConstantKind::Unevaluated(..) => {
|
||||||
// If we land here it means the const can't be evaluated because it's `TooGeneric`.
|
// If we land here it means the const can't be evaluated because it's `TooGeneric`.
|
||||||
self.tcx.sess.emit_err(ConstPatternDependsOnGenericParameter { span });
|
self.tcx.sess.emit_err(ConstPatternDependsOnGenericParameter { span });
|
||||||
return PatKind::Wild;
|
return PatKind::Wild;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue