This commit is contained in:
pjht 2024-09-23 20:36:05 -05:00
commit cf4c629a2b
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E
1777 changed files with 13100 additions and 13056 deletions

View File

@ -27,3 +27,5 @@ ec2cc761bc7067712ecc7734502f703fe3b024c8
84ac80f1921afc243d71fd0caaa4f2838c294102 84ac80f1921afc243d71fd0caaa4f2838c294102
# bless mir-opt tests to add `copy` # bless mir-opt tests to add `copy`
99cb0c6bc399fb94a0ddde7e9b38e9c00d523bad 99cb0c6bc399fb94a0ddde7e9b38e9c00d523bad
# reformat with rustfmt edition 2024
c682aa162b0d41e21cc6748f4fecfe01efb69d1f

2
.gitmodules vendored
View File

@ -33,7 +33,7 @@
[submodule "src/llvm-project"] [submodule "src/llvm-project"]
path = src/llvm-project path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git url = https://github.com/rust-lang/llvm-project.git
branch = rustc/19.1-2024-07-30 branch = rustc/19.1-2024-09-17
shallow = true shallow = true
[submodule "src/doc/embedded-book"] [submodule "src/doc/embedded-book"]
path = src/doc/embedded-book path = src/doc/embedded-book

View File

@ -999,8 +999,8 @@ fn univariant_biased<
if repr.can_randomize_type_layout() && cfg!(feature = "randomize") { if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
#[cfg(feature = "randomize")] #[cfg(feature = "randomize")]
{ {
use rand::seq::SliceRandom;
use rand::SeedableRng; use rand::SeedableRng;
use rand::seq::SliceRandom;
// `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field // `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field
// ordering. // ordering.
let mut rng = let mut rng =

View File

@ -1138,13 +1138,10 @@ impl Scalar {
#[inline] #[inline]
pub fn is_bool(&self) -> bool { pub fn is_bool(&self) -> bool {
use Integer::*; use Integer::*;
matches!( matches!(self, Scalar::Initialized {
self,
Scalar::Initialized {
value: Primitive::Int(I8, false), value: Primitive::Int(I8, false),
valid_range: WrappingRange { start: 0, end: 1 } valid_range: WrappingRange { start: 0, end: 1 }
} })
)
} }
/// Get the primitive representation of this type, ignoring the valid range and whether the /// Get the primitive representation of this type, ignoring the valid range and whether the

View File

@ -21,19 +21,19 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::{cmp, fmt, mem}; use std::{cmp, fmt, mem};
pub use GenericArgs::*;
pub use UnsafeSource::*;
pub use rustc_ast_ir::{Movability, Mutability}; pub use rustc_ast_ir::{Movability, Mutability};
use rustc_data_structures::packed::Pu128; use rustc_data_structures::packed::Pu128;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
pub use rustc_span::AttrId; pub use rustc_span::AttrId;
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; use rustc_span::source_map::{Spanned, respan};
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, Symbol, kw, sym};
pub use GenericArgs::*; use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
pub use UnsafeSource::*; use thin_vec::{ThinVec, thin_vec};
pub use crate::format::*; pub use crate::format::*;
use crate::ptr::P; use crate::ptr::P;
@ -288,7 +288,7 @@ pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
} }
} }
pub use crate::node_id::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID}; pub use crate::node_id::{CRATE_NODE_ID, DUMMY_NODE_ID, NodeId};
/// Modifiers on a trait bound like `~const`, `?` and `!`. /// Modifiers on a trait bound like `~const`, `?` and `!`.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
@ -1187,8 +1187,8 @@ impl Expr {
/// `min_const_generics` as more complex expressions are not supported. /// `min_const_generics` as more complex expressions are not supported.
/// ///
/// Does not ensure that the path resolves to a const param, the caller should check this. /// Does not ensure that the path resolves to a const param, the caller should check this.
pub fn is_potential_trivial_const_arg(&self) -> bool { pub fn is_potential_trivial_const_arg(&self, strip_identity_block: bool) -> bool {
let this = self.maybe_unwrap_block(); let this = if strip_identity_block { self.maybe_unwrap_block().1 } else { self };
if let ExprKind::Path(None, path) = &this.kind if let ExprKind::Path(None, path) = &this.kind
&& path.is_potential_trivial_const_arg() && path.is_potential_trivial_const_arg()
@ -1199,14 +1199,15 @@ pub fn is_potential_trivial_const_arg(&self) -> bool {
} }
} }
pub fn maybe_unwrap_block(&self) -> &Expr { /// Returns an expression with (when possible) *one* outter brace removed
pub fn maybe_unwrap_block(&self) -> (bool, &Expr) {
if let ExprKind::Block(block, None) = &self.kind if let ExprKind::Block(block, None) = &self.kind
&& let [stmt] = block.stmts.as_slice() && let [stmt] = block.stmts.as_slice()
&& let StmtKind::Expr(expr) = &stmt.kind && let StmtKind::Expr(expr) = &stmt.kind
{ {
expr (true, expr)
} else { } else {
self (false, self)
} }
} }

View File

@ -4,15 +4,15 @@
use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::atomic::{AtomicU32, Ordering};
use rustc_index::bit_set::GrowableBitSet; use rustc_index::bit_set::GrowableBitSet;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use smallvec::{smallvec, SmallVec}; use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{thin_vec, ThinVec}; use smallvec::{SmallVec, smallvec};
use thin_vec::{ThinVec, thin_vec};
use crate::ast::{ use crate::ast::{
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DelimArgs, AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DUMMY_NODE_ID,
Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NormalAttr, Path, DelimArgs, Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem,
PathSegment, Safety, DUMMY_NODE_ID, NormalAttr, Path, PathSegment, Safety,
}; };
use crate::ptr::P; use crate::ptr::P;
use crate::token::{self, CommentKind, Delimiter, Token}; use crate::token::{self, CommentKind, Delimiter, Token};

View File

@ -1,7 +1,7 @@
use rustc_span::symbol::sym;
use rustc_span::Symbol; use rustc_span::Symbol;
use rustc_span::symbol::sym;
use crate::{attr, Attribute}; use crate::{Attribute, attr};
#[derive(Debug)] #[derive(Debug)]
pub enum EntryPointType { pub enum EntryPointType {

View File

@ -1,5 +1,5 @@
use rustc_macros::HashStable_Generic; use rustc_macros::HashStable_Generic;
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{Symbol, sym};
#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)] #[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
pub enum AllocatorKind { pub enum AllocatorKind {

View File

@ -1,10 +1,10 @@
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_macros::{Decodable, Encodable}; use rustc_macros::{Decodable, Encodable};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, Symbol};
use crate::ptr::P;
use crate::Expr; use crate::Expr;
use crate::ptr::P;
// Definitions: // Definitions:
// //

View File

@ -13,10 +13,10 @@
use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_span::Span;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::Ident; use rustc_span::symbol::Ident;
use rustc_span::Span; use smallvec::{Array, SmallVec, smallvec};
use smallvec::{smallvec, Array, SmallVec};
use thin_vec::ThinVec; use thin_vec::ThinVec;
use crate::ast::*; use crate::ast::*;

View File

@ -1,21 +1,21 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt; use std::fmt;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::edition::Edition;
use rustc_span::symbol::{kw, sym};
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
#[allow(hidden_glob_reexports)]
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
pub use BinOpToken::*; pub use BinOpToken::*;
pub use LitKind::*; pub use LitKind::*;
pub use Nonterminal::*; pub use Nonterminal::*;
pub use NtExprKind::*; pub use NtExprKind::*;
pub use NtPatKind::*; pub use NtPatKind::*;
pub use TokenKind::*; pub use TokenKind::*;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::edition::Edition;
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
#[allow(hidden_glob_reexports)]
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::symbol::{kw, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
use crate::ast; use crate::ast;
use crate::ptr::P; use crate::ptr::P;
@ -385,35 +385,41 @@ pub fn lit(kind: LitKind, symbol: Symbol, suffix: Option<Symbol>) -> TokenKind {
Literal(Lit::new(kind, symbol, suffix)) Literal(Lit::new(kind, symbol, suffix))
} }
/// An approximation to proc-macro-style single-character operators used by rustc parser. /// An approximation to proc-macro-style single-character operators used by
/// If the operator token can be broken into two tokens, the first of which is single-character, /// rustc parser. If the operator token can be broken into two tokens, the
/// then this function performs that operation, otherwise it returns `None`. /// first of which has `n` (1 or 2) chars, then this function performs that
pub fn break_two_token_op(&self) -> Option<(TokenKind, TokenKind)> { /// operation, otherwise it returns `None`.
Some(match *self { pub fn break_two_token_op(&self, n: u32) -> Option<(TokenKind, TokenKind)> {
Le => (Lt, Eq), assert!(n == 1 || n == 2);
EqEq => (Eq, Eq), Some(match (self, n) {
Ne => (Not, Eq), (Le, 1) => (Lt, Eq),
Ge => (Gt, Eq), (EqEq, 1) => (Eq, Eq),
AndAnd => (BinOp(And), BinOp(And)), (Ne, 1) => (Not, Eq),
OrOr => (BinOp(Or), BinOp(Or)), (Ge, 1) => (Gt, Eq),
BinOp(Shl) => (Lt, Lt), (AndAnd, 1) => (BinOp(And), BinOp(And)),
BinOp(Shr) => (Gt, Gt), (OrOr, 1) => (BinOp(Or), BinOp(Or)),
BinOpEq(Plus) => (BinOp(Plus), Eq), (BinOp(Shl), 1) => (Lt, Lt),
BinOpEq(Minus) => (BinOp(Minus), Eq), (BinOp(Shr), 1) => (Gt, Gt),
BinOpEq(Star) => (BinOp(Star), Eq), (BinOpEq(Plus), 1) => (BinOp(Plus), Eq),
BinOpEq(Slash) => (BinOp(Slash), Eq), (BinOpEq(Minus), 1) => (BinOp(Minus), Eq),
BinOpEq(Percent) => (BinOp(Percent), Eq), (BinOpEq(Star), 1) => (BinOp(Star), Eq),
BinOpEq(Caret) => (BinOp(Caret), Eq), (BinOpEq(Slash), 1) => (BinOp(Slash), Eq),
BinOpEq(And) => (BinOp(And), Eq), (BinOpEq(Percent), 1) => (BinOp(Percent), Eq),
BinOpEq(Or) => (BinOp(Or), Eq), (BinOpEq(Caret), 1) => (BinOp(Caret), Eq),
BinOpEq(Shl) => (Lt, Le), (BinOpEq(And), 1) => (BinOp(And), Eq),
BinOpEq(Shr) => (Gt, Ge), (BinOpEq(Or), 1) => (BinOp(Or), Eq),
DotDot => (Dot, Dot), (BinOpEq(Shl), 1) => (Lt, Le), // `<` + `<=`
DotDotDot => (Dot, DotDot), (BinOpEq(Shl), 2) => (BinOp(Shl), Eq), // `<<` + `=`
PathSep => (Colon, Colon), (BinOpEq(Shr), 1) => (Gt, Ge), // `>` + `>=`
RArrow => (BinOp(Minus), Gt), (BinOpEq(Shr), 2) => (BinOp(Shr), Eq), // `>>` + `=`
LArrow => (Lt, BinOp(Minus)), (DotDot, 1) => (Dot, Dot),
FatArrow => (Eq, Gt), (DotDotDot, 1) => (Dot, DotDot), // `.` + `..`
(DotDotDot, 2) => (DotDot, Dot), // `..` + `.`
(DotDotEq, 2) => (DotDot, Eq),
(PathSep, 1) => (Colon, Colon),
(RArrow, 1) => (BinOp(Minus), Gt),
(LArrow, 1) => (Lt, BinOp(Minus)),
(FatArrow, 1) => (Eq, Gt),
_ => return None, _ => return None,
}) })
} }

View File

@ -20,7 +20,7 @@
use rustc_data_structures::sync::{self, Lrc}; use rustc_data_structures::sync::{self, Lrc};
use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::{Decodable, Encodable}; use rustc_serialize::{Decodable, Encodable};
use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym};
use crate::ast::{AttrStyle, StmtKind}; use crate::ast::{AttrStyle, StmtKind};
use crate::ast_traits::{HasAttrs, HasTokens}; use crate::ast_traits::{HasAttrs, HasTokens};

View File

@ -3,10 +3,10 @@
use std::{ascii, fmt, str}; use std::{ascii, fmt, str};
use rustc_lexer::unescape::{ use rustc_lexer::unescape::{
byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, MixedUnit, Mode, MixedUnit, Mode, byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode,
}; };
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Symbol, kw, sym};
use tracing::debug; use tracing::debug;
use crate::ast::{self, LitKind, MetaItemLit, StrStyle}; use crate::ast::{self, LitKind, MetaItemLit, StrStyle};

View File

@ -15,8 +15,8 @@
pub use rustc_ast_ir::visit::VisitorResult; pub use rustc_ast_ir::visit::VisitorResult;
pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list}; pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
use rustc_span::symbol::Ident;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::Ident;
use crate::ast::*; use crate::ast::*;
use crate::ptr::P; use crate::ptr::P;

View File

@ -8,9 +8,10 @@
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_session::parse::feature_err; use rustc_session::parse::feature_err;
use rustc_span::symbol::kw; use rustc_span::symbol::kw;
use rustc_span::{sym, Span}; use rustc_span::{Span, sym};
use rustc_target::asm; use rustc_target::asm;
use super::LoweringContext;
use super::errors::{ use super::errors::{
AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported, AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst, InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
@ -18,10 +19,9 @@
InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister, InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister,
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict, InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
}; };
use super::LoweringContext;
use crate::{ use crate::{
fluent_generated as fluent, AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, ParamMode,
ParamMode, ResolverAstLoweringExt, ResolverAstLoweringExt, fluent_generated as fluent,
}; };
impl<'a, 'hir> LoweringContext<'a, 'hir> { impl<'a, 'hir> LoweringContext<'a, 'hir> {
@ -221,7 +221,7 @@ pub(crate) fn lower_inline_asm(
let parent_def_id = self.current_def_id_parent; let parent_def_id = self.current_def_id_parent;
let node_id = self.next_node_id(); let node_id = self.next_node_id();
// HACK(min_generic_const_args): see lower_anon_const // HACK(min_generic_const_args): see lower_anon_const
if !expr.is_potential_trivial_const_arg() { if !expr.is_potential_trivial_const_arg(true) {
self.create_def( self.create_def(
parent_def_id, parent_def_id,
node_id, node_id,

View File

@ -46,8 +46,8 @@
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::{Asyncness, ResolverAstLowering}; use rustc_middle::ty::{Asyncness, ResolverAstLowering};
use rustc_span::symbol::Ident;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::Ident;
use rustc_target::spec::abi; use rustc_target::spec::abi;
use {rustc_ast as ast, rustc_hir as hir}; use {rustc_ast as ast, rustc_hir as hir};

View File

@ -4,14 +4,14 @@
use rustc_ast::*; use rustc_ast::*;
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::HirId; use rustc_hir::HirId;
use rustc_hir::def::{DefKind, Res};
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_session::errors::report_lit_error; use rustc_session::errors::report_lit_error;
use rustc_span::source_map::{respan, Spanned}; use rustc_span::source_map::{Spanned, respan};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DesugaringKind, Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, DesugaringKind, Span};
use thin_vec::{thin_vec, ThinVec}; use thin_vec::{ThinVec, thin_vec};
use super::errors::{ use super::errors::{
AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot, AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot,
@ -23,7 +23,7 @@
GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt, GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt,
}; };
use crate::errors::YieldInClosure; use crate::errors::YieldInClosure;
use crate::{fluent_generated, AllowReturnTypeNotation, FnDeclKind, ImplTraitPosition}; use crate::{AllowReturnTypeNotation, FnDeclKind, ImplTraitPosition, fluent_generated};
impl<'hir> LoweringContext<'_, 'hir> { impl<'hir> LoweringContext<'_, 'hir> {
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] { fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@ -389,7 +389,7 @@ fn lower_legacy_const_generics(
let node_id = self.next_node_id(); let node_id = self.next_node_id();
// HACK(min_generic_const_args): see lower_anon_const // HACK(min_generic_const_args): see lower_anon_const
if !arg.is_potential_trivial_const_arg() { if !arg.is_potential_trivial_const_arg(true) {
// Add a definition for the in-band const def. // Add a definition for the in-band const def.
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span); self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
} }
@ -725,9 +725,7 @@ pub(super) fn maybe_forward_track_caller(
span, span,
Some(self.allow_gen_future.clone()), Some(self.allow_gen_future.clone()),
); );
self.lower_attrs( self.lower_attrs(inner_hir_id, &[Attribute {
inner_hir_id,
&[Attribute {
kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new( kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new(
sym::track_caller, sym::track_caller,
span, span,
@ -735,8 +733,7 @@ pub(super) fn maybe_forward_track_caller(
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(), id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
style: AttrStyle::Outer, style: AttrStyle::Outer,
span: unstable_span, span: unstable_span,
}], }]);
);
} }
} }

View File

@ -6,8 +6,8 @@
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_session::config::FmtDebug; use rustc_session::config::FmtDebug;
use rustc_span::symbol::{kw, Ident}; use rustc_span::symbol::{Ident, kw};
use rustc_span::{sym, Span, Symbol}; use rustc_span::{Span, Symbol, sym};
use super::LoweringContext; use super::LoweringContext;
@ -363,16 +363,13 @@ fn make_format_spec<'hir>(
debug_hex, debug_hex,
} = &placeholder.format_options; } = &placeholder.format_options;
let fill = ctx.expr_char(sp, fill.unwrap_or(' ')); let fill = ctx.expr_char(sp, fill.unwrap_or(' '));
let align = ctx.expr_lang_item_type_relative( let align =
sp, ctx.expr_lang_item_type_relative(sp, hir::LangItem::FormatAlignment, match alignment {
hir::LangItem::FormatAlignment,
match alignment {
Some(FormatAlignment::Left) => sym::Left, Some(FormatAlignment::Left) => sym::Left,
Some(FormatAlignment::Right) => sym::Right, Some(FormatAlignment::Right) => sym::Right,
Some(FormatAlignment::Center) => sym::Center, Some(FormatAlignment::Center) => sym::Center,
None => sym::Unknown, None => sym::Unknown,
}, });
);
// This needs to match `Flag` in library/core/src/fmt/rt.rs. // This needs to match `Flag` in library/core/src/fmt/rt.rs.
let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32) let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32)
| ((sign == Some(FormatSign::Minus)) as u32) << 1 | ((sign == Some(FormatSign::Minus)) as u32) << 1

View File

@ -6,7 +6,7 @@
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
/// A visitor that walks over the HIR and collects `Node`s into a HIR map. /// A visitor that walks over the HIR and collects `Node`s into a HIR map.

View File

@ -3,17 +3,17 @@
use rustc_ast::*; use rustc_ast::*;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
use rustc_hir::PredicateOrigin; use rustc_hir::PredicateOrigin;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
use rustc_index::{IndexSlice, IndexVec}; use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::{ResolverAstLowering, TyCtxt}; use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{DesugaringKind, Span, Symbol}; use rustc_span::{DesugaringKind, Span, Symbol};
use rustc_target::spec::abi; use rustc_target::spec::abi;
use smallvec::{smallvec, SmallVec}; use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec; use thin_vec::ThinVec;
use tracing::instrument; use tracing::instrument;
@ -281,16 +281,13 @@ fn lower_item_kind(
); );
this.arena.alloc(this.ty(span, hir::TyKind::Err(guar))) this.arena.alloc(this.ty(span, hir::TyKind::Err(guar)))
} }
Some(ty) => this.lower_ty( Some(ty) => this.lower_ty(ty, ImplTraitContext::OpaqueTy {
ty,
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias { origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.local_def_id(id), parent: this.local_def_id(id),
in_assoc_ty: false, in_assoc_ty: false,
}, },
fn_kind: None, fn_kind: None,
}, }),
),
}, },
); );
hir::ItemKind::TyAlias(ty, generics) hir::ItemKind::TyAlias(ty, generics)
@ -981,16 +978,13 @@ fn lower_impl_item(
hir::ImplItemKind::Type(ty) hir::ImplItemKind::Type(ty)
} }
Some(ty) => { Some(ty) => {
let ty = this.lower_ty( let ty = this.lower_ty(ty, ImplTraitContext::OpaqueTy {
ty,
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias { origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.local_def_id(i.id), parent: this.local_def_id(i.id),
in_assoc_ty: true, in_assoc_ty: true,
}, },
fn_kind: None, fn_kind: None,
}, });
);
hir::ImplItemKind::Type(ty) hir::ImplItemKind::Type(ty)
} }
}, },
@ -1129,13 +1123,10 @@ fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Ex
pub(super) fn lower_const_body(&mut self, span: Span, expr: Option<&Expr>) -> hir::BodyId { pub(super) fn lower_const_body(&mut self, span: Span, expr: Option<&Expr>) -> hir::BodyId {
self.lower_body(|this| { self.lower_body(|this| {
( (&[], match expr {
&[],
match expr {
Some(expr) => this.lower_expr_mut(expr), Some(expr) => this.lower_expr_mut(expr),
None => this.expr_err(span, this.dcx().span_delayed_bug(span, "no block")), None => this.expr_err(span, this.dcx().span_delayed_bug(span, "no block")),
}, })
)
}) })
} }
@ -1515,10 +1506,10 @@ fn lower_generics<T>(
for bound in &bound_pred.bounds { for bound in &bound_pred.bounds {
if !matches!( if !matches!(
*bound, *bound,
GenericBound::Trait( GenericBound::Trait(_, TraitBoundModifiers {
_, polarity: BoundPolarity::Maybe(_),
TraitBoundModifiers { polarity: BoundPolarity::Maybe(_), .. } ..
) })
) { ) {
continue; continue;
} }
@ -1619,16 +1610,13 @@ fn lower_generics<T>(
self.children.push((anon_const_did, hir::MaybeOwner::NonOwner(const_id))); self.children.push((anon_const_did, hir::MaybeOwner::NonOwner(const_id)));
let const_body = self.lower_body(|this| { let const_body = self.lower_body(|this| {
( (&[], hir::Expr {
&[],
hir::Expr {
hir_id: const_expr_id, hir_id: const_expr_id,
kind: hir::ExprKind::Lit( kind: hir::ExprKind::Lit(
this.arena.alloc(hir::Lit { node: LitKind::Bool(true), span }), this.arena.alloc(hir::Lit { node: LitKind::Bool(true), span }),
), ),
span, span,
}, })
)
}); });
let default_ac = self.arena.alloc(hir::AnonConst { let default_ac = self.arena.alloc(hir::AnonConst {

View File

@ -53,7 +53,7 @@
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey}; use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res}; use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE}; use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
use rustc_hir::{ use rustc_hir::{
self as hir, ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName, self as hir, ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName,
TraitCandidate, TraitCandidate,
@ -63,9 +63,9 @@
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::{ResolverAstLowering, TyCtxt}; use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_session::parse::{add_feature_diagnostics, feature_err}; use rustc_session::parse::{add_feature_diagnostics, feature_err};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DesugaringKind, Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, DesugaringKind, Span};
use smallvec::{smallvec, SmallVec}; use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec; use thin_vec::ThinVec;
use tracing::{debug, instrument, trace}; use tracing::{debug, instrument, trace};
@ -2466,7 +2466,7 @@ fn lower_anon_const_to_const_arg_direct(&mut self, anon: &AnonConst) -> hir::Con
/// See [`hir::ConstArg`] for when to use this function vs /// See [`hir::ConstArg`] for when to use this function vs
/// [`Self::lower_anon_const_to_const_arg`]. /// [`Self::lower_anon_const_to_const_arg`].
fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst { fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
if c.value.is_potential_trivial_const_arg() { if c.value.is_potential_trivial_const_arg(true) {
// HACK(min_generic_const_args): see DefCollector::visit_anon_const // HACK(min_generic_const_args): see DefCollector::visit_anon_const
// Over there, we guess if this is a bare param and only create a def if // Over there, we guess if this is a bare param and only create a def if
// we think it's not. However we may can guess wrong (see there for example) // we think it's not. However we may can guess wrong (see there for example)

View File

@ -4,8 +4,8 @@
use rustc_hir::def::{DefKind, LifetimeRes, Res}; use rustc_hir::def::{DefKind, LifetimeRes, Res};
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::ResolverAstLowering; use rustc_middle::ty::ResolverAstLowering;
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, kw};
use super::ResolverAstLoweringExt; use super::ResolverAstLoweringExt;

View File

@ -3,9 +3,9 @@
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::Res; use rustc_hir::def::Res;
use rustc_span::Span;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::Ident; use rustc_span::symbol::Ident;
use rustc_span::Span;
use super::errors::{ use super::errors::{
ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding, ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,

View File

@ -1,14 +1,14 @@
use rustc_ast::{self as ast, *}; use rustc_ast::{self as ast, *};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::GenericArg;
use rustc_hir::def::{DefKind, PartialRes, Res}; use rustc_hir::def::{DefKind, PartialRes, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::GenericArg;
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_session::parse::add_feature_diagnostics; use rustc_session::parse::add_feature_diagnostics;
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, DesugaringKind, Span, Symbol, DUMMY_SP}; use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Span, Symbol};
use smallvec::{smallvec, SmallVec}; use smallvec::{SmallVec, smallvec};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use super::errors::{ use super::errors::{

View File

@ -21,21 +21,21 @@
use itertools::{Either, Itertools}; use itertools::{Either, Itertools};
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, walk_list};
use rustc_ast::*; use rustc_ast::*;
use rustc_ast_pretty::pprust::{self, State}; use rustc_ast_pretty::pprust::{self, State};
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::DiagCtxtHandle; use rustc_errors::DiagCtxtHandle;
use rustc_feature::Features; use rustc_feature::Features;
use rustc_parse::validate_attr; use rustc_parse::validate_attr;
use rustc_session::Session;
use rustc_session::lint::builtin::{ use rustc_session::lint::builtin::{
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, MISSING_UNSAFE_ON_EXTERN, DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, MISSING_UNSAFE_ON_EXTERN,
PATTERNS_IN_FNS_WITHOUT_BODY, PATTERNS_IN_FNS_WITHOUT_BODY,
}; };
use rustc_session::lint::{BuiltinLintDiag, LintBuffer}; use rustc_session::lint::{BuiltinLintDiag, LintBuffer};
use rustc_session::Session;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, kw, sym};
use rustc_target::spec::abi; use rustc_target::spec::abi;
use thin_vec::thin_vec; use thin_vec::thin_vec;

View File

@ -1,12 +1,12 @@
use rustc_ast as ast; use rustc_ast as ast;
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor}; use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
use rustc_ast::{attr, token, NodeId, PatKind}; use rustc_ast::{NodeId, PatKind, attr, token};
use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP}; use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features, GateIssue};
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
use rustc_session::Session; use rustc_session::Session;
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
use rustc_span::Span;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_target::spec::abi; use rustc_target::spec::abi;
use thin_vec::ThinVec; use thin_vec::ThinVec;

View File

@ -2,8 +2,8 @@
use rustc_ast::visit::*; use rustc_ast::visit::*;
use rustc_ast::*; use rustc_ast::*;
use rustc_span::symbol::Ident;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::Ident;
pub struct NodeCounter { pub struct NodeCounter {
pub count: usize, pub count: usize,

View File

@ -1,6 +1,6 @@
use std::borrow::Cow; use std::borrow::Cow;
use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, Token, SIZE_INFINITY}; use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, SIZE_INFINITY, Token};
impl Printer { impl Printer {
/// "raw box" /// "raw box"

View File

@ -7,7 +7,7 @@
use rustc_ast as ast; use rustc_ast as ast;
use rustc_ast::token::{Nonterminal, Token, TokenKind}; use rustc_ast::token::{Nonterminal, Token, TokenKind};
use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast::tokenstream::{TokenStream, TokenTree};
pub use state::{print_crate, AnnNode, Comments, PpAnn, PrintState, State}; pub use state::{AnnNode, Comments, PpAnn, PrintState, State, print_crate};
pub fn nonterminal_to_string(nt: &Nonterminal) -> String { pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
State::new().nonterminal_to_string(nt) State::new().nonterminal_to_string(nt)

View File

@ -18,14 +18,14 @@
use rustc_ast::util::classify; use rustc_ast::util::classify;
use rustc_ast::util::comments::{Comment, CommentStyle}; use rustc_ast::util::comments::{Comment, CommentStyle};
use rustc_ast::{ use rustc_ast::{
self as ast, attr, AttrArgs, AttrArgsEq, BindingMode, BlockCheckMode, ByRef, DelimArgs, self as ast, AttrArgs, AttrArgsEq, BindingMode, BlockCheckMode, ByRef, DelimArgs, GenericArg,
GenericArg, GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass, GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass,
InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term, InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term, attr,
}; };
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_span::source_map::{SourceMap, Spanned}; use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::symbol::{kw, sym, Ident, IdentPrinter, Symbol}; use rustc_span::symbol::{Ident, IdentPrinter, Symbol, kw, sym};
use rustc_span::{BytePos, CharPos, FileName, Pos, Span, DUMMY_SP}; use rustc_span::{BytePos, CharPos, DUMMY_SP, FileName, Pos, Span};
use thin_vec::ThinVec; use thin_vec::ThinVec;
use crate::pp::Breaks::{Consistent, Inconsistent}; use crate::pp::Breaks::{Consistent, Inconsistent};
@ -292,9 +292,9 @@ pub fn print_crate<'a>(
/// - #73345: `#[allow(unused)]` must be printed rather than `# [allow(unused)]` /// - #73345: `#[allow(unused)]` must be printed rather than `# [allow(unused)]`
/// ///
fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool { fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
use token::*;
use Delimiter::*; use Delimiter::*;
use TokenTree::{Delimited as Del, Token as Tok}; use TokenTree::{Delimited as Del, Token as Tok};
use token::*;
fn is_punct(tt: &TokenTree) -> bool { fn is_punct(tt: &TokenTree) -> bool {
matches!(tt, TokenTree::Token(tok, _) if tok.is_punct()) matches!(tt, TokenTree::Token(tok, _) if tok.is_punct())

View File

@ -7,13 +7,13 @@
use rustc_ast::util::literal::escape_byte_str_symbol; use rustc_ast::util::literal::escape_byte_str_symbol;
use rustc_ast::util::parser::{self, AssocOp, Fixity}; use rustc_ast::util::parser::{self, AssocOp, Fixity};
use rustc_ast::{ use rustc_ast::{
self as ast, token, BlockCheckMode, FormatAlignment, FormatArgPosition, FormatArgsPiece, self as ast, BlockCheckMode, FormatAlignment, FormatArgPosition, FormatArgsPiece, FormatCount,
FormatCount, FormatDebugHex, FormatSign, FormatTrait, FormatDebugHex, FormatSign, FormatTrait, token,
}; };
use crate::pp::Breaks::Inconsistent; use crate::pp::Breaks::Inconsistent;
use crate::pprust::state::fixup::FixupContext; use crate::pprust::state::fixup::FixupContext;
use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT}; use crate::pprust::state::{AnnNode, INDENT_UNIT, PrintState, State};
impl<'a> State<'a> { impl<'a> State<'a> {
fn print_else(&mut self, els: Option<&ast::Expr>) { fn print_else(&mut self, els: Option<&ast::Expr>) {

View File

@ -1,5 +1,5 @@
use rustc_ast::util::{classify, parser};
use rustc_ast::Expr; use rustc_ast::Expr;
use rustc_ast::util::{classify, parser};
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub(crate) struct FixupContext { pub(crate) struct FixupContext {

View File

@ -1,13 +1,13 @@
use ast::StaticItem; use ast::StaticItem;
use itertools::{Itertools, Position}; use itertools::{Itertools, Position};
use rustc_ast as ast; use rustc_ast as ast;
use rustc_ast::ptr::P;
use rustc_ast::ModKind; use rustc_ast::ModKind;
use rustc_ast::ptr::P;
use rustc_span::symbol::Ident; use rustc_span::symbol::Ident;
use crate::pp::Breaks::Inconsistent; use crate::pp::Breaks::Inconsistent;
use crate::pprust::state::fixup::FixupContext; use crate::pprust::state::fixup::FixupContext;
use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT}; use crate::pprust::state::{AnnNode, INDENT_UNIT, PrintState, State};
enum DelegationKind<'a> { enum DelegationKind<'a> {
Single, Single,

View File

@ -1,6 +1,6 @@
use rustc_ast as ast; use rustc_ast as ast;
use rustc_span::symbol::Ident; use rustc_span::symbol::Ident;
use rustc_span::{create_default_session_globals_then, DUMMY_SP}; use rustc_span::{DUMMY_SP, create_default_session_globals_then};
use thin_vec::ThinVec; use thin_vec::ThinVec;
use super::*; use super::*;

View File

@ -4,21 +4,21 @@
use rustc_abi::Align; use rustc_abi::Align;
use rustc_ast::{ use rustc_ast::{
self as ast, attr, Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, self as ast, Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NodeId,
NodeId, attr,
}; };
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg}; use rustc_feature::{Features, GatedCfg, find_gated_cfg, is_builtin_attr_name};
use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_session::config::ExpectedValues; use rustc_session::config::ExpectedValues;
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
use rustc_session::lint::BuiltinLintDiag; use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
use rustc_session::parse::feature_err; use rustc_session::parse::feature_err;
use rustc_session::{RustcVersion, Session}; use rustc_session::{RustcVersion, Session};
use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{Symbol, sym};
use crate::fluent_generated; use crate::fluent_generated;
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause}; use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};

View File

@ -15,11 +15,11 @@
mod builtin; mod builtin;
mod session_diagnostics; mod session_diagnostics;
pub use builtin::*;
pub use rustc_ast::attr::*;
pub(crate) use rustc_session::HashStableContext;
pub use IntType::*; pub use IntType::*;
pub use ReprAttr::*; pub use ReprAttr::*;
pub use StabilityLevel::*; pub use StabilityLevel::*;
pub use builtin::*;
pub use rustc_ast::attr::*;
pub(crate) use rustc_session::HashStableContext;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" } rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View File

@ -6,7 +6,7 @@
use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use crate::{fluent_generated as fluent, UnsupportedLiteralReason}; use crate::{UnsupportedLiteralReason, fluent_generated as fluent};
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(attr_expected_one_cfg_pattern, code = E0536)] #[diag(attr_expected_one_cfg_pattern, code = E0536)]
@ -203,10 +203,7 @@ pub(crate) struct UnsupportedLiteral {
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral { impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let mut diag = Diag::new( let mut diag = Diag::new(dcx, level, match self.reason {
dcx,
level,
match self.reason {
UnsupportedLiteralReason::Generic => fluent::attr_unsupported_literal_generic, UnsupportedLiteralReason::Generic => fluent::attr_unsupported_literal_generic,
UnsupportedLiteralReason::CfgString => fluent::attr_unsupported_literal_cfg_string, UnsupportedLiteralReason::CfgString => fluent::attr_unsupported_literal_cfg_string,
UnsupportedLiteralReason::DeprecatedString => { UnsupportedLiteralReason::DeprecatedString => {
@ -215,8 +212,7 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
UnsupportedLiteralReason::DeprecatedKvPair => { UnsupportedLiteralReason::DeprecatedKvPair => {
fluent::attr_unsupported_literal_deprecated_kv_pair fluent::attr_unsupported_literal_deprecated_kv_pair
} }
}, });
);
diag.span(self.span); diag.span(self.span);
diag.code(E0565); diag.code(E0565);
if self.is_bytestr { if self.is_bytestr {

View File

@ -4,15 +4,15 @@
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_index::bit_set::BitSet; use rustc_index::bit_set::BitSet;
use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor}; use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{self, traversal, Body, Local, Location}; use rustc_middle::mir::{self, Body, Local, Location, traversal};
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::{RegionVid, TyCtxt}; use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::move_paths::MoveData; use rustc_mir_dataflow::move_paths::MoveData;
use tracing::debug; use tracing::debug;
use crate::BorrowIndex;
use crate::path_utils::allow_two_phase_borrow; use crate::path_utils::allow_two_phase_borrow;
use crate::place_ext::PlaceExt; use crate::place_ext::PlaceExt;
use crate::BorrowIndex;
pub struct BorrowSet<'tcx> { pub struct BorrowSet<'tcx> {
/// The fundamental map relating bitvector indexes to the borrows /// The fundamental map relating bitvector indexes to the borrows

View File

@ -2,7 +2,7 @@
#![allow(rustc::untranslatable_diagnostic)] #![allow(rustc::untranslatable_diagnostic)]
use rustc_errors::codes::*; use rustc_errors::codes::*;
use rustc_errors::{struct_span_code_err, Applicability, Diag, DiagCtxtHandle}; use rustc_errors::{Applicability, Diag, DiagCtxtHandle, struct_span_code_err};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};

View File

@ -8,12 +8,12 @@
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
pub use super::constraints::OutlivesConstraint; pub use super::constraints::OutlivesConstraint;
pub use super::dataflow::{calculate_borrows_out_of_scope_at_location, BorrowIndex, Borrows}; pub use super::dataflow::{BorrowIndex, Borrows, calculate_borrows_out_of_scope_at_location};
pub use super::facts::{AllFacts as PoloniusInput, RustcFacts}; pub use super::facts::{AllFacts as PoloniusInput, RustcFacts};
pub use super::location::{LocationTable, RichLocation}; pub use super::location::{LocationTable, RichLocation};
pub use super::nll::PoloniusOutput; pub use super::nll::PoloniusOutput;
pub use super::place_ext::PlaceExt; pub use super::place_ext::PlaceExt;
pub use super::places_conflict::{places_conflict, PlaceConflictBias}; pub use super::places_conflict::{PlaceConflictBias, places_conflict};
pub use super::region_infer::RegionInferenceContext; pub use super::region_infer::RegionInferenceContext;
use crate::borrow_set::BorrowSet; use crate::borrow_set::BorrowSet;

View File

@ -12,7 +12,7 @@
use rustc_mir_dataflow::{Analysis, AnalysisDomain, Forward, GenKill, Results, ResultsVisitable}; use rustc_mir_dataflow::{Analysis, AnalysisDomain, Forward, GenKill, Results, ResultsVisitable};
use tracing::debug; use tracing::debug;
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext}; use crate::{BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext, places_conflict};
/// The results of the dataflow analyses used by the borrow checker. /// The results of the dataflow analyses used by the borrow checker.
pub(crate) struct BorrowckResults<'a, 'tcx> { pub(crate) struct BorrowckResults<'a, 'tcx> {

View File

@ -14,18 +14,18 @@
self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex, self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex,
}; };
use rustc_span::Span; use rustc_span::Span;
use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::query::type_op; use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
use rustc_trait_selection::traits::ObligationCtxt; use rustc_trait_selection::traits::ObligationCtxt;
use rustc_trait_selection::traits::query::type_op;
use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause}; use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use crate::MirBorrowckCtxt;
use crate::region_infer::values::RegionElement; use crate::region_infer::values::RegionElement;
use crate::session_diagnostics::{ use crate::session_diagnostics::{
HigherRankedErrorCause, HigherRankedLifetimeError, HigherRankedSubtypeError, HigherRankedErrorCause, HigherRankedLifetimeError, HigherRankedSubtypeError,
}; };
use crate::MirBorrowckCtxt;
#[derive(Clone)] #[derive(Clone)]
pub(crate) struct UniverseInfo<'tcx>(UniverseInfoInner<'tcx>); pub(crate) struct UniverseInfo<'tcx>(UniverseInfoInner<'tcx>);
@ -176,21 +176,20 @@ fn report_error(
return; return;
}; };
let placeholder_region = ty::Region::new_placeholder( let placeholder_region = ty::Region::new_placeholder(tcx, ty::Placeholder {
tcx, universe: adjusted_universe.into(),
ty::Placeholder { universe: adjusted_universe.into(), bound: placeholder.bound }, bound: placeholder.bound,
); });
let error_region = if let RegionElement::PlaceholderRegion(error_placeholder) = let error_region =
error_element if let RegionElement::PlaceholderRegion(error_placeholder) = error_element {
{
let adjusted_universe = let adjusted_universe =
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32()); error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
adjusted_universe.map(|adjusted| { adjusted_universe.map(|adjusted| {
ty::Region::new_placeholder( ty::Region::new_placeholder(tcx, ty::Placeholder {
tcx, universe: adjusted.into(),
ty::Placeholder { universe: adjusted.into(), bound: error_placeholder.bound }, bound: error_placeholder.bound,
) })
}) })
} else { } else {
None None

View File

@ -11,10 +11,10 @@
use rustc_data_structures::captures::Captures; use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::codes::*; use rustc_errors::codes::*;
use rustc_errors::{struct_span_code_err, Applicability, Diag, MultiSpan}; use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{walk_block, walk_expr, Map, Visitor}; use rustc_hir::intravisit::{Map, Visitor, walk_block, walk_expr};
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField}; use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField};
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::hir::nested_filter::OnlyBodies;
@ -27,17 +27,17 @@
}; };
use rustc_middle::ty::print::PrintTraitRefExt as _; use rustc_middle::ty::print::PrintTraitRefExt as _;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, suggest_constraining_type_params, PredicateKind, Ty, TyCtxt, TypeSuperVisitable, self, PredicateKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor, Upcast,
TypeVisitor, Upcast, suggest_constraining_type_params,
}; };
use rustc_middle::util::CallKind; use rustc_middle::util::CallKind;
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex}; use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::hygiene::DesugaringKind; use rustc_span::hygiene::DesugaringKind;
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, Span, Symbol}; use rustc_span::{BytePos, Span, Symbol};
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt}; use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
@ -46,9 +46,9 @@
use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans}; use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans};
use crate::borrow_set::{BorrowData, TwoPhaseActivation}; use crate::borrow_set::{BorrowData, TwoPhaseActivation};
use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead; use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt, Instance}; use crate::diagnostics::{CapturedMessageOpt, Instance, find_all_local_uses};
use crate::prefixes::IsPrefixOf; use crate::prefixes::IsPrefixOf;
use crate::{borrowck_errors, InitializationRequiringAction, MirBorrowckCtxt, WriteKind}; use crate::{InitializationRequiringAction, MirBorrowckCtxt, WriteKind, borrowck_errors};
#[derive(Debug)] #[derive(Debug)]
struct MoveSite { struct MoveSite {
@ -145,10 +145,10 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
span, span,
desired_action.as_noun(), desired_action.as_noun(),
partially_str, partially_str,
self.describe_place_with_options( self.describe_place_with_options(moved_place, DescribePlaceOpt {
moved_place, including_downcast: true,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true }, including_tuple_field: true,
), }),
); );
let reinit_spans = maybe_reinitialized_locations let reinit_spans = maybe_reinitialized_locations
@ -266,10 +266,10 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
} }
} }
let opt_name = self.describe_place_with_options( let opt_name = self.describe_place_with_options(place.as_ref(), DescribePlaceOpt {
place.as_ref(), including_downcast: true,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true }, including_tuple_field: true,
); });
let note_msg = match opt_name { let note_msg = match opt_name {
Some(name) => format!("`{name}`"), Some(name) => format!("`{name}`"),
None => "value".to_owned(), None => "value".to_owned(),
@ -689,17 +689,17 @@ fn report_use_of_uninitialized(
} }
let spans: Vec<_> = spans_set.into_iter().collect(); let spans: Vec<_> = spans_set.into_iter().collect();
let (name, desc) = match self.describe_place_with_options( let (name, desc) = match self.describe_place_with_options(moved_place, DescribePlaceOpt {
moved_place, including_downcast: true,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true }, including_tuple_field: true,
) { }) {
Some(name) => (format!("`{name}`"), format!("`{name}` ")), Some(name) => (format!("`{name}`"), format!("`{name}` ")),
None => ("the variable".to_string(), String::new()), None => ("the variable".to_string(), String::new()),
}; };
let path = match self.describe_place_with_options( let path = match self.describe_place_with_options(used_place, DescribePlaceOpt {
used_place, including_downcast: true,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true }, including_tuple_field: true,
) { }) {
Some(name) => format!("`{name}`"), Some(name) => format!("`{name}`"),
None => "value".to_string(), None => "value".to_string(),
}; };

View File

@ -17,12 +17,12 @@
}; };
use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt}; use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt};
use rustc_span::symbol::{kw, Symbol}; use rustc_span::symbol::{Symbol, kw};
use rustc_span::{sym, DesugaringKind, Span}; use rustc_span::{DesugaringKind, Span, sym};
use rustc_trait_selection::error_reporting::traits::FindExprBySpan; use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use super::{find_use, RegionName, UseSpans}; use super::{RegionName, UseSpans, find_use};
use crate::borrow_set::BorrowData; use crate::borrow_set::BorrowData;
use crate::nll::ConstraintDescription; use crate::nll::ConstraintDescription;
use crate::region_infer::{BlameConstraint, Cause, ExtraConstraintInfo}; use crate::region_infer::{BlameConstraint, Cause, ExtraConstraintInfo};

View File

@ -15,22 +15,22 @@
}; };
use rustc_middle::ty::print::Print; use rustc_middle::ty::print::Print;
use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_middle::util::{call_kind, CallDesugaringKind}; use rustc_middle::util::{CallDesugaringKind, call_kind};
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult}; use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use rustc_span::{Span, Symbol, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_target::abi::{FieldIdx, VariantIdx}; use rustc_target::abi::{FieldIdx, VariantIdx};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{ use rustc_trait_selection::traits::{
type_known_to_meet_bound_modulo_regions, FulfillmentErrorCode, FulfillmentErrorCode, type_known_to_meet_bound_modulo_regions,
}; };
use tracing::debug; use tracing::debug;
use super::borrow_set::BorrowData;
use super::MirBorrowckCtxt; use super::MirBorrowckCtxt;
use super::borrow_set::BorrowData;
use crate::fluent_generated as fluent; use crate::fluent_generated as fluent;
use crate::session_diagnostics::{ use crate::session_diagnostics::{
CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause, CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
@ -177,10 +177,10 @@ pub(super) fn describe_any_place(&self, place_ref: PlaceRef<'tcx>) -> String {
/// End-user visible description of `place` if one can be found. /// End-user visible description of `place` if one can be found.
/// If the place is a temporary for instance, `None` will be returned. /// If the place is a temporary for instance, `None` will be returned.
pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option<String> { pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option<String> {
self.describe_place_with_options( self.describe_place_with_options(place_ref, DescribePlaceOpt {
place_ref, including_downcast: false,
DescribePlaceOpt { including_downcast: false, including_tuple_field: true }, including_tuple_field: true,
) })
} }
/// End-user visible description of `place` if one can be found. If the place is a temporary /// End-user visible description of `place` if one can be found. If the place is a temporary

View File

@ -12,9 +12,9 @@
use rustc_trait_selection::error_reporting::traits::FindExprBySpan; use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use tracing::debug; use tracing::debug;
use crate::MirBorrowckCtxt;
use crate::diagnostics::{CapturedMessageOpt, DescribePlaceOpt, UseSpans}; use crate::diagnostics::{CapturedMessageOpt, DescribePlaceOpt, UseSpans};
use crate::prefixes::PrefixSet; use crate::prefixes::PrefixSet;
use crate::MirBorrowckCtxt;
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum IllegalMoveOriginKind<'tcx> { pub(crate) enum IllegalMoveOriginKind<'tcx> {

View File

@ -14,8 +14,8 @@
PlaceRef, ProjectionElem, PlaceRef, ProjectionElem,
}; };
use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast}; use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast};
use rustc_span::symbol::{kw, Symbol}; use rustc_span::symbol::{Symbol, kw};
use rustc_span::{sym, BytePos, DesugaringKind, Span}; use rustc_span::{BytePos, DesugaringKind, Span, sym};
use rustc_target::abi::FieldIdx; use rustc_target::abi::FieldIdx;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::infer::InferCtxtExt;
@ -24,7 +24,7 @@
use crate::diagnostics::BorrowedContentSource; use crate::diagnostics::BorrowedContentSource;
use crate::util::FindAssignments; use crate::util::FindAssignments;
use crate::{session_diagnostics, MirBorrowckCtxt}; use crate::{MirBorrowckCtxt, session_diagnostics};
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub(crate) enum AccessKind { pub(crate) enum AccessKind {

View File

@ -3,26 +3,26 @@
use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan}; use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::Res::Def;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::GenericBound::Trait; use rustc_hir::GenericBound::Trait;
use rustc_hir::QPath::Resolved; use rustc_hir::QPath::Resolved;
use rustc_hir::WherePredicate::BoundPredicate; use rustc_hir::WherePredicate::BoundPredicate;
use rustc_hir::def::Res::Def;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate}; use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate};
use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound}; use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound};
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::hir::place::PlaceBase; use rustc_middle::hir::place::PlaceBase;
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint}; use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
use rustc_middle::ty::{self, GenericArgs, Region, RegionVid, Ty, TyCtxt, TypeVisitor}; use rustc_middle::ty::{self, GenericArgs, Region, RegionVid, Ty, TyCtxt, TypeVisitor};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, kw};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::infer::nice_region_error::{ use rustc_trait_selection::error_reporting::infer::nice_region_error::{
self, find_anon_type, find_param_with_region, suggest_adding_lifetime_params, self, HirTraitObjectVisitor, NiceRegionError, TraitObjectVisitor, find_anon_type,
HirTraitObjectVisitor, NiceRegionError, TraitObjectVisitor, find_param_with_region, suggest_adding_lifetime_params,
}; };
use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_region_diagnostic; use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_region_diagnostic;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{Obligation, ObligationCtxt}; use rustc_trait_selection::traits::{Obligation, ObligationCtxt};
use tracing::{debug, instrument, trace}; use tracing::{debug, instrument, trace};
@ -36,7 +36,7 @@
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote, LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
}; };
use crate::universal_regions::DefiningTy; use crate::universal_regions::DefiningTy;
use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt}; use crate::{MirBorrowckCtxt, borrowck_errors, fluent_generated as fluent};
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> { impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
fn description(&self) -> &'static str { fn description(&self) -> &'static str {
@ -1108,15 +1108,12 @@ fn suggest_deref_closure_return(&self, diag: &mut Diag<'_>) {
let closure_ty = Ty::new_closure( let closure_ty = Ty::new_closure(
tcx, tcx,
closure_def_id.to_def_id(), closure_def_id.to_def_id(),
ty::ClosureArgs::new( ty::ClosureArgs::new(tcx, ty::ClosureArgsParts {
tcx,
ty::ClosureArgsParts {
parent_args: args.parent_args(), parent_args: args.parent_args(),
closure_kind_ty: args.kind_ty(), closure_kind_ty: args.kind_ty(),
tupled_upvars_ty: args.tupled_upvars_ty(), tupled_upvars_ty: args.tupled_upvars_ty(),
closure_sig_as_fn_ptr_ty, closure_sig_as_fn_ptr_ty,
}, })
)
.args, .args,
); );

View File

@ -11,13 +11,13 @@
use rustc_middle::ty::print::RegionHighlightMode; use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, RegionVid, Ty}; use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, RegionVid, Ty};
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{Symbol, kw, sym};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use crate::universal_regions::DefiningTy;
use crate::MirBorrowckCtxt; use crate::MirBorrowckCtxt;
use crate::universal_regions::DefiningTy;
/// A name for a particular region used in emitting diagnostics. This name could be a generated /// A name for a particular region used in emitting diagnostics. This name could be a generated
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`. /// name like `'1`, a name used by the user like `'a`, or a name like `'static`.

View File

@ -1,8 +1,8 @@
use rustc_index::IndexSlice; use rustc_index::IndexSlice;
use rustc_middle::mir::{Body, Local}; use rustc_middle::mir::{Body, Local};
use rustc_middle::ty::{self, RegionVid, TyCtxt}; use rustc_middle::ty::{self, RegionVid, TyCtxt};
use rustc_span::symbol::Symbol;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::Symbol;
use tracing::debug; use tracing::debug;
use crate::region_infer::RegionInferenceContext; use crate::region_infer::RegionInferenceContext;

View File

@ -10,8 +10,8 @@
use rustc_middle::ty::{RegionVid, TyCtxt}; use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::move_paths::MovePathIndex; use rustc_mir_dataflow::move_paths::MovePathIndex;
use crate::location::{LocationIndex, LocationTable};
use crate::BorrowIndex; use crate::BorrowIndex;
use crate::location::{LocationIndex, LocationTable};
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct RustcFacts; pub struct RustcFacts;

View File

@ -37,13 +37,13 @@
use rustc_middle::query::Providers; use rustc_middle::query::Providers;
use rustc_middle::ty::{self, ParamEnv, RegionVid, TyCtxt}; use rustc_middle::ty::{self, ParamEnv, RegionVid, TyCtxt};
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_mir_dataflow::Analysis;
use rustc_mir_dataflow::impls::{ use rustc_mir_dataflow::impls::{
EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces, EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
}; };
use rustc_mir_dataflow::move_paths::{ use rustc_mir_dataflow::move_paths::{
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex, InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
}; };
use rustc_mir_dataflow::Analysis;
use rustc_session::lint::builtin::UNUSED_MUT; use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx; use rustc_target::abi::FieldIdx;
@ -86,7 +86,7 @@
use dataflow::{BorrowIndex, BorrowckDomain, BorrowckResults, Borrows}; use dataflow::{BorrowIndex, BorrowckDomain, BorrowckResults, Borrows};
use nll::PoloniusOutput; use nll::PoloniusOutput;
use place_ext::PlaceExt; use place_ext::PlaceExt;
use places_conflict::{places_conflict, PlaceConflictBias}; use places_conflict::{PlaceConflictBias, places_conflict};
use region_infer::RegionInferenceContext; use region_infer::RegionInferenceContext;
use renumber::RegionCtxt; use renumber::RegionCtxt;
@ -1612,13 +1612,9 @@ fn check_movable_place(&mut self, location: Location, place: Place<'tcx>) {
match elem { match elem {
ProjectionElem::Deref => match place_ty.ty.kind() { ProjectionElem::Deref => match place_ty.ty.kind() {
ty::Ref(..) | ty::RawPtr(..) => { ty::Ref(..) | ty::RawPtr(..) => {
self.move_errors.push(MoveError::new( self.move_errors.push(MoveError::new(place, location, BorrowedContent {
place,
location,
BorrowedContent {
target_place: place_ref.project_deeper(&[elem], tcx), target_place: place_ref.project_deeper(&[elem], tcx),
}, }));
));
return; return;
} }
ty::Adt(adt, _) => { ty::Adt(adt, _) => {

View File

@ -9,17 +9,17 @@
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_index::IndexSlice; use rustc_index::IndexSlice;
use rustc_middle::mir::pretty::{dump_mir_with_options, PrettyPrintMirOptions}; use rustc_middle::mir::pretty::{PrettyPrintMirOptions, dump_mir_with_options};
use rustc_middle::mir::{ use rustc_middle::mir::{
create_dump_file, dump_enabled, dump_mir, Body, ClosureOutlivesSubject, Body, ClosureOutlivesSubject, ClosureRegionRequirements, PassWhere, Promoted, create_dump_file,
ClosureRegionRequirements, PassWhere, Promoted, dump_enabled, dump_mir,
}; };
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, OpaqueHiddenType, TyCtxt}; use rustc_middle::ty::{self, OpaqueHiddenType, TyCtxt};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData; use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap; use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
use rustc_session::config::MirIncludeSpans; use rustc_session::config::MirIncludeSpans;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
@ -32,7 +32,7 @@
use crate::region_infer::RegionInferenceContext; use crate::region_infer::RegionInferenceContext;
use crate::type_check::{self, MirTypeckRegionConstraints, MirTypeckResults}; use crate::type_check::{self, MirTypeckRegionConstraints, MirTypeckResults};
use crate::universal_regions::UniversalRegions; use crate::universal_regions::UniversalRegions;
use crate::{polonius, renumber, BorrowckInferCtxt}; use crate::{BorrowckInferCtxt, polonius, renumber};
pub type PoloniusOutput = Output<RustcFacts>; pub type PoloniusOutput = Output<RustcFacts>;

View File

@ -5,7 +5,7 @@
use tracing::debug; use tracing::debug;
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation}; use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
use crate::{places_conflict, AccessDepth, BorrowIndex}; use crate::{AccessDepth, BorrowIndex, places_conflict};
/// Returns `true` if the borrow represented by `kind` is /// Returns `true` if the borrow represented by `kind` is
/// allowed to be split into separate Reservation and /// allowed to be split into separate Reservation and

View File

@ -23,6 +23,7 @@
use rustc_span::Span; use rustc_span::Span;
use tracing::{debug, instrument, trace}; use tracing::{debug, instrument, trace};
use crate::BorrowckInferCtxt;
use crate::constraints::graph::{self, NormalConstraintGraph, RegionGraph}; use crate::constraints::graph::{self, NormalConstraintGraph, RegionGraph};
use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet}; use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet};
use crate::dataflow::BorrowIndex; use crate::dataflow::BorrowIndex;
@ -33,10 +34,9 @@
use crate::region_infer::values::{ use crate::region_infer::values::{
LivenessValues, PlaceholderIndices, RegionElement, RegionValues, ToElementIndex, LivenessValues, PlaceholderIndices, RegionElement, RegionValues, ToElementIndex,
}; };
use crate::type_check::free_region_relations::UniversalRegionRelations;
use crate::type_check::Locations; use crate::type_check::Locations;
use crate::type_check::free_region_relations::UniversalRegionRelations;
use crate::universal_regions::UniversalRegions; use crate::universal_regions::UniversalRegions;
use crate::BorrowckInferCtxt;
mod dump_mir; mod dump_mir;
mod graphviz; mod graphviz;

View File

@ -1,8 +1,8 @@
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_hir::OpaqueTyOrigin;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_hir::OpaqueTyOrigin;
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt as _}; use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt as _};
use rustc_infer::traits::{Obligation, ObligationCause}; use rustc_infer::traits::{Obligation, ObligationCause};
use rustc_macros::extension; use rustc_macros::extension;
@ -165,10 +165,10 @@ pub(crate) fn infer_opaque_types(
// FIXME(oli-obk): collect multiple spans for better diagnostics down the road. // FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
prev.span = prev.span.substitute_dummy(concrete_type.span); prev.span = prev.span.substitute_dummy(concrete_type.span);
} else { } else {
result.insert( result.insert(opaque_type_key.def_id, OpaqueHiddenType {
opaque_type_key.def_id, ty,
OpaqueHiddenType { ty, span: concrete_type.span }, span: concrete_type.span,
); });
} }
// Check that all opaque types have the same region parameters if they have the same // Check that all opaque types have the same region parameters if they have the same

View File

@ -5,8 +5,8 @@
use rustc_data_structures::graph::vec_graph::VecGraph; use rustc_data_structures::graph::vec_graph::VecGraph;
use rustc_middle::ty::RegionVid; use rustc_middle::ty::RegionVid;
use crate::constraints::ConstraintSccIndex;
use crate::RegionInferenceContext; use crate::RegionInferenceContext;
use crate::constraints::ConstraintSccIndex;
pub(crate) struct ReverseSccGraph { pub(crate) struct ReverseSccGraph {
graph: VecGraph<ConstraintSccIndex>, graph: VecGraph<ConstraintSccIndex>,

View File

@ -2,9 +2,9 @@
use std::rc::Rc; use std::rc::Rc;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_index::Idx;
use rustc_index::bit_set::SparseBitMatrix; use rustc_index::bit_set::SparseBitMatrix;
use rustc_index::interval::{IntervalSet, SparseIntervalMatrix}; use rustc_index::interval::{IntervalSet, SparseIntervalMatrix};
use rustc_index::Idx;
use rustc_middle::mir::{BasicBlock, Location}; use rustc_middle::mir::{BasicBlock, Location};
use rustc_middle::ty::{self, RegionVid}; use rustc_middle::ty::{self, RegionVid};
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex}; use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};

View File

@ -1,5 +1,5 @@
use rustc_errors::codes::*;
use rustc_errors::MultiSpan; use rustc_errors::MultiSpan;
use rustc_errors::codes::*;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{GenericArg, Ty}; use rustc_middle::ty::{GenericArg, Ty};
use rustc_span::Span; use rustc_span::Span;

View File

@ -5,11 +5,11 @@
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::mir::ConstraintCategory; use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Upcast}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Upcast};
use rustc_span::def_id::DefId;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::def_id::DefId;
use rustc_trait_selection::traits::ObligationCause;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp; use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput}; use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
use rustc_trait_selection::traits::ObligationCause;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use super::{Locations, NormalizeLocation, TypeChecker}; use super::{Locations, NormalizeLocation, TypeChecker};

View File

@ -6,13 +6,13 @@
use rustc_infer::infer::{self, InferCtxt, SubregionOrigin}; use rustc_infer::infer::{self, InferCtxt, SubregionOrigin};
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, ConstraintCategory}; use rustc_middle::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, ConstraintCategory};
use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::ObligationCause; use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
use rustc_span::Span; use rustc_span::Span;
use rustc_trait_selection::traits::ScrubbedTraitError;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp; use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::ScrubbedTraitError;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use crate::constraints::OutlivesConstraint; use crate::constraints::OutlivesConstraint;

View File

@ -6,10 +6,10 @@
use rustc_infer::infer::canonical::QueryRegionConstraints; use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs; use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::region_constraints::GenericKind; use rustc_infer::infer::region_constraints::GenericKind;
use rustc_infer::infer::{outlives, InferCtxt}; use rustc_infer::infer::{InferCtxt, outlives};
use rustc_middle::mir::ConstraintCategory; use rustc_middle::mir::ConstraintCategory;
use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::traits::ObligationCause; use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt}; use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
use rustc_span::{ErrorGuaranteed, Span}; use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
@ -18,7 +18,7 @@
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use type_op::TypeOpOutput; use type_op::TypeOpOutput;
use crate::type_check::{constraint_conversion, Locations, MirTypeckRegionConstraints}; use crate::type_check::{Locations, MirTypeckRegionConstraints, constraint_conversion};
use crate::universal_regions::UniversalRegions; use crate::universal_regions::UniversalRegions;
#[derive(Debug)] #[derive(Debug)]

View File

@ -77,9 +77,7 @@ pub(super) fn check_signature_annotation(&mut self, body: &Body<'tcx>) {
let output_ty = Ty::new_coroutine( let output_ty = Ty::new_coroutine(
self.tcx(), self.tcx(),
self.tcx().coroutine_for_closure(mir_def_id), self.tcx().coroutine_for_closure(mir_def_id),
ty::CoroutineArgs::new( ty::CoroutineArgs::new(self.tcx(), ty::CoroutineArgsParts {
self.tcx(),
ty::CoroutineArgsParts {
parent_args: args.parent_args(), parent_args: args.parent_args(),
kind_ty: Ty::from_coroutine_closure_kind(self.tcx(), args.kind()), kind_ty: Ty::from_coroutine_closure_kind(self.tcx(), args.kind()),
return_ty: user_provided_sig.output(), return_ty: user_provided_sig.output(),
@ -89,8 +87,7 @@ pub(super) fn check_signature_annotation(&mut self, body: &Body<'tcx>) {
resume_ty: next_ty_var(), resume_ty: next_ty_var(),
yield_ty: next_ty_var(), yield_ty: next_ty_var(),
witness: next_ty_var(), witness: next_ty_var(),
}, })
)
.args, .args,
); );

View File

@ -7,10 +7,10 @@
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::ty::visit::TypeVisitable; use rustc_middle::ty::visit::TypeVisitable;
use rustc_middle::ty::{GenericArgsRef, Region, RegionVid, Ty, TyCtxt}; use rustc_middle::ty::{GenericArgsRef, Region, RegionVid, Ty, TyCtxt};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData; use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap; use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
use tracing::debug; use tracing::debug;
use super::TypeChecker; use super::TypeChecker;

View File

@ -8,10 +8,10 @@
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location}; use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
use rustc_middle::traits::query::DropckOutlivesResult; use rustc_middle::traits::query::DropckOutlivesResult;
use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex}; use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex}; use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
use rustc_mir_dataflow::ResultsCursor;
use rustc_span::DUMMY_SP; use rustc_span::DUMMY_SP;
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives; use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};

View File

@ -31,20 +31,20 @@
UserType, UserTypeAnnotationIndex, UserType, UserTypeAnnotationIndex,
}; };
use rustc_middle::{bug, span_bug}; use rustc_middle::{bug, span_bug};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData; use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap; use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span};
use rustc_target::abi::{FieldIdx, FIRST_VARIANT}; use rustc_target::abi::{FIRST_VARIANT, FieldIdx};
use rustc_trait_selection::traits::PredicateObligation;
use rustc_trait_selection::traits::query::type_op::custom::{ use rustc_trait_selection::traits::query::type_op::custom::{
scrape_region_constraints, CustomTypeOp, CustomTypeOp, scrape_region_constraints,
}; };
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::PredicateObligation;
use tracing::{debug, instrument, trace}; use tracing::{debug, instrument, trace};
use crate::borrow_set::BorrowSet; use crate::borrow_set::BorrowSet;
@ -53,13 +53,13 @@
use crate::facts::AllFacts; use crate::facts::AllFacts;
use crate::location::LocationTable; use crate::location::LocationTable;
use crate::member_constraints::MemberConstraintSet; use crate::member_constraints::MemberConstraintSet;
use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices};
use crate::region_infer::TypeTest; use crate::region_infer::TypeTest;
use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices};
use crate::renumber::RegionCtxt; use crate::renumber::RegionCtxt;
use crate::session_diagnostics::{MoveUnsized, SimdIntrinsicArgConst}; use crate::session_diagnostics::{MoveUnsized, SimdIntrinsicArgConst};
use crate::type_check::free_region_relations::{CreateResult, UniversalRegionRelations}; use crate::type_check::free_region_relations::{CreateResult, UniversalRegionRelations};
use crate::universal_regions::{DefiningTy, UniversalRegions}; use crate::universal_regions::{DefiningTy, UniversalRegions};
use crate::{path_utils, BorrowckInferCtxt}; use crate::{BorrowckInferCtxt, path_utils};
macro_rules! span_mirbug { macro_rules! span_mirbug {
($context:expr, $elem:expr, $($message:tt)*) => ({ ($context:expr, $elem:expr, $($message:tt)*) => ({
@ -1944,11 +1944,10 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
} }
&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => { &Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
let trait_ref = ty::TraitRef::new( let trait_ref =
tcx, ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, Some(span)), [
tcx.require_lang_item(LangItem::Sized, Some(span)), ty,
[ty], ]);
);
self.prove_trait_ref( self.prove_trait_ref(
trait_ref, trait_ref,
@ -1961,11 +1960,10 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
Rvalue::ShallowInitBox(operand, ty) => { Rvalue::ShallowInitBox(operand, ty) => {
self.check_operand(operand, location); self.check_operand(operand, location);
let trait_ref = ty::TraitRef::new( let trait_ref =
tcx, ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, Some(span)), [
tcx.require_lang_item(LangItem::Sized, Some(span)), *ty,
[*ty], ]);
);
self.prove_trait_ref( self.prove_trait_ref(
trait_ref, trait_ref,

View File

@ -4,12 +4,12 @@
PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation, PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation,
}; };
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin}; use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
use rustc_infer::traits::solve::Goal;
use rustc_infer::traits::Obligation; use rustc_infer::traits::Obligation;
use rustc_infer::traits::solve::Goal;
use rustc_middle::mir::ConstraintCategory; use rustc_middle::mir::ConstraintCategory;
use rustc_middle::span_bug; use rustc_middle::span_bug;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::ObligationCause; use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::fold::FnMutDelegate; use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::symbol::sym; use rustc_span::symbol::sym;

View File

@ -20,9 +20,9 @@
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::Diag; use rustc_errors::Diag;
use rustc_hir::BodyOwnerKind;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
use rustc_hir::BodyOwnerKind;
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_infer::infer::NllRegionVariableOrigin; use rustc_infer::infer::NllRegionVariableOrigin;
use rustc_macros::extension; use rustc_macros::extension;
@ -37,8 +37,8 @@
use rustc_span::{ErrorGuaranteed, Symbol}; use rustc_span::{ErrorGuaranteed, Symbol};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use crate::renumber::RegionCtxt;
use crate::BorrowckInferCtxt; use crate::BorrowckInferCtxt;
use crate::renumber::RegionCtxt;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct UniversalRegions<'tcx> { pub(crate) struct UniversalRegions<'tcx> {
@ -629,10 +629,10 @@ fn defining_ty(&self) -> DefiningTy<'tcx> {
let ty = tcx let ty = tcx
.typeck(self.mir_def) .typeck(self.mir_def)
.node_type(tcx.local_def_id_to_hir_id(self.mir_def)); .node_type(tcx.local_def_id_to_hir_id(self.mir_def));
let args = InlineConstArgs::new( let args = InlineConstArgs::new(tcx, InlineConstArgsParts {
tcx, parent_args: identity_args,
InlineConstArgsParts { parent_args: identity_args, ty }, ty,
) })
.args; .args;
let args = self.infcx.replace_free_regions_with_nll_infer_vars(FR, args); let args = self.infcx.replace_free_regions_with_nll_infer_vars(FR, args);
DefiningTy::InlineConst(self.mir_def.to_def_id(), args) DefiningTy::InlineConst(self.mir_def.to_def_id(), args)

View File

@ -3,9 +3,9 @@
self as ast, Fn, FnHeader, FnSig, Generics, ItemKind, Safety, Stmt, StmtKind, TyKind, self as ast, Fn, FnHeader, FnSig, Generics, ItemKind, Safety, Stmt, StmtKind, TyKind,
}; };
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::errors; use crate::errors;
use crate::util::check_builtin_macro_attribute; use crate::util::check_builtin_macro_attribute;
@ -68,11 +68,10 @@ fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig_span: Span
let layout_new = cx.std_path(&[sym::alloc, sym::Layout, sym::from_size_align_unchecked]); let layout_new = cx.std_path(&[sym::alloc, sym::Layout, sym::from_size_align_unchecked]);
let layout_new = cx.expr_path(cx.path(span, layout_new)); let layout_new = cx.expr_path(cx.path(span, layout_new));
let layout = cx.expr_call( let layout = cx.expr_call(span, layout_new, thin_vec![
span, cx.expr_ident(span, size),
layout_new, cx.expr_ident(span, align)
thin_vec![cx.expr_ident(span, size), cx.expr_ident(span, align)], ]);
);
let call = cx.expr_call_ident(sig_span, handler, thin_vec![layout]); let call = cx.expr_call_ident(sig_span, handler, thin_vec![layout]);

View File

@ -1,16 +1,16 @@
use ast::token::IdentIsRaw; use ast::token::IdentIsRaw;
use lint::BuiltinLintDiag; use lint::BuiltinLintDiag;
use rustc_ast::AsmMacro;
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter}; use rustc_ast::token::{self, Delimiter};
use rustc_ast::tokenstream::TokenStream; use rustc_ast::tokenstream::TokenStream;
use rustc_ast::AsmMacro;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_expand::base::*; use rustc_expand::base::*;
use rustc_index::bit_set::GrowableBitSet; use rustc_index::bit_set::GrowableBitSet;
use rustc_parse::parser::Parser; use rustc_parse::parser::Parser;
use rustc_session::lint; use rustc_session::lint;
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{ErrorGuaranteed, InnerSpan, Span}; use rustc_span::{ErrorGuaranteed, InnerSpan, Span};
use rustc_target::asm::InlineAsmArch; use rustc_target::asm::InlineAsmArch;
use smallvec::smallvec; use smallvec::smallvec;

View File

@ -3,13 +3,13 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token::Delimiter; use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::{DelimSpan, TokenStream}; use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::{token, DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp}; use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp, token};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_parse::parser::Parser; use rustc_parse::parser::Parser;
use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::symbol::{Ident, Symbol, sym};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span};
use thin_vec::thin_vec; use thin_vec::thin_vec;
use crate::edition_panic::use_panic_2021; use crate::edition_panic::use_panic_2021;

View File

@ -2,15 +2,15 @@
use rustc_ast::token::{self, Delimiter, IdentIsRaw}; use rustc_ast::token::{self, Delimiter, IdentIsRaw};
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
use rustc_ast::{ use rustc_ast::{
BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability, BinOpKind, BorrowKind, DUMMY_NODE_ID, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall,
Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID, Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind,
}; };
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::ExtCtxt; use rustc_expand::base::ExtCtxt;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
pub(super) struct Context<'cx, 'a> { pub(super) struct Context<'cx, 'a> {
// An optimization. // An optimization.

View File

@ -4,8 +4,8 @@
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier}; use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier};
use rustc_feature::AttributeTemplate; use rustc_feature::AttributeTemplate;
use rustc_parse::validate_attr; use rustc_parse::validate_attr;
use rustc_span::symbol::sym;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::sym;
use crate::errors; use crate::errors;

View File

@ -4,7 +4,7 @@
use rustc_ast::mut_visit::MutVisitor; use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::visit::{AssocCtxt, Visitor}; use rustc_ast::visit::{AssocCtxt, Visitor};
use rustc_ast::{mut_visit, visit, Attribute, HasAttrs, HasTokens, NodeId}; use rustc_ast::{Attribute, HasAttrs, HasTokens, NodeId, mut_visit, visit};
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_expand::config::StripUnconfigured; use rustc_expand::config::StripUnconfigured;
@ -12,8 +12,8 @@
use rustc_feature::Features; use rustc_feature::Features;
use rustc_parse::parser::{ForceCollect, Parser}; use rustc_parse::parser::{ForceCollect, Parser};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::symbol::sym;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::sym;
use smallvec::SmallVec; use smallvec::SmallVec;
use tracing::instrument; use tracing::instrument;

View File

@ -1,7 +1,7 @@
//! Attributes injected into the crate root from command line using `-Z crate-attr`. //! Attributes injected into the crate root from command line using `-Z crate-attr`.
use rustc_ast::attr::mk_attr; use rustc_ast::attr::mk_attr;
use rustc_ast::{self as ast, token, AttrItem, AttrStyle}; use rustc_ast::{self as ast, AttrItem, AttrStyle, token};
use rustc_parse::parser::ForceCollect; use rustc_parse::parser::ForceCollect;
use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal}; use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal};
use rustc_session::parse::ParseSess; use rustc_session::parse::ParseSess;

View File

@ -1,6 +1,6 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream; use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{token, ExprKind, LitIntType, LitKind, UintTy}; use rustc_ast::{ExprKind, LitIntType, LitKind, UintTy, token};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_session::errors::report_lit_error; use rustc_session::errors::report_lit_error;
use rustc_span::{ErrorGuaranteed, Span}; use rustc_span::{ErrorGuaranteed, Span};

View File

@ -1,10 +1,10 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token::{self, Token}; use rustc_ast::token::{self, Token};
use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_ast::{AttrVec, Expr, ExprKind, Path, Ty, TyKind, DUMMY_NODE_ID}; use rustc_ast::{AttrVec, DUMMY_NODE_ID, Expr, ExprKind, Path, Ty, TyKind};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult}; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, Symbol};
use crate::errors; use crate::errors;

View File

@ -6,7 +6,7 @@
use rustc_feature::AttributeTemplate; use rustc_feature::AttributeTemplate;
use rustc_parse::validate_attr; use rustc_parse::validate_attr;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{Ident, sym};
use rustc_span::{ErrorGuaranteed, Span}; use rustc_span::{ErrorGuaranteed, Span};
use crate::cfg_eval::cfg_eval; use crate::cfg_eval::cfg_eval;

View File

@ -1,9 +1,9 @@
use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData}; use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;
use crate::deriving::generic::*; use crate::deriving::generic::*;
@ -115,13 +115,10 @@ fn cs_clone_simple(
// type parameters. // type parameters.
} else if !field.ty.kind.is_anon_adt() { } else if !field.ty.kind.is_anon_adt() {
// let _: AssertParamIsClone<FieldTy>; // let _: AssertParamIsClone<FieldTy>;
super::assert_ty_bounds( super::assert_ty_bounds(cx, &mut stmts, field.ty.clone(), field.span, &[
cx, sym::clone,
&mut stmts, sym::AssertParamIsClone,
field.ty.clone(), ]);
field.span,
&[sym::clone, sym::AssertParamIsClone],
);
} }
} }
}; };
@ -130,13 +127,10 @@ fn cs_clone_simple(
// Just a single assertion for unions, that the union impls `Copy`. // Just a single assertion for unions, that the union impls `Copy`.
// let _: AssertParamIsCopy<Self>; // let _: AssertParamIsCopy<Self>;
let self_ty = cx.ty_path(cx.path_ident(trait_span, Ident::with_dummy_span(kw::SelfUpper))); let self_ty = cx.ty_path(cx.path_ident(trait_span, Ident::with_dummy_span(kw::SelfUpper)));
super::assert_ty_bounds( super::assert_ty_bounds(cx, &mut stmts, self_ty, trait_span, &[
cx, sym::clone,
&mut stmts, sym::AssertParamIsCopy,
self_ty, ]);
trait_span,
&[sym::clone, sym::AssertParamIsCopy],
);
} else { } else {
match *substr.fields { match *substr.fields {
StaticStruct(vdata, ..) => { StaticStruct(vdata, ..) => {

View File

@ -1,9 +1,9 @@
use rustc_ast::{self as ast, MetaItem}; use rustc_ast::{self as ast, MetaItem};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::sym;
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;
use crate::deriving::generic::*; use crate::deriving::generic::*;
@ -66,13 +66,10 @@ fn cs_total_eq_assert(
// Already produced an assertion for this type. // Already produced an assertion for this type.
} else { } else {
// let _: AssertParamIsEq<FieldTy>; // let _: AssertParamIsEq<FieldTy>;
super::assert_ty_bounds( super::assert_ty_bounds(cx, &mut stmts, field.ty.clone(), field.span, &[
cx, sym::cmp,
&mut stmts, sym::AssertParamIsEq,
field.ty.clone(), ]);
field.span,
&[sym::cmp, sym::AssertParamIsEq],
);
} }
} }
}; };

View File

@ -1,7 +1,7 @@
use rustc_ast::MetaItem; use rustc_ast::MetaItem;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, sym};
use thin_vec::thin_vec; use thin_vec::thin_vec;
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;

View File

@ -1,8 +1,8 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, MetaItem, Mutability}; use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::sym;
use thin_vec::thin_vec; use thin_vec::thin_vec;
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;

View File

@ -1,7 +1,7 @@
use rustc_ast::{ExprKind, ItemKind, MetaItem, PatKind}; use rustc_ast::{ExprKind, ItemKind, MetaItem, PatKind};
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, sym};
use thin_vec::thin_vec; use thin_vec::thin_vec;
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;

View File

@ -1,9 +1,9 @@
use rustc_ast::{self as ast, EnumDef, MetaItem}; use rustc_ast::{self as ast, EnumDef, MetaItem};
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_session::config::FmtDebug; use rustc_session::config::FmtDebug;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;
use crate::deriving::generic::*; use crate::deriving::generic::*;

View File

@ -3,9 +3,9 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::{self as ast, Expr, MetaItem, Mutability}; use rustc_ast::{self as ast, Expr, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;
use crate::deriving::generic::*; use crate::deriving::generic::*;
@ -32,10 +32,11 @@ pub(crate) fn expand_deriving_rustc_decodable(
methods: vec![MethodDef { methods: vec![MethodDef {
name: sym::decode, name: sym::decode,
generics: Bounds { generics: Bounds {
bounds: vec![( bounds: vec![(typaram, vec![Path::new_(
typaram, vec![krate, sym::Decoder],
vec![Path::new_(vec![krate, sym::Decoder], vec![], PathKind::Global)], vec![],
)], PathKind::Global,
)])],
}, },
explicit_self: false, explicit_self: false,
nonself_args: vec![( nonself_args: vec![(
@ -94,32 +95,24 @@ fn decodable_substructure(
decode_static_fields(cx, trait_span, path, summary, |cx, span, name, field| { decode_static_fields(cx, trait_span, path, summary, |cx, span, name, field| {
cx.expr_try( cx.expr_try(
span, span,
cx.expr_call_global( cx.expr_call_global(span, fn_read_struct_field_path.clone(), thin_vec![
span,
fn_read_struct_field_path.clone(),
thin_vec![
blkdecoder.clone(), blkdecoder.clone(),
cx.expr_str(span, name), cx.expr_str(span, name),
cx.expr_usize(span, field), cx.expr_usize(span, field),
exprdecode.clone(), exprdecode.clone(),
], ]),
),
) )
}); });
let result = cx.expr_ok(trait_span, result); let result = cx.expr_ok(trait_span, result);
let fn_read_struct_path: Vec<_> = let fn_read_struct_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_struct]); cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_struct]);
cx.expr_call_global( cx.expr_call_global(trait_span, fn_read_struct_path, thin_vec![
trait_span,
fn_read_struct_path,
thin_vec![
decoder, decoder,
cx.expr_str(trait_span, substr.type_ident.name), cx.expr_str(trait_span, substr.type_ident.name),
cx.expr_usize(trait_span, nfields), cx.expr_usize(trait_span, nfields),
cx.lambda1(trait_span, result, blkarg), cx.lambda1(trait_span, result, blkarg),
], ])
)
} }
StaticEnum(_, fields) => { StaticEnum(_, fields) => {
let variant = Ident::new(sym::i, trait_span); let variant = Ident::new(sym::i, trait_span);
@ -160,23 +153,19 @@ fn decodable_substructure(
let variant_array_ref = cx.expr_array_ref(trait_span, variants); let variant_array_ref = cx.expr_array_ref(trait_span, variants);
let fn_read_enum_variant_path: Vec<_> = let fn_read_enum_variant_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum_variant]); cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum_variant]);
let result = cx.expr_call_global( let result = cx.expr_call_global(trait_span, fn_read_enum_variant_path, thin_vec![
trait_span, blkdecoder,
fn_read_enum_variant_path, variant_array_ref,
thin_vec![blkdecoder, variant_array_ref, lambda], lambda
); ]);
let fn_read_enum_path: Vec<_> = let fn_read_enum_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum]); cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum]);
cx.expr_call_global( cx.expr_call_global(trait_span, fn_read_enum_path, thin_vec![
trait_span,
fn_read_enum_path,
thin_vec![
decoder, decoder,
cx.expr_str(trait_span, substr.type_ident.name), cx.expr_str(trait_span, substr.type_ident.name),
cx.lambda1(trait_span, result, blkarg), cx.lambda1(trait_span, result, blkarg),
], ])
)
} }
_ => cx.dcx().bug("expected StaticEnum or StaticStruct in derive(Decodable)"), _ => cx.dcx().bug("expected StaticEnum or StaticStruct in derive(Decodable)"),
}; };

View File

@ -2,12 +2,12 @@
use rustc_ast as ast; use rustc_ast as ast;
use rustc_ast::visit::visit_opt; use rustc_ast::visit::visit_opt;
use rustc_ast::{attr, EnumDef, VariantData}; use rustc_ast::{EnumDef, VariantData, attr};
use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt}; use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{ErrorGuaranteed, Span}; use rustc_span::{ErrorGuaranteed, Span};
use smallvec::SmallVec; use smallvec::SmallVec;
use thin_vec::{thin_vec, ThinVec}; use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;
use crate::deriving::generic::*; use crate::deriving::generic::*;
@ -93,10 +93,10 @@ fn default_enum_substructure(
} { } {
Ok(default_variant) => { Ok(default_variant) => {
// We now know there is exactly one unit variant with exactly one `#[default]` attribute. // We now know there is exactly one unit variant with exactly one `#[default]` attribute.
cx.expr_path(cx.path( cx.expr_path(cx.path(default_variant.span, vec![
default_variant.span, Ident::new(kw::SelfUpper, default_variant.span),
vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident], default_variant.ident,
)) ]))
} }
Err(guar) => DummyResult::raw_expr(trait_span, Some(guar)), Err(guar) => DummyResult::raw_expr(trait_span, Some(guar)),
}; };

View File

@ -87,9 +87,9 @@
use rustc_ast::{AttrVec, ExprKind, MetaItem, Mutability}; use rustc_ast::{AttrVec, ExprKind, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;
use crate::deriving::generic::*; use crate::deriving::generic::*;
@ -116,10 +116,11 @@ pub(crate) fn expand_deriving_rustc_encodable(
methods: vec![MethodDef { methods: vec![MethodDef {
name: sym::encode, name: sym::encode,
generics: Bounds { generics: Bounds {
bounds: vec![( bounds: vec![(typaram, vec![Path::new_(
typaram, vec![krate, sym::Encoder],
vec![Path::new_(vec![krate, sym::Encoder], vec![], PathKind::Global)], vec![],
)], PathKind::Global,
)])],
}, },
explicit_self: true, explicit_self: true,
nonself_args: vec![( nonself_args: vec![(
@ -157,14 +158,11 @@ fn encodable_substructure(
// throw an underscore in front to suppress unused variable warnings // throw an underscore in front to suppress unused variable warnings
let blkarg = Ident::new(sym::_e, trait_span); let blkarg = Ident::new(sym::_e, trait_span);
let blkencoder = cx.expr_ident(trait_span, blkarg); let blkencoder = cx.expr_ident(trait_span, blkarg);
let fn_path = cx.expr_path(cx.path_global( let fn_path = cx.expr_path(cx.path_global(trait_span, vec![
trait_span,
vec![
Ident::new(krate, trait_span), Ident::new(krate, trait_span),
Ident::new(sym::Encodable, trait_span), Ident::new(sym::Encodable, trait_span),
Ident::new(sym::encode, trait_span), Ident::new(sym::encode, trait_span),
], ]));
));
match substr.fields { match substr.fields {
Struct(_, fields) => { Struct(_, fields) => {
@ -180,16 +178,12 @@ fn encodable_substructure(
let enc = let enc =
cx.expr_call(span, fn_path.clone(), thin_vec![self_ref, blkencoder.clone()]); cx.expr_call(span, fn_path.clone(), thin_vec![self_ref, blkencoder.clone()]);
let lambda = cx.lambda1(span, enc, blkarg); let lambda = cx.lambda1(span, enc, blkarg);
let call = cx.expr_call_global( let call = cx.expr_call_global(span, fn_emit_struct_field_path.clone(), thin_vec![
span,
fn_emit_struct_field_path.clone(),
thin_vec![
blkencoder.clone(), blkencoder.clone(),
cx.expr_str(span, name), cx.expr_str(span, name),
cx.expr_usize(span, i), cx.expr_usize(span, i),
lambda, lambda,
], ]);
);
// last call doesn't need a try! // last call doesn't need a try!
let last = fields.len() - 1; let last = fields.len() - 1;
@ -214,16 +208,12 @@ fn encodable_substructure(
let fn_emit_struct_path = let fn_emit_struct_path =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_struct]); cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_struct]);
let expr = cx.expr_call_global( let expr = cx.expr_call_global(trait_span, fn_emit_struct_path, thin_vec![
trait_span,
fn_emit_struct_path,
thin_vec![
encoder, encoder,
cx.expr_str(trait_span, substr.type_ident.name), cx.expr_str(trait_span, substr.type_ident.name),
cx.expr_usize(trait_span, fields.len()), cx.expr_usize(trait_span, fields.len()),
blk, blk,
], ]);
);
BlockOrExpr::new_expr(expr) BlockOrExpr::new_expr(expr)
} }
@ -243,11 +233,8 @@ fn encodable_substructure(
let last = fields.len() - 1; let last = fields.len() - 1;
for (i, &FieldInfo { ref self_expr, span, .. }) in fields.iter().enumerate() { for (i, &FieldInfo { ref self_expr, span, .. }) in fields.iter().enumerate() {
let self_ref = cx.expr_addr_of(span, self_expr.clone()); let self_ref = cx.expr_addr_of(span, self_expr.clone());
let enc = cx.expr_call( let enc = cx
span, .expr_call(span, fn_path.clone(), thin_vec![self_ref, blkencoder.clone()]);
fn_path.clone(),
thin_vec![self_ref, blkencoder.clone()],
);
let lambda = cx.lambda1(span, enc, blkarg); let lambda = cx.lambda1(span, enc, blkarg);
let call = cx.expr_call_global( let call = cx.expr_call_global(
@ -274,26 +261,22 @@ fn encodable_substructure(
let fn_emit_enum_variant_path: Vec<_> = let fn_emit_enum_variant_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum_variant]); cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum_variant]);
let call = cx.expr_call_global( let call = cx.expr_call_global(trait_span, fn_emit_enum_variant_path, thin_vec![
trait_span,
fn_emit_enum_variant_path,
thin_vec![
blkencoder, blkencoder,
name, name,
cx.expr_usize(trait_span, *idx), cx.expr_usize(trait_span, *idx),
cx.expr_usize(trait_span, fields.len()), cx.expr_usize(trait_span, fields.len()),
blk, blk,
], ]);
);
let blk = cx.lambda1(trait_span, call, blkarg); let blk = cx.lambda1(trait_span, call, blkarg);
let fn_emit_enum_path: Vec<_> = let fn_emit_enum_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum]); cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum]);
let expr = cx.expr_call_global( let expr = cx.expr_call_global(trait_span, fn_emit_enum_path, thin_vec![
trait_span, encoder,
fn_emit_enum_path, cx.expr_str(trait_span, substr.type_ident.name),
thin_vec![encoder, cx.expr_str(trait_span, substr.type_ident.name), blk], blk
); ]);
BlockOrExpr::new_mixed(thin_vec![me], Some(expr)) BlockOrExpr::new_mixed(thin_vec![me], Some(expr))
} }

View File

@ -178,6 +178,8 @@
use std::ops::Not; use std::ops::Not;
use std::{iter, vec}; use std::{iter, vec};
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::{ use rustc_ast::{
self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics, self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics,
@ -185,12 +187,10 @@
}; };
use rustc_attr as attr; use rustc_attr as attr;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span};
use thin_vec::{thin_vec, ThinVec}; use thin_vec::{ThinVec, thin_vec};
use ty::{Bounds, Path, Ref, Self_, Ty}; use ty::{Bounds, Path, Ref, Self_, Ty};
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;
use crate::{deriving, errors}; use crate::{deriving, errors};
@ -1228,12 +1228,10 @@ fn expand_enum_method_body<'b>(
let discr_let_stmts: ThinVec<_> = iter::zip(&discr_idents, &selflike_args) let discr_let_stmts: ThinVec<_> = iter::zip(&discr_idents, &selflike_args)
.map(|(&ident, selflike_arg)| { .map(|(&ident, selflike_arg)| {
let variant_value = deriving::call_intrinsic( let variant_value =
cx, deriving::call_intrinsic(cx, span, sym::discriminant_value, thin_vec![
span, selflike_arg.clone()
sym::discriminant_value, ]);
thin_vec![selflike_arg.clone()],
);
cx.stmt_let(span, false, ident, variant_value) cx.stmt_let(span, false, ident, variant_value)
}) })
.collect(); .collect();

View File

@ -1,14 +1,14 @@
//! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use //! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use
//! when specifying impls to be derived. //! when specifying impls to be derived.
pub(crate) use Ty::*;
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind}; use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
use rustc_expand::base::ExtCtxt; use rustc_expand::base::ExtCtxt;
use rustc_span::source_map::respan; use rustc_span::source_map::respan;
use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::symbol::{Ident, Symbol, kw};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{DUMMY_SP, Span};
use thin_vec::ThinVec; use thin_vec::ThinVec;
pub(crate) use Ty::*;
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support /// A path, e.g., `::std::option::Option::<i32>` (global). Has support
/// for type parameters. /// for type parameters.

View File

@ -1,7 +1,7 @@
use rustc_ast::{MetaItem, Mutability}; use rustc_ast::{MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::sym;
use thin_vec::thin_vec; use thin_vec::thin_vec;
use crate::deriving::generic::ty::*; use crate::deriving::generic::ty::*;

View File

@ -4,9 +4,9 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::{GenericArg, MetaItem}; use rustc_ast::{GenericArg, MetaItem};
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier}; use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
macro path_local($x:ident) { macro path_local($x:ident) {
generic::ty::Path::new_local(sym::$x) generic::ty::Path::new_local(sym::$x)

View File

@ -1,5 +1,5 @@
use ast::ptr::P;
use ast::HasAttrs; use ast::HasAttrs;
use ast::ptr::P;
use rustc_ast::mut_visit::MutVisitor; use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::visit::BoundKind; use rustc_ast::visit::BoundKind;
use rustc_ast::{ use rustc_ast::{
@ -9,9 +9,9 @@
use rustc_attr as attr; use rustc_attr as attr;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{Ident, sym};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use thin_vec::{thin_vec, ThinVec}; use thin_vec::{ThinVec, thin_vec};
macro_rules! path { macro_rules! path {
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] } ($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }

View File

@ -3,9 +3,9 @@
use rustc_ast::tokenstream::{DelimSpan, TokenStream}; use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::*; use rustc_ast::*;
use rustc_expand::base::*; use rustc_expand::base::*;
use rustc_span::Span;
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use rustc_span::Span;
/// This expands to either /// This expands to either
/// - `$crate::panic::panic_2015!(...)` or /// - `$crate::panic::panic_2015!(...)` or

View File

@ -10,8 +10,8 @@
use rustc_ast::tokenstream::TokenStream; use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability}; use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use thin_vec::thin_vec; use thin_vec::thin_vec;
use crate::errors; use crate::errors;
@ -58,11 +58,11 @@ pub(crate) fn expand_option_env<'cx>(
))], ))],
)) ))
} }
Some(value) => cx.expr_call_global( Some(value) => {
sp, cx.expr_call_global(sp, cx.std_path(&[sym::option, sym::Option, sym::Some]), thin_vec![
cx.std_path(&[sym::option, sym::Option, sym::Some]), cx.expr_str(sp, value)
thin_vec![cx.expr_str(sp, value)], ])
), }
}; };
ExpandResult::Ready(MacEager::expr(e)) ExpandResult::Ready(MacEager::expr(e))
} }

View File

@ -2,9 +2,10 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream; use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{ use rustc_ast::{
token, Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs, Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount, FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount,
FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered, StmtKind, FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered, StmtKind,
token,
}; };
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans}; use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans};

View File

@ -183,14 +183,10 @@ pub(crate) fn translate(&self) -> Result<String, Option<String>> {
s.push('{'); s.push('{');
if let Some(arg) = self.parameter { if let Some(arg) = self.parameter {
match write!( match write!(s, "{}", match arg.checked_sub(1) {
s,
"{}",
match arg.checked_sub(1) {
Some(a) => a, Some(a) => a,
None => return Err(None), None => return Err(None),
} }) {
) {
Err(_) => return Err(None), Err(_) => return Err(None),
_ => {} _ => {}
} }

View File

@ -1,4 +1,4 @@
use super::{iter_subs, parse_next_substitution as pns, Format as F, Num as N, Substitution as S}; use super::{Format as F, Num as N, Substitution as S, iter_subs, parse_next_substitution as pns};
macro_rules! assert_eq_pnsat { macro_rules! assert_eq_pnsat {
($lhs:expr, $rhs:expr) => { ($lhs:expr, $rhs:expr) => {
@ -99,10 +99,12 @@ macro_rules! assert_pns_eq_sub {
fn test_iter() { fn test_iter() {
let s = "The %d'th word %% is: `%.*s` %!\n"; let s = "The %d'th word %% is: `%.*s` %!\n";
let subs: Vec<_> = iter_subs(s, 0).map(|sub| sub.translate().ok()).collect(); let subs: Vec<_> = iter_subs(s, 0).map(|sub| sub.translate().ok()).collect();
assert_eq!( assert_eq!(subs.iter().map(Option::as_deref).collect::<Vec<_>>(), vec![
subs.iter().map(Option::as_deref).collect::<Vec<_>>(), Some("{}"),
vec![Some("{}"), None, Some("{:.*}"), None] None,
); Some("{:.*}"),
None
]);
} }
/// Checks that the translations are what we expect. /// Checks that the translations are what we expect.

View File

@ -1,4 +1,4 @@
use super::{parse_next_substitution as pns, Substitution as S}; use super::{Substitution as S, parse_next_substitution as pns};
macro_rules! assert_eq_pnsat { macro_rules! assert_eq_pnsat {
($lhs:expr, $rhs:expr) => { ($lhs:expr, $rhs:expr) => {
@ -38,10 +38,11 @@ fn test_iter() {
use super::iter_subs; use super::iter_subs;
let s = "The $0'th word $$ is: `$WORD` $!\n"; let s = "The $0'th word $$ is: `$WORD` $!\n";
let subs: Vec<_> = iter_subs(s, 0).map(|sub| sub.translate().ok()).collect(); let subs: Vec<_> = iter_subs(s, 0).map(|sub| sub.translate().ok()).collect();
assert_eq!( assert_eq!(subs.iter().map(Option::as_deref).collect::<Vec<_>>(), vec![
subs.iter().map(Option::as_deref).collect::<Vec<_>>(), Some("{0}"),
vec![Some("{0}"), None, Some("{WORD}")] None,
); Some("{WORD}")
]);
} }
#[test] #[test]

View File

@ -1,5 +1,5 @@
use rustc_ast::expand::allocator::{ use rustc_ast::expand::allocator::{
global_fn_name, AllocatorMethod, AllocatorMethodInput, AllocatorTy, ALLOCATOR_METHODS, ALLOCATOR_METHODS, AllocatorMethod, AllocatorMethodInput, AllocatorTy, global_fn_name,
}; };
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::{ use rustc_ast::{
@ -7,9 +7,9 @@
Stmt, StmtKind, Ty, TyKind, Stmt, StmtKind, Ty, TyKind,
}; };
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec}; use rustc_span::symbol::{Ident, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::errors; use crate::errors;
use crate::util::check_builtin_macro_attribute; use crate::util::check_builtin_macro_attribute;

View File

@ -1,9 +1,9 @@
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream; use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{ast, Pat, Ty}; use rustc_ast::{Pat, Ty, ast};
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_span::{sym, Span}; use rustc_span::{Span, sym};
pub(crate) fn expand<'cx>( pub(crate) fn expand<'cx>(
cx: &'cx mut ExtCtxt<'_>, cx: &'cx mut ExtCtxt<'_>,

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