Auto merge of #111017 - matthiaskrgr:rollup-yy9updi, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #110118 (download-rustc: Give a better error message if artifacts can't be dowloaded)
 - #110631 (rustdoc: catch and don't blow up on impl Trait cycles)
 - #110732 (Make ConstProp some tests unit.)
 - #110996 (bootstrap: Fix compile error: unused-mut)
 - #110999 (Output some bootstrap messages on stderr)
 - #111000 (Remove unneeded function call in `core::option`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-04-30 16:54:16 +00:00
commit f2eb9f85b9
29 changed files with 268 additions and 139 deletions

View file

@ -1007,7 +1007,7 @@ impl<T> Option<T> {
{ {
match self { match self {
Some(x) => x, Some(x) => x,
None => Default::default(), None => T::default(),
} }
} }
@ -1615,11 +1615,7 @@ impl<T> Option<T> {
where where
T: Default, T: Default,
{ {
fn default<T: Default>() -> T { self.get_or_insert_with(T::default)
T::default()
}
self.get_or_insert_with(default)
} }
/// Inserts a value computed from `f` into the option if it is [`None`], /// Inserts a value computed from `f` into the option if it is [`None`],

View file

@ -42,23 +42,23 @@ def get(base, url, path, checksums, verbose=False):
if os.path.exists(path): if os.path.exists(path):
if verify(path, sha256, False): if verify(path, sha256, False):
if verbose: if verbose:
print("using already-download file", path) print("using already-download file", path, file=sys.stderr)
return return
else: else:
if verbose: if verbose:
print("ignoring already-download file", print("ignoring already-download file",
path, "due to failed verification") path, "due to failed verification", file=sys.stderr)
os.unlink(path) os.unlink(path)
download(temp_path, "{}/{}".format(base, url), True, verbose) download(temp_path, "{}/{}".format(base, url), True, verbose)
if not verify(temp_path, sha256, verbose): if not verify(temp_path, sha256, verbose):
raise RuntimeError("failed verification") raise RuntimeError("failed verification")
if verbose: if verbose:
print("moving {} to {}".format(temp_path, path)) print("moving {} to {}".format(temp_path, path), file=sys.stderr)
shutil.move(temp_path, path) shutil.move(temp_path, path)
finally: finally:
if os.path.isfile(temp_path): if os.path.isfile(temp_path):
if verbose: if verbose:
print("removing", temp_path) print("removing", temp_path, file=sys.stderr)
os.unlink(temp_path) os.unlink(temp_path)
@ -68,7 +68,7 @@ def download(path, url, probably_big, verbose):
_download(path, url, probably_big, verbose, True) _download(path, url, probably_big, verbose, True)
return return
except RuntimeError: except RuntimeError:
print("\nspurious failure, trying again") print("\nspurious failure, trying again", file=sys.stderr)
_download(path, url, probably_big, verbose, False) _download(path, url, probably_big, verbose, False)
@ -79,7 +79,7 @@ def _download(path, url, probably_big, verbose, exception):
# - If we are on win32 fallback to powershell # - If we are on win32 fallback to powershell
# - Otherwise raise the error if appropriate # - Otherwise raise the error if appropriate
if probably_big or verbose: if probably_big or verbose:
print("downloading {}".format(url)) print("downloading {}".format(url), file=sys.stderr)
try: try:
if probably_big or verbose: if probably_big or verbose:
@ -115,20 +115,20 @@ def _download(path, url, probably_big, verbose, exception):
def verify(path, expected, verbose): def verify(path, expected, verbose):
"""Check if the sha256 sum of the given path is valid""" """Check if the sha256 sum of the given path is valid"""
if verbose: if verbose:
print("verifying", path) print("verifying", path, file=sys.stderr)
with open(path, "rb") as source: with open(path, "rb") as source:
found = hashlib.sha256(source.read()).hexdigest() found = hashlib.sha256(source.read()).hexdigest()
verified = found == expected verified = found == expected
if not verified: if not verified:
print("invalid checksum:\n" print("invalid checksum:\n"
" found: {}\n" " found: {}\n"
" expected: {}".format(found, expected)) " expected: {}".format(found, expected), file=sys.stderr)
return verified return verified
def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
"""Unpack the given tarball file""" """Unpack the given tarball file"""
print("extracting", tarball) print("extracting", tarball, file=sys.stderr)
fname = os.path.basename(tarball).replace(tarball_suffix, "") fname = os.path.basename(tarball).replace(tarball_suffix, "")
with contextlib.closing(tarfile.open(tarball)) as tar: with contextlib.closing(tarfile.open(tarball)) as tar:
for member in tar.getnames(): for member in tar.getnames():
@ -141,7 +141,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
dst_path = os.path.join(dst, name) dst_path = os.path.join(dst, name)
if verbose: if verbose:
print(" extracting", member) print(" extracting", member, file=sys.stderr)
tar.extract(member, dst) tar.extract(member, dst)
src_path = os.path.join(dst, member) src_path = os.path.join(dst, member)
if os.path.isdir(src_path) and os.path.exists(dst_path): if os.path.isdir(src_path) and os.path.exists(dst_path):
@ -153,7 +153,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs): def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs):
"""Run a child program in a new process""" """Run a child program in a new process"""
if verbose: if verbose:
print("running: " + ' '.join(args)) print("running: " + ' '.join(args), file=sys.stderr)
sys.stdout.flush() sys.stdout.flush()
# Ensure that the .exe is used on Windows just in case a Linux ELF has been # Ensure that the .exe is used on Windows just in case a Linux ELF has been
# compiled in the same directory. # compiled in the same directory.
@ -193,8 +193,8 @@ def require(cmd, exit=True, exception=False):
if exception: if exception:
raise raise
elif exit: elif exit:
print("error: unable to run `{}`: {}".format(' '.join(cmd), exc)) print("error: unable to run `{}`: {}".format(' '.join(cmd), exc), file=sys.stderr)
print("Please make sure it's installed and in the path.") print("Please make sure it's installed and in the path.", file=sys.stderr)
sys.exit(1) sys.exit(1)
return None return None
@ -218,8 +218,8 @@ def default_build_triple(verbose):
if sys.platform == 'darwin': if sys.platform == 'darwin':
if verbose: if verbose:
print("not using rustc detection as it is unreliable on macOS") print("not using rustc detection as it is unreliable on macOS", file=sys.stderr)
print("falling back to auto-detect") print("falling back to auto-detect", file=sys.stderr)
else: else:
try: try:
version = subprocess.check_output(["rustc", "--version", "--verbose"], version = subprocess.check_output(["rustc", "--version", "--verbose"],
@ -228,12 +228,14 @@ def default_build_triple(verbose):
host = next(x for x in version.split('\n') if x.startswith("host: ")) host = next(x for x in version.split('\n') if x.startswith("host: "))
triple = host.split("host: ")[1] triple = host.split("host: ")[1]
if verbose: if verbose:
print("detected default triple {} from pre-installed rustc".format(triple)) print("detected default triple {} from pre-installed rustc".format(triple),
file=sys.stderr)
return triple return triple
except Exception as e: except Exception as e:
if verbose: if verbose:
print("pre-installed rustc not detected: {}".format(e)) print("pre-installed rustc not detected: {}".format(e),
print("falling back to auto-detect") file=sys.stderr)
print("falling back to auto-detect", file=sys.stderr)
required = not platform_is_win32() required = not platform_is_win32()
ostype = require(["uname", "-s"], exit=required) ostype = require(["uname", "-s"], exit=required)
@ -545,7 +547,7 @@ class RustBuild(object):
answer = self._should_fix_bins_and_dylibs = get_answer() answer = self._should_fix_bins_and_dylibs = get_answer()
if answer: if answer:
print("info: You seem to be using Nix.") print("info: You seem to be using Nix.", file=sys.stderr)
return answer return answer
def fix_bin_or_dylib(self, fname): def fix_bin_or_dylib(self, fname):
@ -558,7 +560,7 @@ class RustBuild(object):
Please see https://nixos.org/patchelf.html for more information Please see https://nixos.org/patchelf.html for more information
""" """
assert self._should_fix_bins_and_dylibs is True assert self._should_fix_bins_and_dylibs is True
print("attempting to patch", fname) print("attempting to patch", fname, file=sys.stderr)
# Only build `.nix-deps` once. # Only build `.nix-deps` once.
nix_deps_dir = self.nix_deps_dir nix_deps_dir = self.nix_deps_dir
@ -591,7 +593,7 @@ class RustBuild(object):
"nix-build", "-E", nix_expr, "-o", nix_deps_dir, "nix-build", "-E", nix_expr, "-o", nix_deps_dir,
]) ])
except subprocess.CalledProcessError as reason: except subprocess.CalledProcessError as reason:
print("warning: failed to call nix-build:", reason) print("warning: failed to call nix-build:", reason, file=sys.stderr)
return return
self.nix_deps_dir = nix_deps_dir self.nix_deps_dir = nix_deps_dir
@ -611,7 +613,7 @@ class RustBuild(object):
try: try:
subprocess.check_output([patchelf] + patchelf_args + [fname]) subprocess.check_output([patchelf] + patchelf_args + [fname])
except subprocess.CalledProcessError as reason: except subprocess.CalledProcessError as reason:
print("warning: failed to call patchelf:", reason) print("warning: failed to call patchelf:", reason, file=sys.stderr)
return return
def rustc_stamp(self): def rustc_stamp(self):
@ -755,7 +757,7 @@ class RustBuild(object):
if "GITHUB_ACTIONS" in env: if "GITHUB_ACTIONS" in env:
print("::group::Building bootstrap") print("::group::Building bootstrap")
else: else:
print("Building bootstrap") print("Building bootstrap", file=sys.stderr)
build_dir = os.path.join(self.build_dir, "bootstrap") build_dir = os.path.join(self.build_dir, "bootstrap")
if self.clean and os.path.exists(build_dir): if self.clean and os.path.exists(build_dir):
shutil.rmtree(build_dir) shutil.rmtree(build_dir)
@ -849,9 +851,12 @@ class RustBuild(object):
if 'SUDO_USER' in os.environ and not self.use_vendored_sources: if 'SUDO_USER' in os.environ and not self.use_vendored_sources:
if os.getuid() == 0: if os.getuid() == 0:
self.use_vendored_sources = True self.use_vendored_sources = True
print('info: looks like you\'re trying to run this command as root') print('info: looks like you\'re trying to run this command as root',
print(' and so in order to preserve your $HOME this will now') file=sys.stderr)
print(' use vendored sources by default.') print(' and so in order to preserve your $HOME this will now',
file=sys.stderr)
print(' use vendored sources by default.',
file=sys.stderr)
cargo_dir = os.path.join(self.rust_root, '.cargo') cargo_dir = os.path.join(self.rust_root, '.cargo')
if self.use_vendored_sources: if self.use_vendored_sources:
@ -861,14 +866,18 @@ class RustBuild(object):
"--sync ./src/tools/rust-analyzer/Cargo.toml " \ "--sync ./src/tools/rust-analyzer/Cargo.toml " \
"--sync ./compiler/rustc_codegen_cranelift/Cargo.toml " \ "--sync ./compiler/rustc_codegen_cranelift/Cargo.toml " \
"--sync ./src/bootstrap/Cargo.toml " "--sync ./src/bootstrap/Cargo.toml "
print('error: vendoring required, but vendor directory does not exist.') print('error: vendoring required, but vendor directory does not exist.',
file=sys.stderr)
print(' Run `cargo vendor {}` to initialize the ' print(' Run `cargo vendor {}` to initialize the '
'vendor directory.'.format(sync_dirs)) 'vendor directory.'.format(sync_dirs),
print('Alternatively, use the pre-vendored `rustc-src` dist component.') file=sys.stderr)
print('Alternatively, use the pre-vendored `rustc-src` dist component.',
file=sys.stderr)
raise Exception("{} not found".format(vendor_dir)) raise Exception("{} not found".format(vendor_dir))
if not os.path.exists(cargo_dir): if not os.path.exists(cargo_dir):
print('error: vendoring required, but .cargo/config does not exist.') print('error: vendoring required, but .cargo/config does not exist.',
file=sys.stderr)
raise Exception("{} not found".format(cargo_dir)) raise Exception("{} not found".format(cargo_dir))
else: else:
if os.path.exists(cargo_dir): if os.path.exists(cargo_dir):
@ -978,7 +987,7 @@ def main():
print( print(
"info: Downloading and building bootstrap before processing --help command.\n" "info: Downloading and building bootstrap before processing --help command.\n"
" See src/bootstrap/README.md for help with common commands." " See src/bootstrap/README.md for help with common commands."
) , file=sys.stderr)
exit_code = 0 exit_code = 0
success_word = "successfully" success_word = "successfully"
@ -989,11 +998,12 @@ def main():
exit_code = error.code exit_code = error.code
else: else:
exit_code = 1 exit_code = 1
print(error) print(error, file=sys.stderr)
success_word = "unsuccessfully" success_word = "unsuccessfully"
if not help_triggered: if not help_triggered:
print("Build completed", success_word, "in", format_build_time(time() - start_time)) print("Build completed", success_word, "in", format_build_time(time() - start_time),
file=sys.stderr)
sys.exit(exit_code) sys.exit(exit_code)

View file

@ -1309,7 +1309,7 @@ impl Config {
if config.llvm_from_ci { if config.llvm_from_ci {
let triple = &config.build.triple; let triple = &config.build.triple;
let ci_llvm_bin = config.ci_llvm_root().join("bin"); let ci_llvm_bin = config.ci_llvm_root().join("bin");
let mut build_target = config let build_target = config
.target_config .target_config
.entry(config.build) .entry(config.build)
.or_insert_with(|| Target::from_triple(&triple)); .or_insert_with(|| Target::from_triple(&triple));

View file

@ -112,7 +112,7 @@ impl Config {
is_nixos && !Path::new("/lib").exists() is_nixos && !Path::new("/lib").exists()
}); });
if val { if val {
println!("info: You seem to be using Nix."); eprintln!("info: You seem to be using Nix.");
} }
val val
} }
@ -226,7 +226,7 @@ impl Config {
curl.stdout(Stdio::from(f)); curl.stdout(Stdio::from(f));
if !self.check_run(&mut curl) { if !self.check_run(&mut curl) {
if self.build.contains("windows-msvc") { if self.build.contains("windows-msvc") {
println!("Fallback to PowerShell"); eprintln!("Fallback to PowerShell");
for _ in 0..3 { for _ in 0..3 {
if self.try_run(Command::new("PowerShell.exe").args(&[ if self.try_run(Command::new("PowerShell.exe").args(&[
"/nologo", "/nologo",
@ -239,7 +239,7 @@ impl Config {
])) { ])) {
return; return;
} }
println!("\nspurious failure, trying again"); eprintln!("\nspurious failure, trying again");
} }
} }
if !help_on_error.is_empty() { if !help_on_error.is_empty() {
@ -250,7 +250,7 @@ impl Config {
} }
fn unpack(&self, tarball: &Path, dst: &Path, pattern: &str) { fn unpack(&self, tarball: &Path, dst: &Path, pattern: &str) {
println!("extracting {} to {}", tarball.display(), dst.display()); eprintln!("extracting {} to {}", tarball.display(), dst.display());
if !dst.exists() { if !dst.exists() {
t!(fs::create_dir_all(dst)); t!(fs::create_dir_all(dst));
} }
@ -541,7 +541,18 @@ impl Config {
None None
}; };
self.download_file(&format!("{base_url}/{url}"), &tarball, ""); let mut help_on_error = "";
if destination == "ci-rustc" {
help_on_error = "error: failed to download pre-built rustc from CI
note: old builds get deleted after a certain time
help: if trying to compile an old commit of rustc, disable `download-rustc` in config.toml:
[rust]
download-rustc = false
";
}
self.download_file(&format!("{base_url}/{url}"), &tarball, help_on_error);
if let Some(sha256) = checksum { if let Some(sha256) = checksum {
if !self.verify(&tarball, sha256) { if !self.verify(&tarball, sha256) {
panic!("failed to verify {}", tarball.display()); panic!("failed to verify {}", tarball.display());

View file

@ -1529,7 +1529,9 @@ fn maybe_expand_private_type_alias<'tcx>(
let Res::Def(DefKind::TyAlias, def_id) = path.res else { return None }; let Res::Def(DefKind::TyAlias, def_id) = path.res else { return None };
// Substitute private type aliases // Substitute private type aliases
let def_id = def_id.as_local()?; let def_id = def_id.as_local()?;
let alias = if !cx.cache.effective_visibilities.is_exported(cx.tcx, def_id.to_def_id()) { let alias = if !cx.cache.effective_visibilities.is_exported(cx.tcx, def_id.to_def_id())
&& !cx.current_type_aliases.contains_key(&def_id.to_def_id())
{
&cx.tcx.hir().expect_item(def_id).kind &cx.tcx.hir().expect_item(def_id).kind
} else { } else {
return None; return None;
@ -1609,7 +1611,7 @@ fn maybe_expand_private_type_alias<'tcx>(
} }
} }
Some(cx.enter_alias(substs, |cx| clean_ty(ty, cx))) Some(cx.enter_alias(substs, def_id.to_def_id(), |cx| clean_ty(ty, cx)))
} }
pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type { pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type {
@ -1700,7 +1702,7 @@ fn normalize<'tcx>(
pub(crate) fn clean_middle_ty<'tcx>( pub(crate) fn clean_middle_ty<'tcx>(
bound_ty: ty::Binder<'tcx, Ty<'tcx>>, bound_ty: ty::Binder<'tcx, Ty<'tcx>>,
cx: &mut DocContext<'tcx>, cx: &mut DocContext<'tcx>,
def_id: Option<DefId>, parent_def_id: Option<DefId>,
) -> Type { ) -> Type {
let bound_ty = normalize(cx, bound_ty).unwrap_or(bound_ty); let bound_ty = normalize(cx, bound_ty).unwrap_or(bound_ty);
match *bound_ty.skip_binder().kind() { match *bound_ty.skip_binder().kind() {
@ -1830,7 +1832,9 @@ pub(crate) fn clean_middle_ty<'tcx>(
Tuple(t.iter().map(|t| clean_middle_ty(bound_ty.rebind(t), cx, None)).collect()) Tuple(t.iter().map(|t| clean_middle_ty(bound_ty.rebind(t), cx, None)).collect())
} }
ty::Alias(ty::Projection, ref data) => clean_projection(bound_ty.rebind(*data), cx, def_id), ty::Alias(ty::Projection, ref data) => {
clean_projection(bound_ty.rebind(*data), cx, parent_def_id)
}
ty::Param(ref p) => { ty::Param(ref p) => {
if let Some(bounds) = cx.impl_trait_bounds.remove(&p.index.into()) { if let Some(bounds) = cx.impl_trait_bounds.remove(&p.index.into()) {
@ -1841,15 +1845,30 @@ pub(crate) fn clean_middle_ty<'tcx>(
} }
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => { ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`, // If it's already in the same alias, don't get an infinite loop.
// by looking up the bounds associated with the def_id. if cx.current_type_aliases.contains_key(&def_id) {
let bounds = cx let path =
.tcx external_path(cx, def_id, false, ThinVec::new(), bound_ty.rebind(substs));
.explicit_item_bounds(def_id) Type::Path { path }
.subst_iter_copied(cx.tcx, substs) } else {
.map(|(bound, _)| bound) *cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
.collect::<Vec<_>>(); // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
clean_middle_opaque_bounds(cx, bounds) // by looking up the bounds associated with the def_id.
let bounds = cx
.tcx
.explicit_item_bounds(def_id)
.subst_iter_copied(cx.tcx, substs)
.map(|(bound, _)| bound)
.collect::<Vec<_>>();
let ty = clean_middle_opaque_bounds(cx, bounds);
if let Some(count) = cx.current_type_aliases.get_mut(&def_id) {
*count -= 1;
if *count == 0 {
cx.current_type_aliases.remove(&def_id);
}
}
ty
}
} }
ty::Closure(..) => panic!("Closure"), ty::Closure(..) => panic!("Closure"),
@ -2229,13 +2248,17 @@ fn clean_maybe_renamed_item<'tcx>(
generics: clean_generics(ty.generics, cx), generics: clean_generics(ty.generics, cx),
}), }),
ItemKind::TyAlias(hir_ty, generics) => { ItemKind::TyAlias(hir_ty, generics) => {
*cx.current_type_aliases.entry(def_id).or_insert(0) += 1;
let rustdoc_ty = clean_ty(hir_ty, cx); let rustdoc_ty = clean_ty(hir_ty, cx);
let ty = clean_middle_ty(ty::Binder::dummy(hir_ty_to_ty(cx.tcx, hir_ty)), cx, None); let ty = clean_middle_ty(ty::Binder::dummy(hir_ty_to_ty(cx.tcx, hir_ty)), cx, None);
TypedefItem(Box::new(Typedef { let generics = clean_generics(generics, cx);
type_: rustdoc_ty, if let Some(count) = cx.current_type_aliases.get_mut(&def_id) {
generics: clean_generics(generics, cx), *count -= 1;
item_type: Some(ty), if *count == 0 {
})) cx.current_type_aliases.remove(&def_id);
}
}
TypedefItem(Box::new(Typedef { type_: rustdoc_ty, generics, item_type: Some(ty) }))
} }
ItemKind::Enum(ref def, generics) => EnumItem(Enum { ItemKind::Enum(ref def, generics) => EnumItem(Enum {
variants: def.variants.iter().map(|v| clean_variant(v, cx)).collect(), variants: def.variants.iter().map(|v| clean_variant(v, cx)).collect(),

View file

@ -46,6 +46,7 @@ pub(crate) struct DocContext<'tcx> {
// for expanding type aliases at the HIR level: // for expanding type aliases at the HIR level:
/// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const /// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const
pub(crate) substs: DefIdMap<clean::SubstParam>, pub(crate) substs: DefIdMap<clean::SubstParam>,
pub(crate) current_type_aliases: DefIdMap<usize>,
/// Table synthetic type parameter for `impl Trait` in argument position -> bounds /// Table synthetic type parameter for `impl Trait` in argument position -> bounds
pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>, pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>,
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`. /// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
@ -82,13 +83,25 @@ impl<'tcx> DocContext<'tcx> {
/// Call the closure with the given parameters set as /// Call the closure with the given parameters set as
/// the substitutions for a type alias' RHS. /// the substitutions for a type alias' RHS.
pub(crate) fn enter_alias<F, R>(&mut self, substs: DefIdMap<clean::SubstParam>, f: F) -> R pub(crate) fn enter_alias<F, R>(
&mut self,
substs: DefIdMap<clean::SubstParam>,
def_id: DefId,
f: F,
) -> R
where where
F: FnOnce(&mut Self) -> R, F: FnOnce(&mut Self) -> R,
{ {
let old_substs = mem::replace(&mut self.substs, substs); let old_substs = mem::replace(&mut self.substs, substs);
*self.current_type_aliases.entry(def_id).or_insert(0) += 1;
let r = f(self); let r = f(self);
self.substs = old_substs; self.substs = old_substs;
if let Some(count) = self.current_type_aliases.get_mut(&def_id) {
*count -= 1;
if *count == 0 {
self.current_type_aliases.remove(&def_id);
}
}
r r
} }
@ -327,6 +340,7 @@ pub(crate) fn run_global_ctxt(
external_traits: Default::default(), external_traits: Default::default(),
active_extern_traits: Default::default(), active_extern_traits: Default::default(),
substs: Default::default(), substs: Default::default(),
current_type_aliases: Default::default(),
impl_trait_bounds: Default::default(), impl_trait_bounds: Default::default(),
generated_synthetics: Default::default(), generated_synthetics: Default::default(),
auto_traits, auto_traits,

View file

@ -1,5 +1,4 @@
// unit-test // unit-test: ConstProp
// compile-flags: -O -Zmir-opt-level=4
// EMIT_MIR mult_by_zero.test.ConstProp.diff // EMIT_MIR mult_by_zero.test.ConstProp.diff
fn test(x : i32) -> i32 { fn test(x : i32) -> i32 {

View file

@ -7,8 +7,11 @@
let mut _2: i32; // in scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 let mut _2: i32; // in scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4
bb0: { bb0: {
- _0 = Mul(_1, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 StorageLive(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4
_2 = _1; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4
- _0 = Mul(move _2, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8
+ _0 = const 0_i32; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + _0 = const 0_i32; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8
StorageDead(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:7: +1:8
return; // scope 0 at $DIR/mult_by_zero.rs:+2:2: +2:2 return; // scope 0 at $DIR/mult_by_zero.rs:+2:2: +2:2
} }
} }

View file

@ -19,6 +19,7 @@
StorageLive(_2); // scope 1 at $DIR/mutable_variable.rs:+3:9: +3:10 StorageLive(_2); // scope 1 at $DIR/mutable_variable.rs:+3:9: +3:10
- _2 = _1; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 - _2 = _1; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14
+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14
_0 = const (); // scope 0 at $DIR/mutable_variable.rs:+0:11: +4:2
StorageDead(_2); // scope 1 at $DIR/mutable_variable.rs:+4:1: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/mutable_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable.rs:+4:1: +4:2
return; // scope 0 at $DIR/mutable_variable.rs:+4:2: +4:2 return; // scope 0 at $DIR/mutable_variable.rs:+4:2: +4:2

View file

@ -1,5 +1,4 @@
// unit-test // unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR mutable_variable.main.ConstProp.diff // EMIT_MIR mutable_variable.main.ConstProp.diff
fn main() { fn main() {

View file

@ -3,27 +3,26 @@
fn main() -> () { fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11 let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11
let mut _3: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
let mut _4: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
scope 1 { scope 1 {
debug x => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
let _1: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 let _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
let _2: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
scope 2 { scope 2 {
debug y => (i32, i32){ .0 => _3, .1 => _2, }; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
} }
} }
bb0: { bb0: {
StorageLive(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
_3 = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - _1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25
_4 = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 + _1 = const (42_i32, 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25
_4 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 (_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13
StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
- _2 = _4; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 - _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14
+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 + _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14
_0 = const (); // scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +4:2
StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2
StorageDead(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2
return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2 return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2
} }
} }

View file

@ -1,5 +1,4 @@
// unit-test // unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff // EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff
fn main() { fn main() {

View file

@ -9,10 +9,9 @@
let _2: &mut (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 let _2: &mut (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10
scope 2 { scope 2 {
debug z => _2; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 debug z => _2; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10
let _3: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 let _3: (i32, i32); // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
let _4: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
scope 3 { scope 3 {
debug y => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 debug y => _3; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
} }
} }
} }
@ -24,11 +23,9 @@
_2 = &mut _1; // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:13: +2:19 _2 = &mut _1; // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:13: +2:19
((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13 ((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13
StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
StorageLive(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 _3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14
_3 = (_1.0: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+0:11: +5:2
_4 = (_1.1: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14
StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
StorageDead(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
return; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:2: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:2: +5:2

View file

@ -1,5 +1,4 @@
// unit-test // unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff // EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff
fn main() { fn main() {

View file

@ -16,7 +16,7 @@
StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14 StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14
_1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:29: +1:34 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:29: +1:34
// mir::Constant // mir::Constant
// + span: $DIR/mutable_variable_aggregate_partial_read.rs:7:29: 7:32 // + span: $DIR/mutable_variable_aggregate_partial_read.rs:6:29: 6:32
// + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(<ZST>) } // + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(<ZST>) }
} }
@ -26,6 +26,7 @@
StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10 StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10
- _2 = (_1.1: i32); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 - _2 = (_1.1: i32); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16
+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16
_0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+0:11: +5:2
StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2
StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2
return; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:2: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:2: +5:2

View file

@ -1,6 +1,5 @@
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// unit-test // unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff // EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff
fn main() { fn main() {

View file

@ -4,34 +4,39 @@
fn main() -> () { fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +0:11 let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +0:11
let mut _1: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 let mut _1: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14
let mut _2: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 let _2: (); // in scope 0 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6
let mut _3: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 let mut _3: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
let mut _4: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
scope 1 { scope 1 {
debug x => _1; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 debug x => _1; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14
let _4: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 let _5: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10
scope 2 { scope 2 {
} }
scope 3 { scope 3 {
debug y => _4; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 debug y => _5; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10
} }
} }
bb0: { bb0: {
StorageLive(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 StorageLive(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14
_1 = const 42_u32; // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:17: +1:19 _1 = const 42_u32; // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:17: +1:19
StorageLive(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 StorageLive(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6
StorageLive(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 StorageLive(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
_3 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 StorageLive(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
_4 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
// mir::Constant // mir::Constant
// + span: $DIR/mutable_variable_no_prop.rs:10:13: 10:19 // + span: $DIR/mutable_variable_no_prop.rs:9:13: 9:19
// + literal: Const { ty: *mut u32, val: Value(Scalar(alloc1)) } // + literal: Const { ty: *mut u32, val: Value(Scalar(alloc1)) }
_2 = (*_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 _3 = (*_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19
_1 = move _2; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 _1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19
StorageDead(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19
StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 StorageDead(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20
StorageLive(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 _2 = const (); // scope 2 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6
_4 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 StorageDead(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+4:5: +4:6
StorageDead(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 StorageLive(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10
_5 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14
_0 = const (); // scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +6:2
StorageDead(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2
StorageDead(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2
return; // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:2: +6:2 return; // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:2: +6:2
} }

View file

@ -1,5 +1,4 @@
// unit-test // unit-test: ConstProp
// compile-flags: -O
static mut STATIC: u32 = 0x42424242; static mut STATIC: u32 = 0x42424242;

View file

@ -4,17 +4,16 @@
fn main() -> () { fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +0:11 let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +0:11
let _1: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 let _1: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10
let mut _2: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 let mut _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
scope 1 { scope 1 {
debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10
let mut _5: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
let mut _6: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
scope 2 { scope 2 {
debug x => (i32, i32){ .0 => _5, .1 => _6, }; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 debug x => _2; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
let _3: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
scope 3 { scope 3 {
debug y => _3; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 debug y => _4; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
let _4: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 let _5: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
scope 4 { scope 4 {
debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
} }
@ -26,22 +25,27 @@
StorageLive(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 StorageLive(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10
_1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:13: +1:18 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:13: +1:18
// mir::Constant // mir::Constant
// + span: $DIR/mutable_variable_unprop_assign.rs:7:13: 7:16 // + span: $DIR/mutable_variable_unprop_assign.rs:6:13: 6:16
// + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) } // + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) }
} }
bb1: { bb1: {
StorageLive(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
_5 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - _2 = (const 1_i32, const 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35
_6 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + _2 = const (1_i32, 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35
StorageLive(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
_2 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 _3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
_6 = move _2; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 (_2.1: i32) = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12
StorageDead(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 StorageLive(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
_3 = _6; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 _4 = (_2.1: i32); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16
StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
StorageDead(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - _5 = (_2.0: i32); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16
+ _5 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16
_0 = const (); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +6:2
StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
StorageDead(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2 return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2
} }

View file

@ -1,6 +1,5 @@
// ignore-wasm32 compiled with panic=abort by default // ignore-wasm32 compiled with panic=abort by default
// unit-test // unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff // EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff
fn main() { fn main() {

View file

@ -33,6 +33,7 @@
StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11
- _4 = OffsetOf(Alpha, [2, 1]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:36 - _4 = OffsetOf(Alpha, [2, 1]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:36
+ _4 = const 3_usize; // scope 3 at $DIR/offset_of.rs:+4:14: +4:36 + _4 = const 3_usize; // scope 3 at $DIR/offset_of.rs:+4:14: +4:36
_0 = const (); // scope 0 at $DIR/offset_of.rs:+0:15: +5:2
StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2
StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2
StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2

View file

@ -29,6 +29,7 @@
_3 = OffsetOf(Delta<T>, [1]); // scope 2 at $DIR/offset_of.rs:+3:14: +3:37 _3 = OffsetOf(Delta<T>, [1]); // scope 2 at $DIR/offset_of.rs:+3:14: +3:37
StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11
_4 = OffsetOf(Delta<T>, [2]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:37 _4 = OffsetOf(Delta<T>, [2]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:37
_0 = const (); // scope 0 at $DIR/offset_of.rs:+0:17: +5:2
StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2
StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2
StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2

View file

@ -1,5 +1,4 @@
// unit-test // unit-test: ConstProp
// compile-flags: -O
#![feature(offset_of)] #![feature(offset_of)]

View file

@ -18,7 +18,7 @@
StorageLive(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 StorageLive(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16
_3 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 _3 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16
// mir::Constant // mir::Constant
// + span: $DIR/read_immutable_static.rs:8:13: 8:16 // + span: $DIR/read_immutable_static.rs:7:13: 7:16
// + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) }
- _2 = (*_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 - _2 = (*_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16
+ _2 = const 2_u8; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 + _2 = const 2_u8; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16
@ -26,7 +26,7 @@
StorageLive(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 StorageLive(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22
_5 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 _5 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22
// mir::Constant // mir::Constant
// + span: $DIR/read_immutable_static.rs:8:19: 8:22 // + span: $DIR/read_immutable_static.rs:7:19: 7:22
// + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) }
- _4 = (*_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 - _4 = (*_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22
- _1 = Add(move _2, move _4); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:22 - _1 = Add(move _2, move _4); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:22
@ -36,6 +36,7 @@
StorageDead(_2); // scope 0 at $DIR/read_immutable_static.rs:+1:21: +1:22 StorageDead(_2); // scope 0 at $DIR/read_immutable_static.rs:+1:21: +1:22
StorageDead(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 StorageDead(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23
StorageDead(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23
_0 = const (); // scope 0 at $DIR/read_immutable_static.rs:+0:11: +2:2
StorageDead(_1); // scope 0 at $DIR/read_immutable_static.rs:+2:1: +2:2 StorageDead(_1); // scope 0 at $DIR/read_immutable_static.rs:+2:1: +2:2
return; // scope 0 at $DIR/read_immutable_static.rs:+2:2: +2:2 return; // scope 0 at $DIR/read_immutable_static.rs:+2:2: +2:2
} }

View file

@ -1,5 +1,4 @@
// unit-test // unit-test: ConstProp
// compile-flags: -O
static FOO: u8 = 2; static FOO: u8 = 2;

View file

@ -0,0 +1,12 @@
type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
//~^ ERROR cycle detected when expanding type alias
fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
Box::new(i)
}
fn main() {
let meh = 42;
let muh = 42;
assert!(bar(&meh) == bar(&muh));
}

View file

@ -0,0 +1,25 @@
error[E0391]: cycle detected when expanding type alias `Bar`
--> $DIR/issue-110629-private-type-cycle-dyn.rs:1:38
|
LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
| ^^^^^^^^^^^
|
= note: ...which immediately requires expanding type alias `Bar` again
= note: type aliases cannot be recursive
= help: consider using a struct, enum, or union instead to break the cycle
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
note: cycle used when collecting item types in top-level module
--> $DIR/issue-110629-private-type-cycle-dyn.rs:1:1
|
LL | / type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
LL | |
LL | |
LL | | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
... |
LL | | assert!(bar(&meh) == bar(&muh));
LL | | }
| |_^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.

View file

@ -0,0 +1,15 @@
// check-pass
#![feature(type_alias_impl_trait)]
type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug;
fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
i
}
fn main() {
let meh = 42;
let muh = 42;
assert_eq!(bar(&meh), bar(&muh));
}

View file

@ -0,0 +1,19 @@
// compile-flags: --document-private-items
#![feature(type_alias_impl_trait)]
type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug;
// @has issue_110629_private_type_cycle/type.Bar.html
// @has - '//pre[@class="rust item-decl"]' \
// "pub(crate) type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + Debug;"
fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
i
}
fn main() {
let meh = 42;
let muh = 42;
assert_eq!(bar(&meh), bar(&muh));
}