Skip to content

Commit a1bea15

Browse files
committed
Auto merge of rust-lang#100920 - Dylan-DPC:rollup-vlcw3sr, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - rust-lang#99249 (Do not re-parse function signatures to suggest generics) - rust-lang#100309 (Extend comma suggestion to cases where fields arent missing) - rust-lang#100368 (InferCtxt tainted_by_errors_flag should be Option<ErrorGuaranteed>) - rust-lang#100768 (Migrate `rustc_plugin_impl` to `SessionDiagnostic`) - rust-lang#100835 (net listen backlog update, follow-up from rust-lang#97963.) - rust-lang#100851 (Fix rustc_parse_format precision & width spans) - rust-lang#100857 (Refactor query modifier parsing) - rust-lang#100907 (Fix typo in UnreachableProp) - rust-lang#100909 (Minor `ast::LitKind` improvements) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1cff564 + 28ead17 commit a1bea15

File tree

51 files changed

+509
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+509
-622
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4321,6 +4321,7 @@ dependencies = [
43214321
"rustc_ast",
43224322
"rustc_errors",
43234323
"rustc_lint",
4324+
"rustc_macros",
43244325
"rustc_metadata",
43254326
"rustc_session",
43264327
"rustc_span",

compiler/rustc_ast/src/ast.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,8 @@ pub enum LitFloatType {
17511751
/// E.g., `"foo"`, `42`, `12.34`, or `bool`.
17521752
#[derive(Clone, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)]
17531753
pub enum LitKind {
1754-
/// A string literal (`"foo"`).
1754+
/// A string literal (`"foo"`). The symbol is unescaped, and so may differ
1755+
/// from the original token's symbol.
17551756
Str(Symbol, StrStyle),
17561757
/// A byte string (`b"foo"`).
17571758
ByteStr(Lrc<[u8]>),
@@ -1761,12 +1762,13 @@ pub enum LitKind {
17611762
Char(char),
17621763
/// An integer literal (`1`).
17631764
Int(u128, LitIntType),
1764-
/// A float literal (`1f64` or `1E10f64`).
1765+
/// A float literal (`1f64` or `1E10f64`). Stored as a symbol rather than
1766+
/// `f64` so that `LitKind` can impl `Eq` and `Hash`.
17651767
Float(Symbol, LitFloatType),
17661768
/// A boolean literal.
17671769
Bool(bool),
17681770
/// Placeholder for a literal that wasn't well-formed in some way.
1769-
Err(Symbol),
1771+
Err,
17701772
}
17711773

17721774
impl LitKind {
@@ -1805,7 +1807,7 @@ impl LitKind {
18051807
| LitKind::Int(_, LitIntType::Unsuffixed)
18061808
| LitKind::Float(_, LitFloatType::Unsuffixed)
18071809
| LitKind::Bool(..)
1808-
| LitKind::Err(..) => false,
1810+
| LitKind::Err => false,
18091811
}
18101812
}
18111813
}

compiler/rustc_ast/src/util/literal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl LitKind {
146146

147147
LitKind::ByteStr(bytes.into())
148148
}
149-
token::Err => LitKind::Err(symbol),
149+
token::Err => LitKind::Err,
150150
})
151151
}
152152

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

205205
token::Lit::new(kind, symbol, suffix)

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
928928
} else {
929929
Lit {
930930
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
931-
kind: LitKind::Err(kw::Empty),
931+
kind: LitKind::Err,
932932
span: DUMMY_SP,
933933
}
934934
};

compiler/rustc_builtin_macros/src/concat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn expand_concat(
3939
ast::LitKind::Byte(..) | ast::LitKind::ByteStr(..) => {
4040
cx.span_err(e.span, "cannot concatenate a byte string literal");
4141
}
42-
ast::LitKind::Err(_) => {
42+
ast::LitKind::Err => {
4343
has_errors = true;
4444
}
4545
},

compiler/rustc_builtin_macros/src/concat_bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn invalid_type_err(cx: &mut base::ExtCtxt<'_>, expr: &P<rustc_ast::Expr>, is_ne
4242
ast::LitKind::Bool(_) => {
4343
cx.span_err(expr.span, "cannot concatenate boolean literals");
4444
}
45-
ast::LitKind::Err(_) => {}
45+
ast::LitKind::Err => {}
4646
ast::LitKind::Int(_, _) if !is_nested => {
4747
let mut err = cx.struct_span_err(expr.span, "cannot concatenate numeric literals");
4848
if let Ok(snippet) = cx.sess.source_map().span_to_snippet(expr.span) {

compiler/rustc_builtin_macros/src/format.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl<'a, 'b> Context<'a, 'b> {
413413
/// Verifies one piece of a parse string, and remembers it if valid.
414414
/// All errors are not emitted as fatal so we can continue giving errors
415415
/// about this and possibly other format strings.
416-
fn verify_piece(&mut self, p: &parse::Piece<'_>) {
416+
fn verify_piece(&mut self, p: &parse::Piece<'a>) {
417417
match *p {
418418
parse::String(..) => {}
419419
parse::NextArgument(ref arg) => {
@@ -433,6 +433,11 @@ impl<'a, 'b> Context<'a, 'b> {
433433
let has_precision = arg.format.precision != Count::CountImplied;
434434
let has_width = arg.format.width != Count::CountImplied;
435435

436+
if has_precision || has_width {
437+
// push before named params are resolved to aid diagnostics
438+
self.arg_with_formatting.push(arg.format);
439+
}
440+
436441
// argument second, if it's an implicit positional parameter
437442
// it's written second, so it should come after width/precision.
438443
let pos = match arg.position {
@@ -581,7 +586,11 @@ impl<'a, 'b> Context<'a, 'b> {
581586
let mut zero_based_note = false;
582587

583588
let count = self.pieces.len()
584-
+ self.arg_with_formatting.iter().filter(|fmt| fmt.precision_span.is_some()).count();
589+
+ self
590+
.arg_with_formatting
591+
.iter()
592+
.filter(|fmt| matches!(fmt.precision, parse::CountIsParam(_)))
593+
.count();
585594
if self.names.is_empty() && !numbered_position_args && count != self.num_args() {
586595
e = self.ecx.struct_span_err(
587596
sp,
@@ -647,7 +656,7 @@ impl<'a, 'b> Context<'a, 'b> {
647656
+ self
648657
.arg_with_formatting
649658
.iter()
650-
.filter(|fmt| fmt.precision_span.is_some())
659+
.filter(|fmt| matches!(fmt.precision, parse::CountIsParam(_)))
651660
.count();
652661
e.span_label(
653662
span,
@@ -899,26 +908,22 @@ impl<'a, 'b> Context<'a, 'b> {
899908
},
900909
position_span: arg.position_span,
901910
format: parse::FormatSpec {
902-
fill: arg.format.fill,
911+
fill: None,
903912
align: parse::AlignUnknown,
904913
flags: 0,
905914
precision: parse::CountImplied,
906-
precision_span: None,
915+
precision_span: arg.format.precision_span,
907916
width: parse::CountImplied,
908-
width_span: None,
917+
width_span: arg.format.width_span,
909918
ty: arg.format.ty,
910919
ty_span: arg.format.ty_span,
911920
},
912921
};
913922

914923
let fill = arg.format.fill.unwrap_or(' ');
915-
916924
let pos_simple = arg.position.index() == simple_arg.position.index();
917925

918-
if arg.format.precision_span.is_some() || arg.format.width_span.is_some() {
919-
self.arg_with_formatting.push(arg.format);
920-
}
921-
if !pos_simple || arg.format != simple_arg.format || fill != ' ' {
926+
if !pos_simple || arg.format != simple_arg.format {
922927
self.all_pieces_simple = false;
923928
}
924929

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
plugin_impl_load_plugin_error = {$msg}
2+
3+
plugin_impl_malformed_plugin_attribute = malformed `plugin` attribute
4+
.label = malformed attribute

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fluent_messages! {
4141
lint => "../locales/en-US/lint.ftl",
4242
parser => "../locales/en-US/parser.ftl",
4343
passes => "../locales/en-US/passes.ftl",
44+
plugin_impl => "../locales/en-US/plugin_impl.ftl",
4445
privacy => "../locales/en-US/privacy.ftl",
4546
typeck => "../locales/en-US/typeck.ftl",
4647
}

compiler/rustc_expand/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ pub fn expr_to_spanned_string<'a>(
12271227
);
12281228
Some((err, true))
12291229
}
1230-
ast::LitKind::Err(_) => None,
1230+
ast::LitKind::Err => None,
12311231
_ => Some((cx.struct_span_err(l.span, err_msg), false)),
12321232
},
12331233
ast::ExprKind::Err => None,

compiler/rustc_infer/src/infer/at.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
7474
evaluation_cache: self.evaluation_cache.clone(),
7575
reported_trait_errors: self.reported_trait_errors.clone(),
7676
reported_closure_mismatch: self.reported_closure_mismatch.clone(),
77-
tainted_by_errors_flag: self.tainted_by_errors_flag.clone(),
77+
tainted_by_errors: self.tainted_by_errors.clone(),
7878
err_count_on_creation: self.err_count_on_creation,
7979
in_snapshot: self.in_snapshot.clone(),
8080
universe: self.universe.clone(),

compiler/rustc_infer/src/infer/mod.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub use rustc_middle::ty::IntVarValue;
3232
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt};
3333
use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid};
3434
use rustc_span::symbol::Symbol;
35-
use rustc_span::Span;
35+
use rustc_span::{Span, DUMMY_SP};
3636

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

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

327327
/// This flag is true while there is an active snapshot.
@@ -624,7 +624,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
624624
evaluation_cache: Default::default(),
625625
reported_trait_errors: Default::default(),
626626
reported_closure_mismatch: Default::default(),
627-
tainted_by_errors_flag: Cell::new(false),
627+
tainted_by_errors: Cell::new(None),
628628
err_count_on_creation: tcx.sess.err_count(),
629629
in_snapshot: Cell::new(false),
630630
skip_leak_check: Cell::new(false),
@@ -1227,23 +1227,25 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12271227
pub fn is_tainted_by_errors(&self) -> bool {
12281228
debug!(
12291229
"is_tainted_by_errors(err_count={}, err_count_on_creation={}, \
1230-
tainted_by_errors_flag={})",
1230+
tainted_by_errors={})",
12311231
self.tcx.sess.err_count(),
12321232
self.err_count_on_creation,
1233-
self.tainted_by_errors_flag.get()
1233+
self.tainted_by_errors.get().is_some()
12341234
);
12351235

12361236
if self.tcx.sess.err_count() > self.err_count_on_creation {
12371237
return true; // errors reported since this infcx was made
12381238
}
1239-
self.tainted_by_errors_flag.get()
1239+
self.tainted_by_errors.get().is_some()
12401240
}
12411241

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

12491251
pub fn skip_region_resolution(&self) {

0 commit comments

Comments
 (0)