Skip to content

Rollup of 9 pull requests #100920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Aug 23, 2022
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f4bf8cd
Extend comma suggestion to cases where fields arent missing
compiler-errors Aug 9, 2022
586c84a
Fix rustc_parse_format precision & width spans
Alexendoo Aug 21, 2022
c31f296
Refactor query modifier parsing
camsteffen Aug 21, 2022
8be3764
InferCtxt emit error when incorrectly tainted by errors
chenyukang Aug 10, 2022
f466a75
remove hack fix since we don't have no overflow diagnostic
chenyukang Aug 22, 2022
15c8e55
net listen backlog update, follow-up from #97963.
devnexen Aug 21, 2022
8c2413c
Migrate rustc_plugin_impl to SessionDiagnostic
Facel3ss1 Aug 19, 2022
d7d701a
Create specific ConstantHasGenerics for ConstantItemRibKind.
cjgillot Jul 14, 2022
613dc22
Improve local generic parameter suggestions.
cjgillot Jul 14, 2022
362e636
Do not call generate_fn_name_span in typeck.
cjgillot Jul 14, 2022
6e88d73
Remove generate_fn_name_span and generate_local_type_param_snippet.
cjgillot Jul 14, 2022
da9ccc2
Remove FnItemRibKind.
cjgillot Jul 14, 2022
dff4280
Mark suggestion as MaybeIncorrect.
cjgillot Aug 22, 2022
8e6c5ad
Fix typo in UnreachableProp
Noratrieb Aug 23, 2022
fb5dc6b
Add some useful comments to `LitKind`.
nnethercote Aug 22, 2022
6087dc2
Remove the symbol from `ast::LitKind::Err`.
nnethercote Aug 22, 2022
4d1c273
Rollup merge of #99249 - cjgillot:no-reparse-fn, r=fee1-dead
Dylan-DPC Aug 23, 2022
8733550
Rollup merge of #100309 - compiler-errors:issue-100300, r=sanxiyn
Dylan-DPC Aug 23, 2022
f42cdf7
Rollup merge of #100368 - chenyukang:fix-100321, r=lcnr
Dylan-DPC Aug 23, 2022
35f2d12
Rollup merge of #100768 - Facel3ss1:plugin-impl-translation, r=davidtwco
Dylan-DPC Aug 23, 2022
a163659
Rollup merge of #100835 - devnexen:listener_followups, r=devnexen
Dylan-DPC Aug 23, 2022
110d8d9
Rollup merge of #100851 - Alexendoo:rpf-width-prec-spans, r=fee1-dead
Dylan-DPC Aug 23, 2022
fd93ab4
Rollup merge of #100857 - camsteffen:query-parse-refactor, r=davidtwco
Dylan-DPC Aug 23, 2022
12c1ac0
Rollup merge of #100907 - Nilstrieb:unrachable-typo-lol, r=Dylan-DPC
Dylan-DPC Aug 23, 2022
28ead17
Rollup merge of #100909 - nnethercote:minor-ast-LitKind-improvement, …
Dylan-DPC Aug 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -4321,6 +4321,7 @@ dependencies = [
"rustc_ast",
"rustc_errors",
"rustc_lint",
"rustc_macros",
"rustc_metadata",
"rustc_session",
"rustc_span",
10 changes: 6 additions & 4 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1751,7 +1751,8 @@ pub enum LitFloatType {
/// E.g., `"foo"`, `42`, `12.34`, or `bool`.
#[derive(Clone, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)]
pub enum LitKind {
/// A string literal (`"foo"`).
/// A string literal (`"foo"`). The symbol is unescaped, and so may differ
/// from the original token's symbol.
Str(Symbol, StrStyle),
/// A byte string (`b"foo"`).
ByteStr(Lrc<[u8]>),
@@ -1761,12 +1762,13 @@ pub enum LitKind {
Char(char),
/// An integer literal (`1`).
Int(u128, LitIntType),
/// A float literal (`1f64` or `1E10f64`).
/// A float literal (`1f64` or `1E10f64`). Stored as a symbol rather than
/// `f64` so that `LitKind` can impl `Eq` and `Hash`.
Float(Symbol, LitFloatType),
/// A boolean literal.
Bool(bool),
/// Placeholder for a literal that wasn't well-formed in some way.
Err(Symbol),
Err,
}

impl LitKind {
@@ -1805,7 +1807,7 @@ impl LitKind {
| LitKind::Int(_, LitIntType::Unsuffixed)
| LitKind::Float(_, LitFloatType::Unsuffixed)
| LitKind::Bool(..)
| LitKind::Err(..) => false,
| LitKind::Err => false,
}
}
}
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ impl LitKind {

LitKind::ByteStr(bytes.into())
}
token::Err => LitKind::Err(symbol),
token::Err => LitKind::Err,
})
}

@@ -199,7 +199,7 @@ impl LitKind {
let symbol = if value { kw::True } else { kw::False };
(token::Bool, symbol, None)
}
LitKind::Err(symbol) => (token::Err, symbol, None),
LitKind::Err => unreachable!(),
};

token::Lit::new(kind, symbol, suffix)
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
@@ -928,7 +928,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} else {
Lit {
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
kind: LitKind::Err(kw::Empty),
kind: LitKind::Err,
span: DUMMY_SP,
}
};
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/concat.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ pub fn expand_concat(
ast::LitKind::Byte(..) | ast::LitKind::ByteStr(..) => {
cx.span_err(e.span, "cannot concatenate a byte string literal");
}
ast::LitKind::Err(_) => {
ast::LitKind::Err => {
has_errors = true;
}
},
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/concat_bytes.rs
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ fn invalid_type_err(cx: &mut base::ExtCtxt<'_>, expr: &P<rustc_ast::Expr>, is_ne
ast::LitKind::Bool(_) => {
cx.span_err(expr.span, "cannot concatenate boolean literals");
}
ast::LitKind::Err(_) => {}
ast::LitKind::Err => {}
ast::LitKind::Int(_, _) if !is_nested => {
let mut err = cx.struct_span_err(expr.span, "cannot concatenate numeric literals");
if let Ok(snippet) = cx.sess.source_map().span_to_snippet(expr.span) {
27 changes: 16 additions & 11 deletions compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
@@ -413,7 +413,7 @@ impl<'a, 'b> Context<'a, 'b> {
/// Verifies one piece of a parse string, and remembers it if valid.
/// All errors are not emitted as fatal so we can continue giving errors
/// about this and possibly other format strings.
fn verify_piece(&mut self, p: &parse::Piece<'_>) {
fn verify_piece(&mut self, p: &parse::Piece<'a>) {
match *p {
parse::String(..) => {}
parse::NextArgument(ref arg) => {
@@ -433,6 +433,11 @@ impl<'a, 'b> Context<'a, 'b> {
let has_precision = arg.format.precision != Count::CountImplied;
let has_width = arg.format.width != Count::CountImplied;

if has_precision || has_width {
// push before named params are resolved to aid diagnostics
self.arg_with_formatting.push(arg.format);
}

// argument second, if it's an implicit positional parameter
// it's written second, so it should come after width/precision.
let pos = match arg.position {
@@ -581,7 +586,11 @@ impl<'a, 'b> Context<'a, 'b> {
let mut zero_based_note = false;

let count = self.pieces.len()
+ self.arg_with_formatting.iter().filter(|fmt| fmt.precision_span.is_some()).count();
+ self
.arg_with_formatting
.iter()
.filter(|fmt| matches!(fmt.precision, parse::CountIsParam(_)))
.count();
if self.names.is_empty() && !numbered_position_args && count != self.num_args() {
e = self.ecx.struct_span_err(
sp,
@@ -647,7 +656,7 @@ impl<'a, 'b> Context<'a, 'b> {
+ self
.arg_with_formatting
.iter()
.filter(|fmt| fmt.precision_span.is_some())
.filter(|fmt| matches!(fmt.precision, parse::CountIsParam(_)))
.count();
e.span_label(
span,
@@ -899,26 +908,22 @@ impl<'a, 'b> Context<'a, 'b> {
},
position_span: arg.position_span,
format: parse::FormatSpec {
fill: arg.format.fill,
fill: None,
align: parse::AlignUnknown,
flags: 0,
precision: parse::CountImplied,
precision_span: None,
precision_span: arg.format.precision_span,
width: parse::CountImplied,
width_span: None,
width_span: arg.format.width_span,
ty: arg.format.ty,
ty_span: arg.format.ty_span,
},
};

let fill = arg.format.fill.unwrap_or(' ');

let pos_simple = arg.position.index() == simple_arg.position.index();

if arg.format.precision_span.is_some() || arg.format.width_span.is_some() {
self.arg_with_formatting.push(arg.format);
}
if !pos_simple || arg.format != simple_arg.format || fill != ' ' {
if !pos_simple || arg.format != simple_arg.format {
self.all_pieces_simple = false;
}

4 changes: 4 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/plugin_impl.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugin_impl_load_plugin_error = {$msg}

plugin_impl_malformed_plugin_attribute = malformed `plugin` attribute
.label = malformed attribute
1 change: 1 addition & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ fluent_messages! {
lint => "../locales/en-US/lint.ftl",
parser => "../locales/en-US/parser.ftl",
passes => "../locales/en-US/passes.ftl",
plugin_impl => "../locales/en-US/plugin_impl.ftl",
privacy => "../locales/en-US/privacy.ftl",
typeck => "../locales/en-US/typeck.ftl",
}
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
@@ -1227,7 +1227,7 @@ pub fn expr_to_spanned_string<'a>(
);
Some((err, true))
}
ast::LitKind::Err(_) => None,
ast::LitKind::Err => None,
_ => Some((cx.struct_span_err(l.span, err_msg), false)),
},
ast::ExprKind::Err => None,
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
evaluation_cache: self.evaluation_cache.clone(),
reported_trait_errors: self.reported_trait_errors.clone(),
reported_closure_mismatch: self.reported_closure_mismatch.clone(),
tainted_by_errors_flag: self.tainted_by_errors_flag.clone(),
tainted_by_errors: self.tainted_by_errors.clone(),
err_count_on_creation: self.err_count_on_creation,
in_snapshot: self.in_snapshot.clone(),
universe: self.universe.clone(),
18 changes: 10 additions & 8 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ pub use rustc_middle::ty::IntVarValue;
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt};
use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use rustc_span::{Span, DUMMY_SP};

use std::cell::{Cell, Ref, RefCell};
use std::fmt;
@@ -316,12 +316,12 @@ pub struct InferCtxt<'a, 'tcx> {
///
/// Don't read this flag directly, call `is_tainted_by_errors()`
/// and `set_tainted_by_errors()`.
tainted_by_errors_flag: Cell<bool>,
tainted_by_errors: Cell<Option<ErrorGuaranteed>>,

/// Track how many errors were reported when this infcx is created.
/// If the number of errors increases, that's also a sign (line
/// `tainted_by_errors`) to avoid reporting certain kinds of errors.
// FIXME(matthewjasper) Merge into `tainted_by_errors_flag`
// FIXME(matthewjasper) Merge into `tainted_by_errors`
err_count_on_creation: usize,

/// This flag is true while there is an active snapshot.
@@ -624,7 +624,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
evaluation_cache: Default::default(),
reported_trait_errors: Default::default(),
reported_closure_mismatch: Default::default(),
tainted_by_errors_flag: Cell::new(false),
tainted_by_errors: Cell::new(None),
err_count_on_creation: tcx.sess.err_count(),
in_snapshot: Cell::new(false),
skip_leak_check: Cell::new(false),
@@ -1227,23 +1227,25 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn is_tainted_by_errors(&self) -> bool {
debug!(
"is_tainted_by_errors(err_count={}, err_count_on_creation={}, \
tainted_by_errors_flag={})",
tainted_by_errors={})",
self.tcx.sess.err_count(),
self.err_count_on_creation,
self.tainted_by_errors_flag.get()
self.tainted_by_errors.get().is_some()
);

if self.tcx.sess.err_count() > self.err_count_on_creation {
return true; // errors reported since this infcx was made
}
self.tainted_by_errors_flag.get()
self.tainted_by_errors.get().is_some()
}

/// Set the "tainted by errors" flag to true. We call this when we
/// observe an error from a prior pass.
pub fn set_tainted_by_errors(&self) {
debug!("set_tainted_by_errors()");
self.tainted_by_errors_flag.set(true)
self.tainted_by_errors.set(Some(
self.tcx.sess.delay_span_bug(DUMMY_SP, "`InferCtxt` incorrectly tainted by errors"),
));
}

pub fn skip_region_resolution(&self) {
Loading