, Span, &Substructure<'_>) -> BlockOrExpr + 'a>;
pub fn combine_substructure(
f: CombineSubstructureFunc<'_>,
@@ -454,7 +454,7 @@ fn find_type_parameters(
impl<'a> TraitDef<'a> {
pub fn expand(
self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
mitem: &ast::MetaItem,
item: &'a Annotatable,
push: &mut dyn FnMut(Annotatable),
@@ -464,7 +464,7 @@ impl<'a> TraitDef<'a> {
pub fn expand_ext(
self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
mitem: &ast::MetaItem,
item: &'a Annotatable,
push: &mut dyn FnMut(Annotatable),
@@ -577,7 +577,7 @@ impl<'a> TraitDef<'a> {
/// therefore does not get bound by the derived trait.
fn create_derived_impl(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
type_ident: Ident,
generics: &Generics,
field_tys: Vec>,
@@ -802,7 +802,7 @@ impl<'a> TraitDef<'a> {
fn expand_struct_def(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
struct_def: &'a VariantData,
type_ident: Ident,
generics: &Generics,
@@ -856,7 +856,7 @@ impl<'a> TraitDef<'a> {
fn expand_enum_def(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
enum_def: &'a EnumDef,
type_ident: Ident,
generics: &Generics,
@@ -914,7 +914,7 @@ impl<'a> TraitDef<'a> {
impl<'a> MethodDef<'a> {
fn call_substructure_method(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
type_ident: Ident,
nonselflike_args: &[P],
@@ -929,7 +929,7 @@ impl<'a> MethodDef<'a> {
fn get_ret_ty(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
generics: &Generics,
type_ident: Ident,
@@ -950,7 +950,7 @@ impl<'a> MethodDef<'a> {
// `&self`.
fn extract_arg_details(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
type_ident: Ident,
generics: &Generics,
@@ -986,7 +986,7 @@ impl<'a> MethodDef<'a> {
fn create_method(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
type_ident: Ident,
generics: &Generics,
@@ -1077,7 +1077,7 @@ impl<'a> MethodDef<'a> {
/// ```
fn expand_struct_method_body<'b>(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'b>,
struct_def: &'b VariantData,
type_ident: Ident,
@@ -1100,7 +1100,7 @@ impl<'a> MethodDef<'a> {
fn expand_static_struct_method_body(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
struct_def: &VariantData,
type_ident: Ident,
@@ -1154,7 +1154,7 @@ impl<'a> MethodDef<'a> {
/// `Unify`), and possibly a default arm.
fn expand_enum_method_body<'b>(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'b>,
enum_def: &'b EnumDef,
type_ident: Ident,
@@ -1403,7 +1403,7 @@ impl<'a> MethodDef<'a> {
fn expand_static_enum_method_body(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
enum_def: &EnumDef,
type_ident: Ident,
@@ -1430,7 +1430,7 @@ impl<'a> MethodDef<'a> {
// general helper methods.
impl<'a> TraitDef<'a> {
- fn summarise_struct(&self, cx: &mut ExtCtxt<'_>, struct_def: &VariantData) -> StaticFields {
+ fn summarise_struct(&self, cx: &ExtCtxt<'_>, struct_def: &VariantData) -> StaticFields {
let mut named_idents = Vec::new();
let mut just_spans = Vec::new();
for field in struct_def.fields() {
@@ -1460,7 +1460,7 @@ impl<'a> TraitDef<'a> {
fn create_struct_patterns(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
struct_path: ast::Path,
struct_def: &'a VariantData,
prefixes: &[String],
@@ -1553,7 +1553,7 @@ impl<'a> TraitDef<'a> {
fn create_struct_pattern_fields(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
struct_def: &'a VariantData,
prefixes: &[String],
) -> Vec {
@@ -1570,7 +1570,7 @@ impl<'a> TraitDef<'a> {
fn create_struct_field_access_fields(
&self,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
selflike_args: &[P],
struct_def: &'a VariantData,
is_packed: bool,
@@ -1668,13 +1668,13 @@ pub enum CsFold<'a> {
/// Statics may not be folded over.
pub fn cs_fold(
use_foldl: bool,
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
trait_span: Span,
substructure: &Substructure<'_>,
mut f: F,
) -> P
where
- F: FnMut(&mut ExtCtxt<'_>, CsFold<'_>) -> P,
+ F: FnMut(&ExtCtxt<'_>, CsFold<'_>) -> P,
{
match substructure.fields {
EnumMatching(.., all_fields) | Struct(_, all_fields) => {
diff --git a/compiler/rustc_builtin_macros/src/deriving/hash.rs b/compiler/rustc_builtin_macros/src/deriving/hash.rs
index dd6149cf614..6bb61311bd2 100644
--- a/compiler/rustc_builtin_macros/src/deriving/hash.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/hash.rs
@@ -8,7 +8,7 @@ use rustc_span::Span;
use thin_vec::thin_vec;
pub fn expand_deriving_hash(
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
@@ -46,11 +46,7 @@ pub fn expand_deriving_hash(
hash_trait_def.expand(cx, mitem, item, push);
}
-fn hash_substructure(
- cx: &mut ExtCtxt<'_>,
- trait_span: Span,
- substr: &Substructure<'_>,
-) -> BlockOrExpr {
+fn hash_substructure(cx: &ExtCtxt<'_>, trait_span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
let [state_expr] = substr.nonselflike_args else {
cx.dcx().span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`");
};
diff --git a/compiler/rustc_builtin_macros/src/deriving/mod.rs b/compiler/rustc_builtin_macros/src/deriving/mod.rs
index 8a3375cba9d..9f786d22c93 100644
--- a/compiler/rustc_builtin_macros/src/deriving/mod.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/mod.rs
@@ -40,7 +40,7 @@ pub mod partial_ord;
pub mod generic;
pub(crate) type BuiltinDeriveFn =
- fn(&mut ExtCtxt<'_>, Span, &MetaItem, &Annotatable, &mut dyn FnMut(Annotatable), bool);
+ fn(&ExtCtxt<'_>, Span, &MetaItem, &Annotatable, &mut dyn FnMut(Annotatable), bool);
pub(crate) struct BuiltinDerive(pub(crate) BuiltinDeriveFn);
@@ -117,7 +117,7 @@ fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> P {
}
fn assert_ty_bounds(
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
stmts: &mut ThinVec,
ty: P,
span: Span,
diff --git a/compiler/rustc_builtin_macros/src/edition_panic.rs b/compiler/rustc_builtin_macros/src/edition_panic.rs
index fa22e911642..bb3c83e8c0e 100644
--- a/compiler/rustc_builtin_macros/src/edition_panic.rs
+++ b/compiler/rustc_builtin_macros/src/edition_panic.rs
@@ -40,7 +40,7 @@ pub fn expand_unreachable<'cx>(
fn expand<'cx>(
mac: rustc_span::Symbol,
- cx: &'cx mut ExtCtxt<'_>,
+ cx: &'cx ExtCtxt<'_>,
sp: Span,
tts: TokenStream,
) -> MacroExpanderResult<'cx> {
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs
index 6f031f270ca..51d6058a744 100644
--- a/compiler/rustc_builtin_macros/src/format.rs
+++ b/compiler/rustc_builtin_macros/src/format.rs
@@ -65,7 +65,7 @@ struct MacroInput {
/// ```text
/// Ok((fmtstr, parsed arguments))
/// ```
-fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, MacroInput> {
+fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, MacroInput> {
let mut args = FormatArguments::new();
let mut p = ecx.new_parser_from_tts(tts);
@@ -604,7 +604,7 @@ fn invalid_placeholder_type_error(
}
fn report_missing_placeholders(
- ecx: &mut ExtCtxt<'_>,
+ ecx: &ExtCtxt<'_>,
unused: Vec<(Span, bool)>,
used: &[bool],
args: &FormatArguments,
@@ -734,7 +734,7 @@ fn report_missing_placeholders(
/// This function detects and reports unused format!() arguments that are
/// redundant due to implicit captures (e.g. `format!("{x}", x)`).
fn report_redundant_format_arguments<'a>(
- ecx: &mut ExtCtxt<'a>,
+ ecx: &ExtCtxt<'a>,
args: &FormatArguments,
used: &[bool],
placeholders: Vec<(Span, &str)>,
@@ -806,7 +806,7 @@ fn report_redundant_format_arguments<'a>(
/// there are named arguments or numbered positional arguments in the
/// format string.
fn report_invalid_references(
- ecx: &mut ExtCtxt<'_>,
+ ecx: &ExtCtxt<'_>,
invalid_refs: &[(usize, Option, PositionUsedAs, FormatArgPositionKind)],
template: &[FormatArgsPiece],
fmt_span: Span,
diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs
index abcdfabcaed..61a6361ae8d 100644
--- a/compiler/rustc_builtin_macros/src/source_util.rs
+++ b/compiler/rustc_builtin_macros/src/source_util.rs
@@ -234,7 +234,7 @@ pub fn expand_include_bytes(
}
fn load_binary_file(
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
original_path: &Path,
macro_span: Span,
path_span: Span,
diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs
index 81ac78dd58f..c7568f1461c 100644
--- a/compiler/rustc_builtin_macros/src/test.rs
+++ b/compiler/rustc_builtin_macros/src/test.rs
@@ -96,7 +96,7 @@ pub fn expand_bench(
}
pub fn expand_test_or_bench(
- cx: &mut ExtCtxt<'_>,
+ cx: &ExtCtxt<'_>,
attr_sp: Span,
item: Annotatable,
is_bench: bool,
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index c8b8594c0dd..7c7f702b2c3 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2089,14 +2089,14 @@ fn add_rpath_args(
.map(|(path, _)| &**path)
})
.collect::>();
- let mut rpath_config = RPathConfig {
+ let rpath_config = RPathConfig {
libs: &*libs,
out_filename: out_filename.to_path_buf(),
has_rpath: sess.target.has_rpath,
is_like_osx: sess.target.is_like_osx,
linker_is_gnu: sess.target.linker_flavor.is_gnu(),
};
- cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
+ cmd.args(&rpath::get_rpath_flags(&rpath_config));
}
}
diff --git a/compiler/rustc_codegen_ssa/src/back/rpath.rs b/compiler/rustc_codegen_ssa/src/back/rpath.rs
index 60346228625..ebbf49af184 100644
--- a/compiler/rustc_codegen_ssa/src/back/rpath.rs
+++ b/compiler/rustc_codegen_ssa/src/back/rpath.rs
@@ -12,7 +12,7 @@ pub struct RPathConfig<'a> {
pub linker_is_gnu: bool,
}
-pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec {
+pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec {
// No rpath on windows
if !config.has_rpath {
return Vec::new();
@@ -52,7 +52,7 @@ fn rpaths_to_flags(rpaths: Vec) -> Vec {
ret
}
-fn get_rpaths(config: &mut RPathConfig<'_>) -> Vec {
+fn get_rpaths(config: &RPathConfig<'_>) -> Vec {
debug!("output: {:?}", config.out_filename.display());
debug!("libs:");
for libpath in config.libs {
@@ -73,11 +73,11 @@ fn get_rpaths(config: &mut RPathConfig<'_>) -> Vec {
minimize_rpaths(&rpaths)
}
-fn get_rpaths_relative_to_output(config: &mut RPathConfig<'_>) -> Vec {
+fn get_rpaths_relative_to_output(config: &RPathConfig<'_>) -> Vec {
config.libs.iter().map(|a| get_rpath_relative_to_output(config, a)).collect()
}
-fn get_rpath_relative_to_output(config: &mut RPathConfig<'_>, lib: &Path) -> OsString {
+fn get_rpath_relative_to_output(config: &RPathConfig<'_>, lib: &Path) -> OsString {
// Mac doesn't appear to support $ORIGIN
let prefix = if config.is_like_osx { "@loader_path" } else { "$ORIGIN" };
diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs
index cac1e8f80e3..6029caa965c 100644
--- a/compiler/rustc_expand/src/expand.rs
+++ b/compiler/rustc_expand/src/expand.rs
@@ -871,7 +871,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
let mut parser = self.cx.new_parser_from_tts(toks);
match parse_ast_fragment(&mut parser, kind) {
Ok(fragment) => {
- ensure_complete_parse(&mut parser, path, kind.name(), span);
+ ensure_complete_parse(&parser, path, kind.name(), span);
fragment
}
Err(mut err) => {
@@ -958,7 +958,7 @@ pub fn parse_ast_fragment<'a>(
}
pub fn ensure_complete_parse<'a>(
- parser: &mut Parser<'a>,
+ parser: &Parser<'a>,
macro_path: &ast::Path,
kind_name: &str,
span: Span,
diff --git a/compiler/rustc_infer/src/infer/snapshot/fudge.rs b/compiler/rustc_infer/src/infer/snapshot/fudge.rs
index 14de461cd17..f8f1c1b4c45 100644
--- a/compiler/rustc_infer/src/infer/snapshot/fudge.rs
+++ b/compiler/rustc_infer/src/infer/snapshot/fudge.rs
@@ -13,7 +13,7 @@ use ut::UnifyKey;
use std::ops::Range;
fn vars_since_snapshot<'tcx, T>(
- table: &mut UnificationTable<'_, 'tcx, T>,
+ table: &UnificationTable<'_, 'tcx, T>,
snapshot_var_len: usize,
) -> Range
where
@@ -124,11 +124,11 @@ impl<'tcx> InferCtxt<'tcx> {
let type_vars =
inner.type_variables().vars_since_snapshot(variable_lengths.type_var_len);
let int_vars = vars_since_snapshot(
- &mut inner.int_unification_table(),
+ &inner.int_unification_table(),
variable_lengths.int_var_len,
);
let float_vars = vars_since_snapshot(
- &mut inner.float_unification_table(),
+ &inner.float_unification_table(),
variable_lengths.float_var_len,
);
let region_vars = inner
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs
index b4c98834d0a..f8aaf629131 100644
--- a/compiler/rustc_mir_build/src/build/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/build/matches/mod.rs
@@ -1593,10 +1593,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// [`Switch`]: TestKind::Switch
/// [`SwitchInt`]: TestKind::SwitchInt
/// [`Range`]: TestKind::Range
- fn pick_test(
- &mut self,
- candidates: &mut [&mut Candidate<'_, 'tcx>],
- ) -> (Place<'tcx>, Test<'tcx>) {
+ fn pick_test(&mut self, candidates: &[&mut Candidate<'_, 'tcx>]) -> (Place<'tcx>, Test<'tcx>) {
// Extract the match-pair from the highest priority candidate
let match_pair = &candidates.first().unwrap().match_pairs[0];
let test = self.test(match_pair);
diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs
index f0a13f66555..c3f175f150d 100644
--- a/compiler/rustc_mir_transform/src/coroutine.rs
+++ b/compiler/rustc_mir_transform/src/coroutine.rs
@@ -1226,7 +1226,7 @@ fn create_coroutine_drop_shim<'tcx>(
tcx: TyCtxt<'tcx>,
transform: &TransformVisitor<'tcx>,
coroutine_ty: Ty<'tcx>,
- body: &mut Body<'tcx>,
+ body: &Body<'tcx>,
drop_clean: BasicBlock,
) -> Body<'tcx> {
let mut body = body.clone();
diff --git a/compiler/rustc_mir_transform/src/nrvo.rs b/compiler/rustc_mir_transform/src/nrvo.rs
index c3a92911bbf..232c290e0fb 100644
--- a/compiler/rustc_mir_transform/src/nrvo.rs
+++ b/compiler/rustc_mir_transform/src/nrvo.rs
@@ -84,7 +84,7 @@ impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
///
/// If the MIR fulfills both these conditions, this function returns the `Local` that is assigned
/// to the return place along all possible paths through the control-flow graph.
-fn local_eligible_for_nrvo(body: &mut mir::Body<'_>) -> Option {
+fn local_eligible_for_nrvo(body: &mir::Body<'_>) -> Option {
if IsReturnPlaceRead::run(body) {
return None;
}
@@ -118,10 +118,7 @@ fn local_eligible_for_nrvo(body: &mut mir::Body<'_>) -> Option {
copied_to_return_place
}
-fn find_local_assigned_to_return_place(
- start: BasicBlock,
- body: &mut mir::Body<'_>,
-) -> Option {
+fn find_local_assigned_to_return_place(start: BasicBlock, body: &mir::Body<'_>) -> Option {
let mut block = start;
let mut seen = BitSet::new_empty(body.basic_blocks.len());
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index afda432d3ab..d51fcf693ed 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -2000,7 +2000,7 @@ pub fn parse_crate_edition(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches
}
fn check_error_format_stability(
- early_dcx: &mut EarlyDiagCtxt,
+ early_dcx: &EarlyDiagCtxt,
unstable_opts: &UnstableOptions,
error_format: ErrorOutputType,
) {
@@ -2098,7 +2098,7 @@ fn should_override_cgus_and_disable_thinlto(
fn collect_print_requests(
early_dcx: &EarlyDiagCtxt,
cg: &mut CodegenOptions,
- unstable_opts: &mut UnstableOptions,
+ unstable_opts: &UnstableOptions,
matches: &getopts::Matches,
) -> Vec {
let mut prints = Vec::::new();
@@ -2564,7 +2564,7 @@ fn parse_remap_path_prefix(
}
fn parse_logical_env(
- early_dcx: &mut EarlyDiagCtxt,
+ early_dcx: &EarlyDiagCtxt,
matches: &getopts::Matches,
) -> FxIndexMap {
let mut vars = FxIndexMap::default();
@@ -2722,6 +2722,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
}
if let Ok(graphviz_font) = std::env::var("RUSTC_GRAPHVIZ_FONT") {
+ // FIXME: this is only mutation of UnstableOptions here, move into
+ // UnstableOptions::build?
unstable_opts.graphviz_font = graphviz_font;
}
@@ -2771,7 +2773,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
));
}
- let prints = collect_print_requests(early_dcx, &mut cg, &mut unstable_opts, matches);
+ let prints = collect_print_requests(early_dcx, &mut cg, &unstable_opts, matches);
let cg = cg;
diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs
index 50ebbdccf67..58de5cb31a5 100644
--- a/compiler/rustc_session/src/utils.rs
+++ b/compiler/rustc_session/src/utils.rs
@@ -127,7 +127,7 @@ pub fn extra_compiler_flags() -> Option<(Vec, bool)> {
const ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE: &[&str] = &["incremental"];
- let mut args = std::env::args_os().map(|arg| arg.to_string_lossy().to_string()).peekable();
+ let mut args = std::env::args_os().map(|arg| arg.to_string_lossy().to_string());
let mut result = Vec::new();
let mut excluded_cargo_defaults = false;
diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs
index d39a3788d4c..7c12168b809 100644
--- a/compiler/rustc_smir/src/rustc_smir/context.rs
+++ b/compiler/rustc_smir/src/rustc_smir/context.rs
@@ -420,7 +420,10 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
let tcx = tables.tcx;
let args = args.internal(&mut *tables, tcx);
let def_ty = tables.tcx.type_of(item.internal(&mut *tables, tcx));
- def_ty.instantiate(tables.tcx, args).stable(&mut *tables)
+ tables
+ .tcx
+ .instantiate_and_normalize_erasing_regions(args, ty::ParamEnv::reveal_all(), def_ty)
+ .stable(&mut *tables)
}
fn const_pretty(&self, cnst: &stable_mir::ty::Const) -> String {
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 28f4f81e7d8..fe2691e9d4d 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -4931,7 +4931,7 @@ fn point_at_assoc_type_restriction(
let hir::WherePredicate::BoundPredicate(pred) = pred else {
continue;
};
- let mut bounds = pred.bounds.iter().peekable();
+ let mut bounds = pred.bounds.iter();
while let Some(bound) = bounds.next() {
let Some(trait_ref) = bound.trait_ref() else {
continue;
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index 12371155303..c33e24b1094 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -508,7 +508,7 @@ pub(super) fn opt_normalize_projection_type<'a, 'b, 'tcx>(
/// because it contains `[type error]`. Yuck! (See issue #29857 for
/// one case where this arose.)
fn normalize_to_error<'a, 'tcx>(
- selcx: &mut SelectionContext<'a, 'tcx>,
+ selcx: &SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::AliasTy<'tcx>,
cause: ObligationCause<'tcx>,
diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
index 27dd8f26489..43c750ebbb5 100644
--- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
@@ -239,10 +239,10 @@ fn fulfill_implication<'tcx>(
let source_trait = ImplSubject::Trait(source_trait_ref);
- let selcx = &mut SelectionContext::new(infcx);
+ let selcx = SelectionContext::new(infcx);
let target_args = infcx.fresh_args_for_item(DUMMY_SP, target_impl);
let (target_trait, obligations) =
- util::impl_subject_and_oblig(selcx, param_env, target_impl, target_args, error_cause);
+ util::impl_subject_and_oblig(&selcx, param_env, target_impl, target_args, error_cause);
// do the impls unify? If not, no specialization.
let Ok(InferOk { obligations: more_obligations, .. }) = infcx
diff --git a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
index 1aa65b87f0b..dba014d58b0 100644
--- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
+++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
@@ -198,7 +198,7 @@ impl<'tcx> Children {
}
}
-fn iter_children(children: &mut Children) -> impl Iterator- + '_ {
+fn iter_children(children: &Children) -> impl Iterator
- + '_ {
let nonblanket = children.non_blanket_impls.iter().flat_map(|(_, v)| v.iter());
children.blanket_impls.iter().chain(nonblanket).cloned()
}
diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs
index 29d063321a7..466a53d8ce0 100644
--- a/compiler/rustc_trait_selection/src/traits/util.rs
+++ b/compiler/rustc_trait_selection/src/traits/util.rs
@@ -205,7 +205,7 @@ impl Iterator for SupertraitDefIds<'_> {
/// returning the resulting subject and all obligations that arise.
/// The obligations are closed under normalization.
pub fn impl_subject_and_oblig<'a, 'tcx>(
- selcx: &mut SelectionContext<'a, 'tcx>,
+ selcx: &SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
impl_def_id: DefId,
impl_args: GenericArgsRef<'tcx>,
diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs
index 21db222095f..3e8d186b97e 100644
--- a/compiler/stable_mir/src/ty.rs
+++ b/compiler/stable_mir/src/ty.rs
@@ -654,7 +654,7 @@ impl AdtDef {
with(|cx| cx.def_ty(self.0))
}
- /// Retrieve the type of this Adt instantiating the type with the given arguments.
+ /// Retrieve the type of this Adt by instantiating and normalizing it with the given arguments.
///
/// This will assume the type can be instantiated with these arguments.
pub fn ty_with_args(&self, args: &GenericArgs) -> Ty {
@@ -733,7 +733,7 @@ pub struct FieldDef {
}
impl FieldDef {
- /// Retrieve the type of this field instantiating the type with the given arguments.
+ /// Retrieve the type of this field instantiating and normalizing it with the given arguments.
///
/// This will assume the type can be instantiated with these arguments.
pub fn ty_with_args(&self, args: &GenericArgs) -> Ty {
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index d40a3ea4c88..895c43d4dda 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -643,13 +643,13 @@ impl Step for StdLink {
t!(fs::create_dir_all(&sysroot_bin_dir));
builder.cp_link_r(&stage0_bin_dir, &sysroot_bin_dir);
- // Copy all *.so files from stage0/lib to stage0-sysroot/lib
+ // Copy all files from stage0/lib to stage0-sysroot/lib
let stage0_lib_dir = builder.out.join(host).join("stage0/lib");
if let Ok(files) = fs::read_dir(stage0_lib_dir) {
for file in files {
let file = t!(file);
let path = file.path();
- if path.is_file() && is_dylib(&file.file_name().into_string().unwrap()) {
+ if path.is_file() {
builder
.copy_link(&path, &sysroot.join("lib").join(path.file_name().unwrap()));
}
diff --git a/tests/ui-fulldeps/stable-mir/check_normalization.rs b/tests/ui-fulldeps/stable-mir/check_normalization.rs
new file mode 100644
index 00000000000..72e410f8080
--- /dev/null
+++ b/tests/ui-fulldeps/stable-mir/check_normalization.rs
@@ -0,0 +1,95 @@
+//@ run-pass
+//! Test that types are normalized in an instance body.
+
+//@ ignore-stage1
+//@ ignore-cross-compile
+//@ ignore-remote
+//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837
+//@ edition: 2021
+
+#![feature(rustc_private)]
+
+#[macro_use]
+extern crate rustc_smir;
+extern crate rustc_driver;
+extern crate rustc_interface;
+extern crate stable_mir;
+
+use mir::mono::Instance;
+use ty::{Ty, TyKind, RigidTy};
+use rustc_smir::rustc_internal;
+use stable_mir::*;
+use std::io::Write;
+use std::ops::ControlFlow;
+
+const CRATE_NAME: &str = "input";
+
+/// This function uses the Stable MIR APIs to get information about the test crate.
+fn test_stable_mir() -> ControlFlow<()> {
+ let items = stable_mir::all_local_items();
+
+ // Get all items and split generic vs monomorphic items.
+ let instances: Vec<_> =
+ items.into_iter().filter_map(|item| (!item.requires_monomorphization()).then(|| {
+ Instance::try_from(item).unwrap()
+ })).collect();
+ assert_eq!(instances.len(), 1, "Expected one constant");
+
+ for instance in instances {
+ check_ty(instance.ty());
+ }
+ ControlFlow::Continue(())
+}
+
+fn check_ty(ty: Ty) {
+ match ty.kind() {
+ TyKind::RigidTy(RigidTy::Adt(def, args)) if def.kind().is_struct() => {
+ // Ensure field type is also normalized
+ def.variants_iter().next().unwrap().fields().into_iter().for_each(|f| {
+ check_ty(f.ty_with_args(&args))
+ });
+ }
+ TyKind::RigidTy(RigidTy::Uint(..)) => {}
+ kind => unreachable!("Unexpected kind: {kind:?}")
+ }
+}
+
+
+/// This test will generate and analyze a dummy crate using the stable mir.
+/// For that, it will first write the dummy crate into a file.
+/// Then it will create a `StableMir` using custom arguments and then
+/// it will run the compiler.
+fn main() {
+ let path = "normalization_input.rs";
+ generate_input(&path).unwrap();
+ let args = vec![
+ "rustc".to_string(),
+ "-Cpanic=abort".to_string(),
+ "--crate-type=lib".to_string(),
+ "--crate-name".to_string(),
+ CRATE_NAME.to_string(),
+ path.to_string(),
+ ];
+ run!(args, test_stable_mir).unwrap();
+}
+
+fn generate_input(path: &str) -> std::io::Result<()> {
+ let mut file = std::fs::File::create(path)?;
+ write!(
+ file,
+ r#"
+ pub trait Primitive {{
+ type Base;
+ }}
+
+ impl Primitive for char {{
+ type Base = u32;
+ }}
+
+ pub struct Wrapper(T::Base);
+ pub type WrapperChar = Wrapper;
+ pub const NULL_CHAR: WrapperChar = Wrapper::(0);
+ "#
+ )?;
+ Ok(())
+}