Skip to content

Rollup of 10 pull requests #122735

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
85bad8d
Don't trigger `unused_qualifications` on global paths
jieyouxu Mar 15, 2024
52a1125
Extend format arg help for simple tuple index access expression
jieyouxu Mar 15, 2024
bc5aeb1
compiletest: Remove unneeded pub on get_lib_name()
Enselic Mar 10, 2024
935842b
Add tests
veera-sivarajan Mar 18, 2024
97cc700
Fix ICE: `global_asm!()` Don't Panic When Unable to Evaluate Constant
veera-sivarajan Mar 18, 2024
3948210
Update test with `//@ needs-asm-support`
veera-sivarajan Mar 19, 2024
19f72df
Fix incorrect mutable suggestion information for binding in ref pattern.
surechen Mar 18, 2024
cdeb170
Ensure stack before parsing dot-or-call
workingjubilee Mar 19, 2024
bdb682e
The AssocOpaqueTy HIR node is not actually needed to differentiate fr…
oli-obk Mar 19, 2024
a370ed7
[doc]:fix error code example
heisen-li Mar 19, 2024
3a09680
Ensure nested statics have a HIR node to prevent various queries from…
oli-obk Mar 19, 2024
db48dfc
Change only_local to enum type and change the macros to always requir…
surechen Mar 18, 2024
7b21c1a
add test for casting pointer to union with unsized tail
Mar 19, 2024
9de0921
compiletest: Fix typos in get_lib_name() comment
Enselic Mar 10, 2024
4c95d76
compiletest: Replace bool with enum AuxType for clarity
Enselic Mar 10, 2024
3a5eb35
compiletest: Add support for `//@ aux-bin: foo.rs`
Enselic Mar 17, 2024
489c2e9
Rollup merge of #122435 - jieyouxu:unused_qualifications_global_paths…
matthiaskrgr Mar 19, 2024
45e005d
Rollup merge of #122556 - jieyouxu:non-identifier-format-arg, r=petro…
matthiaskrgr Mar 19, 2024
42dec6f
Rollup merge of #122634 - Enselic:aux-bin, r=oli-obk
matthiaskrgr Mar 19, 2024
17386b8
Rollup merge of #122677 - surechen:fix_122415, r=Nadrieril
matthiaskrgr Mar 19, 2024
2ad2492
Rollup merge of #122691 - veera-sivarajan:bugfix-121099, r=Amanieu
matthiaskrgr Mar 19, 2024
ea7ea2d
Rollup merge of #122695 - surechen:make_only_local_explict_argument, …
matthiaskrgr Mar 19, 2024
6561890
Rollup merge of #122717 - workingjubilee:handle-call-call-call-call-c…
matthiaskrgr Mar 19, 2024
671a2f7
Rollup merge of #122719 - oli-obk:nested_static_feed_hir, r=fee1-dead
matthiaskrgr Mar 19, 2024
f773124
Rollup merge of #122720 - heisen-li:offset_of, r=workingjubilee
matthiaskrgr Mar 19, 2024
433449a
Rollup merge of #122724 - lukas-code:unsized-union-cast-ice-test, r=c…
matthiaskrgr Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub(super) fn index_hir<'hir>(
OwnerNode::TraitItem(item) => collector.visit_trait_item(item),
OwnerNode::ImplItem(item) => collector.visit_impl_item(item),
OwnerNode::ForeignItem(item) => collector.visit_foreign_item(item),
OwnerNode::AssocOpaqueTy(..) => unreachable!(),
OwnerNode::Synthetic => unreachable!(),
};

for (local_id, node) in collector.nodes.iter_enumerated() {
Expand Down
37 changes: 24 additions & 13 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(rustc::untranslatable_diagnostic)]

use core::ops::ControlFlow;
use hir::ExprKind;
use hir::{ExprKind, Param};
use rustc_errors::{Applicability, Diag};
use rustc_hir as hir;
use rustc_hir::intravisit::Visitor;
Expand Down Expand Up @@ -725,25 +725,26 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
_ => local_decl.source_info.span,
};

let def_id = self.body.source.def_id();
let hir_id = if let Some(local_def_id) = def_id.as_local()
&& let Some(body_id) = self.infcx.tcx.hir().maybe_body_owned_by(local_def_id)
{
let body = self.infcx.tcx.hir().body(body_id);
BindingFinder { span: pat_span }.visit_body(body).break_value()
} else {
None
};

// With ref-binding patterns, the mutability suggestion has to apply to
// the binding, not the reference (which would be a type error):
//
// `let &b = a;` -> `let &(mut b) = a;`
if let Some(hir_id) = hir_id
// or
// `fn foo(&x: &i32)` -> `fn foo(&(mut x): &i32)`
let def_id = self.body.source.def_id();
if let Some(local_def_id) = def_id.as_local()
&& let Some(body_id) = self.infcx.tcx.hir().maybe_body_owned_by(local_def_id)
&& let body = self.infcx.tcx.hir().body(body_id)
&& let Some(hir_id) = (BindingFinder { span: pat_span }).visit_body(body).break_value()
&& let node = self.infcx.tcx.hir_node(hir_id)
&& let hir::Node::Local(hir::Local {
pat: hir::Pat { kind: hir::PatKind::Ref(_, _), .. },
..
}) = self.infcx.tcx.hir_node(hir_id)
})
| hir::Node::Param(Param {
pat: hir::Pat { kind: hir::PatKind::Ref(_, _), .. },
..
}) = node
&& let Ok(name) =
self.infcx.tcx.sess.source_map().span_to_snippet(local_decl.source_info.span)
{
Expand Down Expand Up @@ -1310,6 +1311,16 @@ impl<'tcx> Visitor<'tcx> for BindingFinder {
hir::intravisit::walk_stmt(self, s)
}
}

fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) -> Self::Result {
if let hir::Pat { kind: hir::PatKind::Ref(_, _), span, .. } = param.pat
&& *span == self.span
{
ControlFlow::Break(param.hir_id)
} else {
ControlFlow::Continue(())
}
}
}

pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symbol>) -> bool {
Expand Down
46 changes: 29 additions & 17 deletions compiler/rustc_codegen_ssa/src/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::base;
use crate::common;
use crate::traits::*;
use rustc_hir as hir;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::mir::mono::MonoItem;
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::ty;
Expand Down Expand Up @@ -40,23 +41,34 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
.iter()
.map(|(op, op_sp)| match *op {
hir::InlineAsmOperand::Const { ref anon_const } => {
let const_value = cx
.tcx()
.const_eval_poly(anon_const.def_id.to_def_id())
.unwrap_or_else(|_| {
span_bug!(*op_sp, "asm const cannot be resolved")
});
let ty = cx
.tcx()
.typeck_body(anon_const.body)
.node_type(anon_const.hir_id);
let string = common::asm_const_to_str(
cx.tcx(),
*op_sp,
const_value,
cx.layout_of(ty),
);
GlobalAsmOperandRef::Const { string }
match cx.tcx().const_eval_poly(anon_const.def_id.to_def_id()) {
Ok(const_value) => {
let ty = cx
.tcx()
.typeck_body(anon_const.body)
.node_type(anon_const.hir_id);
let string = common::asm_const_to_str(
cx.tcx(),
*op_sp,
const_value,
cx.layout_of(ty),
);
GlobalAsmOperandRef::Const { string }
}
Err(ErrorHandled::Reported { .. }) => {
// An error has already been reported and
// compilation is guaranteed to fail if execution
// hits this path. So an empty string instead of
// a stringified constant value will suffice.
GlobalAsmOperandRef::Const { string: String::new() }
}
Err(ErrorHandled::TooGeneric(_)) => {
span_bug!(
*op_sp,
"asm const cannot be resolved; too generic"
)
}
}
}
hir::InlineAsmOperand::SymFn { ref anon_const } => {
let ty = cx
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ fn intern_as_new_static<'tcx>(
feed.generics_of(tcx.generics_of(static_id).clone());
feed.def_ident_span(tcx.def_ident_span(static_id));
feed.explicit_predicates_of(tcx.explicit_predicates_of(static_id));

feed.feed_hir()
}

/// How a constant value should be interned.
Expand Down
Loading