Rollup merge of #129648 - nnethercote:unreachable_pub-2, r=Urgau

More `unreachable_pub`

Add `unreachable_pub` checking to some more compiler crates. A follow-up to #126013.

r? ``@Urgau``
This commit is contained in:
Matthias Krüger 2024-08-27 18:59:29 +02:00 committed by GitHub
commit 489eb230dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
112 changed files with 743 additions and 703 deletions

View File

@ -16,6 +16,7 @@
#![feature(panic_update_hook)]
#![feature(result_flattening)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::cmp::max;

View File

@ -6,6 +6,7 @@
#![deny(rustdoc::invalid_codeblock_attributes)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
// This higher-order macro defines the error codes that are in use. It is used

View File

@ -4,6 +4,7 @@
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![feature(type_alias_impl_trait)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::borrow::Cow;

View File

@ -204,7 +204,7 @@ pub trait LintDiagnostic<'a, G: EmissionGuarantee> {
}
#[derive(Clone, Debug, Encodable, Decodable)]
pub struct DiagLocation {
pub(crate) struct DiagLocation {
file: Cow<'static, str>,
line: u32,
col: u32,

View File

@ -2387,7 +2387,7 @@ enum DisplaySuggestion {
impl FileWithAnnotatedLines {
/// Preprocess all the annotations so that they are grouped by file and by line number
/// This helps us quickly iterate over the whole message (including secondary file spans)
pub fn collect_annotations(
pub(crate) fn collect_annotations(
emitter: &dyn Emitter,
args: &FluentArgs<'_>,
msp: &MultiSpan,

View File

@ -25,6 +25,7 @@
#![feature(trait_alias)]
#![feature(try_blocks)]
#![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
extern crate self as rustc_errors;
@ -1701,7 +1702,7 @@ impl DiagCtxtInner {
}
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
pub fn eagerly_translate<'a>(
fn eagerly_translate<'a>(
&self,
message: DiagMessage,
args: impl Iterator<Item = DiagArg<'a>>,
@ -1710,7 +1711,7 @@ impl DiagCtxtInner {
}
/// Translate `message` eagerly with `args` to `String`.
pub fn eagerly_translate_to_string<'a>(
fn eagerly_translate_to_string<'a>(
&self,
message: DiagMessage,
args: impl Iterator<Item = DiagArg<'a>>,

View File

@ -12,7 +12,7 @@
use std::any::Any;
#[cfg(windows)]
pub fn acquire_global_lock(name: &str) -> Box<dyn Any> {
pub(crate) fn acquire_global_lock(name: &str) -> Box<dyn Any> {
use std::ffi::CString;
use std::io;
@ -80,6 +80,6 @@ pub fn acquire_global_lock(name: &str) -> Box<dyn Any> {
}
#[cfg(not(windows))]
pub fn acquire_global_lock(_name: &str) -> Box<dyn Any> {
pub(crate) fn acquire_global_lock(_name: &str) -> Box<dyn Any> {
Box::new(())
}

View File

@ -74,7 +74,7 @@ enum ParseOpt {
}
/// Parse a buffer
pub fn entrypoint(txt: &str) -> MdStream<'_> {
pub(crate) fn entrypoint(txt: &str) -> MdStream<'_> {
let ctx = Context { top_block: true, prev: Prev::Newline };
normalize(parse_recursive(txt.trim().as_bytes(), ctx), &mut Vec::new())
}

View File

@ -15,7 +15,7 @@ thread_local! {
}
/// Print to terminal output to a buffer
pub fn entrypoint(stream: &MdStream<'_>, buf: &mut Buffer) -> io::Result<()> {
pub(crate) fn entrypoint(stream: &MdStream<'_>, buf: &mut Buffer) -> io::Result<()> {
#[cfg(not(test))]
if let Some((w, _)) = termize::dimensions() {
WIDTH.with(|c| c.set(std::cmp::min(w, DEFAULT_COLUMN_WIDTH)));
@ -47,7 +47,7 @@ fn write_stream(
Ok(())
}
pub fn write_tt(tt: &MdTree<'_>, buf: &mut Buffer, indent: usize) -> io::Result<()> {
fn write_tt(tt: &MdTree<'_>, buf: &mut Buffer, indent: usize) -> io::Result<()> {
match tt {
MdTree::CodeBlock { txt, lang: _ } => {
buf.set_color(ColorSpec::new().set_dimmed(true))?;

View File

@ -5,13 +5,13 @@ use rustc_macros::{Decodable, Encodable};
use crate::{Level, Loc};
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub struct Line {
pub(crate) struct Line {
pub line_index: usize,
pub annotations: Vec<Annotation>,
}
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Default)]
pub struct AnnotationColumn {
pub(crate) struct AnnotationColumn {
/// the (0-indexed) column for *display* purposes, counted in characters, not utf-8 bytes
pub display: usize,
/// the (0-indexed) column in the file, counted in characters, not utf-8 bytes.
@ -31,13 +31,13 @@ pub struct AnnotationColumn {
}
impl AnnotationColumn {
pub fn from_loc(loc: &Loc) -> AnnotationColumn {
pub(crate) fn from_loc(loc: &Loc) -> AnnotationColumn {
AnnotationColumn { display: loc.col_display, file: loc.col.0 }
}
}
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub struct MultilineAnnotation {
pub(crate) struct MultilineAnnotation {
pub depth: usize,
pub line_start: usize,
pub line_end: usize,
@ -49,19 +49,19 @@ pub struct MultilineAnnotation {
}
impl MultilineAnnotation {
pub fn increase_depth(&mut self) {
pub(crate) fn increase_depth(&mut self) {
self.depth += 1;
}
/// Compare two `MultilineAnnotation`s considering only the `Span` they cover.
pub fn same_span(&self, other: &MultilineAnnotation) -> bool {
pub(crate) fn same_span(&self, other: &MultilineAnnotation) -> bool {
self.line_start == other.line_start
&& self.line_end == other.line_end
&& self.start_col == other.start_col
&& self.end_col == other.end_col
}
pub fn as_start(&self) -> Annotation {
pub(crate) fn as_start(&self) -> Annotation {
Annotation {
start_col: self.start_col,
end_col: AnnotationColumn {
@ -76,7 +76,7 @@ impl MultilineAnnotation {
}
}
pub fn as_end(&self) -> Annotation {
pub(crate) fn as_end(&self) -> Annotation {
Annotation {
start_col: AnnotationColumn {
// these might not correspond to the same place anymore,
@ -91,7 +91,7 @@ impl MultilineAnnotation {
}
}
pub fn as_line(&self) -> Annotation {
pub(crate) fn as_line(&self) -> Annotation {
Annotation {
start_col: Default::default(),
end_col: Default::default(),
@ -103,7 +103,7 @@ impl MultilineAnnotation {
}
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub enum AnnotationType {
pub(crate) enum AnnotationType {
/// Annotation under a single line of code
Singleline,
@ -129,7 +129,7 @@ pub enum AnnotationType {
}
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub struct Annotation {
pub(crate) struct Annotation {
/// Start column.
/// Note that it is important that this field goes
/// first, so that when we sort, we sort orderings by start
@ -152,12 +152,12 @@ pub struct Annotation {
impl Annotation {
/// Whether this annotation is a vertical line placeholder.
pub fn is_line(&self) -> bool {
pub(crate) fn is_line(&self) -> bool {
matches!(self.annotation_type, AnnotationType::MultilineLine(_))
}
/// Length of this annotation as displayed in the stderr output
pub fn len(&self) -> usize {
pub(crate) fn len(&self) -> usize {
// Account for usize underflows
if self.end_col.display > self.start_col.display {
self.end_col.display - self.start_col.display
@ -166,7 +166,7 @@ impl Annotation {
}
}
pub fn has_label(&self) -> bool {
pub(crate) fn has_label(&self) -> bool {
if let Some(ref label) = self.label {
// Consider labels with no text as effectively not being there
// to avoid weird output with unnecessary vertical lines, like:
@ -184,7 +184,7 @@ impl Annotation {
}
}
pub fn takes_space(&self) -> bool {
pub(crate) fn takes_space(&self) -> bool {
// Multiline annotations always have to keep vertical space.
matches!(
self.annotation_type,
@ -194,7 +194,7 @@ impl Annotation {
}
#[derive(Debug)]
pub struct StyledString {
pub(crate) struct StyledString {
pub text: String,
pub style: Style,
}

View File

@ -3,7 +3,7 @@
use crate::snippet::{Style, StyledString};
#[derive(Debug)]
pub struct StyledBuffer {
pub(crate) struct StyledBuffer {
lines: Vec<Vec<StyledChar>>,
}
@ -22,12 +22,12 @@ impl StyledChar {
}
impl StyledBuffer {
pub fn new() -> StyledBuffer {
pub(crate) fn new() -> StyledBuffer {
StyledBuffer { lines: vec![] }
}
/// Returns content of `StyledBuffer` split by lines and line styles
pub fn render(&self) -> Vec<Vec<StyledString>> {
pub(crate) fn render(&self) -> Vec<Vec<StyledString>> {
// Tabs are assumed to have been replaced by spaces in calling code.
debug_assert!(self.lines.iter().all(|r| !r.iter().any(|sc| sc.chr == '\t')));
@ -70,7 +70,7 @@ impl StyledBuffer {
/// Sets `chr` with `style` for given `line`, `col`.
/// If `line` does not exist in our buffer, adds empty lines up to the given
/// and fills the last line with unstyled whitespace.
pub fn putc(&mut self, line: usize, col: usize, chr: char, style: Style) {
pub(crate) fn putc(&mut self, line: usize, col: usize, chr: char, style: Style) {
self.ensure_lines(line);
if col >= self.lines[line].len() {
self.lines[line].resize(col + 1, StyledChar::SPACE);
@ -81,7 +81,7 @@ impl StyledBuffer {
/// Sets `string` with `style` for given `line`, starting from `col`.
/// If `line` does not exist in our buffer, adds empty lines up to the given
/// and fills the last line with unstyled whitespace.
pub fn puts(&mut self, line: usize, col: usize, string: &str, style: Style) {
pub(crate) fn puts(&mut self, line: usize, col: usize, string: &str, style: Style) {
let mut n = col;
for c in string.chars() {
self.putc(line, n, c, style);
@ -91,7 +91,7 @@ impl StyledBuffer {
/// For given `line` inserts `string` with `style` before old content of that line,
/// adding lines if needed
pub fn prepend(&mut self, line: usize, string: &str, style: Style) {
pub(crate) fn prepend(&mut self, line: usize, string: &str, style: Style) {
self.ensure_lines(line);
let string_len = string.chars().count();
@ -107,7 +107,7 @@ impl StyledBuffer {
/// For given `line` inserts `string` with `style` after old content of that line,
/// adding lines if needed
pub fn append(&mut self, line: usize, string: &str, style: Style) {
pub(crate) fn append(&mut self, line: usize, string: &str, style: Style) {
if line >= self.lines.len() {
self.puts(line, 0, string, style);
} else {
@ -116,14 +116,14 @@ impl StyledBuffer {
}
}
pub fn num_lines(&self) -> usize {
pub(crate) fn num_lines(&self) -> usize {
self.lines.len()
}
/// Set `style` for `line`, `col_start..col_end` range if:
/// 1. That line and column range exist in `StyledBuffer`
/// 2. `overwrite` is `true` or existing style is `Style::NoStyle` or `Style::Quotation`
pub fn set_style_range(
pub(crate) fn set_style_range(
&mut self,
line: usize,
col_start: usize,
@ -139,7 +139,7 @@ impl StyledBuffer {
/// Set `style` for `line`, `col` if:
/// 1. That line and column exist in `StyledBuffer`
/// 2. `overwrite` is `true` or existing style is `Style::NoStyle` or `Style::Quotation`
pub fn set_style(&mut self, line: usize, col: usize, style: Style, overwrite: bool) {
fn set_style(&mut self, line: usize, col: usize, style: Style, overwrite: bool) {
if let Some(ref mut line) = self.lines.get_mut(line) {
if let Some(StyledChar { style: s, .. }) = line.get_mut(col) {
if overwrite || matches!(s, Style::NoStyle | Style::Quotation) {

View File

@ -350,7 +350,7 @@ pub(crate) struct ModuleMultipleCandidates {
#[derive(Diagnostic)]
#[diag(expand_trace_macro)]
pub struct TraceMacro {
pub(crate) struct TraceMacro {
#[primary_span]
pub span: Span,
}
@ -402,14 +402,14 @@ pub(crate) struct CustomAttributePanickedHelp {
#[derive(Diagnostic)]
#[diag(expand_proc_macro_derive_tokens)]
pub struct ProcMacroDeriveTokens {
pub(crate) struct ProcMacroDeriveTokens {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(expand_duplicate_matcher_binding)]
pub struct DuplicateMatcherBinding {
pub(crate) struct DuplicateMatcherBinding {
#[primary_span]
#[label]
pub span: Span,
@ -421,7 +421,7 @@ pub struct DuplicateMatcherBinding {
#[diag(expand_missing_fragment_specifier)]
#[note]
#[help(expand_valid)]
pub struct MissingFragmentSpecifier {
pub(crate) struct MissingFragmentSpecifier {
#[primary_span]
pub span: Span,
#[suggestion(
@ -437,7 +437,7 @@ pub struct MissingFragmentSpecifier {
#[derive(Diagnostic)]
#[diag(expand_invalid_fragment_specifier)]
#[help]
pub struct InvalidFragmentSpecifier {
pub(crate) struct InvalidFragmentSpecifier {
#[primary_span]
pub span: Span,
pub fragment: Ident,
@ -446,7 +446,7 @@ pub struct InvalidFragmentSpecifier {
#[derive(Diagnostic)]
#[diag(expand_expected_paren_or_brace)]
pub struct ExpectedParenOrBrace<'a> {
pub(crate) struct ExpectedParenOrBrace<'a> {
#[primary_span]
pub span: Span,
pub token: Cow<'a, str>,
@ -479,7 +479,7 @@ pub(crate) struct GlobDelegationTraitlessQpath {
#[derive(Diagnostic)]
#[diag(expand_proc_macro_back_compat)]
#[note]
pub struct ProcMacroBackCompat {
pub(crate) struct ProcMacroBackCompat {
pub crate_name: String,
pub fixed_version: String,
}

View File

@ -13,6 +13,7 @@
#![feature(rustdoc_internals)]
#![feature(try_blocks)]
#![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
extern crate proc_macro as pm;

View File

@ -196,13 +196,14 @@ impl<'dcx> CollectTrackerAndEmitter<'dcx, '_> {
}
}
/// Currently used by macro_rules! compilation to extract a little information from the `Failure` case.
pub struct FailureForwarder<'matcher> {
/// Currently used by macro_rules! compilation to extract a little information from the `Failure`
/// case.
pub(crate) struct FailureForwarder<'matcher> {
expected_token: Option<&'matcher Token>,
}
impl<'matcher> FailureForwarder<'matcher> {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
Self { expected_token: None }
}
}

View File

@ -407,7 +407,7 @@ fn token_name_eq(t1: &Token, t2: &Token) -> bool {
// Note: the vectors could be created and dropped within `parse_tt`, but to avoid excess
// allocations we have a single vector for each kind that is cleared and reused repeatedly.
pub struct TtParser {
pub(crate) struct TtParser {
macro_name: Ident,
/// The set of current mps to be processed. This should be empty by the end of a successful

View File

@ -14,12 +14,11 @@ use crate::mbe::macro_parser::count_metavar_decls;
use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree};
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \
`literal`, `path`, `meta`, `tt`, `item` and `vis`";
pub const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \
`ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, \
`ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \
`item` and `vis`";
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \
`item` and `vis`";
pub(crate) const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \
`ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, \
`meta`, `tt`, `item` and `vis`";
/// Takes a `tokenstream::TokenStream` and returns a `Vec<self::TokenTree>`. Specifically, this
/// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a

View File

@ -191,12 +191,12 @@ pub(crate) fn placeholder(
}
#[derive(Default)]
pub struct PlaceholderExpander {
pub(crate) struct PlaceholderExpander {
expanded_fragments: FxHashMap<ast::NodeId, AstFragment>,
}
impl PlaceholderExpander {
pub fn add(&mut self, id: ast::NodeId, mut fragment: AstFragment) {
pub(crate) fn add(&mut self, id: ast::NodeId, mut fragment: AstFragment) {
fragment.mut_visit_with(self);
self.expanded_fragments.insert(id, fragment);
}

View File

@ -414,7 +414,7 @@ impl ToInternal<rustc_errors::Level> for Level {
}
}
pub struct FreeFunctions;
pub(crate) struct FreeFunctions;
pub(crate) struct Rustc<'a, 'b> {
ecx: &'a mut ExtCtxt<'b>,
@ -426,7 +426,7 @@ pub(crate) struct Rustc<'a, 'b> {
}
impl<'a, 'b> Rustc<'a, 'b> {
pub fn new(ecx: &'a mut ExtCtxt<'b>) -> Self {
pub(crate) fn new(ecx: &'a mut ExtCtxt<'b>) -> Self {
let expn_data = ecx.current_expansion.id.expn_data();
Rustc {
def_site: ecx.with_def_site_ctxt(expn_data.def_site),

View File

@ -15,6 +15,7 @@
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod accepted;

View File

@ -6,6 +6,7 @@
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_span)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use proc_macro::TokenStream;

View File

@ -277,6 +277,7 @@
)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::borrow::Cow;

View File

@ -10,6 +10,7 @@
#![feature(never_type)]
#![feature(rustc_attrs)]
#![feature(variant_count)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
extern crate self as rustc_hir;

View File

@ -26,13 +26,13 @@ use rustc_span::Span;
/// Our representation is a bit mixed here -- in some cases, we
/// include the self type (e.g., `trait_bounds`) but in others we do not
#[derive(Default, PartialEq, Eq, Clone, Debug)]
pub struct Bounds<'tcx> {
pub(crate) struct Bounds<'tcx> {
clauses: Vec<(ty::Clause<'tcx>, Span)>,
effects_min_tys: FxIndexMap<Ty<'tcx>, Span>,
}
impl<'tcx> Bounds<'tcx> {
pub fn push_region_bound(
pub(crate) fn push_region_bound(
&mut self,
tcx: TyCtxt<'tcx>,
region: ty::PolyTypeOutlivesPredicate<'tcx>,
@ -42,7 +42,7 @@ impl<'tcx> Bounds<'tcx> {
.push((region.map_bound(|p| ty::ClauseKind::TypeOutlives(p)).upcast(tcx), span));
}
pub fn push_trait_bound(
pub(crate) fn push_trait_bound(
&mut self,
tcx: TyCtxt<'tcx>,
defining_def_id: DefId,
@ -154,7 +154,7 @@ impl<'tcx> Bounds<'tcx> {
self.clauses.push((bound_trait_ref.rebind(new_trait_ref).upcast(tcx), span));
}
pub fn push_projection_bound(
pub(crate) fn push_projection_bound(
&mut self,
tcx: TyCtxt<'tcx>,
projection: ty::PolyProjectionPredicate<'tcx>,
@ -166,14 +166,14 @@ impl<'tcx> Bounds<'tcx> {
));
}
pub fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
pub(crate) fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
let sized_def_id = tcx.require_lang_item(LangItem::Sized, Some(span));
let trait_ref = ty::TraitRef::new(tcx, sized_def_id, [ty]);
// Preferable to put this obligation first, since we report better errors for sized ambiguity.
self.clauses.insert(0, (trait_ref.upcast(tcx), span));
}
pub fn clauses(
pub(crate) fn clauses(
&self,
// FIXME(effects): remove tcx
_tcx: TyCtxt<'tcx>,
@ -181,7 +181,7 @@ impl<'tcx> Bounds<'tcx> {
self.clauses.iter().cloned()
}
pub fn effects_min_tys(&self) -> impl Iterator<Item = Ty<'tcx>> + '_ {
pub(crate) fn effects_min_tys(&self) -> impl Iterator<Item = Ty<'tcx>> + '_ {
self.effects_min_tys.keys().copied()
}
}

View File

@ -1053,7 +1053,7 @@ fn check_impl_items_against_trait<'tcx>(
}
}
pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
let t = tcx.type_of(def_id).instantiate_identity();
if let ty::Adt(def, args) = t.kind()
&& def.is_struct()

View File

@ -6,7 +6,7 @@ use rustc_span::Span;
use crate::errors;
/// Check for shared or mutable references of `static mut` inside expression
pub fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
pub(crate) fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
let span = expr.span;
let hir_id = expr.hir_id;
if let hir::ExprKind::AddrOf(borrow_kind, m, expr) = expr.kind
@ -26,7 +26,7 @@ pub fn maybe_expr_static_mut(tcx: TyCtxt<'_>, expr: hir::Expr<'_>) {
}
/// Check for shared or mutable references of `static mut` inside statement
pub fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
pub(crate) fn maybe_stmt_static_mut(tcx: TyCtxt<'_>, stmt: hir::Stmt<'_>) {
if let hir::StmtKind::Let(loc) = stmt.kind
&& let hir::PatKind::Binding(ba, _, _, _) = loc.pat.kind
&& let hir::ByRef::Yes(rmutbl) = ba.0

View File

@ -22,7 +22,7 @@ use rustc_span::source_map;
use super::errs::{maybe_expr_static_mut, maybe_stmt_static_mut};
#[derive(Debug, Copy, Clone)]
pub struct Context {
struct Context {
/// The scope that contains any new variables declared, plus its depth in
/// the scope tree.
var_parent: Option<(Scope, ScopeDepth)>,
@ -893,7 +893,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
/// re-use in incremental scenarios. We may sometimes need to rerun the
/// type checker even when the HIR hasn't changed, and in those cases
/// we can avoid reconstructing the region scope tree.
pub fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
pub(crate) fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
let typeck_root_def_id = tcx.typeck_root_def_id(def_id);
if typeck_root_def_id != def_id {
return tcx.region_scope_tree(typeck_root_def_id);

View File

@ -5,7 +5,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint;
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_unused_traits, ..*providers };
}

View File

@ -332,7 +332,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
}
}
pub fn coerce_unsized_info<'tcx>(
pub(crate) fn coerce_unsized_info<'tcx>(
tcx: TyCtxt<'tcx>,
impl_did: LocalDefId,
) -> Result<CoerceUnsizedInfo, ErrorGuaranteed> {

View File

@ -19,7 +19,7 @@ use rustc_span::ErrorGuaranteed;
use crate::errors;
/// On-demand query: yields a map containing all types mapped to their inherent impls.
pub fn crate_inherent_impls(
pub(crate) fn crate_inherent_impls(
tcx: TyCtxt<'_>,
(): (),
) -> Result<&'_ CrateInherentImpls, ErrorGuaranteed> {
@ -32,7 +32,7 @@ pub fn crate_inherent_impls(
Ok(tcx.arena.alloc(collect.impls_map))
}
pub fn crate_incoherent_impls(
pub(crate) fn crate_incoherent_impls(
tcx: TyCtxt<'_>,
simp: SimplifiedType,
) -> Result<&[DefId], ErrorGuaranteed> {
@ -43,7 +43,10 @@ pub fn crate_incoherent_impls(
}
/// On-demand query: yields a vector of the inherent impls for a specific type.
pub fn inherent_impls(tcx: TyCtxt<'_>, ty_def_id: LocalDefId) -> Result<&[DefId], ErrorGuaranteed> {
pub(crate) fn inherent_impls(
tcx: TyCtxt<'_>,
ty_def_id: LocalDefId,
) -> Result<&[DefId], ErrorGuaranteed> {
let crate_map = tcx.crate_inherent_impls(())?;
Ok(match crate_map.inherent_impls.get(&ty_def_id) {
Some(v) => &v[..],

View File

@ -11,7 +11,10 @@ use rustc_span::{ErrorGuaranteed, Symbol};
use rustc_trait_selection::traits::{self, SkipLeakCheck};
use smallvec::SmallVec;
pub fn crate_inherent_impls_overlap_check(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> {
pub(crate) fn crate_inherent_impls_overlap_check(
tcx: TyCtxt<'_>,
(): (),
) -> Result<(), ErrorGuaranteed> {
let mut inherent_overlap_checker = InherentOverlapChecker { tcx };
let mut res = Ok(());
for id in tcx.hir().items() {

View File

@ -123,7 +123,7 @@ fn enforce_empty_impls_for_marker_traits(
.emit())
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
use self::builtin::coerce_unsized_info;
use self::inherent_impls::{crate_incoherent_impls, crate_inherent_impls, inherent_impls};
use self::inherent_impls_overlap::crate_inherent_impls_overlap_check;

View File

@ -2071,7 +2071,7 @@ fn is_late_bound_map(
}
}
pub fn deny_non_region_late_bound(
fn deny_non_region_late_bound(
tcx: TyCtxt<'_>,
bound_vars: &mut FxIndexMap<LocalDefId, ResolvedArg>,
where_: &str,

View File

@ -725,7 +725,7 @@ fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {
}
}
pub fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
pub(crate) fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
use hir::intravisit::Visitor;
if tcx.features().lazy_type_alias {
return true;

View File

@ -6,7 +6,7 @@ use rustc_span::Span;
use rustc_type_ir::fold::TypeFoldable;
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Parameter(pub u32);
pub(crate) struct Parameter(pub u32);
impl From<ty::ParamTy> for Parameter {
fn from(param: ty::ParamTy) -> Self {
@ -27,7 +27,7 @@ impl From<ty::ParamConst> for Parameter {
}
/// Returns the set of parameters constrained by the impl header.
pub fn parameters_for_impl<'tcx>(
pub(crate) fn parameters_for_impl<'tcx>(
tcx: TyCtxt<'tcx>,
impl_self_ty: Ty<'tcx>,
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
@ -44,7 +44,7 @@ pub fn parameters_for_impl<'tcx>(
/// uniquely determined by `value` (see RFC 447). If it is true, return the list
/// of parameters whose values are needed in order to constrain `value` - these
/// differ, with the latter being a superset, in the presence of projections.
pub fn parameters_for<'tcx>(
pub(crate) fn parameters_for<'tcx>(
tcx: TyCtxt<'tcx>,
value: impl TypeFoldable<TyCtxt<'tcx>>,
include_nonconstraining: bool,
@ -102,7 +102,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParameterCollector {
}
}
pub fn identify_constrained_generic_params<'tcx>(
pub(crate) fn identify_constrained_generic_params<'tcx>(
tcx: TyCtxt<'tcx>,
predicates: ty::GenericPredicates<'tcx>,
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
@ -156,7 +156,7 @@ pub fn identify_constrained_generic_params<'tcx>(
/// which is determined by 1, which requires `U`, that is determined
/// by 0. I should probably pick a less tangled example, but I can't
/// think of any.
pub fn setup_constraining_predicates<'tcx>(
pub(crate) fn setup_constraining_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
predicates: &mut [(ty::Clause<'tcx>, Span)],
impl_trait_ref: Option<ty::TraitRef<'tcx>>,

View File

@ -11,15 +11,15 @@ use rustc_span::{Span, Symbol};
use crate::fluent_generated as fluent;
mod pattern_types;
pub use pattern_types::*;
pub mod wrong_number_of_generic_args;
pub(crate) use pattern_types::*;
pub(crate) mod wrong_number_of_generic_args;
mod precise_captures;
pub(crate) use precise_captures::*;
#[derive(Diagnostic)]
#[diag(hir_analysis_ambiguous_assoc_item)]
pub struct AmbiguousAssocItem<'a> {
pub(crate) struct AmbiguousAssocItem<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -30,7 +30,7 @@ pub struct AmbiguousAssocItem<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_assoc_kind_mismatch)]
pub struct AssocKindMismatch {
pub(crate) struct AssocKindMismatch {
#[primary_span]
#[label]
pub span: Span,
@ -52,7 +52,7 @@ pub struct AssocKindMismatch {
hir_analysis_assoc_kind_mismatch_wrap_in_braces_sugg,
applicability = "maybe-incorrect"
)]
pub struct AssocKindMismatchWrapInBracesSugg {
pub(crate) struct AssocKindMismatchWrapInBracesSugg {
#[suggestion_part(code = "{{ ")]
pub lo: Span,
#[suggestion_part(code = " }}")]
@ -61,7 +61,7 @@ pub struct AssocKindMismatchWrapInBracesSugg {
#[derive(Diagnostic)]
#[diag(hir_analysis_assoc_item_is_private, code = E0624)]
pub struct AssocItemIsPrivate {
pub(crate) struct AssocItemIsPrivate {
#[primary_span]
#[label]
pub span: Span,
@ -73,7 +73,7 @@ pub struct AssocItemIsPrivate {
#[derive(Diagnostic)]
#[diag(hir_analysis_assoc_item_not_found, code = E0220)]
pub struct AssocItemNotFound<'a> {
pub(crate) struct AssocItemNotFound<'a> {
#[primary_span]
pub span: Span,
pub assoc_name: Ident,
@ -86,7 +86,7 @@ pub struct AssocItemNotFound<'a> {
}
#[derive(Subdiagnostic)]
pub enum AssocItemNotFoundLabel<'a> {
pub(crate) enum AssocItemNotFoundLabel<'a> {
#[label(hir_analysis_assoc_item_not_found_label)]
NotFound {
#[primary_span]
@ -105,7 +105,7 @@ pub enum AssocItemNotFoundLabel<'a> {
#[derive(Subdiagnostic)]
pub enum AssocItemNotFoundSugg<'a> {
pub(crate) enum AssocItemNotFoundSugg<'a> {
#[suggestion(
hir_analysis_assoc_item_not_found_similar_sugg,
code = "{suggested_name}",
@ -162,7 +162,7 @@ pub enum AssocItemNotFoundSugg<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_unrecognized_atomic_operation, code = E0092)]
pub struct UnrecognizedAtomicOperation<'a> {
pub(crate) struct UnrecognizedAtomicOperation<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -171,7 +171,7 @@ pub struct UnrecognizedAtomicOperation<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_wrong_number_of_generic_arguments_to_intrinsic, code = E0094)]
pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
pub(crate) struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -183,7 +183,7 @@ pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_unrecognized_intrinsic_function, code = E0093)]
#[help]
pub struct UnrecognizedIntrinsicFunction {
pub(crate) struct UnrecognizedIntrinsicFunction {
#[primary_span]
#[label]
pub span: Span,
@ -192,7 +192,7 @@ pub struct UnrecognizedIntrinsicFunction {
#[derive(Diagnostic)]
#[diag(hir_analysis_lifetimes_or_bounds_mismatch_on_trait, code = E0195)]
pub struct LifetimesOrBoundsMismatchOnTrait {
pub(crate) struct LifetimesOrBoundsMismatchOnTrait {
#[primary_span]
#[label]
pub span: Span,
@ -208,14 +208,14 @@ pub struct LifetimesOrBoundsMismatchOnTrait {
#[derive(Diagnostic)]
#[diag(hir_analysis_drop_impl_on_wrong_item, code = E0120)]
pub struct DropImplOnWrongItem {
pub(crate) struct DropImplOnWrongItem {
#[primary_span]
#[label]
pub span: Span,
}
#[derive(Diagnostic)]
pub enum FieldAlreadyDeclared {
pub(crate) enum FieldAlreadyDeclared {
#[diag(hir_analysis_field_already_declared, code = E0124)]
NotNested {
field_name: Symbol,
@ -272,14 +272,14 @@ pub enum FieldAlreadyDeclared {
#[derive(Subdiagnostic)]
#[help(hir_analysis_field_already_declared_nested_help)]
pub struct FieldAlreadyDeclaredNestedHelp {
pub(crate) struct FieldAlreadyDeclaredNestedHelp {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_analysis_copy_impl_on_type_with_dtor, code = E0184)]
pub struct CopyImplOnTypeWithDtor {
pub(crate) struct CopyImplOnTypeWithDtor {
#[primary_span]
#[label]
pub span: Span,
@ -287,14 +287,14 @@ pub struct CopyImplOnTypeWithDtor {
#[derive(Diagnostic)]
#[diag(hir_analysis_multiple_relaxed_default_bounds, code = E0203)]
pub struct MultipleRelaxedDefaultBounds {
pub(crate) struct MultipleRelaxedDefaultBounds {
#[primary_span]
pub spans: Vec<Span>,
}
#[derive(Diagnostic)]
#[diag(hir_analysis_copy_impl_on_non_adt, code = E0206)]
pub struct CopyImplOnNonAdt {
pub(crate) struct CopyImplOnNonAdt {
#[primary_span]
#[label]
pub span: Span,
@ -302,7 +302,7 @@ pub struct CopyImplOnNonAdt {
#[derive(Diagnostic)]
#[diag(hir_analysis_const_param_ty_impl_on_unsized)]
pub struct ConstParamTyImplOnUnsized {
pub(crate) struct ConstParamTyImplOnUnsized {
#[primary_span]
#[label]
pub span: Span,
@ -310,7 +310,7 @@ pub struct ConstParamTyImplOnUnsized {
#[derive(Diagnostic)]
#[diag(hir_analysis_const_param_ty_impl_on_non_adt)]
pub struct ConstParamTyImplOnNonAdt {
pub(crate) struct ConstParamTyImplOnNonAdt {
#[primary_span]
#[label]
pub span: Span,
@ -318,7 +318,7 @@ pub struct ConstParamTyImplOnNonAdt {
#[derive(Diagnostic)]
#[diag(hir_analysis_trait_object_declared_with_no_traits, code = E0224)]
pub struct TraitObjectDeclaredWithNoTraits {
pub(crate) struct TraitObjectDeclaredWithNoTraits {
#[primary_span]
pub span: Span,
#[label(hir_analysis_alias_span)]
@ -327,14 +327,14 @@ pub struct TraitObjectDeclaredWithNoTraits {
#[derive(Diagnostic)]
#[diag(hir_analysis_ambiguous_lifetime_bound, code = E0227)]
pub struct AmbiguousLifetimeBound {
pub(crate) struct AmbiguousLifetimeBound {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_analysis_assoc_item_constraints_not_allowed_here, code = E0229)]
pub struct AssocItemConstraintsNotAllowedHere {
pub(crate) struct AssocItemConstraintsNotAllowedHere {
#[primary_span]
#[label]
pub span: Span,
@ -383,7 +383,7 @@ pub(crate) struct EscapingBoundVarInTyOfAssocConstBinding<'tcx> {
#[derive(Subdiagnostic)]
#[help(hir_analysis_parenthesized_fn_trait_expansion)]
pub struct ParenthesizedFnTraitExpansion {
pub(crate) struct ParenthesizedFnTraitExpansion {
#[primary_span]
pub span: Span,
@ -392,7 +392,7 @@ pub struct ParenthesizedFnTraitExpansion {
#[derive(Diagnostic)]
#[diag(hir_analysis_typeof_reserved_keyword_used, code = E0516)]
pub struct TypeofReservedKeywordUsed<'tcx> {
pub(crate) struct TypeofReservedKeywordUsed<'tcx> {
pub ty: Ty<'tcx>,
#[primary_span]
#[label]
@ -403,7 +403,7 @@ pub struct TypeofReservedKeywordUsed<'tcx> {
#[derive(Diagnostic)]
#[diag(hir_analysis_value_of_associated_struct_already_specified, code = E0719)]
pub struct ValueOfAssociatedStructAlreadySpecified {
pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
#[primary_span]
#[label]
pub span: Span,
@ -416,7 +416,7 @@ pub struct ValueOfAssociatedStructAlreadySpecified {
#[derive(Diagnostic)]
#[diag(hir_analysis_unconstrained_opaque_type)]
#[note]
pub struct UnconstrainedOpaqueType {
pub(crate) struct UnconstrainedOpaqueType {
#[primary_span]
pub span: Span,
pub name: Symbol,
@ -426,7 +426,7 @@ pub struct UnconstrainedOpaqueType {
#[derive(Diagnostic)]
#[diag(hir_analysis_tait_forward_compat)]
#[note]
pub struct TaitForwardCompat {
pub(crate) struct TaitForwardCompat {
#[primary_span]
pub span: Span,
#[note]
@ -436,7 +436,7 @@ pub struct TaitForwardCompat {
#[derive(Diagnostic)]
#[diag(hir_analysis_tait_forward_compat2)]
#[note]
pub struct TaitForwardCompat2 {
pub(crate) struct TaitForwardCompat2 {
#[primary_span]
pub span: Span,
#[note(hir_analysis_opaque)]
@ -444,7 +444,7 @@ pub struct TaitForwardCompat2 {
pub opaque_type: String,
}
pub struct MissingTypeParams {
pub(crate) struct MissingTypeParams {
pub span: Span,
pub def_span: Span,
pub span_snippet: Option<String>,
@ -512,7 +512,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MissingTypeParams {
#[derive(Diagnostic)]
#[diag(hir_analysis_manual_implementation, code = E0183)]
#[help]
pub struct ManualImplementation {
pub(crate) struct ManualImplementation {
#[primary_span]
#[label]
pub span: Span,
@ -521,14 +521,14 @@ pub struct ManualImplementation {
#[derive(Diagnostic)]
#[diag(hir_analysis_generic_args_on_overridden_impl)]
pub struct GenericArgsOnOverriddenImpl {
pub(crate) struct GenericArgsOnOverriddenImpl {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_analysis_const_impl_for_non_const_trait)]
pub struct ConstImplForNonConstTrait {
pub(crate) struct ConstImplForNonConstTrait {
#[primary_span]
pub trait_ref_span: Span,
pub trait_name: String,
@ -542,7 +542,7 @@ pub struct ConstImplForNonConstTrait {
#[derive(Diagnostic)]
#[diag(hir_analysis_const_bound_for_non_const_trait)]
pub struct ConstBoundForNonConstTrait {
pub(crate) struct ConstBoundForNonConstTrait {
#[primary_span]
pub span: Span,
pub modifier: &'static str,
@ -550,7 +550,7 @@ pub struct ConstBoundForNonConstTrait {
#[derive(Diagnostic)]
#[diag(hir_analysis_self_in_impl_self)]
pub struct SelfInImplSelf {
pub(crate) struct SelfInImplSelf {
#[primary_span]
pub span: MultiSpan,
#[note]
@ -567,7 +567,7 @@ pub(crate) struct LinkageType {
#[derive(Diagnostic)]
#[help]
#[diag(hir_analysis_auto_deref_reached_recursion_limit, code = E0055)]
pub struct AutoDerefReachedRecursionLimit<'a> {
pub(crate) struct AutoDerefReachedRecursionLimit<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -736,7 +736,7 @@ pub(crate) struct InvalidUnionField {
#[derive(Diagnostic)]
#[diag(hir_analysis_invalid_unnamed_field_ty)]
pub struct InvalidUnnamedFieldTy {
pub(crate) struct InvalidUnnamedFieldTy {
#[primary_span]
pub span: Span,
}
@ -894,7 +894,7 @@ pub(crate) struct SIMDFFIHighlyExperimental {
}
#[derive(Diagnostic)]
pub enum ImplNotMarkedDefault {
pub(crate) enum ImplNotMarkedDefault {
#[diag(hir_analysis_impl_not_marked_default, code = E0520)]
#[note]
Ok {
@ -1137,7 +1137,7 @@ pub(crate) enum LateBoundInApit {
#[derive(LintDiagnostic)]
#[diag(hir_analysis_unused_associated_type_bounds)]
#[note]
pub struct UnusedAssociatedTypeBounds {
pub(crate) struct UnusedAssociatedTypeBounds {
#[suggestion(code = "")]
pub span: Span,
}
@ -1162,7 +1162,7 @@ pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
#[derive(Diagnostic)]
#[diag(hir_analysis_inherent_ty_outside, code = E0390)]
#[help]
pub struct InherentTyOutside {
pub(crate) struct InherentTyOutside {
#[primary_span]
#[help(hir_analysis_span_help)]
pub span: Span,
@ -1170,7 +1170,7 @@ pub struct InherentTyOutside {
#[derive(Diagnostic)]
#[diag(hir_analysis_coerce_unsized_may, code = E0378)]
pub struct DispatchFromDynCoercion<'a> {
pub(crate) struct DispatchFromDynCoercion<'a> {
#[primary_span]
pub span: Span,
pub trait_name: &'a str,
@ -1182,7 +1182,7 @@ pub struct DispatchFromDynCoercion<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_dispatch_from_dyn_repr, code = E0378)]
pub struct DispatchFromDynRepr {
pub(crate) struct DispatchFromDynRepr {
#[primary_span]
pub span: Span,
}
@ -1190,7 +1190,7 @@ pub struct DispatchFromDynRepr {
#[derive(Diagnostic)]
#[diag(hir_analysis_inherent_ty_outside_relevant, code = E0390)]
#[help]
pub struct InherentTyOutsideRelevant {
pub(crate) struct InherentTyOutsideRelevant {
#[primary_span]
pub span: Span,
#[help(hir_analysis_span_help)]
@ -1200,7 +1200,7 @@ pub struct InherentTyOutsideRelevant {
#[derive(Diagnostic)]
#[diag(hir_analysis_inherent_ty_outside_new, code = E0116)]
#[note]
pub struct InherentTyOutsideNew {
pub(crate) struct InherentTyOutsideNew {
#[primary_span]
#[label]
pub span: Span,
@ -1209,7 +1209,7 @@ pub struct InherentTyOutsideNew {
#[derive(Diagnostic)]
#[diag(hir_analysis_inherent_ty_outside_primitive, code = E0390)]
#[help]
pub struct InherentTyOutsidePrimitive {
pub(crate) struct InherentTyOutsidePrimitive {
#[primary_span]
pub span: Span,
#[help(hir_analysis_span_help)]
@ -1219,7 +1219,7 @@ pub struct InherentTyOutsidePrimitive {
#[derive(Diagnostic)]
#[diag(hir_analysis_inherent_primitive_ty, code = E0390)]
#[help]
pub struct InherentPrimitiveTy<'a> {
pub(crate) struct InherentPrimitiveTy<'a> {
#[primary_span]
pub span: Span,
#[subdiagnostic]
@ -1228,14 +1228,14 @@ pub struct InherentPrimitiveTy<'a> {
#[derive(Subdiagnostic)]
#[note(hir_analysis_inherent_primitive_ty_note)]
pub struct InherentPrimitiveTyNote<'a> {
pub(crate) struct InherentPrimitiveTyNote<'a> {
pub subty: Ty<'a>,
}
#[derive(Diagnostic)]
#[diag(hir_analysis_inherent_dyn, code = E0785)]
#[note]
pub struct InherentDyn {
pub(crate) struct InherentDyn {
#[primary_span]
#[label]
pub span: Span,
@ -1244,7 +1244,7 @@ pub struct InherentDyn {
#[derive(Diagnostic)]
#[diag(hir_analysis_inherent_nominal, code = E0118)]
#[note]
pub struct InherentNominal {
pub(crate) struct InherentNominal {
#[primary_span]
#[label]
pub span: Span,
@ -1253,7 +1253,7 @@ pub struct InherentNominal {
#[derive(Diagnostic)]
#[diag(hir_analysis_dispatch_from_dyn_zst, code = E0378)]
#[note]
pub struct DispatchFromDynZST<'a> {
pub(crate) struct DispatchFromDynZST<'a> {
#[primary_span]
pub span: Span,
pub name: Symbol,
@ -1262,7 +1262,7 @@ pub struct DispatchFromDynZST<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_coerce_unsized_may, code = E0378)]
pub struct DispatchFromDynSingle<'a> {
pub(crate) struct DispatchFromDynSingle<'a> {
#[primary_span]
pub span: Span,
pub trait_name: &'a str,
@ -1273,7 +1273,7 @@ pub struct DispatchFromDynSingle<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_dispatch_from_dyn_multi, code = E0378)]
#[note]
pub struct DispatchFromDynMulti {
pub(crate) struct DispatchFromDynMulti {
#[primary_span]
pub span: Span,
#[note(hir_analysis_coercions_note)]
@ -1284,7 +1284,7 @@ pub struct DispatchFromDynMulti {
#[derive(Diagnostic)]
#[diag(hir_analysis_coerce_unsized_may, code = E0376)]
pub struct DispatchFromDynStruct<'a> {
pub(crate) struct DispatchFromDynStruct<'a> {
#[primary_span]
pub span: Span,
pub trait_name: &'a str,
@ -1292,7 +1292,7 @@ pub struct DispatchFromDynStruct<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_coerce_unsized_may, code = E0377)]
pub struct DispatchFromDynSame<'a> {
pub(crate) struct DispatchFromDynSame<'a> {
#[primary_span]
pub span: Span,
pub trait_name: &'a str,
@ -1304,7 +1304,7 @@ pub struct DispatchFromDynSame<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_coerce_unsized_may, code = E0374)]
pub struct CoerceUnsizedOneField<'a> {
pub(crate) struct CoerceUnsizedOneField<'a> {
#[primary_span]
pub span: Span,
pub trait_name: &'a str,
@ -1315,7 +1315,7 @@ pub struct CoerceUnsizedOneField<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_coerce_unsized_multi, code = E0375)]
#[note]
pub struct CoerceUnsizedMulti {
pub(crate) struct CoerceUnsizedMulti {
#[primary_span]
#[label]
pub span: Span,
@ -1327,7 +1327,7 @@ pub struct CoerceUnsizedMulti {
#[derive(Diagnostic)]
#[diag(hir_analysis_coerce_unsized_may, code = E0378)]
pub struct CoerceUnsizedMay<'a> {
pub(crate) struct CoerceUnsizedMay<'a> {
#[primary_span]
pub span: Span,
pub trait_name: &'a str,
@ -1335,7 +1335,7 @@ pub struct CoerceUnsizedMay<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_trait_cannot_impl_for_ty, code = E0204)]
pub struct TraitCannotImplForTy {
pub(crate) struct TraitCannotImplForTy {
#[primary_span]
pub span: Span,
pub trait_name: String,
@ -1347,7 +1347,7 @@ pub struct TraitCannotImplForTy {
#[derive(Subdiagnostic)]
#[note(hir_analysis_requires_note)]
pub struct ImplForTyRequires {
pub(crate) struct ImplForTyRequires {
#[primary_span]
pub span: MultiSpan,
pub error_predicate: String,
@ -1358,7 +1358,7 @@ pub struct ImplForTyRequires {
#[derive(Diagnostic)]
#[diag(hir_analysis_traits_with_defualt_impl, code = E0321)]
#[note]
pub struct TraitsWithDefaultImpl<'a> {
pub(crate) struct TraitsWithDefaultImpl<'a> {
#[primary_span]
pub span: Span,
pub traits: String,
@ -1368,7 +1368,7 @@ pub struct TraitsWithDefaultImpl<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_cross_crate_traits, code = E0321)]
pub struct CrossCrateTraits<'a> {
pub(crate) struct CrossCrateTraits<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -1378,7 +1378,7 @@ pub struct CrossCrateTraits<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_cross_crate_traits_defined, code = E0321)]
pub struct CrossCrateTraitsDefined {
pub(crate) struct CrossCrateTraitsDefined {
#[primary_span]
#[label]
pub span: Span,
@ -1390,7 +1390,7 @@ pub struct CrossCrateTraitsDefined {
#[derive(Diagnostic)]
#[diag(hir_analysis_ty_param_first_local, code = E0210)]
#[note]
pub struct TyParamFirstLocal<'tcx> {
pub(crate) struct TyParamFirstLocal<'tcx> {
#[primary_span]
#[label]
pub span: Span,
@ -1403,7 +1403,7 @@ pub struct TyParamFirstLocal<'tcx> {
#[derive(LintDiagnostic)]
#[diag(hir_analysis_ty_param_first_local, code = E0210)]
#[note]
pub struct TyParamFirstLocalLint<'tcx> {
pub(crate) struct TyParamFirstLocalLint<'tcx> {
#[label]
pub span: Span,
#[note(hir_analysis_case_note)]
@ -1415,7 +1415,7 @@ pub struct TyParamFirstLocalLint<'tcx> {
#[derive(Diagnostic)]
#[diag(hir_analysis_ty_param_some, code = E0210)]
#[note]
pub struct TyParamSome {
pub(crate) struct TyParamSome {
#[primary_span]
#[label]
pub span: Span,
@ -1427,7 +1427,7 @@ pub struct TyParamSome {
#[derive(LintDiagnostic)]
#[diag(hir_analysis_ty_param_some, code = E0210)]
#[note]
pub struct TyParamSomeLint {
pub(crate) struct TyParamSomeLint {
#[label]
pub span: Span,
#[note(hir_analysis_only_note)]
@ -1436,7 +1436,7 @@ pub struct TyParamSomeLint {
}
#[derive(Diagnostic)]
pub enum OnlyCurrentTraits {
pub(crate) enum OnlyCurrentTraits {
#[diag(hir_analysis_only_current_traits_outside, code = E0117)]
Outside {
#[primary_span]
@ -1465,20 +1465,20 @@ pub enum OnlyCurrentTraits {
#[derive(Subdiagnostic)]
#[label(hir_analysis_only_current_traits_opaque)]
pub struct OnlyCurrentTraitsOpaque {
pub(crate) struct OnlyCurrentTraitsOpaque {
#[primary_span]
pub span: Span,
}
#[derive(Subdiagnostic)]
#[label(hir_analysis_only_current_traits_foreign)]
pub struct OnlyCurrentTraitsForeign {
pub(crate) struct OnlyCurrentTraitsForeign {
#[primary_span]
pub span: Span,
}
#[derive(Subdiagnostic)]
#[label(hir_analysis_only_current_traits_name)]
pub struct OnlyCurrentTraitsName<'a> {
pub(crate) struct OnlyCurrentTraitsName<'a> {
#[primary_span]
pub span: Span,
pub name: &'a str,
@ -1486,7 +1486,7 @@ pub struct OnlyCurrentTraitsName<'a> {
#[derive(Subdiagnostic)]
#[label(hir_analysis_only_current_traits_pointer)]
pub struct OnlyCurrentTraitsPointer<'a> {
pub(crate) struct OnlyCurrentTraitsPointer<'a> {
#[primary_span]
pub span: Span,
pub pointer: Ty<'a>,
@ -1494,7 +1494,7 @@ pub struct OnlyCurrentTraitsPointer<'a> {
#[derive(Subdiagnostic)]
#[label(hir_analysis_only_current_traits_ty)]
pub struct OnlyCurrentTraitsTy<'a> {
pub(crate) struct OnlyCurrentTraitsTy<'a> {
#[primary_span]
pub span: Span,
pub ty: Ty<'a>,
@ -1502,7 +1502,7 @@ pub struct OnlyCurrentTraitsTy<'a> {
#[derive(Subdiagnostic)]
#[label(hir_analysis_only_current_traits_adt)]
pub struct OnlyCurrentTraitsAdt {
pub(crate) struct OnlyCurrentTraitsAdt {
#[primary_span]
pub span: Span,
pub name: String,
@ -1513,11 +1513,11 @@ pub struct OnlyCurrentTraitsAdt {
hir_analysis_only_current_traits_pointer_sugg,
applicability = "maybe-incorrect"
)]
pub struct OnlyCurrentTraitsPointerSugg<'a> {
pub(crate) struct OnlyCurrentTraitsPointerSugg<'a> {
#[suggestion_part(code = "WrapperType")]
pub wrapper_span: Span,
#[suggestion_part(code = "struct WrapperType(*{mut_key}{ptr_ty});\n\n")]
pub struct_span: Span,
pub(crate) struct_span: Span,
pub mut_key: &'a str,
pub ptr_ty: Ty<'a>,
}
@ -1525,7 +1525,7 @@ pub struct OnlyCurrentTraitsPointerSugg<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_static_mut_ref, code = E0796)]
#[note]
pub struct StaticMutRef<'a> {
pub(crate) struct StaticMutRef<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -1535,7 +1535,7 @@ pub struct StaticMutRef<'a> {
}
#[derive(Subdiagnostic)]
pub enum MutRefSugg {
pub(crate) enum MutRefSugg {
#[multipart_suggestion(
hir_analysis_suggestion,
style = "verbose",
@ -1565,7 +1565,7 @@ pub enum MutRefSugg {
#[diag(hir_analysis_static_mut_refs_lint)]
#[note]
#[note(hir_analysis_why_note)]
pub struct RefOfMutStatic<'a> {
pub(crate) struct RefOfMutStatic<'a> {
#[label]
pub span: Span,
#[subdiagnostic]
@ -1575,7 +1575,7 @@ pub struct RefOfMutStatic<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_not_supported_delegation)]
pub struct UnsupportedDelegation<'a> {
pub(crate) struct UnsupportedDelegation<'a> {
#[primary_span]
pub span: Span,
pub descr: &'a str,
@ -1585,7 +1585,7 @@ pub struct UnsupportedDelegation<'a> {
#[derive(Diagnostic)]
#[diag(hir_analysis_method_should_return_future)]
pub struct MethodShouldReturnFuture {
pub(crate) struct MethodShouldReturnFuture {
#[primary_span]
pub span: Span,
pub method_name: Symbol,
@ -1649,7 +1649,7 @@ pub(crate) struct UnconstrainedGenericParameter {
}
#[derive(Diagnostic)]
pub enum UnnamedFieldsRepr<'a> {
pub(crate) enum UnnamedFieldsRepr<'a> {
#[diag(hir_analysis_unnamed_fields_repr_missing_repr_c)]
MissingReprC {
#[primary_span]
@ -1678,14 +1678,14 @@ pub enum UnnamedFieldsRepr<'a> {
#[derive(Subdiagnostic)]
#[note(hir_analysis_unnamed_fields_repr_field_defined)]
pub struct UnnamedFieldsReprFieldDefined {
pub(crate) struct UnnamedFieldsReprFieldDefined {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_analysis_opaque_captures_higher_ranked_lifetime, code = E0657)]
pub struct OpaqueCapturesHigherRankedLifetime {
pub(crate) struct OpaqueCapturesHigherRankedLifetime {
#[primary_span]
pub span: Span,
#[label]
@ -1697,7 +1697,7 @@ pub struct OpaqueCapturesHigherRankedLifetime {
#[derive(Diagnostic)]
#[diag(hir_analysis_pattern_type_non_const_range)]
pub struct NonConstRange {
pub(crate) struct NonConstRange {
#[primary_span]
pub span: Span,
}
@ -1706,7 +1706,7 @@ pub struct NonConstRange {
#[diag(hir_analysis_invalid_receiver_ty, code = E0307)]
#[note]
#[help(hir_analysis_invalid_receiver_ty_help)]
pub struct InvalidReceiverTy<'tcx> {
pub(crate) struct InvalidReceiverTy<'tcx> {
#[primary_span]
pub span: Span,
pub receiver_ty: Ty<'tcx>,
@ -1716,12 +1716,12 @@ pub struct InvalidReceiverTy<'tcx> {
#[diag(hir_analysis_effects_without_next_solver)]
#[note]
#[help]
pub struct EffectsWithoutNextSolver;
pub(crate) struct EffectsWithoutNextSolver;
#[derive(Diagnostic)]
#[diag(hir_analysis_cmse_call_inputs_stack_spill, code = E0798)]
#[note]
pub struct CmseCallInputsStackSpill {
pub(crate) struct CmseCallInputsStackSpill {
#[primary_span]
#[label]
pub span: Span,
@ -1732,7 +1732,7 @@ pub struct CmseCallInputsStackSpill {
#[diag(hir_analysis_cmse_call_output_stack_spill, code = E0798)]
#[note(hir_analysis_note1)]
#[note(hir_analysis_note2)]
pub struct CmseCallOutputStackSpill {
pub(crate) struct CmseCallOutputStackSpill {
#[primary_span]
#[label]
pub span: Span,
@ -1740,7 +1740,7 @@ pub struct CmseCallOutputStackSpill {
#[derive(Diagnostic)]
#[diag(hir_analysis_cmse_call_generic, code = E0798)]
pub struct CmseCallGeneric {
pub(crate) struct CmseCallGeneric {
#[primary_span]
pub span: Span,
}

View File

@ -3,7 +3,7 @@ use rustc_span::Span;
#[derive(Diagnostic)]
#[diag(hir_analysis_pattern_type_wild_pat)]
pub struct WildPatTy {
pub(crate) struct WildPatTy {
#[primary_span]
pub span: Span,
}

View File

@ -4,7 +4,7 @@ use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[diag(hir_analysis_param_not_captured)]
#[note]
pub struct ParamNotCaptured {
pub(crate) struct ParamNotCaptured {
#[primary_span]
pub opaque_span: Span,
#[label]
@ -15,7 +15,7 @@ pub struct ParamNotCaptured {
#[derive(Diagnostic)]
#[diag(hir_analysis_self_ty_not_captured)]
#[note]
pub struct SelfTyNotCaptured {
pub(crate) struct SelfTyNotCaptured {
#[primary_span]
pub opaque_span: Span,
#[label]
@ -24,7 +24,7 @@ pub struct SelfTyNotCaptured {
#[derive(Diagnostic)]
#[diag(hir_analysis_lifetime_not_captured)]
pub struct LifetimeNotCaptured {
pub(crate) struct LifetimeNotCaptured {
#[primary_span]
pub use_span: Span,
#[label(hir_analysis_param_label)]
@ -35,7 +35,7 @@ pub struct LifetimeNotCaptured {
#[derive(Diagnostic)]
#[diag(hir_analysis_bad_precise_capture)]
pub struct BadPreciseCapture {
pub(crate) struct BadPreciseCapture {
#[primary_span]
pub span: Span,
pub kind: &'static str,
@ -44,7 +44,7 @@ pub struct BadPreciseCapture {
#[derive(Diagnostic)]
#[diag(hir_analysis_precise_capture_self_alias)]
pub struct PreciseCaptureSelfAlias {
pub(crate) struct PreciseCaptureSelfAlias {
#[primary_span]
pub span: Span,
#[label]
@ -54,7 +54,7 @@ pub struct PreciseCaptureSelfAlias {
#[derive(Diagnostic)]
#[diag(hir_analysis_duplicate_precise_capture)]
pub struct DuplicatePreciseCapture {
pub(crate) struct DuplicatePreciseCapture {
#[primary_span]
pub first_span: Span,
pub name: Symbol,
@ -64,7 +64,7 @@ pub struct DuplicatePreciseCapture {
#[derive(Diagnostic)]
#[diag(hir_analysis_lifetime_must_be_first)]
pub struct LifetimesMustBeFirst {
pub(crate) struct LifetimesMustBeFirst {
#[primary_span]
pub lifetime_span: Span,
pub name: Symbol,

View File

@ -8,7 +8,7 @@ use rustc_span::def_id::DefId;
use GenericArgsInfo::*;
/// Handles the `wrong number of type / lifetime / ... arguments` family of error messages.
pub struct WrongNumberOfGenericArgs<'a, 'tcx> {
pub(crate) struct WrongNumberOfGenericArgs<'a, 'tcx> {
pub(crate) tcx: TyCtxt<'tcx>,
pub(crate) angle_brackets: AngleBrackets,
@ -49,7 +49,7 @@ pub(crate) enum AngleBrackets {
// Information about the kind of arguments that are either missing or are unexpected
#[derive(Debug)]
pub enum GenericArgsInfo {
pub(crate) enum GenericArgsInfo {
MissingLifetimes {
num_missing_args: usize,
},
@ -87,7 +87,7 @@ pub enum GenericArgsInfo {
}
impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
pub fn new(
pub(crate) fn new(
tcx: TyCtxt<'tcx>,
gen_args_info: GenericArgsInfo,
path_segment: &'a hir::PathSegment<'_>,

View File

@ -11,7 +11,7 @@ use crate::errors;
/// Check conditions on inputs and outputs that the cmse ABIs impose: arguments and results MUST be
/// returned via registers (i.e. MUST NOT spill to the stack). LLVM will also validate these
/// conditions, but by checking them here rustc can emit nicer error messages.
pub fn validate_cmse_abi<'tcx>(
pub(crate) fn validate_cmse_abi<'tcx>(
tcx: TyCtxt<'tcx>,
dcx: DiagCtxtHandle<'_>,
hir_id: HirId,

View File

@ -11,7 +11,7 @@ use rustc_trait_selection::traits::{self, ObligationCtxt};
use crate::collect::ItemCtxt;
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { diagnostic_hir_wf_check, ..*providers };
}

View File

@ -53,7 +53,10 @@ mod min_specialization;
/// impl<'a> Trait<Foo> for Bar { type X = &'a i32; }
/// // ^ 'a is unused and appears in assoc type, error
/// ```
pub fn check_impl_wf(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) -> Result<(), ErrorGuaranteed> {
pub(crate) fn check_impl_wf(
tcx: TyCtxt<'_>,
impl_def_id: LocalDefId,
) -> Result<(), ErrorGuaranteed> {
let min_specialization = tcx.features().min_specialization;
let mut res = Ok(());
debug_assert_matches!(tcx.def_kind(impl_def_id), DefKind::Impl { .. });

View File

@ -72,6 +72,7 @@ This API is completely unstable and subject to change.
#![feature(slice_partition_dedup)]
#![feature(try_blocks)]
#![feature(unwrap_infallible)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
#[macro_use]

View File

@ -5,12 +5,12 @@ use rustc_middle::ty::{self, OutlivesPredicate, TyCtxt};
use super::utils::*;
#[derive(Debug)]
pub struct ExplicitPredicatesMap<'tcx> {
pub(crate) struct ExplicitPredicatesMap<'tcx> {
map: FxIndexMap<DefId, ty::EarlyBinder<'tcx, RequiredPredicates<'tcx>>>,
}
impl<'tcx> ExplicitPredicatesMap<'tcx> {
pub fn new() -> ExplicitPredicatesMap<'tcx> {
pub(crate) fn new() -> ExplicitPredicatesMap<'tcx> {
ExplicitPredicatesMap { map: FxIndexMap::default() }
}

View File

@ -9,7 +9,7 @@ mod explicit;
mod implicit_infer;
mod utils;
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { inferred_outlives_of, inferred_outlives_crate, ..*providers };
}

View File

@ -12,7 +12,7 @@ use rustc_middle::{bug, span_bug};
use super::terms::VarianceTerm::*;
use super::terms::*;
pub struct ConstraintContext<'a, 'tcx> {
pub(crate) struct ConstraintContext<'a, 'tcx> {
pub terms_cx: TermsContext<'a, 'tcx>,
// These are pointers to common `ConstantTerm` instances
@ -27,7 +27,7 @@ pub struct ConstraintContext<'a, 'tcx> {
/// Declares that the variable `decl_id` appears in a location with
/// variance `variance`.
#[derive(Copy, Clone)]
pub struct Constraint<'a> {
pub(crate) struct Constraint<'a> {
pub inferred: InferredIndex,
pub variance: &'a VarianceTerm<'a>,
}
@ -41,11 +41,11 @@ pub struct Constraint<'a> {
/// ```
/// then while we are visiting `Bar<T>`, the `CurrentItem` would have
/// the `DefId` and the start of `Foo`'s inferreds.
pub struct CurrentItem {
struct CurrentItem {
inferred_start: InferredIndex,
}
pub fn add_constraints_from_crate<'a, 'tcx>(
pub(crate) fn add_constraints_from_crate<'a, 'tcx>(
terms_cx: TermsContext<'a, 'tcx>,
) -> ConstraintContext<'a, 'tcx> {
let tcx = terms_cx.tcx;

View File

@ -28,7 +28,7 @@ pub(crate) mod dump;
/// Code for transforming variances.
mod xform;
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { variances_of, crate_variances, ..*providers };
}

View File

@ -21,7 +21,7 @@ struct SolveContext<'a, 'tcx> {
solutions: Vec<ty::Variance>,
}
pub fn solve_constraints<'tcx>(
pub(crate) fn solve_constraints<'tcx>(
constraints_cx: ConstraintContext<'_, 'tcx>,
) -> ty::CrateVariancesMap<'tcx> {
let ConstraintContext { terms_cx, constraints, .. } = constraints_cx;

View File

@ -18,13 +18,13 @@ use rustc_middle::ty::{self, TyCtxt};
use self::VarianceTerm::*;
pub type VarianceTermPtr<'a> = &'a VarianceTerm<'a>;
pub(crate) type VarianceTermPtr<'a> = &'a VarianceTerm<'a>;
#[derive(Copy, Clone, Debug)]
pub struct InferredIndex(pub usize);
pub(crate) struct InferredIndex(pub usize);
#[derive(Copy, Clone)]
pub enum VarianceTerm<'a> {
pub(crate) enum VarianceTerm<'a> {
ConstantTerm(ty::Variance),
TransformTerm(VarianceTermPtr<'a>, VarianceTermPtr<'a>),
InferredTerm(InferredIndex),
@ -45,7 +45,7 @@ impl<'a> fmt::Debug for VarianceTerm<'a> {
/// The first pass over the crate simply builds up the set of inferreds.
pub struct TermsContext<'a, 'tcx> {
pub(crate) struct TermsContext<'a, 'tcx> {
pub tcx: TyCtxt<'tcx>,
pub arena: &'a DroplessArena,
@ -62,7 +62,7 @@ pub struct TermsContext<'a, 'tcx> {
pub inferred_terms: Vec<VarianceTermPtr<'a>>,
}
pub fn determine_parameters_to_be_inferred<'a, 'tcx>(
pub(crate) fn determine_parameters_to_be_inferred<'a, 'tcx>(
tcx: TyCtxt<'tcx>,
arena: &'a DroplessArena,
) -> TermsContext<'a, 'tcx> {

View File

@ -1,6 +1,6 @@
use rustc_middle::ty;
pub fn glb(v1: ty::Variance, v2: ty::Variance) -> ty::Variance {
pub(crate) fn glb(v1: ty::Variance, v2: ty::Variance) -> ty::Variance {
// Greatest lower bound of the variance lattice as
// defined in The Paper:
//

View File

@ -3,6 +3,7 @@
// tidy-alphabetical-start
#![recursion_limit = "256"]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::cell::Cell;

View File

@ -374,7 +374,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn maybe_get_coercion_reason(
pub(crate) fn maybe_get_coercion_reason(
&self,
hir_id: hir::HirId,
sp: Span,
@ -584,7 +584,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// (e.g. we're in the tail of a function body)
//
// Returns the `LocalDefId` of the RPIT, which is always identity-substituted.
pub fn return_position_impl_trait_from_match_expectation(
pub(crate) fn return_position_impl_trait_from_match_expectation(
&self,
expectation: Expectation<'tcx>,
) -> Option<LocalDefId> {

View File

@ -13,11 +13,11 @@ use super::method::MethodCallee;
use super::{FnCtxt, PlaceOp};
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'tcx> {
pub(crate) fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'tcx> {
Autoderef::new(self, self.param_env, self.body_id, span, base_ty)
}
pub fn try_overloaded_deref(
pub(crate) fn try_overloaded_deref(
&self,
span: Span,
base_ty: Ty<'tcx>,
@ -26,11 +26,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// Returns the adjustment steps.
pub fn adjust_steps(&self, autoderef: &Autoderef<'a, 'tcx>) -> Vec<Adjustment<'tcx>> {
pub(crate) fn adjust_steps(&self, autoderef: &Autoderef<'a, 'tcx>) -> Vec<Adjustment<'tcx>> {
self.register_infer_ok_obligations(self.adjust_steps_as_infer_ok(autoderef))
}
pub fn adjust_steps_as_infer_ok(
pub(crate) fn adjust_steps_as_infer_ok(
&self,
autoderef: &Autoderef<'a, 'tcx>,
) -> InferOk<'tcx, Vec<Adjustment<'tcx>>> {

View File

@ -29,7 +29,7 @@ use crate::errors;
/// Checks that it is legal to call methods of the trait corresponding
/// to `trait_id` (this only cares about the trait, not the specific
/// method that is called).
pub fn check_legal_trait_for_method_call(
pub(crate) fn check_legal_trait_for_method_call(
tcx: TyCtxt<'_>,
span: Span,
receiver: Option<Span>,
@ -62,7 +62,7 @@ enum CallStep<'tcx> {
}
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn check_call(
pub(crate) fn check_call(
&self,
call_expr: &'tcx hir::Expr<'tcx>,
callee_expr: &'tcx hir::Expr<'tcx>,
@ -940,7 +940,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
#[derive(Debug)]
pub struct DeferredCallResolution<'tcx> {
pub(crate) struct DeferredCallResolution<'tcx> {
call_expr: &'tcx hir::Expr<'tcx>,
callee_expr: &'tcx hir::Expr<'tcx>,
closure_ty: Ty<'tcx>,
@ -949,7 +949,7 @@ pub struct DeferredCallResolution<'tcx> {
}
impl<'a, 'tcx> DeferredCallResolution<'tcx> {
pub fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) {
pub(crate) fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) {
debug!("DeferredCallResolution::resolve() {:?}", self);
// we should not be invoked until the closure kind has been

View File

@ -976,7 +976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// adjusted type of the expression, if successful.
/// Adjustments are only recorded if the coercion succeeded.
/// The expressions *must not* have any preexisting adjustments.
pub fn coerce(
pub(crate) fn coerce(
&self,
expr: &hir::Expr<'_>,
expr_ty: Ty<'tcx>,
@ -1011,7 +1011,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
///
/// Returns false if the coercion creates any obligations that result in
/// errors.
pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
pub(crate) fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
// FIXME(-Znext-solver): We need to structurally resolve both types here.
let source = self.resolve_vars_with_obligations(expr_ty);
debug!("coercion::can_with_predicates({:?} -> {:?})", source, target);
@ -1032,7 +1032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Given a type and a target type, this function will calculate and return
/// how many dereference steps needed to achieve `expr_ty <: target`. If
/// it's not possible, return `None`.
pub fn deref_steps(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> Option<usize> {
pub(crate) fn deref_steps(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> Option<usize> {
let cause = self.cause(DUMMY_SP, ObligationCauseCode::ExprAssignable);
// We don't ever need two-phase here since we throw out the result of the coercion
let coerce = Coerce::new(self, cause, AllowTwoPhase::No);
@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// This function is for diagnostics only, since it does not register
/// trait or region sub-obligations. (presumably we could, but it's not
/// particularly important for diagnostics...)
pub fn deref_once_mutably_for_diagnostic(&self, expr_ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
pub(crate) fn deref_once_mutably_for_diagnostic(&self, expr_ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
self.autoderef(DUMMY_SP, expr_ty).nth(1).and_then(|(deref_ty, _)| {
self.infcx
.type_implements_trait(
@ -1341,7 +1341,7 @@ pub fn can_coerce<'tcx>(
/// }
/// let final_ty = coerce.complete(fcx);
/// ```
pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
pub(crate) struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
expected_ty: Ty<'tcx>,
final_ty: Option<Ty<'tcx>>,
expressions: Expressions<'tcx, 'exprs, E>,
@ -1350,7 +1350,7 @@ pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
/// The type of a `CoerceMany` that is storing up the expressions into
/// a buffer. We use this in `check/mod.rs` for things like `break`.
pub type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, &'tcx hir::Expr<'tcx>>;
pub(crate) type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, &'tcx hir::Expr<'tcx>>;
enum Expressions<'tcx, 'exprs, E: AsCoercionSite> {
Dynamic(Vec<&'tcx hir::Expr<'tcx>>),
@ -1361,7 +1361,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// The usual case; collect the set of expressions dynamically.
/// If the full set of coercion sites is known before hand,
/// consider `with_coercion_sites()` instead to avoid allocation.
pub fn new(expected_ty: Ty<'tcx>) -> Self {
pub(crate) fn new(expected_ty: Ty<'tcx>) -> Self {
Self::make(expected_ty, Expressions::Dynamic(vec![]))
}
@ -1370,7 +1370,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// expected to pass each element in the slice to `coerce(...)` in
/// order. This is used with arrays in particular to avoid
/// needlessly cloning the slice.
pub fn with_coercion_sites(expected_ty: Ty<'tcx>, coercion_sites: &'exprs [E]) -> Self {
pub(crate) fn with_coercion_sites(expected_ty: Ty<'tcx>, coercion_sites: &'exprs [E]) -> Self {
Self::make(expected_ty, Expressions::UpFront(coercion_sites))
}
@ -1386,7 +1386,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// Typically, this is used as the expected type when
/// type-checking each of the alternative expressions whose types
/// we are trying to merge.
pub fn expected_ty(&self) -> Ty<'tcx> {
pub(crate) fn expected_ty(&self) -> Ty<'tcx> {
self.expected_ty
}
@ -1394,7 +1394,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// at the LUB of the expressions we've seen so far (if any). This
/// isn't *final* until you call `self.complete()`, which will return
/// the merged type.
pub fn merged_ty(&self) -> Ty<'tcx> {
pub(crate) fn merged_ty(&self) -> Ty<'tcx> {
self.final_ty.unwrap_or(self.expected_ty)
}
@ -1403,7 +1403,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// could coerce from. This will record `expression`, and later
/// calls to `coerce` may come back and add adjustments and things
/// if necessary.
pub fn coerce<'a>(
pub(crate) fn coerce<'a>(
&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
@ -1425,7 +1425,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// The `augment_error` gives you a chance to extend the error
/// message, in case any results (e.g., we use this to suggest
/// removing a `;`).
pub fn coerce_forced_unit<'a>(
pub(crate) fn coerce_forced_unit<'a>(
&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
@ -1920,7 +1920,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
}
}
pub fn complete<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> {
pub(crate) fn complete<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> {
if let Some(final_ty) = self.final_ty {
final_ty
} else {
@ -1934,7 +1934,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// Something that can be converted into an expression to which we can
/// apply a coercion.
pub trait AsCoercionSite {
pub(crate) trait AsCoercionSite {
fn as_coercion_site(&self) -> &hir::Expr<'_>;
}

View File

@ -18,7 +18,7 @@ use super::method::probe;
use crate::FnCtxt;
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn emit_type_mismatch_suggestions(
pub(crate) fn emit_type_mismatch_suggestions(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'tcx>,
@ -70,7 +70,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn emit_coerce_suggestions(
pub(crate) fn emit_coerce_suggestions(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'tcx>,
@ -165,13 +165,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Requires that the two types unify, and prints an error message if
/// they don't.
pub fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
pub(crate) fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
if let Err(e) = self.demand_suptype_diag(sp, expected, actual) {
e.emit();
}
}
pub fn demand_suptype_diag(
pub(crate) fn demand_suptype_diag(
&'a self,
sp: Span,
expected: Ty<'tcx>,
@ -193,13 +193,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
}
pub fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
pub(crate) fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
if let Err(err) = self.demand_eqtype_diag(sp, expected, actual) {
err.emit();
}
}
pub fn demand_eqtype_diag(
pub(crate) fn demand_eqtype_diag(
&'a self,
sp: Span,
expected: Ty<'tcx>,
@ -208,7 +208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.demand_eqtype_with_origin(&self.misc(sp), expected, actual)
}
pub fn demand_eqtype_with_origin(
pub(crate) fn demand_eqtype_with_origin(
&'a self,
cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>,
@ -220,7 +220,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
}
pub fn demand_coerce(
pub(crate) fn demand_coerce(
&self,
expr: &'tcx hir::Expr<'tcx>,
checked_ty: Ty<'tcx>,
@ -279,7 +279,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Notes the point at which a variable is constrained to some type incompatible
/// with some expectation given by `source`.
pub fn note_source_of_type_mismatch_constraint(
pub(crate) fn note_source_of_type_mismatch_constraint(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'_>,
@ -558,7 +558,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// When encountering a type error on the value of a `break`, try to point at the reason for the
// expected type.
pub fn annotate_loop_expected_due_to_inference(
pub(crate) fn annotate_loop_expected_due_to_inference(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'_>,
@ -964,7 +964,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}
pub fn get_conversion_methods_for_diagnostic(
pub(crate) fn get_conversion_methods_for_diagnostic(
&self,
span: Span,
expected: Ty<'tcx>,
@ -1186,7 +1186,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub enum TypeMismatchSource<'tcx> {
pub(crate) enum TypeMismatchSource<'tcx> {
/// Expected the binding to have the given type, but it was found to have
/// a different type. Find out when that type first became incompatible.
Ty(Ty<'tcx>),

View File

@ -8,7 +8,7 @@ use rustc_span::{Span, DUMMY_SP};
/// as diverging), with some manual adjustments for control-flow
/// primitives (approximating a CFG).
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Diverges {
pub(crate) enum Diverges {
/// Potentially unknown, some cases converge,
/// others require a CFG to determine them.
Maybe,

View File

@ -17,7 +17,7 @@ use crate::fluent_generated as fluent;
#[derive(Diagnostic)]
#[diag(hir_typeck_field_multiply_specified_in_initializer, code = E0062)]
pub struct FieldMultiplySpecifiedInInitializer {
pub(crate) struct FieldMultiplySpecifiedInInitializer {
#[primary_span]
#[label]
pub span: Span,
@ -28,7 +28,7 @@ pub struct FieldMultiplySpecifiedInInitializer {
#[derive(Diagnostic)]
#[diag(hir_typeck_return_stmt_outside_of_fn_body, code = E0572)]
pub struct ReturnStmtOutsideOfFnBody {
pub(crate) struct ReturnStmtOutsideOfFnBody {
#[primary_span]
pub span: Span,
#[label(hir_typeck_encl_body_label)]
@ -38,7 +38,7 @@ pub struct ReturnStmtOutsideOfFnBody {
pub statement_kind: ReturnLikeStatementKind,
}
pub enum ReturnLikeStatementKind {
pub(crate) enum ReturnLikeStatementKind {
Return,
Become,
}
@ -57,21 +57,21 @@ impl IntoDiagArg for ReturnLikeStatementKind {
#[derive(Diagnostic)]
#[diag(hir_typeck_rustcall_incorrect_args)]
pub struct RustCallIncorrectArgs {
pub(crate) struct RustCallIncorrectArgs {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_typeck_yield_expr_outside_of_coroutine, code = E0627)]
pub struct YieldExprOutsideOfCoroutine {
pub(crate) struct YieldExprOutsideOfCoroutine {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_typeck_struct_expr_non_exhaustive, code = E0639)]
pub struct StructExprNonExhaustive {
pub(crate) struct StructExprNonExhaustive {
#[primary_span]
pub span: Span,
pub what: &'static str,
@ -79,21 +79,21 @@ pub struct StructExprNonExhaustive {
#[derive(Diagnostic)]
#[diag(hir_typeck_functional_record_update_on_non_struct, code = E0436)]
pub struct FunctionalRecordUpdateOnNonStruct {
pub(crate) struct FunctionalRecordUpdateOnNonStruct {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_typeck_address_of_temporary_taken, code = E0745)]
pub struct AddressOfTemporaryTaken {
pub(crate) struct AddressOfTemporaryTaken {
#[primary_span]
#[label]
pub span: Span,
}
#[derive(Subdiagnostic)]
pub enum AddReturnTypeSuggestion {
pub(crate) enum AddReturnTypeSuggestion {
#[suggestion(
hir_typeck_add_return_type_add,
code = " -> {found}",
@ -116,7 +116,7 @@ pub enum AddReturnTypeSuggestion {
}
#[derive(Subdiagnostic)]
pub enum ExpectedReturnTypeLabel<'tcx> {
pub(crate) enum ExpectedReturnTypeLabel<'tcx> {
#[label(hir_typeck_expected_default_return_type)]
Unit {
#[primary_span]
@ -132,7 +132,7 @@ pub enum ExpectedReturnTypeLabel<'tcx> {
#[derive(Diagnostic)]
#[diag(hir_typeck_explicit_destructor, code = E0040)]
pub struct ExplicitDestructorCall {
pub(crate) struct ExplicitDestructorCall {
#[primary_span]
#[label]
pub span: Span,
@ -141,7 +141,7 @@ pub struct ExplicitDestructorCall {
}
#[derive(Subdiagnostic)]
pub enum ExplicitDestructorCallSugg {
pub(crate) enum ExplicitDestructorCallSugg {
#[suggestion(hir_typeck_suggestion, code = "drop", applicability = "maybe-incorrect")]
Empty(#[primary_span] Span),
#[multipart_suggestion(hir_typeck_suggestion, style = "short")]
@ -155,7 +155,7 @@ pub enum ExplicitDestructorCallSugg {
#[derive(Diagnostic)]
#[diag(hir_typeck_missing_parentheses_in_range, code = E0689)]
pub struct MissingParenthesesInRange {
pub(crate) struct MissingParenthesesInRange {
#[primary_span]
#[label(hir_typeck_missing_parentheses_in_range)]
pub span: Span,
@ -166,7 +166,7 @@ pub struct MissingParenthesesInRange {
}
#[derive(LintDiagnostic)]
pub enum NeverTypeFallbackFlowingIntoUnsafe {
pub(crate) enum NeverTypeFallbackFlowingIntoUnsafe {
#[help]
#[diag(hir_typeck_never_type_fallback_flowing_into_unsafe_call)]
Call,
@ -187,7 +187,7 @@ pub enum NeverTypeFallbackFlowingIntoUnsafe {
#[derive(LintDiagnostic)]
#[help]
#[diag(hir_typeck_dependency_on_unit_never_type_fallback)]
pub struct DependencyOnUnitNeverTypeFallback<'tcx> {
pub(crate) struct DependencyOnUnitNeverTypeFallback<'tcx> {
#[note]
pub obligation_span: Span,
pub obligation: ty::Predicate<'tcx>,
@ -199,7 +199,7 @@ pub struct DependencyOnUnitNeverTypeFallback<'tcx> {
style = "verbose",
applicability = "maybe-incorrect"
)]
pub struct AddMissingParenthesesInRange {
pub(crate) struct AddMissingParenthesesInRange {
pub func_name: String,
#[suggestion_part(code = "(")]
pub left: Span,
@ -207,7 +207,7 @@ pub struct AddMissingParenthesesInRange {
pub right: Span,
}
pub struct TypeMismatchFruTypo {
pub(crate) struct TypeMismatchFruTypo {
/// Span of the LHS of the range
pub expr_span: Span,
/// Span of the `..RHS` part of the range
@ -246,7 +246,7 @@ impl Subdiagnostic for TypeMismatchFruTypo {
#[derive(LintDiagnostic)]
#[diag(hir_typeck_lossy_provenance_int2ptr)]
#[help]
pub struct LossyProvenanceInt2Ptr<'tcx> {
pub(crate) struct LossyProvenanceInt2Ptr<'tcx> {
pub expr_ty: Ty<'tcx>,
pub cast_ty: Ty<'tcx>,
#[subdiagnostic]
@ -255,14 +255,14 @@ pub struct LossyProvenanceInt2Ptr<'tcx> {
#[derive(LintDiagnostic)]
#[diag(hir_typeck_ptr_cast_add_auto_to_object)]
pub struct PtrCastAddAutoToObject {
pub(crate) struct PtrCastAddAutoToObject {
pub traits_len: usize,
pub traits: DiagSymbolList<String>,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(hir_typeck_suggestion, applicability = "has-placeholders")]
pub struct LossyProvenanceInt2PtrSuggestion {
pub(crate) struct LossyProvenanceInt2PtrSuggestion {
#[suggestion_part(code = "(...).with_addr(")]
pub lo: Span,
#[suggestion_part(code = ")")]
@ -272,7 +272,7 @@ pub struct LossyProvenanceInt2PtrSuggestion {
#[derive(LintDiagnostic)]
#[diag(hir_typeck_lossy_provenance_ptr2int)]
#[help]
pub struct LossyProvenancePtr2Int<'tcx> {
pub(crate) struct LossyProvenancePtr2Int<'tcx> {
pub expr_ty: Ty<'tcx>,
pub cast_ty: Ty<'tcx>,
#[subdiagnostic]
@ -280,7 +280,7 @@ pub struct LossyProvenancePtr2Int<'tcx> {
}
#[derive(Subdiagnostic)]
pub enum LossyProvenancePtr2IntSuggestion<'tcx> {
pub(crate) enum LossyProvenancePtr2IntSuggestion<'tcx> {
#[multipart_suggestion(hir_typeck_suggestion, applicability = "maybe-incorrect")]
NeedsParensCast {
#[suggestion_part(code = "(")]
@ -314,7 +314,7 @@ pub enum LossyProvenancePtr2IntSuggestion<'tcx> {
}
#[derive(Subdiagnostic)]
pub enum HelpUseLatestEdition {
pub(crate) enum HelpUseLatestEdition {
#[help(hir_typeck_help_set_edition_cargo)]
#[note(hir_typeck_note_edition_guide)]
Cargo { edition: Edition },
@ -324,7 +324,7 @@ pub enum HelpUseLatestEdition {
}
impl HelpUseLatestEdition {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
let edition = LATEST_STABLE_EDITION;
if rustc_session::utils::was_invoked_from_cargo() {
Self::Cargo { edition }
@ -336,7 +336,7 @@ impl HelpUseLatestEdition {
#[derive(Diagnostic)]
#[diag(hir_typeck_invalid_callee, code = E0618)]
pub struct InvalidCallee {
pub(crate) struct InvalidCallee {
#[primary_span]
pub span: Span,
pub ty: String,
@ -344,7 +344,7 @@ pub struct InvalidCallee {
#[derive(Diagnostic)]
#[diag(hir_typeck_int_to_fat, code = E0606)]
pub struct IntToWide<'tcx> {
pub(crate) struct IntToWide<'tcx> {
#[primary_span]
#[label(hir_typeck_int_to_fat_label)]
pub span: Span,
@ -357,7 +357,7 @@ pub struct IntToWide<'tcx> {
}
#[derive(Subdiagnostic)]
pub enum OptionResultRefMismatch {
pub(crate) enum OptionResultRefMismatch {
#[suggestion(
hir_typeck_option_result_copied,
code = ".copied()",
@ -396,7 +396,7 @@ pub enum OptionResultRefMismatch {
// },
}
pub struct RemoveSemiForCoerce {
pub(crate) struct RemoveSemiForCoerce {
pub expr: Span,
pub ret: Span,
pub semi: Span,
@ -426,7 +426,7 @@ impl Subdiagnostic for RemoveSemiForCoerce {
#[derive(Diagnostic)]
#[diag(hir_typeck_const_select_must_be_const)]
#[help]
pub struct ConstSelectMustBeConst {
pub(crate) struct ConstSelectMustBeConst {
#[primary_span]
pub span: Span,
}
@ -435,7 +435,7 @@ pub struct ConstSelectMustBeConst {
#[diag(hir_typeck_const_select_must_be_fn)]
#[note]
#[help]
pub struct ConstSelectMustBeFn<'a> {
pub(crate) struct ConstSelectMustBeFn<'a> {
#[primary_span]
pub span: Span,
pub ty: Ty<'a>,
@ -443,14 +443,14 @@ pub struct ConstSelectMustBeFn<'a> {
#[derive(Diagnostic)]
#[diag(hir_typeck_union_pat_multiple_fields)]
pub struct UnionPatMultipleFields {
pub(crate) struct UnionPatMultipleFields {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(hir_typeck_union_pat_dotdot)]
pub struct UnionPatDotDot {
pub(crate) struct UnionPatDotDot {
#[primary_span]
pub span: Span,
}
@ -461,7 +461,7 @@ pub struct UnionPatDotDot {
applicability = "maybe-incorrect",
style = "verbose"
)]
pub struct UseIsEmpty {
pub(crate) struct UseIsEmpty {
#[suggestion_part(code = "!")]
pub lo: Span,
#[suggestion_part(code = ".is_empty()")]
@ -471,13 +471,13 @@ pub struct UseIsEmpty {
#[derive(Diagnostic)]
#[diag(hir_typeck_arg_mismatch_indeterminate)]
pub struct ArgMismatchIndeterminate {
pub(crate) struct ArgMismatchIndeterminate {
#[primary_span]
pub span: Span,
}
#[derive(Subdiagnostic)]
pub enum SuggestBoxing {
pub(crate) enum SuggestBoxing {
#[note(hir_typeck_suggest_boxing_note)]
#[multipart_suggestion(
hir_typeck_suggest_boxing_when_appropriate,
@ -511,7 +511,7 @@ pub enum SuggestBoxing {
style = "verbose",
code = "core::ptr::null_mut()"
)]
pub struct SuggestPtrNullMut {
pub(crate) struct SuggestPtrNullMut {
#[primary_span]
pub span: Span,
}
@ -519,7 +519,7 @@ pub struct SuggestPtrNullMut {
#[derive(LintDiagnostic)]
#[diag(hir_typeck_trivial_cast)]
#[help]
pub struct TrivialCast<'tcx> {
pub(crate) struct TrivialCast<'tcx> {
pub numeric: bool,
pub expr_ty: Ty<'tcx>,
pub cast_ty: Ty<'tcx>,
@ -527,7 +527,7 @@ pub struct TrivialCast<'tcx> {
#[derive(Diagnostic)]
#[diag(hir_typeck_no_associated_item, code = E0599)]
pub struct NoAssociatedItem {
pub(crate) struct NoAssociatedItem {
#[primary_span]
pub span: Span,
pub item_kind: &'static str,
@ -539,7 +539,7 @@ pub struct NoAssociatedItem {
#[derive(Subdiagnostic)]
#[note(hir_typeck_candidate_trait_note)]
pub struct CandidateTraitNote {
pub(crate) struct CandidateTraitNote {
#[primary_span]
pub span: Span,
pub trait_name: String,
@ -549,7 +549,7 @@ pub struct CandidateTraitNote {
#[derive(Diagnostic)]
#[diag(hir_typeck_cannot_cast_to_bool, code = E0054)]
pub struct CannotCastToBool<'tcx> {
pub(crate) struct CannotCastToBool<'tcx> {
#[primary_span]
pub span: Span,
pub expr_ty: Ty<'tcx>,
@ -559,14 +559,14 @@ pub struct CannotCastToBool<'tcx> {
#[derive(LintDiagnostic)]
#[diag(hir_typeck_cast_enum_drop)]
pub struct CastEnumDrop<'tcx> {
pub(crate) struct CastEnumDrop<'tcx> {
pub expr_ty: Ty<'tcx>,
pub cast_ty: Ty<'tcx>,
}
#[derive(Diagnostic)]
#[diag(hir_typeck_cast_unknown_pointer, code = E0641)]
pub struct CastUnknownPointer {
pub(crate) struct CastUnknownPointer {
#[primary_span]
pub span: Span,
pub to: bool,
@ -574,7 +574,7 @@ pub struct CastUnknownPointer {
pub sub: CastUnknownPointerSub,
}
pub enum CastUnknownPointerSub {
pub(crate) enum CastUnknownPointerSub {
To(Span),
From(Span),
}
@ -601,7 +601,7 @@ impl rustc_errors::Subdiagnostic for CastUnknownPointerSub {
}
#[derive(Subdiagnostic)]
pub enum CannotCastToBoolHelp {
pub(crate) enum CannotCastToBoolHelp {
#[suggestion(
hir_typeck_suggestion,
applicability = "machine-applicable",
@ -615,7 +615,7 @@ pub enum CannotCastToBoolHelp {
#[derive(Diagnostic)]
#[diag(hir_typeck_ctor_is_private, code = E0603)]
pub struct CtorIsPrivate {
pub(crate) struct CtorIsPrivate {
#[primary_span]
pub span: Span,
pub def: String,
@ -623,7 +623,7 @@ pub struct CtorIsPrivate {
#[derive(Subdiagnostic)]
#[note(hir_typeck_deref_is_empty)]
pub struct DerefImplsIsEmpty {
pub(crate) struct DerefImplsIsEmpty {
#[primary_span]
pub span: Span,
pub deref_ty: String,
@ -635,7 +635,7 @@ pub struct DerefImplsIsEmpty {
applicability = "machine-applicable",
style = "verbose"
)]
pub struct SuggestConvertViaMethod<'tcx> {
pub(crate) struct SuggestConvertViaMethod<'tcx> {
#[suggestion_part(code = "{sugg}")]
pub span: Span,
#[suggestion_part(code = "")]
@ -647,13 +647,13 @@ pub struct SuggestConvertViaMethod<'tcx> {
#[derive(Subdiagnostic)]
#[note(hir_typeck_note_caller_chooses_ty_for_ty_param)]
pub struct NoteCallerChoosesTyForTyParam<'tcx> {
pub(crate) struct NoteCallerChoosesTyForTyParam<'tcx> {
pub ty_param_name: Symbol,
pub found_ty: Ty<'tcx>,
}
#[derive(Subdiagnostic)]
pub enum SuggestBoxingForReturnImplTrait {
pub(crate) enum SuggestBoxingForReturnImplTrait {
#[multipart_suggestion(hir_typeck_rpit_change_return_type, applicability = "maybe-incorrect")]
ChangeReturnType {
#[suggestion_part(code = "Box<dyn")]
@ -672,7 +672,7 @@ pub enum SuggestBoxingForReturnImplTrait {
#[derive(Diagnostic)]
#[diag(hir_typeck_self_ctor_from_outer_item, code = E0401)]
pub struct SelfCtorFromOuterItem {
pub(crate) struct SelfCtorFromOuterItem {
#[primary_span]
pub span: Span,
#[label]
@ -683,7 +683,7 @@ pub struct SelfCtorFromOuterItem {
#[derive(LintDiagnostic)]
#[diag(hir_typeck_self_ctor_from_outer_item)]
pub struct SelfCtorFromOuterItemLint {
pub(crate) struct SelfCtorFromOuterItemLint {
#[label]
pub impl_span: Span,
#[subdiagnostic]
@ -692,7 +692,7 @@ pub struct SelfCtorFromOuterItemLint {
#[derive(Subdiagnostic)]
#[suggestion(hir_typeck_suggestion, code = "{name}", applicability = "machine-applicable")]
pub struct ReplaceWithName {
pub(crate) struct ReplaceWithName {
#[primary_span]
pub span: Span,
pub name: String,

View File

@ -7,7 +7,7 @@ use super::FnCtxt;
/// When type-checking an expression, we propagate downward
/// whatever type hint we are able in the form of an `Expectation`.
#[derive(Copy, Clone, Debug)]
pub enum Expectation<'tcx> {
pub(crate) enum Expectation<'tcx> {
/// We know nothing about what type this expression should have.
NoExpectation,

View File

@ -51,7 +51,7 @@ use crate::{
};
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn check_expr_has_type_or_error(
pub(crate) fn check_expr_has_type_or_error(
&self,
expr: &'tcx hir::Expr<'tcx>,
expected_ty: Ty<'tcx>,
@ -977,7 +977,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// Check if the expression that could not be assigned to was a typoed expression that
pub fn check_for_missing_semi(&self, expr: &'tcx hir::Expr<'tcx>, err: &mut Diag<'_>) -> bool {
pub(crate) fn check_for_missing_semi(
&self,
expr: &'tcx hir::Expr<'tcx>,
err: &mut Diag<'_>,
) -> bool {
if let hir::ExprKind::Binary(binop, lhs, rhs) = expr.kind
&& let hir::BinOpKind::Mul = binop.node
&& self.tcx.sess.source_map().is_multiline(lhs.span.between(rhs.span))

View File

@ -18,7 +18,7 @@ use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
use crate::{errors, FnCtxt, TypeckRootCtxt};
#[derive(Copy, Clone)]
pub enum DivergingFallbackBehavior {
pub(crate) enum DivergingFallbackBehavior {
/// Always fallback to `()` (aka "always spontaneous decay")
ToUnit,
/// Sometimes fallback to `!`, but mainly fallback to `()` so that most of the crates are not broken.

View File

@ -132,18 +132,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
deferred_call_resolutions.remove(&closure_def_id).unwrap_or_default()
}
pub fn tag(&self) -> String {
fn tag(&self) -> String {
format!("{self:p}")
}
pub fn local_ty(&self, span: Span, nid: HirId) -> Ty<'tcx> {
pub(crate) fn local_ty(&self, span: Span, nid: HirId) -> Ty<'tcx> {
self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| {
span_bug!(span, "no type for local variable {}", self.tcx.hir().node_to_string(nid))
})
}
#[inline]
pub fn write_ty(&self, id: HirId, ty: Ty<'tcx>) {
pub(crate) fn write_ty(&self, id: HirId, ty: Ty<'tcx>) {
debug!("write_ty({:?}, {:?}) in fcx {}", id, self.resolve_vars_if_possible(ty), self.tag());
let mut typeck = self.typeck_results.borrow_mut();
let mut node_ty = typeck.node_types_mut();
@ -165,7 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn write_field_index(
pub(crate) fn write_field_index(
&self,
hir_id: HirId,
index: FieldIdx,
@ -198,7 +198,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.write_args(hir_id, method.args);
}
pub fn write_args(&self, node_id: HirId, args: GenericArgsRef<'tcx>) {
fn write_args(&self, node_id: HirId, args: GenericArgsRef<'tcx>) {
if !args.is_empty() {
debug!("write_args({:?}, {:?}) in fcx {}", node_id, args, self.tag());
@ -364,7 +364,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
)
}
pub fn require_type_meets(
pub(crate) fn require_type_meets(
&self,
ty: Ty<'tcx>,
span: Span,
@ -374,7 +374,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.register_bound(ty, def_id, traits::ObligationCause::new(span, self.body_id, code));
}
pub fn require_type_is_sized(
pub(crate) fn require_type_is_sized(
&self,
ty: Ty<'tcx>,
span: Span,
@ -386,7 +386,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn require_type_is_sized_deferred(
pub(crate) fn require_type_is_sized_deferred(
&self,
ty: Ty<'tcx>,
span: Span,
@ -397,7 +397,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn require_type_has_static_alignment(
pub(crate) fn require_type_has_static_alignment(
&self,
ty: Ty<'tcx>,
span: Span,
@ -426,7 +426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn register_bound(
pub(crate) fn register_bound(
&self,
ty: Ty<'tcx>,
def_id: DefId,
@ -443,7 +443,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> LoweredTy<'tcx> {
pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> LoweredTy<'tcx> {
let ty = self.lowerer().lower_ty(hir_ty);
self.register_wf_obligation(ty.into(), hir_ty.span, ObligationCauseCode::WellFormed(None));
LoweredTy::from_raw(self, hir_ty.span, ty)
@ -474,7 +474,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn lower_array_length(&self, length: &hir::ArrayLen<'tcx>) -> ty::Const<'tcx> {
pub(crate) fn lower_array_length(&self, length: &hir::ArrayLen<'tcx>) -> ty::Const<'tcx> {
match length {
hir::ArrayLen::Infer(inf) => self.ct_infer(None, inf.span),
hir::ArrayLen::Body(const_arg) => {
@ -486,7 +486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn lower_const_arg(
pub(crate) fn lower_const_arg(
&self,
const_arg: &'tcx hir::ConstArg<'tcx>,
param_def_id: DefId,
@ -515,7 +515,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
t.has_free_regions() || t.has_aliases() || t.has_infer_types()
}
pub fn node_ty(&self, id: HirId) -> Ty<'tcx> {
pub(crate) fn node_ty(&self, id: HirId) -> Ty<'tcx> {
match self.typeck_results.borrow().node_types().get(id) {
Some(&t) => t,
None if let Some(e) = self.tainted_by_errors() => Ty::new_error(self.tcx, e),
@ -529,7 +529,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn node_ty_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
pub(crate) fn node_ty_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
match self.typeck_results.borrow().node_types().get(id) {
Some(&t) => Some(t),
None if let Some(e) = self.tainted_by_errors() => Some(Ty::new_error(self.tcx, e)),
@ -538,7 +538,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// Registers an obligation for checking later, during regionck, that `arg` is well-formed.
pub fn register_wf_obligation(
pub(crate) fn register_wf_obligation(
&self,
arg: ty::GenericArg<'tcx>,
span: Span,
@ -555,7 +555,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// Registers obligations that all `args` are well-formed.
pub fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, expr: &hir::Expr<'_>) {
pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, expr: &hir::Expr<'_>) {
for arg in args.iter().filter(|arg| {
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
}) {
@ -566,7 +566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// FIXME(arielb1): use this instead of field.ty everywhere
// Only for fields! Returns <none> for methods>
// Indifferent to privacy flags
pub fn field_ty(
pub(crate) fn field_ty(
&self,
span: Span,
field: &'tcx ty::FieldDef,
@ -897,7 +897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Given a `HirId`, return the `HirId` of the enclosing function, its `FnDecl`, and whether a
/// suggestion can be made, `None` otherwise.
pub fn get_fn_decl(
pub(crate) fn get_fn_decl(
&self,
blk_id: HirId,
) -> Option<(LocalDefId, &'tcx hir::FnDecl<'tcx>, bool)> {
@ -1534,7 +1534,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
///
/// If no resolution is possible, then an error is reported.
/// Numeric inference variables may be left unresolved.
pub fn structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
pub(crate) fn structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
let ty = self.try_structurally_resolve_type(sp, ty);
if !ty.is_ty_var() {

View File

@ -12,7 +12,7 @@ use rustc_trait_selection::traits;
use crate::FnCtxt;
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn adjust_fulfillment_error_for_expr_obligation(
pub(crate) fn adjust_fulfillment_error_for_expr_obligation(
&self,
error: &mut traits::FulfillmentError<'tcx>,
) -> bool {
@ -483,7 +483,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
*
* This function only updates the error span.
*/
pub fn blame_specific_expr_if_possible(
pub(crate) fn blame_specific_expr_if_possible(
&self,
error: &mut traits::FulfillmentError<'tcx>,
expr: &'tcx hir::Expr<'tcx>,

View File

@ -17,7 +17,7 @@ rustc_index::newtype_index! {
}
impl ExpectedIdx {
pub fn to_provided_idx(self) -> ProvidedIdx {
pub(crate) fn to_provided_idx(self) -> ProvidedIdx {
ProvidedIdx::from_usize(self.as_usize())
}
}

View File

@ -45,7 +45,7 @@ use crate::{
};
#[derive(Clone, Copy, Default)]
pub enum DivergingBlockBehavior {
pub(crate) enum DivergingBlockBehavior {
/// This is the current stable behavior:
///
/// ```rust
@ -1556,7 +1556,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn check_struct_path(
pub(crate) fn check_struct_path(
&self,
qpath: &QPath<'tcx>,
hir_id: HirId,
@ -1622,7 +1622,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn check_decl_initializer(
fn check_decl_initializer(
&self,
hir_id: HirId,
pat: &'tcx hir::Pat<'tcx>,
@ -1700,7 +1700,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// Type check a `let` statement.
pub fn check_decl_local(&self, local: &'tcx hir::LetStmt<'tcx>) {
fn check_decl_local(&self, local: &'tcx hir::LetStmt<'tcx>) {
self.check_decl(local.into());
if local.pat.is_never_pattern() {
self.diverges.set(Diverges::Always {
@ -1710,7 +1710,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn check_stmt(&self, stmt: &'tcx hir::Stmt<'tcx>) {
fn check_stmt(&self, stmt: &'tcx hir::Stmt<'tcx>) {
// Don't do all the complex logic below for `DeclItem`.
match stmt.kind {
hir::StmtKind::Item(..) => return,
@ -1745,7 +1745,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.diverges.set(self.diverges.get() | old_diverges);
}
pub fn check_block_no_value(&self, blk: &'tcx hir::Block<'tcx>) {
pub(crate) fn check_block_no_value(&self, blk: &'tcx hir::Block<'tcx>) {
let unit = self.tcx.types.unit;
let ty = self.check_block_with_expected(blk, ExpectHasType(unit));

View File

@ -117,7 +117,7 @@ pub(crate) struct FnCtxt<'a, 'tcx> {
}
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn new(
pub(crate) fn new(
root_ctxt: &'a TypeckRootCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
body_id: LocalDefId,
@ -148,15 +148,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.root_ctxt.infcx.dcx()
}
pub fn cause(&self, span: Span, code: ObligationCauseCode<'tcx>) -> ObligationCause<'tcx> {
pub(crate) fn cause(
&self,
span: Span,
code: ObligationCauseCode<'tcx>,
) -> ObligationCause<'tcx> {
ObligationCause::new(span, self.body_id, code)
}
pub fn misc(&self, span: Span) -> ObligationCause<'tcx> {
pub(crate) fn misc(&self, span: Span) -> ObligationCause<'tcx> {
self.cause(span, ObligationCauseCode::Misc)
}
pub fn sess(&self) -> &Session {
pub(crate) fn sess(&self) -> &Session {
self.tcx.sess
}
@ -165,7 +169,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Use [`InferCtxtErrorExt::err_ctxt`] to start one without a `TypeckResults`.
///
/// [`InferCtxtErrorExt::err_ctxt`]: rustc_trait_selection::error_reporting::InferCtxtErrorExt::err_ctxt
pub fn err_ctxt(&'a self) -> TypeErrCtxt<'a, 'tcx> {
pub(crate) fn err_ctxt(&'a self) -> TypeErrCtxt<'a, 'tcx> {
let mut sub_relations = SubRelations::default();
sub_relations.add_constraints(
self,
@ -365,7 +369,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
/// This is a bridge between the interface of HIR ty lowering, which outputs a raw
/// `Ty`, and the API in this module, which expect `Ty` to be fully normalized.
#[derive(Clone, Copy, Debug)]
pub struct LoweredTy<'tcx> {
pub(crate) struct LoweredTy<'tcx> {
/// The unnormalized type provided by the user.
pub raw: Ty<'tcx>,
@ -374,7 +378,7 @@ pub struct LoweredTy<'tcx> {
}
impl<'tcx> LoweredTy<'tcx> {
pub fn from_raw(fcx: &FnCtxt<'_, 'tcx>, span: Span, raw: Ty<'tcx>) -> LoweredTy<'tcx> {
fn from_raw(fcx: &FnCtxt<'_, 'tcx>, span: Span, raw: Ty<'tcx>) -> LoweredTy<'tcx> {
// FIXME(-Znext-solver): We're still figuring out how to best handle
// normalization and this doesn't feel too great. We should look at this
// code again before stabilizing it.

View File

@ -64,7 +64,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// - Points out the method's return type as the reason for the expected type.
/// - Possible missing semicolon.
/// - Possible missing return type if the return type is the default, and not `fn main()`.
pub fn suggest_mismatched_types_on_tail(
pub(crate) fn suggest_mismatched_types_on_tail(
&self,
err: &mut Diag<'_>,
expr: &'tcx hir::Expr<'tcx>,
@ -177,7 +177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.err_ctxt().extract_callable_info(self.body_id, self.param_env, ty)
}
pub fn suggest_two_fn_call(
pub(crate) fn suggest_two_fn_call(
&self,
err: &mut Diag<'_>,
lhs_expr: &'tcx hir::Expr<'tcx>,
@ -251,7 +251,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn suggest_remove_last_method_call(
pub(crate) fn suggest_remove_last_method_call(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'tcx>,
@ -280,7 +280,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
false
}
pub fn suggest_deref_ref_or_into(
pub(crate) fn suggest_deref_ref_or_into(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'tcx>,
@ -747,7 +747,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
///
/// If the expression is the expression of a closure without block (`|| expr`), a
/// block is needed to be added too (`|| { expr; }`). This is denoted by `needs_block`.
pub fn suggest_missing_semicolon(
pub(crate) fn suggest_missing_semicolon(
&self,
err: &mut Diag<'_>,
expression: &'tcx hir::Expr<'tcx>,
@ -2077,7 +2077,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// If the expr is a while or for loop and is the tail expr of its
// enclosing body suggest returning a value right after it
pub fn suggest_returning_value_after_loop(
pub(crate) fn suggest_returning_value_after_loop(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'tcx>,

View File

@ -38,7 +38,7 @@ fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
}
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn check_transmute(&self, from: Ty<'tcx>, to: Ty<'tcx>, hir_id: HirId) {
pub(crate) fn check_transmute(&self, from: Ty<'tcx>, to: Ty<'tcx>, hir_id: HirId) {
let tcx = self.tcx;
let dl = &tcx.data_layout;
let span = tcx.hir().span(hir_id);

View File

@ -8,6 +8,7 @@
#![feature(let_chains)]
#![feature(never_type)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
#[macro_use]

View File

@ -42,13 +42,13 @@ impl<'a, 'tcx> Deref for ConfirmContext<'a, 'tcx> {
}
#[derive(Debug)]
pub struct ConfirmResult<'tcx> {
pub(crate) struct ConfirmResult<'tcx> {
pub callee: MethodCallee<'tcx>,
pub illegal_sized_bound: Option<Span>,
}
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn confirm_method(
pub(crate) fn confirm_method(
&self,
span: Span,
self_expr: &'tcx hir::Expr<'tcx>,
@ -66,7 +66,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
confirm_cx.confirm(unadjusted_self_ty, pick, segment)
}
pub fn confirm_method_for_diagnostic(
pub(crate) fn confirm_method_for_diagnostic(
&self,
span: Span,
self_expr: &'tcx hir::Expr<'tcx>,

View File

@ -4,7 +4,7 @@
mod confirm;
mod prelude_edition_lints;
pub mod probe;
pub(crate) mod probe;
mod suggest;
use rustc_errors::{Applicability, Diag, SubdiagMessage};
@ -24,15 +24,15 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use rustc_trait_selection::traits::{self, NormalizeExt};
use self::probe::{IsSuggestion, ProbeScope};
pub use self::MethodError::*;
pub(crate) use self::MethodError::*;
use crate::FnCtxt;
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
probe::provide(providers);
}
#[derive(Clone, Copy, Debug)]
pub struct MethodCallee<'tcx> {
pub(crate) struct MethodCallee<'tcx> {
/// Impl method ID, for inherent methods, or trait method ID, otherwise.
pub def_id: DefId,
pub args: GenericArgsRef<'tcx>,
@ -44,7 +44,7 @@ pub struct MethodCallee<'tcx> {
}
#[derive(Debug)]
pub enum MethodError<'tcx> {
pub(crate) enum MethodError<'tcx> {
// Did not find an applicable method, but we did find various near-misses that may work.
NoMatch(NoMatchData<'tcx>),
@ -70,7 +70,7 @@ pub enum MethodError<'tcx> {
// Contains a list of static methods that may apply, a list of unsatisfied trait predicates which
// could lead to matches if satisfied, and a list of not-in-scope traits which may work.
#[derive(Debug)]
pub struct NoMatchData<'tcx> {
pub(crate) struct NoMatchData<'tcx> {
pub static_candidates: Vec<CandidateSource>,
pub unsatisfied_predicates:
Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>, Option<ObligationCause<'tcx>>)>,
@ -82,7 +82,7 @@ pub struct NoMatchData<'tcx> {
// A pared down enum describing just the places from which a method
// candidate can arise. Used for error reporting only.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum CandidateSource {
pub(crate) enum CandidateSource {
Impl(DefId),
Trait(DefId /* trait id */),
}
@ -254,7 +254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ok(result.callee)
}
pub fn lookup_method_for_diagnostic(
pub(crate) fn lookup_method_for_diagnostic(
&self,
self_ty: Ty<'tcx>,
segment: &hir::PathSegment<'tcx>,
@ -296,7 +296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ok(pick)
}
pub fn lookup_probe_for_diagnostic(
pub(crate) fn lookup_probe_for_diagnostic(
&self,
method_name: Ident,
self_ty: Ty<'tcx>,
@ -569,7 +569,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Finds item with name `item_name` defined in impl/trait `def_id`
/// and return it, or `None`, if no such item was defined there.
pub fn associated_value(&self, def_id: DefId, item_name: Ident) -> Option<ty::AssocItem> {
fn associated_value(&self, def_id: DefId, item_name: Ident) -> Option<ty::AssocItem> {
self.tcx
.associated_items(def_id)
.find_by_name_and_namespace(self.tcx, item_name, Namespace::ValueNS, def_id)

View File

@ -38,14 +38,14 @@ use rustc_trait_selection::traits::{self, ObligationCause, ObligationCtxt};
use smallvec::{smallvec, SmallVec};
use self::CandidateKind::*;
pub use self::PickKind::*;
pub(crate) use self::PickKind::*;
use super::{suggest, CandidateSource, MethodError, NoMatchData};
use crate::FnCtxt;
/// Boolean flag used to indicate if this search is for a suggestion
/// or not. If true, we can allow ambiguity and so forth.
#[derive(Clone, Copy, Debug)]
pub struct IsSuggestion(pub bool);
pub(crate) struct IsSuggestion(pub bool);
pub(crate) struct ProbeContext<'a, 'tcx> {
fcx: &'a FnCtxt<'a, 'tcx>,
@ -134,7 +134,7 @@ enum ProbeResult {
/// (at most) one of these. Either the receiver has type `T` and we convert it to `&T` (or with
/// `mut`), or it has type `*mut T` and we convert it to `*const T`.
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum AutorefOrPtrAdjustment {
pub(crate) enum AutorefOrPtrAdjustment {
/// Receiver has type `T`, add `&` or `&mut` (it `T` is `mut`), and maybe also "unsize" it.
/// Unsizing is used to convert a `[T; N]` to `[T]`, which only makes sense when autorefing.
Autoref {
@ -158,7 +158,7 @@ impl AutorefOrPtrAdjustment {
}
#[derive(Debug, Clone)]
pub struct Pick<'tcx> {
pub(crate) struct Pick<'tcx> {
pub item: ty::AssocItem,
pub kind: PickKind<'tcx>,
pub import_ids: SmallVec<[LocalDefId; 1]>,
@ -179,7 +179,7 @@ pub struct Pick<'tcx> {
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum PickKind<'tcx> {
pub(crate) enum PickKind<'tcx> {
InherentImplPick,
ObjectPick,
TraitPick,
@ -189,10 +189,10 @@ pub enum PickKind<'tcx> {
),
}
pub type PickResult<'tcx> = Result<Pick<'tcx>, MethodError<'tcx>>;
pub(crate) type PickResult<'tcx> = Result<Pick<'tcx>, MethodError<'tcx>>;
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum Mode {
pub(crate) enum Mode {
// An expression of the form `receiver.method_name(...)`.
// Autoderefs are performed on `receiver`, lookup is done based on the
// `self` argument of the method, and static methods aren't considered.
@ -204,7 +204,7 @@ pub enum Mode {
}
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum ProbeScope {
pub(crate) enum ProbeScope {
// Single candidate coming from pre-resolved delegation method.
Single(DefId),
@ -507,7 +507,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.method_autoderef_steps = method_autoderef_steps;
}
@ -1288,7 +1288,7 @@ impl<'tcx> Pick<'tcx> {
/// Checks whether two picks do not refer to the same trait item for the same `Self` type.
/// Only useful for comparisons of picks in order to improve diagnostics.
/// Do not use for type checking.
pub fn differs_from(&self, other: &Self) -> bool {
pub(crate) fn differs_from(&self, other: &Self) -> bool {
let Self {
item:
AssocItem {
@ -1312,7 +1312,7 @@ impl<'tcx> Pick<'tcx> {
}
/// In case there were unstable name collisions, emit them as a lint.
pub fn maybe_emit_unstable_name_collision_hint(
pub(crate) fn maybe_emit_unstable_name_collision_hint(
&self,
tcx: TyCtxt<'tcx>,
span: Span,

View File

@ -415,7 +415,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err
}
pub fn suggest_use_shadowed_binding_with_method(
fn suggest_use_shadowed_binding_with_method(
&self,
self_source: SelfSource<'tcx>,
method_name: Ident,
@ -4223,19 +4223,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
#[derive(Copy, Clone, Debug)]
pub enum SelfSource<'a> {
enum SelfSource<'a> {
QPath(&'a hir::Ty<'a>),
MethodCall(&'a hir::Expr<'a> /* rcvr */),
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct TraitInfo {
pub(crate) struct TraitInfo {
pub def_id: DefId,
}
/// Retrieves all traits in this crate and any dependent crates,
/// and wraps them into `TraitInfo` for custom sorting.
pub fn all_traits(tcx: TyCtxt<'_>) -> Vec<TraitInfo> {
pub(crate) fn all_traits(tcx: TyCtxt<'_>) -> Vec<TraitInfo> {
tcx.all_traits().map(|def_id| TraitInfo { def_id }).collect()
}

View File

@ -25,7 +25,7 @@ use crate::Expectation;
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Checks a `a <op>= b`
pub fn check_binop_assign(
pub(crate) fn check_binop_assign(
&self,
expr: &'tcx hir::Expr<'tcx>,
op: hir::BinOp,
@ -84,7 +84,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/// Checks a potentially overloaded binary operator.
pub fn check_binop(
pub(crate) fn check_binop(
&self,
expr: &'tcx hir::Expr<'tcx>,
op: hir::BinOp,
@ -770,7 +770,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn check_user_unop(
pub(crate) fn check_user_unop(
&self,
ex: &'tcx hir::Expr<'tcx>,
operand_ty: Ty<'tcx>,

View File

@ -944,7 +944,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
pub fn check_dereferenceable(
fn check_dereferenceable(
&self,
span: Span,
expected: Ty<'tcx>,

View File

@ -246,7 +246,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// always know whether a place needs to be mutable or not in the first pass.
/// This happens whether there is an implicit mutable reborrow, e.g. when the type
/// is used as the receiver of a method call.
pub fn convert_place_derefs_to_mutable(&self, expr: &hir::Expr<'_>) {
pub(crate) fn convert_place_derefs_to_mutable(&self, expr: &hir::Expr<'_>) {
// Gather up expressions we want to munge.
let mut exprs = vec![expr];

View File

@ -65,7 +65,7 @@ fn record_rvalue_scope(
}
}
pub fn resolve_rvalue_scopes<'a, 'tcx>(
pub(crate) fn resolve_rvalue_scopes<'a, 'tcx>(
fcx: &'a FnCtxt<'a, 'tcx>,
scope_tree: &'a ScopeTree,
def_id: DefId,

View File

@ -77,7 +77,7 @@ impl<'tcx> Deref for TypeckRootCtxt<'tcx> {
}
impl<'tcx> TypeckRootCtxt<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
pub(crate) fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
let hir_owner = tcx.local_def_id_to_hir_id(def_id).owner;
let infcx = tcx.infer_ctxt().ignoring_regions().with_opaque_type_inference(def_id).build();
@ -124,7 +124,7 @@ impl<'tcx> TypeckRootCtxt<'tcx> {
infer_ok.value
}
pub fn update_infer_var_info(&self, obligation: &PredicateObligation<'tcx>) {
fn update_infer_var_info(&self, obligation: &PredicateObligation<'tcx>) {
let infer_var_info = &mut self.infer_var_info.borrow_mut();
// (*) binder skipped

View File

@ -74,7 +74,7 @@ enum PlaceAncestryRelation {
type InferredCaptureInformation<'tcx> = Vec<(Place<'tcx>, ty::CaptureInfo)>;
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn closure_analyze(&self, body: &'tcx hir::Body<'tcx>) {
pub(crate) fn closure_analyze(&self, body: &'tcx hir::Body<'tcx>) {
InferBorrowKindVisitor { fcx: self }.visit_body(body);
// it's our job to process these.

View File

@ -35,7 +35,7 @@ use crate::FnCtxt;
// resolve_type_vars_in_body, which creates a new TypeTables which
// doesn't contain any inference types.
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn resolve_type_vars_in_body(
pub(crate) fn resolve_type_vars_in_body(
&self,
body: &'tcx hir::Body<'tcx>,
) -> &'tcx ty::TypeckResults<'tcx> {

View File

@ -55,7 +55,7 @@ use {rustc_ast as ast, rustc_graphviz as dot, rustc_hir as hir};
use crate::errors;
#[allow(missing_docs)]
pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
pub(crate) fn assert_dep_graph(tcx: TyCtxt<'_>) {
tcx.dep_graph.with_ignore(|| {
if tcx.sess.opts.unstable_opts.dump_dep_graph {
tcx.dep_graph.with_query(dump_graph);
@ -261,7 +261,7 @@ fn dump_graph(query: &DepGraphQuery) {
}
#[allow(missing_docs)]
pub struct GraphvizDepGraph(FxIndexSet<DepKind>, Vec<(DepKind, DepKind)>);
struct GraphvizDepGraph(FxIndexSet<DepKind>, Vec<(DepKind, DepKind)>);
impl<'a> dot::GraphWalk<'a> for GraphvizDepGraph {
type Node = DepKind;

View File

@ -6,7 +6,7 @@ use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[diag(incremental_unrecognized_depnode)]
pub struct UnrecognizedDepNode {
pub(crate) struct UnrecognizedDepNode {
#[primary_span]
pub span: Span,
pub name: Symbol,
@ -14,28 +14,28 @@ pub struct UnrecognizedDepNode {
#[derive(Diagnostic)]
#[diag(incremental_missing_depnode)]
pub struct MissingDepNode {
pub(crate) struct MissingDepNode {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_missing_if_this_changed)]
pub struct MissingIfThisChanged {
pub(crate) struct MissingIfThisChanged {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_ok)]
pub struct Ok {
pub(crate) struct Ok {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_no_path)]
pub struct NoPath {
pub(crate) struct NoPath {
#[primary_span]
pub span: Span,
pub target: Symbol,
@ -44,7 +44,7 @@ pub struct NoPath {
#[derive(Diagnostic)]
#[diag(incremental_assertion_auto)]
pub struct AssertionAuto<'a> {
pub(crate) struct AssertionAuto<'a> {
#[primary_span]
pub span: Span,
pub name: &'a str,
@ -53,7 +53,7 @@ pub struct AssertionAuto<'a> {
#[derive(Diagnostic)]
#[diag(incremental_undefined_clean_dirty_assertions_item)]
pub struct UndefinedCleanDirtyItem {
pub(crate) struct UndefinedCleanDirtyItem {
#[primary_span]
pub span: Span,
pub kind: String,
@ -61,7 +61,7 @@ pub struct UndefinedCleanDirtyItem {
#[derive(Diagnostic)]
#[diag(incremental_undefined_clean_dirty_assertions)]
pub struct UndefinedCleanDirty {
pub(crate) struct UndefinedCleanDirty {
#[primary_span]
pub span: Span,
pub kind: String,
@ -69,7 +69,7 @@ pub struct UndefinedCleanDirty {
#[derive(Diagnostic)]
#[diag(incremental_repeated_depnode_label)]
pub struct RepeatedDepNodeLabel<'a> {
pub(crate) struct RepeatedDepNodeLabel<'a> {
#[primary_span]
pub span: Span,
pub label: &'a str,
@ -77,7 +77,7 @@ pub struct RepeatedDepNodeLabel<'a> {
#[derive(Diagnostic)]
#[diag(incremental_unrecognized_depnode_label)]
pub struct UnrecognizedDepNodeLabel<'a> {
pub(crate) struct UnrecognizedDepNodeLabel<'a> {
#[primary_span]
pub span: Span,
pub label: &'a str,
@ -85,7 +85,7 @@ pub struct UnrecognizedDepNodeLabel<'a> {
#[derive(Diagnostic)]
#[diag(incremental_not_dirty)]
pub struct NotDirty<'a> {
pub(crate) struct NotDirty<'a> {
#[primary_span]
pub span: Span,
pub dep_node_str: &'a str,
@ -93,7 +93,7 @@ pub struct NotDirty<'a> {
#[derive(Diagnostic)]
#[diag(incremental_not_clean)]
pub struct NotClean<'a> {
pub(crate) struct NotClean<'a> {
#[primary_span]
pub span: Span,
pub dep_node_str: &'a str,
@ -101,7 +101,7 @@ pub struct NotClean<'a> {
#[derive(Diagnostic)]
#[diag(incremental_not_loaded)]
pub struct NotLoaded<'a> {
pub(crate) struct NotLoaded<'a> {
#[primary_span]
pub span: Span,
pub dep_node_str: &'a str,
@ -109,7 +109,7 @@ pub struct NotLoaded<'a> {
#[derive(Diagnostic)]
#[diag(incremental_unknown_item)]
pub struct UnknownItem {
pub(crate) struct UnknownItem {
#[primary_span]
pub span: Span,
pub name: Symbol,
@ -117,14 +117,14 @@ pub struct UnknownItem {
#[derive(Diagnostic)]
#[diag(incremental_no_cfg)]
pub struct NoCfg {
pub(crate) struct NoCfg {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_associated_value_expected_for)]
pub struct AssociatedValueExpectedFor {
pub(crate) struct AssociatedValueExpectedFor {
#[primary_span]
pub span: Span,
pub ident: Ident,
@ -132,21 +132,21 @@ pub struct AssociatedValueExpectedFor {
#[derive(Diagnostic)]
#[diag(incremental_associated_value_expected)]
pub struct AssociatedValueExpected {
pub(crate) struct AssociatedValueExpected {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_unchecked_clean)]
pub struct UncheckedClean {
pub(crate) struct UncheckedClean {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(incremental_delete_old)]
pub struct DeleteOld<'a> {
pub(crate) struct DeleteOld<'a> {
pub name: &'a str,
pub path: PathBuf,
pub err: std::io::Error,
@ -154,7 +154,7 @@ pub struct DeleteOld<'a> {
#[derive(Diagnostic)]
#[diag(incremental_create_new)]
pub struct CreateNew<'a> {
pub(crate) struct CreateNew<'a> {
pub name: &'a str,
pub path: PathBuf,
pub err: std::io::Error,
@ -162,7 +162,7 @@ pub struct CreateNew<'a> {
#[derive(Diagnostic)]
#[diag(incremental_write_new)]
pub struct WriteNew<'a> {
pub(crate) struct WriteNew<'a> {
pub name: &'a str,
pub path: PathBuf,
pub err: std::io::Error,
@ -170,14 +170,14 @@ pub struct WriteNew<'a> {
#[derive(Diagnostic)]
#[diag(incremental_canonicalize_path)]
pub struct CanonicalizePath {
pub(crate) struct CanonicalizePath {
pub path: PathBuf,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_create_incr_comp_dir)]
pub struct CreateIncrCompDir<'a> {
pub(crate) struct CreateIncrCompDir<'a> {
pub tag: &'a str,
pub path: &'a Path,
pub err: std::io::Error,
@ -185,7 +185,7 @@ pub struct CreateIncrCompDir<'a> {
#[derive(Diagnostic)]
#[diag(incremental_create_lock)]
pub struct CreateLock<'a> {
pub(crate) struct CreateLock<'a> {
pub lock_err: std::io::Error,
pub session_dir: &'a Path,
#[note(incremental_lock_unsupported)]
@ -197,84 +197,84 @@ pub struct CreateLock<'a> {
#[derive(Diagnostic)]
#[diag(incremental_delete_lock)]
pub struct DeleteLock<'a> {
pub(crate) struct DeleteLock<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_hard_link_failed)]
pub struct HardLinkFailed<'a> {
pub(crate) struct HardLinkFailed<'a> {
pub path: &'a Path,
}
#[derive(Diagnostic)]
#[diag(incremental_delete_partial)]
pub struct DeletePartial<'a> {
pub(crate) struct DeletePartial<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_delete_full)]
pub struct DeleteFull<'a> {
pub(crate) struct DeleteFull<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_finalize)]
pub struct Finalize<'a> {
pub(crate) struct Finalize<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_invalid_gc_failed)]
pub struct InvalidGcFailed<'a> {
pub(crate) struct InvalidGcFailed<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_finalized_gc_failed)]
pub struct FinalizedGcFailed<'a> {
pub(crate) struct FinalizedGcFailed<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_session_gc_failed)]
pub struct SessionGcFailed<'a> {
pub(crate) struct SessionGcFailed<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_assert_not_loaded)]
pub struct AssertNotLoaded;
pub(crate) struct AssertNotLoaded;
#[derive(Diagnostic)]
#[diag(incremental_assert_loaded)]
pub struct AssertLoaded;
pub(crate) struct AssertLoaded;
#[derive(Diagnostic)]
#[diag(incremental_delete_incompatible)]
pub struct DeleteIncompatible {
pub(crate) struct DeleteIncompatible {
pub path: PathBuf,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_load_dep_graph)]
pub struct LoadDepGraph {
pub(crate) struct LoadDepGraph {
pub path: PathBuf,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_move_dep_graph)]
pub struct MoveDepGraph<'a> {
pub(crate) struct MoveDepGraph<'a> {
pub from: &'a Path,
pub to: &'a Path,
pub err: std::io::Error,
@ -282,14 +282,14 @@ pub struct MoveDepGraph<'a> {
#[derive(Diagnostic)]
#[diag(incremental_create_dep_graph)]
pub struct CreateDepGraph<'a> {
pub(crate) struct CreateDepGraph<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_copy_workproduct_to_cache)]
pub struct CopyWorkProductToCache<'a> {
pub(crate) struct CopyWorkProductToCache<'a> {
pub from: &'a Path,
pub to: &'a Path,
pub err: std::io::Error,
@ -297,13 +297,13 @@ pub struct CopyWorkProductToCache<'a> {
#[derive(Diagnostic)]
#[diag(incremental_delete_workproduct)]
pub struct DeleteWorkProduct<'a> {
pub(crate) struct DeleteWorkProduct<'a> {
pub path: &'a Path,
pub err: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(incremental_corrupt_file)]
pub struct CorruptFile<'a> {
pub(crate) struct CorruptFile<'a> {
pub path: &'a Path,
}

View File

@ -6,6 +6,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod assert_dep_graph;

View File

@ -4,7 +4,7 @@ use rustc_macros::{Decodable, Encodable};
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
#[derive(Debug, Encodable, Decodable)]
pub struct SerializedWorkProduct {
pub(crate) struct SerializedWorkProduct {
/// node that produced the work-product
pub id: WorkProductId,

View File

@ -133,7 +133,7 @@ struct Assertion {
loaded_from_disk: Labels,
}
pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
pub(crate) fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
if !tcx.sess.opts.unstable_opts.query_dep_graph {
return;
}
@ -174,7 +174,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
})
}
pub struct DirtyCleanVisitor<'tcx> {
struct DirtyCleanVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
checked_attrs: FxHashSet<ast::AttrId>,
}
@ -429,7 +429,7 @@ fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
/// A visitor that collects all `#[rustc_clean]` attributes from
/// the HIR. It is used to verify that we really ran checks for all annotated
/// nodes.
pub struct FindAllAttrs<'tcx> {
struct FindAllAttrs<'tcx> {
tcx: TyCtxt<'tcx>,
found_attrs: Vec<&'tcx Attribute>,
}

View File

@ -89,7 +89,7 @@ where
/// incompatible version of the compiler.
/// - Returns `Err(..)` if some kind of IO error occurred while reading the
/// file.
pub fn read_file(
pub(crate) fn read_file(
path: &Path,
report_incremental_info: bool,
is_nightly_build: bool,

View File

@ -157,7 +157,7 @@ pub(crate) fn work_products_path(sess: &Session) -> PathBuf {
}
/// Returns the path to a session's query cache.
pub fn query_cache_path(sess: &Session) -> PathBuf {
pub(crate) fn query_cache_path(sess: &Session) -> PathBuf {
in_incr_comp_dir_sess(sess, QUERY_CACHE_FILENAME)
}

View File

@ -3,6 +3,7 @@
#![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(extend_one, new_uninit, step_trait, test))]
#![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod bit_set;

View File

@ -3,7 +3,7 @@ use rustc_span::Span;
#[derive(Diagnostic)]
#[diag(infer_opaque_hidden_type)]
pub struct OpaqueHiddenTypeDiag {
pub(crate) struct OpaqueHiddenTypeDiag {
#[primary_span]
#[label]
pub span: Span,

View File

@ -18,11 +18,11 @@ pub(crate) struct RegionRelations<'a, 'tcx> {
}
impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
pub(crate) fn new(tcx: TyCtxt<'tcx>, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
Self { tcx, free_regions }
}
pub fn lub_param_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
pub(crate) fn lub_param_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
self.free_regions.lub_param_regions(self.tcx, r_a, r_b)
}
}
@ -80,7 +80,7 @@ impl<'tcx> FreeRegionMap<'tcx> {
/// cases, this is more conservative than necessary, in order to
/// avoid making arbitrary choices. See
/// `TransitiveRelation::postdom_upper_bound` for more details.
pub fn lub_param_regions(
pub(crate) fn lub_param_regions(
&self,
tcx: TyCtxt<'tcx>,
r_a: Region<'tcx>,

View File

@ -43,7 +43,7 @@ pub(crate) fn resolve<'tcx>(
/// Contains the result of lexical region resolution. Offers methods
/// to lookup up the final value of a region variable.
#[derive(Clone)]
pub struct LexicalRegionResolutions<'tcx> {
pub(crate) struct LexicalRegionResolutions<'tcx> {
pub(crate) values: IndexVec<RegionVid, VarValue<'tcx>>,
}

View File

@ -705,7 +705,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
/// not only the generalized type, but also a bool flag
/// indicating whether further WF checks are needed.
#[derive(Debug)]
pub struct Generalization<T> {
struct Generalization<T> {
/// When generalizing `<?0 as Trait>::Assoc` or
/// `<T as Bar<<?0 as Foo>::Assoc>>::Assoc`
/// for `?0` generalization returns an inference

View File

@ -29,7 +29,7 @@ use crate::traits::ObligationCause;
///
/// GLB moves "down" the lattice (to smaller values); LUB moves
/// "up" the lattice (to bigger values).
pub trait LatticeDir<'f, 'tcx>: PredicateEmittingRelation<InferCtxt<'tcx>> {
pub(crate) trait LatticeDir<'f, 'tcx>: PredicateEmittingRelation<InferCtxt<'tcx>> {
fn infcx(&self) -> &'f InferCtxt<'tcx>;
fn cause(&self) -> &ObligationCause<'tcx>;

View File

@ -170,7 +170,7 @@ impl<'tcx> InferCtxt<'tcx> {
}
}
pub struct InferenceFudger<'a, 'tcx> {
struct InferenceFudger<'a, 'tcx> {
infcx: &'a InferCtxt<'tcx>,
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
int_vars: Range<IntVid>,

View File

@ -158,7 +158,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
}
impl<'tcx> InferCtxtUndoLogs<'tcx> {
pub fn start_snapshot(&mut self) -> Snapshot<'tcx> {
pub(crate) fn start_snapshot(&mut self) -> Snapshot<'tcx> {
self.num_open_snapshots += 1;
Snapshot { undo_len: self.logs.len(), _marker: PhantomData }
}

View File

@ -28,6 +28,7 @@
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![recursion_limit = "512"] // For rustdoc
#![warn(unreachable_pub)]
// tidy-alphabetical-end
#[macro_use]

View File

@ -22,7 +22,7 @@ pub use self::engine::{FromSolverError, ScrubbedTraitError, TraitEngine};
pub(crate) use self::project::UndoLog;
pub use self::project::{
MismatchedProjectionTypes, Normalized, NormalizedTerm, ProjectionCache, ProjectionCacheEntry,
ProjectionCacheKey, ProjectionCacheStorage, Reveal,
ProjectionCacheKey, ProjectionCacheStorage,
};
pub use self::ImplSource::*;
pub use self::SelectionError::*;

View File

@ -2,7 +2,7 @@
use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage};
use rustc_data_structures::undo_log::Rollback;
pub use rustc_middle::traits::{EvaluationResult, Reveal};
use rustc_middle::traits::EvaluationResult;
use rustc_middle::ty;
use super::PredicateObligation;

View File

@ -2,6 +2,7 @@
#![feature(decl_macro)]
#![feature(let_chains)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod callbacks;

View File

@ -23,6 +23,7 @@
// We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added.
#![deny(unstable_features)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod cursor;

View File

@ -413,7 +413,7 @@ pub fn check_ast_node<'a>(
}
}
pub fn check_ast_node_inner<'a, T: EarlyLintPass>(
fn check_ast_node_inner<'a, T: EarlyLintPass>(
sess: &Session,
check_node: impl EarlyCheckNode<'a>,
context: EarlyContext<'_>,

Some files were not shown because too many files have changed in this diff Show More