Add warn(unreachable_pub)
to rustc_errors
.
This commit is contained in:
parent
2b5621280c
commit
5fd503ab44
@ -204,7 +204,7 @@ pub trait LintDiagnostic<'a, G: EmissionGuarantee> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Encodable, Decodable)]
|
#[derive(Clone, Debug, Encodable, Decodable)]
|
||||||
pub struct DiagLocation {
|
pub(crate) struct DiagLocation {
|
||||||
file: Cow<'static, str>,
|
file: Cow<'static, str>,
|
||||||
line: u32,
|
line: u32,
|
||||||
col: u32,
|
col: u32,
|
||||||
|
@ -2387,7 +2387,7 @@ enum DisplaySuggestion {
|
|||||||
impl FileWithAnnotatedLines {
|
impl FileWithAnnotatedLines {
|
||||||
/// Preprocess all the annotations so that they are grouped by file and by line number
|
/// 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)
|
/// 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,
|
emitter: &dyn Emitter,
|
||||||
args: &FluentArgs<'_>,
|
args: &FluentArgs<'_>,
|
||||||
msp: &MultiSpan,
|
msp: &MultiSpan,
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
#![feature(yeet_expr)]
|
#![feature(yeet_expr)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
extern crate self as rustc_errors;
|
extern crate self as rustc_errors;
|
||||||
@ -1701,7 +1702,7 @@ fn has_errors_or_delayed_bugs(&self) -> Option<ErrorGuaranteed> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
|
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
|
||||||
pub fn eagerly_translate<'a>(
|
fn eagerly_translate<'a>(
|
||||||
&self,
|
&self,
|
||||||
message: DiagMessage,
|
message: DiagMessage,
|
||||||
args: impl Iterator<Item = DiagArg<'a>>,
|
args: impl Iterator<Item = DiagArg<'a>>,
|
||||||
@ -1710,7 +1711,7 @@ pub fn eagerly_translate<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Translate `message` eagerly with `args` to `String`.
|
/// Translate `message` eagerly with `args` to `String`.
|
||||||
pub fn eagerly_translate_to_string<'a>(
|
fn eagerly_translate_to_string<'a>(
|
||||||
&self,
|
&self,
|
||||||
message: DiagMessage,
|
message: DiagMessage,
|
||||||
args: impl Iterator<Item = DiagArg<'a>>,
|
args: impl Iterator<Item = DiagArg<'a>>,
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[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::ffi::CString;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
@ -80,6 +80,6 @@ fn drop(&mut self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[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(())
|
Box::new(())
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ enum ParseOpt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a buffer
|
/// 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 };
|
let ctx = Context { top_block: true, prev: Prev::Newline };
|
||||||
normalize(parse_recursive(txt.trim().as_bytes(), ctx), &mut Vec::new())
|
normalize(parse_recursive(txt.trim().as_bytes(), ctx), &mut Vec::new())
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Print to terminal output to a buffer
|
/// 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))]
|
#[cfg(not(test))]
|
||||||
if let Some((w, _)) = termize::dimensions() {
|
if let Some((w, _)) = termize::dimensions() {
|
||||||
WIDTH.with(|c| c.set(std::cmp::min(w, DEFAULT_COLUMN_WIDTH)));
|
WIDTH.with(|c| c.set(std::cmp::min(w, DEFAULT_COLUMN_WIDTH)));
|
||||||
@ -47,7 +47,7 @@ fn write_stream(
|
|||||||
Ok(())
|
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 {
|
match tt {
|
||||||
MdTree::CodeBlock { txt, lang: _ } => {
|
MdTree::CodeBlock { txt, lang: _ } => {
|
||||||
buf.set_color(ColorSpec::new().set_dimmed(true))?;
|
buf.set_color(ColorSpec::new().set_dimmed(true))?;
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
use crate::{Level, Loc};
|
use crate::{Level, Loc};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
||||||
pub struct Line {
|
pub(crate) struct Line {
|
||||||
pub line_index: usize,
|
pub line_index: usize,
|
||||||
pub annotations: Vec<Annotation>,
|
pub annotations: Vec<Annotation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Default)]
|
#[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
|
/// the (0-indexed) column for *display* purposes, counted in characters, not utf-8 bytes
|
||||||
pub display: usize,
|
pub display: usize,
|
||||||
/// the (0-indexed) column in the file, counted in characters, not utf-8 bytes.
|
/// the (0-indexed) column in the file, counted in characters, not utf-8 bytes.
|
||||||
@ -31,13 +31,13 @@ pub struct AnnotationColumn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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 }
|
AnnotationColumn { display: loc.col_display, file: loc.col.0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
||||||
pub struct MultilineAnnotation {
|
pub(crate) struct MultilineAnnotation {
|
||||||
pub depth: usize,
|
pub depth: usize,
|
||||||
pub line_start: usize,
|
pub line_start: usize,
|
||||||
pub line_end: usize,
|
pub line_end: usize,
|
||||||
@ -49,19 +49,19 @@ pub struct MultilineAnnotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MultilineAnnotation {
|
impl MultilineAnnotation {
|
||||||
pub fn increase_depth(&mut self) {
|
pub(crate) fn increase_depth(&mut self) {
|
||||||
self.depth += 1;
|
self.depth += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compare two `MultilineAnnotation`s considering only the `Span` they cover.
|
/// 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_start == other.line_start
|
||||||
&& self.line_end == other.line_end
|
&& self.line_end == other.line_end
|
||||||
&& self.start_col == other.start_col
|
&& self.start_col == other.start_col
|
||||||
&& self.end_col == other.end_col
|
&& self.end_col == other.end_col
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_start(&self) -> Annotation {
|
pub(crate) fn as_start(&self) -> Annotation {
|
||||||
Annotation {
|
Annotation {
|
||||||
start_col: self.start_col,
|
start_col: self.start_col,
|
||||||
end_col: AnnotationColumn {
|
end_col: AnnotationColumn {
|
||||||
@ -76,7 +76,7 @@ pub fn as_start(&self) -> Annotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_end(&self) -> Annotation {
|
pub(crate) fn as_end(&self) -> Annotation {
|
||||||
Annotation {
|
Annotation {
|
||||||
start_col: AnnotationColumn {
|
start_col: AnnotationColumn {
|
||||||
// these might not correspond to the same place anymore,
|
// these might not correspond to the same place anymore,
|
||||||
@ -91,7 +91,7 @@ pub fn as_end(&self) -> Annotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_line(&self) -> Annotation {
|
pub(crate) fn as_line(&self) -> Annotation {
|
||||||
Annotation {
|
Annotation {
|
||||||
start_col: Default::default(),
|
start_col: Default::default(),
|
||||||
end_col: Default::default(),
|
end_col: Default::default(),
|
||||||
@ -103,7 +103,7 @@ pub fn as_line(&self) -> Annotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
||||||
pub enum AnnotationType {
|
pub(crate) enum AnnotationType {
|
||||||
/// Annotation under a single line of code
|
/// Annotation under a single line of code
|
||||||
Singleline,
|
Singleline,
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ pub enum AnnotationType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
|
||||||
pub struct Annotation {
|
pub(crate) struct Annotation {
|
||||||
/// Start column.
|
/// Start column.
|
||||||
/// Note that it is important that this field goes
|
/// Note that it is important that this field goes
|
||||||
/// first, so that when we sort, we sort orderings by start
|
/// first, so that when we sort, we sort orderings by start
|
||||||
@ -152,12 +152,12 @@ pub struct Annotation {
|
|||||||
|
|
||||||
impl Annotation {
|
impl Annotation {
|
||||||
/// Whether this annotation is a vertical line placeholder.
|
/// 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(_))
|
matches!(self.annotation_type, AnnotationType::MultilineLine(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Length of this annotation as displayed in the stderr output
|
/// 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
|
// Account for usize underflows
|
||||||
if self.end_col.display > self.start_col.display {
|
if self.end_col.display > self.start_col.display {
|
||||||
self.end_col.display - self.start_col.display
|
self.end_col.display - self.start_col.display
|
||||||
@ -166,7 +166,7 @@ pub fn len(&self) -> usize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_label(&self) -> bool {
|
pub(crate) fn has_label(&self) -> bool {
|
||||||
if let Some(ref label) = self.label {
|
if let Some(ref label) = self.label {
|
||||||
// Consider labels with no text as effectively not being there
|
// Consider labels with no text as effectively not being there
|
||||||
// to avoid weird output with unnecessary vertical lines, like:
|
// to avoid weird output with unnecessary vertical lines, like:
|
||||||
@ -184,7 +184,7 @@ pub fn has_label(&self) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn takes_space(&self) -> bool {
|
pub(crate) fn takes_space(&self) -> bool {
|
||||||
// Multiline annotations always have to keep vertical space.
|
// Multiline annotations always have to keep vertical space.
|
||||||
matches!(
|
matches!(
|
||||||
self.annotation_type,
|
self.annotation_type,
|
||||||
@ -194,7 +194,7 @@ pub fn takes_space(&self) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StyledString {
|
pub(crate) struct StyledString {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub style: Style,
|
pub style: Style,
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use crate::snippet::{Style, StyledString};
|
use crate::snippet::{Style, StyledString};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StyledBuffer {
|
pub(crate) struct StyledBuffer {
|
||||||
lines: Vec<Vec<StyledChar>>,
|
lines: Vec<Vec<StyledChar>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,12 +22,12 @@ const fn new(chr: char, style: Style) -> Self {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl StyledBuffer {
|
impl StyledBuffer {
|
||||||
pub fn new() -> StyledBuffer {
|
pub(crate) fn new() -> StyledBuffer {
|
||||||
StyledBuffer { lines: vec![] }
|
StyledBuffer { lines: vec![] }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns content of `StyledBuffer` split by lines and line styles
|
/// 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.
|
// 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')));
|
debug_assert!(self.lines.iter().all(|r| !r.iter().any(|sc| sc.chr == '\t')));
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ fn ensure_lines(&mut self, line: usize) {
|
|||||||
/// Sets `chr` with `style` for given `line`, `col`.
|
/// Sets `chr` with `style` for given `line`, `col`.
|
||||||
/// If `line` does not exist in our buffer, adds empty lines up to the given
|
/// If `line` does not exist in our buffer, adds empty lines up to the given
|
||||||
/// and fills the last line with unstyled whitespace.
|
/// 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);
|
self.ensure_lines(line);
|
||||||
if col >= self.lines[line].len() {
|
if col >= self.lines[line].len() {
|
||||||
self.lines[line].resize(col + 1, StyledChar::SPACE);
|
self.lines[line].resize(col + 1, StyledChar::SPACE);
|
||||||
@ -81,7 +81,7 @@ pub fn putc(&mut self, line: usize, col: usize, chr: char, style: Style) {
|
|||||||
/// Sets `string` with `style` for given `line`, starting from `col`.
|
/// 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
|
/// If `line` does not exist in our buffer, adds empty lines up to the given
|
||||||
/// and fills the last line with unstyled whitespace.
|
/// 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;
|
let mut n = col;
|
||||||
for c in string.chars() {
|
for c in string.chars() {
|
||||||
self.putc(line, n, c, style);
|
self.putc(line, n, c, style);
|
||||||
@ -91,7 +91,7 @@ pub fn puts(&mut self, line: usize, col: usize, string: &str, style: Style) {
|
|||||||
|
|
||||||
/// For given `line` inserts `string` with `style` before old content of that line,
|
/// For given `line` inserts `string` with `style` before old content of that line,
|
||||||
/// adding lines if needed
|
/// 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);
|
self.ensure_lines(line);
|
||||||
let string_len = string.chars().count();
|
let string_len = string.chars().count();
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ pub fn prepend(&mut self, line: usize, string: &str, style: Style) {
|
|||||||
|
|
||||||
/// For given `line` inserts `string` with `style` after old content of that line,
|
/// For given `line` inserts `string` with `style` after old content of that line,
|
||||||
/// adding lines if needed
|
/// 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() {
|
if line >= self.lines.len() {
|
||||||
self.puts(line, 0, string, style);
|
self.puts(line, 0, string, style);
|
||||||
} else {
|
} else {
|
||||||
@ -116,14 +116,14 @@ pub fn append(&mut self, line: usize, string: &str, style: Style) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn num_lines(&self) -> usize {
|
pub(crate) fn num_lines(&self) -> usize {
|
||||||
self.lines.len()
|
self.lines.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set `style` for `line`, `col_start..col_end` range if:
|
/// Set `style` for `line`, `col_start..col_end` range if:
|
||||||
/// 1. That line and column range exist in `StyledBuffer`
|
/// 1. That line and column range exist in `StyledBuffer`
|
||||||
/// 2. `overwrite` is `true` or existing style is `Style::NoStyle` or `Style::Quotation`
|
/// 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,
|
&mut self,
|
||||||
line: usize,
|
line: usize,
|
||||||
col_start: usize,
|
col_start: usize,
|
||||||
@ -139,7 +139,7 @@ pub fn set_style_range(
|
|||||||
/// Set `style` for `line`, `col` if:
|
/// Set `style` for `line`, `col` if:
|
||||||
/// 1. That line and column exist in `StyledBuffer`
|
/// 1. That line and column exist in `StyledBuffer`
|
||||||
/// 2. `overwrite` is `true` or existing style is `Style::NoStyle` or `Style::Quotation`
|
/// 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(ref mut line) = self.lines.get_mut(line) {
|
||||||
if let Some(StyledChar { style: s, .. }) = line.get_mut(col) {
|
if let Some(StyledChar { style: s, .. }) = line.get_mut(col) {
|
||||||
if overwrite || matches!(s, Style::NoStyle | Style::Quotation) {
|
if overwrite || matches!(s, Style::NoStyle | Style::Quotation) {
|
||||||
|
Loading…
Reference in New Issue
Block a user