mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #118294 - GuillaumeGomez:rollup-ij2bzwt, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #116446 (Yeet `mir::Const::from_anon_const`) - #117871 (remove unused pub fns) - #118017 (rustc_lint: address latent TODO) - #118199 (Remove `HirId` from `QPath::LangItem`) - #118272 (resolve: Avoid clones of `MacroData`) - #118291 (rustdoc-search: clean up some DOM code) Failed merges: - #118201 (Miscellaneous `ObligationCauseCode` cleanups) - #118256 (rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` cleanup) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ec1393f14e
@ -560,7 +560,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
expr: &'hir hir::Expr<'hir>,
|
||||
overall_span: Span,
|
||||
) -> &'hir hir::Expr<'hir> {
|
||||
let constructor = self.arena.alloc(self.expr_lang_item_path(method_span, lang_item, None));
|
||||
let constructor = self.arena.alloc(self.expr_lang_item_path(method_span, lang_item));
|
||||
self.expr_call(overall_span, constructor, std::slice::from_ref(expr))
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
// Resume argument type: `ResumeTy`
|
||||
let unstable_span =
|
||||
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
|
||||
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span, None);
|
||||
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span);
|
||||
let input_ty = hir::Ty {
|
||||
hir_id: self.next_id(),
|
||||
kind: hir::TyKind::Path(resume_ty),
|
||||
@ -818,19 +818,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span,
|
||||
hir::LangItem::PinNewUnchecked,
|
||||
arena_vec![self; ref_mut_awaitee],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let get_context = self.expr_call_lang_item_fn_mut(
|
||||
gen_future_span,
|
||||
hir::LangItem::GetContext,
|
||||
arena_vec![self; task_context],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let call = self.expr_call_lang_item_fn(
|
||||
span,
|
||||
hir::LangItem::FuturePoll,
|
||||
arena_vec![self; new_unchecked, get_context],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
self.arena.alloc(self.expr_unsafe(call))
|
||||
};
|
||||
@ -843,12 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident);
|
||||
let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid);
|
||||
let ready_field = self.single_pat_field(gen_future_span, x_pat);
|
||||
let ready_pat = self.pat_lang_item_variant(
|
||||
span,
|
||||
hir::LangItem::PollReady,
|
||||
ready_field,
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let ready_pat = self.pat_lang_item_variant(span, hir::LangItem::PollReady, ready_field);
|
||||
let break_x = self.with_loop_scope(loop_node_id, move |this| {
|
||||
let expr_break =
|
||||
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
|
||||
@ -859,12 +851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|
||||
// `::std::task::Poll::Pending => {}`
|
||||
let pending_arm = {
|
||||
let pending_pat = self.pat_lang_item_variant(
|
||||
span,
|
||||
hir::LangItem::PollPending,
|
||||
&[],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let pending_pat = self.pat_lang_item_variant(span, hir::LangItem::PollPending, &[]);
|
||||
let empty_block = self.expr_block_empty(span);
|
||||
self.arm(pending_pat, empty_block)
|
||||
};
|
||||
@ -922,7 +909,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span,
|
||||
hir::LangItem::IntoFutureIntoFuture,
|
||||
arena_vec![self; expr],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
|
||||
// match <into_future_expr> {
|
||||
@ -1379,8 +1365,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
|
||||
let e1 = self.lower_expr_mut(e1);
|
||||
let e2 = self.lower_expr_mut(e2);
|
||||
let fn_path =
|
||||
hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span), None);
|
||||
let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span));
|
||||
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
|
||||
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
|
||||
}
|
||||
@ -1421,7 +1406,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
);
|
||||
|
||||
hir::ExprKind::Struct(
|
||||
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span), None)),
|
||||
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span))),
|
||||
fields,
|
||||
None,
|
||||
)
|
||||
@ -1590,7 +1575,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
head_span,
|
||||
hir::LangItem::IteratorNext,
|
||||
arena_vec![self; ref_mut_iter],
|
||||
None,
|
||||
);
|
||||
let arms = arena_vec![self; none_arm, some_arm];
|
||||
|
||||
@ -1619,7 +1603,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
head_span,
|
||||
hir::LangItem::IntoIterIntoIter,
|
||||
arena_vec![self; head],
|
||||
None,
|
||||
)
|
||||
};
|
||||
|
||||
@ -1675,7 +1658,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
unstable_span,
|
||||
hir::LangItem::TryTraitBranch,
|
||||
arena_vec![self; sub_expr],
|
||||
None,
|
||||
)
|
||||
};
|
||||
|
||||
@ -1880,9 +1862,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
args: &'hir [hir::Expr<'hir>],
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> hir::Expr<'hir> {
|
||||
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item, hir_id));
|
||||
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item));
|
||||
self.expr_call_mut(span, path, args)
|
||||
}
|
||||
|
||||
@ -1891,21 +1872,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
args: &'hir [hir::Expr<'hir>],
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> &'hir hir::Expr<'hir> {
|
||||
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args, hir_id))
|
||||
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args))
|
||||
}
|
||||
|
||||
fn expr_lang_item_path(
|
||||
&mut self,
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> hir::Expr<'hir> {
|
||||
self.expr(
|
||||
span,
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id)),
|
||||
)
|
||||
fn expr_lang_item_path(&mut self, span: Span, lang_item: hir::LangItem) -> hir::Expr<'hir> {
|
||||
self.expr(span, hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))))
|
||||
}
|
||||
|
||||
/// `<LangItem>::name`
|
||||
@ -1918,7 +1890,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let path = hir::ExprKind::Path(hir::QPath::TypeRelative(
|
||||
self.arena.alloc(self.ty(
|
||||
span,
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), None)),
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))),
|
||||
)),
|
||||
self.arena.alloc(hir::PathSegment::new(
|
||||
Ident::new(name, span),
|
||||
|
@ -2304,21 +2304,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
|
||||
fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
|
||||
let field = self.single_pat_field(span, pat);
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field, None)
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field)
|
||||
}
|
||||
|
||||
fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
|
||||
let field = self.single_pat_field(span, pat);
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field, None)
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field)
|
||||
}
|
||||
|
||||
fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
|
||||
let field = self.single_pat_field(span, pat);
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field, None)
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field)
|
||||
}
|
||||
|
||||
fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[], None)
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[])
|
||||
}
|
||||
|
||||
fn single_pat_field(
|
||||
@ -2341,9 +2341,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
fields: &'hir [hir::PatField<'hir>],
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> &'hir hir::Pat<'hir> {
|
||||
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id);
|
||||
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span));
|
||||
self.pat(span, hir::PatKind::Struct(qpath, fields, false))
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&& let hir::ExprKind::Path(hir::QPath::LangItem(
|
||||
LangItem::IntoIterIntoIter,
|
||||
_,
|
||||
_,
|
||||
)) = call_expr.kind
|
||||
{
|
||||
// Do not suggest `.clone()` in a `for` loop, we already suggest borrowing.
|
||||
@ -1346,11 +1345,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
// };
|
||||
// corresponding to the desugaring of a for loop `for <pat> in <head> { <body> }`.
|
||||
if let hir::ExprKind::Call(path, [arg]) = ex.kind
|
||||
&& let hir::ExprKind::Path(hir::QPath::LangItem(
|
||||
LangItem::IntoIterIntoIter,
|
||||
_,
|
||||
_,
|
||||
)) = path.kind
|
||||
&& let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IntoIterIntoIter, _)) =
|
||||
path.kind
|
||||
&& arg.span.contains(self.issue_span)
|
||||
{
|
||||
// Find `IntoIterator::into_iter(<head>)`
|
||||
@ -1368,10 +1364,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
..
|
||||
}) = stmt.kind
|
||||
&& let hir::ExprKind::Call(path, _args) = call.kind
|
||||
&& let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IteratorNext, _, _)) =
|
||||
&& let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IteratorNext, _)) =
|
||||
path.kind
|
||||
&& let hir::PatKind::Struct(path, [field, ..], _) = bind.pat.kind
|
||||
&& let hir::QPath::LangItem(LangItem::OptionSome, pat_span, _) = path
|
||||
&& let hir::QPath::LangItem(LangItem::OptionSome, pat_span) = path
|
||||
&& call.span.contains(self.issue_span)
|
||||
{
|
||||
// Find `<pat>` and the span for the whole `for` loop.
|
||||
|
@ -891,7 +891,6 @@ extern "C" {
|
||||
pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
|
||||
pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
|
||||
pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
|
||||
pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
|
||||
|
||||
// Operations on constants of any type
|
||||
pub fn LLVMConstNull(Ty: &Type) -> &Value;
|
||||
@ -955,7 +954,6 @@ extern "C" {
|
||||
pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
|
||||
|
||||
// Operations on global variables, functions, and aliases (globals)
|
||||
@ -2346,11 +2344,6 @@ extern "C" {
|
||||
len: usize,
|
||||
Identifier: *const c_char,
|
||||
) -> Option<&Module>;
|
||||
pub fn LLVMRustGetBitcodeSliceFromObjectData(
|
||||
Data: *const u8,
|
||||
len: usize,
|
||||
out_len: &mut usize,
|
||||
) -> *const u8;
|
||||
pub fn LLVMRustGetSliceFromObjectDataByName(
|
||||
data: *const u8,
|
||||
len: usize,
|
||||
|
@ -227,10 +227,6 @@ impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
}
|
||||
|
||||
impl Type {
|
||||
pub fn i8_llcx(llcx: &llvm::Context) -> &Type {
|
||||
unsafe { llvm::LLVMInt8TypeInContext(llcx) }
|
||||
}
|
||||
|
||||
/// Creates an integer type with the given number of bits, e.g., i24
|
||||
pub fn ix_llcx(llcx: &llvm::Context, num_bits: u64) -> &Type {
|
||||
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }
|
||||
|
@ -256,13 +256,13 @@ where
|
||||
}
|
||||
|
||||
/// Iterates over all fields of an array. Much more efficient than doing the
|
||||
/// same by repeatedly calling `operand_index`.
|
||||
/// same by repeatedly calling `project_index`.
|
||||
pub fn project_array_fields<'a, P: Projectable<'tcx, M::Provenance>>(
|
||||
&self,
|
||||
base: &'a P,
|
||||
) -> InterpResult<'tcx, ArrayIterator<'tcx, 'a, M::Provenance, P>> {
|
||||
let abi::FieldsShape::Array { stride, .. } = base.layout().fields else {
|
||||
span_bug!(self.cur_span(), "operand_array_fields: expected an array layout");
|
||||
span_bug!(self.cur_span(), "project_array_fields: expected an array layout");
|
||||
};
|
||||
let len = base.len(self)?;
|
||||
let field_layout = base.layout().field(self, 0);
|
||||
|
@ -1023,36 +1023,3 @@ pub fn promote_candidates<'tcx>(
|
||||
|
||||
promotions
|
||||
}
|
||||
|
||||
/// This function returns `true` if the function being called in the array
|
||||
/// repeat expression is a `const` function.
|
||||
pub fn is_const_fn_in_array_repeat_expression<'tcx>(
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
place: &Place<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
) -> bool {
|
||||
match place.as_local() {
|
||||
// rule out cases such as: `let my_var = some_fn(); [my_var; N]`
|
||||
Some(local) if body.local_decls[local].is_user_variable() => return false,
|
||||
None => return false,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
for block in body.basic_blocks.iter() {
|
||||
if let Some(Terminator { kind: TerminatorKind::Call { func, destination, .. }, .. }) =
|
||||
&block.terminator
|
||||
{
|
||||
if let Operand::Constant(box ConstOperand { const_, .. }) = func {
|
||||
if let ty::FnDef(def_id, _) = *const_.ty().kind() {
|
||||
if destination == place {
|
||||
if ccx.tcx.is_const_fn(def_id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
@ -522,33 +522,6 @@ impl<'a> LabelText<'a> {
|
||||
HtmlStr(ref s) => format!("<{s}>"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Decomposes content into string suitable for making EscStr that
|
||||
/// yields same content as self. The result obeys the law
|
||||
/// render(`lt`) == render(`EscStr(lt.pre_escaped_content())`) for
|
||||
/// all `lt: LabelText`.
|
||||
fn pre_escaped_content(self) -> Cow<'a, str> {
|
||||
match self {
|
||||
EscStr(s) => s,
|
||||
LabelStr(s) => {
|
||||
if s.contains('\\') {
|
||||
s.escape_default().to_string().into()
|
||||
} else {
|
||||
s
|
||||
}
|
||||
}
|
||||
HtmlStr(s) => s,
|
||||
}
|
||||
}
|
||||
|
||||
/// Puts `suffix` on a line below this label, with a blank line separator.
|
||||
pub fn suffix_line(self, suffix: LabelText<'_>) -> LabelText<'static> {
|
||||
let mut prefix = self.pre_escaped_content().into_owned();
|
||||
let suffix = suffix.pre_escaped_content();
|
||||
prefix.push_str(r"\n\n");
|
||||
prefix.push_str(&suffix);
|
||||
EscStr(prefix.into())
|
||||
}
|
||||
}
|
||||
|
||||
pub type Nodes<'a, N> = Cow<'a, [N]>;
|
||||
|
@ -2058,8 +2058,8 @@ pub enum QPath<'hir> {
|
||||
/// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
|
||||
TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
|
||||
|
||||
/// Reference to a `#[lang = "foo"]` item. `HirId` of the inner expr.
|
||||
LangItem(LangItem, Span, Option<HirId>),
|
||||
/// Reference to a `#[lang = "foo"]` item.
|
||||
LangItem(LangItem, Span),
|
||||
}
|
||||
|
||||
impl<'hir> QPath<'hir> {
|
||||
@ -2068,7 +2068,7 @@ impl<'hir> QPath<'hir> {
|
||||
match *self {
|
||||
QPath::Resolved(_, path) => path.span,
|
||||
QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
|
||||
QPath::LangItem(_, span, _) => span,
|
||||
QPath::LangItem(_, span) => span,
|
||||
}
|
||||
}
|
||||
|
||||
@ -2078,7 +2078,7 @@ impl<'hir> QPath<'hir> {
|
||||
match *self {
|
||||
QPath::Resolved(_, path) => path.span,
|
||||
QPath::TypeRelative(qself, _) => qself.span,
|
||||
QPath::LangItem(_, span, _) => span,
|
||||
QPath::LangItem(_, span) => span,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2546,7 +2546,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
.map(|(ty, _, _)| ty)
|
||||
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
|
||||
}
|
||||
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => {
|
||||
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span)) => {
|
||||
let def_id = tcx.require_lang_item(lang_item, Some(span));
|
||||
let (args, _) = self.create_args_for_ast_path(
|
||||
span,
|
||||
|
@ -1623,7 +1623,7 @@ impl<'a> State<'a> {
|
||||
self.print_ident(item_segment.ident);
|
||||
self.print_generic_args(item_segment.args(), colons_before_params)
|
||||
}
|
||||
hir::QPath::LangItem(lang_item, span, _) => {
|
||||
hir::QPath::LangItem(lang_item, span) => {
|
||||
self.word("#[lang = \"");
|
||||
self.print_ident(Ident::new(lang_item.name(), span));
|
||||
self.word("\"]");
|
||||
|
@ -289,8 +289,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ExprKind::AddrOf(kind, mutbl, oprnd) => {
|
||||
self.check_expr_addr_of(kind, mutbl, oprnd, expected, expr)
|
||||
}
|
||||
ExprKind::Path(QPath::LangItem(lang_item, _, hir_id)) => {
|
||||
self.check_lang_item_path(lang_item, expr, hir_id)
|
||||
ExprKind::Path(QPath::LangItem(lang_item, _)) => {
|
||||
self.check_lang_item_path(lang_item, expr)
|
||||
}
|
||||
ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr, &[]),
|
||||
ExprKind::InlineAsm(asm) => {
|
||||
@ -497,9 +497,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
lang_item: hir::LangItem,
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> Ty<'tcx> {
|
||||
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id, hir_id).1
|
||||
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id).1
|
||||
}
|
||||
|
||||
pub(crate) fn check_expr_path(
|
||||
|
@ -753,7 +753,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
lang_item: hir::LangItem,
|
||||
span: Span,
|
||||
hir_id: hir::HirId,
|
||||
expr_hir_id: Option<hir::HirId>,
|
||||
) -> (Res, Ty<'tcx>) {
|
||||
let def_id = self.tcx.require_lang_item(lang_item, Some(span));
|
||||
let def_kind = self.tcx.def_kind(def_id);
|
||||
@ -770,7 +769,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
let code = match lang_item {
|
||||
hir::LangItem::IntoFutureIntoFuture => {
|
||||
Some(ObligationCauseCode::AwaitableExpr(expr_hir_id))
|
||||
if let hir::Node::Expr(into_future_call) = self.tcx.hir().get_parent(hir_id)
|
||||
&& let hir::ExprKind::Call(_, [arg0]) = &into_future_call.kind
|
||||
{
|
||||
Some(ObligationCauseCode::AwaitableExpr(arg0.hir_id))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => {
|
||||
Some(ObligationCauseCode::ForLoopIterator)
|
||||
|
@ -1842,8 +1842,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
(result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)), ty)
|
||||
}
|
||||
QPath::LangItem(lang_item, span, id) => {
|
||||
let (res, ty) = self.resolve_lang_item_path(lang_item, span, hir_id, id);
|
||||
QPath::LangItem(lang_item, span) => {
|
||||
let (res, ty) = self.resolve_lang_item_path(lang_item, span, hir_id);
|
||||
(res, self.handle_raw_ty(path_span, ty))
|
||||
}
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
return false;
|
||||
}
|
||||
let pin_did = self.tcx.lang_items().pin_type();
|
||||
// This guards the `unwrap` and `mk_box` below.
|
||||
// This guards the `new_box` below.
|
||||
if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() {
|
||||
return false;
|
||||
}
|
||||
|
@ -1087,7 +1087,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
||||
|
||||
Box::new(segment.into_iter())
|
||||
}
|
||||
hir::QPath::LangItem(_, _, _) => Box::new(iter::empty()),
|
||||
hir::QPath::LangItem(_, _) => Box::new(iter::empty()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::fold::BoundVarReplacerDelegate;
|
||||
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||
use rustc_middle::ty::relate::RelateResult;
|
||||
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
||||
use rustc_middle::ty::visit::TypeVisitableExt;
|
||||
pub use rustc_middle::ty::IntVarValue;
|
||||
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
|
||||
@ -1406,17 +1406,6 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
value.fold_with(&mut r)
|
||||
}
|
||||
|
||||
/// Returns the first unresolved type or const variable contained in `T`.
|
||||
pub fn first_unresolved_const_or_ty_var<T>(
|
||||
&self,
|
||||
value: &T,
|
||||
) -> Option<(ty::Term<'tcx>, Option<Span>)>
|
||||
where
|
||||
T: TypeVisitable<TyCtxt<'tcx>>,
|
||||
{
|
||||
value.visit_with(&mut resolve::UnresolvedTypeOrConstFinder::new(self)).break_value()
|
||||
}
|
||||
|
||||
pub fn probe_const_var(&self, vid: ty::ConstVid) -> Result<ty::Const<'tcx>, ty::UniverseIndex> {
|
||||
match self.inner.borrow_mut().const_unification_table().probe_value(vid).val {
|
||||
ConstVariableValue::Known { value } => Ok(value),
|
||||
|
@ -36,7 +36,7 @@ use rustc_middle::ty::{self, print::Printer, GenericArg, RegisteredTools, Ty, Ty
|
||||
use rustc_session::config::ExpectedValues;
|
||||
use rustc_session::lint::{BuiltinLintDiagnostics, LintExpectationId};
|
||||
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
|
||||
use rustc_session::Session;
|
||||
use rustc_session::{LintStoreMarker, Session};
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
@ -77,6 +77,8 @@ pub struct LintStore {
|
||||
lint_groups: FxHashMap<&'static str, LintGroup>,
|
||||
}
|
||||
|
||||
impl LintStoreMarker for LintStore {}
|
||||
|
||||
/// The target of the `by_name` map, which accounts for renaming/deprecation.
|
||||
#[derive(Debug)]
|
||||
enum TargetLint {
|
||||
|
@ -30,10 +30,10 @@ use rustc_span::Span;
|
||||
use std::any::Any;
|
||||
use std::cell::Cell;
|
||||
|
||||
/// Extract the `LintStore` from the query context.
|
||||
/// This function exists because we've erased `LintStore` as `dyn Any` in the session.
|
||||
/// Extract the [`LintStore`] from [`Session`].
|
||||
///
|
||||
/// This function exists because [`Session::lint_store`] is type-erased.
|
||||
pub fn unerased_lint_store(sess: &Session) -> &LintStore {
|
||||
assert!(sess.lint_store.is_some());
|
||||
let store: &Lrc<_> = sess.lint_store.as_ref().unwrap();
|
||||
let store: &dyn Any = &**store;
|
||||
store.downcast_ref().unwrap()
|
||||
|
@ -39,6 +39,7 @@
|
||||
#![feature(min_specialization)]
|
||||
#![feature(never_type)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![cfg_attr(bootstrap, feature(trait_upcasting))]
|
||||
#![recursion_limit = "256"]
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
|
@ -1562,32 +1562,6 @@ LLVMRustParseBitcodeForLTO(LLVMContextRef Context,
|
||||
return wrap(std::move(*SrcOrError).release());
|
||||
}
|
||||
|
||||
// Find the bitcode section in the object file data and return it as a slice.
|
||||
// Fail if the bitcode section is present but empty.
|
||||
//
|
||||
// On success, the return value is the pointer to the start of the slice and
|
||||
// `out_len` is filled with the (non-zero) length. On failure, the return value
|
||||
// is `nullptr` and `out_len` is set to zero.
|
||||
extern "C" const char*
|
||||
LLVMRustGetBitcodeSliceFromObjectData(const char *data,
|
||||
size_t len,
|
||||
size_t *out_len) {
|
||||
*out_len = 0;
|
||||
|
||||
StringRef Data(data, len);
|
||||
MemoryBufferRef Buffer(Data, ""); // The id is unused.
|
||||
|
||||
Expected<MemoryBufferRef> BitcodeOrError =
|
||||
object::IRObjectFile::findBitcodeInMemBuffer(Buffer);
|
||||
if (!BitcodeOrError) {
|
||||
LLVMRustSetLastError(toString(BitcodeOrError.takeError()).c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*out_len = BitcodeOrError->getBufferSize();
|
||||
return BitcodeOrError->getBufferStart();
|
||||
}
|
||||
|
||||
// Find a section of an object file by name. Fail if the section is missing or
|
||||
// empty.
|
||||
extern "C" const char *LLVMRustGetSliceFromObjectDataByName(const char *data,
|
||||
|
@ -1,17 +1,16 @@
|
||||
use std::fmt::{self, Debug, Display, Formatter};
|
||||
|
||||
use rustc_hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::{self as hir};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_session::RemapFileNameExt;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{HasDataLayout, Size};
|
||||
|
||||
use crate::mir::interpret::{alloc_range, AllocId, ConstAllocation, ErrorHandled, Scalar};
|
||||
use crate::mir::{pretty_print_const_value, Promoted};
|
||||
use crate::ty::GenericArgsRef;
|
||||
use crate::ty::ScalarInt;
|
||||
use crate::ty::{self, print::pretty_print_const, List, Ty, TyCtxt};
|
||||
use crate::ty::{GenericArgs, GenericArgsRef};
|
||||
use crate::ty::{self, print::pretty_print_const, Ty, TyCtxt};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/// Evaluated Constants
|
||||
@ -220,6 +219,17 @@ pub enum Const<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Const<'tcx> {
|
||||
pub fn identity_unevaluated(tcx: TyCtxt<'tcx>, def_id: DefId) -> ty::EarlyBinder<Const<'tcx>> {
|
||||
ty::EarlyBinder::bind(Const::Unevaluated(
|
||||
UnevaluatedConst {
|
||||
def: def_id,
|
||||
args: ty::GenericArgs::identity_for_item(tcx, def_id),
|
||||
promoted: None,
|
||||
},
|
||||
tcx.type_of(def_id).skip_binder(),
|
||||
))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn ty(&self) -> Ty<'tcx> {
|
||||
match self {
|
||||
@ -399,101 +409,6 @@ impl<'tcx> Const<'tcx> {
|
||||
Self::Val(val, ty)
|
||||
}
|
||||
|
||||
/// Literals are converted to `Const::Val`, const generic parameters are eagerly
|
||||
/// converted to a constant, everything else becomes `Unevaluated`.
|
||||
#[instrument(skip(tcx), level = "debug", ret)]
|
||||
pub fn from_anon_const(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def: LocalDefId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> Self {
|
||||
let body_id = match tcx.hir().get_by_def_id(def) {
|
||||
hir::Node::AnonConst(ac) => ac.body,
|
||||
_ => {
|
||||
span_bug!(tcx.def_span(def), "from_anon_const can only process anonymous constants")
|
||||
}
|
||||
};
|
||||
|
||||
let expr = &tcx.hir().body(body_id).value;
|
||||
debug!(?expr);
|
||||
|
||||
// Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
|
||||
// currently have to be wrapped in curly brackets, so it's necessary to special-case.
|
||||
let expr = match &expr.kind {
|
||||
hir::ExprKind::Block(block, _) if block.stmts.is_empty() && block.expr.is_some() => {
|
||||
block.expr.as_ref().unwrap()
|
||||
}
|
||||
_ => expr,
|
||||
};
|
||||
debug!("expr.kind: {:?}", expr.kind);
|
||||
|
||||
let ty = tcx.type_of(def).instantiate_identity();
|
||||
debug!(?ty);
|
||||
|
||||
// FIXME(const_generics): We currently have to special case parameters because `min_const_generics`
|
||||
// does not provide the parents generics to anonymous constants. We still allow generic const
|
||||
// parameters by themselves however, e.g. `N`. These constants would cause an ICE if we were to
|
||||
// ever try to substitute the generic parameters in their bodies.
|
||||
//
|
||||
// While this doesn't happen as these constants are always used as `ty::ConstKind::Param`, it does
|
||||
// cause issues if we were to remove that special-case and try to evaluate the constant instead.
|
||||
use hir::{def::DefKind::ConstParam, def::Res, ExprKind, Path, QPath};
|
||||
match expr.kind {
|
||||
ExprKind::Path(QPath::Resolved(_, &Path { res: Res::Def(ConstParam, def_id), .. })) => {
|
||||
// Find the name and index of the const parameter by indexing the generics of
|
||||
// the parent item and construct a `ParamConst`.
|
||||
let item_def_id = tcx.parent(def_id);
|
||||
let generics = tcx.generics_of(item_def_id);
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
let name = tcx.item_name(def_id);
|
||||
let ty_const = ty::Const::new_param(tcx, ty::ParamConst::new(index, name), ty);
|
||||
debug!(?ty_const);
|
||||
|
||||
return Self::Ty(ty_const);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def);
|
||||
let parent_args = if let Some(parent_hir_id) = tcx.hir().opt_parent_id(hir_id)
|
||||
&& let Some(parent_did) = parent_hir_id.as_owner()
|
||||
{
|
||||
GenericArgs::identity_for_item(tcx, parent_did)
|
||||
} else {
|
||||
List::empty()
|
||||
};
|
||||
debug!(?parent_args);
|
||||
|
||||
let did = def.to_def_id();
|
||||
let child_args = GenericArgs::identity_for_item(tcx, did);
|
||||
let args = tcx.mk_args_from_iter(parent_args.into_iter().chain(child_args.into_iter()));
|
||||
debug!(?args);
|
||||
|
||||
let span = tcx.def_span(def);
|
||||
let uneval = UnevaluatedConst::new(did, args);
|
||||
debug!(?span, ?param_env);
|
||||
|
||||
match tcx.const_eval_resolve(param_env, uneval, Some(span)) {
|
||||
Ok(val) => {
|
||||
debug!("evaluated const value");
|
||||
Self::Val(val, ty)
|
||||
}
|
||||
Err(_) => {
|
||||
debug!("error encountered during evaluation");
|
||||
// Error was handled in `const_eval_resolve`. Here we just create a
|
||||
// new unevaluated const and error hard later in codegen
|
||||
Self::Unevaluated(
|
||||
UnevaluatedConst {
|
||||
def: did,
|
||||
args: GenericArgs::identity_for_item(tcx, did),
|
||||
promoted: None,
|
||||
},
|
||||
ty,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_ty_const(c: ty::Const<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
|
||||
match c.kind() {
|
||||
ty::ConstKind::Value(valtree) => {
|
||||
|
@ -42,64 +42,6 @@ pub enum UnsafetyViolationDetails {
|
||||
CallToFunctionWith,
|
||||
}
|
||||
|
||||
impl UnsafetyViolationDetails {
|
||||
pub fn description_and_note(&self) -> (&'static str, &'static str) {
|
||||
use UnsafetyViolationDetails::*;
|
||||
match self {
|
||||
CallToUnsafeFunction => (
|
||||
"call to unsafe function",
|
||||
"consult the function's documentation for information on how to avoid undefined \
|
||||
behavior",
|
||||
),
|
||||
UseOfInlineAssembly => (
|
||||
"use of inline assembly",
|
||||
"inline assembly is entirely unchecked and can cause undefined behavior",
|
||||
),
|
||||
InitializingTypeWith => (
|
||||
"initializing type with `rustc_layout_scalar_valid_range` attr",
|
||||
"initializing a layout restricted type's field with a value outside the valid \
|
||||
range is undefined behavior",
|
||||
),
|
||||
CastOfPointerToInt => {
|
||||
("cast of pointer to int", "casting pointers to integers in constants")
|
||||
}
|
||||
UseOfMutableStatic => (
|
||||
"use of mutable static",
|
||||
"mutable statics can be mutated by multiple threads: aliasing violations or data \
|
||||
races will cause undefined behavior",
|
||||
),
|
||||
UseOfExternStatic => (
|
||||
"use of extern static",
|
||||
"extern statics are not controlled by the Rust type system: invalid data, \
|
||||
aliasing violations or data races will cause undefined behavior",
|
||||
),
|
||||
DerefOfRawPointer => (
|
||||
"dereference of raw pointer",
|
||||
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
|
||||
and cause data races: all of these are undefined behavior",
|
||||
),
|
||||
AccessToUnionField => (
|
||||
"access to union field",
|
||||
"the field may not be properly initialized: using uninitialized data will cause \
|
||||
undefined behavior",
|
||||
),
|
||||
MutationOfLayoutConstrainedField => (
|
||||
"mutation of layout constrained field",
|
||||
"mutating layout constrained fields cannot statically be checked for valid values",
|
||||
),
|
||||
BorrowOfLayoutConstrainedField => (
|
||||
"borrow of layout constrained field with interior mutability",
|
||||
"references to fields of layout constrained fields lose the constraints. Coupled \
|
||||
with interior mutability, the field can be changed to invalid values",
|
||||
),
|
||||
CallToFunctionWith => (
|
||||
"call to function with `#[target_feature]`",
|
||||
"can only be called if the required target features are available",
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
|
||||
pub struct UnsafetyViolation {
|
||||
pub source_info: SourceInfo,
|
||||
|
@ -422,7 +422,7 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
/// If `X` is the concrete type of an opaque type `impl Y`, then `X` must implement `Y`
|
||||
OpaqueType,
|
||||
|
||||
AwaitableExpr(Option<hir::HirId>),
|
||||
AwaitableExpr(hir::HirId),
|
||||
|
||||
ForLoopIterator,
|
||||
|
||||
|
@ -108,17 +108,6 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
|
||||
tcx.sess.emit_err(DropCheckOverflow { span, ty, overflow_ty: *overflow_ty });
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_kinds_reporting_overflows(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Vec<GenericArg<'tcx>> {
|
||||
self.report_overflows(tcx, span, ty);
|
||||
let DropckOutlivesResult { kinds, overflows: _ } = self;
|
||||
kinds
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of constraints that need to be satisfied in order for
|
||||
|
@ -216,6 +216,10 @@ impl<'tcx> Const<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(const_generics): We currently have to special case parameters because `min_const_generics`
|
||||
// does not provide the parents generics to anonymous constants. We still allow generic const
|
||||
// parameters by themselves however, e.g. `N`. These constants would cause an ICE if we were to
|
||||
// ever try to substitute the generic parameters in their bodies.
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(hir::QPath::Resolved(
|
||||
_,
|
||||
|
@ -604,13 +604,6 @@ impl<T> EarlyBinder<Option<T>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, U> EarlyBinder<(T, U)> {
|
||||
pub fn transpose_tuple2(self) -> (EarlyBinder<T>, EarlyBinder<U>) {
|
||||
let EarlyBinder { value: (lhs, rhs) } = self;
|
||||
(EarlyBinder { value: lhs }, EarlyBinder { value: rhs })
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>
|
||||
where
|
||||
I::Item: TypeFoldable<TyCtxt<'tcx>>,
|
||||
|
@ -42,7 +42,6 @@ use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, StashKey};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
|
||||
use rustc_hir::Node;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
@ -1301,25 +1300,6 @@ impl<'tcx> Predicate<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateKind::Clause(ClauseKind::TypeOutlives(data)) => Some(predicate.rebind(data)),
|
||||
PredicateKind::Clause(ClauseKind::Trait(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
||||
| PredicateKind::Clause(ClauseKind::Projection(..))
|
||||
| PredicateKind::AliasRelate(..)
|
||||
| PredicateKind::Subtype(..)
|
||||
| PredicateKind::Coerce(..)
|
||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
||||
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
||||
| PredicateKind::ObjectSafe(..)
|
||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
||||
| PredicateKind::ConstEquate(..)
|
||||
| PredicateKind::Ambiguous => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Matches a `PredicateKind::Clause` and turns it into a `Clause`, otherwise returns `None`.
|
||||
pub fn as_clause(self) -> Option<Clause<'tcx>> {
|
||||
match self.kind().skip_binder() {
|
||||
@ -2532,22 +2512,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Yields the parent function's `LocalDefId` if `def_id` is an `impl Trait` definition.
|
||||
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<LocalDefId> {
|
||||
let def_id = def_id.as_local()?;
|
||||
if let Node::Item(item) = tcx.hir().get_by_def_id(def_id) {
|
||||
if let hir::ItemKind::OpaqueTy(opaque_ty) = item.kind {
|
||||
return match opaque_ty.origin {
|
||||
hir::OpaqueTyOrigin::FnReturn(parent) | hir::OpaqueTyOrigin::AsyncFn(parent) => {
|
||||
Some(parent)
|
||||
}
|
||||
hir::OpaqueTyOrigin::TyAlias { .. } => None,
|
||||
};
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn int_ty(ity: ast::IntTy) -> IntTy {
|
||||
match ity {
|
||||
ast::IntTy::Isize => IntTy::Isize,
|
||||
|
@ -701,22 +701,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
.map(|decl| ty::EarlyBinder::bind(decl.ty))
|
||||
}
|
||||
|
||||
/// Normalizes all opaque types in the given value, replacing them
|
||||
/// with their underlying types.
|
||||
pub fn expand_opaque_types(self, val: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let mut visitor = OpaqueTypeExpander {
|
||||
seen_opaque_tys: FxHashSet::default(),
|
||||
expanded_cache: FxHashMap::default(),
|
||||
primary_def_id: None,
|
||||
found_recursion: false,
|
||||
found_any_recursion: false,
|
||||
check_recursion: false,
|
||||
expand_coroutines: false,
|
||||
tcx: self,
|
||||
};
|
||||
val.fold_with(&mut visitor)
|
||||
}
|
||||
|
||||
/// Expands the given impl trait type, stopping if the type is recursive.
|
||||
#[instrument(skip(self), level = "debug", ret)]
|
||||
pub fn try_expand_impl_trait_type(
|
||||
|
@ -642,15 +642,23 @@ impl<'tcx> Cx<'tcx> {
|
||||
}
|
||||
}
|
||||
hir::InlineAsmOperand::Const { ref anon_const } => {
|
||||
let value =
|
||||
mir::Const::from_anon_const(tcx, anon_const.def_id, self.param_env);
|
||||
let value = mir::Const::identity_unevaluated(
|
||||
tcx,
|
||||
anon_const.def_id.to_def_id(),
|
||||
)
|
||||
.instantiate_identity()
|
||||
.normalize(tcx, self.param_env);
|
||||
let span = tcx.def_span(anon_const.def_id);
|
||||
|
||||
InlineAsmOperand::Const { value, span }
|
||||
}
|
||||
hir::InlineAsmOperand::SymFn { ref anon_const } => {
|
||||
let value =
|
||||
mir::Const::from_anon_const(tcx, anon_const.def_id, self.param_env);
|
||||
let value = mir::Const::identity_unevaluated(
|
||||
tcx,
|
||||
anon_const.def_id.to_def_id(),
|
||||
)
|
||||
.instantiate_identity()
|
||||
.normalize(tcx, self.param_env);
|
||||
let span = tcx.def_span(anon_const.def_id);
|
||||
|
||||
InlineAsmOperand::SymFn { value, span }
|
||||
|
@ -156,33 +156,26 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_macro(&mut self, res: Res) -> Option<MacroData> {
|
||||
pub(crate) fn get_macro(&mut self, res: Res) -> Option<&MacroData> {
|
||||
match res {
|
||||
Res::Def(DefKind::Macro(..), def_id) => Some(self.get_macro_by_def_id(def_id)),
|
||||
Res::NonMacroAttr(_) => {
|
||||
Some(MacroData { ext: self.non_macro_attr.clone(), macro_rules: false })
|
||||
}
|
||||
Res::NonMacroAttr(_) => Some(&self.non_macro_attr),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_macro_by_def_id(&mut self, def_id: DefId) -> MacroData {
|
||||
if let Some(macro_data) = self.macro_map.get(&def_id) {
|
||||
return macro_data.clone();
|
||||
pub(crate) fn get_macro_by_def_id(&mut self, def_id: DefId) -> &MacroData {
|
||||
if self.macro_map.contains_key(&def_id) {
|
||||
return &self.macro_map[&def_id];
|
||||
}
|
||||
|
||||
let load_macro_untracked = self.cstore().load_macro_untracked(def_id, self.tcx);
|
||||
let (ext, macro_rules) = match load_macro_untracked {
|
||||
LoadedMacro::MacroDef(item, edition) => (
|
||||
Lrc::new(self.compile_macro(&item, edition).0),
|
||||
matches!(item.kind, ItemKind::MacroDef(def) if def.macro_rules),
|
||||
),
|
||||
LoadedMacro::ProcMacro(extz) => (Lrc::new(extz), false),
|
||||
let loaded_macro = self.cstore().load_macro_untracked(def_id, self.tcx);
|
||||
let macro_data = match loaded_macro {
|
||||
LoadedMacro::MacroDef(item, edition) => self.compile_macro(&item, edition),
|
||||
LoadedMacro::ProcMacro(ext) => MacroData::new(Lrc::new(ext)),
|
||||
};
|
||||
|
||||
let macro_data = MacroData { ext, macro_rules };
|
||||
self.macro_map.insert(def_id, macro_data.clone());
|
||||
macro_data
|
||||
self.macro_map.entry(def_id).or_insert(macro_data)
|
||||
}
|
||||
|
||||
pub(crate) fn build_reduced_graph(
|
||||
@ -1175,16 +1168,10 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||
// Mark the given macro as unused unless its name starts with `_`.
|
||||
// Macro uses will remove items from this set, and the remaining
|
||||
// items will be reported as `unused_macros`.
|
||||
fn insert_unused_macro(
|
||||
&mut self,
|
||||
ident: Ident,
|
||||
def_id: LocalDefId,
|
||||
node_id: NodeId,
|
||||
rule_spans: &[(usize, Span)],
|
||||
) {
|
||||
fn insert_unused_macro(&mut self, ident: Ident, def_id: LocalDefId, node_id: NodeId) {
|
||||
if !ident.as_str().starts_with('_') {
|
||||
self.r.unused_macros.insert(def_id, (node_id, ident));
|
||||
for (rule_i, rule_span) in rule_spans.iter() {
|
||||
for (rule_i, rule_span) in &self.r.macro_map[&def_id.to_def_id()].rule_spans {
|
||||
self.r.unused_macro_rules.insert((def_id, *rule_i), (ident, *rule_span));
|
||||
}
|
||||
}
|
||||
@ -1194,24 +1181,24 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||
let parent_scope = self.parent_scope;
|
||||
let expansion = parent_scope.expansion;
|
||||
let def_id = self.r.local_def_id(item.id);
|
||||
let (ext, ident, span, macro_rules, rule_spans) = match &item.kind {
|
||||
let (macro_kind, ident, span, macro_rules) = match &item.kind {
|
||||
ItemKind::MacroDef(def) => {
|
||||
let (ext, rule_spans) = self.r.compile_macro(item, self.r.tcx.sess.edition());
|
||||
let ext = Lrc::new(ext);
|
||||
(ext, item.ident, item.span, def.macro_rules, rule_spans)
|
||||
let macro_kind = self.r.macro_map[&def_id.to_def_id()].ext.macro_kind();
|
||||
(macro_kind, item.ident, item.span, def.macro_rules)
|
||||
}
|
||||
ItemKind::Fn(..) => match self.proc_macro_stub(item) {
|
||||
Some((macro_kind, ident, span)) => {
|
||||
let macro_data = MacroData::new(self.r.dummy_ext(macro_kind));
|
||||
self.r.macro_map.insert(def_id.to_def_id(), macro_data);
|
||||
self.r.proc_macro_stubs.insert(def_id);
|
||||
(self.r.dummy_ext(macro_kind), ident, span, false, Vec::new())
|
||||
(macro_kind, ident, span, false)
|
||||
}
|
||||
None => return parent_scope.macro_rules,
|
||||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id.to_def_id());
|
||||
self.r.macro_map.insert(def_id.to_def_id(), MacroData { ext, macro_rules });
|
||||
let res = Res::Def(DefKind::Macro(macro_kind), def_id.to_def_id());
|
||||
self.r.local_macro_def_scopes.insert(def_id, parent_scope.module);
|
||||
|
||||
if macro_rules {
|
||||
@ -1245,7 +1232,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||
self.r.define(self.r.graph_root, ident, MacroNS, import_binding);
|
||||
} else {
|
||||
self.r.check_reserved_macro_name(ident, res);
|
||||
self.insert_unused_macro(ident, def_id, item.id, &rule_spans);
|
||||
self.insert_unused_macro(ident, def_id, item.id);
|
||||
}
|
||||
self.r.visibilities.insert(def_id, vis);
|
||||
let scope = self.r.arenas.alloc_macro_rules_scope(MacroRulesScope::Binding(
|
||||
@ -1268,7 +1255,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||
_ => self.resolve_visibility(&item.vis),
|
||||
};
|
||||
if !vis.is_public() {
|
||||
self.insert_unused_macro(ident, def_id, item.id, &rule_spans);
|
||||
self.insert_unused_macro(ident, def_id, item.id);
|
||||
}
|
||||
self.r.define(module, ident, MacroNS, (res, vis, span, expansion));
|
||||
self.r.visibilities.insert(def_id, vis);
|
||||
|
@ -111,9 +111,14 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
||||
return visit::walk_item(self, i);
|
||||
}
|
||||
};
|
||||
let def = self.create_def(i.id, def_data, i.span);
|
||||
let def_id = self.create_def(i.id, def_data, i.span);
|
||||
|
||||
self.with_parent(def, |this| {
|
||||
if let ItemKind::MacroDef(..) = i.kind {
|
||||
let macro_data = self.resolver.compile_macro(i, self.resolver.tcx.sess.edition());
|
||||
self.resolver.macro_map.insert(def_id.to_def_id(), macro_data);
|
||||
}
|
||||
|
||||
self.with_parent(def_id, |this| {
|
||||
this.with_impl_trait(ImplTraitContext::Existential, |this| {
|
||||
match i.kind {
|
||||
ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => {
|
||||
|
@ -240,7 +240,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
{
|
||||
// The macro is a proc macro derive
|
||||
if let Some(def_id) = module.expansion.expn_data().macro_def_id {
|
||||
let ext = self.get_macro_by_def_id(def_id).ext;
|
||||
let ext = &self.get_macro_by_def_id(def_id).ext;
|
||||
if ext.builtin_name.is_none()
|
||||
&& ext.macro_kind() == MacroKind::Derive
|
||||
&& parent.expansion.outer_expn_is_descendant_of(*ctxt)
|
||||
|
@ -927,9 +927,16 @@ struct DeriveData {
|
||||
#[derive(Clone)]
|
||||
struct MacroData {
|
||||
ext: Lrc<SyntaxExtension>,
|
||||
rule_spans: Vec<(usize, Span)>,
|
||||
macro_rules: bool,
|
||||
}
|
||||
|
||||
impl MacroData {
|
||||
fn new(ext: Lrc<SyntaxExtension>) -> MacroData {
|
||||
MacroData { ext, rule_spans: Vec::new(), macro_rules: false }
|
||||
}
|
||||
}
|
||||
|
||||
/// The main resolver class.
|
||||
///
|
||||
/// This is the visitor that walks the whole crate.
|
||||
@ -1038,7 +1045,7 @@ pub struct Resolver<'a, 'tcx> {
|
||||
macro_map: FxHashMap<DefId, MacroData>,
|
||||
dummy_ext_bang: Lrc<SyntaxExtension>,
|
||||
dummy_ext_derive: Lrc<SyntaxExtension>,
|
||||
non_macro_attr: Lrc<SyntaxExtension>,
|
||||
non_macro_attr: MacroData,
|
||||
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'a>>,
|
||||
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'a>>,
|
||||
unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
|
||||
@ -1321,6 +1328,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
|
||||
let features = tcx.features();
|
||||
let pub_vis = ty::Visibility::<DefId>::Public;
|
||||
let edition = tcx.sess.edition();
|
||||
|
||||
let mut resolver = Resolver {
|
||||
tcx,
|
||||
@ -1402,9 +1410,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
registered_tools,
|
||||
macro_use_prelude: FxHashMap::default(),
|
||||
macro_map: FxHashMap::default(),
|
||||
dummy_ext_bang: Lrc::new(SyntaxExtension::dummy_bang(tcx.sess.edition())),
|
||||
dummy_ext_derive: Lrc::new(SyntaxExtension::dummy_derive(tcx.sess.edition())),
|
||||
non_macro_attr: Lrc::new(SyntaxExtension::non_macro_attr(tcx.sess.edition())),
|
||||
dummy_ext_bang: Lrc::new(SyntaxExtension::dummy_bang(edition)),
|
||||
dummy_ext_derive: Lrc::new(SyntaxExtension::dummy_derive(edition)),
|
||||
non_macro_attr: MacroData::new(Lrc::new(SyntaxExtension::non_macro_attr(edition))),
|
||||
invocation_parent_scopes: Default::default(),
|
||||
output_macro_rules_scopes: Default::default(),
|
||||
macro_rules_scopes: Default::default(),
|
||||
@ -1564,7 +1572,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
match macro_kind {
|
||||
MacroKind::Bang => self.dummy_ext_bang.clone(),
|
||||
MacroKind::Derive => self.dummy_ext_derive.clone(),
|
||||
MacroKind::Attr => self.non_macro_attr.clone(),
|
||||
MacroKind::Attr => self.non_macro_attr.ext.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use crate::errors::{
|
||||
MacroExpectedFound, RemoveSurroundingDerive,
|
||||
};
|
||||
use crate::Namespace::*;
|
||||
use crate::{BuiltinMacroState, Determinacy};
|
||||
use crate::{BuiltinMacroState, Determinacy, MacroData};
|
||||
use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet};
|
||||
use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding};
|
||||
use rustc_ast::expand::StrippedCfgItem;
|
||||
@ -695,7 +695,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
res
|
||||
};
|
||||
|
||||
res.map(|res| (self.get_macro(res).map(|macro_data| macro_data.ext), res))
|
||||
res.map(|res| (self.get_macro(res).map(|macro_data| macro_data.ext.clone()), res))
|
||||
}
|
||||
|
||||
pub(crate) fn finalize_macro_resolutions(&mut self, krate: &Crate) {
|
||||
@ -936,27 +936,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
/// Compile the macro into a `SyntaxExtension` and its rule spans.
|
||||
///
|
||||
/// Possibly replace its expander to a pre-defined one for built-in macros.
|
||||
pub(crate) fn compile_macro(
|
||||
&mut self,
|
||||
item: &ast::Item,
|
||||
edition: Edition,
|
||||
) -> (SyntaxExtension, Vec<(usize, Span)>) {
|
||||
let (mut result, mut rule_spans) =
|
||||
pub(crate) fn compile_macro(&mut self, item: &ast::Item, edition: Edition) -> MacroData {
|
||||
let (mut ext, mut rule_spans) =
|
||||
compile_declarative_macro(self.tcx.sess, self.tcx.features(), item, edition);
|
||||
|
||||
if let Some(builtin_name) = result.builtin_name {
|
||||
if let Some(builtin_name) = ext.builtin_name {
|
||||
// The macro was marked with `#[rustc_builtin_macro]`.
|
||||
if let Some(builtin_macro) = self.builtin_macros.get_mut(&builtin_name) {
|
||||
// The macro is a built-in, replace its expander function
|
||||
// while still taking everything else from the source code.
|
||||
// If we already loaded this builtin macro, give a better error message than 'no such builtin macro'.
|
||||
match mem::replace(builtin_macro, BuiltinMacroState::AlreadySeen(item.span)) {
|
||||
BuiltinMacroState::NotYetSeen(ext) => {
|
||||
result.kind = ext;
|
||||
BuiltinMacroState::NotYetSeen(builtin_ext) => {
|
||||
ext.kind = builtin_ext;
|
||||
rule_spans = Vec::new();
|
||||
if item.id != ast::DUMMY_NODE_ID {
|
||||
self.builtin_macro_kinds
|
||||
.insert(self.local_def_id(item.id), result.macro_kind());
|
||||
.insert(self.local_def_id(item.id), ext.macro_kind());
|
||||
}
|
||||
}
|
||||
BuiltinMacroState::AlreadySeen(span) => {
|
||||
@ -976,6 +972,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
(result, rule_spans)
|
||||
let ItemKind::MacroDef(def) = &item.kind else { unreachable!() };
|
||||
MacroData { ext: Lrc::new(ext), rule_spans, macro_rules: def.macro_rules }
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +139,8 @@ pub struct CompilerIO {
|
||||
pub temps_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
pub trait LintStoreMarker: Any + DynSync + DynSend {}
|
||||
|
||||
/// Represents the data associated with a compilation
|
||||
/// session for a single crate.
|
||||
pub struct Session {
|
||||
@ -171,10 +173,7 @@ pub struct Session {
|
||||
pub jobserver: Client,
|
||||
|
||||
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
|
||||
///
|
||||
/// FIXME(Centril): consider `dyn LintStoreMarker` once
|
||||
/// we can upcast to `Any` for some additional type safety.
|
||||
pub lint_store: Option<Lrc<dyn Any + DynSync + DynSend>>,
|
||||
pub lint_store: Option<Lrc<dyn LintStoreMarker>>,
|
||||
|
||||
/// Should be set if any lints are registered in `lint_store`.
|
||||
pub registered_lints: bool,
|
||||
|
@ -139,13 +139,6 @@ pub fn set_session_globals_then<R>(session_globals: &SessionGlobals, f: impl FnO
|
||||
SESSION_GLOBALS.set(session_globals, f)
|
||||
}
|
||||
|
||||
pub fn create_default_session_if_not_set_then<R, F>(f: F) -> R
|
||||
where
|
||||
F: FnOnce(&SessionGlobals) -> R,
|
||||
{
|
||||
create_session_if_not_set_then(edition::DEFAULT_EDITION, f)
|
||||
}
|
||||
|
||||
pub fn create_session_if_not_set_then<R, F>(edition: Edition, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&SessionGlobals) -> R,
|
||||
|
@ -330,7 +330,7 @@ fn equate_impl_headers<'tcx>(
|
||||
impl1.self_ty,
|
||||
impl2.self_ty,
|
||||
),
|
||||
_ => bug!("mk_eq_impl_headers given mismatched impl kinds"),
|
||||
_ => bug!("equate_impl_headers given mismatched impl kinds"),
|
||||
};
|
||||
|
||||
result.map(|infer_ok| infer_ok.obligations).ok()
|
||||
|
@ -1634,8 +1634,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
|
||||
fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic) {
|
||||
let hir = self.tcx.hir();
|
||||
if let ObligationCauseCode::AwaitableExpr(Some(hir_id)) =
|
||||
obligation.cause.code().peel_derives()
|
||||
if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code().peel_derives()
|
||||
&& let hir::Node::Expr(expr) = hir.get(*hir_id)
|
||||
{
|
||||
// FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()`
|
||||
|
@ -2424,10 +2424,7 @@ function initSearch(rawSearchIndex) {
|
||||
* @param {boolean} display - True if this is the active tab
|
||||
*/
|
||||
function addTab(array, query, display) {
|
||||
let extraClass = "";
|
||||
if (display === true) {
|
||||
extraClass = " active";
|
||||
}
|
||||
const extraClass = display ? " active" : "";
|
||||
|
||||
const output = document.createElement("div");
|
||||
let length = 0;
|
||||
@ -2669,13 +2666,9 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||
/**
|
||||
* Perform a search based on the current state of the search input element
|
||||
* and display the results.
|
||||
* @param {Event} [e] - The event that triggered this search, if any
|
||||
* @param {boolean} [forced]
|
||||
*/
|
||||
function search(e, forced) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
function search(forced) {
|
||||
const query = parseQuery(searchState.input.value.trim());
|
||||
let filterCrates = getFilterCrates();
|
||||
|
||||
@ -3212,7 +3205,8 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||
// popping a state (Firefox), which is why search() is
|
||||
// called both here and at the end of the startSearch()
|
||||
// function.
|
||||
search(e);
|
||||
e.preventDefault();
|
||||
search();
|
||||
} else {
|
||||
searchState.input.value = "";
|
||||
// When browsing back from search results the main page
|
||||
@ -3247,7 +3241,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
|
||||
// before paste back the previous search, you get the old search results without
|
||||
// the filter. To prevent this, we need to remove the previous results.
|
||||
currentResults = null;
|
||||
search(undefined, true);
|
||||
search(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ pub(super) fn check(
|
||||
// ? is a Call, makes sure not to rec *x?, but rather (*x)?
|
||||
ExprKind::Call(hir_callee, _) => matches!(
|
||||
hir_callee.kind,
|
||||
ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, _, _))
|
||||
ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, ..))
|
||||
),
|
||||
ExprKind::MethodCall(_, self_arg, ..) if expr.hir_id == self_arg.hir_id => true,
|
||||
ExprKind::Match(_, _, MatchSource::TryDesugar(_) | MatchSource::AwaitDesugar)
|
||||
|
@ -309,7 +309,7 @@ fn check_final_expr<'tcx>(
|
||||
let replacement = if let Some(inner_expr) = inner {
|
||||
// if desugar of `do yeet`, don't lint
|
||||
if let ExprKind::Call(path_expr, _) = inner_expr.kind
|
||||
&& let ExprKind::Path(QPath::LangItem(LangItem::TryTraitFromYeet, _, _)) = path_expr.kind
|
||||
&& let ExprKind::Path(QPath::LangItem(LangItem::TryTraitFromYeet, ..)) = path_expr.kind
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
|
||||
}
|
||||
},
|
||||
hir::QPath::TypeRelative(_, path) => path.ident.name,
|
||||
hir::QPath::LangItem(_, _, _) => return,
|
||||
hir::QPath::LangItem(..) => return,
|
||||
};
|
||||
match constructor_symbol {
|
||||
sym::Some | sym::Ok if path.ident.name == rustc_span::sym::map => (),
|
||||
|
@ -170,7 +170,7 @@ fn qpath_certainty(cx: &LateContext<'_>, qpath: &QPath<'_>, resolves_to_type: bo
|
||||
path_segment_certainty(cx, type_certainty(cx, ty), path_segment, resolves_to_type)
|
||||
},
|
||||
|
||||
QPath::LangItem(lang_item, _, _) => {
|
||||
QPath::LangItem(lang_item, ..) => {
|
||||
cx.tcx
|
||||
.lang_items()
|
||||
.get(*lang_item)
|
||||
|
15
tests/ui/asm/const-error.rs
Normal file
15
tests/ui/asm/const-error.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// only-x86_64
|
||||
// needs-asm-support
|
||||
|
||||
#![feature(asm_const)]
|
||||
|
||||
// Test to make sure that we emit const errors eagerly for inline asm
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
fn test<T>() {
|
||||
unsafe { asm!("/* {} */", const 1 / 0); }
|
||||
//~^ ERROR evaluation of
|
||||
}
|
||||
|
||||
fn main() {}
|
9
tests/ui/asm/const-error.stderr
Normal file
9
tests/ui/asm/const-error.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
error[E0080]: evaluation of `test::<T>::{constant#0}` failed
|
||||
--> $DIR/const-error.rs:11:37
|
||||
|
|
||||
LL | unsafe { asm!("/* {} */", const 1 / 0); }
|
||||
| ^^^^^ attempt to divide `1_i32` by zero
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
Loading…
Reference in New Issue
Block a user