Skip to content

Commit 8d7f257

Browse files
committed
Merge from rustc
2 parents 9ef0de9 + 101e182 commit 8d7f257

File tree

702 files changed

+13057
-8073
lines changed

Some content is hidden

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

702 files changed

+13057
-8073
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ a06baa56b95674fc626b3c3fd680d6a65357fe60
44
95e00bfed801e264e9c4ac817004153ca0f19eb6
55
# reformat with new rustfmt
66
971c549ca334b7b7406e61e958efcca9c4152822
7+
# refactor infcx building
8+
283abbf0e7d20176f76006825b5c52e9a4234e4c

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Hsiang-Cheng Yang <[email protected]>
217217
218218
219219
220-
Ibraheem Ahmed <[email protected]>
220+
221221
Ilyong Cho <[email protected]>
222222
inquisitivecrystal <[email protected]>
223223
Irina Popa <[email protected]>

.reuse/dep5

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ Files: *
66
Copyright: The Rust Project Developers (see https://thanks.rust-lang.org)
77
License: MIT or Apache-2.0
88

9-
Files: library/std/src/sync/mpsc/mpsc_queue.rs
10-
library/std/src/sync/mpsc/spsc_queue.rs
11-
Copyright: 2010-2011 Dmitry Vyukov
12-
License: BSD-2-Clause
13-
149
Files: src/librustdoc/html/static/fonts/FiraSans*
1510
Copyright: 2014, Mozilla Foundation, 2014, Telefonica S.A.
1611
License: OFL-1.1

Cargo.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ dependencies = [
273273

274274
[[package]]
275275
name = "cargo"
276-
version = "0.67.0"
276+
version = "0.68.0"
277277
dependencies = [
278278
"anyhow",
279279
"atty",
@@ -473,9 +473,9 @@ version = "0.1.0"
473473

474474
[[package]]
475475
name = "cc"
476-
version = "1.0.73"
476+
version = "1.0.76"
477477
source = "registry+https://github.com/rust-lang/crates.io-index"
478-
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
478+
checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"
479479
dependencies = [
480480
"jobserver",
481481
]
@@ -502,9 +502,9 @@ dependencies = [
502502

503503
[[package]]
504504
name = "chalk-derive"
505-
version = "0.80.0"
505+
version = "0.87.0"
506506
source = "registry+https://github.com/rust-lang/crates.io-index"
507-
checksum = "d0001adf0cf12361e08b65e1898ea138f8f77d8f5177cbf29b6b3b3532252bd6"
507+
checksum = "d552b2fa341f5fc35c6b917b1d289d3c3a34d0b74e579390ea6192d6152a8cdb"
508508
dependencies = [
509509
"proc-macro2",
510510
"quote",
@@ -514,9 +514,9 @@ dependencies = [
514514

515515
[[package]]
516516
name = "chalk-engine"
517-
version = "0.80.0"
517+
version = "0.87.0"
518518
source = "registry+https://github.com/rust-lang/crates.io-index"
519-
checksum = "c44ee96f2d67cb5193d1503f185db1abad9933a1c6e6b4169c176f90baecd393"
519+
checksum = "7e54ac43048cb31c470d7b3e3acd409090ef4a5abddfe02455187aebc3d6879f"
520520
dependencies = [
521521
"chalk-derive",
522522
"chalk-ir",
@@ -527,9 +527,9 @@ dependencies = [
527527

528528
[[package]]
529529
name = "chalk-ir"
530-
version = "0.80.0"
530+
version = "0.87.0"
531531
source = "registry+https://github.com/rust-lang/crates.io-index"
532-
checksum = "92d8a95548f23618fda86426e4304e563ec2bb7ba0216139f0748d63c107b5f1"
532+
checksum = "43aa55deff4e7fbdb09fa014543372f2c95a06835ac487b9ce57b5099b950838"
533533
dependencies = [
534534
"bitflags",
535535
"chalk-derive",
@@ -538,9 +538,9 @@ dependencies = [
538538

539539
[[package]]
540540
name = "chalk-solve"
541-
version = "0.80.0"
541+
version = "0.87.0"
542542
source = "registry+https://github.com/rust-lang/crates.io-index"
543-
checksum = "f37f492dacfafe2e21319b80827da2779932909bb392f0cc86b2bd5c07c1b4e1"
543+
checksum = "61213deefc36ba265ad01c4d997e18bcddf7922862a4594a47ca4575afb3dab4"
544544
dependencies = [
545545
"chalk-derive",
546546
"chalk-ir",

LICENSES/BSD-2-Clause.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

compiler/rustc_ast/src/ast.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ impl Expr {
12081208
ExprKind::Tup(_) => ExprPrecedence::Tup,
12091209
ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node),
12101210
ExprKind::Unary(..) => ExprPrecedence::Unary,
1211-
ExprKind::Lit(_) => ExprPrecedence::Lit,
1211+
ExprKind::Lit(_) | ExprKind::IncludedBytes(..) => ExprPrecedence::Lit,
12121212
ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast,
12131213
ExprKind::Let(..) => ExprPrecedence::Let,
12141214
ExprKind::If(..) => ExprPrecedence::If,
@@ -1446,6 +1446,12 @@ pub enum ExprKind {
14461446
/// with an optional value to be returned.
14471447
Yeet(Option<P<Expr>>),
14481448

1449+
/// Bytes included via `include_bytes!`
1450+
/// Added for optimization purposes to avoid the need to escape
1451+
/// large binary blobs - should always behave like [`ExprKind::Lit`]
1452+
/// with a `ByteStr` literal.
1453+
IncludedBytes(Lrc<[u8]>),
1454+
14491455
/// Placeholder for an expression that wasn't syntactically well formed in some way.
14501456
Err,
14511457
}

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern crate rustc_macros;
2929
extern crate tracing;
3030

3131
pub mod util {
32+
pub mod case;
3233
pub mod classify;
3334
pub mod comments;
3435
pub mod literal;

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
14281428
}
14291429
ExprKind::Try(expr) => vis.visit_expr(expr),
14301430
ExprKind::TryBlock(body) => vis.visit_block(body),
1431-
ExprKind::Lit(_) | ExprKind::Err => {}
1431+
ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err => {}
14321432
}
14331433
vis.visit_id(id);
14341434
vis.visit_span(span);

compiler/rustc_ast/src/token.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub use TokenKind::*;
55

66
use crate::ast;
77
use crate::ptr::P;
8+
use crate::util::case::Case;
89

910
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1011
use rustc_data_structures::sync::Lrc;
@@ -615,6 +616,15 @@ impl Token {
615616
self.is_non_raw_ident_where(|id| id.name == kw)
616617
}
617618

619+
/// Returns `true` if the token is a given keyword, `kw` or if `case` is `Insensitive` and this token is an identifier equal to `kw` ignoring the case.
620+
pub fn is_keyword_case(&self, kw: Symbol, case: Case) -> bool {
621+
self.is_keyword(kw)
622+
|| (case == Case::Insensitive
623+
&& self.is_non_raw_ident_where(|id| {
624+
id.name.as_str().to_lowercase() == kw.as_str().to_lowercase()
625+
}))
626+
}
627+
618628
pub fn is_path_segment_keyword(&self) -> bool {
619629
self.is_non_raw_ident_where(Ident::is_path_segment_keyword)
620630
}

compiler/rustc_ast/src/util/case.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// Whatever to ignore case (`fn` vs `Fn` vs `FN`) or not. Used for recovering.
2+
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
3+
pub enum Case {
4+
Sensitive,
5+
Insensitive,
6+
}

compiler/rustc_ast/src/util/literal.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::ast::{self, Lit, LitKind};
44
use crate::token::{self, Token};
5+
use rustc_data_structures::sync::Lrc;
56
use rustc_lexer::unescape::{byte_from_char, unescape_byte, unescape_char, unescape_literal, Mode};
67
use rustc_span::symbol::{kw, sym, Symbol};
78
use rustc_span::Span;
@@ -231,6 +232,13 @@ impl Lit {
231232
Lit { token_lit: kind.to_token_lit(), kind, span }
232233
}
233234

235+
/// Recovers an AST literal from a string of bytes produced by `include_bytes!`.
236+
/// This requires ASCII-escaping the string, which can result in poor performance
237+
/// for very large strings of bytes.
238+
pub fn from_included_bytes(bytes: &Lrc<[u8]>, span: Span) -> Lit {
239+
Self::from_lit_kind(LitKind::ByteStr(bytes.clone()), span)
240+
}
241+
234242
/// Losslessly convert an AST literal into a token.
235243
pub fn to_token(&self) -> Token {
236244
let kind = match self.token_lit.kind {

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub trait Visitor<'ast>: Sized {
251251
macro_rules! walk_list {
252252
($visitor: expr, $method: ident, $list: expr $(, $($extra_args: expr),* )?) => {
253253
{
254-
#[cfg_attr(not(bootstrap), allow(for_loops_over_fallibles))]
254+
#[allow(for_loops_over_fallibles)]
255255
for elem in $list {
256256
$visitor.$method(elem $(, $($extra_args,)* )?)
257257
}
@@ -901,7 +901,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
901901
}
902902
ExprKind::Try(ref subexpression) => visitor.visit_expr(subexpression),
903903
ExprKind::TryBlock(ref body) => visitor.visit_block(body),
904-
ExprKind::Lit(_) | ExprKind::Err => {}
904+
ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err => {}
905905
}
906906

907907
visitor.visit_expr_post(expression)

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
8787
ExprKind::Lit(ref l) => {
8888
hir::ExprKind::Lit(respan(self.lower_span(l.span), l.kind.clone()))
8989
}
90+
ExprKind::IncludedBytes(ref bytes) => hir::ExprKind::Lit(respan(
91+
self.lower_span(e.span),
92+
LitKind::ByteStr(bytes.clone()),
93+
)),
9094
ExprKind::Cast(ref expr, ref ty) => {
9195
let expr = self.lower_expr(expr);
9296
let ty =

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
323323
// ```
324324
fn lower_expr_within_pat(&mut self, expr: &Expr, allow_paths: bool) -> &'hir hir::Expr<'hir> {
325325
match expr.kind {
326-
ExprKind::Lit(..) | ExprKind::ConstBlock(..) | ExprKind::Err => {}
326+
ExprKind::Lit(..)
327+
| ExprKind::ConstBlock(..)
328+
| ExprKind::IncludedBytes(..)
329+
| ExprKind::Err => {}
327330
ExprKind::Path(..) if allow_paths => {}
328331
ExprKind::Unary(UnOp::Neg, ref inner) if matches!(inner.kind, ExprKind::Lit(_)) => {}
329332
_ => {

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ impl<'a> State<'a> {
322322
ast::ExprKind::Lit(ref lit) => {
323323
self.print_literal(lit);
324324
}
325+
ast::ExprKind::IncludedBytes(ref bytes) => {
326+
let lit = ast::Lit::from_included_bytes(bytes, expr.span);
327+
self.print_literal(&lit)
328+
}
325329
ast::ExprKind::Cast(ref expr, ref ty) => {
326330
let prec = AssocOp::As.precedence() as i8;
327331
self.print_expr_maybe_paren(expr, prec);

compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::nll::ToRegionVid;
24
use crate::path_utils::allow_two_phase_borrow;
35
use crate::place_ext::PlaceExt;

compiler/rustc_borrowck/src/borrowck_errors.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
88
pub(crate) fn cannot_move_when_borrowed(
99
&self,
1010
span: Span,
11-
desc: &str,
11+
borrow_span: Span,
12+
place: &str,
13+
borrow_place: &str,
14+
value_place: &str,
1215
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
13-
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
16+
self.infcx.tcx.sess.create_err(crate::session_diagnostics::MoveBorrow {
17+
place,
18+
span,
19+
borrow_place,
20+
value_place,
21+
borrow_span,
22+
})
1423
}
1524

1625
pub(crate) fn cannot_use_when_mutably_borrowed(

compiler/rustc_borrowck/src/constraint_generation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_infer::infer::InferCtxt;
24
use rustc_middle::mir::visit::TyContext;
35
use rustc_middle::mir::visit::Visitor;

compiler/rustc_borrowck/src/constraints/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use rustc_data_structures::graph::scc::Sccs;
25
use rustc_index::vec::IndexVec;
36
use rustc_middle::mir::ConstraintCategory;

compiler/rustc_borrowck/src/consumers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
//! This file provides API for compiler consumers.
24
35
use rustc_hir::def_id::LocalDefId;

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_data_structures::fx::FxHashMap;
24
use rustc_index::bit_set::BitSet;
35
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place};

compiler/rustc_borrowck/src/def_use.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_middle::mir::visit::{
24
MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext,
35
};

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
25
use rustc_infer::infer::canonical::Canonical;
36
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
224224
}
225225
}
226226

227-
use_spans.var_span_label_path_only(
228-
&mut err,
229-
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
230-
);
227+
use_spans.var_path_only_subdiag(&mut err, desired_action);
231228

232229
if !is_loop_move {
233230
err.span_label(
@@ -404,10 +401,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
404401
let used = desired_action.as_general_verb_in_past_tense();
405402
let mut err =
406403
struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
407-
use_spans.var_span_label_path_only(
408-
&mut err,
409-
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
410-
);
404+
use_spans.var_path_only_subdiag(&mut err, desired_action);
411405

412406
if let InitializationRequiringAction::PartialAssignment
413407
| InitializationRequiringAction::Assignment = desired_action
@@ -673,16 +667,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
673667
let move_spans = self.move_spans(place.as_ref(), location);
674668
let span = move_spans.args_or_use();
675669

676-
let mut err =
677-
self.cannot_move_when_borrowed(span, &self.describe_any_place(place.as_ref()));
678-
err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg));
679-
err.span_label(span, format!("move out of {} occurs here", value_msg));
680-
681-
borrow_spans.var_span_label_path_only(
682-
&mut err,
683-
format!("borrow occurs due to use{}", borrow_spans.describe()),
670+
let mut err = self.cannot_move_when_borrowed(
671+
span,
672+
borrow_span,
673+
&self.describe_any_place(place.as_ref()),
674+
&borrow_msg,
675+
&value_msg,
684676
);
685677

678+
borrow_spans.var_path_only_subdiag(&mut err, crate::InitializationRequiringAction::Borrow);
679+
686680
move_spans.var_span_label(
687681
&mut err,
688682
format!("move occurs due to use{}", move_spans.describe()),
@@ -724,22 +718,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
724718
borrow_span,
725719
&self.describe_any_place(borrow.borrowed_place.as_ref()),
726720
);
727-
borrow_spans.var_subdiag(
728-
&mut err,
729-
|var_span| {
730-
use crate::session_diagnostics::CaptureVarCause::*;
731-
let place = &borrow.borrowed_place;
732-
let desc_place = self.describe_any_place(place.as_ref());
733-
match borrow_spans {
734-
UseSpans::ClosureUse { generator_kind, .. } => match generator_kind {
735-
Some(_) => BorrowUsePlaceGenerator { place: desc_place, var_span },
736-
None => BorrowUsePlaceClosure { place: desc_place, var_span },
737-
},
738-
_ => BorrowUsePlace { place: desc_place, var_span },
739-
}
740-
},
741-
"mutable",
742-
);
721+
borrow_spans.var_subdiag(&mut err, Some(borrow.kind), |kind, var_span| {
722+
use crate::session_diagnostics::CaptureVarCause::*;
723+
let place = &borrow.borrowed_place;
724+
let desc_place = self.describe_any_place(place.as_ref());
725+
match kind {
726+
Some(_) => BorrowUsePlaceGenerator { place: desc_place, var_span },
727+
None => BorrowUsePlaceClosure { place: desc_place, var_span },
728+
}
729+
});
743730

744731
self.explain_why_borrow_contains_point(location, borrow, None)
745732
.add_explanation_to_diagnostic(

0 commit comments

Comments
 (0)