mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Rollup merge of #126013 - nnethercote:unreachable_pub, r=Urgau
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
This commit is contained in:
commit
110c3df7fd
@ -3,6 +3,7 @@
|
|||||||
#![cfg_attr(feature = "nightly", doc(rust_logo))]
|
#![cfg_attr(feature = "nightly", doc(rust_logo))]
|
||||||
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
|
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
|
||||||
#![cfg_attr(feature = "nightly", feature(step_trait))]
|
#![cfg_attr(feature = "nightly", feature(step_trait))]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
#![feature(strict_provenance)]
|
#![feature(strict_provenance)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
use std::alloc::Layout;
|
use std::alloc::Layout;
|
||||||
|
@ -32,7 +32,7 @@ impl<T> TypedArena<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_unused() {
|
fn test_unused() {
|
||||||
let arena: TypedArena<Point> = TypedArena::default();
|
let arena: TypedArena<Point> = TypedArena::default();
|
||||||
assert!(arena.chunks.borrow().is_empty());
|
assert!(arena.chunks.borrow().is_empty());
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ fn test_arena_alloc_nested() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_copy() {
|
fn test_copy() {
|
||||||
let arena = TypedArena::default();
|
let arena = TypedArena::default();
|
||||||
#[cfg(not(miri))]
|
#[cfg(not(miri))]
|
||||||
const N: usize = 100000;
|
const N: usize = 100000;
|
||||||
@ -87,13 +87,13 @@ pub fn test_copy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
pub fn bench_copy(b: &mut Bencher) {
|
fn bench_copy(b: &mut Bencher) {
|
||||||
let arena = TypedArena::default();
|
let arena = TypedArena::default();
|
||||||
b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 }))
|
b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
pub fn bench_copy_nonarena(b: &mut Bencher) {
|
fn bench_copy_nonarena(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let _: Box<_> = Box::new(Point { x: 1, y: 2, z: 3 });
|
let _: Box<_> = Box::new(Point { x: 1, y: 2, z: 3 });
|
||||||
})
|
})
|
||||||
@ -106,7 +106,7 @@ struct Noncopy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_noncopy() {
|
fn test_noncopy() {
|
||||||
let arena = TypedArena::default();
|
let arena = TypedArena::default();
|
||||||
#[cfg(not(miri))]
|
#[cfg(not(miri))]
|
||||||
const N: usize = 100000;
|
const N: usize = 100000;
|
||||||
@ -118,7 +118,7 @@ pub fn test_noncopy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_typed_arena_zero_sized() {
|
fn test_typed_arena_zero_sized() {
|
||||||
let arena = TypedArena::default();
|
let arena = TypedArena::default();
|
||||||
#[cfg(not(miri))]
|
#[cfg(not(miri))]
|
||||||
const N: usize = 100000;
|
const N: usize = 100000;
|
||||||
@ -130,7 +130,7 @@ pub fn test_typed_arena_zero_sized() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_typed_arena_clear() {
|
fn test_typed_arena_clear() {
|
||||||
let mut arena = TypedArena::default();
|
let mut arena = TypedArena::default();
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
arena.clear();
|
arena.clear();
|
||||||
@ -145,7 +145,7 @@ pub fn test_typed_arena_clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
pub fn bench_typed_arena_clear(b: &mut Bencher) {
|
fn bench_typed_arena_clear(b: &mut Bencher) {
|
||||||
let mut arena = TypedArena::default();
|
let mut arena = TypedArena::default();
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
arena.alloc(Point { x: 1, y: 2, z: 3 });
|
arena.alloc(Point { x: 1, y: 2, z: 3 });
|
||||||
@ -154,7 +154,7 @@ pub fn bench_typed_arena_clear(b: &mut Bencher) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
pub fn bench_typed_arena_clear_100(b: &mut Bencher) {
|
fn bench_typed_arena_clear_100(b: &mut Bencher) {
|
||||||
let mut arena = TypedArena::default();
|
let mut arena = TypedArena::default();
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for _ in 0..100 {
|
for _ in 0..100 {
|
||||||
@ -230,7 +230,7 @@ fn test_typed_arena_drop_small_count() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
pub fn bench_noncopy(b: &mut Bencher) {
|
fn bench_noncopy(b: &mut Bencher) {
|
||||||
let arena = TypedArena::default();
|
let arena = TypedArena::default();
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
arena.alloc(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] })
|
arena.alloc(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] })
|
||||||
@ -238,7 +238,7 @@ pub fn bench_noncopy(b: &mut Bencher) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
pub fn bench_noncopy_nonarena(b: &mut Bencher) {
|
fn bench_noncopy_nonarena(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let _: Box<_> =
|
let _: Box<_> =
|
||||||
Box::new(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] });
|
Box::new(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] });
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
pub mod util {
|
pub mod util {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#![cfg_attr(feature = "nightly", allow(internal_features))]
|
#![cfg_attr(feature = "nightly", allow(internal_features))]
|
||||||
#![cfg_attr(feature = "nightly", feature(never_type))]
|
#![cfg_attr(feature = "nightly", feature(never_type))]
|
||||||
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
|
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
#[cfg(feature = "nightly")]
|
#[cfg(feature = "nightly")]
|
||||||
|
@ -6,7 +6,7 @@ use rustc_span::{Span, Symbol};
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
|
#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
|
||||||
pub struct GenericTypeWithParentheses {
|
pub(crate) struct GenericTypeWithParentheses {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -16,7 +16,7 @@ pub struct GenericTypeWithParentheses {
|
|||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")]
|
#[multipart_suggestion(ast_lowering_use_angle_brackets, applicability = "maybe-incorrect")]
|
||||||
pub struct UseAngleBrackets {
|
pub(crate) struct UseAngleBrackets {
|
||||||
#[suggestion_part(code = "<")]
|
#[suggestion_part(code = "<")]
|
||||||
pub open_param: Span,
|
pub open_param: Span,
|
||||||
#[suggestion_part(code = ">")]
|
#[suggestion_part(code = ">")]
|
||||||
@ -26,7 +26,7 @@ pub struct UseAngleBrackets {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_invalid_abi, code = E0703)]
|
#[diag(ast_lowering_invalid_abi, code = E0703)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct InvalidAbi {
|
pub(crate) struct InvalidAbi {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -38,7 +38,7 @@ pub struct InvalidAbi {
|
|||||||
pub suggestion: Option<InvalidAbiSuggestion>,
|
pub suggestion: Option<InvalidAbiSuggestion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InvalidAbiReason(pub &'static str);
|
pub(crate) struct InvalidAbiReason(pub &'static str);
|
||||||
|
|
||||||
impl Subdiagnostic for InvalidAbiReason {
|
impl Subdiagnostic for InvalidAbiReason {
|
||||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||||
@ -57,7 +57,7 @@ impl Subdiagnostic for InvalidAbiReason {
|
|||||||
code = "{suggestion}",
|
code = "{suggestion}",
|
||||||
applicability = "maybe-incorrect"
|
applicability = "maybe-incorrect"
|
||||||
)]
|
)]
|
||||||
pub struct InvalidAbiSuggestion {
|
pub(crate) struct InvalidAbiSuggestion {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub suggestion: String,
|
pub suggestion: String,
|
||||||
@ -65,7 +65,7 @@ pub struct InvalidAbiSuggestion {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_assoc_ty_parentheses)]
|
#[diag(ast_lowering_assoc_ty_parentheses)]
|
||||||
pub struct AssocTyParentheses {
|
pub(crate) struct AssocTyParentheses {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[subdiagnostic]
|
#[subdiagnostic]
|
||||||
@ -73,7 +73,7 @@ pub struct AssocTyParentheses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum AssocTyParenthesesSub {
|
pub(crate) enum AssocTyParenthesesSub {
|
||||||
#[multipart_suggestion(ast_lowering_remove_parentheses)]
|
#[multipart_suggestion(ast_lowering_remove_parentheses)]
|
||||||
Empty {
|
Empty {
|
||||||
#[suggestion_part(code = "")]
|
#[suggestion_part(code = "")]
|
||||||
@ -91,7 +91,7 @@ pub enum AssocTyParenthesesSub {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_misplaced_impl_trait, code = E0562)]
|
#[diag(ast_lowering_misplaced_impl_trait, code = E0562)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct MisplacedImplTrait<'a> {
|
pub(crate) struct MisplacedImplTrait<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub position: DiagArgFromDisplay<'a>,
|
pub position: DiagArgFromDisplay<'a>,
|
||||||
@ -99,7 +99,7 @@ pub struct MisplacedImplTrait<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_assoc_ty_binding_in_dyn)]
|
#[diag(ast_lowering_assoc_ty_binding_in_dyn)]
|
||||||
pub struct MisplacedAssocTyBinding {
|
pub(crate) struct MisplacedAssocTyBinding {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " = impl", applicability = "maybe-incorrect", style = "verbose")]
|
#[suggestion(code = " = impl", applicability = "maybe-incorrect", style = "verbose")]
|
||||||
@ -108,7 +108,7 @@ pub struct MisplacedAssocTyBinding {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_underscore_expr_lhs_assign)]
|
#[diag(ast_lowering_underscore_expr_lhs_assign)]
|
||||||
pub struct UnderscoreExprLhsAssign {
|
pub(crate) struct UnderscoreExprLhsAssign {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -116,7 +116,7 @@ pub struct UnderscoreExprLhsAssign {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_base_expression_double_dot, code = E0797)]
|
#[diag(ast_lowering_base_expression_double_dot, code = E0797)]
|
||||||
pub struct BaseExpressionDoubleDot {
|
pub(crate) struct BaseExpressionDoubleDot {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[suggestion(code = "/* expr */", applicability = "has-placeholders", style = "verbose")]
|
#[suggestion(code = "/* expr */", applicability = "has-placeholders", style = "verbose")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -124,7 +124,7 @@ pub struct BaseExpressionDoubleDot {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = E0728)]
|
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = E0728)]
|
||||||
pub struct AwaitOnlyInAsyncFnAndBlocks {
|
pub(crate) struct AwaitOnlyInAsyncFnAndBlocks {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub await_kw_span: Span,
|
pub await_kw_span: Span,
|
||||||
@ -134,21 +134,21 @@ pub struct AwaitOnlyInAsyncFnAndBlocks {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_coroutine_too_many_parameters, code = E0628)]
|
#[diag(ast_lowering_coroutine_too_many_parameters, code = E0628)]
|
||||||
pub struct CoroutineTooManyParameters {
|
pub(crate) struct CoroutineTooManyParameters {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub fn_decl_span: Span,
|
pub fn_decl_span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_closure_cannot_be_static, code = E0697)]
|
#[diag(ast_lowering_closure_cannot_be_static, code = E0697)]
|
||||||
pub struct ClosureCannotBeStatic {
|
pub(crate) struct ClosureCannotBeStatic {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub fn_decl_span: Span,
|
pub fn_decl_span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
|
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
|
||||||
pub struct FunctionalRecordUpdateDestructuringAssignment {
|
pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[suggestion(code = "", applicability = "machine-applicable")]
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -156,28 +156,28 @@ pub struct FunctionalRecordUpdateDestructuringAssignment {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_async_coroutines_not_supported, code = E0727)]
|
#[diag(ast_lowering_async_coroutines_not_supported, code = E0727)]
|
||||||
pub struct AsyncCoroutinesNotSupported {
|
pub(crate) struct AsyncCoroutinesNotSupported {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_inline_asm_unsupported_target, code = E0472)]
|
#[diag(ast_lowering_inline_asm_unsupported_target, code = E0472)]
|
||||||
pub struct InlineAsmUnsupportedTarget {
|
pub(crate) struct InlineAsmUnsupportedTarget {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_att_syntax_only_x86)]
|
#[diag(ast_lowering_att_syntax_only_x86)]
|
||||||
pub struct AttSyntaxOnlyX86 {
|
pub(crate) struct AttSyntaxOnlyX86 {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_abi_specified_multiple_times)]
|
#[diag(ast_lowering_abi_specified_multiple_times)]
|
||||||
pub struct AbiSpecifiedMultipleTimes {
|
pub(crate) struct AbiSpecifiedMultipleTimes {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub abi_span: Span,
|
pub abi_span: Span,
|
||||||
pub prev_name: Symbol,
|
pub prev_name: Symbol,
|
||||||
@ -189,7 +189,7 @@ pub struct AbiSpecifiedMultipleTimes {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_clobber_abi_not_supported)]
|
#[diag(ast_lowering_clobber_abi_not_supported)]
|
||||||
pub struct ClobberAbiNotSupported {
|
pub(crate) struct ClobberAbiNotSupported {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub abi_span: Span,
|
pub abi_span: Span,
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ pub struct ClobberAbiNotSupported {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[note]
|
#[note]
|
||||||
#[diag(ast_lowering_invalid_abi_clobber_abi)]
|
#[diag(ast_lowering_invalid_abi_clobber_abi)]
|
||||||
pub struct InvalidAbiClobberAbi {
|
pub(crate) struct InvalidAbiClobberAbi {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub abi_span: Span,
|
pub abi_span: Span,
|
||||||
pub supported_abis: String,
|
pub supported_abis: String,
|
||||||
@ -205,7 +205,7 @@ pub struct InvalidAbiClobberAbi {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_invalid_register)]
|
#[diag(ast_lowering_invalid_register)]
|
||||||
pub struct InvalidRegister<'a> {
|
pub(crate) struct InvalidRegister<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub op_span: Span,
|
pub op_span: Span,
|
||||||
pub reg: Symbol,
|
pub reg: Symbol,
|
||||||
@ -214,7 +214,7 @@ pub struct InvalidRegister<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_invalid_register_class)]
|
#[diag(ast_lowering_invalid_register_class)]
|
||||||
pub struct InvalidRegisterClass<'a> {
|
pub(crate) struct InvalidRegisterClass<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub op_span: Span,
|
pub op_span: Span,
|
||||||
pub reg_class: Symbol,
|
pub reg_class: Symbol,
|
||||||
@ -223,7 +223,7 @@ pub struct InvalidRegisterClass<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_invalid_asm_template_modifier_reg_class)]
|
#[diag(ast_lowering_invalid_asm_template_modifier_reg_class)]
|
||||||
pub struct InvalidAsmTemplateModifierRegClass {
|
pub(crate) struct InvalidAsmTemplateModifierRegClass {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(ast_lowering_template_modifier)]
|
#[label(ast_lowering_template_modifier)]
|
||||||
pub placeholder_span: Span,
|
pub placeholder_span: Span,
|
||||||
@ -234,7 +234,7 @@ pub struct InvalidAsmTemplateModifierRegClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum InvalidAsmTemplateModifierRegClassSub {
|
pub(crate) enum InvalidAsmTemplateModifierRegClassSub {
|
||||||
#[note(ast_lowering_support_modifiers)]
|
#[note(ast_lowering_support_modifiers)]
|
||||||
SupportModifier { class_name: Symbol, modifiers: String },
|
SupportModifier { class_name: Symbol, modifiers: String },
|
||||||
#[note(ast_lowering_does_not_support_modifiers)]
|
#[note(ast_lowering_does_not_support_modifiers)]
|
||||||
@ -243,7 +243,7 @@ pub enum InvalidAsmTemplateModifierRegClassSub {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_invalid_asm_template_modifier_const)]
|
#[diag(ast_lowering_invalid_asm_template_modifier_const)]
|
||||||
pub struct InvalidAsmTemplateModifierConst {
|
pub(crate) struct InvalidAsmTemplateModifierConst {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(ast_lowering_template_modifier)]
|
#[label(ast_lowering_template_modifier)]
|
||||||
pub placeholder_span: Span,
|
pub placeholder_span: Span,
|
||||||
@ -253,7 +253,7 @@ pub struct InvalidAsmTemplateModifierConst {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_invalid_asm_template_modifier_sym)]
|
#[diag(ast_lowering_invalid_asm_template_modifier_sym)]
|
||||||
pub struct InvalidAsmTemplateModifierSym {
|
pub(crate) struct InvalidAsmTemplateModifierSym {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(ast_lowering_template_modifier)]
|
#[label(ast_lowering_template_modifier)]
|
||||||
pub placeholder_span: Span,
|
pub placeholder_span: Span,
|
||||||
@ -263,7 +263,7 @@ pub struct InvalidAsmTemplateModifierSym {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_invalid_asm_template_modifier_label)]
|
#[diag(ast_lowering_invalid_asm_template_modifier_label)]
|
||||||
pub struct InvalidAsmTemplateModifierLabel {
|
pub(crate) struct InvalidAsmTemplateModifierLabel {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(ast_lowering_template_modifier)]
|
#[label(ast_lowering_template_modifier)]
|
||||||
pub placeholder_span: Span,
|
pub placeholder_span: Span,
|
||||||
@ -273,7 +273,7 @@ pub struct InvalidAsmTemplateModifierLabel {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_register_class_only_clobber)]
|
#[diag(ast_lowering_register_class_only_clobber)]
|
||||||
pub struct RegisterClassOnlyClobber {
|
pub(crate) struct RegisterClassOnlyClobber {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub op_span: Span,
|
pub op_span: Span,
|
||||||
pub reg_class_name: Symbol,
|
pub reg_class_name: Symbol,
|
||||||
@ -281,7 +281,7 @@ pub struct RegisterClassOnlyClobber {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_register_conflict)]
|
#[diag(ast_lowering_register_conflict)]
|
||||||
pub struct RegisterConflict<'a> {
|
pub(crate) struct RegisterConflict<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(ast_lowering_register1)]
|
#[label(ast_lowering_register1)]
|
||||||
pub op_span1: Span,
|
pub op_span1: Span,
|
||||||
@ -296,7 +296,7 @@ pub struct RegisterConflict<'a> {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[help]
|
#[help]
|
||||||
#[diag(ast_lowering_sub_tuple_binding)]
|
#[diag(ast_lowering_sub_tuple_binding)]
|
||||||
pub struct SubTupleBinding<'a> {
|
pub(crate) struct SubTupleBinding<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
#[suggestion(
|
#[suggestion(
|
||||||
@ -313,7 +313,7 @@ pub struct SubTupleBinding<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_extra_double_dot)]
|
#[diag(ast_lowering_extra_double_dot)]
|
||||||
pub struct ExtraDoubleDot<'a> {
|
pub(crate) struct ExtraDoubleDot<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -325,21 +325,21 @@ pub struct ExtraDoubleDot<'a> {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[note]
|
#[note]
|
||||||
#[diag(ast_lowering_misplaced_double_dot)]
|
#[diag(ast_lowering_misplaced_double_dot)]
|
||||||
pub struct MisplacedDoubleDot {
|
pub(crate) struct MisplacedDoubleDot {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_misplaced_relax_trait_bound)]
|
#[diag(ast_lowering_misplaced_relax_trait_bound)]
|
||||||
pub struct MisplacedRelaxTraitBound {
|
pub(crate) struct MisplacedRelaxTraitBound {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_match_arm_with_no_body)]
|
#[diag(ast_lowering_match_arm_with_no_body)]
|
||||||
pub struct MatchArmWithNoBody {
|
pub(crate) struct MatchArmWithNoBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
|
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
|
||||||
@ -348,7 +348,7 @@ pub struct MatchArmWithNoBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_never_pattern_with_body)]
|
#[diag(ast_lowering_never_pattern_with_body)]
|
||||||
pub struct NeverPatternWithBody {
|
pub(crate) struct NeverPatternWithBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
||||||
@ -357,7 +357,7 @@ pub struct NeverPatternWithBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_never_pattern_with_guard)]
|
#[diag(ast_lowering_never_pattern_with_guard)]
|
||||||
pub struct NeverPatternWithGuard {
|
pub(crate) struct NeverPatternWithGuard {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -365,7 +365,7 @@ pub struct NeverPatternWithGuard {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_arbitrary_expression_in_pattern)]
|
#[diag(ast_lowering_arbitrary_expression_in_pattern)]
|
||||||
pub struct ArbitraryExpressionInPattern {
|
pub(crate) struct ArbitraryExpressionInPattern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[note(ast_lowering_pattern_from_macro_note)]
|
#[note(ast_lowering_pattern_from_macro_note)]
|
||||||
@ -374,13 +374,13 @@ pub struct ArbitraryExpressionInPattern {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_lowering_inclusive_range_with_no_end)]
|
#[diag(ast_lowering_inclusive_range_with_no_end)]
|
||||||
pub struct InclusiveRangeWithNoEnd {
|
pub(crate) struct InclusiveRangeWithNoEnd {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
pub enum BadReturnTypeNotation {
|
pub(crate) enum BadReturnTypeNotation {
|
||||||
#[diag(ast_lowering_bad_return_type_notation_inputs)]
|
#[diag(ast_lowering_bad_return_type_notation_inputs)]
|
||||||
Inputs {
|
Inputs {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -1188,7 +1188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
/// into the body. This is to make sure that the future actually owns the
|
/// into the body. This is to make sure that the future actually owns the
|
||||||
/// arguments that are passed to the function, and to ensure things like
|
/// arguments that are passed to the function, and to ensure things like
|
||||||
/// drop order are stable.
|
/// drop order are stable.
|
||||||
pub fn lower_coroutine_body_with_moved_arguments(
|
pub(crate) fn lower_coroutine_body_with_moved_arguments(
|
||||||
&mut self,
|
&mut self,
|
||||||
decl: &FnDecl,
|
decl: &FnDecl,
|
||||||
lower_body: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::Expr<'hir>,
|
lower_body: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::Expr<'hir>,
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
@ -11,7 +11,7 @@ use crate::fluent_generated as fluent;
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_visibility_not_permitted, code = E0449)]
|
#[diag(ast_passes_visibility_not_permitted, code = E0449)]
|
||||||
pub struct VisibilityNotPermitted {
|
pub(crate) struct VisibilityNotPermitted {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[subdiagnostic]
|
#[subdiagnostic]
|
||||||
@ -25,7 +25,7 @@ pub struct VisibilityNotPermitted {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum VisibilityNotPermittedNote {
|
pub(crate) enum VisibilityNotPermittedNote {
|
||||||
#[note(ast_passes_enum_variant)]
|
#[note(ast_passes_enum_variant)]
|
||||||
EnumVariant,
|
EnumVariant,
|
||||||
#[note(ast_passes_trait_impl)]
|
#[note(ast_passes_trait_impl)]
|
||||||
@ -38,7 +38,7 @@ pub enum VisibilityNotPermittedNote {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_trait_fn_const, code = E0379)]
|
#[diag(ast_passes_trait_fn_const, code = E0379)]
|
||||||
pub struct TraitFnConst {
|
pub(crate) struct TraitFnConst {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -64,21 +64,21 @@ pub struct TraitFnConst {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_forbidden_bound)]
|
#[diag(ast_passes_forbidden_bound)]
|
||||||
pub struct ForbiddenBound {
|
pub(crate) struct ForbiddenBound {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub spans: Vec<Span>,
|
pub spans: Vec<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_forbidden_const_param)]
|
#[diag(ast_passes_forbidden_const_param)]
|
||||||
pub struct ForbiddenConstParam {
|
pub(crate) struct ForbiddenConstParam {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub const_param_spans: Vec<Span>,
|
pub const_param_spans: Vec<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_fn_param_too_many)]
|
#[diag(ast_passes_fn_param_too_many)]
|
||||||
pub struct FnParamTooMany {
|
pub(crate) struct FnParamTooMany {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub max_num_args: usize,
|
pub max_num_args: usize,
|
||||||
@ -86,14 +86,14 @@ pub struct FnParamTooMany {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_fn_param_c_var_args_not_last)]
|
#[diag(ast_passes_fn_param_c_var_args_not_last)]
|
||||||
pub struct FnParamCVarArgsNotLast {
|
pub(crate) struct FnParamCVarArgsNotLast {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_fn_param_doc_comment)]
|
#[diag(ast_passes_fn_param_doc_comment)]
|
||||||
pub struct FnParamDocComment {
|
pub(crate) struct FnParamDocComment {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -101,7 +101,7 @@ pub struct FnParamDocComment {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_fn_param_forbidden_attr)]
|
#[diag(ast_passes_fn_param_forbidden_attr)]
|
||||||
pub struct FnParamForbiddenAttr {
|
pub(crate) struct FnParamForbiddenAttr {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ pub struct FnParamForbiddenAttr {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_fn_param_forbidden_self)]
|
#[diag(ast_passes_fn_param_forbidden_self)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct FnParamForbiddenSelf {
|
pub(crate) struct FnParamForbiddenSelf {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -117,7 +117,7 @@ pub struct FnParamForbiddenSelf {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_forbidden_default)]
|
#[diag(ast_passes_forbidden_default)]
|
||||||
pub struct ForbiddenDefault {
|
pub(crate) struct ForbiddenDefault {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label]
|
#[label]
|
||||||
@ -126,7 +126,7 @@ pub struct ForbiddenDefault {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_assoc_const_without_body)]
|
#[diag(ast_passes_assoc_const_without_body)]
|
||||||
pub struct AssocConstWithoutBody {
|
pub(crate) struct AssocConstWithoutBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
||||||
@ -135,7 +135,7 @@ pub struct AssocConstWithoutBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_assoc_fn_without_body)]
|
#[diag(ast_passes_assoc_fn_without_body)]
|
||||||
pub struct AssocFnWithoutBody {
|
pub(crate) struct AssocFnWithoutBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
||||||
@ -144,7 +144,7 @@ pub struct AssocFnWithoutBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_assoc_type_without_body)]
|
#[diag(ast_passes_assoc_type_without_body)]
|
||||||
pub struct AssocTypeWithoutBody {
|
pub(crate) struct AssocTypeWithoutBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
||||||
@ -153,7 +153,7 @@ pub struct AssocTypeWithoutBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_const_without_body)]
|
#[diag(ast_passes_const_without_body)]
|
||||||
pub struct ConstWithoutBody {
|
pub(crate) struct ConstWithoutBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
||||||
@ -162,7 +162,7 @@ pub struct ConstWithoutBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_static_without_body)]
|
#[diag(ast_passes_static_without_body)]
|
||||||
pub struct StaticWithoutBody {
|
pub(crate) struct StaticWithoutBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
||||||
@ -171,7 +171,7 @@ pub struct StaticWithoutBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_ty_alias_without_body)]
|
#[diag(ast_passes_ty_alias_without_body)]
|
||||||
pub struct TyAliasWithoutBody {
|
pub(crate) struct TyAliasWithoutBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
||||||
@ -180,7 +180,7 @@ pub struct TyAliasWithoutBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_fn_without_body)]
|
#[diag(ast_passes_fn_without_body)]
|
||||||
pub struct FnWithoutBody {
|
pub(crate) struct FnWithoutBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
||||||
@ -190,7 +190,7 @@ pub struct FnWithoutBody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum ExternBlockSuggestion {
|
pub(crate) enum ExternBlockSuggestion {
|
||||||
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
|
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
|
||||||
Implicit {
|
Implicit {
|
||||||
#[suggestion_part(code = "extern {{")]
|
#[suggestion_part(code = "extern {{")]
|
||||||
@ -210,7 +210,7 @@ pub enum ExternBlockSuggestion {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_extern_invalid_safety)]
|
#[diag(ast_passes_extern_invalid_safety)]
|
||||||
pub struct InvalidSafetyOnExtern {
|
pub(crate) struct InvalidSafetyOnExtern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub item_span: Span,
|
pub item_span: Span,
|
||||||
#[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
|
#[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
|
||||||
@ -219,28 +219,28 @@ pub struct InvalidSafetyOnExtern {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_item_invalid_safety)]
|
#[diag(ast_passes_item_invalid_safety)]
|
||||||
pub struct InvalidSafetyOnItem {
|
pub(crate) struct InvalidSafetyOnItem {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_bare_fn_invalid_safety)]
|
#[diag(ast_passes_bare_fn_invalid_safety)]
|
||||||
pub struct InvalidSafetyOnBareFn {
|
pub(crate) struct InvalidSafetyOnBareFn {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_unsafe_static)]
|
#[diag(ast_passes_unsafe_static)]
|
||||||
pub struct UnsafeStatic {
|
pub(crate) struct UnsafeStatic {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_bound_in_context)]
|
#[diag(ast_passes_bound_in_context)]
|
||||||
pub struct BoundInContext<'a> {
|
pub(crate) struct BoundInContext<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub ctx: &'a str,
|
pub ctx: &'a str,
|
||||||
@ -249,7 +249,7 @@ pub struct BoundInContext<'a> {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_extern_types_cannot)]
|
#[diag(ast_passes_extern_types_cannot)]
|
||||||
#[note(ast_passes_extern_keyword_link)]
|
#[note(ast_passes_extern_keyword_link)]
|
||||||
pub struct ExternTypesCannotHave<'a> {
|
pub(crate) struct ExternTypesCannotHave<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -262,7 +262,7 @@ pub struct ExternTypesCannotHave<'a> {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_body_in_extern)]
|
#[diag(ast_passes_body_in_extern)]
|
||||||
#[note(ast_passes_extern_keyword_link)]
|
#[note(ast_passes_extern_keyword_link)]
|
||||||
pub struct BodyInExtern<'a> {
|
pub(crate) struct BodyInExtern<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(ast_passes_cannot_have)]
|
#[label(ast_passes_cannot_have)]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -277,7 +277,7 @@ pub struct BodyInExtern<'a> {
|
|||||||
#[diag(ast_passes_fn_body_extern)]
|
#[diag(ast_passes_fn_body_extern)]
|
||||||
#[help]
|
#[help]
|
||||||
#[note(ast_passes_extern_keyword_link)]
|
#[note(ast_passes_extern_keyword_link)]
|
||||||
pub struct FnBodyInExtern {
|
pub(crate) struct FnBodyInExtern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(ast_passes_cannot_have)]
|
#[label(ast_passes_cannot_have)]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -289,7 +289,7 @@ pub struct FnBodyInExtern {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_extern_fn_qualifiers)]
|
#[diag(ast_passes_extern_fn_qualifiers)]
|
||||||
pub struct FnQualifierInExtern {
|
pub(crate) struct FnQualifierInExtern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -300,7 +300,7 @@ pub struct FnQualifierInExtern {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_extern_item_ascii)]
|
#[diag(ast_passes_extern_item_ascii)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct ExternItemAscii {
|
pub(crate) struct ExternItemAscii {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label]
|
#[label]
|
||||||
@ -309,14 +309,14 @@ pub struct ExternItemAscii {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_bad_c_variadic)]
|
#[diag(ast_passes_bad_c_variadic)]
|
||||||
pub struct BadCVariadic {
|
pub(crate) struct BadCVariadic {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Vec<Span>,
|
pub span: Vec<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_item_underscore)]
|
#[diag(ast_passes_item_underscore)]
|
||||||
pub struct ItemUnderscore<'a> {
|
pub(crate) struct ItemUnderscore<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -325,7 +325,7 @@ pub struct ItemUnderscore<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_nomangle_ascii, code = E0754)]
|
#[diag(ast_passes_nomangle_ascii, code = E0754)]
|
||||||
pub struct NoMangleAscii {
|
pub(crate) struct NoMangleAscii {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ pub struct NoMangleAscii {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_module_nonascii, code = E0754)]
|
#[diag(ast_passes_module_nonascii, code = E0754)]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct ModuleNonAscii {
|
pub(crate) struct ModuleNonAscii {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
@ -341,7 +341,7 @@ pub struct ModuleNonAscii {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_auto_generic, code = E0567)]
|
#[diag(ast_passes_auto_generic, code = E0567)]
|
||||||
pub struct AutoTraitGeneric {
|
pub(crate) struct AutoTraitGeneric {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[suggestion(code = "", applicability = "machine-applicable")]
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -351,7 +351,7 @@ pub struct AutoTraitGeneric {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_auto_super_lifetime, code = E0568)]
|
#[diag(ast_passes_auto_super_lifetime, code = E0568)]
|
||||||
pub struct AutoTraitBounds {
|
pub(crate) struct AutoTraitBounds {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[suggestion(code = "", applicability = "machine-applicable")]
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -361,7 +361,7 @@ pub struct AutoTraitBounds {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_auto_items, code = E0380)]
|
#[diag(ast_passes_auto_items, code = E0380)]
|
||||||
pub struct AutoTraitItems {
|
pub(crate) struct AutoTraitItems {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub spans: Vec<Span>,
|
pub spans: Vec<Span>,
|
||||||
#[suggestion(code = "", applicability = "machine-applicable")]
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||||
@ -372,7 +372,7 @@ pub struct AutoTraitItems {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_generic_before_constraints)]
|
#[diag(ast_passes_generic_before_constraints)]
|
||||||
pub struct ArgsBeforeConstraint {
|
pub(crate) struct ArgsBeforeConstraint {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub arg_spans: Vec<Span>,
|
pub arg_spans: Vec<Span>,
|
||||||
#[label(ast_passes_constraints)]
|
#[label(ast_passes_constraints)]
|
||||||
@ -390,7 +390,7 @@ pub struct ArgsBeforeConstraint {
|
|||||||
pub arg_spans2: EmptyLabelManySpans,
|
pub arg_spans2: EmptyLabelManySpans,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EmptyLabelManySpans(pub Vec<Span>);
|
pub(crate) struct EmptyLabelManySpans(pub Vec<Span>);
|
||||||
|
|
||||||
// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
|
// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
|
||||||
impl Subdiagnostic for EmptyLabelManySpans {
|
impl Subdiagnostic for EmptyLabelManySpans {
|
||||||
@ -405,28 +405,28 @@ impl Subdiagnostic for EmptyLabelManySpans {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_pattern_in_fn_pointer, code = E0561)]
|
#[diag(ast_passes_pattern_in_fn_pointer, code = E0561)]
|
||||||
pub struct PatternFnPointer {
|
pub(crate) struct PatternFnPointer {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_trait_object_single_bound, code = E0226)]
|
#[diag(ast_passes_trait_object_single_bound, code = E0226)]
|
||||||
pub struct TraitObjectBound {
|
pub(crate) struct TraitObjectBound {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_impl_trait_path, code = E0667)]
|
#[diag(ast_passes_impl_trait_path, code = E0667)]
|
||||||
pub struct ImplTraitPath {
|
pub(crate) struct ImplTraitPath {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_nested_impl_trait, code = E0666)]
|
#[diag(ast_passes_nested_impl_trait, code = E0666)]
|
||||||
pub struct NestedImplTrait {
|
pub(crate) struct NestedImplTrait {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label(ast_passes_outer)]
|
#[label(ast_passes_outer)]
|
||||||
@ -437,14 +437,14 @@ pub struct NestedImplTrait {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_at_least_one_trait)]
|
#[diag(ast_passes_at_least_one_trait)]
|
||||||
pub struct AtLeastOneTrait {
|
pub(crate) struct AtLeastOneTrait {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_out_of_order_params)]
|
#[diag(ast_passes_out_of_order_params)]
|
||||||
pub struct OutOfOrderParams<'a> {
|
pub(crate) struct OutOfOrderParams<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub spans: Vec<Span>,
|
pub spans: Vec<Span>,
|
||||||
#[suggestion(code = "{ordered_params}", applicability = "machine-applicable")]
|
#[suggestion(code = "{ordered_params}", applicability = "machine-applicable")]
|
||||||
@ -457,14 +457,14 @@ pub struct OutOfOrderParams<'a> {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_obsolete_auto)]
|
#[diag(ast_passes_obsolete_auto)]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct ObsoleteAuto {
|
pub(crate) struct ObsoleteAuto {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_unsafe_negative_impl, code = E0198)]
|
#[diag(ast_passes_unsafe_negative_impl, code = E0198)]
|
||||||
pub struct UnsafeNegativeImpl {
|
pub(crate) struct UnsafeNegativeImpl {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label(ast_passes_negative)]
|
#[label(ast_passes_negative)]
|
||||||
@ -475,7 +475,7 @@ pub struct UnsafeNegativeImpl {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_inherent_cannot_be)]
|
#[diag(ast_passes_inherent_cannot_be)]
|
||||||
pub struct InherentImplCannot<'a> {
|
pub(crate) struct InherentImplCannot<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label(ast_passes_because)]
|
#[label(ast_passes_because)]
|
||||||
@ -489,7 +489,7 @@ pub struct InherentImplCannot<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_inherent_cannot_be, code = E0197)]
|
#[diag(ast_passes_inherent_cannot_be, code = E0197)]
|
||||||
pub struct InherentImplCannotUnsafe<'a> {
|
pub(crate) struct InherentImplCannotUnsafe<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label(ast_passes_because)]
|
#[label(ast_passes_because)]
|
||||||
@ -501,7 +501,7 @@ pub struct InherentImplCannotUnsafe<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_unsafe_item)]
|
#[diag(ast_passes_unsafe_item)]
|
||||||
pub struct UnsafeItem {
|
pub(crate) struct UnsafeItem {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub kind: &'static str,
|
pub kind: &'static str,
|
||||||
@ -509,14 +509,14 @@ pub struct UnsafeItem {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_missing_unsafe_on_extern)]
|
#[diag(ast_passes_missing_unsafe_on_extern)]
|
||||||
pub struct MissingUnsafeOnExtern {
|
pub(crate) struct MissingUnsafeOnExtern {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_fieldless_union)]
|
#[diag(ast_passes_fieldless_union)]
|
||||||
pub struct FieldlessUnion {
|
pub(crate) struct FieldlessUnion {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
@ -524,7 +524,7 @@ pub struct FieldlessUnion {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_where_clause_after_type_alias)]
|
#[diag(ast_passes_where_clause_after_type_alias)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct WhereClauseAfterTypeAlias {
|
pub(crate) struct WhereClauseAfterTypeAlias {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[help]
|
#[help]
|
||||||
@ -534,7 +534,7 @@ pub struct WhereClauseAfterTypeAlias {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_where_clause_before_type_alias)]
|
#[diag(ast_passes_where_clause_before_type_alias)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct WhereClauseBeforeTypeAlias {
|
pub(crate) struct WhereClauseBeforeTypeAlias {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[subdiagnostic]
|
#[subdiagnostic]
|
||||||
@ -543,7 +543,7 @@ pub struct WhereClauseBeforeTypeAlias {
|
|||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
|
|
||||||
pub enum WhereClauseBeforeTypeAliasSugg {
|
pub(crate) enum WhereClauseBeforeTypeAliasSugg {
|
||||||
#[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
|
#[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
|
||||||
Remove {
|
Remove {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
@ -565,14 +565,14 @@ pub enum WhereClauseBeforeTypeAliasSugg {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_generic_default_trailing)]
|
#[diag(ast_passes_generic_default_trailing)]
|
||||||
pub struct GenericDefaultTrailing {
|
pub(crate) struct GenericDefaultTrailing {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_nested_lifetimes, code = E0316)]
|
#[diag(ast_passes_nested_lifetimes, code = E0316)]
|
||||||
pub struct NestedLifetimes {
|
pub(crate) struct NestedLifetimes {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
@ -580,7 +580,7 @@ pub struct NestedLifetimes {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_optional_trait_supertrait)]
|
#[diag(ast_passes_optional_trait_supertrait)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct OptionalTraitSupertrait {
|
pub(crate) struct OptionalTraitSupertrait {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub path_str: String,
|
pub path_str: String,
|
||||||
@ -588,14 +588,14 @@ pub struct OptionalTraitSupertrait {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_optional_trait_object)]
|
#[diag(ast_passes_optional_trait_object)]
|
||||||
pub struct OptionalTraitObject {
|
pub(crate) struct OptionalTraitObject {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_const_bound_trait_object)]
|
#[diag(ast_passes_const_bound_trait_object)]
|
||||||
pub struct ConstBoundTraitObject {
|
pub(crate) struct ConstBoundTraitObject {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
@ -604,7 +604,7 @@ pub struct ConstBoundTraitObject {
|
|||||||
// FIXME(effects): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
|
// FIXME(effects): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_tilde_const_disallowed)]
|
#[diag(ast_passes_tilde_const_disallowed)]
|
||||||
pub struct TildeConstDisallowed {
|
pub(crate) struct TildeConstDisallowed {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[subdiagnostic]
|
#[subdiagnostic]
|
||||||
@ -612,7 +612,7 @@ pub struct TildeConstDisallowed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic, Copy, Clone)]
|
#[derive(Subdiagnostic, Copy, Clone)]
|
||||||
pub enum TildeConstReason {
|
pub(crate) enum TildeConstReason {
|
||||||
#[note(ast_passes_closure)]
|
#[note(ast_passes_closure)]
|
||||||
Closure,
|
Closure,
|
||||||
#[note(ast_passes_function)]
|
#[note(ast_passes_function)]
|
||||||
@ -658,7 +658,7 @@ pub enum TildeConstReason {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_const_and_async)]
|
#[diag(ast_passes_const_and_async)]
|
||||||
pub struct ConstAndAsync {
|
pub(crate) struct ConstAndAsync {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub spans: Vec<Span>,
|
pub spans: Vec<Span>,
|
||||||
#[label(ast_passes_const)]
|
#[label(ast_passes_const)]
|
||||||
@ -671,7 +671,7 @@ pub struct ConstAndAsync {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_const_and_c_variadic)]
|
#[diag(ast_passes_const_and_c_variadic)]
|
||||||
pub struct ConstAndCVariadic {
|
pub(crate) struct ConstAndCVariadic {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub spans: Vec<Span>,
|
pub spans: Vec<Span>,
|
||||||
#[label(ast_passes_const)]
|
#[label(ast_passes_const)]
|
||||||
@ -683,7 +683,7 @@ pub struct ConstAndCVariadic {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_pattern_in_foreign, code = E0130)]
|
#[diag(ast_passes_pattern_in_foreign, code = E0130)]
|
||||||
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
|
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
|
||||||
pub struct PatternInForeign {
|
pub(crate) struct PatternInForeign {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -692,7 +692,7 @@ pub struct PatternInForeign {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_pattern_in_bodiless, code = E0642)]
|
#[diag(ast_passes_pattern_in_bodiless, code = E0642)]
|
||||||
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
|
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
|
||||||
pub struct PatternInBodiless {
|
pub(crate) struct PatternInBodiless {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -701,7 +701,7 @@ pub struct PatternInBodiless {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_equality_in_where)]
|
#[diag(ast_passes_equality_in_where)]
|
||||||
#[note]
|
#[note]
|
||||||
pub struct EqualityInWhere {
|
pub(crate) struct EqualityInWhere {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -718,7 +718,7 @@ pub struct EqualityInWhere {
|
|||||||
style = "verbose",
|
style = "verbose",
|
||||||
applicability = "maybe-incorrect"
|
applicability = "maybe-incorrect"
|
||||||
)]
|
)]
|
||||||
pub struct AssociatedSuggestion {
|
pub(crate) struct AssociatedSuggestion {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub ident: Ident,
|
pub ident: Ident,
|
||||||
@ -728,7 +728,7 @@ pub struct AssociatedSuggestion {
|
|||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
|
#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
|
||||||
pub struct AssociatedSuggestion2 {
|
pub(crate) struct AssociatedSuggestion2 {
|
||||||
#[suggestion_part(code = "{args}")]
|
#[suggestion_part(code = "{args}")]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub args: String,
|
pub args: String,
|
||||||
@ -740,14 +740,14 @@ pub struct AssociatedSuggestion2 {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_stability_outside_std, code = E0734)]
|
#[diag(ast_passes_stability_outside_std, code = E0734)]
|
||||||
pub struct StabilityOutsideStd {
|
pub(crate) struct StabilityOutsideStd {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_feature_on_non_nightly, code = E0554)]
|
#[diag(ast_passes_feature_on_non_nightly, code = E0554)]
|
||||||
pub struct FeatureOnNonNightly {
|
pub(crate) struct FeatureOnNonNightly {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub channel: &'static str,
|
pub channel: &'static str,
|
||||||
@ -757,7 +757,7 @@ pub struct FeatureOnNonNightly {
|
|||||||
pub sugg: Option<Span>,
|
pub sugg: Option<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StableFeature {
|
pub(crate) struct StableFeature {
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
pub since: Symbol,
|
pub since: Symbol,
|
||||||
}
|
}
|
||||||
@ -777,7 +777,7 @@ impl Subdiagnostic for StableFeature {
|
|||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_incompatible_features)]
|
#[diag(ast_passes_incompatible_features)]
|
||||||
#[help]
|
#[help]
|
||||||
pub struct IncompatibleFeatures {
|
pub(crate) struct IncompatibleFeatures {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub spans: Vec<Span>,
|
pub spans: Vec<Span>,
|
||||||
pub f1: Symbol,
|
pub f1: Symbol,
|
||||||
@ -786,7 +786,7 @@ pub struct IncompatibleFeatures {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_show_span)]
|
#[diag(ast_passes_show_span)]
|
||||||
pub struct ShowSpan {
|
pub(crate) struct ShowSpan {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub msg: &'static str,
|
pub msg: &'static str,
|
||||||
@ -794,28 +794,28 @@ pub struct ShowSpan {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_negative_bound_not_supported)]
|
#[diag(ast_passes_negative_bound_not_supported)]
|
||||||
pub struct NegativeBoundUnsupported {
|
pub(crate) struct NegativeBoundUnsupported {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_constraint_on_negative_bound)]
|
#[diag(ast_passes_constraint_on_negative_bound)]
|
||||||
pub struct ConstraintOnNegativeBound {
|
pub(crate) struct ConstraintOnNegativeBound {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
|
#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
|
||||||
pub struct NegativeBoundWithParentheticalNotation {
|
pub(crate) struct NegativeBoundWithParentheticalNotation {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_invalid_unnamed_field_ty)]
|
#[diag(ast_passes_invalid_unnamed_field_ty)]
|
||||||
pub struct InvalidUnnamedFieldTy {
|
pub(crate) struct InvalidUnnamedFieldTy {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label]
|
#[label]
|
||||||
@ -824,7 +824,7 @@ pub struct InvalidUnnamedFieldTy {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_invalid_unnamed_field)]
|
#[diag(ast_passes_invalid_unnamed_field)]
|
||||||
pub struct InvalidUnnamedField {
|
pub(crate) struct InvalidUnnamedField {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[label]
|
#[label]
|
||||||
@ -833,7 +833,7 @@ pub struct InvalidUnnamedField {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_anon_struct_or_union_not_allowed)]
|
#[diag(ast_passes_anon_struct_or_union_not_allowed)]
|
||||||
pub struct AnonStructOrUnionNotAllowed {
|
pub(crate) struct AnonStructOrUnionNotAllowed {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
@ -842,7 +842,7 @@ pub struct AnonStructOrUnionNotAllowed {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_match_arm_with_no_body)]
|
#[diag(ast_passes_match_arm_with_no_body)]
|
||||||
pub struct MatchArmWithNoBody {
|
pub(crate) struct MatchArmWithNoBody {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
|
#[suggestion(code = " => todo!(),", applicability = "has-placeholders")]
|
||||||
@ -851,7 +851,7 @@ pub struct MatchArmWithNoBody {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_precise_capturing_not_allowed_here)]
|
#[diag(ast_passes_precise_capturing_not_allowed_here)]
|
||||||
pub struct PreciseCapturingNotAllowedHere {
|
pub(crate) struct PreciseCapturingNotAllowedHere {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub loc: &'static str,
|
pub loc: &'static str,
|
||||||
@ -859,7 +859,7 @@ pub struct PreciseCapturingNotAllowedHere {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(ast_passes_precise_capturing_duplicated)]
|
#[diag(ast_passes_precise_capturing_duplicated)]
|
||||||
pub struct DuplicatePreciseCapturing {
|
pub(crate) struct DuplicatePreciseCapturing {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
pub bound1: Span,
|
pub bound1: Span,
|
||||||
#[label]
|
#[label]
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#![feature(iter_is_partitioned)]
|
#![feature(iter_is_partitioned)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
pub mod ast_validation;
|
pub mod ast_validation;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
mod helpers;
|
mod helpers;
|
||||||
|
@ -89,7 +89,7 @@ impl Printer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Token {
|
impl Token {
|
||||||
pub fn is_hardbreak_tok(&self) -> bool {
|
pub(crate) fn is_hardbreak_tok(&self) -> bool {
|
||||||
*self == Printer::hardbreak_tok_offset(0)
|
*self == Printer::hardbreak_tok_offset(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,54 +11,54 @@ use std::ops::{Index, IndexMut};
|
|||||||
/// Holding a RingBuffer whose view is elements left..right gives the ability to
|
/// Holding a RingBuffer whose view is elements left..right gives the ability to
|
||||||
/// use Index and IndexMut to access elements i in the infinitely long queue for
|
/// use Index and IndexMut to access elements i in the infinitely long queue for
|
||||||
/// which left <= i < right.
|
/// which left <= i < right.
|
||||||
pub struct RingBuffer<T> {
|
pub(super) struct RingBuffer<T> {
|
||||||
data: VecDeque<T>,
|
data: VecDeque<T>,
|
||||||
// Abstract index of data[0] in the infinitely sized queue.
|
// Abstract index of data[0] in the infinitely sized queue.
|
||||||
offset: usize,
|
offset: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> RingBuffer<T> {
|
impl<T> RingBuffer<T> {
|
||||||
pub fn new() -> Self {
|
pub(super) fn new() -> Self {
|
||||||
RingBuffer { data: VecDeque::new(), offset: 0 }
|
RingBuffer { data: VecDeque::new(), offset: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub(super) fn is_empty(&self) -> bool {
|
||||||
self.data.is_empty()
|
self.data.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, value: T) -> usize {
|
pub(super) fn push(&mut self, value: T) -> usize {
|
||||||
let index = self.offset + self.data.len();
|
let index = self.offset + self.data.len();
|
||||||
self.data.push_back(value);
|
self.data.push_back(value);
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(&mut self) {
|
pub(super) fn clear(&mut self) {
|
||||||
self.data.clear();
|
self.data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index_of_first(&self) -> usize {
|
pub(super) fn index_of_first(&self) -> usize {
|
||||||
self.offset
|
self.offset
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn first(&self) -> Option<&T> {
|
pub(super) fn first(&self) -> Option<&T> {
|
||||||
self.data.front()
|
self.data.front()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn first_mut(&mut self) -> Option<&mut T> {
|
pub(super) fn first_mut(&mut self) -> Option<&mut T> {
|
||||||
self.data.front_mut()
|
self.data.front_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pop_first(&mut self) -> Option<T> {
|
pub(super) fn pop_first(&mut self) -> Option<T> {
|
||||||
let first = self.data.pop_front()?;
|
let first = self.data.pop_front()?;
|
||||||
self.offset += 1;
|
self.offset += 1;
|
||||||
Some(first)
|
Some(first)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn last(&self) -> Option<&T> {
|
pub(super) fn last(&self) -> Option<&T> {
|
||||||
self.data.back()
|
self.data.back()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn last_mut(&mut self) -> Option<&mut T> {
|
pub(super) fn last_mut(&mut self) -> Option<&mut T> {
|
||||||
self.data.back_mut()
|
self.data.back_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,13 +110,13 @@ impl Default for FixupContext {
|
|||||||
impl FixupContext {
|
impl FixupContext {
|
||||||
/// Create the initial fixup for printing an expression in statement
|
/// Create the initial fixup for printing an expression in statement
|
||||||
/// position.
|
/// position.
|
||||||
pub fn new_stmt() -> Self {
|
pub(crate) fn new_stmt() -> Self {
|
||||||
FixupContext { stmt: true, ..FixupContext::default() }
|
FixupContext { stmt: true, ..FixupContext::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create the initial fixup for printing an expression as the right-hand
|
/// Create the initial fixup for printing an expression as the right-hand
|
||||||
/// side of a match arm.
|
/// side of a match arm.
|
||||||
pub fn new_match_arm() -> Self {
|
pub(crate) fn new_match_arm() -> Self {
|
||||||
FixupContext { match_arm: true, ..FixupContext::default() }
|
FixupContext { match_arm: true, ..FixupContext::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ impl FixupContext {
|
|||||||
/// of an `if` or `while`. There are a few other positions which are
|
/// of an `if` or `while`. There are a few other positions which are
|
||||||
/// grammatically equivalent and also use this, such as the iterator
|
/// grammatically equivalent and also use this, such as the iterator
|
||||||
/// expression in `for` and the scrutinee in `match`.
|
/// expression in `for` and the scrutinee in `match`.
|
||||||
pub fn new_cond() -> Self {
|
pub(crate) fn new_cond() -> Self {
|
||||||
FixupContext { parenthesize_exterior_struct_lit: true, ..FixupContext::default() }
|
FixupContext { parenthesize_exterior_struct_lit: true, ..FixupContext::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ impl FixupContext {
|
|||||||
///
|
///
|
||||||
/// Not every expression has a leftmost subexpression. For example neither
|
/// Not every expression has a leftmost subexpression. For example neither
|
||||||
/// `-$a` nor `[$a]` have one.
|
/// `-$a` nor `[$a]` have one.
|
||||||
pub fn leftmost_subexpression(self) -> Self {
|
pub(crate) fn leftmost_subexpression(self) -> Self {
|
||||||
FixupContext {
|
FixupContext {
|
||||||
stmt: false,
|
stmt: false,
|
||||||
leftmost_subexpression_in_stmt: self.stmt || self.leftmost_subexpression_in_stmt,
|
leftmost_subexpression_in_stmt: self.stmt || self.leftmost_subexpression_in_stmt,
|
||||||
@ -158,7 +158,7 @@ impl FixupContext {
|
|||||||
/// current expression, and is not surrounded by a paren/bracket/brace. For
|
/// current expression, and is not surrounded by a paren/bracket/brace. For
|
||||||
/// example the `$b` in `$a + $b` and `-$b`, but not the one in `[$b]` or
|
/// example the `$b` in `$a + $b` and `-$b`, but not the one in `[$b]` or
|
||||||
/// `$a.f($b)`.
|
/// `$a.f($b)`.
|
||||||
pub fn subsequent_subexpression(self) -> Self {
|
pub(crate) fn subsequent_subexpression(self) -> Self {
|
||||||
FixupContext {
|
FixupContext {
|
||||||
stmt: false,
|
stmt: false,
|
||||||
leftmost_subexpression_in_stmt: false,
|
leftmost_subexpression_in_stmt: false,
|
||||||
@ -173,7 +173,7 @@ impl FixupContext {
|
|||||||
///
|
///
|
||||||
/// The documentation on `FixupContext::leftmost_subexpression_in_stmt` has
|
/// The documentation on `FixupContext::leftmost_subexpression_in_stmt` has
|
||||||
/// examples.
|
/// examples.
|
||||||
pub fn would_cause_statement_boundary(self, expr: &Expr) -> bool {
|
pub(crate) fn would_cause_statement_boundary(self, expr: &Expr) -> bool {
|
||||||
(self.leftmost_subexpression_in_stmt && !classify::expr_requires_semi_to_be_stmt(expr))
|
(self.leftmost_subexpression_in_stmt && !classify::expr_requires_semi_to_be_stmt(expr))
|
||||||
|| (self.leftmost_subexpression_in_match_arm && classify::expr_is_complete(expr))
|
|| (self.leftmost_subexpression_in_match_arm && classify::expr_is_complete(expr))
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ impl FixupContext {
|
|||||||
///
|
///
|
||||||
/// - `true && false`, because otherwise this would be misinterpreted as a
|
/// - `true && false`, because otherwise this would be misinterpreted as a
|
||||||
/// "let chain".
|
/// "let chain".
|
||||||
pub fn needs_par_as_let_scrutinee(self, expr: &Expr) -> bool {
|
pub(crate) fn needs_par_as_let_scrutinee(self, expr: &Expr) -> bool {
|
||||||
self.parenthesize_exterior_struct_lit && parser::contains_exterior_struct_lit(expr)
|
self.parenthesize_exterior_struct_lit && parser::contains_exterior_struct_lit(expr)
|
||||||
|| parser::needs_par_as_let_scrutinee(expr.precedence().order())
|
|| parser::needs_par_as_let_scrutinee(expr.precedence().order())
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
mod builtin;
|
mod builtin;
|
||||||
|
@ -127,7 +127,7 @@ pub(crate) enum InvalidIssueStringCause {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl InvalidIssueStringCause {
|
impl InvalidIssueStringCause {
|
||||||
pub fn from_int_error_kind(span: Span, kind: &IntErrorKind) -> Option<Self> {
|
pub(crate) fn from_int_error_kind(span: Span, kind: &IntErrorKind) -> Option<Self> {
|
||||||
match kind {
|
match kind {
|
||||||
IntErrorKind::Empty => Some(Self::Empty { span }),
|
IntErrorKind::Empty => Some(Self::Empty { span }),
|
||||||
IntErrorKind::InvalidDigit => Some(Self::InvalidDigit { span }),
|
IntErrorKind::InvalidDigit => Some(Self::InvalidDigit { span }),
|
||||||
@ -303,7 +303,7 @@ pub(crate) enum IncorrectReprFormatGenericCause<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IncorrectReprFormatGenericCause<'a> {
|
impl<'a> IncorrectReprFormatGenericCause<'a> {
|
||||||
pub fn from_lit_kind(span: Span, kind: &ast::LitKind, name: &'a str) -> Option<Self> {
|
pub(crate) fn from_lit_kind(span: Span, kind: &ast::LitKind, name: &'a str) -> Option<Self> {
|
||||||
match kind {
|
match kind {
|
||||||
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
|
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
|
||||||
Some(Self::Int { span, name, int: int.get() })
|
Some(Self::Int { span, name, int: int.get() })
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
|
// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
mod data {
|
mod data {
|
||||||
|
@ -9,7 +9,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
|
|||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
||||||
pub fn dcx(&self) -> DiagCtxtHandle<'infcx> {
|
pub(crate) fn dcx(&self) -> DiagCtxtHandle<'infcx> {
|
||||||
self.infcx.dcx()
|
self.infcx.dcx()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, Results, ResultsVisi
|
|||||||
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
|
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
|
||||||
|
|
||||||
/// The results of the dataflow analyses used by the borrow checker.
|
/// The results of the dataflow analyses used by the borrow checker.
|
||||||
pub struct BorrowckResults<'a, 'mir, 'tcx> {
|
pub(crate) struct BorrowckResults<'a, 'mir, 'tcx> {
|
||||||
pub(crate) borrows: Results<'tcx, Borrows<'a, 'mir, 'tcx>>,
|
pub(crate) borrows: Results<'tcx, Borrows<'a, 'mir, 'tcx>>,
|
||||||
pub(crate) uninits: Results<'tcx, MaybeUninitializedPlaces<'a, 'mir, 'tcx>>,
|
pub(crate) uninits: Results<'tcx, MaybeUninitializedPlaces<'a, 'mir, 'tcx>>,
|
||||||
pub(crate) ever_inits: Results<'tcx, EverInitializedPlaces<'a, 'mir, 'tcx>>,
|
pub(crate) ever_inits: Results<'tcx, EverInitializedPlaces<'a, 'mir, 'tcx>>,
|
||||||
@ -22,7 +22,7 @@ pub struct BorrowckResults<'a, 'mir, 'tcx> {
|
|||||||
|
|
||||||
/// The transient state of the dataflow analyses used by the borrow checker.
|
/// The transient state of the dataflow analyses used by the borrow checker.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BorrowckFlowState<'a, 'mir, 'tcx> {
|
pub(crate) struct BorrowckFlowState<'a, 'mir, 'tcx> {
|
||||||
pub(crate) borrows: <Borrows<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
pub(crate) borrows: <Borrows<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
||||||
pub(crate) uninits: <MaybeUninitializedPlaces<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
pub(crate) uninits: <MaybeUninitializedPlaces<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
||||||
pub(crate) ever_inits: <EverInitializedPlaces<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
pub(crate) ever_inits: <EverInitializedPlaces<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain,
|
||||||
|
@ -4,13 +4,13 @@ use rustc_middle::mir::visit::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone)]
|
#[derive(Eq, PartialEq, Clone)]
|
||||||
pub enum DefUse {
|
pub(crate) enum DefUse {
|
||||||
Def,
|
Def,
|
||||||
Use,
|
Use,
|
||||||
Drop,
|
Drop,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn categorize(context: PlaceContext) -> Option<DefUse> {
|
pub(crate) fn categorize(context: PlaceContext) -> Option<DefUse> {
|
||||||
match context {
|
match context {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// DEFS
|
// DEFS
|
||||||
|
@ -645,7 +645,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn suggest_reborrow(
|
pub(crate) fn suggest_reborrow(
|
||||||
&self,
|
&self,
|
||||||
err: &mut Diag<'infcx>,
|
err: &mut Diag<'infcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
@ -1891,10 +1891,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
|||||||
struct FindUselessClone<'tcx> {
|
struct FindUselessClone<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
typeck_results: &'tcx ty::TypeckResults<'tcx>,
|
typeck_results: &'tcx ty::TypeckResults<'tcx>,
|
||||||
pub clones: Vec<&'tcx hir::Expr<'tcx>>,
|
clones: Vec<&'tcx hir::Expr<'tcx>>,
|
||||||
}
|
}
|
||||||
impl<'tcx> FindUselessClone<'tcx> {
|
impl<'tcx> FindUselessClone<'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
|
fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
|
||||||
Self { tcx, typeck_results: tcx.typeck(def_id), clones: vec![] }
|
Self { tcx, typeck_results: tcx.typeck(def_id), clones: vec![] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1916,7 +1916,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
|||||||
let body = hir.body(body_id).value;
|
let body = hir.body(body_id).value;
|
||||||
expr_finder.visit_expr(body);
|
expr_finder.visit_expr(body);
|
||||||
|
|
||||||
pub struct Holds<'tcx> {
|
struct Holds<'tcx> {
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ pub(crate) use region_name::{RegionName, RegionNameSource};
|
|||||||
pub(crate) use rustc_middle::util::CallKind;
|
pub(crate) use rustc_middle::util::CallKind;
|
||||||
|
|
||||||
pub(super) struct DescribePlaceOpt {
|
pub(super) struct DescribePlaceOpt {
|
||||||
pub including_downcast: bool,
|
including_downcast: bool,
|
||||||
|
|
||||||
/// Enable/Disable tuple fields.
|
/// Enable/Disable tuple fields.
|
||||||
/// For example `x` tuple. if it's `true` `x.0`. Otherwise `x`
|
/// For example `x` tuple. if it's `true` `x.0`. Otherwise `x`
|
||||||
pub including_tuple_field: bool,
|
including_tuple_field: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct IncludingTupleField(pub(super) bool);
|
pub(super) struct IncludingTupleField(pub(super) bool);
|
||||||
|
@ -16,7 +16,7 @@ use crate::prefixes::PrefixSet;
|
|||||||
use crate::MirBorrowckCtxt;
|
use crate::MirBorrowckCtxt;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum IllegalMoveOriginKind<'tcx> {
|
pub(crate) enum IllegalMoveOriginKind<'tcx> {
|
||||||
/// Illegal move due to attempt to move from behind a reference.
|
/// Illegal move due to attempt to move from behind a reference.
|
||||||
BorrowedContent {
|
BorrowedContent {
|
||||||
/// The place the reference refers to: if erroneous code was trying to
|
/// The place the reference refers to: if erroneous code was trying to
|
||||||
|
@ -1374,7 +1374,7 @@ impl<'tcx> Visitor<'tcx> for BindingFinder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symbol>) -> bool {
|
fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symbol>) -> bool {
|
||||||
debug!("local_info: {:?}, ty.kind(): {:?}", local_decl.local_info, local_decl.ty.kind());
|
debug!("local_info: {:?}, ty.kind(): {:?}", local_decl.local_info, local_decl.ty.kind());
|
||||||
|
|
||||||
match *local_decl.local_info() {
|
match *local_decl.local_info() {
|
||||||
|
@ -31,7 +31,7 @@ enum SuggestedConstraint {
|
|||||||
///
|
///
|
||||||
/// Adds a help note suggesting adding a where clause with the needed constraints.
|
/// Adds a help note suggesting adding a where clause with the needed constraints.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct OutlivesSuggestionBuilder {
|
pub(crate) struct OutlivesSuggestionBuilder {
|
||||||
/// The list of outlives constraints that need to be added. Specifically, we map each free
|
/// The list of outlives constraints that need to be added. Specifically, we map each free
|
||||||
/// region to all other regions that it must outlive. I will use the shorthand `fr:
|
/// region to all other regions that it must outlive. I will use the shorthand `fr:
|
||||||
/// outlived_frs`. Not all of these regions will already have names necessarily. Some could be
|
/// outlived_frs`. Not all of these regions will already have names necessarily. Some could be
|
||||||
|
@ -72,22 +72,24 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
|
|||||||
pub(crate) struct RegionErrors<'tcx>(Vec<(RegionErrorKind<'tcx>, ErrorGuaranteed)>, TyCtxt<'tcx>);
|
pub(crate) struct RegionErrors<'tcx>(Vec<(RegionErrorKind<'tcx>, ErrorGuaranteed)>, TyCtxt<'tcx>);
|
||||||
|
|
||||||
impl<'tcx> RegionErrors<'tcx> {
|
impl<'tcx> RegionErrors<'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
|
pub(crate) fn new(tcx: TyCtxt<'tcx>) -> Self {
|
||||||
Self(vec![], tcx)
|
Self(vec![], tcx)
|
||||||
}
|
}
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
pub(crate) fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
||||||
let val = val.into();
|
let val = val.into();
|
||||||
let guar = self.1.sess.dcx().delayed_bug(format!("{val:?}"));
|
let guar = self.1.sess.dcx().delayed_bug(format!("{val:?}"));
|
||||||
self.0.push((val, guar));
|
self.0.push((val, guar));
|
||||||
}
|
}
|
||||||
pub fn is_empty(&self) -> bool {
|
pub(crate) fn is_empty(&self) -> bool {
|
||||||
self.0.is_empty()
|
self.0.is_empty()
|
||||||
}
|
}
|
||||||
pub fn into_iter(self) -> impl Iterator<Item = (RegionErrorKind<'tcx>, ErrorGuaranteed)> {
|
pub(crate) fn into_iter(
|
||||||
|
self,
|
||||||
|
) -> impl Iterator<Item = (RegionErrorKind<'tcx>, ErrorGuaranteed)> {
|
||||||
self.0.into_iter()
|
self.0.into_iter()
|
||||||
}
|
}
|
||||||
pub fn has_errors(&self) -> Option<ErrorGuaranteed> {
|
pub(crate) fn has_errors(&self) -> Option<ErrorGuaranteed> {
|
||||||
self.0.get(0).map(|x| x.1)
|
self.0.get(0).map(|x| x.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +143,7 @@ pub(crate) enum RegionErrorKind<'tcx> {
|
|||||||
|
|
||||||
/// Information about the various region constraints involved in a borrow checker error.
|
/// Information about the various region constraints involved in a borrow checker error.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ErrorConstraintInfo<'tcx> {
|
pub(crate) struct ErrorConstraintInfo<'tcx> {
|
||||||
// fr: outlived_fr
|
// fr: outlived_fr
|
||||||
pub(super) fr: RegionVid,
|
pub(super) fr: RegionVid,
|
||||||
pub(super) fr_is_local: bool,
|
pub(super) fr_is_local: bool,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -2444,7 +2445,7 @@ mod diags {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BorrowckDiags<'infcx, 'tcx> {
|
pub(crate) struct BorrowckDiags<'infcx, 'tcx> {
|
||||||
/// This field keeps track of move errors that are to be reported for given move indices.
|
/// This field keeps track of move errors that are to be reported for given move indices.
|
||||||
///
|
///
|
||||||
/// There are situations where many errors can be reported for a single move out (see
|
/// There are situations where many errors can be reported for a single move out (see
|
||||||
@ -2468,7 +2469,7 @@ mod diags {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'infcx, 'tcx> BorrowckDiags<'infcx, 'tcx> {
|
impl<'infcx, 'tcx> BorrowckDiags<'infcx, 'tcx> {
|
||||||
pub fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
BorrowckDiags {
|
BorrowckDiags {
|
||||||
buffered_move_errors: BTreeMap::new(),
|
buffered_move_errors: BTreeMap::new(),
|
||||||
buffered_mut_errors: Default::default(),
|
buffered_mut_errors: Default::default(),
|
||||||
@ -2476,25 +2477,25 @@ mod diags {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_error(&mut self, diag: Diag<'infcx>) {
|
pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) {
|
||||||
self.buffered_diags.push(BufferedDiag::Error(diag));
|
self.buffered_diags.push(BufferedDiag::Error(diag));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_non_error(&mut self, diag: Diag<'infcx, ()>) {
|
pub(crate) fn buffer_non_error(&mut self, diag: Diag<'infcx, ()>) {
|
||||||
self.buffered_diags.push(BufferedDiag::NonError(diag));
|
self.buffered_diags.push(BufferedDiag::NonError(diag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
||||||
pub fn buffer_error(&mut self, diag: Diag<'infcx>) {
|
pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) {
|
||||||
self.diags.buffer_error(diag);
|
self.diags.buffer_error(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_non_error(&mut self, diag: Diag<'infcx, ()>) {
|
pub(crate) fn buffer_non_error(&mut self, diag: Diag<'infcx, ()>) {
|
||||||
self.diags.buffer_non_error(diag);
|
self.diags.buffer_non_error(diag);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_move_error(
|
pub(crate) fn buffer_move_error(
|
||||||
&mut self,
|
&mut self,
|
||||||
move_out_indices: Vec<MoveOutIndex>,
|
move_out_indices: Vec<MoveOutIndex>,
|
||||||
place_and_err: (PlaceRef<'tcx>, Diag<'infcx>),
|
place_and_err: (PlaceRef<'tcx>, Diag<'infcx>),
|
||||||
@ -2510,16 +2511,19 @@ mod diags {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_buffered_mut_error(&mut self, span: Span) -> Option<(Diag<'infcx>, usize)> {
|
pub(crate) fn get_buffered_mut_error(
|
||||||
|
&mut self,
|
||||||
|
span: Span,
|
||||||
|
) -> Option<(Diag<'infcx>, usize)> {
|
||||||
// FIXME(#120456) - is `swap_remove` correct?
|
// FIXME(#120456) - is `swap_remove` correct?
|
||||||
self.diags.buffered_mut_errors.swap_remove(&span)
|
self.diags.buffered_mut_errors.swap_remove(&span)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_mut_error(&mut self, span: Span, diag: Diag<'infcx>, count: usize) {
|
pub(crate) fn buffer_mut_error(&mut self, span: Span, diag: Diag<'infcx>, count: usize) {
|
||||||
self.diags.buffered_mut_errors.insert(span, (diag, count));
|
self.diags.buffered_mut_errors.insert(span, (diag, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
|
pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
|
||||||
let mut res = None;
|
let mut res = None;
|
||||||
|
|
||||||
// Buffer any move errors that we collected and de-duplicated.
|
// Buffer any move errors that we collected and de-duplicated.
|
||||||
@ -2553,7 +2557,7 @@ mod diags {
|
|||||||
self.diags.buffered_diags.is_empty()
|
self.diags.buffered_diags.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_move_error(
|
pub(crate) fn has_move_error(
|
||||||
&self,
|
&self,
|
||||||
move_out_indices: &[MoveOutIndex],
|
move_out_indices: &[MoveOutIndex],
|
||||||
) -> Option<&(PlaceRef<'tcx>, Diag<'infcx>)> {
|
) -> Option<&(PlaceRef<'tcx>, Diag<'infcx>)> {
|
||||||
|
@ -8,7 +8,7 @@ use rustc_middle::mir::{PlaceRef, ProjectionElem};
|
|||||||
|
|
||||||
use super::MirBorrowckCtxt;
|
use super::MirBorrowckCtxt;
|
||||||
|
|
||||||
pub trait IsPrefixOf<'tcx> {
|
pub(crate) trait IsPrefixOf<'tcx> {
|
||||||
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool;
|
fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ mod graphviz;
|
|||||||
mod opaque_types;
|
mod opaque_types;
|
||||||
mod reverse_sccs;
|
mod reverse_sccs;
|
||||||
|
|
||||||
pub mod values;
|
pub(crate) mod values;
|
||||||
|
|
||||||
pub type ConstraintSccs = Sccs<RegionVid, ConstraintSccIndex, RegionTracker>;
|
pub(crate) type ConstraintSccs = Sccs<RegionVid, ConstraintSccIndex, RegionTracker>;
|
||||||
|
|
||||||
/// An annotation for region graph SCCs that tracks
|
/// An annotation for region graph SCCs that tracks
|
||||||
/// the values of its elements.
|
/// the values of its elements.
|
||||||
@ -226,7 +226,7 @@ pub(crate) struct AppliedMemberConstraint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RegionDefinition<'tcx> {
|
pub(crate) struct RegionDefinition<'tcx> {
|
||||||
/// What kind of variable is this -- a free region? existential
|
/// What kind of variable is this -- a free region? existential
|
||||||
/// variable? etc. (See the `NllRegionVariableOrigin` for more
|
/// variable? etc. (See the `NllRegionVariableOrigin` for more
|
||||||
/// info.)
|
/// info.)
|
||||||
@ -288,7 +288,7 @@ pub(crate) enum Cause {
|
|||||||
/// `InferCtxt::process_registered_region_obligations` and
|
/// `InferCtxt::process_registered_region_obligations` and
|
||||||
/// `InferCtxt::type_must_outlive` in `rustc_infer::infer::InferCtxt`.
|
/// `InferCtxt::type_must_outlive` in `rustc_infer::infer::InferCtxt`.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct TypeTest<'tcx> {
|
pub(crate) struct TypeTest<'tcx> {
|
||||||
/// The type `T` that must outlive the region.
|
/// The type `T` that must outlive the region.
|
||||||
pub generic_kind: GenericKind<'tcx>,
|
pub generic_kind: GenericKind<'tcx>,
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ enum Trace<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum ExtraConstraintInfo {
|
pub(crate) enum ExtraConstraintInfo {
|
||||||
PlaceholderFromPredicate(Span),
|
PlaceholderFromPredicate(Span),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2259,7 +2259,7 @@ impl<'tcx> RegionDefinition<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct BlameConstraint<'tcx> {
|
pub(crate) struct BlameConstraint<'tcx> {
|
||||||
pub category: ConstraintCategory<'tcx>,
|
pub category: ConstraintCategory<'tcx>,
|
||||||
pub from_closure: bool,
|
pub from_closure: bool,
|
||||||
pub cause: ObligationCause<'tcx>,
|
pub cause: ObligationCause<'tcx>,
|
||||||
|
@ -473,20 +473,20 @@ struct LazyOpaqueTyEnv<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LazyOpaqueTyEnv<'tcx> {
|
impl<'tcx> LazyOpaqueTyEnv<'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
|
fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
|
||||||
Self { tcx, def_id, canonical_args: std::cell::OnceCell::new() }
|
Self { tcx, def_id, canonical_args: std::cell::OnceCell::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn param_equal_static(&self, param_index: usize) -> bool {
|
fn param_equal_static(&self, param_index: usize) -> bool {
|
||||||
self.get_canonical_args()[param_index].expect_region().is_static()
|
self.get_canonical_args()[param_index].expect_region().is_static()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn params_equal(&self, param1: usize, param2: usize) -> bool {
|
fn params_equal(&self, param1: usize, param2: usize) -> bool {
|
||||||
let canonical_args = self.get_canonical_args();
|
let canonical_args = self.get_canonical_args();
|
||||||
canonical_args[param1] == canonical_args[param2]
|
canonical_args[param1] == canonical_args[param2]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn param_is_error(&self, param_index: usize) -> Result<(), ErrorGuaranteed> {
|
fn param_is_error(&self, param_index: usize) -> Result<(), ErrorGuaranteed> {
|
||||||
self.get_canonical_args()[param_index].error_reported()
|
self.get_canonical_args()[param_index].error_reported()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ macro_rules! span_mirbug_and_err {
|
|||||||
|
|
||||||
mod canonical;
|
mod canonical;
|
||||||
mod constraint_conversion;
|
mod constraint_conversion;
|
||||||
pub mod free_region_relations;
|
pub(crate) mod free_region_relations;
|
||||||
mod input_output;
|
mod input_output;
|
||||||
pub(crate) mod liveness;
|
pub(crate) mod liveness;
|
||||||
mod relate_tys;
|
mod relate_tys;
|
||||||
|
@ -57,7 +57,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NllTypeRelating<'me, 'bccx, 'tcx> {
|
struct NllTypeRelating<'me, 'bccx, 'tcx> {
|
||||||
type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
|
type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
|
||||||
|
|
||||||
/// Where (and why) is this relation taking place?
|
/// Where (and why) is this relation taking place?
|
||||||
@ -82,7 +82,7 @@ pub struct NllTypeRelating<'me, 'bccx, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
|
impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
|
||||||
pub fn new(
|
fn new(
|
||||||
type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
|
type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
|
||||||
locations: Locations,
|
locations: Locations,
|
||||||
category: ConstraintCategory<'tcx>,
|
category: ConstraintCategory<'tcx>,
|
||||||
|
@ -39,7 +39,7 @@ use crate::renumber::RegionCtxt;
|
|||||||
use crate::BorrowckInferCtxt;
|
use crate::BorrowckInferCtxt;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct UniversalRegions<'tcx> {
|
pub(crate) struct UniversalRegions<'tcx> {
|
||||||
indices: UniversalRegionIndices<'tcx>,
|
indices: UniversalRegionIndices<'tcx>,
|
||||||
|
|
||||||
/// The vid assigned to `'static`
|
/// The vid assigned to `'static`
|
||||||
@ -95,7 +95,7 @@ pub struct UniversalRegions<'tcx> {
|
|||||||
/// regions appear free in the defining type and late-bound regions
|
/// regions appear free in the defining type and late-bound regions
|
||||||
/// appear bound in the signature.
|
/// appear bound in the signature.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum DefiningTy<'tcx> {
|
pub(crate) enum DefiningTy<'tcx> {
|
||||||
/// The MIR is a closure. The signature is found via
|
/// The MIR is a closure. The signature is found via
|
||||||
/// `ClosureArgs::closure_sig_ty`.
|
/// `ClosureArgs::closure_sig_ty`.
|
||||||
Closure(DefId, GenericArgsRef<'tcx>),
|
Closure(DefId, GenericArgsRef<'tcx>),
|
||||||
@ -131,7 +131,7 @@ impl<'tcx> DefiningTy<'tcx> {
|
|||||||
/// not a closure or coroutine, there are no upvars, and hence it
|
/// not a closure or coroutine, there are no upvars, and hence it
|
||||||
/// will be an empty list. The order of types in this list will
|
/// will be an empty list. The order of types in this list will
|
||||||
/// match up with the upvar order in the HIR, typesystem, and MIR.
|
/// match up with the upvar order in the HIR, typesystem, and MIR.
|
||||||
pub fn upvar_tys(self) -> &'tcx ty::List<Ty<'tcx>> {
|
pub(crate) fn upvar_tys(self) -> &'tcx ty::List<Ty<'tcx>> {
|
||||||
match self {
|
match self {
|
||||||
DefiningTy::Closure(_, args) => args.as_closure().upvar_tys(),
|
DefiningTy::Closure(_, args) => args.as_closure().upvar_tys(),
|
||||||
DefiningTy::CoroutineClosure(_, args) => args.as_coroutine_closure().upvar_tys(),
|
DefiningTy::CoroutineClosure(_, args) => args.as_coroutine_closure().upvar_tys(),
|
||||||
@ -145,7 +145,7 @@ impl<'tcx> DefiningTy<'tcx> {
|
|||||||
/// Number of implicit inputs -- notably the "environment"
|
/// Number of implicit inputs -- notably the "environment"
|
||||||
/// parameter for closures -- that appear in MIR but not in the
|
/// parameter for closures -- that appear in MIR but not in the
|
||||||
/// user's code.
|
/// user's code.
|
||||||
pub fn implicit_inputs(self) -> usize {
|
pub(crate) fn implicit_inputs(self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
DefiningTy::Closure(..)
|
DefiningTy::Closure(..)
|
||||||
| DefiningTy::CoroutineClosure(..)
|
| DefiningTy::CoroutineClosure(..)
|
||||||
@ -154,15 +154,15 @@ impl<'tcx> DefiningTy<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_fn_def(&self) -> bool {
|
pub(crate) fn is_fn_def(&self) -> bool {
|
||||||
matches!(*self, DefiningTy::FnDef(..))
|
matches!(*self, DefiningTy::FnDef(..))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_const(&self) -> bool {
|
pub(crate) fn is_const(&self) -> bool {
|
||||||
matches!(*self, DefiningTy::Const(..) | DefiningTy::InlineConst(..))
|
matches!(*self, DefiningTy::Const(..) | DefiningTy::InlineConst(..))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn def_id(&self) -> DefId {
|
pub(crate) fn def_id(&self) -> DefId {
|
||||||
match *self {
|
match *self {
|
||||||
DefiningTy::Closure(def_id, ..)
|
DefiningTy::Closure(def_id, ..)
|
||||||
| DefiningTy::CoroutineClosure(def_id, ..)
|
| DefiningTy::CoroutineClosure(def_id, ..)
|
||||||
@ -196,7 +196,7 @@ struct UniversalRegionIndices<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum RegionClassification {
|
pub(crate) enum RegionClassification {
|
||||||
/// A **global** region is one that can be named from
|
/// A **global** region is one that can be named from
|
||||||
/// anywhere. There is only one, `'static`.
|
/// anywhere. There is only one, `'static`.
|
||||||
Global,
|
Global,
|
||||||
@ -246,7 +246,7 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
/// MIR -- that is, all the regions that appear in the function's
|
/// MIR -- that is, all the regions that appear in the function's
|
||||||
/// signature. This will also compute the relationships that are
|
/// signature. This will also compute the relationships that are
|
||||||
/// known between those regions.
|
/// known between those regions.
|
||||||
pub fn new(
|
pub(crate) fn new(
|
||||||
infcx: &BorrowckInferCtxt<'tcx>,
|
infcx: &BorrowckInferCtxt<'tcx>,
|
||||||
mir_def: LocalDefId,
|
mir_def: LocalDefId,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
@ -263,7 +263,7 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
/// if the `ClosureRegionRequirements` contains something like
|
/// if the `ClosureRegionRequirements` contains something like
|
||||||
/// `'1: '2`, then the caller would impose the constraint that
|
/// `'1: '2`, then the caller would impose the constraint that
|
||||||
/// `V[1]: V[2]`.
|
/// `V[1]: V[2]`.
|
||||||
pub fn closure_mapping(
|
pub(crate) fn closure_mapping(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
closure_args: GenericArgsRef<'tcx>,
|
closure_args: GenericArgsRef<'tcx>,
|
||||||
expected_num_vars: usize,
|
expected_num_vars: usize,
|
||||||
@ -289,13 +289,13 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if `r` is a member of this set of universal regions.
|
/// Returns `true` if `r` is a member of this set of universal regions.
|
||||||
pub fn is_universal_region(&self, r: RegionVid) -> bool {
|
pub(crate) fn is_universal_region(&self, r: RegionVid) -> bool {
|
||||||
(FIRST_GLOBAL_INDEX..self.num_universals).contains(&r.index())
|
(FIRST_GLOBAL_INDEX..self.num_universals).contains(&r.index())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Classifies `r` as a universal region, returning `None` if this
|
/// Classifies `r` as a universal region, returning `None` if this
|
||||||
/// is not a member of this set of universal regions.
|
/// is not a member of this set of universal regions.
|
||||||
pub fn region_classification(&self, r: RegionVid) -> Option<RegionClassification> {
|
pub(crate) fn region_classification(&self, r: RegionVid) -> Option<RegionClassification> {
|
||||||
let index = r.index();
|
let index = r.index();
|
||||||
if (FIRST_GLOBAL_INDEX..self.first_extern_index).contains(&index) {
|
if (FIRST_GLOBAL_INDEX..self.first_extern_index).contains(&index) {
|
||||||
Some(RegionClassification::Global)
|
Some(RegionClassification::Global)
|
||||||
@ -310,17 +310,17 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
|
|
||||||
/// Returns an iterator over all the RegionVids corresponding to
|
/// Returns an iterator over all the RegionVids corresponding to
|
||||||
/// universally quantified free regions.
|
/// universally quantified free regions.
|
||||||
pub fn universal_regions(&self) -> impl Iterator<Item = RegionVid> {
|
pub(crate) fn universal_regions(&self) -> impl Iterator<Item = RegionVid> {
|
||||||
(FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize)
|
(FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if `r` is classified as a local region.
|
/// Returns `true` if `r` is classified as a local region.
|
||||||
pub fn is_local_free_region(&self, r: RegionVid) -> bool {
|
pub(crate) fn is_local_free_region(&self, r: RegionVid) -> bool {
|
||||||
self.region_classification(r) == Some(RegionClassification::Local)
|
self.region_classification(r) == Some(RegionClassification::Local)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of universal regions created in any category.
|
/// Returns the number of universal regions created in any category.
|
||||||
pub fn len(&self) -> usize {
|
pub(crate) fn len(&self) -> usize {
|
||||||
self.num_universals
|
self.num_universals
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,19 +329,19 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
/// closure type (versus those bound in the closure
|
/// closure type (versus those bound in the closure
|
||||||
/// signature). They are therefore the regions between which the
|
/// signature). They are therefore the regions between which the
|
||||||
/// closure may impose constraints that its creator must verify.
|
/// closure may impose constraints that its creator must verify.
|
||||||
pub fn num_global_and_external_regions(&self) -> usize {
|
pub(crate) fn num_global_and_external_regions(&self) -> usize {
|
||||||
self.first_local_index
|
self.first_local_index
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets an iterator over all the early-bound regions that have names.
|
/// Gets an iterator over all the early-bound regions that have names.
|
||||||
pub fn named_universal_regions<'s>(
|
pub(crate) fn named_universal_regions<'s>(
|
||||||
&'s self,
|
&'s self,
|
||||||
) -> impl Iterator<Item = (ty::Region<'tcx>, ty::RegionVid)> + 's {
|
) -> impl Iterator<Item = (ty::Region<'tcx>, ty::RegionVid)> + 's {
|
||||||
self.indices.indices.iter().map(|(&r, &v)| (r, v))
|
self.indices.indices.iter().map(|(&r, &v)| (r, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See `UniversalRegionIndices::to_region_vid`.
|
/// See `UniversalRegionIndices::to_region_vid`.
|
||||||
pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
|
pub(crate) fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
|
||||||
self.indices.to_region_vid(r)
|
self.indices.to_region_vid(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tainted_by_errors(&self) -> Option<ErrorGuaranteed> {
|
pub(crate) fn tainted_by_errors(&self) -> Option<ErrorGuaranteed> {
|
||||||
self.indices.tainted_by_errors.get()
|
self.indices.tainted_by_errors.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -880,7 +880,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
|
|||||||
/// reference those regions from the `ParamEnv`. It is also used
|
/// reference those regions from the `ParamEnv`. It is also used
|
||||||
/// during initialization. Relies on the `indices` map having been
|
/// during initialization. Relies on the `indices` map having been
|
||||||
/// fully initialized.
|
/// fully initialized.
|
||||||
pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
|
fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
|
||||||
if let ty::ReVar(..) = *r {
|
if let ty::ReVar(..) = *r {
|
||||||
r.as_var()
|
r.as_var()
|
||||||
} else if let ty::ReError(guar) = *r {
|
} else if let ty::ReError(guar) = *r {
|
||||||
@ -899,7 +899,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
|
|||||||
|
|
||||||
/// Replaces all free regions in `value` with region vids, as
|
/// Replaces all free regions in `value` with region vids, as
|
||||||
/// returned by `to_region_vid`.
|
/// returned by `to_region_vid`.
|
||||||
pub fn fold_to_region_vids<T>(&self, tcx: TyCtxt<'tcx>, value: T) -> T
|
fn fold_to_region_vids<T>(&self, tcx: TyCtxt<'tcx>, value: T) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
||||||
use rustc_middle::mir::{Body, Local, Location};
|
use rustc_middle::mir::{Body, Local, Location};
|
||||||
|
|
||||||
pub trait FindAssignments {
|
pub(crate) trait FindAssignments {
|
||||||
// Finds all statements that assign directly to local (i.e., X = ...)
|
// Finds all statements that assign directly to local (i.e., X = ...)
|
||||||
// and returns their locations.
|
// and returns their locations.
|
||||||
fn find_assignments(&self, local: Local) -> Vec<Location>;
|
fn find_assignments(&self, local: Local) -> Vec<Location>;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
mod collect_writes;
|
mod collect_writes;
|
||||||
|
|
||||||
pub use collect_writes::FindAssignments;
|
pub(crate) use collect_writes::FindAssignments;
|
||||||
|
@ -351,15 +351,15 @@ struct TypeParameter {
|
|||||||
pub(crate) struct BlockOrExpr(ThinVec<ast::Stmt>, Option<P<Expr>>);
|
pub(crate) struct BlockOrExpr(ThinVec<ast::Stmt>, Option<P<Expr>>);
|
||||||
|
|
||||||
impl BlockOrExpr {
|
impl BlockOrExpr {
|
||||||
pub fn new_stmts(stmts: ThinVec<ast::Stmt>) -> BlockOrExpr {
|
pub(crate) fn new_stmts(stmts: ThinVec<ast::Stmt>) -> BlockOrExpr {
|
||||||
BlockOrExpr(stmts, None)
|
BlockOrExpr(stmts, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_expr(expr: P<Expr>) -> BlockOrExpr {
|
pub(crate) fn new_expr(expr: P<Expr>) -> BlockOrExpr {
|
||||||
BlockOrExpr(ThinVec::new(), Some(expr))
|
BlockOrExpr(ThinVec::new(), Some(expr))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_mixed(stmts: ThinVec<ast::Stmt>, expr: Option<P<Expr>>) -> BlockOrExpr {
|
pub(crate) fn new_mixed(stmts: ThinVec<ast::Stmt>, expr: Option<P<Expr>>) -> BlockOrExpr {
|
||||||
BlockOrExpr(stmts, expr)
|
BlockOrExpr(stmts, expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,7 +461,7 @@ fn find_type_parameters(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TraitDef<'a> {
|
impl<'a> TraitDef<'a> {
|
||||||
pub fn expand(
|
pub(crate) fn expand(
|
||||||
self,
|
self,
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
mitem: &ast::MetaItem,
|
mitem: &ast::MetaItem,
|
||||||
@ -471,7 +471,7 @@ impl<'a> TraitDef<'a> {
|
|||||||
self.expand_ext(cx, mitem, item, push, false);
|
self.expand_ext(cx, mitem, item, push, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expand_ext(
|
pub(crate) fn expand_ext(
|
||||||
self,
|
self,
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
mitem: &ast::MetaItem,
|
mitem: &ast::MetaItem,
|
||||||
|
@ -27,17 +27,17 @@ pub(crate) enum PathKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Path {
|
impl Path {
|
||||||
pub fn new(path: Vec<Symbol>) -> Path {
|
pub(crate) fn new(path: Vec<Symbol>) -> Path {
|
||||||
Path::new_(path, Vec::new(), PathKind::Std)
|
Path::new_(path, Vec::new(), PathKind::Std)
|
||||||
}
|
}
|
||||||
pub fn new_local(path: Symbol) -> Path {
|
pub(crate) fn new_local(path: Symbol) -> Path {
|
||||||
Path::new_(vec![path], Vec::new(), PathKind::Local)
|
Path::new_(vec![path], Vec::new(), PathKind::Local)
|
||||||
}
|
}
|
||||||
pub fn new_(path: Vec<Symbol>, params: Vec<Box<Ty>>, kind: PathKind) -> Path {
|
pub(crate) fn new_(path: Vec<Symbol>, params: Vec<Box<Ty>>, kind: PathKind) -> Path {
|
||||||
Path { path, params, kind }
|
Path { path, params, kind }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_ty(
|
pub(crate) fn to_ty(
|
||||||
&self,
|
&self,
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
@ -46,7 +46,7 @@ impl Path {
|
|||||||
) -> P<ast::Ty> {
|
) -> P<ast::Ty> {
|
||||||
cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
|
cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
|
||||||
}
|
}
|
||||||
pub fn to_path(
|
pub(crate) fn to_path(
|
||||||
&self,
|
&self,
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
@ -87,7 +87,7 @@ pub(crate) fn self_ref() -> Ty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Ty {
|
impl Ty {
|
||||||
pub fn to_ty(
|
pub(crate) fn to_ty(
|
||||||
&self,
|
&self,
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
@ -108,7 +108,7 @@ impl Ty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_path(
|
pub(crate) fn to_path(
|
||||||
&self,
|
&self,
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
@ -167,10 +167,10 @@ pub(crate) struct Bounds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Bounds {
|
impl Bounds {
|
||||||
pub fn empty() -> Bounds {
|
pub(crate) fn empty() -> Bounds {
|
||||||
Bounds { bounds: Vec::new() }
|
Bounds { bounds: Vec::new() }
|
||||||
}
|
}
|
||||||
pub fn to_generics(
|
pub(crate) fn to_generics(
|
||||||
&self,
|
&self,
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -18,7 +18,7 @@ macro_rules! path {
|
|||||||
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }
|
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expand_deriving_smart_ptr(
|
pub(crate) fn expand_deriving_smart_ptr(
|
||||||
cx: &ExtCtxt<'_>,
|
cx: &ExtCtxt<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
_mitem: &MetaItem,
|
_mitem: &MetaItem,
|
||||||
|
@ -930,7 +930,7 @@ pub(crate) struct ExpectedItem<'a> {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(builtin_macros_naked_functions_testing_attribute, code = E0736)]
|
#[diag(builtin_macros_naked_functions_testing_attribute, code = E0736)]
|
||||||
pub struct NakedFunctionTestingAttribute {
|
pub(crate) struct NakedFunctionTestingAttribute {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label(builtin_macros_naked_attribute)]
|
#[label(builtin_macros_naked_attribute)]
|
||||||
pub naked_span: Span,
|
pub naked_span: Span,
|
||||||
|
@ -5,7 +5,7 @@ pub(crate) mod printf {
|
|||||||
|
|
||||||
/// Represents a single `printf`-style substitution.
|
/// Represents a single `printf`-style substitution.
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub enum Substitution<'a> {
|
pub(crate) enum Substitution<'a> {
|
||||||
/// A formatted output substitution with its internal byte offset.
|
/// A formatted output substitution with its internal byte offset.
|
||||||
Format(Format<'a>),
|
Format(Format<'a>),
|
||||||
/// A literal `%%` escape, with its start and end indices.
|
/// A literal `%%` escape, with its start and end indices.
|
||||||
@ -13,21 +13,21 @@ pub(crate) mod printf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Substitution<'a> {
|
impl<'a> Substitution<'a> {
|
||||||
pub fn as_str(&self) -> &str {
|
pub(crate) fn as_str(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Format(fmt) => fmt.span,
|
Substitution::Format(fmt) => fmt.span,
|
||||||
Substitution::Escape(_) => "%%",
|
Substitution::Escape(_) => "%%",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> InnerSpan {
|
pub(crate) fn position(&self) -> InnerSpan {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Format(fmt) => fmt.position,
|
Substitution::Format(fmt) => fmt.position,
|
||||||
&Substitution::Escape((start, end)) => InnerSpan::new(start, end),
|
&Substitution::Escape((start, end)) => InnerSpan::new(start, end),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(&mut self, start: usize, end: usize) {
|
pub(crate) fn set_position(&mut self, start: usize, end: usize) {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Format(fmt) => fmt.position = InnerSpan::new(start, end),
|
Substitution::Format(fmt) => fmt.position = InnerSpan::new(start, end),
|
||||||
Substitution::Escape(pos) => *pos = (start, end),
|
Substitution::Escape(pos) => *pos = (start, end),
|
||||||
@ -38,7 +38,7 @@ pub(crate) mod printf {
|
|||||||
///
|
///
|
||||||
/// This ignores cases where the substitution does not have an exact equivalent, or where
|
/// This ignores cases where the substitution does not have an exact equivalent, or where
|
||||||
/// the substitution would be unnecessary.
|
/// the substitution would be unnecessary.
|
||||||
pub fn translate(&self) -> Result<String, Option<String>> {
|
pub(crate) fn translate(&self) -> Result<String, Option<String>> {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Format(fmt) => fmt.translate(),
|
Substitution::Format(fmt) => fmt.translate(),
|
||||||
Substitution::Escape(_) => Err(None),
|
Substitution::Escape(_) => Err(None),
|
||||||
@ -48,23 +48,23 @@ pub(crate) mod printf {
|
|||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
/// A single `printf`-style formatting directive.
|
/// A single `printf`-style formatting directive.
|
||||||
pub struct Format<'a> {
|
pub(crate) struct Format<'a> {
|
||||||
/// The entire original formatting directive.
|
/// The entire original formatting directive.
|
||||||
pub span: &'a str,
|
span: &'a str,
|
||||||
/// The (1-based) parameter to be converted.
|
/// The (1-based) parameter to be converted.
|
||||||
pub parameter: Option<u16>,
|
parameter: Option<u16>,
|
||||||
/// Formatting flags.
|
/// Formatting flags.
|
||||||
pub flags: &'a str,
|
flags: &'a str,
|
||||||
/// Minimum width of the output.
|
/// Minimum width of the output.
|
||||||
pub width: Option<Num>,
|
width: Option<Num>,
|
||||||
/// Precision of the conversion.
|
/// Precision of the conversion.
|
||||||
pub precision: Option<Num>,
|
precision: Option<Num>,
|
||||||
/// Length modifier for the conversion.
|
/// Length modifier for the conversion.
|
||||||
pub length: Option<&'a str>,
|
length: Option<&'a str>,
|
||||||
/// Type of parameter being converted.
|
/// Type of parameter being converted.
|
||||||
pub type_: &'a str,
|
type_: &'a str,
|
||||||
/// Byte offset for the start and end of this formatting directive.
|
/// Byte offset for the start and end of this formatting directive.
|
||||||
pub position: InnerSpan,
|
position: InnerSpan,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Format<'_> {
|
impl Format<'_> {
|
||||||
@ -72,7 +72,7 @@ pub(crate) mod printf {
|
|||||||
///
|
///
|
||||||
/// Returns `Err` in cases where the `printf` directive does not have an exact Rust
|
/// Returns `Err` in cases where the `printf` directive does not have an exact Rust
|
||||||
/// equivalent, rather than guessing.
|
/// equivalent, rather than guessing.
|
||||||
pub fn translate(&self) -> Result<String, Option<String>> {
|
pub(crate) fn translate(&self) -> Result<String, Option<String>> {
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
let (c_alt, c_zero, c_left, c_plus) = {
|
let (c_alt, c_zero, c_left, c_plus) = {
|
||||||
@ -249,7 +249,7 @@ pub(crate) mod printf {
|
|||||||
|
|
||||||
/// A general number used in a `printf` formatting directive.
|
/// A general number used in a `printf` formatting directive.
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
pub enum Num {
|
enum Num {
|
||||||
// The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU
|
// The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU
|
||||||
// libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it
|
// libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it
|
||||||
// is *vanishingly* unlikely that *anyone* is going to try formatting something wider, or
|
// is *vanishingly* unlikely that *anyone* is going to try formatting something wider, or
|
||||||
@ -288,12 +288,12 @@ pub(crate) mod printf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all substitutions in a given string.
|
/// Returns an iterator over all substitutions in a given string.
|
||||||
pub fn iter_subs(s: &str, start_pos: usize) -> Substitutions<'_> {
|
pub(crate) fn iter_subs(s: &str, start_pos: usize) -> Substitutions<'_> {
|
||||||
Substitutions { s, pos: start_pos }
|
Substitutions { s, pos: start_pos }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterator over substitutions in a string.
|
/// Iterator over substitutions in a string.
|
||||||
pub struct Substitutions<'a> {
|
pub(crate) struct Substitutions<'a> {
|
||||||
s: &'a str,
|
s: &'a str,
|
||||||
pos: usize,
|
pos: usize,
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ pub(crate) mod printf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse the next substitution from the input string.
|
/// Parse the next substitution from the input string.
|
||||||
pub fn parse_next_substitution(s: &str) -> Option<(Substitution<'_>, &str)> {
|
fn parse_next_substitution(s: &str) -> Option<(Substitution<'_>, &str)> {
|
||||||
use self::State::*;
|
use self::State::*;
|
||||||
|
|
||||||
let at = {
|
let at = {
|
||||||
@ -615,20 +615,20 @@ pub(crate) mod printf {
|
|||||||
mod tests;
|
mod tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod shell {
|
pub(crate) mod shell {
|
||||||
use rustc_span::InnerSpan;
|
use rustc_span::InnerSpan;
|
||||||
|
|
||||||
use super::strcursor::StrCursor as Cur;
|
use super::strcursor::StrCursor as Cur;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub enum Substitution<'a> {
|
pub(crate) enum Substitution<'a> {
|
||||||
Ordinal(u8, (usize, usize)),
|
Ordinal(u8, (usize, usize)),
|
||||||
Name(&'a str, (usize, usize)),
|
Name(&'a str, (usize, usize)),
|
||||||
Escape((usize, usize)),
|
Escape((usize, usize)),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Substitution<'_> {
|
impl Substitution<'_> {
|
||||||
pub fn as_str(&self) -> String {
|
pub(crate) fn as_str(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Ordinal(n, _) => format!("${n}"),
|
Substitution::Ordinal(n, _) => format!("${n}"),
|
||||||
Substitution::Name(n, _) => format!("${n}"),
|
Substitution::Name(n, _) => format!("${n}"),
|
||||||
@ -636,17 +636,17 @@ pub mod shell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self) -> InnerSpan {
|
pub(crate) fn position(&self) -> InnerSpan {
|
||||||
let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
|
let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
|
||||||
InnerSpan::new(pos.0, pos.1)
|
InnerSpan::new(pos.0, pos.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(&mut self, start: usize, end: usize) {
|
fn set_position(&mut self, start: usize, end: usize) {
|
||||||
let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
|
let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
|
||||||
*pos = (start, end);
|
*pos = (start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn translate(&self) -> Result<String, Option<String>> {
|
pub(crate) fn translate(&self) -> Result<String, Option<String>> {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Ordinal(n, _) => Ok(format!("{{{}}}", n)),
|
Substitution::Ordinal(n, _) => Ok(format!("{{{}}}", n)),
|
||||||
Substitution::Name(n, _) => Ok(format!("{{{}}}", n)),
|
Substitution::Name(n, _) => Ok(format!("{{{}}}", n)),
|
||||||
@ -656,12 +656,12 @@ pub mod shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all substitutions in a given string.
|
/// Returns an iterator over all substitutions in a given string.
|
||||||
pub fn iter_subs(s: &str, start_pos: usize) -> Substitutions<'_> {
|
pub(crate) fn iter_subs(s: &str, start_pos: usize) -> Substitutions<'_> {
|
||||||
Substitutions { s, pos: start_pos }
|
Substitutions { s, pos: start_pos }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterator over substitutions in a string.
|
/// Iterator over substitutions in a string.
|
||||||
pub struct Substitutions<'a> {
|
pub(crate) struct Substitutions<'a> {
|
||||||
s: &'a str,
|
s: &'a str,
|
||||||
pos: usize,
|
pos: usize,
|
||||||
}
|
}
|
||||||
@ -683,7 +683,7 @@ pub mod shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse the next substitution from the input string.
|
/// Parse the next substitution from the input string.
|
||||||
pub fn parse_next_substitution(s: &str) -> Option<(Substitution<'_>, &str)> {
|
fn parse_next_substitution(s: &str) -> Option<(Substitution<'_>, &str)> {
|
||||||
let at = {
|
let at = {
|
||||||
let start = s.find('$')?;
|
let start = s.find('$')?;
|
||||||
match s[start + 1..].chars().next()? {
|
match s[start + 1..].chars().next()? {
|
||||||
@ -743,24 +743,24 @@ pub mod shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod strcursor {
|
mod strcursor {
|
||||||
pub struct StrCursor<'a> {
|
pub(crate) struct StrCursor<'a> {
|
||||||
s: &'a str,
|
s: &'a str,
|
||||||
pub at: usize,
|
pub at: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StrCursor<'a> {
|
impl<'a> StrCursor<'a> {
|
||||||
pub fn new_at(s: &'a str, at: usize) -> StrCursor<'a> {
|
pub(crate) fn new_at(s: &'a str, at: usize) -> StrCursor<'a> {
|
||||||
StrCursor { s, at }
|
StrCursor { s, at }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn at_next_cp(mut self) -> Option<StrCursor<'a>> {
|
pub(crate) fn at_next_cp(mut self) -> Option<StrCursor<'a>> {
|
||||||
match self.try_seek_right_cp() {
|
match self.try_seek_right_cp() {
|
||||||
true => Some(self),
|
true => Some(self),
|
||||||
false => None,
|
false => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_cp(mut self) -> Option<(char, StrCursor<'a>)> {
|
pub(crate) fn next_cp(mut self) -> Option<(char, StrCursor<'a>)> {
|
||||||
let cp = self.cp_after()?;
|
let cp = self.cp_after()?;
|
||||||
self.seek_right(cp.len_utf8());
|
self.seek_right(cp.len_utf8());
|
||||||
Some((cp, self))
|
Some((cp, self))
|
||||||
@ -770,11 +770,11 @@ mod strcursor {
|
|||||||
&self.s[0..self.at]
|
&self.s[0..self.at]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn slice_after(&self) -> &'a str {
|
pub(crate) fn slice_after(&self) -> &'a str {
|
||||||
&self.s[self.at..]
|
&self.s[self.at..]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn slice_between(&self, until: StrCursor<'a>) -> Option<&'a str> {
|
pub(crate) fn slice_between(&self, until: StrCursor<'a>) -> Option<&'a str> {
|
||||||
if !str_eq_literal(self.s, until.s) {
|
if !str_eq_literal(self.s, until.s) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#![feature(proc_macro_quote)]
|
#![feature(proc_macro_quote)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
@ -6,13 +6,13 @@ use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue};
|
|||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_codegen_ssa::MemFlags;
|
use rustc_codegen_ssa::MemFlags;
|
||||||
use rustc_middle::ty::layout::LayoutOf;
|
use rustc_middle::ty::layout::LayoutOf;
|
||||||
pub use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
pub(crate) use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
|
||||||
use rustc_middle::ty::Ty;
|
use rustc_middle::ty::Ty;
|
||||||
use rustc_middle::{bug, ty};
|
use rustc_middle::{bug, ty};
|
||||||
use rustc_session::config;
|
use rustc_session::config;
|
||||||
pub use rustc_target::abi::call::*;
|
pub(crate) use rustc_target::abi::call::*;
|
||||||
use rustc_target::abi::{self, HasDataLayout, Int, Size};
|
use rustc_target::abi::{self, HasDataLayout, Int, Size};
|
||||||
pub use rustc_target::spec::abi::Abi;
|
pub(crate) use rustc_target::spec::abi::Abi;
|
||||||
use rustc_target::spec::SanitizerSet;
|
use rustc_target::spec::SanitizerSet;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ use crate::type_of::LayoutLlvmExt;
|
|||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use crate::{attributes, llvm_util};
|
use crate::{attributes, llvm_util};
|
||||||
|
|
||||||
pub trait ArgAttributesExt {
|
trait ArgAttributesExt {
|
||||||
fn apply_attrs_to_llfn(&self, idx: AttributePlace, cx: &CodegenCx<'_, '_>, llfn: &Value);
|
fn apply_attrs_to_llfn(&self, idx: AttributePlace, cx: &CodegenCx<'_, '_>, llfn: &Value);
|
||||||
fn apply_attrs_to_callsite(
|
fn apply_attrs_to_callsite(
|
||||||
&self,
|
&self,
|
||||||
@ -111,7 +111,7 @@ impl ArgAttributesExt for ArgAttributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LlvmType {
|
pub(crate) trait LlvmType {
|
||||||
fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type;
|
fn llvm_type<'ll>(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ impl LlvmType for CastTarget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ArgAbiExt<'ll, 'tcx> {
|
trait ArgAbiExt<'ll, 'tcx> {
|
||||||
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
||||||
fn store(
|
fn store(
|
||||||
&self,
|
&self,
|
||||||
@ -307,7 +307,7 @@ impl<'ll, 'tcx> ArgAbiMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FnAbiLlvmExt<'ll, 'tcx> {
|
pub(crate) trait FnAbiLlvmExt<'ll, 'tcx> {
|
||||||
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
||||||
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
||||||
fn llvm_cconv(&self) -> llvm::CallConv;
|
fn llvm_cconv(&self) -> llvm::CallConv;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Set and unset common attributes on LLVM values.
|
//! Set and unset common attributes on LLVM values.
|
||||||
|
|
||||||
pub use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
|
use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry};
|
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry};
|
||||||
@ -17,13 +17,13 @@ use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace
|
|||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use crate::{attributes, llvm_util};
|
use crate::{attributes, llvm_util};
|
||||||
|
|
||||||
pub fn apply_to_llfn(llfn: &Value, idx: AttributePlace, attrs: &[&Attribute]) {
|
pub(crate) fn apply_to_llfn(llfn: &Value, idx: AttributePlace, attrs: &[&Attribute]) {
|
||||||
if !attrs.is_empty() {
|
if !attrs.is_empty() {
|
||||||
llvm::AddFunctionAttributes(llfn, idx, attrs);
|
llvm::AddFunctionAttributes(llfn, idx, attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_to_callsite(callsite: &Value, idx: AttributePlace, attrs: &[&Attribute]) {
|
pub(crate) fn apply_to_callsite(callsite: &Value, idx: AttributePlace, attrs: &[&Attribute]) {
|
||||||
if !attrs.is_empty() {
|
if !attrs.is_empty() {
|
||||||
llvm::AddCallSiteAttributes(callsite, idx, attrs);
|
llvm::AddCallSiteAttributes(callsite, idx, attrs);
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ fn patchable_function_entry_attrs<'ll>(
|
|||||||
|
|
||||||
/// Get LLVM sanitize attributes.
|
/// Get LLVM sanitize attributes.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn sanitize_attrs<'ll>(
|
pub(crate) fn sanitize_attrs<'ll>(
|
||||||
cx: &CodegenCx<'ll, '_>,
|
cx: &CodegenCx<'ll, '_>,
|
||||||
no_sanitize: SanitizerSet,
|
no_sanitize: SanitizerSet,
|
||||||
) -> SmallVec<[&'ll Attribute; 4]> {
|
) -> SmallVec<[&'ll Attribute; 4]> {
|
||||||
@ -120,7 +120,7 @@ pub fn sanitize_attrs<'ll>(
|
|||||||
|
|
||||||
/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
|
/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn uwtable_attr(llcx: &llvm::Context, use_sync_unwind: Option<bool>) -> &Attribute {
|
pub(crate) fn uwtable_attr(llcx: &llvm::Context, use_sync_unwind: Option<bool>) -> &Attribute {
|
||||||
// NOTE: We should determine if we even need async unwind tables, as they
|
// NOTE: We should determine if we even need async unwind tables, as they
|
||||||
// take have more overhead and if we can use sync unwind tables we
|
// take have more overhead and if we can use sync unwind tables we
|
||||||
// probably should.
|
// probably should.
|
||||||
@ -128,7 +128,7 @@ pub fn uwtable_attr(llcx: &llvm::Context, use_sync_unwind: Option<bool>) -> &Att
|
|||||||
llvm::CreateUWTableAttr(llcx, async_unwind)
|
llvm::CreateUWTableAttr(llcx, async_unwind)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
pub(crate) fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
||||||
let mut fp = cx.sess().target.frame_pointer;
|
let mut fp = cx.sess().target.frame_pointer;
|
||||||
let opts = &cx.sess().opts;
|
let opts = &cx.sess().opts;
|
||||||
// "mcount" function relies on stack pointer.
|
// "mcount" function relies on stack pointer.
|
||||||
@ -280,19 +280,19 @@ fn backchain_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
|||||||
if found_positive { Some(llvm::CreateAttrString(cx.llcx, "backchain")) } else { None }
|
if found_positive { Some(llvm::CreateAttrString(cx.llcx, "backchain")) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll Attribute {
|
pub(crate) fn target_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll Attribute {
|
||||||
let target_cpu = llvm_util::target_cpu(cx.tcx.sess);
|
let target_cpu = llvm_util::target_cpu(cx.tcx.sess);
|
||||||
llvm::CreateAttrStringValue(cx.llcx, "target-cpu", target_cpu)
|
llvm::CreateAttrStringValue(cx.llcx, "target-cpu", target_cpu)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
pub(crate) fn tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
||||||
llvm_util::tune_cpu(cx.tcx.sess)
|
llvm_util::tune_cpu(cx.tcx.sess)
|
||||||
.map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu))
|
.map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `NonLazyBind` LLVM attribute,
|
/// Get the `NonLazyBind` LLVM attribute,
|
||||||
/// if the codegen options allow skipping the PLT.
|
/// if the codegen options allow skipping the PLT.
|
||||||
pub fn non_lazy_bind_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
pub(crate) fn non_lazy_bind_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
|
||||||
// Don't generate calls through PLT if it's not necessary
|
// Don't generate calls through PLT if it's not necessary
|
||||||
if !cx.sess().needs_plt() {
|
if !cx.sess().needs_plt() {
|
||||||
Some(AttributeKind::NonLazyBind.create_attr(cx.llcx))
|
Some(AttributeKind::NonLazyBind.create_attr(cx.llcx))
|
||||||
@ -327,7 +327,7 @@ fn create_alloc_family_attr(llcx: &llvm::Context) -> &llvm::Attribute {
|
|||||||
/// Helper for `FnAbi::apply_attrs_llfn`:
|
/// Helper for `FnAbi::apply_attrs_llfn`:
|
||||||
/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
|
/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
|
||||||
/// attributes.
|
/// attributes.
|
||||||
pub fn llfn_attrs_from_instance<'ll, 'tcx>(
|
pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
|
||||||
cx: &CodegenCx<'ll, 'tcx>,
|
cx: &CodegenCx<'ll, 'tcx>,
|
||||||
llfn: &'ll Value,
|
llfn: &'ll Value,
|
||||||
instance: ty::Instance<'tcx>,
|
instance: ty::Instance<'tcx>,
|
||||||
|
@ -86,7 +86,7 @@ impl<'a> ArchiveBuilder for LlvmArchiveBuilder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LlvmArchiveBuilderBuilder;
|
pub(crate) struct LlvmArchiveBuilderBuilder;
|
||||||
|
|
||||||
impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
|
impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
|
||||||
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
|
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
|
||||||
|
@ -33,9 +33,9 @@ use crate::{LlvmCodegenBackend, ModuleLlvm};
|
|||||||
|
|
||||||
/// We keep track of the computed LTO cache keys from the previous
|
/// We keep track of the computed LTO cache keys from the previous
|
||||||
/// session to determine which CGUs we can reuse.
|
/// session to determine which CGUs we can reuse.
|
||||||
pub const THIN_LTO_KEYS_INCR_COMP_FILE_NAME: &str = "thin-lto-past-keys.bin";
|
const THIN_LTO_KEYS_INCR_COMP_FILE_NAME: &str = "thin-lto-past-keys.bin";
|
||||||
|
|
||||||
pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
|
fn crate_type_allows_lto(crate_type: CrateType) -> bool {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
CrateType::Executable
|
CrateType::Executable
|
||||||
| CrateType::Dylib
|
| CrateType::Dylib
|
||||||
@ -710,7 +710,7 @@ impl Drop for ThinBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn optimize_thin_module(
|
pub(crate) unsafe fn optimize_thin_module(
|
||||||
thin_module: ThinModule<LlvmCodegenBackend>,
|
thin_module: ThinModule<LlvmCodegenBackend>,
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
|
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
|
||||||
@ -806,7 +806,7 @@ pub unsafe fn optimize_thin_module(
|
|||||||
|
|
||||||
/// Maps LLVM module identifiers to their corresponding LLVM LTO cache keys
|
/// Maps LLVM module identifiers to their corresponding LLVM LTO cache keys
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct ThinLTOKeysMap {
|
struct ThinLTOKeysMap {
|
||||||
// key = llvm name of importing module, value = LLVM cache key
|
// key = llvm name of importing module, value = LLVM cache key
|
||||||
keys: BTreeMap<String, String>,
|
keys: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
@ -863,7 +863,7 @@ fn module_name_to_str(c_str: &CStr) -> &str {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_module<'a>(
|
pub(crate) fn parse_module<'a>(
|
||||||
cx: &'a llvm::Context,
|
cx: &'a llvm::Context,
|
||||||
name: &CStr,
|
name: &CStr,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
|
@ -21,14 +21,14 @@ fn llvm_args_to_string_id(profiler: &SelfProfiler, pass_name: &str, ir_name: &st
|
|||||||
EventId::from_label(profiler.alloc_string(components.as_slice()))
|
EventId::from_label(profiler.alloc_string(components.as_slice()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LlvmSelfProfiler<'a> {
|
pub(crate) struct LlvmSelfProfiler<'a> {
|
||||||
profiler: Arc<SelfProfiler>,
|
profiler: Arc<SelfProfiler>,
|
||||||
stack: Vec<TimingGuard<'a>>,
|
stack: Vec<TimingGuard<'a>>,
|
||||||
llvm_pass_event_kind: StringId,
|
llvm_pass_event_kind: StringId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LlvmSelfProfiler<'a> {
|
impl<'a> LlvmSelfProfiler<'a> {
|
||||||
pub fn new(profiler: Arc<SelfProfiler>) -> Self {
|
pub(crate) fn new(profiler: Arc<SelfProfiler>) -> Self {
|
||||||
let llvm_pass_event_kind = profiler.alloc_string("LLVM Pass");
|
let llvm_pass_event_kind = profiler.alloc_string("LLVM Pass");
|
||||||
Self { profiler, stack: Vec::default(), llvm_pass_event_kind }
|
Self { profiler, stack: Vec::default(), llvm_pass_event_kind }
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ impl<'a> LlvmSelfProfiler<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe extern "C" fn selfprofile_before_pass_callback(
|
pub(crate) unsafe extern "C" fn selfprofile_before_pass_callback(
|
||||||
llvm_self_profiler: *mut c_void,
|
llvm_self_profiler: *mut c_void,
|
||||||
pass_name: *const c_char,
|
pass_name: *const c_char,
|
||||||
ir_name: *const c_char,
|
ir_name: *const c_char,
|
||||||
@ -56,7 +56,7 @@ pub unsafe extern "C" fn selfprofile_before_pass_callback(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe extern "C" fn selfprofile_after_pass_callback(llvm_self_profiler: *mut c_void) {
|
pub(crate) unsafe extern "C" fn selfprofile_after_pass_callback(llvm_self_profiler: *mut c_void) {
|
||||||
let llvm_self_profiler = unsafe { &mut *(llvm_self_profiler as *mut LlvmSelfProfiler<'_>) };
|
let llvm_self_profiler = unsafe { &mut *(llvm_self_profiler as *mut LlvmSelfProfiler<'_>) };
|
||||||
llvm_self_profiler.after_pass_callback();
|
llvm_self_profiler.after_pass_callback();
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,14 @@ use crate::llvm::{self, DiagnosticInfo, PassManager};
|
|||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use crate::{base, common, llvm_util, LlvmCodegenBackend, ModuleLlvm};
|
use crate::{base, common, llvm_util, LlvmCodegenBackend, ModuleLlvm};
|
||||||
|
|
||||||
pub fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> FatalError {
|
pub(crate) fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> FatalError {
|
||||||
match llvm::last_error() {
|
match llvm::last_error() {
|
||||||
Some(llvm_err) => dcx.emit_almost_fatal(WithLlvmError(err, llvm_err)),
|
Some(llvm_err) => dcx.emit_almost_fatal(WithLlvmError(err, llvm_err)),
|
||||||
None => dcx.emit_almost_fatal(err),
|
None => dcx.emit_almost_fatal(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_output_file<'ll>(
|
fn write_output_file<'ll>(
|
||||||
dcx: DiagCtxtHandle<'_>,
|
dcx: DiagCtxtHandle<'_>,
|
||||||
target: &'ll llvm::TargetMachine,
|
target: &'ll llvm::TargetMachine,
|
||||||
pm: &llvm::PassManager<'ll>,
|
pm: &llvm::PassManager<'ll>,
|
||||||
@ -95,7 +95,7 @@ pub fn write_output_file<'ll>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_informational_target_machine(
|
pub(crate) fn create_informational_target_machine(
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
only_base_features: bool,
|
only_base_features: bool,
|
||||||
) -> OwnedTargetMachine {
|
) -> OwnedTargetMachine {
|
||||||
@ -107,7 +107,7 @@ pub fn create_informational_target_machine(
|
|||||||
.unwrap_or_else(|err| llvm_err(sess.dcx(), err).raise())
|
.unwrap_or_else(|err| llvm_err(sess.dcx(), err).raise())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTargetMachine {
|
pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTargetMachine {
|
||||||
let split_dwarf_file = if tcx.sess.target_can_use_split_dwarf() {
|
let split_dwarf_file = if tcx.sess.target_can_use_split_dwarf() {
|
||||||
tcx.output_filenames(()).split_dwarf_path(
|
tcx.output_filenames(()).split_dwarf_path(
|
||||||
tcx.sess.split_debuginfo(),
|
tcx.sess.split_debuginfo(),
|
||||||
@ -130,9 +130,7 @@ pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTargetMach
|
|||||||
.unwrap_or_else(|err| llvm_err(tcx.dcx(), err).raise())
|
.unwrap_or_else(|err| llvm_err(tcx.dcx(), err).raise())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_llvm_opt_settings(
|
fn to_llvm_opt_settings(cfg: config::OptLevel) -> (llvm::CodeGenOptLevel, llvm::CodeGenOptSize) {
|
||||||
cfg: config::OptLevel,
|
|
||||||
) -> (llvm::CodeGenOptLevel, llvm::CodeGenOptSize) {
|
|
||||||
use self::config::OptLevel::*;
|
use self::config::OptLevel::*;
|
||||||
match cfg {
|
match cfg {
|
||||||
No => (llvm::CodeGenOptLevel::None, llvm::CodeGenOptSizeNone),
|
No => (llvm::CodeGenOptLevel::None, llvm::CodeGenOptSizeNone),
|
||||||
@ -179,7 +177,7 @@ pub(crate) fn to_llvm_code_model(code_model: Option<CodeModel>) -> llvm::CodeMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_machine_factory(
|
pub(crate) fn target_machine_factory(
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
optlvl: config::OptLevel,
|
optlvl: config::OptLevel,
|
||||||
target_features: &[String],
|
target_features: &[String],
|
||||||
@ -320,7 +318,7 @@ pub(crate) fn save_temp_bitcode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// In what context is a dignostic handler being attached to a codegen unit?
|
/// In what context is a dignostic handler being attached to a codegen unit?
|
||||||
pub enum CodegenDiagnosticsStage {
|
pub(crate) enum CodegenDiagnosticsStage {
|
||||||
/// Prelink optimization stage.
|
/// Prelink optimization stage.
|
||||||
Opt,
|
Opt,
|
||||||
/// LTO/ThinLTO postlink optimization stage.
|
/// LTO/ThinLTO postlink optimization stage.
|
||||||
@ -329,14 +327,14 @@ pub enum CodegenDiagnosticsStage {
|
|||||||
Codegen,
|
Codegen,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DiagnosticHandlers<'a> {
|
pub(crate) struct DiagnosticHandlers<'a> {
|
||||||
data: *mut (&'a CodegenContext<LlvmCodegenBackend>, DiagCtxtHandle<'a>),
|
data: *mut (&'a CodegenContext<LlvmCodegenBackend>, DiagCtxtHandle<'a>),
|
||||||
llcx: &'a llvm::Context,
|
llcx: &'a llvm::Context,
|
||||||
old_handler: Option<&'a llvm::DiagnosticHandler>,
|
old_handler: Option<&'a llvm::DiagnosticHandler>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DiagnosticHandlers<'a> {
|
impl<'a> DiagnosticHandlers<'a> {
|
||||||
pub fn new(
|
pub(crate) fn new(
|
||||||
cgcx: &'a CodegenContext<LlvmCodegenBackend>,
|
cgcx: &'a CodegenContext<LlvmCodegenBackend>,
|
||||||
dcx: DiagCtxtHandle<'a>,
|
dcx: DiagCtxtHandle<'a>,
|
||||||
llcx: &'a llvm::Context,
|
llcx: &'a llvm::Context,
|
||||||
|
@ -32,7 +32,7 @@ use crate::context::CodegenCx;
|
|||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use crate::{attributes, llvm};
|
use crate::{attributes, llvm};
|
||||||
|
|
||||||
pub struct ValueIter<'ll> {
|
pub(crate) struct ValueIter<'ll> {
|
||||||
cur: Option<&'ll Value>,
|
cur: Option<&'ll Value>,
|
||||||
step: unsafe extern "C" fn(&'ll Value) -> Option<&'ll Value>,
|
step: unsafe extern "C" fn(&'ll Value) -> Option<&'ll Value>,
|
||||||
}
|
}
|
||||||
@ -49,11 +49,14 @@ impl<'ll> Iterator for ValueIter<'ll> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_globals(llmod: &llvm::Module) -> ValueIter<'_> {
|
pub(crate) fn iter_globals(llmod: &llvm::Module) -> ValueIter<'_> {
|
||||||
unsafe { ValueIter { cur: llvm::LLVMGetFirstGlobal(llmod), step: llvm::LLVMGetNextGlobal } }
|
unsafe { ValueIter { cur: llvm::LLVMGetFirstGlobal(llmod), step: llvm::LLVMGetNextGlobal } }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen<ModuleLlvm>, u64) {
|
pub(crate) fn compile_codegen_unit(
|
||||||
|
tcx: TyCtxt<'_>,
|
||||||
|
cgu_name: Symbol,
|
||||||
|
) -> (ModuleCodegen<ModuleLlvm>, u64) {
|
||||||
let start_time = Instant::now();
|
let start_time = Instant::now();
|
||||||
|
|
||||||
let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);
|
let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx);
|
||||||
@ -140,7 +143,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen
|
|||||||
(module, cost)
|
(module, cost)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
|
pub(crate) fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
|
||||||
let Some(sect) = attrs.link_section else { return };
|
let Some(sect) = attrs.link_section else { return };
|
||||||
unsafe {
|
unsafe {
|
||||||
let buf = SmallCStr::new(sect.as_str());
|
let buf = SmallCStr::new(sect.as_str());
|
||||||
@ -148,7 +151,7 @@ pub fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
|
pub(crate) fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
|
||||||
match linkage {
|
match linkage {
|
||||||
Linkage::External => llvm::Linkage::ExternalLinkage,
|
Linkage::External => llvm::Linkage::ExternalLinkage,
|
||||||
Linkage::AvailableExternally => llvm::Linkage::AvailableExternallyLinkage,
|
Linkage::AvailableExternally => llvm::Linkage::AvailableExternallyLinkage,
|
||||||
@ -164,7 +167,7 @@ pub fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
|
pub(crate) fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
|
||||||
match linkage {
|
match linkage {
|
||||||
Visibility::Default => llvm::Visibility::Default,
|
Visibility::Default => llvm::Visibility::Default,
|
||||||
Visibility::Hidden => llvm::Visibility::Hidden,
|
Visibility::Hidden => llvm::Visibility::Hidden,
|
||||||
|
@ -36,7 +36,7 @@ use crate::{attributes, llvm_util};
|
|||||||
|
|
||||||
// All Builders must have an llfn associated with them
|
// All Builders must have an llfn associated with them
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct Builder<'a, 'll, 'tcx> {
|
pub(crate) struct Builder<'a, 'll, 'tcx> {
|
||||||
pub llbuilder: &'ll mut llvm::Builder<'ll>,
|
pub llbuilder: &'ll mut llvm::Builder<'ll>,
|
||||||
pub cx: &'a CodegenCx<'ll, 'tcx>,
|
pub cx: &'a CodegenCx<'ll, 'tcx>,
|
||||||
}
|
}
|
||||||
@ -1343,7 +1343,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
|
|||||||
Builder { llbuilder, cx }
|
Builder { llbuilder, cx }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn llfn(&self) -> &'ll Value {
|
pub(crate) fn llfn(&self) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMGetBasicBlockParent(self.llbb()) }
|
unsafe { llvm::LLVMGetBasicBlockParent(self.llbb()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1375,7 +1375,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_unpredictable(&mut self, inst: &'ll Value) {
|
pub(crate) fn set_unpredictable(&mut self, inst: &'ll Value) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMSetMetadata(
|
llvm::LLVMSetMetadata(
|
||||||
inst,
|
inst,
|
||||||
@ -1385,15 +1385,15 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn minnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
pub(crate) fn minnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs) }
|
unsafe { llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn maxnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
pub(crate) fn maxnum(&mut self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildMaxNum(self.llbuilder, lhs, rhs) }
|
unsafe { llvm::LLVMRustBuildMaxNum(self.llbuilder, lhs, rhs) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_element(
|
pub(crate) fn insert_element(
|
||||||
&mut self,
|
&mut self,
|
||||||
vec: &'ll Value,
|
vec: &'ll Value,
|
||||||
elt: &'ll Value,
|
elt: &'ll Value,
|
||||||
@ -1402,7 +1402,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
|
|||||||
unsafe { llvm::LLVMBuildInsertElement(self.llbuilder, vec, elt, idx, UNNAMED) }
|
unsafe { llvm::LLVMBuildInsertElement(self.llbuilder, vec, elt, idx, UNNAMED) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shuffle_vector(
|
pub(crate) fn shuffle_vector(
|
||||||
&mut self,
|
&mut self,
|
||||||
v1: &'ll Value,
|
v1: &'ll Value,
|
||||||
v2: &'ll Value,
|
v2: &'ll Value,
|
||||||
@ -1411,65 +1411,77 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
|
|||||||
unsafe { llvm::LLVMBuildShuffleVector(self.llbuilder, v1, v2, mask, UNNAMED) }
|
unsafe { llvm::LLVMBuildShuffleVector(self.llbuilder, v1, v2, mask, UNNAMED) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vector_reduce_fadd(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_fadd(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src) }
|
unsafe { llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_fmul(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_fmul(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src) }
|
unsafe { llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_fadd_reassoc(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_fadd_reassoc(
|
||||||
|
&mut self,
|
||||||
|
acc: &'ll Value,
|
||||||
|
src: &'ll Value,
|
||||||
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let instr = llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src);
|
let instr = llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src);
|
||||||
llvm::LLVMRustSetAllowReassoc(instr);
|
llvm::LLVMRustSetAllowReassoc(instr);
|
||||||
instr
|
instr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_fmul_reassoc(&mut self, acc: &'ll Value, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_fmul_reassoc(
|
||||||
|
&mut self,
|
||||||
|
acc: &'ll Value,
|
||||||
|
src: &'ll Value,
|
||||||
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let instr = llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src);
|
let instr = llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src);
|
||||||
llvm::LLVMRustSetAllowReassoc(instr);
|
llvm::LLVMRustSetAllowReassoc(instr);
|
||||||
instr
|
instr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_add(&mut self, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_add(&mut self, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceAdd(self.llbuilder, src) }
|
unsafe { llvm::LLVMRustBuildVectorReduceAdd(self.llbuilder, src) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_mul(&mut self, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_mul(&mut self, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceMul(self.llbuilder, src) }
|
unsafe { llvm::LLVMRustBuildVectorReduceMul(self.llbuilder, src) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_and(&mut self, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_and(&mut self, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceAnd(self.llbuilder, src) }
|
unsafe { llvm::LLVMRustBuildVectorReduceAnd(self.llbuilder, src) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_or(&mut self, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_or(&mut self, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceOr(self.llbuilder, src) }
|
unsafe { llvm::LLVMRustBuildVectorReduceOr(self.llbuilder, src) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_xor(&mut self, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_xor(&mut self, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceXor(self.llbuilder, src) }
|
unsafe { llvm::LLVMRustBuildVectorReduceXor(self.llbuilder, src) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_fmin(&mut self, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_fmin(&mut self, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false)
|
llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_fmax(&mut self, src: &'ll Value) -> &'ll Value {
|
pub(crate) fn vector_reduce_fmax(&mut self, src: &'ll Value) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false)
|
llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_min(&mut self, src: &'ll Value, is_signed: bool) -> &'ll Value {
|
pub(crate) fn vector_reduce_min(&mut self, src: &'ll Value, is_signed: bool) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceMin(self.llbuilder, src, is_signed) }
|
unsafe { llvm::LLVMRustBuildVectorReduceMin(self.llbuilder, src, is_signed) }
|
||||||
}
|
}
|
||||||
pub fn vector_reduce_max(&mut self, src: &'ll Value, is_signed: bool) -> &'ll Value {
|
pub(crate) fn vector_reduce_max(&mut self, src: &'ll Value, is_signed: bool) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustBuildVectorReduceMax(self.llbuilder, src, is_signed) }
|
unsafe { llvm::LLVMRustBuildVectorReduceMax(self.llbuilder, src, is_signed) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_clause(&mut self, landing_pad: &'ll Value, clause: &'ll Value) {
|
pub(crate) fn add_clause(&mut self, landing_pad: &'ll Value, clause: &'ll Value) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMAddClause(landing_pad, clause);
|
llvm::LLVMAddClause(landing_pad, clause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn catch_ret(&mut self, funclet: &Funclet<'ll>, unwind: &'ll BasicBlock) -> &'ll Value {
|
pub(crate) fn catch_ret(
|
||||||
|
&mut self,
|
||||||
|
funclet: &Funclet<'ll>,
|
||||||
|
unwind: &'ll BasicBlock,
|
||||||
|
) -> &'ll Value {
|
||||||
let ret = unsafe { llvm::LLVMBuildCatchRet(self.llbuilder, funclet.cleanuppad(), unwind) };
|
let ret = unsafe { llvm::LLVMBuildCatchRet(self.llbuilder, funclet.cleanuppad(), unwind) };
|
||||||
ret.expect("LLVM does not have support for catchret")
|
ret.expect("LLVM does not have support for catchret")
|
||||||
}
|
}
|
||||||
@ -1515,7 +1527,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
|
|||||||
Cow::Owned(casted_args)
|
Cow::Owned(casted_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value {
|
pub(crate) fn va_arg(&mut self, list: &'ll Value, ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMBuildVAArg(self.llbuilder, list, ty, UNNAMED) }
|
unsafe { llvm::LLVMBuildVAArg(self.llbuilder, list, ty, UNNAMED) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ use crate::value::Value;
|
|||||||
///
|
///
|
||||||
/// - `cx`: the crate context
|
/// - `cx`: the crate context
|
||||||
/// - `instance`: the instance to be instantiated
|
/// - `instance`: the instance to be instantiated
|
||||||
pub fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value {
|
pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value {
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
|
|
||||||
debug!("get_fn(instance={:?})", instance);
|
debug!("get_fn(instance={:?})", instance);
|
||||||
|
@ -13,7 +13,7 @@ use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer};
|
|||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::consts::const_alloc_to_llvm;
|
use crate::consts::const_alloc_to_llvm;
|
||||||
pub use crate::context::CodegenCx;
|
pub(crate) use crate::context::CodegenCx;
|
||||||
use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True};
|
use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True};
|
||||||
use crate::type_::Type;
|
use crate::type_::Type;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
@ -58,21 +58,21 @@ use crate::value::Value;
|
|||||||
/// When inside of a landing pad, each function call in LLVM IR needs to be
|
/// When inside of a landing pad, each function call in LLVM IR needs to be
|
||||||
/// annotated with which landing pad it's a part of. This is accomplished via
|
/// annotated with which landing pad it's a part of. This is accomplished via
|
||||||
/// the `OperandBundleDef` value created for MSVC landing pads.
|
/// the `OperandBundleDef` value created for MSVC landing pads.
|
||||||
pub struct Funclet<'ll> {
|
pub(crate) struct Funclet<'ll> {
|
||||||
cleanuppad: &'ll Value,
|
cleanuppad: &'ll Value,
|
||||||
operand: OperandBundleDef<'ll>,
|
operand: OperandBundleDef<'ll>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ll> Funclet<'ll> {
|
impl<'ll> Funclet<'ll> {
|
||||||
pub fn new(cleanuppad: &'ll Value) -> Self {
|
pub(crate) fn new(cleanuppad: &'ll Value) -> Self {
|
||||||
Funclet { cleanuppad, operand: OperandBundleDef::new("funclet", &[cleanuppad]) }
|
Funclet { cleanuppad, operand: OperandBundleDef::new("funclet", &[cleanuppad]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cleanuppad(&self) -> &'ll Value {
|
pub(crate) fn cleanuppad(&self) -> &'ll Value {
|
||||||
self.cleanuppad
|
self.cleanuppad
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bundle(&self) -> &OperandBundleDef<'ll> {
|
pub(crate) fn bundle(&self) -> &OperandBundleDef<'ll> {
|
||||||
&self.operand
|
&self.operand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,16 +92,16 @@ impl<'ll> BackendTypes for CodegenCx<'ll, '_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'ll> CodegenCx<'ll, '_> {
|
impl<'ll> CodegenCx<'ll, '_> {
|
||||||
pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
|
pub(crate) fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
|
||||||
let len = u64::try_from(elts.len()).expect("LLVMConstArray2 elements len overflow");
|
let len = u64::try_from(elts.len()).expect("LLVMConstArray2 elements len overflow");
|
||||||
unsafe { llvm::LLVMConstArray2(ty, elts.as_ptr(), len) }
|
unsafe { llvm::LLVMConstArray2(ty, elts.as_ptr(), len) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
|
pub(crate) fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
|
||||||
bytes_in_context(self.llcx, bytes)
|
bytes_in_context(self.llcx, bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
|
pub(crate) fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let idx = c_uint::try_from(idx).expect("LLVMGetAggregateElement index overflow");
|
let idx = c_uint::try_from(idx).expect("LLVMGetAggregateElement index overflow");
|
||||||
let r = llvm::LLVMGetAggregateElement(v, idx).unwrap();
|
let r = llvm::LLVMGetAggregateElement(v, idx).unwrap();
|
||||||
@ -339,18 +339,18 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the [LLVM type][Type] of a [`Value`].
|
/// Get the [LLVM type][Type] of a [`Value`].
|
||||||
pub fn val_ty(v: &Value) -> &Type {
|
pub(crate) fn val_ty(v: &Value) -> &Type {
|
||||||
unsafe { llvm::LLVMTypeOf(v) }
|
unsafe { llvm::LLVMTypeOf(v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
|
pub(crate) fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = bytes.as_ptr() as *const c_char;
|
let ptr = bytes.as_ptr() as *const c_char;
|
||||||
llvm::LLVMConstStringInContext2(llcx, ptr, bytes.len(), True)
|
llvm::LLVMConstStringInContext2(llcx, ptr, bytes.len(), True)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn struct_in_context<'ll>(
|
fn struct_in_context<'ll>(
|
||||||
llcx: &'ll llvm::Context,
|
llcx: &'ll llvm::Context,
|
||||||
elts: &[&'ll Value],
|
elts: &[&'ll Value],
|
||||||
packed: bool,
|
packed: bool,
|
||||||
|
@ -29,7 +29,7 @@ use crate::type_of::LayoutLlvmExt;
|
|||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use crate::{base, debuginfo};
|
use crate::{base, debuginfo};
|
||||||
|
|
||||||
pub fn const_alloc_to_llvm<'ll>(
|
pub(crate) fn const_alloc_to_llvm<'ll>(
|
||||||
cx: &CodegenCx<'ll, '_>,
|
cx: &CodegenCx<'ll, '_>,
|
||||||
alloc: ConstAllocation<'_>,
|
alloc: ConstAllocation<'_>,
|
||||||
is_static: bool,
|
is_static: bool,
|
||||||
|
@ -40,7 +40,7 @@ use crate::{attributes, coverageinfo, debuginfo, llvm, llvm_util};
|
|||||||
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
|
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
|
||||||
/// `llvm::Context` so that several compilation units may be optimized in parallel.
|
/// `llvm::Context` so that several compilation units may be optimized in parallel.
|
||||||
/// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`.
|
/// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`.
|
||||||
pub struct CodegenCx<'ll, 'tcx> {
|
pub(crate) struct CodegenCx<'ll, 'tcx> {
|
||||||
pub tcx: TyCtxt<'tcx>,
|
pub tcx: TyCtxt<'tcx>,
|
||||||
pub use_dll_storage_attrs: bool,
|
pub use_dll_storage_attrs: bool,
|
||||||
pub tls_model: llvm::ThreadLocalMode,
|
pub tls_model: llvm::ThreadLocalMode,
|
||||||
@ -111,7 +111,7 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn create_module<'ll>(
|
pub(crate) unsafe fn create_module<'ll>(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
llcx: &'ll llvm::Context,
|
llcx: &'ll llvm::Context,
|
||||||
mod_name: &str,
|
mod_name: &str,
|
||||||
@ -562,7 +562,9 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn coverage_context(&self) -> Option<&coverageinfo::CrateCoverageContext<'ll, 'tcx>> {
|
pub(crate) fn coverage_context(
|
||||||
|
&self,
|
||||||
|
) -> Option<&coverageinfo::CrateCoverageContext<'ll, 'tcx>> {
|
||||||
self.coverage_cx.as_ref()
|
self.coverage_cx.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,7 +1099,7 @@ impl<'ll> CodegenCx<'ll, '_> {
|
|||||||
impl CodegenCx<'_, '_> {
|
impl CodegenCx<'_, '_> {
|
||||||
/// Generates a new symbol name with the given prefix. This symbol name must
|
/// Generates a new symbol name with the given prefix. This symbol name must
|
||||||
/// only be used for definitions with `internal` or `private` linkage.
|
/// only be used for definitions with `internal` or `private` linkage.
|
||||||
pub fn generate_local_symbol_name(&self, prefix: &str) -> String {
|
pub(crate) fn generate_local_symbol_name(&self, prefix: &str) -> String {
|
||||||
let idx = self.local_gen_sym_counter.get();
|
let idx = self.local_gen_sym_counter.get();
|
||||||
self.local_gen_sym_counter.set(idx + 1);
|
self.local_gen_sym_counter.set(idx + 1);
|
||||||
// Include a '.' character, so there can be no accidental conflicts with
|
// Include a '.' character, so there can be no accidental conflicts with
|
||||||
|
@ -80,7 +80,7 @@ pub struct CounterExpression {
|
|||||||
/// Must match the layout of `LLVMRustCounterMappingRegionKind`.
|
/// Must match the layout of `LLVMRustCounterMappingRegionKind`.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum RegionKind {
|
enum RegionKind {
|
||||||
/// A CodeRegion associates some code with a counter
|
/// A CodeRegion associates some code with a counter
|
||||||
CodeRegion = 0,
|
CodeRegion = 0,
|
||||||
|
|
||||||
@ -110,13 +110,13 @@ pub enum RegionKind {
|
|||||||
MCDCBranchRegion = 6,
|
MCDCBranchRegion = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod mcdc {
|
mod mcdc {
|
||||||
use rustc_middle::mir::coverage::{ConditionInfo, DecisionInfo};
|
use rustc_middle::mir::coverage::{ConditionInfo, DecisionInfo};
|
||||||
|
|
||||||
/// Must match the layout of `LLVMRustMCDCDecisionParameters`.
|
/// Must match the layout of `LLVMRustMCDCDecisionParameters`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
pub struct DecisionParameters {
|
pub(crate) struct DecisionParameters {
|
||||||
bitmap_idx: u32,
|
bitmap_idx: u32,
|
||||||
num_conditions: u16,
|
num_conditions: u16,
|
||||||
}
|
}
|
||||||
@ -127,14 +127,14 @@ pub mod mcdc {
|
|||||||
/// Must match the layout of `LLVMRustMCDCBranchParameters`.
|
/// Must match the layout of `LLVMRustMCDCBranchParameters`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
pub struct BranchParameters {
|
pub(crate) struct BranchParameters {
|
||||||
condition_id: LLVMConditionId,
|
condition_id: LLVMConditionId,
|
||||||
condition_ids: [LLVMConditionId; 2],
|
condition_ids: [LLVMConditionId; 2],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum ParameterTag {
|
enum ParameterTag {
|
||||||
None = 0,
|
None = 0,
|
||||||
Decision = 1,
|
Decision = 1,
|
||||||
Branch = 2,
|
Branch = 2,
|
||||||
@ -142,24 +142,24 @@ pub mod mcdc {
|
|||||||
/// Same layout with `LLVMRustMCDCParameters`
|
/// Same layout with `LLVMRustMCDCParameters`
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Parameters {
|
pub(crate) struct Parameters {
|
||||||
tag: ParameterTag,
|
tag: ParameterTag,
|
||||||
decision_params: DecisionParameters,
|
decision_params: DecisionParameters,
|
||||||
branch_params: BranchParameters,
|
branch_params: BranchParameters,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parameters {
|
impl Parameters {
|
||||||
pub fn none() -> Self {
|
pub(crate) fn none() -> Self {
|
||||||
Self {
|
Self {
|
||||||
tag: ParameterTag::None,
|
tag: ParameterTag::None,
|
||||||
decision_params: Default::default(),
|
decision_params: Default::default(),
|
||||||
branch_params: Default::default(),
|
branch_params: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn decision(decision_params: DecisionParameters) -> Self {
|
pub(crate) fn decision(decision_params: DecisionParameters) -> Self {
|
||||||
Self { tag: ParameterTag::Decision, decision_params, branch_params: Default::default() }
|
Self { tag: ParameterTag::Decision, decision_params, branch_params: Default::default() }
|
||||||
}
|
}
|
||||||
pub fn branch(branch_params: BranchParameters) -> Self {
|
pub(crate) fn branch(branch_params: BranchParameters) -> Self {
|
||||||
Self { tag: ParameterTag::Branch, decision_params: Default::default(), branch_params }
|
Self { tag: ParameterTag::Branch, decision_params: Default::default(), branch_params }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind};
|
|||||||
/// Holds all of the coverage mapping data associated with a function instance,
|
/// Holds all of the coverage mapping data associated with a function instance,
|
||||||
/// collected during traversal of `Coverage` statements in the function's MIR.
|
/// collected during traversal of `Coverage` statements in the function's MIR.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FunctionCoverageCollector<'tcx> {
|
pub(crate) struct FunctionCoverageCollector<'tcx> {
|
||||||
/// Coverage info that was attached to this function by the instrumentor.
|
/// Coverage info that was attached to this function by the instrumentor.
|
||||||
function_coverage_info: &'tcx FunctionCoverageInfo,
|
function_coverage_info: &'tcx FunctionCoverageInfo,
|
||||||
is_used: bool,
|
is_used: bool,
|
||||||
@ -32,7 +32,7 @@ pub struct FunctionCoverageCollector<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> FunctionCoverageCollector<'tcx> {
|
impl<'tcx> FunctionCoverageCollector<'tcx> {
|
||||||
/// Creates a new set of coverage data for a used (called) function.
|
/// Creates a new set of coverage data for a used (called) function.
|
||||||
pub fn new(
|
pub(crate) fn new(
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
function_coverage_info: &'tcx FunctionCoverageInfo,
|
function_coverage_info: &'tcx FunctionCoverageInfo,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -40,7 +40,7 @@ impl<'tcx> FunctionCoverageCollector<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new set of coverage data for an unused (never called) function.
|
/// Creates a new set of coverage data for an unused (never called) function.
|
||||||
pub fn unused(
|
pub(crate) fn unused(
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
function_coverage_info: &'tcx FunctionCoverageInfo,
|
function_coverage_info: &'tcx FunctionCoverageInfo,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -195,7 +195,7 @@ impl<'tcx> FunctionCoverage<'tcx> {
|
|||||||
|
|
||||||
/// Return the source hash, generated from the HIR node structure, and used to indicate whether
|
/// Return the source hash, generated from the HIR node structure, and used to indicate whether
|
||||||
/// or not the source code structure changed between different compilations.
|
/// or not the source code structure changed between different compilations.
|
||||||
pub fn source_hash(&self) -> u64 {
|
pub(crate) fn source_hash(&self) -> u64 {
|
||||||
if self.is_used { self.function_coverage_info.function_source_hash } else { 0 }
|
if self.is_used { self.function_coverage_info.function_source_hash } else { 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ use crate::{coverageinfo, llvm};
|
|||||||
/// implementing this Rust version, and though the format documentation is very explicit and
|
/// implementing this Rust version, and though the format documentation is very explicit and
|
||||||
/// detailed, some undocumented details in Clang's implementation (that may or may not be important)
|
/// detailed, some undocumented details in Clang's implementation (that may or may not be important)
|
||||||
/// were also replicated for Rust's Coverage Map.
|
/// were also replicated for Rust's Coverage Map.
|
||||||
pub fn finalize(cx: &CodegenCx<'_, '_>) {
|
pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) {
|
||||||
let tcx = cx.tcx;
|
let tcx = cx.tcx;
|
||||||
|
|
||||||
// Ensure that LLVM is using a version of the coverage mapping format that
|
// Ensure that LLVM is using a version of the coverage mapping format that
|
||||||
|
@ -22,10 +22,10 @@ use crate::llvm;
|
|||||||
|
|
||||||
pub(crate) mod ffi;
|
pub(crate) mod ffi;
|
||||||
pub(crate) mod map_data;
|
pub(crate) mod map_data;
|
||||||
pub mod mapgen;
|
mod mapgen;
|
||||||
|
|
||||||
/// A context object for maintaining all state needed by the coverageinfo module.
|
/// A context object for maintaining all state needed by the coverageinfo module.
|
||||||
pub struct CrateCoverageContext<'ll, 'tcx> {
|
pub(crate) struct CrateCoverageContext<'ll, 'tcx> {
|
||||||
/// Coverage data for each instrumented function identified by DefId.
|
/// Coverage data for each instrumented function identified by DefId.
|
||||||
pub(crate) function_coverage_map:
|
pub(crate) function_coverage_map:
|
||||||
RefCell<FxIndexMap<Instance<'tcx>, FunctionCoverageCollector<'tcx>>>,
|
RefCell<FxIndexMap<Instance<'tcx>, FunctionCoverageCollector<'tcx>>>,
|
||||||
@ -34,7 +34,7 @@ pub struct CrateCoverageContext<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'ll, 'tcx> CrateCoverageContext<'ll, 'tcx> {
|
impl<'ll, 'tcx> CrateCoverageContext<'ll, 'tcx> {
|
||||||
pub fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
function_coverage_map: Default::default(),
|
function_coverage_map: Default::default(),
|
||||||
pgo_func_name_var_map: Default::default(),
|
pgo_func_name_var_map: Default::default(),
|
||||||
@ -42,7 +42,7 @@ impl<'ll, 'tcx> CrateCoverageContext<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_function_coverage_map(
|
fn take_function_coverage_map(
|
||||||
&self,
|
&self,
|
||||||
) -> FxIndexMap<Instance<'tcx>, FunctionCoverageCollector<'tcx>> {
|
) -> FxIndexMap<Instance<'tcx>, FunctionCoverageCollector<'tcx>> {
|
||||||
self.function_coverage_map.replace(FxIndexMap::default())
|
self.function_coverage_map.replace(FxIndexMap::default())
|
||||||
|
@ -15,7 +15,7 @@ use crate::llvm::debuginfo::{DILocation, DIScope};
|
|||||||
|
|
||||||
/// Produces DIScope DIEs for each MIR Scope which has variables defined in it.
|
/// Produces DIScope DIEs for each MIR Scope which has variables defined in it.
|
||||||
// FIXME(eddyb) almost all of this should be in `rustc_codegen_ssa::mir::debuginfo`.
|
// FIXME(eddyb) almost all of this should be in `rustc_codegen_ssa::mir::debuginfo`.
|
||||||
pub fn compute_mir_scopes<'ll, 'tcx>(
|
pub(crate) fn compute_mir_scopes<'ll, 'tcx>(
|
||||||
cx: &CodegenCx<'ll, 'tcx>,
|
cx: &CodegenCx<'ll, 'tcx>,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
mir: &Body<'tcx>,
|
mir: &Body<'tcx>,
|
||||||
|
@ -16,7 +16,7 @@ use crate::value::Value;
|
|||||||
|
|
||||||
/// Inserts a side-effect free instruction sequence that makes sure that the
|
/// Inserts a side-effect free instruction sequence that makes sure that the
|
||||||
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
|
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
|
||||||
pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, '_, '_>) {
|
pub(crate) fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, '_, '_>) {
|
||||||
if needs_gdb_debug_scripts_section(bx) {
|
if needs_gdb_debug_scripts_section(bx) {
|
||||||
let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global(bx);
|
let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global(bx);
|
||||||
// Load just the first byte as that's all that's necessary to force
|
// Load just the first byte as that's all that's necessary to force
|
||||||
@ -30,7 +30,9 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_,
|
|||||||
|
|
||||||
/// Allocates the global variable responsible for the .debug_gdb_scripts binary
|
/// Allocates the global variable responsible for the .debug_gdb_scripts binary
|
||||||
/// section.
|
/// section.
|
||||||
pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll Value {
|
pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
|
||||||
|
cx: &CodegenCx<'ll, '_>,
|
||||||
|
) -> &'ll Value {
|
||||||
let c_section_var_name = c"__rustc_debug_gdb_scripts_section__";
|
let c_section_var_name = c"__rustc_debug_gdb_scripts_section__";
|
||||||
let section_var_name = c_section_var_name.to_str().unwrap();
|
let section_var_name = c_section_var_name.to_str().unwrap();
|
||||||
|
|
||||||
@ -82,7 +84,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
|
pub(crate) fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
|
||||||
let omit_gdb_pretty_printer_section =
|
let omit_gdb_pretty_printer_section =
|
||||||
attr::contains_name(cx.tcx.hir().krate_attrs(), sym::omit_gdb_pretty_printer_section);
|
attr::contains_name(cx.tcx.hir().krate_attrs(), sym::omit_gdb_pretty_printer_section);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ const NO_GENERICS: for<'ll> fn(&CodegenCx<'ll, '_>) -> SmallVec<&'ll DIType> = |
|
|||||||
|
|
||||||
// SmallVec is used quite a bit in this module, so create a shorthand.
|
// SmallVec is used quite a bit in this module, so create a shorthand.
|
||||||
// The actual number of elements is not so important.
|
// The actual number of elements is not so important.
|
||||||
pub type SmallVec<T> = smallvec::SmallVec<[T; 16]>;
|
type SmallVec<T> = smallvec::SmallVec<[T; 16]>;
|
||||||
|
|
||||||
mod enums;
|
mod enums;
|
||||||
mod type_map;
|
mod type_map;
|
||||||
@ -425,7 +425,7 @@ fn build_slice_type_di_node<'ll, 'tcx>(
|
|||||||
///
|
///
|
||||||
/// This function will look up the debuginfo node in the TypeMap. If it can't find it, it
|
/// This function will look up the debuginfo node in the TypeMap. If it can't find it, it
|
||||||
/// will create the node by dispatching to the corresponding `build_*_di_node()` function.
|
/// will create the node by dispatching to the corresponding `build_*_di_node()` function.
|
||||||
pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
pub(crate) fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
||||||
let unique_type_id = UniqueTypeId::for_ty(cx.tcx, t);
|
let unique_type_id = UniqueTypeId::for_ty(cx.tcx, t);
|
||||||
|
|
||||||
if let Some(existing_di_node) = debug_context(cx).type_map.di_node_for_unique_id(unique_type_id)
|
if let Some(existing_di_node) = debug_context(cx).type_map.di_node_for_unique_id(unique_type_id)
|
||||||
@ -531,7 +531,7 @@ fn hex_encode(data: &[u8]) -> String {
|
|||||||
hex_string
|
hex_string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll DIFile {
|
pub(crate) fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll DIFile {
|
||||||
let cache_key = Some((source_file.stable_id, source_file.src_hash));
|
let cache_key = Some((source_file.stable_id, source_file.src_hash));
|
||||||
return debug_context(cx)
|
return debug_context(cx)
|
||||||
.created_files
|
.created_files
|
||||||
@ -644,7 +644,7 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unknown_file_metadata<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
|
fn unknown_file_metadata<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
|
||||||
debug_context(cx).created_files.borrow_mut().entry(None).or_insert_with(|| unsafe {
|
debug_context(cx).created_files.borrow_mut().entry(None).or_insert_with(|| unsafe {
|
||||||
let file_name = "<unknown>";
|
let file_name = "<unknown>";
|
||||||
let directory = "";
|
let directory = "";
|
||||||
@ -859,7 +859,7 @@ fn build_param_type_di_node<'ll, 'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_compile_unit_di_node<'ll, 'tcx>(
|
pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
codegen_unit_name: &str,
|
codegen_unit_name: &str,
|
||||||
debug_context: &CodegenUnitDebugContext<'ll, 'tcx>,
|
debug_context: &CodegenUnitDebugContext<'ll, 'tcx>,
|
||||||
@ -1319,7 +1319,11 @@ fn build_generic_type_param_di_nodes<'ll, 'tcx>(
|
|||||||
/// Creates debug information for the given global variable.
|
/// Creates debug information for the given global variable.
|
||||||
///
|
///
|
||||||
/// Adds the created debuginfo nodes directly to the crate's IR.
|
/// Adds the created debuginfo nodes directly to the crate's IR.
|
||||||
pub fn build_global_var_di_node<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId, global: &'ll Value) {
|
pub(crate) fn build_global_var_di_node<'ll>(
|
||||||
|
cx: &CodegenCx<'ll, '_>,
|
||||||
|
def_id: DefId,
|
||||||
|
global: &'ll Value,
|
||||||
|
) {
|
||||||
if cx.dbg_cx.is_none() {
|
if cx.dbg_cx.is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1559,7 +1563,7 @@ pub(crate) fn apply_vcall_visibility_metadata<'ll, 'tcx>(
|
|||||||
/// given type.
|
/// given type.
|
||||||
///
|
///
|
||||||
/// Adds the created metadata nodes directly to the crate's IR.
|
/// Adds the created metadata nodes directly to the crate's IR.
|
||||||
pub fn create_vtable_di_node<'ll, 'tcx>(
|
pub(crate) fn create_vtable_di_node<'ll, 'tcx>(
|
||||||
cx: &CodegenCx<'ll, 'tcx>,
|
cx: &CodegenCx<'ll, 'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||||
@ -1604,7 +1608,7 @@ pub fn create_vtable_di_node<'ll, 'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an "extension" of an existing `DIScope` into another file.
|
/// Creates an "extension" of an existing `DIScope` into another file.
|
||||||
pub fn extend_scope_to_file<'ll>(
|
pub(crate) fn extend_scope_to_file<'ll>(
|
||||||
cx: &CodegenCx<'ll, '_>,
|
cx: &CodegenCx<'ll, '_>,
|
||||||
scope_metadata: &'ll DIScope,
|
scope_metadata: &'ll DIScope,
|
||||||
file: &SourceFile,
|
file: &SourceFile,
|
||||||
@ -1613,7 +1617,7 @@ pub fn extend_scope_to_file<'ll>(
|
|||||||
unsafe { llvm::LLVMRustDIBuilderCreateLexicalBlockFile(DIB(cx), scope_metadata, file_metadata) }
|
unsafe { llvm::LLVMRustDIBuilderCreateLexicalBlockFile(DIB(cx), scope_metadata, file_metadata) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tuple_field_name(field_index: usize) -> Cow<'static, str> {
|
fn tuple_field_name(field_index: usize) -> Cow<'static, str> {
|
||||||
const TUPLE_FIELD_NAMES: [&'static str; 16] = [
|
const TUPLE_FIELD_NAMES: [&'static str; 16] = [
|
||||||
"__0", "__1", "__2", "__3", "__4", "__5", "__6", "__7", "__8", "__9", "__10", "__11",
|
"__0", "__1", "__2", "__3", "__4", "__5", "__6", "__7", "__8", "__9", "__10", "__11",
|
||||||
"__12", "__13", "__14", "__15",
|
"__12", "__13", "__14", "__15",
|
||||||
|
@ -257,7 +257,7 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
|
|||||||
/// ---> DW_TAG_structure_type (type of variant 3)
|
/// ---> DW_TAG_structure_type (type of variant 3)
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
pub fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
|
fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
|
||||||
cx: &CodegenCx<'ll, 'tcx>,
|
cx: &CodegenCx<'ll, 'tcx>,
|
||||||
variant_index: VariantIdx,
|
variant_index: VariantIdx,
|
||||||
coroutine_type_and_layout: TyAndLayout<'tcx>,
|
coroutine_type_and_layout: TyAndLayout<'tcx>,
|
||||||
|
@ -22,7 +22,7 @@ mod private {
|
|||||||
// `UniqueTypeId` from being constructed directly, without asserting
|
// `UniqueTypeId` from being constructed directly, without asserting
|
||||||
// the preconditions.
|
// the preconditions.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, HashStable)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, HashStable)]
|
||||||
pub struct HiddenZst;
|
pub(crate) struct HiddenZst;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A unique identifier for anything that we create a debuginfo node for.
|
/// A unique identifier for anything that we create a debuginfo node for.
|
||||||
@ -48,17 +48,17 @@ pub(super) enum UniqueTypeId<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> UniqueTypeId<'tcx> {
|
impl<'tcx> UniqueTypeId<'tcx> {
|
||||||
pub fn for_ty(tcx: TyCtxt<'tcx>, t: Ty<'tcx>) -> Self {
|
pub(crate) fn for_ty(tcx: TyCtxt<'tcx>, t: Ty<'tcx>) -> Self {
|
||||||
assert_eq!(t, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t));
|
assert_eq!(t, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t));
|
||||||
UniqueTypeId::Ty(t, private::HiddenZst)
|
UniqueTypeId::Ty(t, private::HiddenZst)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_enum_variant_part(tcx: TyCtxt<'tcx>, enum_ty: Ty<'tcx>) -> Self {
|
pub(crate) fn for_enum_variant_part(tcx: TyCtxt<'tcx>, enum_ty: Ty<'tcx>) -> Self {
|
||||||
assert_eq!(enum_ty, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), enum_ty));
|
assert_eq!(enum_ty, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), enum_ty));
|
||||||
UniqueTypeId::VariantPart(enum_ty, private::HiddenZst)
|
UniqueTypeId::VariantPart(enum_ty, private::HiddenZst)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_enum_variant_struct_type(
|
pub(crate) fn for_enum_variant_struct_type(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
enum_ty: Ty<'tcx>,
|
enum_ty: Ty<'tcx>,
|
||||||
variant_idx: VariantIdx,
|
variant_idx: VariantIdx,
|
||||||
@ -67,7 +67,7 @@ impl<'tcx> UniqueTypeId<'tcx> {
|
|||||||
UniqueTypeId::VariantStructType(enum_ty, variant_idx, private::HiddenZst)
|
UniqueTypeId::VariantStructType(enum_ty, variant_idx, private::HiddenZst)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_enum_variant_struct_type_wrapper(
|
pub(crate) fn for_enum_variant_struct_type_wrapper(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
enum_ty: Ty<'tcx>,
|
enum_ty: Ty<'tcx>,
|
||||||
variant_idx: VariantIdx,
|
variant_idx: VariantIdx,
|
||||||
@ -76,7 +76,7 @@ impl<'tcx> UniqueTypeId<'tcx> {
|
|||||||
UniqueTypeId::VariantStructTypeCppLikeWrapper(enum_ty, variant_idx, private::HiddenZst)
|
UniqueTypeId::VariantStructTypeCppLikeWrapper(enum_ty, variant_idx, private::HiddenZst)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_vtable_ty(
|
pub(crate) fn for_vtable_ty(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
self_type: Ty<'tcx>,
|
self_type: Ty<'tcx>,
|
||||||
implemented_trait: Option<PolyExistentialTraitRef<'tcx>>,
|
implemented_trait: Option<PolyExistentialTraitRef<'tcx>>,
|
||||||
@ -93,7 +93,7 @@ impl<'tcx> UniqueTypeId<'tcx> {
|
|||||||
/// argument of the various `LLVMRustDIBuilderCreate*Type()` methods.
|
/// argument of the various `LLVMRustDIBuilderCreate*Type()` methods.
|
||||||
///
|
///
|
||||||
/// Right now this takes the form of a hex-encoded opaque hash value.
|
/// Right now this takes the form of a hex-encoded opaque hash value.
|
||||||
pub fn generate_unique_id_string(self, tcx: TyCtxt<'tcx>) -> String {
|
fn generate_unique_id_string(self, tcx: TyCtxt<'tcx>) -> String {
|
||||||
let mut hasher = StableHasher::new();
|
let mut hasher = StableHasher::new();
|
||||||
tcx.with_stable_hashing_context(|mut hcx| {
|
tcx.with_stable_hashing_context(|mut hcx| {
|
||||||
hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher))
|
hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher))
|
||||||
@ -101,7 +101,7 @@ impl<'tcx> UniqueTypeId<'tcx> {
|
|||||||
hasher.finish::<Fingerprint>().to_hex()
|
hasher.finish::<Fingerprint>().to_hex()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect_ty(self) -> Ty<'tcx> {
|
pub(crate) fn expect_ty(self) -> Ty<'tcx> {
|
||||||
match self {
|
match self {
|
||||||
UniqueTypeId::Ty(ty, _) => ty,
|
UniqueTypeId::Ty(ty, _) => ty,
|
||||||
_ => bug!("Expected `UniqueTypeId::Ty` but found `{:?}`", self),
|
_ => bug!("Expected `UniqueTypeId::Ty` but found `{:?}`", self),
|
||||||
@ -133,25 +133,25 @@ impl<'ll, 'tcx> TypeMap<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DINodeCreationResult<'ll> {
|
pub(crate) struct DINodeCreationResult<'ll> {
|
||||||
pub di_node: &'ll DIType,
|
pub di_node: &'ll DIType,
|
||||||
pub already_stored_in_typemap: bool,
|
pub already_stored_in_typemap: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ll> DINodeCreationResult<'ll> {
|
impl<'ll> DINodeCreationResult<'ll> {
|
||||||
pub fn new(di_node: &'ll DIType, already_stored_in_typemap: bool) -> Self {
|
pub(crate) fn new(di_node: &'ll DIType, already_stored_in_typemap: bool) -> Self {
|
||||||
DINodeCreationResult { di_node, already_stored_in_typemap }
|
DINodeCreationResult { di_node, already_stored_in_typemap }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
pub enum Stub<'ll> {
|
pub(crate) enum Stub<'ll> {
|
||||||
Struct,
|
Struct,
|
||||||
Union,
|
Union,
|
||||||
VTableTy { vtable_holder: &'ll DIType },
|
VTableTy { vtable_holder: &'ll DIType },
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StubInfo<'ll, 'tcx> {
|
pub(crate) struct StubInfo<'ll, 'tcx> {
|
||||||
metadata: &'ll DIType,
|
metadata: &'ll DIType,
|
||||||
unique_type_id: UniqueTypeId<'tcx>,
|
unique_type_id: UniqueTypeId<'tcx>,
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,13 @@ use crate::llvm::debuginfo::{
|
|||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
|
||||||
mod create_scope_map;
|
mod create_scope_map;
|
||||||
pub mod gdb;
|
mod gdb;
|
||||||
pub mod metadata;
|
pub(crate) mod metadata;
|
||||||
mod namespace;
|
mod namespace;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub use self::create_scope_map::compute_mir_scopes;
|
use self::create_scope_map::compute_mir_scopes;
|
||||||
pub use self::metadata::build_global_var_di_node;
|
pub(crate) use self::metadata::build_global_var_di_node;
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
const DW_TAG_auto_variable: c_uint = 0x100;
|
const DW_TAG_auto_variable: c_uint = 0x100;
|
||||||
@ -54,7 +54,7 @@ const DW_TAG_auto_variable: c_uint = 0x100;
|
|||||||
const DW_TAG_arg_variable: c_uint = 0x101;
|
const DW_TAG_arg_variable: c_uint = 0x101;
|
||||||
|
|
||||||
/// A context object for maintaining all state needed by the debuginfo module.
|
/// A context object for maintaining all state needed by the debuginfo module.
|
||||||
pub struct CodegenUnitDebugContext<'ll, 'tcx> {
|
pub(crate) struct CodegenUnitDebugContext<'ll, 'tcx> {
|
||||||
llcontext: &'ll llvm::Context,
|
llcontext: &'ll llvm::Context,
|
||||||
llmod: &'ll llvm::Module,
|
llmod: &'ll llvm::Module,
|
||||||
builder: &'ll mut DIBuilder<'ll>,
|
builder: &'ll mut DIBuilder<'ll>,
|
||||||
@ -74,7 +74,7 @@ impl Drop for CodegenUnitDebugContext<'_, '_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
|
impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
|
||||||
pub fn new(llmod: &'ll llvm::Module) -> Self {
|
pub(crate) fn new(llmod: &'ll llvm::Module) -> Self {
|
||||||
debug!("CodegenUnitDebugContext::new");
|
debug!("CodegenUnitDebugContext::new");
|
||||||
let builder = unsafe { llvm::LLVMRustDIBuilderCreate(llmod) };
|
let builder = unsafe { llvm::LLVMRustDIBuilderCreate(llmod) };
|
||||||
// DIBuilder inherits context from the module, so we'd better use the same one
|
// DIBuilder inherits context from the module, so we'd better use the same one
|
||||||
@ -90,7 +90,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finalize(&self, sess: &Session) {
|
pub(crate) fn finalize(&self, sess: &Session) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustDIBuilderFinalize(self.builder);
|
llvm::LLVMRustDIBuilderFinalize(self.builder);
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates any deferred debug metadata nodes
|
/// Creates any deferred debug metadata nodes
|
||||||
pub fn finalize(cx: &CodegenCx<'_, '_>) {
|
pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) {
|
||||||
if let Some(dbg_cx) = &cx.dbg_cx {
|
if let Some(dbg_cx) = &cx.dbg_cx {
|
||||||
debug!("finalize");
|
debug!("finalize");
|
||||||
|
|
||||||
@ -241,13 +241,13 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
|
|||||||
// FIXME(eddyb) rename this to better indicate it's a duplicate of
|
// FIXME(eddyb) rename this to better indicate it's a duplicate of
|
||||||
// `rustc_span::Loc` rather than `DILocation`, perhaps by making
|
// `rustc_span::Loc` rather than `DILocation`, perhaps by making
|
||||||
// `lookup_char_pos` return the right information instead.
|
// `lookup_char_pos` return the right information instead.
|
||||||
pub struct DebugLoc {
|
struct DebugLoc {
|
||||||
/// Information about the original source file.
|
/// Information about the original source file.
|
||||||
pub file: Lrc<SourceFile>,
|
file: Lrc<SourceFile>,
|
||||||
/// The (1-based) line number.
|
/// The (1-based) line number.
|
||||||
pub line: u32,
|
line: u32,
|
||||||
/// The (1-based) column number.
|
/// The (1-based) column number.
|
||||||
pub col: u32,
|
col: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CodegenCx<'_, '_> {
|
impl CodegenCx<'_, '_> {
|
||||||
@ -255,7 +255,7 @@ impl CodegenCx<'_, '_> {
|
|||||||
// FIXME(eddyb) rename this to better indicate it's a duplicate of
|
// FIXME(eddyb) rename this to better indicate it's a duplicate of
|
||||||
// `lookup_char_pos` rather than `dbg_loc`, perhaps by making
|
// `lookup_char_pos` rather than `dbg_loc`, perhaps by making
|
||||||
// `lookup_char_pos` return the right information instead.
|
// `lookup_char_pos` return the right information instead.
|
||||||
pub fn lookup_debug_loc(&self, pos: BytePos) -> DebugLoc {
|
fn lookup_debug_loc(&self, pos: BytePos) -> DebugLoc {
|
||||||
let (file, line, col) = match self.sess().source_map().lookup_line(pos) {
|
let (file, line, col) = match self.sess().source_map().lookup_line(pos) {
|
||||||
Ok(SourceFileAndLine { sf: file, line }) => {
|
Ok(SourceFileAndLine { sf: file, line }) => {
|
||||||
let line_pos = file.lines()[line];
|
let line_pos = file.lines()[line];
|
||||||
|
@ -9,7 +9,7 @@ use crate::common::CodegenCx;
|
|||||||
use crate::llvm;
|
use crate::llvm;
|
||||||
use crate::llvm::debuginfo::DIScope;
|
use crate::llvm::debuginfo::DIScope;
|
||||||
|
|
||||||
pub fn mangled_name_of_instance<'a, 'tcx>(
|
pub(crate) fn mangled_name_of_instance<'a, 'tcx>(
|
||||||
cx: &CodegenCx<'a, 'tcx>,
|
cx: &CodegenCx<'a, 'tcx>,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
) -> ty::SymbolName<'tcx> {
|
) -> ty::SymbolName<'tcx> {
|
||||||
@ -17,7 +17,7 @@ pub fn mangled_name_of_instance<'a, 'tcx>(
|
|||||||
tcx.symbol_name(instance)
|
tcx.symbol_name(instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn item_namespace<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
pub(crate) fn item_namespace<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
||||||
if let Some(&scope) = debug_context(cx).namespace_map.borrow().get(&def_id) {
|
if let Some(&scope) = debug_context(cx).namespace_map.borrow().get(&def_id) {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use crate::common::CodegenCx;
|
|||||||
use crate::llvm;
|
use crate::llvm;
|
||||||
use crate::llvm::debuginfo::{DIArray, DIBuilder, DIDescriptor, DIScope};
|
use crate::llvm::debuginfo::{DIArray, DIBuilder, DIDescriptor, DIScope};
|
||||||
|
|
||||||
pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool {
|
pub(crate) fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool {
|
||||||
// The is_local_to_unit flag indicates whether a function is local to the
|
// The is_local_to_unit flag indicates whether a function is local to the
|
||||||
// current compilation unit (i.e., if it is *static* in the C-sense). The
|
// current compilation unit (i.e., if it is *static* in the C-sense). The
|
||||||
// *reachable* set should provide a good approximation of this, as it
|
// *reachable* set should provide a good approximation of this, as it
|
||||||
@ -24,7 +24,7 @@ pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn create_DIArray<'ll>(
|
pub(crate) fn create_DIArray<'ll>(
|
||||||
builder: &DIBuilder<'ll>,
|
builder: &DIBuilder<'ll>,
|
||||||
arr: &[Option<&'ll DIDescriptor>],
|
arr: &[Option<&'ll DIDescriptor>],
|
||||||
) -> &'ll DIArray {
|
) -> &'ll DIArray {
|
||||||
@ -32,7 +32,7 @@ pub fn create_DIArray<'ll>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn debug_context<'a, 'll, 'tcx>(
|
pub(crate) fn debug_context<'a, 'll, 'tcx>(
|
||||||
cx: &'a CodegenCx<'ll, 'tcx>,
|
cx: &'a CodegenCx<'ll, 'tcx>,
|
||||||
) -> &'a CodegenUnitDebugContext<'ll, 'tcx> {
|
) -> &'a CodegenUnitDebugContext<'ll, 'tcx> {
|
||||||
cx.dbg_cx.as_ref().unwrap()
|
cx.dbg_cx.as_ref().unwrap()
|
||||||
@ -40,11 +40,11 @@ pub fn debug_context<'a, 'll, 'tcx>(
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn DIB<'a, 'll>(cx: &'a CodegenCx<'ll, '_>) -> &'a DIBuilder<'ll> {
|
pub(crate) fn DIB<'a, 'll>(cx: &'a CodegenCx<'ll, '_>) -> &'a DIBuilder<'ll> {
|
||||||
cx.dbg_cx.as_ref().unwrap().builder
|
cx.dbg_cx.as_ref().unwrap().builder
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_namespace_for_item<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
pub(crate) fn get_namespace_for_item<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
||||||
item_namespace(cx, cx.tcx.parent(def_id))
|
item_namespace(cx, cx.tcx.parent(def_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||||||
///
|
///
|
||||||
/// If there’s a value with the same name already declared, the function will
|
/// If there’s a value with the same name already declared, the function will
|
||||||
/// return its Value instead.
|
/// return its Value instead.
|
||||||
pub fn declare_global(&self, name: &str, ty: &'ll Type) -> &'ll Value {
|
pub(crate) fn declare_global(&self, name: &str, ty: &'ll Type) -> &'ll Value {
|
||||||
debug!("declare_global(name={:?})", name);
|
debug!("declare_global(name={:?})", name);
|
||||||
unsafe { llvm::LLVMRustGetOrInsertGlobal(self.llmod, name.as_ptr().cast(), name.len(), ty) }
|
unsafe { llvm::LLVMRustGetOrInsertGlobal(self.llmod, name.as_ptr().cast(), name.len(), ty) }
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||||||
///
|
///
|
||||||
/// If there’s a value with the same name already declared, the function will
|
/// If there’s a value with the same name already declared, the function will
|
||||||
/// update the declaration and return existing Value instead.
|
/// update the declaration and return existing Value instead.
|
||||||
pub fn declare_cfn(
|
pub(crate) fn declare_cfn(
|
||||||
&self,
|
&self,
|
||||||
name: &str,
|
name: &str,
|
||||||
unnamed: llvm::UnnamedAddr,
|
unnamed: llvm::UnnamedAddr,
|
||||||
@ -100,7 +100,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||||||
///
|
///
|
||||||
/// If there’s a value with the same name already declared, the function will
|
/// If there’s a value with the same name already declared, the function will
|
||||||
/// update the declaration and return existing Value instead.
|
/// update the declaration and return existing Value instead.
|
||||||
pub fn declare_entry_fn(
|
pub(crate) fn declare_entry_fn(
|
||||||
&self,
|
&self,
|
||||||
name: &str,
|
name: &str,
|
||||||
callconv: llvm::CallConv,
|
callconv: llvm::CallConv,
|
||||||
@ -119,7 +119,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||||||
///
|
///
|
||||||
/// If there’s a value with the same name already declared, the function will
|
/// If there’s a value with the same name already declared, the function will
|
||||||
/// update the declaration and return existing Value instead.
|
/// update the declaration and return existing Value instead.
|
||||||
pub fn declare_fn(
|
pub(crate) fn declare_fn(
|
||||||
&self,
|
&self,
|
||||||
name: &str,
|
name: &str,
|
||||||
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||||
@ -199,7 +199,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||||||
/// return `None` if the name already has a definition associated with it. In that
|
/// return `None` if the name already has a definition associated with it. In that
|
||||||
/// case an error should be reported to the user, because it usually happens due
|
/// case an error should be reported to the user, because it usually happens due
|
||||||
/// to user’s fault (e.g., misuse of `#[no_mangle]` or `#[export_name]` attributes).
|
/// to user’s fault (e.g., misuse of `#[no_mangle]` or `#[export_name]` attributes).
|
||||||
pub fn define_global(&self, name: &str, ty: &'ll Type) -> Option<&'ll Value> {
|
pub(crate) fn define_global(&self, name: &str, ty: &'ll Type) -> Option<&'ll Value> {
|
||||||
if self.get_defined_value(name).is_some() {
|
if self.get_defined_value(name).is_some() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
@ -210,19 +210,19 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||||||
/// Declare a private global
|
/// Declare a private global
|
||||||
///
|
///
|
||||||
/// Use this function when you intend to define a global without a name.
|
/// Use this function when you intend to define a global without a name.
|
||||||
pub fn define_private_global(&self, ty: &'ll Type) -> &'ll Value {
|
pub(crate) fn define_private_global(&self, ty: &'ll Type) -> &'ll Value {
|
||||||
unsafe { llvm::LLVMRustInsertPrivateGlobal(self.llmod, ty) }
|
unsafe { llvm::LLVMRustInsertPrivateGlobal(self.llmod, ty) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets declared value by name.
|
/// Gets declared value by name.
|
||||||
pub fn get_declared_value(&self, name: &str) -> Option<&'ll Value> {
|
pub(crate) fn get_declared_value(&self, name: &str) -> Option<&'ll Value> {
|
||||||
debug!("get_declared_value(name={:?})", name);
|
debug!("get_declared_value(name={:?})", name);
|
||||||
unsafe { llvm::LLVMRustGetNamedValue(self.llmod, name.as_ptr().cast(), name.len()) }
|
unsafe { llvm::LLVMRustGetNamedValue(self.llmod, name.as_ptr().cast(), name.len()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets defined or externally defined (AvailableExternally linkage) value by
|
/// Gets defined or externally defined (AvailableExternally linkage) value by
|
||||||
/// name.
|
/// name.
|
||||||
pub fn get_defined_value(&self, name: &str) -> Option<&'ll Value> {
|
pub(crate) fn get_defined_value(&self, name: &str) -> Option<&'ll Value> {
|
||||||
self.get_declared_value(name).and_then(|val| {
|
self.get_declared_value(name).and_then(|val| {
|
||||||
let declaration = unsafe { llvm::LLVMIsDeclaration(val) != 0 };
|
let declaration = unsafe { llvm::LLVMIsDeclaration(val) != 0 };
|
||||||
if !declaration { Some(val) } else { None }
|
if !declaration { Some(val) } else { None }
|
||||||
|
@ -207,13 +207,13 @@ pub(crate) struct CopyBitcode {
|
|||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_llvm_unknown_debuginfo_compression)]
|
#[diag(codegen_llvm_unknown_debuginfo_compression)]
|
||||||
pub struct UnknownCompression {
|
pub(crate) struct UnknownCompression {
|
||||||
pub algorithm: &'static str,
|
pub algorithm: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(codegen_llvm_mismatch_data_layout)]
|
#[diag(codegen_llvm_mismatch_data_layout)]
|
||||||
pub struct MismatchedDataLayout<'a> {
|
pub(crate) struct MismatchedDataLayout<'a> {
|
||||||
pub rustc_target: &'a str,
|
pub rustc_target: &'a str,
|
||||||
pub rustc_layout: &'a str,
|
pub rustc_layout: &'a str,
|
||||||
pub llvm_target: &'a str,
|
pub llvm_target: &'a str,
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#![feature(iter_intersperse)]
|
#![feature(iter_intersperse)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
@ -45,11 +46,11 @@ use rustc_session::Session;
|
|||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
|
||||||
mod back {
|
mod back {
|
||||||
pub mod archive;
|
pub(crate) mod archive;
|
||||||
pub mod lto;
|
pub(crate) mod lto;
|
||||||
pub mod owned_target_machine;
|
pub(crate) mod owned_target_machine;
|
||||||
mod profiling;
|
mod profiling;
|
||||||
pub mod write;
|
pub(crate) mod write;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod abi;
|
mod abi;
|
||||||
|
@ -136,14 +136,14 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||||||
unsafe { llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr()) };
|
unsafe { llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn time_trace_profiler_finish(file_name: &Path) {
|
pub(crate) fn time_trace_profiler_finish(file_name: &Path) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let file_name = path_to_c_string(file_name);
|
let file_name = path_to_c_string(file_name);
|
||||||
llvm::LLVMRustTimeTraceProfilerFinish(file_name.as_ptr());
|
llvm::LLVMRustTimeTraceProfilerFinish(file_name.as_ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum TargetFeatureFoldStrength<'a> {
|
enum TargetFeatureFoldStrength<'a> {
|
||||||
// The feature is only tied when enabling the feature, disabling
|
// The feature is only tied when enabling the feature, disabling
|
||||||
// this feature shouldn't disable the tied feature.
|
// this feature shouldn't disable the tied feature.
|
||||||
EnableOnly(&'a str),
|
EnableOnly(&'a str),
|
||||||
@ -160,28 +160,28 @@ impl<'a> TargetFeatureFoldStrength<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LLVMFeature<'a> {
|
pub(crate) struct LLVMFeature<'a> {
|
||||||
pub llvm_feature_name: &'a str,
|
llvm_feature_name: &'a str,
|
||||||
pub dependency: Option<TargetFeatureFoldStrength<'a>>,
|
dependency: Option<TargetFeatureFoldStrength<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> LLVMFeature<'a> {
|
impl<'a> LLVMFeature<'a> {
|
||||||
pub fn new(llvm_feature_name: &'a str) -> Self {
|
fn new(llvm_feature_name: &'a str) -> Self {
|
||||||
Self { llvm_feature_name, dependency: None }
|
Self { llvm_feature_name, dependency: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_dependency(
|
fn with_dependency(
|
||||||
llvm_feature_name: &'a str,
|
llvm_feature_name: &'a str,
|
||||||
dependency: TargetFeatureFoldStrength<'a>,
|
dependency: TargetFeatureFoldStrength<'a>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { llvm_feature_name, dependency: Some(dependency) }
|
Self { llvm_feature_name, dependency: Some(dependency) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn contains(&self, feat: &str) -> bool {
|
fn contains(&self, feat: &str) -> bool {
|
||||||
self.iter().any(|dep| dep == feat)
|
self.iter().any(|dep| dep == feat)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&'a self) -> impl Iterator<Item = &'a str> {
|
fn iter(&'a self) -> impl Iterator<Item = &'a str> {
|
||||||
let dependencies = self.dependency.iter().map(|feat| feat.as_str());
|
let dependencies = self.dependency.iter().map(|feat| feat.as_str());
|
||||||
std::iter::once(self.llvm_feature_name).chain(dependencies)
|
std::iter::once(self.llvm_feature_name).chain(dependencies)
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
|
|||||||
// Though note that Rust can also be build with an external precompiled version of LLVM
|
// Though note that Rust can also be build with an external precompiled version of LLVM
|
||||||
// which might lead to failures if the oldest tested / supported LLVM version
|
// which might lead to failures if the oldest tested / supported LLVM version
|
||||||
// doesn't yet support the relevant intrinsics
|
// doesn't yet support the relevant intrinsics
|
||||||
pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
|
pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
|
||||||
let arch = if sess.target.arch == "x86_64" {
|
let arch = if sess.target.arch == "x86_64" {
|
||||||
"x86"
|
"x86"
|
||||||
} else if sess.target.arch == "arm64ec" {
|
} else if sess.target.arch == "arm64ec" {
|
||||||
@ -257,7 +257,7 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
|
|||||||
|
|
||||||
/// Given a map from target_features to whether they are enabled or disabled,
|
/// Given a map from target_features to whether they are enabled or disabled,
|
||||||
/// ensure only valid combinations are allowed.
|
/// ensure only valid combinations are allowed.
|
||||||
pub fn check_tied_features(
|
pub(crate) fn check_tied_features(
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
features: &FxHashMap<&str, bool>,
|
features: &FxHashMap<&str, bool>,
|
||||||
) -> Option<&'static [&'static str]> {
|
) -> Option<&'static [&'static str]> {
|
||||||
@ -337,19 +337,19 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_version() {
|
pub(crate) fn print_version() {
|
||||||
let (major, minor, patch) = get_version();
|
let (major, minor, patch) = get_version();
|
||||||
println!("LLVM version: {major}.{minor}.{patch}");
|
println!("LLVM version: {major}.{minor}.{patch}");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_version() -> (u32, u32, u32) {
|
pub(crate) fn get_version() -> (u32, u32, u32) {
|
||||||
// Can be called without initializing LLVM
|
// Can be called without initializing LLVM
|
||||||
unsafe {
|
unsafe {
|
||||||
(llvm::LLVMRustVersionMajor(), llvm::LLVMRustVersionMinor(), llvm::LLVMRustVersionPatch())
|
(llvm::LLVMRustVersionMajor(), llvm::LLVMRustVersionMinor(), llvm::LLVMRustVersionPatch())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_passes() {
|
pub(crate) fn print_passes() {
|
||||||
// Can be called without initializing LLVM
|
// Can be called without initializing LLVM
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustPrintPasses();
|
llvm::LLVMRustPrintPasses();
|
||||||
@ -479,7 +479,7 @@ fn handle_native(name: &str) -> &str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_cpu(sess: &Session) -> &str {
|
pub(crate) fn target_cpu(sess: &Session) -> &str {
|
||||||
match sess.opts.cg.target_cpu {
|
match sess.opts.cg.target_cpu {
|
||||||
Some(ref name) => handle_native(name),
|
Some(ref name) => handle_native(name),
|
||||||
None => handle_native(sess.target.cpu.as_ref()),
|
None => handle_native(sess.target.cpu.as_ref()),
|
||||||
@ -699,7 +699,7 @@ fn backend_feature_name<'a>(sess: &Session, s: &'a str) -> Option<&'a str> {
|
|||||||
Some(feature)
|
Some(feature)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tune_cpu(sess: &Session) -> Option<&str> {
|
pub(crate) fn tune_cpu(sess: &Session) -> Option<&str> {
|
||||||
let name = sess.opts.unstable_opts.tune_cpu.as_ref()?;
|
let name = sess.opts.unstable_opts.tune_cpu.as_ref()?;
|
||||||
Some(handle_native(name))
|
Some(handle_native(name))
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ use rustc_target::abi::{AddressSpace, Align, Integer, Size};
|
|||||||
|
|
||||||
use crate::abi::{FnAbiLlvmExt, LlvmType};
|
use crate::abi::{FnAbiLlvmExt, LlvmType};
|
||||||
use crate::context::CodegenCx;
|
use crate::context::CodegenCx;
|
||||||
pub use crate::llvm::Type;
|
pub(crate) use crate::llvm::Type;
|
||||||
use crate::llvm::{Bool, False, True};
|
use crate::llvm::{Bool, False, True};
|
||||||
use crate::type_of::LayoutLlvmExt;
|
use crate::type_of::LayoutLlvmExt;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
@ -139,21 +139,21 @@ fn struct_llfields<'a, 'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
|
impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
|
||||||
pub fn align_of(&self, ty: Ty<'tcx>) -> Align {
|
pub(crate) fn align_of(&self, ty: Ty<'tcx>) -> Align {
|
||||||
self.layout_of(ty).align.abi
|
self.layout_of(ty).align.abi
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size_of(&self, ty: Ty<'tcx>) -> Size {
|
pub(crate) fn size_of(&self, ty: Ty<'tcx>) -> Size {
|
||||||
self.layout_of(ty).size
|
self.layout_of(ty).size
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size_and_align_of(&self, ty: Ty<'tcx>) -> (Size, Align) {
|
pub(crate) fn size_and_align_of(&self, ty: Ty<'tcx>) -> (Size, Align) {
|
||||||
let layout = self.layout_of(ty);
|
let layout = self.layout_of(ty);
|
||||||
(layout.size, layout.align.abi)
|
(layout.size, layout.align.abi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LayoutLlvmExt<'tcx> {
|
pub(crate) trait LayoutLlvmExt<'tcx> {
|
||||||
fn is_llvm_immediate(&self) -> bool;
|
fn is_llvm_immediate(&self) -> bool;
|
||||||
fn is_llvm_scalar_pair(&self) -> bool;
|
fn is_llvm_scalar_pair(&self) -> bool;
|
||||||
fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type;
|
fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type;
|
||||||
|
@ -2,7 +2,7 @@ use std::hash::{Hash, Hasher};
|
|||||||
use std::{fmt, ptr};
|
use std::{fmt, ptr};
|
||||||
|
|
||||||
use crate::llvm;
|
use crate::llvm;
|
||||||
pub use crate::llvm::Value;
|
pub(crate) use crate::llvm::Value;
|
||||||
|
|
||||||
impl PartialEq for Value {
|
impl PartialEq for Value {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
@ -1207,7 +1207,7 @@ mod win {
|
|||||||
|
|
||||||
/// Get the Windows system OEM code page. This is most notably the code page
|
/// Get the Windows system OEM code page. This is most notably the code page
|
||||||
/// used for link.exe's output.
|
/// used for link.exe's output.
|
||||||
pub fn oem_code_page() -> u32 {
|
pub(super) fn oem_code_page() -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut cp: u32 = 0;
|
let mut cp: u32 = 0;
|
||||||
// We're using the `LOCALE_RETURN_NUMBER` flag to return a u32.
|
// We're using the `LOCALE_RETURN_NUMBER` flag to return a u32.
|
||||||
@ -1230,7 +1230,7 @@ mod win {
|
|||||||
///
|
///
|
||||||
/// It will fail if the multi-byte string is longer than `i32::MAX` or if it contains
|
/// It will fail if the multi-byte string is longer than `i32::MAX` or if it contains
|
||||||
/// any invalid bytes for the expected encoding.
|
/// any invalid bytes for the expected encoding.
|
||||||
pub fn locale_byte_str_to_string(s: &[u8], code_page: u32) -> Option<String> {
|
pub(super) fn locale_byte_str_to_string(s: &[u8], code_page: u32) -> Option<String> {
|
||||||
// `MultiByteToWideChar` requires a length to be a "positive integer".
|
// `MultiByteToWideChar` requires a length to be a "positive integer".
|
||||||
if s.len() > isize::MAX as usize {
|
if s.len() > isize::MAX as usize {
|
||||||
return None;
|
return None;
|
||||||
|
@ -754,7 +754,7 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<B: WriteBackendMethods> WorkItem<B> {
|
impl<B: WriteBackendMethods> WorkItem<B> {
|
||||||
pub fn module_kind(&self) -> ModuleKind {
|
fn module_kind(&self) -> ModuleKind {
|
||||||
match *self {
|
match *self {
|
||||||
WorkItem::Optimize(ref m) => m.kind,
|
WorkItem::Optimize(ref m) => m.kind,
|
||||||
WorkItem::CopyPostLtoArtifacts(_) | WorkItem::LTO(_) => ModuleKind::Regular,
|
WorkItem::CopyPostLtoArtifacts(_) | WorkItem::LTO(_) => ModuleKind::Regular,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#![feature(rustdoc_internals)]
|
#![feature(rustdoc_internals)]
|
||||||
#![feature(strict_provenance)]
|
#![feature(strict_provenance)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
|
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
|
||||||
|
@ -13,7 +13,7 @@ use tracing::debug;
|
|||||||
use super::FunctionCx;
|
use super::FunctionCx;
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
||||||
pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub(crate) fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
fx: &FunctionCx<'a, 'tcx, Bx>,
|
fx: &FunctionCx<'a, 'tcx, Bx>,
|
||||||
) -> BitSet<mir::Local> {
|
) -> BitSet<mir::Local> {
|
||||||
let mir = fx.mir;
|
let mir = fx.mir;
|
||||||
@ -251,14 +251,14 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum CleanupKind {
|
pub(crate) enum CleanupKind {
|
||||||
NotCleanup,
|
NotCleanup,
|
||||||
Funclet,
|
Funclet,
|
||||||
Internal { funclet: mir::BasicBlock },
|
Internal { funclet: mir::BasicBlock },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CleanupKind {
|
impl CleanupKind {
|
||||||
pub fn funclet_bb(self, for_bb: mir::BasicBlock) -> Option<mir::BasicBlock> {
|
pub(crate) fn funclet_bb(self, for_bb: mir::BasicBlock) -> Option<mir::BasicBlock> {
|
||||||
match self {
|
match self {
|
||||||
CleanupKind::NotCleanup => None,
|
CleanupKind::NotCleanup => None,
|
||||||
CleanupKind::Funclet => Some(for_bb),
|
CleanupKind::Funclet => Some(for_bb),
|
||||||
@ -270,7 +270,7 @@ impl CleanupKind {
|
|||||||
/// MSVC requires unwinding code to be split to a tree of *funclets*, where each funclet can only
|
/// MSVC requires unwinding code to be split to a tree of *funclets*, where each funclet can only
|
||||||
/// branch to itself or to its parent. Luckily, the code we generates matches this pattern.
|
/// branch to itself or to its parent. Luckily, the code we generates matches this pattern.
|
||||||
/// Recover that structure in an analyze pass.
|
/// Recover that structure in an analyze pass.
|
||||||
pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
|
pub(crate) fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
|
||||||
fn discover_masters<'tcx>(
|
fn discover_masters<'tcx>(
|
||||||
result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
|
result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
|
||||||
mir: &mir::Body<'tcx>,
|
mir: &mir::Body<'tcx>,
|
||||||
|
Loading…
Reference in New Issue
Block a user