Regression tests for issue #54477.
At some point someone may want to revisit PR #53564
it would be really good to have regression tests for #54477 before that happens. :)
. src/ci/docker/x86_64-gnu-tools/repo.sh;
commit_toolstate_change "$MESSAGE_FILE" "$TRAVIS_BUILD_DIR/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "$MESSAGE_FILE" "$TOOLSTATE_REPO_ACCESS_TOKEN";
-env:
- global:
- - SCCACHE_BUCKET=rust-lang-ci-sccache2
- - SCCACHE_REGION=us-west-1
- - AWS_ACCESS_KEY_ID=AKIAJAMV3QAMMA6AXHFQ
- # AWS_SECRET_ACCESS_KEY=...
- - secure: "j96XxTVOSUf4s4r4htIxn/fvIa5DWbMgLqWl7r8z2QfgUwscmkMXAwXuFNc7s7bGTpV/+CgDiMFFM6BAFLGKutytIF6oA02s9b+usQYnM0th7YQ2AIgm9GtMTJCJp4AoyfFmh8F2faUICBZlfVLUJ34udHEe35vOklix+0k4WDo="
- # TOOLSTATE_REPO_ACCESS_TOKEN=...
- - secure: "ESfcXqv4N2VMhqi2iIyw6da9VrsA78I4iR1asouCaq4hzTTrkB4WNRrfURy6xg72gQ4nMhtRJbB0/2jmc9Cu1+g2CzXtyiL223aJ5CKrXdcvbitopQSDfp07dMWm+UED+hNFEanpErKAeU/6FM3A+J+60PMk8MCF1h9tqNRISJw="
-
before_install:
- # We'll use the AWS cli to download/upload cached docker layers, so install
- # that here.
- - if [ "$TRAVIS_OS_NAME" = linux ]; then
- pip install --user awscli;
- export PATH=$PATH:$HOME/.local/bin;
- fi
+ # We'll use the AWS cli to download/upload cached docker layers as well as
+ # push our deployments, so download that here.
+ - pip install --user awscli; export PATH=$PATH:$HOME/.local/bin
- mkdir -p $HOME/rustsrc
# FIXME(#46924): these two commands are required to enable IPv6,
# they shouldn't exist, please revert once more official solutions appeared.
echo "#### Build successful; Disk usage after running script:";
df -h;
du . | sort -nr | head -n100
+ - >
+ if [ "$DEPLOY$DEPLOY_ALT" == "1" ]; then
+ mkdir -p deploy/$TRAVIS_COMMIT;
+ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
+ rm -rf build/dist/doc &&
+ cp -r build/dist/* deploy/$TRAVIS_COMMIT;
+ else
+ rm -rf obj/build/dist/doc &&
+ cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT;
+ fi;
+ ls -la deploy/$TRAVIS_COMMIT;
+ deploy_dir=rustc-builds;
+ if [ "$DEPLOY_ALT" == "1" ]; then
+ deploy_dir=rustc-builds-alt;
+ fi;
+ travis_retry aws s3 cp --no-progress --recursive --acl public-read ./deploy s3://rust-lang-ci2/$deploy_dir
+ fi
after_failure:
- >
notifications:
email: false
-
-before_deploy:
- - mkdir -p deploy/$TRAVIS_COMMIT
- - >
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
- rm -rf build/dist/doc &&
- cp -r build/dist/* deploy/$TRAVIS_COMMIT;
- else
- rm -rf obj/build/dist/doc &&
- cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT;
- fi
- - ls -la deploy/$TRAVIS_COMMIT
-
-deploy:
- - provider: s3
- bucket: rust-lang-ci2
- skip_cleanup: true
- local_dir: deploy
- upload_dir: rustc-builds
- acl: public_read
- region: us-west-1
- access_key_id: AKIAJVBODR3IA4O72THQ
- secret_access_key:
- secure: "kUGd3t7JcVWFESgIlzvsM8viZgCA9Encs3creW0xLJaLSeI1iVjlJK4h/2/nO6y224AFrh/GUfsNr4/4AlxPuYb8OU5oC5Lv+Ff2JiRDYtuNpyQSKAQp+bRYytWMtrmhja91h118Mbm90cUfcLPwkdiINgJNTXhPKg5Cqu3VYn0="
- on:
- branch: auto
- condition: $DEPLOY = 1
-
- # this is the same as the above deployment provider except that it uploads to
- # a slightly different directory and has a different trigger
- - provider: s3
- bucket: rust-lang-ci2
- skip_cleanup: true
- local_dir: deploy
- upload_dir: rustc-builds-alt
- acl: public_read
- region: us-west-1
- access_key_id: AKIAJVBODR3IA4O72THQ
- secret_access_key:
- secure: "kUGd3t7JcVWFESgIlzvsM8viZgCA9Encs3creW0xLJaLSeI1iVjlJK4h/2/nO6y224AFrh/GUfsNr4/4AlxPuYb8OU5oC5Lv+Ff2JiRDYtuNpyQSKAQp+bRYytWMtrmhja91h118Mbm90cUfcLPwkdiINgJNTXhPKg5Cqu3VYn0="
- on:
- branch: auto
- condition: $DEPLOY_ALT = 1
-
- # These two providers are the same as the two above, except deploy on the
- # try branch. Travis does not appear to provide a way to use "or" in these
- # conditions.
- - provider: s3
- bucket: rust-lang-ci2
- skip_cleanup: true
- local_dir: deploy
- upload_dir: rustc-builds
- acl: public_read
- region: us-west-1
- access_key_id: AKIAJVBODR3IA4O72THQ
- secret_access_key:
- secure: "kUGd3t7JcVWFESgIlzvsM8viZgCA9Encs3creW0xLJaLSeI1iVjlJK4h/2/nO6y224AFrh/GUfsNr4/4AlxPuYb8OU5oC5Lv+Ff2JiRDYtuNpyQSKAQp+bRYytWMtrmhja91h118Mbm90cUfcLPwkdiINgJNTXhPKg5Cqu3VYn0="
- on:
- branch: try
- condition: $DEPLOY = 1
-
- - provider: s3
- bucket: rust-lang-ci2
- skip_cleanup: true
- local_dir: deploy
- upload_dir: rustc-builds-alt
- acl: public_read
- region: us-west-1
- access_key_id: AKIAJVBODR3IA4O72THQ
- secret_access_key:
- secure: "kUGd3t7JcVWFESgIlzvsM8viZgCA9Encs3creW0xLJaLSeI1iVjlJK4h/2/nO6y224AFrh/GUfsNr4/4AlxPuYb8OU5oC5Lv+Ff2JiRDYtuNpyQSKAQp+bRYytWMtrmhja91h118Mbm90cUfcLPwkdiINgJNTXhPKg5Cqu3VYn0="
- on:
- branch: try
- condition: $DEPLOY_ALT = 1
environment:
- SCCACHE_BUCKET: rust-lang-ci-sccache2
- SCCACHE_REGION: us-west-1
- AWS_ACCESS_KEY_ID: AKIAJAMV3QAMMA6AXHFQ
- AWS_SECRET_ACCESS_KEY:
- secure: 7Y+JiquYedOAgnUU26uL0DPzrxmTtR+qIwG6rNKSuWDffqU3vVZxbGXim9QpTO80
SCCACHE_DIGEST: f808afabb4a4eb1d7112bcb3fa6be03b61e93412890c88e177c667eb37f46353d7ec294e559b16f9f4b5e894f2185fe7670a0df15fd064889ecbd80f0c34166c
- TOOLSTATE_REPO_ACCESS_TOKEN:
- secure: gKGlVktr7iuqCoYSxHxDE9ltLOKU0nYDEuQxvWbNxUIW7ri5ppn8L06jQzN0GGzN
# By default schannel checks revocation of certificates unlike some other SSL
# backends, but we've historically had problems on CI where a revocation
deploy:
- provider: S3
- skip_cleanup: true
- access_key_id: AKIAJVBODR3IA4O72THQ
- secret_access_key:
- secure: tQWIE+DJHjXaV4np/3YeETkEmXngtIuIgAO/LYKQaUshGLgN8cBCFGG3cHx5lKLt
+ access_key_id: $(AWS_ACCESS_KEY_ID)
+ secret_access_key: $(AWS_SECRET_ACCESS_KEY)
bucket: rust-lang-ci2
set_public: true
region: us-west-1
# This provider is the same as the one above except that it has a slightly
# different upload directory and a slightly different trigger
- provider: S3
- skip_cleanup: true
- access_key_id: AKIAJVBODR3IA4O72THQ
- secret_access_key:
- secure: tQWIE+DJHjXaV4np/3YeETkEmXngtIuIgAO/LYKQaUshGLgN8cBCFGG3cHx5lKLt
+ access_key_id: $(AWS_ACCESS_KEY_ID)
+ secret_access_key: $(AWS_SECRET_ACCESS_KEY)
bucket: rust-lang-ci2
set_public: true
region: us-west-1
[[package]]
name = "cargo"
-version = "0.32.0"
+version = "0.33.0"
dependencies = [
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bytesize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "crates-io 0.20.0",
+ "crates-io 0.21.0",
"crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy-mini-macro-test 0.2.0",
"clippy_dev 0.0.1",
"clippy_lints 0.0.212",
- "compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiletest_rs 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "compiletest_rs"
-version = "0.3.13"
+version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "crates-io"
-version = "0.20.0"
+version = "0.21.0"
dependencies = [
"curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiletest_rs 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"vergen 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
name = "rls"
version = "0.130.5"
dependencies = [
- "cargo 0.32.0",
+ "cargo 0.33.0",
"cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy_lints 0.0.212",
"crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
-"checksum compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d3064bc712922596dd5ab449fca9261d411893356581fe5297b96aa8f53bb1b8"
+"checksum compiletest_rs 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "75e809f56d6aa9575b67924b0af686c4f4c1380314f47947e235e9ff7fa94bed"
"checksum core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc3532ec724375c7cb7ff0a097b714fde180bb1f6ed2ab27cfcd99ffca873cd2"
"checksum core-foundation-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a3fb15cdbdd9cf8b82d97d0296bb5cd3631bba58d6e31650a002a8e7fb5721f9"
"checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19"
use config::Config;
// The version number
-pub const CFG_RELEASE_NUM: &str = "1.31.0";
+pub const CFG_RELEASE_NUM: &str = "1.32.0";
pub struct GitInfo {
inner: Option<Info>,
"src/jemalloc",
"src/libprofiler_builtins",
"src/stdsimd",
+ "src/libproc_macro",
];
let std_src_dirs_exclude = [
"src/libcompiler_builtins/compiler-rt/test",
-FROM ubuntu:16.04
+FROM ubuntu:18.10
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
+#[cfg(target_pointer_width = "16")]
+const MAXIMUM_ZST_CAPACITY: usize = 1 << (16 - 1); // Largest possible power of two
#[cfg(target_pointer_width = "32")]
const MAXIMUM_ZST_CAPACITY: usize = 1 << (32 - 1); // Largest possible power of two
#[cfg(target_pointer_width = "64")]
#![feature(box_syntax)]
#![feature(cfg_target_has_atomic)]
#![feature(coerce_unsized)]
-#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(core_intrinsics)]
#![feature(custom_attribute)]
#![feature(dropck_eyepatch)]
/// type `T`.
///
/// [get_mut]: #method.get_mut
-#[cfg_attr(all(not(stage0), not(test)), lang = "rc")]
+#[cfg_attr(not(test), lang = "rc")]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Rc<T: ?Sized> {
ptr: NonNull<RcBox<T>>,
/// counting in general.
///
/// [rc_examples]: ../../std/rc/index.html#examples
-#[cfg_attr(all(not(stage0), not(test)), lang = "arc")]
+#[cfg_attr(not(test), lang = "arc")]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Arc<T: ?Sized> {
ptr: NonNull<ArcInner<T>>,
#![feature(allocator_api)]
#![feature(alloc_system)]
#![feature(box_syntax)]
-#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(drain_filter)]
#![feature(exact_size_is_empty)]
#![feature(pattern)]
-Subproject commit 0703bfa72524e01e414477657ca9b64794c5c1c3
+Subproject commit 939cbca6e9d829265d6cf006d3532142a4061cd3
#![feature(doc_spotlight)]
#![feature(extern_types)]
#![feature(fundamental)]
-#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(intrinsics)]
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
/// [alignment]: ./fn.align_of.html
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
-#[cfg_attr(not(stage0), rustc_promotable)]
+#[rustc_promotable]
pub const fn size_of<T>() -> usize {
intrinsics::size_of::<T>()
}
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
-#[cfg_attr(not(stage0), rustc_promotable)]
+#[rustc_promotable]
pub const fn align_of<T>() -> usize {
intrinsics::min_align_of::<T>()
}
#[inline]
#[stable(feature = "needs_drop", since = "1.21.0")]
#[rustc_const_unstable(feature = "const_needs_drop")]
-#[cfg(not(stage0))]
pub const fn needs_drop<T>() -> bool {
intrinsics::needs_drop::<T>()
}
-#[inline]
-#[stable(feature = "needs_drop", since = "1.21.0")]
-#[cfg(stage0)]
-/// Ceci n'est pas la documentation
-pub fn needs_drop<T>() -> bool {
- unsafe { intrinsics::needs_drop::<T>() }
-}
-
/// Creates a value whose bytes are all zero.
///
/// This has the same effect as allocating space with
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- #[cfg_attr(not(stage0), rustc_promotable)]
+ #[rustc_promotable]
pub const fn min_value() -> Self {
!0 ^ ((!0 as $UnsignedT) >> 1) as Self
}
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- #[cfg_attr(not(stage0), rustc_promotable)]
+ #[rustc_promotable]
pub const fn max_value() -> Self {
!Self::min_value()
}
/// ```
#[stable(feature = "inclusive_range_methods", since = "1.27.0")]
#[inline]
- #[cfg_attr(not(stage0), rustc_promotable)]
+ #[rustc_promotable]
pub const fn new(start: Idx, end: Idx) -> Self {
Self { start, end, is_empty: None }
}
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
-#[cfg_attr(not(stage0), rustc_promotable)]
+#[rustc_promotable]
pub const fn null<T>() -> *const T { 0 as *const T }
/// Creates a null mutable raw pointer.
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
-#[cfg_attr(not(stage0), rustc_promotable)]
+#[rustc_promotable]
pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
/// Swaps the values at two mutable locations of the same type, without
#![feature(flt2dec)]
#![feature(fmt_internals)]
#![feature(hashmap_internals)]
-#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(pattern)]
#![feature(range_is_empty)]
#![feature(raw)]
/// ```
#[stable(feature = "duration", since = "1.3.0")]
#[inline]
- #[cfg_attr(not(stage0), rustc_promotable)]
+ #[rustc_promotable]
pub const fn from_secs(secs: u64) -> Duration {
Duration { secs, nanos: 0 }
}
/// ```
#[stable(feature = "duration", since = "1.3.0")]
#[inline]
- #[cfg_attr(not(stage0), rustc_promotable)]
+ #[rustc_promotable]
pub const fn from_millis(millis: u64) -> Duration {
Duration {
secs: millis / MILLIS_PER_SEC,
/// ```
#[stable(feature = "duration_from_micros", since = "1.27.0")]
#[inline]
- #[cfg_attr(not(stage0), rustc_promotable)]
+ #[rustc_promotable]
pub const fn from_micros(micros: u64) -> Duration {
Duration {
secs: micros / MICROS_PER_SEC,
/// ```
#[stable(feature = "duration_extras", since = "1.27.0")]
#[inline]
- #[cfg_attr(not(stage0), rustc_promotable)]
+ #[rustc_promotable]
pub const fn from_nanos(nanos: u64) -> Duration {
Duration {
secs: nanos / (NANOS_PER_SEC as u64),
&mut self,
def: Def,
p: &Path,
- ident: Option<Ident>,
param_mode: ParamMode,
explicit_owner: Option<NodeId>,
) -> hir::Path {
explicit_owner,
)
})
- .chain(ident.map(|ident| hir::PathSegment::from_ident(ident)))
.collect(),
span: p.span,
}
fn lower_path(&mut self, id: NodeId, p: &Path, param_mode: ParamMode) -> hir::Path {
let def = self.expect_full_def(id);
- self.lower_path_extra(def, p, None, param_mode, None)
+ self.lower_path_extra(def, p, param_mode, None)
}
fn lower_path_segment(
self.with_hir_id_owner(new_node_id, |this| {
let new_id = this.lower_node_id(new_node_id);
let path =
- this.lower_path_extra(def, &path, None, ParamMode::Explicit, None);
+ this.lower_path_extra(def, &path, ParamMode::Explicit, None);
let item = hir::ItemKind::Use(P(path), hir::UseKind::Single);
let vis_kind = match vis.node {
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
let id = this.next_id();
+ let mut path = path.clone();
+ for seg in path.segments.iter_mut() {
+ if seg.id.is_some() {
+ seg.id = Some(this.next_id().node_id);
+ }
+ }
hir::VisibilityKind::Restricted {
- path: path.clone(),
+ path,
id: id.node_id,
hir_id: id.hir_id,
}
}
let path =
- P(self.lower_path_extra(ret_def, &path, None, ParamMode::Explicit, None));
+ P(self.lower_path_extra(ret_def, &path, ParamMode::Explicit, None));
hir::ItemKind::Use(path, hir::UseKind::Single)
}
UseTreeKind::Glob => {
// the stability of `use a::{};`, to avoid it showing up as
// a re-export by accident when `pub`, e.g. in documentation.
let def = self.expect_full_def_from_use(id).next().unwrap_or(Def::Err);
- let path = P(self.lower_path_extra(def, &prefix, None, ParamMode::Explicit, None));
+ let path = P(self.lower_path_extra(def, &prefix, ParamMode::Explicit, None));
*vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
hir::ItemKind::Use(path, hir::UseKind::ListStem)
}
path: P(self.lower_path_extra(
def,
path,
- None,
ParamMode::Explicit,
explicit_owner,
)),
};
bug!("inconsistent DepNode for `{}`: \
- current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}) {}",
+ current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}){}",
node_str,
self.definitions
.def_path(self.current_dep_node_owner)
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use rustc_data_structures::sync::Lrc;
-use syntax::source_map::SourceMap;
-use syntax_pos::{BytePos, SourceFile};
-
-#[derive(Clone)]
-struct CacheEntry {
- time_stamp: usize,
- line_number: usize,
- line_start: BytePos,
- line_end: BytePos,
- file: Lrc<SourceFile>,
- file_index: usize,
-}
-
-#[derive(Clone)]
-pub struct CachingSourceMapView<'cm> {
- source_map: &'cm SourceMap,
- line_cache: [CacheEntry; 3],
- time_stamp: usize,
-}
-
-impl<'cm> CachingSourceMapView<'cm> {
- pub fn new(source_map: &'cm SourceMap) -> CachingSourceMapView<'cm> {
- let files = source_map.files();
- let first_file = files[0].clone();
- let entry = CacheEntry {
- time_stamp: 0,
- line_number: 0,
- line_start: BytePos(0),
- line_end: BytePos(0),
- file: first_file,
- file_index: 0,
- };
-
- CachingSourceMapView {
- source_map,
- line_cache: [entry.clone(), entry.clone(), entry],
- time_stamp: 0,
- }
- }
-
- pub fn byte_pos_to_line_and_col(&mut self,
- pos: BytePos)
- -> Option<(Lrc<SourceFile>, usize, BytePos)> {
- self.time_stamp += 1;
-
- // Check if the position is in one of the cached lines
- for cache_entry in self.line_cache.iter_mut() {
- if pos >= cache_entry.line_start && pos < cache_entry.line_end {
- cache_entry.time_stamp = self.time_stamp;
-
- return Some((cache_entry.file.clone(),
- cache_entry.line_number,
- pos - cache_entry.line_start));
- }
- }
-
- // No cache hit ...
- let mut oldest = 0;
- for index in 1 .. self.line_cache.len() {
- if self.line_cache[index].time_stamp < self.line_cache[oldest].time_stamp {
- oldest = index;
- }
- }
-
- let cache_entry = &mut self.line_cache[oldest];
-
- // If the entry doesn't point to the correct file, fix it up
- if pos < cache_entry.file.start_pos || pos >= cache_entry.file.end_pos {
- let file_valid;
- if self.source_map.files().len() > 0 {
- let file_index = self.source_map.lookup_source_file_idx(pos);
- let file = self.source_map.files()[file_index].clone();
-
- if pos >= file.start_pos && pos < file.end_pos {
- cache_entry.file = file;
- cache_entry.file_index = file_index;
- file_valid = true;
- } else {
- file_valid = false;
- }
- } else {
- file_valid = false;
- }
-
- if !file_valid {
- return None;
- }
- }
-
- let line_index = cache_entry.file.lookup_line(pos).unwrap();
- let line_bounds = cache_entry.file.line_bounds(line_index);
-
- cache_entry.line_number = line_index + 1;
- cache_entry.line_start = line_bounds.0;
- cache_entry.line_end = line_bounds.1;
- cache_entry.time_stamp = self.time_stamp;
-
- return Some((cache_entry.file.clone(),
- cache_entry.line_number,
- pos - cache_entry.line_start));
- }
-}
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use rustc_data_structures::sync::Lrc;
+use syntax::source_map::SourceMap;
+use syntax_pos::{BytePos, SourceFile};
+
+#[derive(Clone)]
+struct CacheEntry {
+ time_stamp: usize,
+ line_number: usize,
+ line_start: BytePos,
+ line_end: BytePos,
+ file: Lrc<SourceFile>,
+ file_index: usize,
+}
+
+#[derive(Clone)]
+pub struct CachingSourceMapView<'cm> {
+ source_map: &'cm SourceMap,
+ line_cache: [CacheEntry; 3],
+ time_stamp: usize,
+}
+
+impl<'cm> CachingSourceMapView<'cm> {
+ pub fn new(source_map: &'cm SourceMap) -> CachingSourceMapView<'cm> {
+ let files = source_map.files();
+ let first_file = files[0].clone();
+ let entry = CacheEntry {
+ time_stamp: 0,
+ line_number: 0,
+ line_start: BytePos(0),
+ line_end: BytePos(0),
+ file: first_file,
+ file_index: 0,
+ };
+
+ CachingSourceMapView {
+ source_map,
+ line_cache: [entry.clone(), entry.clone(), entry],
+ time_stamp: 0,
+ }
+ }
+
+ pub fn byte_pos_to_line_and_col(&mut self,
+ pos: BytePos)
+ -> Option<(Lrc<SourceFile>, usize, BytePos)> {
+ self.time_stamp += 1;
+
+ // Check if the position is in one of the cached lines
+ for cache_entry in self.line_cache.iter_mut() {
+ if pos >= cache_entry.line_start && pos < cache_entry.line_end {
+ cache_entry.time_stamp = self.time_stamp;
+
+ return Some((cache_entry.file.clone(),
+ cache_entry.line_number,
+ pos - cache_entry.line_start));
+ }
+ }
+
+ // No cache hit ...
+ let mut oldest = 0;
+ for index in 1 .. self.line_cache.len() {
+ if self.line_cache[index].time_stamp < self.line_cache[oldest].time_stamp {
+ oldest = index;
+ }
+ }
+
+ let cache_entry = &mut self.line_cache[oldest];
+
+ // If the entry doesn't point to the correct file, fix it up
+ if pos < cache_entry.file.start_pos || pos >= cache_entry.file.end_pos {
+ let file_valid;
+ if self.source_map.files().len() > 0 {
+ let file_index = self.source_map.lookup_source_file_idx(pos);
+ let file = self.source_map.files()[file_index].clone();
+
+ if pos >= file.start_pos && pos < file.end_pos {
+ cache_entry.file = file;
+ cache_entry.file_index = file_index;
+ file_valid = true;
+ } else {
+ file_valid = false;
+ }
+ } else {
+ file_valid = false;
+ }
+
+ if !file_valid {
+ return None;
+ }
+ }
+
+ let line_index = cache_entry.file.lookup_line(pos).unwrap();
+ let line_bounds = cache_entry.file.line_bounds(line_index);
+
+ cache_entry.line_number = line_index + 1;
+ cache_entry.line_start = line_bounds.0;
+ cache_entry.line_end = line_bounds.1;
+ cache_entry.time_stamp = self.time_stamp;
+
+ return Some((cache_entry.file.clone(),
+ cache_entry.line_number,
+ pos - cache_entry.line_start));
+ }
+}
//! ICH - Incremental Compilation Hash
crate use rustc_data_structures::fingerprint::Fingerprint;
-pub use self::caching_codemap_view::CachingSourceMapView;
+pub use self::caching_source_map_view::CachingSourceMapView;
pub use self::hcx::{StableHashingContextProvider, StableHashingContext, NodeIdHashingMode,
hash_stable_trait_impls};
-mod caching_codemap_view;
+mod caching_source_map_view;
mod hcx;
mod impls_cstore;
type Node = Node;
type Edge = Edge<'tcx>;
fn nodes(&self) -> dot::Nodes<'_, Node> {
- let mut set = FxHashSet::default();
- for node in self.node_ids.keys() {
- set.insert(*node);
- }
+ let set = self.node_ids.keys().cloned().collect::<FxHashSet<_>>();
debug!("constraint graph has {} nodes", set.len());
set.into_iter().collect()
}
#![feature(box_patterns)]
#![feature(box_syntax)]
-#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![cfg_attr(windows, feature(libc))]
#![feature(step_trait)]
#![feature(integer_atomics)]
#![feature(test)]
-#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(in_band_lifetimes)]
#![feature(macro_at_most_once_rep)]
#![feature(crate_visibility_modifier)]
pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let sess = &tcx.sess;
- let mut fmts = FxHashMap::default();
- for &ty in sess.crate_types.borrow().iter() {
+ let fmts = sess.crate_types.borrow().iter().map(|&ty| {
let linkage = calculate_type(tcx, ty);
verify_ok(tcx, &linkage);
- fmts.insert(ty, linkage);
- }
+ (ty, linkage)
+ }).collect::<FxHashMap<_, _>>();
sess.abort_if_errors();
sess.dependency_formats.set(fmts);
}
pub fn elaborate_trait_refs<'cx, 'gcx, 'tcx>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
- trait_refs: &[ty::PolyTraitRef<'tcx>])
+ trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Elaborator<'cx, 'gcx, 'tcx>
{
- let predicates = trait_refs.iter()
- .map(|trait_ref| trait_ref.to_predicate())
+ let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate())
.collect();
elaborate_predicates(tcx, predicates)
}
}
pub fn transitive_bounds<'cx, 'gcx, 'tcx>(tcx: TyCtxt<'cx, 'gcx, 'tcx>,
- bounds: &[ty::PolyTraitRef<'tcx>])
+ bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
-> Supertraits<'cx, 'gcx, 'tcx>
{
elaborate_trait_refs(tcx, bounds).filter_to_traits()
use session::{CrateDisambiguator, Session};
use std::mem;
use syntax::ast::NodeId;
-use syntax::source_map::{SourceMap, StableFilemapId};
+use syntax::source_map::{SourceMap, StableSourceFileId};
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
use ty;
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
source_map: &'sess SourceMap,
- file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
+ file_index_to_stable_id: FxHashMap<SourceFileIndex, StableSourceFileId>,
// These two fields caches that are populated lazily during decoding.
file_index_to_file: Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
// This type is used only for (de-)serialization.
#[derive(RustcEncodable, RustcDecodable)]
struct Footer {
- file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
+ file_index_to_stable_id: FxHashMap<SourceFileIndex, StableSourceFileId>,
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
query_result_index: EncodedQueryResultIndex,
diagnostics_index: EncodedQueryResultIndex,
tcx.dep_graph.with_ignore(|| {
// Allocate SourceFileIndices
let (file_to_file_index, file_index_to_stable_id) = {
- let mut file_to_file_index = FxHashMap::default();
- let mut file_index_to_stable_id = FxHashMap::default();
+ let files = tcx.sess.source_map().files();
+ let mut file_to_file_index = FxHashMap::with_capacity_and_hasher(
+ files.len(), Default::default());
+ let mut file_index_to_stable_id = FxHashMap::with_capacity_and_hasher(
+ files.len(), Default::default());
- for (index, file) in tcx.sess.source_map().files().iter().enumerate() {
+ for (index, file) in files.iter().enumerate() {
let index = SourceFileIndex(index as u32);
let file_ptr: *const SourceFile = &**file as *const _;
file_to_file_index.insert(file_ptr, index);
- file_index_to_stable_id.insert(index, StableFilemapId::new(&file));
+ file_index_to_stable_id.insert(index, StableSourceFileId::new(&file));
}
(file_to_file_index, file_index_to_stable_id)
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
- file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableFilemapId>,
+ file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableSourceFileId>,
alloc_decoding_session: AllocDecodingSession<'x>,
}
// except according to those terms.
use rustc_data_structures::sync::{RwLock, ReadGuard, MappedReadGuard};
-use std::mem;
/// The `Steal` struct is intended to used as the value for a query.
/// Specifically, we sometimes have queries (*cough* MIR *cough*)
pub fn steal(&self) -> T {
let value_ref = &mut *self.value.try_write().expect("stealing value which is locked");
- let value = mem::replace(value_ref, None);
+ let value = value_ref.take();
value.expect("attempt to read from stolen value")
}
}
use rustc::ich::NodeIdHashingMode;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc::ty::Instance;
-use common::CodegenCx;
+use common::{CodegenCx, C_u64};
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
-use rustc::ty::layout::{self, Align, LayoutOf, PrimitiveExt, Size, TyLayout};
+use rustc::ty::layout::{self, Align, HasDataLayout, Integer, IntegerExt, LayoutOf,
+ PrimitiveExt, Size, TyLayout};
use rustc::session::config;
use rustc::util::nodemap::FxHashMap;
use rustc_fs_util::path2cstr;
unfinished_type: Ty<'tcx>,
unique_type_id: UniqueTypeId,
metadata_stub: &'ll DICompositeType,
+ member_holding_stub: &'ll DICompositeType,
member_description_factory: MemberDescriptionFactory<'ll, 'tcx>,
},
FinalMetadata(&'ll DICompositeType)
unfinished_type: Ty<'tcx>,
unique_type_id: UniqueTypeId,
metadata_stub: &'ll DICompositeType,
+ member_holding_stub: &'ll DICompositeType,
member_description_factory: MemberDescriptionFactory<'ll, 'tcx>,
) -> RecursiveTypeDescription<'ll, 'tcx> {
unfinished_type,
unique_type_id,
metadata_stub,
+ member_holding_stub,
member_description_factory,
}
}
unfinished_type,
unique_type_id,
metadata_stub,
+ member_holding_stub,
ref member_description_factory,
} => {
// Make sure that we have a forward declaration of the type in
// ... and attach them to the stub to complete it.
set_members_of_composite_type(cx,
- metadata_stub,
+ member_holding_stub,
member_descriptions);
return MetadataCreationResult::new(metadata_stub, true);
}
size: pointer_size,
align: pointer_align,
flags: DIFlags::FlagZero,
+ discriminant: None,
},
MemberDescription {
name: "length".to_owned(),
size: usize_size,
align: usize_align,
flags: DIFlags::FlagZero,
+ discriminant: None,
},
];
size: data_ptr_field.size,
align: data_ptr_field.align,
flags: DIFlags::FlagArtificial,
+ discriminant: None,
},
MemberDescription {
name: "vtable".to_owned(),
size: vtable_field.size,
align: vtable_field.align,
flags: DIFlags::FlagArtificial,
+ discriminant: None,
},
];
size: Size,
align: Align,
flags: DIFlags,
+ discriminant: Option<u64>,
}
// A factory for MemberDescriptions. It produces a list of member descriptions
size,
align,
flags: DIFlags::FlagZero,
+ discriminant: None,
}
}).collect()
}
struct_type,
unique_type_id,
struct_metadata_stub,
+ struct_metadata_stub,
StructMDF(StructMemberDescriptionFactory {
ty: struct_type,
variant,
size,
align,
flags: DIFlags::FlagZero,
+ discriminant: None,
}
}).collect()
}
) -> RecursiveTypeDescription<'ll, 'tcx> {
let tuple_name = compute_debuginfo_type_name(cx, tuple_type, false);
+ let struct_stub = create_struct_stub(cx,
+ tuple_type,
+ &tuple_name[..],
+ unique_type_id,
+ NO_SCOPE_METADATA);
+
create_and_register_recursive_type_forward_declaration(
cx,
tuple_type,
unique_type_id,
- create_struct_stub(cx,
- tuple_type,
- &tuple_name[..],
- unique_type_id,
- NO_SCOPE_METADATA),
+ struct_stub,
+ struct_stub,
TupleMDF(TupleMemberDescriptionFactory {
ty: tuple_type,
component_types: component_types.to_vec(),
size,
align,
flags: DIFlags::FlagZero,
+ discriminant: None,
}
}).collect()
}
union_type,
unique_type_id,
union_metadata_stub,
+ union_metadata_stub,
UnionMDF(UnionMemberDescriptionFactory {
layout: cx.layout_of(union_type),
variant,
// Enums
//=-----------------------------------------------------------------------------
+// DWARF variant support is only available starting in LLVM 7.
+// Although the earlier enum debug info output did not work properly
+// in all situations, it is better for the time being to continue to
+// sometimes emit the old style rather than emit something completely
+// useless when rust is compiled against LLVM 6 or older. This
+// function decides which representation will be emitted.
+fn use_enum_fallback(cx: &CodegenCx) -> bool {
+ // On MSVC we have to use the fallback mode, because LLVM doesn't
+ // lower variant parts to PDB.
+ return cx.sess().target.target.options.is_like_msvc || unsafe {
+ llvm::LLVMRustVersionMajor() < 7
+ };
+}
+
// Describes the members of an enum value: An enum is described as a union of
// structs in DWARF. This MemberDescriptionFactory provides the description for
// the members of this union; so for every variant of the given enum, this
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
-> Vec<MemberDescription<'ll>> {
let adt = &self.enum_type.ty_adt_def().unwrap();
+
+ // This will always find the metadata in the type map.
+ let fallback = use_enum_fallback(cx);
+ let self_metadata = if fallback {
+ self.containing_scope
+ } else {
+ type_metadata(cx, self.enum_type, self.span)
+ };
+
match self.layout.variants {
layout::Variants::Single { .. } if adt.variants.is_empty() => vec![],
layout::Variants::Single { index } => {
self.layout,
&adt.variants[index],
NoDiscriminant,
- self.containing_scope,
+ self_metadata,
self.span);
let member_descriptions =
member_descriptions);
vec![
MemberDescription {
- name: String::new(),
+ name: if fallback {
+ String::new()
+ } else {
+ adt.variants[index].name.as_str().to_string()
+ },
type_metadata: variant_type_metadata,
offset: Size::ZERO,
size: self.layout.size,
align: self.layout.align,
- flags: DIFlags::FlagZero
+ flags: DIFlags::FlagZero,
+ discriminant: None,
}
]
}
layout::Variants::Tagged { ref variants, .. } => {
- let discriminant_info = RegularDiscriminant(self.discriminant_type_metadata
- .expect(""));
+ let discriminant_info = if fallback {
+ RegularDiscriminant(self.discriminant_type_metadata
+ .expect(""))
+ } else {
+ // This doesn't matter in this case.
+ NoDiscriminant
+ };
(0..variants.len()).map(|i| {
let variant = self.layout.for_variant(cx, i);
let (variant_type_metadata, member_desc_factory) =
variant,
&adt.variants[i],
discriminant_info,
- self.containing_scope,
+ self_metadata,
self.span);
let member_descriptions = member_desc_factory
variant_type_metadata,
member_descriptions);
MemberDescription {
- name: String::new(),
+ name: if fallback {
+ String::new()
+ } else {
+ adt.variants[i].name.as_str().to_string()
+ },
type_metadata: variant_type_metadata,
offset: Size::ZERO,
- size: variant.size,
- align: variant.align,
- flags: DIFlags::FlagZero
+ size: self.layout.size,
+ align: self.layout.align,
+ flags: DIFlags::FlagZero,
+ discriminant: Some(self.layout.ty.ty_adt_def().unwrap()
+ .discriminant_for_variant(cx.tcx, i)
+ .val as u64),
}
}).collect()
}
- layout::Variants::NicheFilling { dataful_variant, ref niche_variants, .. } => {
- let variant = self.layout.for_variant(cx, dataful_variant);
- // Create a description of the non-null variant
- let (variant_type_metadata, member_description_factory) =
- describe_enum_variant(cx,
- variant,
- &adt.variants[dataful_variant],
- OptimizedDiscriminant,
- self.containing_scope,
- self.span);
+ layout::Variants::NicheFilling {
+ ref niche_variants,
+ niche_start,
+ ref variants,
+ dataful_variant,
+ ..
+ } => {
+ if fallback {
+ let variant = self.layout.for_variant(cx, dataful_variant);
+ // Create a description of the non-null variant
+ let (variant_type_metadata, member_description_factory) =
+ describe_enum_variant(cx,
+ variant,
+ &adt.variants[dataful_variant],
+ OptimizedDiscriminant,
+ self.containing_scope,
+ self.span);
- let variant_member_descriptions =
- member_description_factory.create_member_descriptions(cx);
+ let variant_member_descriptions =
+ member_description_factory.create_member_descriptions(cx);
- set_members_of_composite_type(cx,
- variant_type_metadata,
- variant_member_descriptions);
-
- // Encode the information about the null variant in the union
- // member's name.
- let mut name = String::from("RUST$ENCODED$ENUM$");
- // HACK(eddyb) the debuggers should just handle offset+size
- // of discriminant instead of us having to recover its path.
- // Right now it's not even going to work for `niche_start > 0`,
- // and for multiple niche variants it only supports the first.
- fn compute_field_path<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
- name: &mut String,
- layout: TyLayout<'tcx>,
- offset: Size,
- size: Size) {
- for i in 0..layout.fields.count() {
- let field_offset = layout.fields.offset(i);
- if field_offset > offset {
- continue;
- }
- let inner_offset = offset - field_offset;
- let field = layout.field(cx, i);
- if inner_offset + size <= field.size {
- write!(name, "{}$", i).unwrap();
- compute_field_path(cx, name, field, inner_offset, size);
+ set_members_of_composite_type(cx,
+ variant_type_metadata,
+ variant_member_descriptions);
+
+ // Encode the information about the null variant in the union
+ // member's name.
+ let mut name = String::from("RUST$ENCODED$ENUM$");
+ // Right now it's not even going to work for `niche_start > 0`,
+ // and for multiple niche variants it only supports the first.
+ fn compute_field_path<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
+ name: &mut String,
+ layout: TyLayout<'tcx>,
+ offset: Size,
+ size: Size) {
+ for i in 0..layout.fields.count() {
+ let field_offset = layout.fields.offset(i);
+ if field_offset > offset {
+ continue;
+ }
+ let inner_offset = offset - field_offset;
+ let field = layout.field(cx, i);
+ if inner_offset + size <= field.size {
+ write!(name, "{}$", i).unwrap();
+ compute_field_path(cx, name, field, inner_offset, size);
+ }
}
}
+ compute_field_path(cx, &mut name,
+ self.layout,
+ self.layout.fields.offset(0),
+ self.layout.field(cx, 0).size);
+ name.push_str(&adt.variants[*niche_variants.start()].name.as_str());
+
+ // Create the (singleton) list of descriptions of union members.
+ vec![
+ MemberDescription {
+ name,
+ type_metadata: variant_type_metadata,
+ offset: Size::ZERO,
+ size: variant.size,
+ align: variant.align,
+ flags: DIFlags::FlagZero,
+ discriminant: None,
+ }
+ ]
+ } else {
+ (0..variants.len()).map(|i| {
+ let variant = self.layout.for_variant(cx, i);
+ let (variant_type_metadata, member_desc_factory) =
+ describe_enum_variant(cx,
+ variant,
+ &adt.variants[i],
+ OptimizedDiscriminant,
+ self_metadata,
+ self.span);
+
+ let member_descriptions = member_desc_factory
+ .create_member_descriptions(cx);
+
+ set_members_of_composite_type(cx,
+ variant_type_metadata,
+ member_descriptions);
+
+ let niche_value = if i == dataful_variant {
+ None
+ } else {
+ let niche = (i as u128)
+ .wrapping_sub(*niche_variants.start() as u128)
+ .wrapping_add(niche_start);
+ assert_eq!(niche as u64 as u128, niche);
+ Some(niche as u64)
+ };
+
+ MemberDescription {
+ name: adt.variants[i].name.as_str().to_string(),
+ type_metadata: variant_type_metadata,
+ offset: Size::ZERO,
+ size: self.layout.size,
+ align: self.layout.align,
+ flags: DIFlags::FlagZero,
+ discriminant: niche_value,
+ }
+ }).collect()
}
- compute_field_path(cx, &mut name,
- self.layout,
- self.layout.fields.offset(0),
- self.layout.field(cx, 0).size);
- name.push_str(&adt.variants[*niche_variants.start()].name.as_str());
-
- // Create the (singleton) list of descriptions of union members.
- vec![
- MemberDescription {
- name,
- type_metadata: variant_type_metadata,
- offset: Size::ZERO,
- size: variant.size,
- align: variant.align,
- flags: DIFlags::FlagZero
- }
- ]
}
}
}
let (size, align) = cx.size_and_align_of(ty);
MemberDescription {
name: name.to_string(),
- type_metadata: match self.discriminant_type_metadata {
- Some(metadata) if i == 0 => metadata,
- _ => type_metadata(cx, ty, self.span)
+ type_metadata: if use_enum_fallback(cx) {
+ match self.discriminant_type_metadata {
+ Some(metadata) if i == 0 => metadata,
+ _ => type_metadata(cx, ty, self.span)
+ }
+ } else {
+ type_metadata(cx, ty, self.span)
},
offset: self.offsets[i],
size,
align,
- flags: DIFlags::FlagZero
+ flags: DIFlags::FlagZero,
+ discriminant: None,
}
}).collect()
}
NoDiscriminant
}
-// Returns a tuple of (1) type_metadata_stub of the variant, (2) the llvm_type
-// of the variant, and (3) a MemberDescriptionFactory for producing the
-// descriptions of the fields of the variant. This is a rudimentary version of a
-// full RecursiveTypeDescription.
+// Returns a tuple of (1) type_metadata_stub of the variant, (2) a
+// MemberDescriptionFactory for producing the descriptions of the
+// fields of the variant. This is a rudimentary version of a full
+// RecursiveTypeDescription.
fn describe_enum_variant(
cx: &CodegenCx<'ll, 'tcx>,
layout: layout::TyLayout<'tcx>,
unique_type_id,
Some(containing_scope));
- // If this is not a univariant enum, there is also the discriminant field.
- let (discr_offset, discr_arg) = match discriminant_info {
- RegularDiscriminant(_) => {
- // We have the layout of an enum variant, we need the layout of the outer enum
- let enum_layout = cx.layout_of(layout.ty);
- (Some(enum_layout.fields.offset(0)),
- Some(("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, 0).ty)))
- }
- _ => (None, None),
- };
- let offsets = discr_offset.into_iter().chain((0..layout.fields.count()).map(|i| {
- layout.fields.offset(i)
- })).collect();
-
// Build an array of (field name, field type) pairs to be captured in the factory closure.
- let args = discr_arg.into_iter().chain((0..layout.fields.count()).map(|i| {
- let name = if variant.ctor_kind == CtorKind::Fn {
- format!("__{}", i)
- } else {
- variant.fields[i].ident.to_string()
+ let (offsets, args) = if use_enum_fallback(cx) {
+ // If this is not a univariant enum, there is also the discriminant field.
+ let (discr_offset, discr_arg) = match discriminant_info {
+ RegularDiscriminant(_) => {
+ // We have the layout of an enum variant, we need the layout of the outer enum
+ let enum_layout = cx.layout_of(layout.ty);
+ (Some(enum_layout.fields.offset(0)),
+ Some(("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, 0).ty)))
+ }
+ _ => (None, None),
};
- (name, layout.field(cx, i).ty)
- })).collect();
+ (
+ discr_offset.into_iter().chain((0..layout.fields.count()).map(|i| {
+ layout.fields.offset(i)
+ })).collect(),
+ discr_arg.into_iter().chain((0..layout.fields.count()).map(|i| {
+ let name = if variant.ctor_kind == CtorKind::Fn {
+ format!("__{}", i)
+ } else {
+ variant.fields[i].ident.to_string()
+ };
+ (name, layout.field(cx, i).ty)
+ })).collect()
+ )
+ } else {
+ (
+ (0..layout.fields.count()).map(|i| {
+ layout.fields.offset(i)
+ }).collect(),
+ (0..layout.fields.count()).map(|i| {
+ let name = if variant.ctor_kind == CtorKind::Fn {
+ format!("__{}", i)
+ } else {
+ variant.fields[i].ident.to_string()
+ };
+ (name, layout.field(cx, i).ty)
+ }).collect()
+ )
+ };
let member_description_factory =
VariantMDF(VariantMemberDescriptionFactory {
// <unknown>
let file_metadata = unknown_file_metadata(cx);
- let def = enum_type.ty_adt_def().unwrap();
- let enumerators_metadata: Vec<_> = def.discriminants(cx.tcx)
- .zip(&def.variants)
- .map(|(discr, v)| {
- let name = SmallCStr::new(&v.name.as_str());
- unsafe {
- Some(llvm::LLVMRustDIBuilderCreateEnumerator(
- DIB(cx),
- name.as_ptr(),
- // FIXME: what if enumeration has i128 discriminant?
- discr.val as u64))
- }
- })
- .collect();
-
let discriminant_type_metadata = |discr: layout::Primitive| {
+ let def = enum_type.ty_adt_def().unwrap();
+ let enumerators_metadata: Vec<_> = def.discriminants(cx.tcx)
+ .zip(&def.variants)
+ .map(|(discr, v)| {
+ let name = SmallCStr::new(&v.name.as_str());
+ unsafe {
+ Some(llvm::LLVMRustDIBuilderCreateEnumerator(
+ DIB(cx),
+ name.as_ptr(),
+ // FIXME: what if enumeration has i128 discriminant?
+ discr.val as u64))
+ }
+ })
+ .collect();
+
let disr_type_key = (enum_def_id, discr);
let cached_discriminant_type_metadata = debug_context(cx).created_enum_disr_types
.borrow()
discriminant_size.bits(),
discriminant_align.abi_bits() as u32,
create_DIArray(DIB(cx), &enumerators_metadata),
- discriminant_base_type_metadata)
+ discriminant_base_type_metadata, true)
};
debug_context(cx).created_enum_disr_types
let layout = cx.layout_of(enum_type);
- let discriminant_type_metadata = match layout.variants {
- layout::Variants::Single { .. } |
- layout::Variants::NicheFilling { .. } => None,
- layout::Variants::Tagged { ref tag, .. } => {
- Some(discriminant_type_metadata(tag.value))
- }
- };
-
- if let (&layout::Abi::Scalar(_), Some(discr)) = (&layout.abi, discriminant_type_metadata) {
- return FinalMetadata(discr);
+ match (&layout.abi, &layout.variants) {
+ (&layout::Abi::Scalar(_), &layout::Variants::Tagged {ref tag, .. }) =>
+ return FinalMetadata(discriminant_type_metadata(tag.value)),
+ _ => {}
}
let (enum_type_size, enum_type_align) = layout.size_and_align();
let unique_type_id_str = SmallCStr::new(
debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id)
);
- let enum_metadata = unsafe {
- llvm::LLVMRustDIBuilderCreateUnionType(
- DIB(cx),
- containing_scope,
- enum_name.as_ptr(),
- file_metadata,
- UNKNOWN_LINE_NUMBER,
- enum_type_size.bits(),
- enum_type_align.abi_bits() as u32,
- DIFlags::FlagZero,
- None,
- 0, // RuntimeLang
- unique_type_id_str.as_ptr())
+
+ if use_enum_fallback(cx) {
+ let discriminant_type_metadata = match layout.variants {
+ layout::Variants::Single { .. } |
+ layout::Variants::NicheFilling { .. } => None,
+ layout::Variants::Tagged { ref tag, .. } => {
+ Some(discriminant_type_metadata(tag.value))
+ }
+ };
+
+ let enum_metadata = unsafe {
+ llvm::LLVMRustDIBuilderCreateUnionType(
+ DIB(cx),
+ containing_scope,
+ enum_name.as_ptr(),
+ file_metadata,
+ UNKNOWN_LINE_NUMBER,
+ enum_type_size.bits(),
+ enum_type_align.abi_bits() as u32,
+ DIFlags::FlagZero,
+ None,
+ 0, // RuntimeLang
+ unique_type_id_str.as_ptr())
+ };
+
+ return create_and_register_recursive_type_forward_declaration(
+ cx,
+ enum_type,
+ unique_type_id,
+ enum_metadata,
+ enum_metadata,
+ EnumMDF(EnumMemberDescriptionFactory {
+ enum_type,
+ layout,
+ discriminant_type_metadata,
+ containing_scope,
+ span,
+ }),
+ );
+ }
+
+ let discriminator_metadata = match &layout.variants {
+ // A single-variant enum has no discriminant.
+ &layout::Variants::Single { .. } => None,
+
+ &layout::Variants::NicheFilling { ref niche, .. } => {
+ // Find the integer type of the correct size.
+ let size = niche.value.size(cx);
+ let align = niche.value.align(cx);
+
+ let discr_type = match niche.value {
+ layout::Int(t, _) => t,
+ layout::Float(layout::FloatTy::F32) => Integer::I32,
+ layout::Float(layout::FloatTy::F64) => Integer::I64,
+ layout::Pointer => cx.data_layout().ptr_sized_integer(),
+ }.to_ty(cx.tcx, false);
+
+ let discr_metadata = basic_type_metadata(cx, discr_type);
+ unsafe {
+ Some(llvm::LLVMRustDIBuilderCreateMemberType(
+ DIB(cx),
+ containing_scope,
+ ptr::null_mut(),
+ file_metadata,
+ UNKNOWN_LINE_NUMBER,
+ size.bits(),
+ align.abi_bits() as u32,
+ layout.fields.offset(0).bits(),
+ DIFlags::FlagArtificial,
+ discr_metadata))
+ }
+ },
+
+ &layout::Variants::Tagged { ref tag, .. } => {
+ let discr_type = tag.value.to_ty(cx.tcx);
+ let (size, align) = cx.size_and_align_of(discr_type);
+
+ let discr_metadata = basic_type_metadata(cx, discr_type);
+ unsafe {
+ Some(llvm::LLVMRustDIBuilderCreateMemberType(
+ DIB(cx),
+ containing_scope,
+ ptr::null_mut(),
+ file_metadata,
+ UNKNOWN_LINE_NUMBER,
+ size.bits(),
+ align.abi_bits() as u32,
+ layout.fields.offset(0).bits(),
+ DIFlags::FlagArtificial,
+ discr_metadata))
+ }
+ },
+ };
+
+ let empty_array = create_DIArray(DIB(cx), &[]);
+ let variant_part = unsafe {
+ llvm::LLVMRustDIBuilderCreateVariantPart(
+ DIB(cx),
+ containing_scope,
+ ptr::null_mut(),
+ file_metadata,
+ UNKNOWN_LINE_NUMBER,
+ enum_type_size.bits(),
+ enum_type_align.abi_bits() as u32,
+ DIFlags::FlagZero,
+ discriminator_metadata,
+ empty_array,
+ unique_type_id_str.as_ptr())
+ };
+
+ // The variant part must be wrapped in a struct according to DWARF.
+ let type_array = create_DIArray(DIB(cx), &[Some(variant_part)]);
+ let struct_wrapper = unsafe {
+ llvm::LLVMRustDIBuilderCreateStructType(
+ DIB(cx),
+ Some(containing_scope),
+ enum_name.as_ptr(),
+ file_metadata,
+ UNKNOWN_LINE_NUMBER,
+ enum_type_size.bits(),
+ enum_type_align.abi_bits() as u32,
+ DIFlags::FlagZero,
+ None,
+ type_array,
+ 0,
+ None,
+ unique_type_id_str.as_ptr())
};
return create_and_register_recursive_type_forward_declaration(
cx,
enum_type,
unique_type_id,
- enum_metadata,
+ struct_wrapper,
+ variant_part,
EnumMDF(EnumMemberDescriptionFactory {
enum_type,
layout,
- discriminant_type_metadata,
+ discriminant_type_metadata: None,
containing_scope,
span,
}),
.map(|member_description| {
let member_name = CString::new(member_description.name).unwrap();
unsafe {
- Some(llvm::LLVMRustDIBuilderCreateMemberType(
+ Some(llvm::LLVMRustDIBuilderCreateVariantMemberType(
DIB(cx),
composite_type_metadata,
member_name.as_ptr(),
member_description.size.bits(),
member_description.align.abi_bits() as u32,
member_description.offset.bits(),
+ match member_description.discriminant {
+ None => None,
+ Some(value) => Some(C_u64(cx, value)),
+ },
member_description.flags,
member_description.type_metadata))
}
Ty: &'a DIType)
-> &'a DIDerivedType;
+ pub fn LLVMRustDIBuilderCreateVariantMemberType(Builder: &DIBuilder<'a>,
+ Scope: &'a DIScope,
+ Name: *const c_char,
+ File: &'a DIFile,
+ LineNumber: c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ OffsetInBits: u64,
+ Discriminant: Option<&'a Value>,
+ Flags: DIFlags,
+ Ty: &'a DIType)
+ -> &'a DIType;
+
pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: &DIBuilder<'a>,
Scope: &'a DIScope,
File: &'a DIFile,
SizeInBits: u64,
AlignInBits: u32,
Elements: &'a DIArray,
- ClassType: &'a DIType)
+ ClassType: &'a DIType,
+ IsFixed: bool)
-> &'a DIType;
pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,
UniqueId: *const c_char)
-> &'a DIType;
+ pub fn LLVMRustDIBuilderCreateVariantPart(Builder: &DIBuilder<'a>,
+ Scope: &'a DIScope,
+ Name: *const c_char,
+ File: &'a DIFile,
+ LineNo: c_uint,
+ SizeInBits: u64,
+ AlignInBits: u32,
+ Flags: DIFlags,
+ Discriminator: Option<&'a DIDerivedType>,
+ Elements: &'a DIArray,
+ UniqueId: *const c_char)
+ -> &'a DIDerivedType;
+
pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool);
pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: &DIBuilder<'a>,
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(in_band_lifetimes)]
-#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#![feature(unsize)]
//! If you expect to store more than 1 element in the common case, steer clear
//! and use a `Vec<T>`, `Box<[T]>`, or a `SmallVec<T>`.
-use std::mem;
-
#[derive(Clone, Hash, Debug, PartialEq)]
pub struct TinyList<T: PartialEq> {
head: Option<Element<T>>
pub fn insert(&mut self, data: T) {
self.head = Some(Element {
data,
- next: mem::replace(&mut self.head, None).map(Box::new),
+ next: self.head.take().map(Box::new)
});
}
pub fn remove(&mut self, data: &T) -> bool {
self.head = match self.head {
Some(ref mut head) if head.data == *data => {
- mem::replace(&mut head.next, None).map(|x| *x)
+ head.next.take().map(|x| *x)
}
Some(ref mut head) => return head.remove_next(data),
None => return false,
if next.data != *data {
return next.remove_next(data)
} else {
- mem::replace(&mut next.next, None)
+ next.next.take()
}
} else {
return false
pub struct EmitterWriter {
dst: Destination,
- cm: Option<Lrc<SourceMapperDyn>>,
+ sm: Option<Lrc<SourceMapperDyn>>,
short_message: bool,
teach: bool,
ui_testing: bool,
impl EmitterWriter {
pub fn stderr(color_config: ColorConfig,
- code_map: Option<Lrc<SourceMapperDyn>>,
+ source_map: Option<Lrc<SourceMapperDyn>>,
short_message: bool,
teach: bool)
-> EmitterWriter {
let dst = Destination::from_stderr(color_config);
EmitterWriter {
dst,
- cm: code_map,
+ sm: source_map,
short_message,
teach,
ui_testing: false,
}
pub fn new(dst: Box<dyn Write + Send>,
- code_map: Option<Lrc<SourceMapperDyn>>,
+ source_map: Option<Lrc<SourceMapperDyn>>,
short_message: bool,
teach: bool)
-> EmitterWriter {
EmitterWriter {
dst: Raw(dst),
- cm: code_map,
+ sm: source_map,
short_message,
teach,
ui_testing: false,
let mut output = vec![];
let mut multiline_annotations = vec![];
- if let Some(ref cm) = self.cm {
+ if let Some(ref sm) = self.sm {
for span_label in msp.span_labels() {
if span_label.span.is_dummy() {
continue;
}
- let lo = cm.lookup_char_pos(span_label.span.lo());
- let mut hi = cm.lookup_char_pos(span_label.span.hi());
+ let lo = sm.lookup_char_pos(span_label.span.lo());
+ let mut hi = sm.lookup_char_pos(span_label.span.hi());
// Watch out for "empty spans". If we get a span like 6..6, we
// want to just display a `^` at 6, so convert that to
fn get_multispan_max_line_num(&mut self, msp: &MultiSpan) -> usize {
let mut max = 0;
- if let Some(ref cm) = self.cm {
+ if let Some(ref sm) = self.sm {
for primary_span in msp.primary_spans() {
if !primary_span.is_dummy() {
- let hi = cm.lookup_char_pos(primary_span.hi());
+ let hi = sm.lookup_char_pos(primary_span.hi());
if hi.line > max {
max = hi.line;
}
if !self.short_message {
for span_label in msp.span_labels() {
if !span_label.span.is_dummy() {
- let hi = cm.lookup_char_pos(span_label.span.hi());
+ let hi = sm.lookup_char_pos(span_label.span.hi());
if hi.line > max {
max = hi.line;
}
always_backtrace: bool) -> bool {
let mut spans_updated = false;
- if let Some(ref cm) = self.cm {
+ if let Some(ref sm) = self.sm {
let mut before_after: Vec<(Span, Span)> = vec![];
let mut new_labels: Vec<(Span, String)> = vec![];
if sp.is_dummy() {
continue;
}
- let call_sp = cm.call_span_if_macro(*sp);
+ let call_sp = sm.call_span_if_macro(*sp);
if call_sp != *sp && !always_backtrace {
before_after.push((*sp, call_sp));
}
})));
}
// Check to make sure we're not in any <*macros>
- if !cm.span_to_filename(def_site).is_macros() &&
+ if !sm.span_to_filename(def_site).is_macros() &&
!trace.macro_decl_name.starts_with("desugaring of ") &&
!trace.macro_decl_name.starts_with("#[") ||
always_backtrace {
if sp_label.span.is_dummy() {
continue;
}
- if cm.span_to_filename(sp_label.span.clone()).is_macros() &&
+ if sm.span_to_filename(sp_label.span.clone()).is_macros() &&
!always_backtrace
{
let v = sp_label.span.macro_backtrace();
let mut annotated_files = self.preprocess_annotations(msp);
// Make sure our primary file comes first
- let (primary_lo, cm) = if let (Some(cm), Some(ref primary_span)) =
- (self.cm.as_ref(), msp.primary_span().as_ref()) {
+ let (primary_lo, sm) = if let (Some(sm), Some(ref primary_span)) =
+ (self.sm.as_ref(), msp.primary_span().as_ref()) {
if !primary_span.is_dummy() {
- (cm.lookup_char_pos(primary_span.lo()), cm)
+ (sm.lookup_char_pos(primary_span.lo()), sm)
} else {
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
return Ok(());
// Print out the annotate source lines that correspond with the error
for annotated_file in annotated_files {
// we can't annotate anything if the source is unavailable.
- if !cm.ensure_source_file_source_present(annotated_file.file.clone()) {
+ if !sm.ensure_source_file_source_present(annotated_file.file.clone()) {
continue;
}
buffer.append(buffer_msg_line_offset,
&format!("{}:{}:{}",
loc.file.name,
- cm.doctest_offset_line(loc.line),
+ sm.doctest_offset_line(loc.line),
loc.col.0 + 1),
Style::LineAndColumn);
for _ in 0..max_line_num_len {
buffer.prepend(0,
&format!("{}:{}:{}: ",
loc.file.name,
- cm.doctest_offset_line(loc.line),
+ sm.doctest_offset_line(loc.line),
loc.col.0 + 1),
Style::LineAndColumn);
}
};
format!("{}:{}{}",
annotated_file.file.name,
- cm.doctest_offset_line(first_line.line_index),
+ sm.doctest_offset_line(first_line.line_index),
col)
} else {
annotated_file.file.name.to_string()
level: &Level,
max_line_num_len: usize)
-> io::Result<()> {
- if let Some(ref cm) = self.cm {
+ if let Some(ref sm) = self.sm {
let mut buffer = StyledBuffer::new();
// Render the suggestion message
Some(Style::HeaderMsg));
// Render the replacements for each suggestion
- let suggestions = suggestion.splice_lines(&**cm);
+ let suggestions = suggestion.splice_lines(&**sm);
let mut row_num = 2;
for &(ref complete, ref parts) in suggestions.iter().take(MAX_SUGGESTIONS) {
&& parts[0].snippet.trim() == complete.trim())
&& complete.lines().count() == 1;
- let lines = cm.span_to_lines(parts[0].span).unwrap();
+ let lines = sm.span_to_lines(parts[0].span).unwrap();
assert!(!lines.lines.is_empty());
- let line_start = cm.lookup_char_pos(parts[0].span.lo()).line;
+ let line_start = sm.lookup_char_pos(parts[0].span.lo()).line;
draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1);
let mut line_pos = 0;
let mut lines = complete.lines();
if show_underline {
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1);
for part in parts {
- let span_start_pos = cm.lookup_char_pos(part.span.lo()).col_display;
- let span_end_pos = cm.lookup_char_pos(part.span.hi()).col_display;
+ let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display;
+ let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display;
// Do not underline the leading...
let start = part.snippet.len()
fn span_to_filename(&self, sp: Span) -> FileName;
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
fn call_span_if_macro(&self, sp: Span) -> Span;
- fn ensure_source_file_source_present(&self, file_map: Lrc<SourceFile>) -> bool;
+ fn ensure_source_file_source_present(&self, source_file: Lrc<SourceFile>) -> bool;
fn doctest_offset_line(&self, line: usize) -> usize;
}
msg: &str,
followed_by_block: bool) {
if let ast::ExprKind::Paren(ref inner) = value.node {
- let necessary = followed_by_block && if let ast::ExprKind::Ret(_) = inner.node {
- true
- } else {
- parser::contains_exterior_struct_lit(&inner)
+ let necessary = followed_by_block && match inner.node {
+ ast::ExprKind::Ret(_) | ast::ExprKind::Break(..) => true,
+ _ => parser::contains_exterior_struct_lit(&inner),
};
if !necessary {
let expr_text = if let Ok(snippet) = cx.sess().source_map()
mbcx.errors_buffer.sort_by_key(|diag| diag.span.primary_span());
if tcx.migrate_borrowck() {
- match tcx.borrowck(def_id).signalled_any_error {
+ // When borrowck=migrate, check if AST-borrowck would
+ // error on the given code.
+
+ // rust-lang/rust#55492: loop over parents to ensure that
+ // errors that AST-borrowck only detects in some parent of
+ // a closure still allows NLL to signal an error.
+ let mut curr_def_id = def_id;
+ let signalled_any_error = loop {
+ match tcx.borrowck(curr_def_id).signalled_any_error {
+ SignalledError::NoErrorsSeen => {
+ // keep traversing (and borrow-checking) parents
+ }
+ SignalledError::SawSomeError => {
+ // stop search here
+ break SignalledError::SawSomeError;
+ }
+ }
+
+ if tcx.is_closure(curr_def_id) {
+ curr_def_id = tcx.parent_def_id(curr_def_id)
+ .expect("a closure must have a parent_def_id");
+ } else {
+ break SignalledError::NoErrorsSeen;
+ }
+ };
+
+ match signalled_any_error {
SignalledError::NoErrorsSeen => {
// if AST-borrowck signalled no errors, then
// downgrade all the buffered MIR-borrowck errors
| Write(wk @ WriteKind::StorageDeadOrDrop)
| Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shared))
| Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow)) => {
- if let Err(_place_err) = self.is_mutable(place, is_local_mutation_allowed) {
+ if let (Err(_place_err), true) = (
+ self.is_mutable(place, is_local_mutation_allowed),
+ self.errors_buffer.is_empty()
+ ) {
if self.infcx.tcx.migrate_borrowck() {
// rust-lang/rust#46908: In pure NLL mode this
// code path should be unreachable (and thus
location,
);
} else {
- self.infcx.tcx.sess.delay_span_bug(
+ span_bug!(
span,
- &format!(
- "Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
- place, kind
- ),
+ "Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
+ place,
+ kind,
);
}
}
AccessKind::Move => {
err = self.infcx.tcx
.cannot_move_out_of(span, &(item_msg + &reason), Origin::Mir);
- act = "move";
- acted_on = "moved";
- span
+ err.span_label(span, "cannot move");
+ err.buffer(&mut self.errors_buffer);
+ return;
}
AccessKind::Mutate => {
err = self.infcx.tcx
key.param_env.reveal = Reveal::UserFacing;
match tcx.const_eval(key) {
// try again with reveal all as requested
- Err(ErrorHandled::TooGeneric) => {},
+ Err(ErrorHandled::TooGeneric) => {
+ // Promoteds should never be "too generic" when getting evaluated.
+ // They either don't get evaluated, or we are in a monomorphic context
+ assert!(key.value.promoted.is_none());
+ },
// dedupliate calls
other => return other,
}
let (lo, hi) = layout.valid_range.clone().into_inner();
let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits
assert!(hi <= max_hi);
- if lo == 0 && hi == max_hi {
+ // We could also write `(hi + 1) % (max_hi + 1) == lo` but `max_hi + 1` overflows for `u128`
+ if (lo == 0 && hi == max_hi) || (hi + 1 == lo) {
// Nothing to check
return Ok(());
}
#![feature(nll)]
#![feature(in_band_lifetimes)]
-#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)]
#![feature(box_patterns)]
);
for (i, &Segment { ident, id }) in path.iter().enumerate() {
- debug!("resolve_path ident {} {:?}", i, ident);
+ debug!("resolve_path ident {} {:?} {:?}", i, ident, id);
+ let record_segment_def = |this: &mut Self, def| {
+ if record_used {
+ if let Some(id) = id {
+ if !this.def_map.contains_key(&id) {
+ assert!(id != ast::DUMMY_NODE_ID, "Trying to resolve dummy id");
+ this.record_def(id, PathResolution::new(def));
+ }
+ }
+ }
+ };
let is_last = i == path.len() - 1;
let ns = if is_last { opt_ns.unwrap_or(TypeNS) } else { TypeNS };
// we found a local variable or type param
Some(LexicalScopeBinding::Def(def))
if opt_ns == Some(TypeNS) || opt_ns == Some(ValueNS) => {
+ record_segment_def(self, def);
return PathResult::NonModule(PathResolution::with_unresolved_segments(
def, path.len() - 1
));
let maybe_assoc = opt_ns != Some(MacroNS) && PathSource::Type.is_expected(def);
if let Some(next_module) = binding.module() {
module = Some(ModuleOrUniformRoot::Module(next_module));
- if record_used {
- if let Some(id) = id {
- if !self.def_map.contains_key(&id) {
- assert!(id != ast::DUMMY_NODE_ID, "Trying to resolve dummy id");
- self.record_def(id, PathResolution::new(def));
- }
- }
- }
+ record_segment_def(self, def);
} else if def == Def::ToolMod && i + 1 != path.len() {
let def = Def::NonMacroAttr(NonMacroAttrKind::Tool);
return PathResult::NonModule(PathResolution::new(def));
// we only write one macro def per unique macro definition, and
// one macro use per unique callsite span.
// mac_defs: FxHashSet<Span>,
- macro_calls: FxHashSet<Span>,
+ // macro_calls: FxHashSet<Span>,
}
impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
span: span_utils,
cur_scope: CRATE_NODE_ID,
// mac_defs: FxHashSet::default(),
- macro_calls: FxHashSet::default(),
+ // macro_calls: FxHashSet::default(),
}
}
}
fn process_path(&mut self, id: NodeId, path: &'l ast::Path) {
- debug!("process_path {:?}", path);
- if generated_code(path.span) {
+ if self.span.filter_generated(path.span) {
return;
}
self.dump_path_ref(id, path);
/// If the span is not macro-generated, do nothing, else use callee and
/// callsite spans to record macro definition and use data, using the
/// mac_uses and mac_defs sets to prevent multiples.
- fn process_macro_use(&mut self, span: Span) {
- let source_span = span.source_callsite();
- if !self.macro_calls.insert(source_span) {
- return;
- }
+ fn process_macro_use(&mut self, _span: Span) {
+ // FIXME if we're not dumping the defs (see below), there is no point
+ // dumping refs either.
+ // let source_span = span.source_callsite();
+ // if !self.macro_calls.insert(source_span) {
+ // return;
+ // }
- let data = match self.save_ctxt.get_macro_use_data(span) {
- None => return,
- Some(data) => data,
- };
+ // let data = match self.save_ctxt.get_macro_use_data(span) {
+ // None => return,
+ // Some(data) => data,
+ // };
- self.dumper.macro_use(data);
+ // self.dumper.macro_use(data);
// FIXME write the macro def
// let mut hasher = DefaultHasher::new();
self.result.compilation = Some(data);
}
- pub fn macro_use(&mut self, data: MacroRef) {
+ pub fn _macro_use(&mut self, data: MacroRef) {
if self.config.pub_only || self.config.reachable_only {
return;
}
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(box_syntax)]
-#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(nll)]
#![feature(slice_patterns)]
no_integrated_as: true,
// There are no atomic CAS instructions available in the MSP430
- // instruction set
- max_atomic_width: Some(16),
+ // instruction set, and the LLVM backend doesn't currently support
+ // compiler fences so the Atomic* API is missing on this target.
+ // When the LLVM backend gains support for compile fences uncomment
+ // the `singlethread: true` line and set `max_atomic_width` to
+ // `Some(16)`.
+ max_atomic_width: Some(0),
atomic_cas: false,
+ // singlethread: true,
// Because these devices have very little resources having an
// unwinder is too onerous so we default to "abort" because the
) -> Vec<OutlivesBound<'tcx>> {
sup_components
.into_iter()
- .flat_map(|component| {
+ .filter_map(|component| {
match component {
Component::Region(r) =>
- vec![OutlivesBound::RegionSubRegion(sub_region, r)],
+ Some(OutlivesBound::RegionSubRegion(sub_region, r)),
Component::Param(p) =>
- vec![OutlivesBound::RegionSubParam(sub_region, p)],
+ Some(OutlivesBound::RegionSubParam(sub_region, p)),
Component::Projection(p) =>
- vec![OutlivesBound::RegionSubProjection(sub_region, p)],
+ Some(OutlivesBound::RegionSubProjection(sub_region, p)),
Component::EscapingProjection(_) =>
// If the projection has escaping regions, don't
// try to infer any implied bounds even for its
// idea is that the WAY that the caller proves
// that may change in the future and we want to
// give ourselves room to get smarter here.
- vec![],
+ None,
Component::UnresolvedInferenceVariable(..) =>
- vec![],
+ None,
}
})
.collect()
{
let tcx = self.tcx();
- let bounds: Vec<_> = self.get_type_parameter_bounds(span, ty_param_def_id)
- .predicates.into_iter().filter_map(|(p, _)| p.to_opt_poly_trait_ref()).collect();
+ let bounds = self.get_type_parameter_bounds(span, ty_param_def_id)
+ .predicates.into_iter().filter_map(|(p, _)| p.to_opt_poly_trait_ref());
// Check that there is exactly one way to find an associated type with the
// correct name.
- let suitable_bounds = traits::transitive_bounds(tcx, &bounds)
+ let suitable_bounds = traits::transitive_bounds(tcx, bounds)
.filter(|b| self.trait_defines_associated_type_named(b.def_id(), assoc_name));
let param_node_id = tcx.hir.as_local_node_id(ty_param_def_id).unwrap();
use syntax::ast;
use syntax::util::lev_distance::{lev_distance, find_best_match_for_name};
use syntax_pos::{Span, symbol::Symbol};
+use std::iter;
use std::mem;
use std::ops::Deref;
use std::rc::Rc;
// itself. Hence, a `&self` method will wind up with an
// argument type like `&Trait`.
let trait_ref = principal.with_self_ty(self.tcx, self_ty);
- self.elaborate_bounds(&[trait_ref], |this, new_trait_ref, item| {
+ self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
let new_trait_ref = this.erase_late_bound_regions(&new_trait_ref);
let (xform_self_ty, xform_ret_ty) =
param_ty: ty::ParamTy) {
// FIXME -- Do we want to commit to this behavior for param bounds?
- let bounds: Vec<_> = self.param_env
+ let bounds = self.param_env
.caller_bounds
.iter()
.filter_map(|predicate| {
ty::Predicate::TypeOutlives(..) |
ty::Predicate::ConstEvaluatable(..) => None,
}
- })
- .collect();
+ });
- self.elaborate_bounds(&bounds, |this, poly_trait_ref, item| {
+ self.elaborate_bounds(bounds, |this, poly_trait_ref, item| {
let trait_ref = this.erase_late_bound_regions(&poly_trait_ref);
let (xform_self_ty, xform_ret_ty) =
// Do a search through a list of bounds, using a callback to actually
// create the candidates.
- fn elaborate_bounds<F>(&mut self, bounds: &[ty::PolyTraitRef<'tcx>], mut mk_cand: F)
+ fn elaborate_bounds<F>(&mut self,
+ bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
+ mut mk_cand: F)
where F: for<'b> FnMut(&mut ProbeContext<'b, 'gcx, 'tcx>,
ty::PolyTraitRef<'tcx>,
ty::AssociatedItem)
{
- debug!("elaborate_bounds(bounds={:?})", bounds);
-
let tcx = self.tcx;
for bound_trait_ref in traits::transitive_bounds(tcx, bounds) {
+ debug!("elaborate_bounds(bound_trait_ref={:?})", bound_trait_ref);
for item in self.impl_or_trait_item(bound_trait_ref.def_id()) {
if !self.has_applicable_self(&item) {
self.record_static_candidate(TraitSource(bound_trait_ref.def_id()));
}
let static_candidates = mem::replace(&mut self.static_candidates, vec![]);
- let private_candidate = mem::replace(&mut self.private_candidate, None);
+ let private_candidate = self.private_candidate.take();
let unsatisfied_predicates = mem::replace(&mut self.unsatisfied_predicates, vec![]);
// things failed, so lets look at all traits, for diagnostic purposes now:
_ => span_bug!(span, "non-ADT passed to check_expr_struct_fields")
};
- let mut remaining_fields = FxHashMap::default();
- for (i, field) in variant.fields.iter().enumerate() {
- remaining_fields.insert(field.ident.modern(), (i, field));
- }
+ let mut remaining_fields = variant.fields.iter().enumerate().map(|(i, field)|
+ (field.ident.modern(), (i, field))
+ ).collect::<FxHashMap<_, _>>();
let mut seen_fields = FxHashMap::default();
// provided (if any) into their appropriate spaces. We'll also report
// errors if type parameters are provided in an inappropriate place.
- let mut generic_segs = FxHashSet::default();
- for PathSeg(_, index) in &path_segs {
- generic_segs.insert(index);
- }
+ let generic_segs = path_segs.iter().map(|PathSeg(_, index)| index)
+ .collect::<FxHashSet<_>>();
AstConv::prohibit_generics(self, segments.iter().enumerate().filter_map(|(index, seg)| {
if !generic_segs.contains(&index) {
Some(seg)
return wrapper;
}
- var hideItemDeclarations = getCurrentValue('rustdoc-item-declarations') === "false";
+ var showItemDeclarations = getCurrentValue('rustdoc-item-declarations') === "false";
function buildToggleWrapper(e) {
if (hasClass(e, 'autohide')) {
var wrap = e.previousElementSibling;
if (hasClass(e, "type-decl")) {
fontSize = "20px";
otherMessage = ' Show declaration';
- if (hideItemDeclarations === false) {
+ if (showItemDeclarations === false) {
extraClass = 'collapsed';
}
} else if (hasClass(e, "sub-variant")) {
extraClass = "marg-left";
}
- e.parentNode.insertBefore(createToggle(otherMessage,
- fontSize,
- extraClass,
- hideItemDeclarations),
- e);
- if (otherMessage.length > 0 && hideItemDeclarations === true) {
+ e.parentNode.insertBefore(
+ createToggle(otherMessage,
+ fontSize,
+ extraClass,
+ hasClass(e, "type-decl") === false || showItemDeclarations === true),
+ e);
+ if (hasClass(e, "type-decl") === true && showItemDeclarations === true) {
collapseDocs(e.previousSibling.childNodes[0], "toggle");
}
}
padding-left: 0;
}
-.example-wrap {
+body:not(.source) .example-wrap {
display: inline-flex;
+}
+
+.example-wrap {
width: 100%;
}
text-align: right;
}
-.example-wrap > pre.rust {
+body:not(.source) .example-wrap > pre.rust {
width: 100%;
}
#![feature(cfg_target_vendor)]
#![feature(char_error_internals)]
#![feature(compiler_builtins_lib)]
-#![cfg_attr(stage0, feature(min_const_fn))]
#![feature(const_int_ops)]
#![feature(const_ip)]
#![feature(const_raw_ptr_deref)]
_ => panic!("inconsistent state in unpark"),
}
- // Coordinate wakeup through the mutex and a condvar notification
- let _lock = self.inner.lock.lock().unwrap();
+ // There is a period between when the parked thread sets `state` to
+ // `PARKED` (or last checked `state` in the case of a spurious wake
+ // up) and when it actually waits on `cvar`. If we were to notify
+ // during this period it would be ignored and then when the parked
+ // thread went to sleep it would never wake up. Fortunately, it has
+ // `lock` locked at this stage so we can acquire `lock` to wait until
+ // it is ready to receive the notification.
+ //
+ // Releasing `lock` before the call to `notify_one` means that when the
+ // parked thread wakes it doesn't get woken only to have to wait for us
+ // to release `lock`.
+ drop(self.inner.lock.lock().unwrap());
self.inner.cvar.notify_one()
}
pub struct JsonEmitter {
dst: Box<dyn Write + Send>,
registry: Option<Registry>,
- cm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
+ sm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
pretty: bool,
ui_testing: bool,
}
impl JsonEmitter {
pub fn stderr(registry: Option<Registry>,
- code_map: Lrc<SourceMap>,
+ source_map: Lrc<SourceMap>,
pretty: bool) -> JsonEmitter {
JsonEmitter {
dst: Box::new(io::stderr()),
registry,
- cm: code_map,
+ sm: source_map,
pretty,
ui_testing: false,
}
pub fn new(dst: Box<dyn Write + Send>,
registry: Option<Registry>,
- code_map: Lrc<SourceMap>,
+ source_map: Lrc<SourceMap>,
pretty: bool) -> JsonEmitter {
JsonEmitter {
dst,
registry,
- cm: code_map,
+ sm: source_map,
pretty,
ui_testing: false,
}
}
let buf = BufWriter::default();
let output = buf.clone();
- EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false, false)
+ EmitterWriter::new(Box::new(buf), Some(je.sm.clone()), false, false)
.ui_testing(je.ui_testing).emit(db);
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
let output = String::from_utf8(output).unwrap();
mut backtrace: vec::IntoIter<MacroBacktrace>,
je: &JsonEmitter)
-> DiagnosticSpan {
- let start = je.cm.lookup_char_pos(span.lo());
- let end = je.cm.lookup_char_pos(span.hi());
+ let start = je.sm.lookup_char_pos(span.lo());
+ let end = je.sm.lookup_char_pos(span.hi());
let backtrace_step = backtrace.next().map(|bt| {
let call_site =
Self::from_span_full(bt.call_site,
/// of `span` gets a DiagnosticSpanLine, with the highlight indicating the
/// `span` within the line.
fn from_span(span: Span, je: &JsonEmitter) -> Vec<DiagnosticSpanLine> {
- je.cm.span_to_lines(span)
+ je.sm.span_to_lines(span)
.map(|lines| {
let fm = &*lines.file;
lines.lines
let end = sess.source_map().lookup_byte_offset(span.hi());
// Make the range zero-length if the span is invalid.
- if span.lo() > span.hi() || begin.fm.start_pos != end.fm.start_pos {
+ if span.lo() > span.hi() || begin.sf.start_pos != end.sf.start_pos {
span = span.shrink_to_lo();
}
- let mut sr = StringReader::new_raw_internal(sess, begin.fm, None);
+ let mut sr = StringReader::new_raw_internal(sess, begin.sf, None);
// Seek the lexer to the right byte range.
sr.next_pos = span.lo();
// I guess this is the only way to figure out if
// we're at the beginning of the file...
- let cmap = SourceMap::new(FilePathMapping::empty());
- cmap.files.borrow_mut().file_maps.push(self.source_file.clone());
- let loc = cmap.lookup_char_pos_adj(self.pos);
+ let smap = SourceMap::new(FilePathMapping::empty());
+ smap.files.borrow_mut().source_files.push(self.source_file.clone());
+ let loc = smap.lookup_char_pos_adj(self.pos);
debug!("Skipping a shebang");
if loc.line == 1 && loc.col == CharPos(0) {
// FIXME: Add shebang "token", return it
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lock;
use with_globals;
- fn mk_sess(cm: Lrc<SourceMap>) -> ParseSess {
+ fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
- Some(cm.clone()),
+ Some(sm.clone()),
false,
false);
ParseSess {
unstable_features: UnstableFeatures::from_environment(),
config: CrateConfig::default(),
included_mod_stack: Lock::new(Vec::new()),
- code_map: cm,
+ source_map: sm,
missing_fragment_specifiers: Lock::new(FxHashSet::default()),
raw_identifier_spans: Lock::new(Vec::new()),
registered_diagnostics: Lock::new(ErrorMap::new()),
}
// open a string reader for the given string
- fn setup<'a>(cm: &SourceMap,
+ fn setup<'a>(sm: &SourceMap,
sess: &'a ParseSess,
teststr: String)
-> StringReader<'a> {
- let fm = cm.new_source_file(PathBuf::from("zebra.rs").into(), teststr);
- StringReader::new(sess, fm, None)
+ let sf = sm.new_source_file(PathBuf::from("zebra.rs").into(), teststr);
+ StringReader::new(sess, sf, None)
}
#[test]
fn t1() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- let mut string_reader = setup(&cm,
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ let mut string_reader = setup(&sm,
&sh,
"/* my source file */ fn main() { println!(\"zebra\"); }\n"
.to_string());
#[test]
fn doublecolonparsing() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- check_tokenization(setup(&cm, &sh, "a b".to_string()),
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ check_tokenization(setup(&sm, &sh, "a b".to_string()),
vec![mk_ident("a"), token::Whitespace, mk_ident("b")]);
})
}
#[test]
fn dcparsing_2() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- check_tokenization(setup(&cm, &sh, "a::b".to_string()),
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ check_tokenization(setup(&sm, &sh, "a::b".to_string()),
vec![mk_ident("a"), token::ModSep, mk_ident("b")]);
})
}
#[test]
fn dcparsing_3() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- check_tokenization(setup(&cm, &sh, "a ::b".to_string()),
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ check_tokenization(setup(&sm, &sh, "a ::b".to_string()),
vec![mk_ident("a"), token::Whitespace, token::ModSep, mk_ident("b")]);
})
}
#[test]
fn dcparsing_4() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- check_tokenization(setup(&cm, &sh, "a:: b".to_string()),
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ check_tokenization(setup(&sm, &sh, "a:: b".to_string()),
vec![mk_ident("a"), token::ModSep, token::Whitespace, mk_ident("b")]);
})
}
#[test]
fn character_a() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- assert_eq!(setup(&cm, &sh, "'a'".to_string()).next_token().tok,
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token().tok,
token::Literal(token::Char(Symbol::intern("a")), None));
})
}
#[test]
fn character_space() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- assert_eq!(setup(&cm, &sh, "' '".to_string()).next_token().tok,
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token().tok,
token::Literal(token::Char(Symbol::intern(" ")), None));
})
}
#[test]
fn character_escaped() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- assert_eq!(setup(&cm, &sh, "'\\n'".to_string()).next_token().tok,
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ assert_eq!(setup(&sm, &sh, "'\\n'".to_string()).next_token().tok,
token::Literal(token::Char(Symbol::intern("\\n")), None));
})
}
#[test]
fn lifetime_name() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- assert_eq!(setup(&cm, &sh, "'abc".to_string()).next_token().tok,
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ assert_eq!(setup(&sm, &sh, "'abc".to_string()).next_token().tok,
token::Lifetime(Ident::from_str("'abc")));
})
}
#[test]
fn raw_string() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- assert_eq!(setup(&cm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string())
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ assert_eq!(setup(&sm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string())
.next_token()
.tok,
token::Literal(token::StrRaw(Symbol::intern("\"#a\\b\x00c\""), 3), None));
#[test]
fn literal_suffixes() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
macro_rules! test {
($input: expr, $tok_type: ident, $tok_contents: expr) => {{
- assert_eq!(setup(&cm, &sh, format!("{}suffix", $input)).next_token().tok,
+ assert_eq!(setup(&sm, &sh, format!("{}suffix", $input)).next_token().tok,
token::Literal(token::$tok_type(Symbol::intern($tok_contents)),
Some(Symbol::intern("suffix"))));
// with a whitespace separator:
- assert_eq!(setup(&cm, &sh, format!("{} suffix", $input)).next_token().tok,
+ assert_eq!(setup(&sm, &sh, format!("{} suffix", $input)).next_token().tok,
token::Literal(token::$tok_type(Symbol::intern($tok_contents)),
None));
}}
test!("1.0", Float, "1.0");
test!("1.0e10", Float, "1.0e10");
- assert_eq!(setup(&cm, &sh, "2us".to_string()).next_token().tok,
+ assert_eq!(setup(&sm, &sh, "2us".to_string()).next_token().tok,
token::Literal(token::Integer(Symbol::intern("2")),
Some(Symbol::intern("us"))));
- assert_eq!(setup(&cm, &sh, "r###\"raw\"###suffix".to_string()).next_token().tok,
+ assert_eq!(setup(&sm, &sh, "r###\"raw\"###suffix".to_string()).next_token().tok,
token::Literal(token::StrRaw(Symbol::intern("raw"), 3),
Some(Symbol::intern("suffix"))));
- assert_eq!(setup(&cm, &sh, "br###\"raw\"###suffix".to_string()).next_token().tok,
+ assert_eq!(setup(&sm, &sh, "br###\"raw\"###suffix".to_string()).next_token().tok,
token::Literal(token::ByteStrRaw(Symbol::intern("raw"), 3),
Some(Symbol::intern("suffix"))));
})
#[test]
fn nested_block_comments() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- let mut lexer = setup(&cm, &sh, "/* /* */ */'a'".to_string());
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ let mut lexer = setup(&sm, &sh, "/* /* */ */'a'".to_string());
match lexer.next_token().tok {
token::Comment => {}
_ => panic!("expected a comment!"),
#[test]
fn crlf_comments() {
with_globals(|| {
- let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- let sh = mk_sess(cm.clone());
- let mut lexer = setup(&cm, &sh, "// test\r\n/// test\r\n".to_string());
+ let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let sh = mk_sess(sm.clone());
+ let mut lexer = setup(&sm, &sh, "// test\r\n/// test\r\n".to_string());
let comment = lexer.next_token();
assert_eq!(comment.tok, token::Comment);
assert_eq!((comment.sp.lo(), comment.sp.hi()), (BytePos(0), BytePos(7)));
pub non_modrs_mods: Lock<Vec<(ast::Ident, Span)>>,
/// Used to determine and report recursive mod inclusions
included_mod_stack: Lock<Vec<PathBuf>>,
- code_map: Lrc<SourceMap>,
+ source_map: Lrc<SourceMap>,
pub buffered_lints: Lock<Vec<BufferedEarlyLint>>,
}
ParseSess::with_span_handler(handler, cm)
}
- pub fn with_span_handler(handler: Handler, code_map: Lrc<SourceMap>) -> ParseSess {
+ pub fn with_span_handler(handler: Handler, source_map: Lrc<SourceMap>) -> ParseSess {
ParseSess {
span_diagnostic: handler,
unstable_features: UnstableFeatures::from_environment(),
raw_identifier_spans: Lock::new(Vec::new()),
registered_diagnostics: Lock::new(ErrorMap::new()),
included_mod_stack: Lock::new(vec![]),
- code_map,
+ source_map,
non_modrs_mods: Lock::new(vec![]),
buffered_lints: Lock::new(vec![]),
}
}
pub fn source_map(&self) -> &SourceMap {
- &self.code_map
+ &self.source_map
}
pub fn buffer_lint<S: Into<MultiSpan>>(&self,
// subsequent compilation sessions (which is something we need to do during
// incremental compilation).
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
-pub struct StableFilemapId(u128);
+pub struct StableSourceFileId(u128);
-impl StableFilemapId {
- pub fn new(source_file: &SourceFile) -> StableFilemapId {
+impl StableSourceFileId {
+ pub fn new(source_file: &SourceFile) -> StableSourceFileId {
let mut hasher = StableHasher::new();
source_file.name.hash(&mut hasher);
source_file.name_was_remapped.hash(&mut hasher);
source_file.unmapped_path.hash(&mut hasher);
- StableFilemapId(hasher.finish())
+ StableSourceFileId(hasher.finish())
}
}
#[derive(Default)]
pub(super) struct SourceMapFiles {
- pub(super) file_maps: Vec<Lrc<SourceFile>>,
- stable_id_to_source_file: FxHashMap<StableFilemapId, Lrc<SourceFile>>
+ pub(super) source_files: Vec<Lrc<SourceFile>>,
+ stable_id_to_source_file: FxHashMap<StableSourceFileId, Lrc<SourceFile>>
}
pub struct SourceMap {
}
pub fn files(&self) -> MappedLockGuard<Vec<Lrc<SourceFile>>> {
- LockGuard::map(self.files.borrow(), |files| &mut files.file_maps)
+ LockGuard::map(self.files.borrow(), |files| &mut files.source_files)
}
- pub fn source_file_by_stable_id(&self, stable_id: StableFilemapId) -> Option<Lrc<SourceFile>> {
- self.files.borrow().stable_id_to_source_file.get(&stable_id).map(|fm| fm.clone())
+ pub fn source_file_by_stable_id(&self, stable_id: StableSourceFileId) ->
+ Option<Lrc<SourceFile>> {
+ self.files.borrow().stable_id_to_source_file.get(&stable_id).map(|sf| sf.clone())
}
fn next_start_pos(&self) -> usize {
- match self.files.borrow().file_maps.last() {
+ match self.files.borrow().source_files.last() {
None => 0,
// Add one so there is some space between files. This lets us distinguish
// positions in the source_map, even in the presence of zero-length files.
let mut files = self.files.borrow_mut();
- files.file_maps.push(source_file.clone());
- files.stable_id_to_source_file.insert(StableFilemapId::new(&source_file),
+ files.source_files.push(source_file.clone());
+ files.stable_id_to_source_file.insert(StableSourceFileId::new(&source_file),
source_file.clone());
source_file
let mut files = self.files.borrow_mut();
- files.file_maps.push(source_file.clone());
- files.stable_id_to_source_file.insert(StableFilemapId::new(&source_file),
+ files.source_files.push(source_file.clone());
+ files.stable_id_to_source_file.insert(StableSourceFileId::new(&source_file),
source_file.clone());
source_file
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
let chpos = self.bytepos_to_file_charpos(pos);
match self.lookup_line(pos) {
- Ok(SourceFileAndLine { fm: f, line: a }) => {
+ Ok(SourceFileAndLine { sf: f, line: a }) => {
let line = a + 1; // Line numbers start at 1
let linebpos = f.lines[a];
let linechpos = self.bytepos_to_file_charpos(linebpos);
pub fn lookup_line(&self, pos: BytePos) -> Result<SourceFileAndLine, Lrc<SourceFile>> {
let idx = self.lookup_source_file_idx(pos);
- let f = (*self.files.borrow().file_maps)[idx].clone();
+ let f = (*self.files.borrow().source_files)[idx].clone();
match f.lookup_line(pos) {
- Some(line) => Ok(SourceFileAndLine { fm: f, line: line }),
+ Some(line) => Ok(SourceFileAndLine { sf: f, line: line }),
None => Err(f)
}
}
}
pub fn span_to_string(&self, sp: Span) -> String {
- if self.files.borrow().file_maps.is_empty() && sp.is_dummy() {
+ if self.files.borrow().source_files.is_empty() && sp.is_dummy() {
return "no-location".to_string();
}
let local_begin = self.lookup_byte_offset(sp.lo());
let local_end = self.lookup_byte_offset(sp.hi());
- if local_begin.fm.start_pos != local_end.fm.start_pos {
+ if local_begin.sf.start_pos != local_end.sf.start_pos {
return Err(SpanSnippetError::DistinctSources(DistinctSources {
- begin: (local_begin.fm.name.clone(),
- local_begin.fm.start_pos),
- end: (local_end.fm.name.clone(),
- local_end.fm.start_pos)
+ begin: (local_begin.sf.name.clone(),
+ local_begin.sf.start_pos),
+ end: (local_end.sf.name.clone(),
+ local_end.sf.start_pos)
}));
} else {
- self.ensure_source_file_source_present(local_begin.fm.clone());
+ self.ensure_source_file_source_present(local_begin.sf.clone());
let start_index = local_begin.pos.to_usize();
let end_index = local_end.pos.to_usize();
- let source_len = (local_begin.fm.end_pos -
- local_begin.fm.start_pos).to_usize();
+ let source_len = (local_begin.sf.end_pos -
+ local_begin.sf.start_pos).to_usize();
if start_index > end_index || end_index > source_len {
- return Err(SpanSnippetError::MalformedForCodemap(
- MalformedCodemapPositions {
- name: local_begin.fm.name.clone(),
+ return Err(SpanSnippetError::MalformedForSourcemap(
+ MalformedSourceMapPositions {
+ name: local_begin.sf.name.clone(),
source_len,
begin_pos: local_begin.pos,
end_pos: local_end.pos,
}));
}
- if let Some(ref src) = local_begin.fm.src {
+ if let Some(ref src) = local_begin.sf.src {
return Ok(extract_source(src, start_index, end_index));
- } else if let Some(src) = local_begin.fm.external_src.borrow().get_source() {
+ } else if let Some(src) = local_begin.sf.external_src.borrow().get_source() {
return Ok(extract_source(src, start_index, end_index));
} else {
return Err(SpanSnippetError::SourceNotAvailable {
- filename: local_begin.fm.name.clone()
+ filename: local_begin.sf.name.clone()
});
}
}
return 1;
}
- let source_len = (local_begin.fm.end_pos - local_begin.fm.start_pos).to_usize();
+ let source_len = (local_begin.sf.end_pos - local_begin.sf.start_pos).to_usize();
debug!("find_width_of_character_at_span: source_len=`{:?}`", source_len);
// Ensure indexes are also not malformed.
if start_index > end_index || end_index > source_len {
return 1;
}
- let src = local_begin.fm.external_src.borrow();
+ let src = local_begin.sf.external_src.borrow();
// We need to extend the snippet to the end of the src rather than to end_index so when
// searching forwards for boundaries we've got somewhere to search.
- let snippet = if let Some(ref src) = local_begin.fm.src {
+ let snippet = if let Some(ref src) = local_begin.sf.src {
let len = src.len();
(&src[start_index..len])
} else if let Some(src) = src.get_source() {
}
pub fn get_source_file(&self, filename: &FileName) -> Option<Lrc<SourceFile>> {
- for fm in self.files.borrow().file_maps.iter() {
- if *filename == fm.name {
- return Some(fm.clone());
+ for sf in self.files.borrow().source_files.iter() {
+ if *filename == sf.name {
+ return Some(sf.clone());
}
}
None
/// For a global BytePos compute the local offset within the containing SourceFile
pub fn lookup_byte_offset(&self, bpos: BytePos) -> SourceFileAndBytePos {
let idx = self.lookup_source_file_idx(bpos);
- let fm = (*self.files.borrow().file_maps)[idx].clone();
- let offset = bpos - fm.start_pos;
- SourceFileAndBytePos {fm: fm, pos: offset}
+ let sf = (*self.files.borrow().source_files)[idx].clone();
+ let offset = bpos - sf.start_pos;
+ SourceFileAndBytePos {sf: sf, pos: offset}
}
/// Converts an absolute BytePos to a CharPos relative to the source_file.
pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos {
let idx = self.lookup_source_file_idx(bpos);
- let map = &(*self.files.borrow().file_maps)[idx];
+ let map = &(*self.files.borrow().source_files)[idx];
// The number of extra bytes due to multibyte chars in the SourceFile
let mut total_extra_bytes = 0;
// Return the index of the source_file (in self.files) which contains pos.
pub fn lookup_source_file_idx(&self, pos: BytePos) -> usize {
let files = self.files.borrow();
- let files = &files.file_maps;
+ let files = &files.source_files;
let count = files.len();
// Binary search for the source_file.
}
sp
}
- fn ensure_source_file_source_present(&self, file_map: Lrc<SourceFile>) -> bool {
- file_map.add_external_src(
- || match file_map.name {
+ fn ensure_source_file_source_present(&self, source_file: Lrc<SourceFile>) -> bool {
+ source_file.add_external_src(
+ || match source_file.name {
FileName::Real(ref name) => self.file_loader.read_file(name).ok(),
_ => None,
}
use super::*;
use rustc_data_structures::sync::Lrc;
- fn init_code_map() -> SourceMap {
- let cm = SourceMap::new(FilePathMapping::empty());
- cm.new_source_file(PathBuf::from("blork.rs").into(),
+ fn init_source_map() -> SourceMap {
+ let sm = SourceMap::new(FilePathMapping::empty());
+ sm.new_source_file(PathBuf::from("blork.rs").into(),
"first line.\nsecond line".to_string());
- cm.new_source_file(PathBuf::from("empty.rs").into(),
+ sm.new_source_file(PathBuf::from("empty.rs").into(),
String::new());
- cm.new_source_file(PathBuf::from("blork2.rs").into(),
+ sm.new_source_file(PathBuf::from("blork2.rs").into(),
"first line.\nsecond line".to_string());
- cm
+ sm
}
#[test]
fn t3() {
// Test lookup_byte_offset
- let cm = init_code_map();
+ let sm = init_source_map();
- let fmabp1 = cm.lookup_byte_offset(BytePos(23));
- assert_eq!(fmabp1.fm.name, PathBuf::from("blork.rs").into());
- assert_eq!(fmabp1.pos, BytePos(23));
+ let srcfbp1 = sm.lookup_byte_offset(BytePos(23));
+ assert_eq!(srcfbp1.sf.name, PathBuf::from("blork.rs").into());
+ assert_eq!(srcfbp1.pos, BytePos(23));
- let fmabp1 = cm.lookup_byte_offset(BytePos(24));
- assert_eq!(fmabp1.fm.name, PathBuf::from("empty.rs").into());
- assert_eq!(fmabp1.pos, BytePos(0));
+ let srcfbp1 = sm.lookup_byte_offset(BytePos(24));
+ assert_eq!(srcfbp1.sf.name, PathBuf::from("empty.rs").into());
+ assert_eq!(srcfbp1.pos, BytePos(0));
- let fmabp2 = cm.lookup_byte_offset(BytePos(25));
- assert_eq!(fmabp2.fm.name, PathBuf::from("blork2.rs").into());
- assert_eq!(fmabp2.pos, BytePos(0));
+ let srcfbp2 = sm.lookup_byte_offset(BytePos(25));
+ assert_eq!(srcfbp2.sf.name, PathBuf::from("blork2.rs").into());
+ assert_eq!(srcfbp2.pos, BytePos(0));
}
#[test]
fn t4() {
// Test bytepos_to_file_charpos
- let cm = init_code_map();
+ let sm = init_source_map();
- let cp1 = cm.bytepos_to_file_charpos(BytePos(22));
+ let cp1 = sm.bytepos_to_file_charpos(BytePos(22));
assert_eq!(cp1, CharPos(22));
- let cp2 = cm.bytepos_to_file_charpos(BytePos(25));
+ let cp2 = sm.bytepos_to_file_charpos(BytePos(25));
assert_eq!(cp2, CharPos(0));
}
#[test]
fn t5() {
// Test zero-length source_files.
- let cm = init_code_map();
+ let sm = init_source_map();
- let loc1 = cm.lookup_char_pos(BytePos(22));
+ let loc1 = sm.lookup_char_pos(BytePos(22));
assert_eq!(loc1.file.name, PathBuf::from("blork.rs").into());
assert_eq!(loc1.line, 2);
assert_eq!(loc1.col, CharPos(10));
- let loc2 = cm.lookup_char_pos(BytePos(25));
+ let loc2 = sm.lookup_char_pos(BytePos(25));
assert_eq!(loc2.file.name, PathBuf::from("blork2.rs").into());
assert_eq!(loc2.line, 1);
assert_eq!(loc2.col, CharPos(0));
}
- fn init_code_map_mbc() -> SourceMap {
- let cm = SourceMap::new(FilePathMapping::empty());
+ fn init_source_map_mbc() -> SourceMap {
+ let sm = SourceMap::new(FilePathMapping::empty());
// € is a three byte utf8 char.
- cm.new_source_file(PathBuf::from("blork.rs").into(),
+ sm.new_source_file(PathBuf::from("blork.rs").into(),
"fir€st €€€€ line.\nsecond line".to_string());
- cm.new_source_file(PathBuf::from("blork2.rs").into(),
+ sm.new_source_file(PathBuf::from("blork2.rs").into(),
"first line€€.\n€ second line".to_string());
- cm
+ sm
}
#[test]
fn t6() {
// Test bytepos_to_file_charpos in the presence of multi-byte chars
- let cm = init_code_map_mbc();
+ let sm = init_source_map_mbc();
- let cp1 = cm.bytepos_to_file_charpos(BytePos(3));
+ let cp1 = sm.bytepos_to_file_charpos(BytePos(3));
assert_eq!(cp1, CharPos(3));
- let cp2 = cm.bytepos_to_file_charpos(BytePos(6));
+ let cp2 = sm.bytepos_to_file_charpos(BytePos(6));
assert_eq!(cp2, CharPos(4));
- let cp3 = cm.bytepos_to_file_charpos(BytePos(56));
+ let cp3 = sm.bytepos_to_file_charpos(BytePos(56));
assert_eq!(cp3, CharPos(12));
- let cp4 = cm.bytepos_to_file_charpos(BytePos(61));
+ let cp4 = sm.bytepos_to_file_charpos(BytePos(61));
assert_eq!(cp4, CharPos(15));
}
#[test]
fn t7() {
// Test span_to_lines for a span ending at the end of source_file
- let cm = init_code_map();
+ let sm = init_source_map();
let span = Span::new(BytePos(12), BytePos(23), NO_EXPANSION);
- let file_lines = cm.span_to_lines(span).unwrap();
+ let file_lines = sm.span_to_lines(span).unwrap();
assert_eq!(file_lines.file.name, PathBuf::from("blork.rs").into());
assert_eq!(file_lines.lines.len(), 1);
/// lines in the middle of a file.
#[test]
fn span_to_snippet_and_lines_spanning_multiple_lines() {
- let cm = SourceMap::new(FilePathMapping::empty());
+ let sm = SourceMap::new(FilePathMapping::empty());
let inputtext = "aaaaa\nbbbbBB\nCCC\nDDDDDddddd\neee\n";
let selection = " \n ~~\n~~~\n~~~~~ \n \n";
- cm.new_source_file(Path::new("blork.rs").to_owned().into(), inputtext.to_string());
+ sm.new_source_file(Path::new("blork.rs").to_owned().into(), inputtext.to_string());
let span = span_from_selection(inputtext, selection);
// check that we are extracting the text we thought we were extracting
- assert_eq!(&cm.span_to_snippet(span).unwrap(), "BB\nCCC\nDDDDD");
+ assert_eq!(&sm.span_to_snippet(span).unwrap(), "BB\nCCC\nDDDDD");
// check that span_to_lines gives us the complete result with the lines/cols we expected
- let lines = cm.span_to_lines(span).unwrap();
+ let lines = sm.span_to_lines(span).unwrap();
let expected = vec![
LineInfo { line_index: 1, start_col: CharPos(4), end_col: CharPos(6) },
LineInfo { line_index: 2, start_col: CharPos(0), end_col: CharPos(3) },
#[test]
fn t8() {
// Test span_to_snippet for a span ending at the end of source_file
- let cm = init_code_map();
+ let sm = init_source_map();
let span = Span::new(BytePos(12), BytePos(23), NO_EXPANSION);
- let snippet = cm.span_to_snippet(span);
+ let snippet = sm.span_to_snippet(span);
assert_eq!(snippet, Ok("second line".to_string()));
}
#[test]
fn t9() {
// Test span_to_str for a span ending at the end of source_file
- let cm = init_code_map();
+ let sm = init_source_map();
let span = Span::new(BytePos(12), BytePos(23), NO_EXPANSION);
- let sstr = cm.span_to_string(span);
+ let sstr = sm.span_to_string(span);
assert_eq!(sstr, "blork.rs:2:1: 2:12");
}
/// Test failing to merge two spans on different lines
#[test]
fn span_merging_fail() {
- let cm = SourceMap::new(FilePathMapping::empty());
+ let sm = SourceMap::new(FilePathMapping::empty());
let inputtext = "bbbb BB\ncc CCC\n";
let selection1 = " ~~\n \n";
let selection2 = " \n ~~~\n";
- cm.new_source_file(Path::new("blork.rs").to_owned().into(), inputtext.to_owned());
+ sm.new_source_file(Path::new("blork.rs").to_owned().into(), inputtext.to_owned());
let span1 = span_from_selection(inputtext, selection1);
let span2 = span_from_selection(inputtext, selection2);
- assert!(cm.merge_spans(span1, span2).is_none());
+ assert!(sm.merge_spans(span1, span2).is_none());
}
/// Returns the span corresponding to the `n`th occurrence of
with_globals(|| {
let output = Arc::new(Mutex::new(Vec::new()));
- let code_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
- code_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned());
+ let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ source_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned());
let primary_span = make_span(&file_text, &span_labels[0].start, &span_labels[0].end);
let mut msp = MultiSpan::from_span(primary_span);
let span = make_span(&file_text, &span_label.start, &span_label.end);
msp.push_span_label(span, span_label.label.to_string());
println!("span: {:?} label: {:?}", span, span_label.label);
- println!("text: {:?}", code_map.span_to_snippet(span));
+ println!("text: {:?}", source_map.span_to_snippet(span));
}
let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }),
- Some(code_map.clone()),
+ Some(source_map.clone()),
false,
false);
let handler = Handler::with_emitter(true, false, Box::new(emitter));
// it encounters. If that point is already outside the source_file, remove
// it again.
if let Some(&last_line_start) = lines.last() {
- let file_map_end = source_file_start_pos + BytePos::from_usize(src.len());
- assert!(file_map_end >= last_line_start);
- if last_line_start == file_map_end {
+ let source_file_end = source_file_start_pos + BytePos::from_usize(src.len());
+ assert!(source_file_end >= last_line_start);
+ if last_line_start == source_file_end {
lines.pop();
}
}
// used to be structural records. Better names, anyone?
#[derive(Debug)]
-pub struct SourceFileAndLine { pub fm: Lrc<SourceFile>, pub line: usize }
+pub struct SourceFileAndLine { pub sf: Lrc<SourceFile>, pub line: usize }
#[derive(Debug)]
-pub struct SourceFileAndBytePos { pub fm: Lrc<SourceFile>, pub pos: BytePos }
+pub struct SourceFileAndBytePos { pub sf: Lrc<SourceFile>, pub pos: BytePos }
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct LineInfo {
}
// _____________________________________________________________________________
-// SpanLinesError, SpanSnippetError, DistinctSources, MalformedCodemapPositions
+// SpanLinesError, SpanSnippetError, DistinctSources, MalformedSourceMapPositions
//
pub type FileLinesResult = Result<FileLines, SpanLinesError>;
pub enum SpanSnippetError {
IllFormedSpan(Span),
DistinctSources(DistinctSources),
- MalformedForCodemap(MalformedCodemapPositions),
+ MalformedForSourcemap(MalformedSourceMapPositions),
SourceNotAvailable { filename: FileName }
}
}
#[derive(Clone, PartialEq, Eq, Debug)]
-pub struct MalformedCodemapPositions {
+pub struct MalformedSourceMapPositions {
pub name: FileName,
pub source_len: usize,
pub begin_pos: BytePos,
-Subproject commit caddcd9b9dc9479a20908d93c3e47c49b021379e
+Subproject commit 7051ead40a5f825878b59bf08d4e768be9e99a4a
unwrapDI<DIType>(VTableHolder), UniqueId));
}
+extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart(
+ LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+ LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
+ uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Discriminator,
+ LLVMMetadataRef Elements, const char *UniqueId) {
+#if LLVM_VERSION_GE(7, 0)
+ return wrap(Builder->createVariantPart(
+ unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
+ SizeInBits, AlignInBits, fromRust(Flags), unwrapDI<DIDerivedType>(Discriminator),
+ DINodeArray(unwrapDI<MDTuple>(Elements)), UniqueId));
+#else
+ abort();
+#endif
+}
+
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMemberType(
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
fromRust(Flags), unwrapDI<DIType>(Ty)));
}
+extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType(
+ LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
+ const char *Name, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
+ uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant,
+ LLVMRustDIFlags Flags, LLVMMetadataRef Ty) {
+#if LLVM_VERSION_GE(7, 0)
+ llvm::ConstantInt* D = nullptr;
+ if (Discriminant) {
+ D = unwrap<llvm::ConstantInt>(Discriminant);
+ }
+ return wrap(Builder->createVariantMemberType(unwrapDI<DIDescriptor>(Scope), Name,
+ unwrapDI<DIFile>(File), LineNo,
+ SizeInBits, AlignInBits, OffsetInBits, D,
+ fromRust(Flags), unwrapDI<DIType>(Ty)));
+#else
+ return wrap(Builder->createMemberType(unwrapDI<DIDescriptor>(Scope), Name,
+ unwrapDI<DIFile>(File), LineNo,
+ SizeInBits, AlignInBits, OffsetInBits,
+ fromRust(Flags), unwrapDI<DIType>(Ty)));
+#endif
+}
+
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateLexicalBlock(
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
LLVMMetadataRef File, unsigned Line, unsigned Col) {
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
uint32_t AlignInBits, LLVMMetadataRef Elements,
- LLVMMetadataRef ClassTy) {
+ LLVMMetadataRef ClassTy, bool IsFixed) {
+#if LLVM_VERSION_GE(7, 0)
return wrap(Builder->createEnumerationType(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
- unwrapDI<DIType>(ClassTy)));
+ unwrapDI<DIType>(ClassTy), "", IsFixed));
+#else
+ // Ignore IsFixed on older LLVM.
+ return wrap(Builder->createEnumerationType(
+ unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
+ SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
+ unwrapDI<DIType>(ClassTy), ""));
+#endif
}
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
# `0.x.0` for Cargo where they were released on `date`.
-date: 2018-10-13
+date: 2018-10-30
rustc: beta
cargo: beta
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test depends on a patch that was committed to upstream LLVM
+// before 7.0, then backported to the Rust LLVM fork. It tests that
+// debug info for "c-like" enums is properly emitted.
+
+// ignore-tidy-linelength
+// ignore-windows
+// min-system-llvm-version 7.0
+
+// compile-flags: -g -C no-prepopulate-passes
+
+// CHECK-LABEL: @main
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "E",{{.*}}flags: DIFlagFixedEnum,{{.*}}
+// CHECK: {{.*}}DIEnumerator{{.*}}name: "A",{{.*}}value: {{[0-9].*}}
+// CHECK: {{.*}}DIEnumerator{{.*}}name: "B",{{.*}}value: {{[0-9].*}}
+// CHECK: {{.*}}DIEnumerator{{.*}}name: "C",{{.*}}value: {{[0-9].*}}
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+#![allow(unused_assignments)]
+
+enum E { A, B, C }
+
+pub fn main() {
+ let e = E::C;
+}
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test depends on a patch that was committed to upstream LLVM
+// before 7.0, then backported to the Rust LLVM fork. It tests that
+// optimized enum debug info accurately reflects the enum layout.
+
+// ignore-tidy-linelength
+// ignore-windows
+// min-system-llvm-version 7.0
+
+// compile-flags: -g -C no-prepopulate-passes
+
+// CHECK-LABEL: @main
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}}
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}}
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "C",{{.*}}extraData:{{.*}}
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "C",{{.*}}
+// CHECK-NOT: {{.*}}DIDerivedType{{.*}}name: "D",{{.*}}extraData:{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "D",{{.*}}
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "D",{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}}
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+#![allow(unused_assignments)]
+
+enum E { A, B, C, D(bool) }
+
+pub fn main() {
+ let e = E::D(true);
+}
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test depends on a patch that was committed to upstream LLVM
+// before 7.0, then backported to the Rust LLVM fork. It tests that
+// debug info for tagged (ordinary) enums is properly emitted.
+
+// ignore-tidy-linelength
+// ignore-windows
+// min-system-llvm-version 7.0
+
+// compile-flags: -g -C no-prepopulate-passes
+
+// CHECK-LABEL: @main
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "E",{{.*}}
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}}
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}}
+// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}}
+// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}}
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+#![allow(unused_assignments)]
+
+enum E { A(u32), B(u32) }
+
+pub fn main() {
+ let e = E::A(23);
+}
// min-lldb-version: 310
+// This fails on lldb 6.0.1 on x86-64 Fedora 28; so mark it macOS-only
+// for now.
+// only-macos
+
// compile-flags:-g
// === GDB TESTS ===================================================================================
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// min-lldb-version: 310
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 7.11.90 - 7.12.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:run
+
+// gdb-command:print *the_a_ref
+// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
+// gdbr-check:$1 = borrowed_enum_legacy::ABC::TheA{x: 0, y: 8970181431921507452}
+
+// gdb-command:print *the_b_ref
+// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
+// gdbr-check:$2 = borrowed_enum_legacy::ABC::TheB(0, 286331153, 286331153)
+
+// gdb-command:print *univariant_ref
+// gdbg-check:$3 = {{__0 = 4820353753753434}}
+// gdbr-check:$3 = borrowed_enum_legacy::Univariant::TheOnlyCase(4820353753753434)
+
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *the_a_ref
+// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
+// lldbr-check:(borrowed_enum_legacy::ABC::TheA) *the_a_ref = TheA { borrowed_enum_legacy::ABC::TheA: 0, borrowed_enum_legacy::ABC::TheB: 8970181431921507452 }
+// lldb-command:print *the_b_ref
+// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153)
+// lldbr-check:(borrowed_enum_legacy::ABC::TheB) *the_b_ref = { = 0 = 286331153 = 286331153 }
+// lldb-command:print *univariant_ref
+// lldbg-check:[...]$2 = TheOnlyCase(4820353753753434)
+// lldbr-check:(borrowed_enum_legacy::Univariant) *univariant_ref = { borrowed_enum_legacy::TheOnlyCase = { = 4820353753753434 } }
+
+#![allow(unused_variables)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+enum ABC {
+ TheA { x: i64, y: i64 },
+ TheB (i64, i32, i32),
+}
+
+// This is a special case since it does not have the implicit discriminant field.
+enum Univariant {
+ TheOnlyCase(i64)
+}
+
+fn main() {
+
+ // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
+ // 0b01111100011111000111110001111100 = 2088533116
+ // 0b0111110001111100 = 31868
+ // 0b01111100 = 124
+ let the_a = ABC::TheA { x: 0, y: 8970181431921507452 };
+ let the_a_ref: &ABC = &the_a;
+
+ // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
+ // 0b00010001000100010001000100010001 = 286331153
+ // 0b0001000100010001 = 4369
+ // 0b00010001 = 17
+ let the_b = ABC::TheB (0, 286331153, 286331153);
+ let the_b_ref: &ABC = &the_b;
+
+ let univariant = Univariant::TheOnlyCase(4820353753753434);
+ let univariant_ref: &Univariant = &univariant;
+
+ zzz(); // #break
+}
+
+fn zzz() {()}
// except according to those terms.
// ignore-tidy-linelength
-// min-lldb-version: 310
-// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// Require LLVM with DW_TAG_variant_part and a gdb or lldb that can read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
+// rust-lldb
// compile-flags:-g
// gdb-command:run
// gdb-command:print *the_a_ref
-// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
// gdbr-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452}
// gdb-command:print *the_b_ref
-// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
// gdbr-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153)
// gdb-command:print *univariant_ref
-// gdbg-check:$3 = {{__0 = 4820353753753434}}
// gdbr-check:$3 = borrowed_enum::Univariant::TheOnlyCase(4820353753753434)
// lldb-command:run
// lldb-command:print *the_a_ref
-// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
-// lldbr-check:(borrowed_enum::ABC::TheA) *the_a_ref = TheA { borrowed_enum::ABC::TheA: 0, borrowed_enum::ABC::TheB: 8970181431921507452 }
+// lldbr-check:(borrowed_enum::ABC::TheA) *the_a_ref = TheA { TheA: 0, TheB: 8970181431921507452 }
// lldb-command:print *the_b_ref
-// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153)
// lldbr-check:(borrowed_enum::ABC::TheB) *the_b_ref = { = 0 = 286331153 = 286331153 }
// lldb-command:print *univariant_ref
-// lldbg-check:[...]$2 = TheOnlyCase(4820353753753434)
-// lldbr-check:(borrowed_enum::Univariant) *univariant_ref = { borrowed_enum::TheOnlyCase = { = 4820353753753434 } }
+// lldbr-check:(borrowed_enum::Univariant) *univariant_ref = { TheOnlyCase = { = 4820353753753434 } }
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
// min-lldb-version: 310
+// This fails on lldb 6.0.1 on x86-64 Fedora 28; so mark it macOS-only
+// for now.
+// only-macos
+
// aux-build:cross_crate_spans.rs
extern crate cross_crate_spans;
// min-lldb-version: 310
+// This fails on lldb 6.0.1 on x86-64 Fedora 28; so mark it macOS-only
+// for now.
+// only-macos
+
// compile-flags:-g
// === GDB TESTS ===================================================================================
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// ignore-lldb: FIXME(#27089)
+// min-lldb-version: 310
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+// gdb-command:run
+
+// gdb-command:print eight_bytes1
+// gdbg-check:$1 = {{RUST$ENUM$DISR = Variant1, __0 = 100}, {RUST$ENUM$DISR = Variant1, __0 = 100}}
+// gdbr-check:$1 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(100)
+
+// gdb-command:print four_bytes1
+// gdbg-check:$2 = {{RUST$ENUM$DISR = Variant1, __0 = 101}, {RUST$ENUM$DISR = Variant1, __0 = 101}}
+// gdbr-check:$2 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(101)
+
+// gdb-command:print two_bytes1
+// gdbg-check:$3 = {{RUST$ENUM$DISR = Variant1, __0 = 102}, {RUST$ENUM$DISR = Variant1, __0 = 102}}
+// gdbr-check:$3 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(102)
+
+// gdb-command:print one_byte1
+// gdbg-check:$4 = {{RUST$ENUM$DISR = Variant1, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant1, __0 = 65 'A'}}
+// gdbr-check:$4 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(65)
+
+
+// gdb-command:print eight_bytes2
+// gdbg-check:$5 = {{RUST$ENUM$DISR = Variant2, __0 = 100}, {RUST$ENUM$DISR = Variant2, __0 = 100}}
+// gdbr-check:$5 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(100)
+
+// gdb-command:print four_bytes2
+// gdbg-check:$6 = {{RUST$ENUM$DISR = Variant2, __0 = 101}, {RUST$ENUM$DISR = Variant2, __0 = 101}}
+// gdbr-check:$6 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(101)
+
+// gdb-command:print two_bytes2
+// gdbg-check:$7 = {{RUST$ENUM$DISR = Variant2, __0 = 102}, {RUST$ENUM$DISR = Variant2, __0 = 102}}
+// gdbr-check:$7 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(102)
+
+// gdb-command:print one_byte2
+// gdbg-check:$8 = {{RUST$ENUM$DISR = Variant2, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant2, __0 = 65 'A'}}
+// gdbr-check:$8 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(65)
+
+// gdb-command:continue
+
+// === LLDB TESTS ==================================================================================
+// lldb-command:run
+
+// lldb-command:print eight_bytes1
+// lldb-check:[...]$0 = Variant1(100)
+// lldb-command:print four_bytes1
+// lldb-check:[...]$1 = Variant1(101)
+// lldb-command:print two_bytes1
+// lldb-check:[...]$2 = Variant1(102)
+// lldb-command:print one_byte1
+// lldb-check:[...]$3 = Variant1('A')
+
+// lldb-command:print eight_bytes2
+// lldb-check:[...]$4 = Variant2(100)
+// lldb-command:print four_bytes2
+// lldb-check:[...]$5 = Variant2(101)
+// lldb-command:print two_bytes2
+// lldb-check:[...]$6 = Variant2(102)
+// lldb-command:print one_byte2
+// lldb-check:[...]$7 = Variant2('A')
+
+// lldb-command:continue
+
+#![allow(unused_variables)]
+#![allow(dead_code)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+// This test case makes sure that we get correct type descriptions for the enum
+// discriminant of different instantiations of the same generic enum type where,
+// dependending on the generic type parameter(s), the discriminant has a
+// different size in memory.
+
+enum Enum<T> {
+ Variant1(T),
+ Variant2(T)
+}
+
+fn main() {
+ // These are ordered for descending size on purpose
+ let eight_bytes1 = Enum::Variant1(100.0f64);
+ let four_bytes1 = Enum::Variant1(101i32);
+ let two_bytes1 = Enum::Variant1(102i16);
+ let one_byte1 = Enum::Variant1(65u8);
+
+ let eight_bytes2 = Enum::Variant2(100.0f64);
+ let four_bytes2 = Enum::Variant2(101i32);
+ let two_bytes2 = Enum::Variant2(102i16);
+ let one_byte2 = Enum::Variant2(65u8);
+
+ zzz(); // #break
+}
+
+fn zzz() { () }
// ignore-lldb: FIXME(#27089)
// min-lldb-version: 310
+// Require LLVM with DW_TAG_variant_part and a gdb that can read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
+
// compile-flags:-g
// === GDB TESTS ===================================================================================
// gdb-command:run
// gdb-command:print eight_bytes1
-// gdbg-check:$1 = {{RUST$ENUM$DISR = Variant1, __0 = 100}, {RUST$ENUM$DISR = Variant1, __0 = 100}}
-// gdbr-check:$1 = generic_enum_with_different_disr_sizes::Enum::Variant1(100)
+// gdbr-check:$1 = generic_enum_with_different_disr_sizes::Enum<f64>::Variant1(100)
// gdb-command:print four_bytes1
-// gdbg-check:$2 = {{RUST$ENUM$DISR = Variant1, __0 = 101}, {RUST$ENUM$DISR = Variant1, __0 = 101}}
-// gdbr-check:$2 = generic_enum_with_different_disr_sizes::Enum::Variant1(101)
+// gdbr-check:$2 = generic_enum_with_different_disr_sizes::Enum<i32>::Variant1(101)
// gdb-command:print two_bytes1
-// gdbg-check:$3 = {{RUST$ENUM$DISR = Variant1, __0 = 102}, {RUST$ENUM$DISR = Variant1, __0 = 102}}
-// gdbr-check:$3 = generic_enum_with_different_disr_sizes::Enum::Variant1(102)
+// gdbr-check:$3 = generic_enum_with_different_disr_sizes::Enum<i16>::Variant1(102)
// gdb-command:print one_byte1
-// gdbg-check:$4 = {{RUST$ENUM$DISR = Variant1, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant1, __0 = 65 'A'}}
-// gdbr-check:$4 = generic_enum_with_different_disr_sizes::Enum::Variant1(65)
+// gdbr-check:$4 = generic_enum_with_different_disr_sizes::Enum<u8>::Variant1(65)
// gdb-command:print eight_bytes2
-// gdbg-check:$5 = {{RUST$ENUM$DISR = Variant2, __0 = 100}, {RUST$ENUM$DISR = Variant2, __0 = 100}}
-// gdbr-check:$5 = generic_enum_with_different_disr_sizes::Enum::Variant2(100)
+// gdbr-check:$5 = generic_enum_with_different_disr_sizes::Enum<f64>::Variant2(100)
// gdb-command:print four_bytes2
-// gdbg-check:$6 = {{RUST$ENUM$DISR = Variant2, __0 = 101}, {RUST$ENUM$DISR = Variant2, __0 = 101}}
-// gdbr-check:$6 = generic_enum_with_different_disr_sizes::Enum::Variant2(101)
+// gdbr-check:$6 = generic_enum_with_different_disr_sizes::Enum<i32>::Variant2(101)
// gdb-command:print two_bytes2
-// gdbg-check:$7 = {{RUST$ENUM$DISR = Variant2, __0 = 102}, {RUST$ENUM$DISR = Variant2, __0 = 102}}
-// gdbr-check:$7 = generic_enum_with_different_disr_sizes::Enum::Variant2(102)
+// gdbr-check:$7 = generic_enum_with_different_disr_sizes::Enum<i16>::Variant2(102)
// gdb-command:print one_byte2
-// gdbg-check:$8 = {{RUST$ENUM$DISR = Variant2, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant2, __0 = 65 'A'}}
-// gdbr-check:$8 = generic_enum_with_different_disr_sizes::Enum::Variant2(65)
+// gdbr-check:$8 = generic_enum_with_different_disr_sizes::Enum<u8>::Variant2(65)
// gdb-command:continue
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// min-lldb-version: 310
+// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// gdb-command:set print union on
+// gdb-command:run
+
+// gdb-command:print case1
+// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
+// gdbr-check:$1 = generic_struct_style_enum_legacy::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
+
+// gdb-command:print case2
+// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
+// gdbr-check:$2 = generic_struct_style_enum_legacy::Regular::Case2{a: 0, b: 286331153, c: 286331153}
+
+// gdb-command:print case3
+// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
+// gdbr-check:$3 = generic_struct_style_enum_legacy::Regular::Case3{a: 0, b: 6438275382588823897}
+
+// gdb-command:print univariant
+// gdbg-check:$4 = {{a = -1}}
+// gdbr-check:$4 = generic_struct_style_enum_legacy::Univariant<i32>::TheOnlyCase{a: -1}
+
+
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+use self::Regular::{Case1, Case2, Case3};
+use self::Univariant::TheOnlyCase;
+
+// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
+// substituted with something of size `xx` bits and the same alignment as an integer type of the
+// same size.
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+enum Regular<T16, T32, T64> {
+ Case1 { a: T64, b: T16, c: T16, d: T16, e: T16},
+ Case2 { a: T64, b: T32, c: T32},
+ Case3 { a: T64, b: T64 }
+}
+
+enum Univariant<T> {
+ TheOnlyCase { a: T }
+}
+
+fn main() {
+
+ // In order to avoid endianness trouble all of the following test values consist of a single
+ // repeated byte. This way each interpretation of the union should look the same, no matter if
+ // this is a big or little endian machine.
+
+ // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
+ // 0b01111100011111000111110001111100 = 2088533116
+ // 0b0111110001111100 = 31868
+ // 0b01111100 = 124
+ let case1: Regular<u16, u32, i64> = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 };
+
+ // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
+ // 0b00010001000100010001000100010001 = 286331153
+ // 0b0001000100010001 = 4369
+ // 0b00010001 = 17
+ let case2: Regular<i16, u32, i64> = Case2 { a: 0, b: 286331153, c: 286331153 };
+
+ // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
+ // 0b01011001010110010101100101011001 = 1499027801
+ // 0b0101100101011001 = 22873
+ // 0b01011001 = 89
+ let case3: Regular<u16, i32, u64> = Case3 { a: 0, b: 6438275382588823897 };
+
+ let univariant = TheOnlyCase { a: -1 };
+
+ zzz(); // #break
+}
+
+fn zzz() {()}
// ignore-tidy-linelength
// min-lldb-version: 310
-// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// Require LLVM with DW_TAG_variant_part and a gdb that can read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
// compile-flags:-g
// gdb-command:run
// gdb-command:print case1
-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
-// gdbr-check:$1 = generic_struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
+// gdbr-check:$1 = generic_struct_style_enum::Regular<u16, u32, i64>::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
// gdb-command:print case2
-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
-// gdbr-check:$2 = generic_struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153}
+// gdbr-check:$2 = generic_struct_style_enum::Regular<i16, u32, i64>::Case2{a: 0, b: 286331153, c: 286331153}
// gdb-command:print case3
-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
-// gdbr-check:$3 = generic_struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897}
+// gdbr-check:$3 = generic_struct_style_enum::Regular<u16, i32, u64>::Case3{a: 0, b: 6438275382588823897}
// gdb-command:print univariant
-// gdbg-check:$4 = {{a = -1}}
// gdbr-check:$4 = generic_struct_style_enum::Univariant<i32>::TheOnlyCase{a: -1}
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// min-lldb-version: 310
+// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:set print union on
+// gdb-command:run
+
+// gdb-command:print case1
+// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
+// gdbr-check:$1 = generic_tuple_style_enum_legacy::Regular::Case1(0, 31868, 31868, 31868, 31868)
+
+// gdb-command:print case2
+// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
+// gdbr-check:$2 = generic_tuple_style_enum_legacy::Regular::Case2(0, 286331153, 286331153)
+
+// gdb-command:print case3
+// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
+// gdbr-check:$3 = generic_tuple_style_enum_legacy::Regular::Case3(0, 6438275382588823897)
+
+// gdb-command:print univariant
+// gdbg-check:$4 = {{__0 = -1}}
+// gdbr-check:$4 = generic_tuple_style_enum_legacy::Univariant<i64>::TheOnlyCase(-1)
+
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print case1
+// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
+// lldbr-check:(generic_tuple_style_enum_legacy::Regular<u16, u32, u64>::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
+
+// lldb-command:print case2
+// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
+// lldbr-check:(generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2) case2 = Regular<i16, i32, i64>::Case2 { generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2: 286331153, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case3: 286331153 }
+
+// lldb-command:print case3
+// lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
+// lldbr-check:(generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case3) case3 = Regular<i16, i32, i64>::Case3 { generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2: 6438275382588823897 }
+
+// lldb-command:print univariant
+// lldbg-check:[...]$3 = TheOnlyCase(-1)
+// lldbr-check:(generic_tuple_style_enum_legacy::Univariant<i64>) univariant = { generic_tuple_style_enum_legacy::TheOnlyCase = { = -1 } }
+
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+use self::Regular::{Case1, Case2, Case3};
+use self::Univariant::TheOnlyCase;
+
+// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
+// substituted with something of size `xx` bits and the same alignment as an integer type of the
+// same size.
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+enum Regular<T16, T32, T64> {
+ Case1(T64, T16, T16, T16, T16),
+ Case2(T64, T32, T32),
+ Case3(T64, T64)
+}
+
+enum Univariant<T64> {
+ TheOnlyCase(T64)
+}
+
+fn main() {
+
+ // In order to avoid endianness trouble all of the following test values consist of a single
+ // repeated byte. This way each interpretation of the union should look the same, no matter if
+ // this is a big or little endian machine.
+
+ // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
+ // 0b01111100011111000111110001111100 = 2088533116
+ // 0b0111110001111100 = 31868
+ // 0b01111100 = 124
+ let case1: Regular<u16, u32, u64> = Case1(0_u64, 31868_u16, 31868_u16, 31868_u16, 31868_u16);
+
+ // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
+ // 0b00010001000100010001000100010001 = 286331153
+ // 0b0001000100010001 = 4369
+ // 0b00010001 = 17
+ let case2: Regular<i16, i32, i64> = Case2(0_i64, 286331153_i32, 286331153_i32);
+
+ // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
+ // 0b01011001010110010101100101011001 = 1499027801
+ // 0b0101100101011001 = 22873
+ // 0b01011001 = 89
+ let case3: Regular<i16, i32, i64> = Case3(0_i64, 6438275382588823897_i64);
+
+ let univariant = TheOnlyCase(-1_i64);
+
+ zzz(); // #break
+}
+
+fn zzz() { () }
// except according to those terms.
// ignore-tidy-linelength
-// min-lldb-version: 310
-// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can
+// read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
+// rust-lldb
// compile-flags:-g
// gdb-command:run
// gdb-command:print case1
-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
-// gdbr-check:$1 = generic_tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868)
+// gdbr-check:$1 = generic_tuple_style_enum::Regular<u16, u32, u64>::Case1(0, 31868, 31868, 31868, 31868)
// gdb-command:print case2
-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
-// gdbr-check:$2 = generic_tuple_style_enum::Regular::Case2(0, 286331153, 286331153)
+// gdbr-check:$2 = generic_tuple_style_enum::Regular<i16, i32, i64>::Case2(0, 286331153, 286331153)
// gdb-command:print case3
-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
-// gdbr-check:$3 = generic_tuple_style_enum::Regular::Case3(0, 6438275382588823897)
+// gdbr-check:$3 = generic_tuple_style_enum::Regular<i16, i32, i64>::Case3(0, 6438275382588823897)
// gdb-command:print univariant
-// gdbg-check:$4 = {{__0 = -1}}
// gdbr-check:$4 = generic_tuple_style_enum::Univariant<i64>::TheOnlyCase(-1)
// lldb-command:run
// lldb-command:print case1
-// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
// lldbr-check:(generic_tuple_style_enum::Regular<u16, u32, u64>::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
// lldb-command:print case2
-// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
-// lldbr-check:(generic_tuple_style_enum::Regular<i16, i32, i64>::Case2) case2 = Regular<i16, i32, i64>::Case2 { generic_tuple_style_enum::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum::Regular<i16, i32, i64>::Case2: 286331153, generic_tuple_style_enum::Regular<i16, i32, i64>::Case3: 286331153 }
+// lldbr-check:(generic_tuple_style_enum::Regular<i16, i32, i64>::Case2) case2 = Regular<i16, i32, i64>::Case2 { Case1: 0, Case2: 286331153, Case3: 286331153 }
// lldb-command:print case3
-// lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
-// lldbr-check:(generic_tuple_style_enum::Regular<i16, i32, i64>::Case3) case3 = Regular<i16, i32, i64>::Case3 { generic_tuple_style_enum::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum::Regular<i16, i32, i64>::Case2: 6438275382588823897 }
+// lldbr-check:(generic_tuple_style_enum::Regular<i16, i32, i64>::Case3) case3 = Regular<i16, i32, i64>::Case3 { Case1: 0, Case2: 6438275382588823897 }
// lldb-command:print univariant
-// lldbg-check:[...]$3 = TheOnlyCase(-1)
-// lldbr-check:(generic_tuple_style_enum::Univariant<i64>) univariant = { generic_tuple_style_enum::TheOnlyCase = { = -1 } }
+// lldbr-check:(generic_tuple_style_enum::Univariant<i64>) univariant = { TheOnlyCase = { = -1 } }
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
// STACK BY REF
// lldb-command:print *self
// lldbg-check:[...]$0 = TupleStruct(100, -100.5)
-// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 100 = -100.5 }
+// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = TupleStruct(100, -100.5)
// lldb-command:print arg1
// lldbg-check:[...]$1 = -1
// lldbr-check:(isize) arg1 = -1
// STACK BY VAL
// lldb-command:print self
// lldbg-check:[...]$3 = TupleStruct(100, -100.5)
-// lldbr-check:(method_on_tuple_struct::TupleStruct) self = { = 100 = -100.5 }
+// lldbr-check:(method_on_tuple_struct::TupleStruct) self = TupleStruct(100, -100.5)
// lldb-command:print arg1
// lldbg-check:[...]$4 = -3
// lldbr-check:(isize) arg1 = -3
// OWNED BY REF
// lldb-command:print *self
// lldbg-check:[...]$6 = TupleStruct(200, -200.5)
-// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 200 = -200.5 }
+// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = TupleStruct(200, -200.5)
// lldb-command:print arg1
// lldbg-check:[...]$7 = -5
// lldbr-check:(isize) arg1 = -5
// OWNED BY VAL
// lldb-command:print self
// lldbg-check:[...]$9 = TupleStruct(200, -200.5)
-// lldbr-check:(method_on_tuple_struct::TupleStruct) self = { = 200 = -200.5 }
+// lldbr-check:(method_on_tuple_struct::TupleStruct) self = TupleStruct(200, -200.5)
// lldb-command:print arg1
// lldbg-check:[...]$10 = -7
// lldbr-check:(isize) arg1 = -7
// OWNED MOVED
// lldb-command:print *self
// lldbg-check:[...]$12 = TupleStruct(200, -200.5)
-// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 200 = -200.5 }
+// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = TupleStruct(200, -200.5)
// lldb-command:print arg1
// lldbg-check:[...]$13 = -9
// lldbr-check:(isize) arg1 = -9
// ignore-lldb
+// Require LLVM with DW_TAG_variant_part and a gdb that can read it.
+// gdb 8.2.0 crashes on this test case, see
+// https://sourceware.org/bugzilla/show_bug.cgi?id=23626
+// This will be fixed in the next release, which will be >= 8.2.1.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2.1
+
// compile-flags:-g
// gdb-command:run
// gdb-command:print first
-// gdbg-check:$1 = {<No data fields>}
-// gdbr-check:$1 = <error reading variable>
+// gdbr-check:$1 = nil_enum::ANilEnum {<No data fields>}
// gdb-command:print second
-// gdbg-check:$2 = {<No data fields>}
-// gdbr-check:$2 = <error reading variable>
+// gdbr-check:$2 = nil_enum::AnotherNilEnum {<No data fields>}
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// ignore-lldb
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 7.11.90 - 7.12.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// gdb-command:run
+
+// gdb-command:print stack_unique.value
+// gdb-check:$1 = 0
+// gdbg-command:print stack_unique.next.RUST$ENCODED$ENUM$0$Empty.val->value
+// gdbr-command:print stack_unique.next.val.value
+// gdb-check:$2 = 1
+
+// gdbg-command:print unique_unique->value
+// gdbr-command:print unique_unique.value
+// gdb-check:$3 = 2
+// gdbg-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
+// gdbr-command:print unique_unique.next.val.value
+// gdb-check:$4 = 3
+
+// gdb-command:print vec_unique[0].value
+// gdb-check:$5 = 6.5
+// gdbg-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value
+// gdbr-command:print vec_unique[0].next.val.value
+// gdb-check:$6 = 7.5
+
+// gdbg-command:print borrowed_unique->value
+// gdbr-command:print borrowed_unique.value
+// gdb-check:$7 = 8.5
+// gdbg-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
+// gdbr-command:print borrowed_unique.next.val.value
+// gdb-check:$8 = 9.5
+
+// LONG CYCLE
+// gdb-command:print long_cycle1.value
+// gdb-check:$9 = 20
+// gdbg-command:print long_cycle1.next->value
+// gdbr-command:print long_cycle1.next.value
+// gdb-check:$10 = 21
+// gdbg-command:print long_cycle1.next->next->value
+// gdbr-command:print long_cycle1.next.next.value
+// gdb-check:$11 = 22
+// gdbg-command:print long_cycle1.next->next->next->value
+// gdbr-command:print long_cycle1.next.next.next.value
+// gdb-check:$12 = 23
+
+// gdb-command:print long_cycle2.value
+// gdb-check:$13 = 24
+// gdbg-command:print long_cycle2.next->value
+// gdbr-command:print long_cycle2.next.value
+// gdb-check:$14 = 25
+// gdbg-command:print long_cycle2.next->next->value
+// gdbr-command:print long_cycle2.next.next.value
+// gdb-check:$15 = 26
+
+// gdb-command:print long_cycle3.value
+// gdb-check:$16 = 27
+// gdbg-command:print long_cycle3.next->value
+// gdbr-command:print long_cycle3.next.value
+// gdb-check:$17 = 28
+
+// gdb-command:print long_cycle4.value
+// gdb-check:$18 = 29.5
+
+// gdbg-command:print (*****long_cycle_w_anonymous_types).value
+// gdbr-command:print long_cycle_w_anonymous_types.value
+// gdb-check:$19 = 30
+
+// gdbg-command:print (*****((*****long_cycle_w_anonymous_types).next.RUST$ENCODED$ENUM$0$Empty.val)).value
+// gdbr-command:print long_cycle_w_anonymous_types.next.val.value
+// gdb-check:$20 = 31
+
+// gdb-command:continue
+
+#![allow(unused_variables)]
+#![feature(box_syntax)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+use self::Opt::{Empty, Val};
+
+enum Opt<T> {
+ Empty,
+ Val { val: T }
+}
+
+struct UniqueNode<T> {
+ next: Opt<Box<UniqueNode<T>>>,
+ value: T
+}
+
+struct LongCycle1<T> {
+ next: Box<LongCycle2<T>>,
+ value: T,
+}
+
+struct LongCycle2<T> {
+ next: Box<LongCycle3<T>>,
+ value: T,
+}
+
+struct LongCycle3<T> {
+ next: Box<LongCycle4<T>>,
+ value: T,
+}
+
+struct LongCycle4<T> {
+ next: Option<Box<LongCycle1<T>>>,
+ value: T,
+}
+
+struct LongCycleWithAnonymousTypes {
+ next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>,
+ value: usize,
+}
+
+// This test case makes sure that recursive structs are properly described. The Node structs are
+// generic so that we can have a new type (that newly needs to be described) for the different
+// cases. The potential problem with recursive types is that the DI generation algorithm gets
+// trapped in an endless loop. To make sure, we actually test this in the different cases, we have
+// to operate on a new type each time, otherwise we would just hit the DI cache for all but the
+// first case.
+
+// The different cases below (stack_*, unique_*, box_*, etc) are set up so that the type description
+// algorithm will enter the type reference cycle that is created by a recursive definition from a
+// different context each time.
+
+// The "long cycle" cases are constructed to span a longer, indirect recursion cycle between types.
+// The different locals will cause the DI algorithm to enter the type reference cycle at different
+// points.
+
+fn main() {
+ let stack_unique: UniqueNode<u16> = UniqueNode {
+ next: Val {
+ val: box UniqueNode {
+ next: Empty,
+ value: 1,
+ }
+ },
+ value: 0,
+ };
+
+ let unique_unique: Box<UniqueNode<u32>> = box UniqueNode {
+ next: Val {
+ val: box UniqueNode {
+ next: Empty,
+ value: 3,
+ }
+ },
+ value: 2,
+ };
+
+ let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
+ next: Val {
+ val: box UniqueNode {
+ next: Empty,
+ value: 7.5,
+ }
+ },
+ value: 6.5,
+ }];
+
+ let borrowed_unique: &UniqueNode<f64> = &UniqueNode {
+ next: Val {
+ val: box UniqueNode {
+ next: Empty,
+ value: 9.5,
+ }
+ },
+ value: 8.5,
+ };
+
+ // LONG CYCLE
+ let long_cycle1: LongCycle1<u16> = LongCycle1 {
+ next: box LongCycle2 {
+ next: box LongCycle3 {
+ next: box LongCycle4 {
+ next: None,
+ value: 23,
+ },
+ value: 22,
+ },
+ value: 21
+ },
+ value: 20
+ };
+
+ let long_cycle2: LongCycle2<u32> = LongCycle2 {
+ next: box LongCycle3 {
+ next: box LongCycle4 {
+ next: None,
+ value: 26,
+ },
+ value: 25,
+ },
+ value: 24
+ };
+
+ let long_cycle3: LongCycle3<u64> = LongCycle3 {
+ next: box LongCycle4 {
+ next: None,
+ value: 28,
+ },
+ value: 27,
+ };
+
+ let long_cycle4: LongCycle4<f32> = LongCycle4 {
+ next: None,
+ value: 29.5,
+ };
+
+ // It's important that LongCycleWithAnonymousTypes is encountered only at the end of the
+ // `box` chain.
+ let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes {
+ next: Val {
+ val: box box box box box LongCycleWithAnonymousTypes {
+ next: Empty,
+ value: 31,
+ }
+ },
+ value: 30
+ };
+
+ zzz(); // #break
+}
+
+fn zzz() {()}
// ignore-tidy-linelength
// ignore-lldb
-// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// Require LLVM with DW_TAG_variant_part and a gdb that can read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
// compile-flags:-g
// gdb-command:print stack_unique.value
// gdb-check:$1 = 0
-// gdbg-command:print stack_unique.next.RUST$ENCODED$ENUM$0$Empty.val->value
// gdbr-command:print stack_unique.next.val.value
// gdb-check:$2 = 1
-// gdbg-command:print unique_unique->value
// gdbr-command:print unique_unique.value
// gdb-check:$3 = 2
-// gdbg-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
// gdbr-command:print unique_unique.next.val.value
// gdb-check:$4 = 3
// gdb-command:print vec_unique[0].value
// gdb-check:$5 = 6.5
-// gdbg-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value
// gdbr-command:print vec_unique[0].next.val.value
// gdb-check:$6 = 7.5
-// gdbg-command:print borrowed_unique->value
// gdbr-command:print borrowed_unique.value
// gdb-check:$7 = 8.5
-// gdbg-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
// gdbr-command:print borrowed_unique.next.val.value
// gdb-check:$8 = 9.5
// LONG CYCLE
// gdb-command:print long_cycle1.value
// gdb-check:$9 = 20
-// gdbg-command:print long_cycle1.next->value
// gdbr-command:print long_cycle1.next.value
// gdb-check:$10 = 21
-// gdbg-command:print long_cycle1.next->next->value
// gdbr-command:print long_cycle1.next.next.value
// gdb-check:$11 = 22
-// gdbg-command:print long_cycle1.next->next->next->value
// gdbr-command:print long_cycle1.next.next.next.value
// gdb-check:$12 = 23
// gdb-command:print long_cycle2.value
// gdb-check:$13 = 24
-// gdbg-command:print long_cycle2.next->value
// gdbr-command:print long_cycle2.next.value
// gdb-check:$14 = 25
-// gdbg-command:print long_cycle2.next->next->value
// gdbr-command:print long_cycle2.next.next.value
// gdb-check:$15 = 26
// gdb-command:print long_cycle3.value
// gdb-check:$16 = 27
-// gdbg-command:print long_cycle3.next->value
// gdbr-command:print long_cycle3.next.value
// gdb-check:$17 = 28
// gdb-command:print long_cycle4.value
// gdb-check:$18 = 29.5
-// gdbg-command:print (*****long_cycle_w_anonymous_types).value
// gdbr-command:print long_cycle_w_anonymous_types.value
// gdb-check:$19 = 30
-// gdbg-command:print (*****((*****long_cycle_w_anonymous_types).next.RUST$ENCODED$ENUM$0$Empty.val)).value
// gdbr-command:print long_cycle_w_anonymous_types.next.val.value
// gdb-check:$20 = 31
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// min-lldb-version: 310
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 7.11.90 - 7.12.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:set print union on
+// gdb-command:run
+
+// gdb-command:print case1
+// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
+// gdbr-check:$1 = struct_style_enum_legacy::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
+
+// gdb-command:print case2
+// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
+// gdbr-check:$2 = struct_style_enum_legacy::Regular::Case2{a: 0, b: 286331153, c: 286331153}
+
+// gdb-command:print case3
+// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
+// gdbr-check:$3 = struct_style_enum_legacy::Regular::Case3{a: 0, b: 6438275382588823897}
+
+// gdb-command:print univariant
+// gdbg-check:$4 = {{a = -1}}
+// gdbr-check:$4 = struct_style_enum_legacy::Univariant::TheOnlyCase{a: -1}
+
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print case1
+// lldbg-check:[...]$0 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 }
+// lldbr-check:(struct_style_enum_legacy::Regular::Case1) case1 = { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 }
+
+// lldb-command:print case2
+// lldbg-check:[...]$1 = Case2 { a: 0, b: 286331153, c: 286331153 }
+// lldbr-check:(struct_style_enum_legacy::Regular::Case2) case2 = Case2 { struct_style_enum_legacy::Regular::Case1: 0, struct_style_enum_legacy::Regular::Case2: 286331153, struct_style_enum_legacy::Regular::Case3: 286331153 }
+
+// lldb-command:print case3
+// lldbg-check:[...]$2 = Case3 { a: 0, b: 6438275382588823897 }
+// lldbr-check:(struct_style_enum_legacy::Regular::Case3) case3 = Case3 { struct_style_enum_legacy::Regular::Case1: 0, struct_style_enum_legacy::Regular::Case2: 6438275382588823897 }
+
+// lldb-command:print univariant
+// lldbg-check:[...]$3 = TheOnlyCase { a: -1 }
+// lldbr-check:(struct_style_enum_legacy::Univariant) univariant = Univariant { struct_style_enum_legacy::TheOnlyCase: TheOnlyCase { a: -1 } }
+
+#![allow(unused_variables)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+use self::Regular::{Case1, Case2, Case3};
+use self::Univariant::TheOnlyCase;
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+enum Regular {
+ Case1 { a: u64, b: u16, c: u16, d: u16, e: u16},
+ Case2 { a: u64, b: u32, c: u32},
+ Case3 { a: u64, b: u64 }
+}
+
+enum Univariant {
+ TheOnlyCase { a: i64 }
+}
+
+fn main() {
+
+ // In order to avoid endianness trouble all of the following test values consist of a single
+ // repeated byte. This way each interpretation of the union should look the same, no matter if
+ // this is a big or little endian machine.
+
+ // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
+ // 0b01111100011111000111110001111100 = 2088533116
+ // 0b0111110001111100 = 31868
+ // 0b01111100 = 124
+ let case1 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 };
+
+ // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
+ // 0b00010001000100010001000100010001 = 286331153
+ // 0b0001000100010001 = 4369
+ // 0b00010001 = 17
+ let case2 = Case2 { a: 0, b: 286331153, c: 286331153 };
+
+ // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
+ // 0b01011001010110010101100101011001 = 1499027801
+ // 0b0101100101011001 = 22873
+ // 0b01011001 = 89
+ let case3 = Case3 { a: 0, b: 6438275382588823897 };
+
+ let univariant = TheOnlyCase { a: -1 };
+
+ zzz(); // #break
+}
+
+fn zzz() {()}
// except according to those terms.
// ignore-tidy-linelength
-// min-lldb-version: 310
-// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can
+// read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
+// rust-lldb
// compile-flags:-g
// gdb-command:run
// gdb-command:print case1
-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$1 = struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
// gdb-command:print case2
-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
// gdbr-check:$2 = struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153}
// gdb-command:print case3
-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
// gdbr-check:$3 = struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897}
// gdb-command:print univariant
-// gdbg-check:$4 = {{a = -1}}
// gdbr-check:$4 = struct_style_enum::Univariant::TheOnlyCase{a: -1}
// lldb-command:run
// lldb-command:print case1
-// lldbg-check:[...]$0 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 }
// lldbr-check:(struct_style_enum::Regular::Case1) case1 = { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 }
// lldb-command:print case2
-// lldbg-check:[...]$1 = Case2 { a: 0, b: 286331153, c: 286331153 }
-// lldbr-check:(struct_style_enum::Regular::Case2) case2 = Case2 { struct_style_enum::Regular::Case1: 0, struct_style_enum::Regular::Case2: 286331153, struct_style_enum::Regular::Case3: 286331153 }
+// lldbr-check:(struct_style_enum::Regular::Case2) case2 = Case2 { Case1: 0, Case2: 286331153, Case3: 286331153 }
// lldb-command:print case3
-// lldbg-check:[...]$2 = Case3 { a: 0, b: 6438275382588823897 }
-// lldbr-check:(struct_style_enum::Regular::Case3) case3 = Case3 { struct_style_enum::Regular::Case1: 0, struct_style_enum::Regular::Case2: 6438275382588823897 }
+// lldbr-check:(struct_style_enum::Regular::Case3) case3 = Case3 { Case1: 0, Case2: 6438275382588823897 }
// lldb-command:print univariant
-// lldbg-check:[...]$3 = TheOnlyCase { a: -1 }
-// lldbr-check:(struct_style_enum::Univariant) univariant = Univariant { struct_style_enum::TheOnlyCase: TheOnlyCase { a: -1 } }
+// lldbr-check:(struct_style_enum::Univariant) univariant = Univariant { TheOnlyCase: TheOnlyCase { a: -1 } }
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// min-lldb-version: 310
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 7.11.90 - 7.12.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:set print union on
+// gdb-command:run
+
+// gdb-command:print case1
+// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
+// gdbr-check:$1 = tuple_style_enum_legacy::Regular::Case1(0, 31868, 31868, 31868, 31868)
+
+// gdb-command:print case2
+// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
+// gdbr-check:$2 = tuple_style_enum_legacy::Regular::Case2(0, 286331153, 286331153)
+
+// gdb-command:print case3
+// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
+// gdbr-check:$3 = tuple_style_enum_legacy::Regular::Case3(0, 6438275382588823897)
+
+// gdb-command:print univariant
+// gdbg-check:$4 = {{__0 = -1}}
+// gdbr-check:$4 = tuple_style_enum_legacy::Univariant::TheOnlyCase(-1)
+
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print case1
+// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
+// lldbr-check:(tuple_style_enum_legacy::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
+
+// lldb-command:print case2
+// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
+// lldbr-check:(tuple_style_enum_legacy::Regular::Case2) case2 = Case2 { tuple_style_enum_legacy::Regular::Case1: 0, tuple_style_enum_legacy::Regular::Case2: 286331153, tuple_style_enum_legacy::Regular::Case3: 286331153 }
+
+// lldb-command:print case3
+// lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
+// lldbr-check:(tuple_style_enum_legacy::Regular::Case3) case3 = Case3 { tuple_style_enum_legacy::Regular::Case1: 0, tuple_style_enum_legacy::Regular::Case2: 6438275382588823897 }
+
+// lldb-command:print univariant
+// lldbg-check:[...]$3 = TheOnlyCase(-1)
+// lldbr-check:(tuple_style_enum_legacy::Univariant) univariant = { tuple_style_enum_legacy::TheOnlyCase = { = -1 } }
+
+#![allow(unused_variables)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+use self::Regular::{Case1, Case2, Case3};
+use self::Univariant::TheOnlyCase;
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+enum Regular {
+ Case1(u64, u16, u16, u16, u16),
+ Case2(u64, u32, u32),
+ Case3(u64, u64)
+}
+
+enum Univariant {
+ TheOnlyCase(i64)
+}
+
+fn main() {
+
+ // In order to avoid endianness trouble all of the following test values consist of a single
+ // repeated byte. This way each interpretation of the union should look the same, no matter if
+ // this is a big or little endian machine.
+
+ // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
+ // 0b01111100011111000111110001111100 = 2088533116
+ // 0b0111110001111100 = 31868
+ // 0b01111100 = 124
+ let case1 = Case1(0, 31868, 31868, 31868, 31868);
+
+ // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
+ // 0b00010001000100010001000100010001 = 286331153
+ // 0b0001000100010001 = 4369
+ // 0b00010001 = 17
+ let case2 = Case2(0, 286331153, 286331153);
+
+ // 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
+ // 0b01011001010110010101100101011001 = 1499027801
+ // 0b0101100101011001 = 22873
+ // 0b01011001 = 89
+ let case3 = Case3(0, 6438275382588823897);
+
+ let univariant = TheOnlyCase(-1);
+
+ zzz(); // #break
+}
+
+fn zzz() {()}
// except according to those terms.
// ignore-tidy-linelength
-// min-lldb-version: 310
-// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can
+// read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
+// rust-lldb
// compile-flags:-g
// gdb-command:run
// gdb-command:print case1
-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$1 = tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868)
// gdb-command:print case2
-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
// gdbr-check:$2 = tuple_style_enum::Regular::Case2(0, 286331153, 286331153)
// gdb-command:print case3
-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
// gdbr-check:$3 = tuple_style_enum::Regular::Case3(0, 6438275382588823897)
// gdb-command:print univariant
-// gdbg-check:$4 = {{__0 = -1}}
// gdbr-check:$4 = tuple_style_enum::Univariant::TheOnlyCase(-1)
// lldb-command:run
// lldb-command:print case1
-// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
// lldbr-check:(tuple_style_enum::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
// lldb-command:print case2
-// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
-// lldbr-check:(tuple_style_enum::Regular::Case2) case2 = Case2 { tuple_style_enum::Regular::Case1: 0, tuple_style_enum::Regular::Case2: 286331153, tuple_style_enum::Regular::Case3: 286331153 }
+// lldbr-check:(tuple_style_enum::Regular::Case2) case2 = Case2 { Case1: 0, Case2: 286331153, Case3: 286331153 }
// lldb-command:print case3
-// lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
-// lldbr-check:(tuple_style_enum::Regular::Case3) case3 = Case3 { tuple_style_enum::Regular::Case1: 0, tuple_style_enum::Regular::Case2: 6438275382588823897 }
+// lldbr-check:(tuple_style_enum::Regular::Case3) case3 = Case3 { Case1: 0, Case2: 6438275382588823897 }
// lldb-command:print univariant
-// lldbg-check:[...]$3 = TheOnlyCase(-1)
-// lldbr-check:(tuple_style_enum::Univariant) univariant = { tuple_style_enum::TheOnlyCase = { = -1 } }
+// lldbr-check:(tuple_style_enum::Univariant) univariant = { TheOnlyCase = { = -1 } }
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
--- /dev/null
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-tidy-linelength
+// min-lldb-version: 310
+
+// As long as LLVM 5 and LLVM 6 are supported, we want to test the
+// enum debuginfo fallback mode. Once those are desupported, this
+// test can be removed, as there is another (non-"legacy") test that
+// tests the new mode.
+// ignore-llvm-version: 7.0 - 9.9.9
+// ignore-gdb-version: 7.11.90 - 7.12.9
+// ignore-gdb-version: 8.2 - 9.9
+
+// compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:run
+
+// gdb-command:print *the_a
+// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
+// gdbr-check:$1 = unique_enum_legacy::ABC::TheA{x: 0, y: 8970181431921507452}
+
+// gdb-command:print *the_b
+// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
+// gdbr-check:$2 = unique_enum_legacy::ABC::TheB(0, 286331153, 286331153)
+
+// gdb-command:print *univariant
+// gdbg-check:$3 = {{__0 = 123234}}
+// gdbr-check:$3 = unique_enum_legacy::Univariant::TheOnlyCase(123234)
+
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *the_a
+// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
+// lldbr-check:(unique_enum_legacy::ABC::TheA) *the_a = TheA { unique_enum_legacy::ABC::TheA: 0, unique_enum_legacy::ABC::TheB: 8970181431921507452 }
+
+// lldb-command:print *the_b
+// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153)
+// lldbr-check:(unique_enum_legacy::ABC::TheB) *the_b = { = 0 = 286331153 = 286331153 }
+
+// lldb-command:print *univariant
+// lldbg-check:[...]$2 = TheOnlyCase(123234)
+// lldbr-check:(unique_enum_legacy::Univariant) *univariant = { unique_enum_legacy::TheOnlyCase = { = 123234 } }
+
+#![allow(unused_variables)]
+#![feature(box_syntax)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+// The first element is to ensure proper alignment, irrespective of the machines word size. Since
+// the size of the discriminant value is machine dependent, this has be taken into account when
+// datatype layout should be predictable as in this case.
+enum ABC {
+ TheA { x: i64, y: i64 },
+ TheB (i64, i32, i32),
+}
+
+// This is a special case since it does not have the implicit discriminant field.
+enum Univariant {
+ TheOnlyCase(i64)
+}
+
+fn main() {
+
+ // In order to avoid endianness trouble all of the following test values consist of a single
+ // repeated byte. This way each interpretation of the union should look the same, no matter if
+ // this is a big or little endian machine.
+
+ // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
+ // 0b01111100011111000111110001111100 = 2088533116
+ // 0b0111110001111100 = 31868
+ // 0b01111100 = 124
+ let the_a: Box<_> = box ABC::TheA { x: 0, y: 8970181431921507452 };
+
+ // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
+ // 0b00010001000100010001000100010001 = 286331153
+ // 0b0001000100010001 = 4369
+ // 0b00010001 = 17
+ let the_b: Box<_> = box ABC::TheB (0, 286331153, 286331153);
+
+ let univariant: Box<_> = box Univariant::TheOnlyCase(123234);
+
+ zzz(); // #break
+}
+
+fn zzz() {()}
// except according to those terms.
// ignore-tidy-linelength
-// min-lldb-version: 310
-// ignore-gdb-version: 7.11.90 - 7.12.9
+
+// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can
+// read it.
+// min-system-llvm-version: 7.0
+// min-gdb-version: 8.2
+// rust-lldb
// compile-flags:-g
// gdb-command:run
// gdb-command:print *the_a
-// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
// gdbr-check:$1 = unique_enum::ABC::TheA{x: 0, y: 8970181431921507452}
// gdb-command:print *the_b
-// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
// gdbr-check:$2 = unique_enum::ABC::TheB(0, 286331153, 286331153)
// gdb-command:print *univariant
-// gdbg-check:$3 = {{__0 = 123234}}
// gdbr-check:$3 = unique_enum::Univariant::TheOnlyCase(123234)
// lldb-command:run
// lldb-command:print *the_a
-// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
-// lldbr-check:(unique_enum::ABC::TheA) *the_a = TheA { unique_enum::ABC::TheA: 0, unique_enum::ABC::TheB: 8970181431921507452 }
+// lldbr-check:(unique_enum::ABC::TheA) *the_a = TheA { TheA: 0, TheB: 8970181431921507452 }
// lldb-command:print *the_b
-// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153)
// lldbr-check:(unique_enum::ABC::TheB) *the_b = { = 0 = 286331153 = 286331153 }
// lldb-command:print *univariant
-// lldbg-check:[...]$2 = TheOnlyCase(123234)
-// lldbr-check:(unique_enum::Univariant) *univariant = { unique_enum::TheOnlyCase = { = 123234 } }
+// lldbr-check:(unique_enum::Univariant) *univariant = { TheOnlyCase = { = 123234 } }
#![allow(unused_variables)]
#![feature(box_syntax)]
// lldb-command:print padded_tuple
// lldbg-check:[...]$4 = &[(6, 7), (8, 9)]
-// lldbr-check:(&[(i32, i16)]) padded_tuple = { data_ptr = *0x555555554ff0 length = 2 }
+// lldbr-check:(&[(i32, i16)]) padded_tuple = { data_ptr = *0x555555555030 length = 2 }
// lldb-command:print padded_struct
// lldbg-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }]
// The AST node for the (1 + y) expression generated by the macro will then
// take it's `lo` span bound from the `1` literal in the macro-defining file
// and it's `hi` bound from `y` in this file, which should be lower than the
- // `lo` and even lower than the lower bound of the FileMap it is supposedly
- // contained in because the FileMap for this file was allocated earlier than
- // the FileMap of the macro-defining file.
+ // `lo` and even lower than the lower bound of the SourceFile it is supposedly
+ // contained in because the SourceFile for this file was allocated earlier than
+ // the SourceFile of the macro-defining file.
return (x, add1!(y));
}
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Tests that paths in `pub(...)` don't fail HIR verification.
+
+#![allow(unused_imports)]
+#![allow(dead_code)]
+
+pub(self) use self::my_mod::Foo;
+
+mod my_mod {
+ pub(super) use self::Foo as Bar;
+ pub(in super::my_mod) use self::Foo as Baz;
+
+ pub struct Foo;
+}
+
+fn main() {}
LL | match *s { sty(v) => v } //~ ERROR cannot move out
| ^
-error[E0507]: cannot move out of `s.0` which is behind a `&` reference
- --> $DIR/access-mode-in-closures.rs:19:24
- |
-LL | let _foo = unpack(|s| {
- | - help: consider changing this to be a mutable reference: `&mut sty`
-LL | // Test that `s` is moved here.
-LL | match *s { sty(v) => v } //~ ERROR cannot move out
- | ^
- | |
- | cannot move out of `s.0` which is behind a `&` reference
- | `s` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
LL | *n; //~ ERROR: cannot move out of borrowed content
| ^^ cannot move out of borrowed content
-error[E0507]: cannot move out of `*n` which is behind a `&` reference
- --> $DIR/binop-move-semantics.rs:42:5
- |
-LL | let n = &y;
- | -- help: consider changing this to be a mutable reference: `&mut y`
-...
-LL | *n; //~ ERROR: cannot move out of borrowed content
- | ^^
- | |
- | cannot move out of `*n` which is behind a `&` reference
- | `n` is a `&` reference, so the data it refers to cannot be moved
-
error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
--> $DIR/binop-move-semantics.rs:64:5
|
| | immutable borrow later used here
| mutable borrow occurs here
-error: aborting due to 7 previous errors
+error: aborting due to 6 previous errors
Some errors occurred: E0382, E0502, E0507.
For more information about an error, try `rustc --explain E0382`.
LL | c1;
| -- first borrow later used here
-warning[E0594]: cannot assign to `x`, as it is not declared as mutable
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/borrowck-closures-unique.rs:57:38
|
LL | fn e(x: &'static mut isize) {
| - help: consider changing this to be mutable: `mut x`
LL | let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument
| ^^^^^ cannot assign
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
Some errors occurred: E0500, E0524, E0594.
For more information about an error, try `rustc --explain E0500`.
LL | *y = 1;
| ------ first borrow later used here
-warning: captured variable cannot escape `FnMut` closure body
+error: captured variable cannot escape `FnMut` closure body
--> $DIR/borrowck-describe-lvalue.rs:305:16
|
LL | || {
|
= note: `FnMut` closures only have access to their captured variables while they are executing...
= note: ...therefore, they cannot allow references to captured variables to escape
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
error[E0503]: cannot use `f.x` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:53:9
|
= note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
-error: aborting due to 29 previous errors
+error: aborting due to 30 previous errors
Some errors occurred: E0382, E0499, E0502, E0503.
For more information about an error, try `rustc --explain E0382`.
+++ /dev/null
-error[E0507]: cannot move out of borrowed content
- --> $DIR/borrowck-fn-in-const-a.rs:19:16
- |
-LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
- | ^^ cannot move out of borrowed content
-
-error[E0507]: cannot move out of `*x` which is behind a `&` reference
- --> $DIR/borrowck-fn-in-const-a.rs:19:16
- |
-LL | fn broken(x: &String) -> String {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
- | ^^
- | |
- | cannot move out of `*x` which is behind a `&` reference
- | `x` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0507`.
-error[E0507]: cannot move out of `*__next` which is behind a `&` reference
- --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10
- |
-LL | for &a in x.iter() { //~ ERROR cannot move out
- | -^
- | ||
- | |cannot move out of `*__next` which is behind a `&` reference
- | |`__next` is a `&` reference, so the data it refers to cannot be moved
- | help: consider changing this to be a mutable reference: `&mut a`
-
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15
|
LL | for &a in x.iter() { //~ ERROR cannot move out
| ^
-error[E0507]: cannot move out of `*__next` which is behind a `&` reference
- --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:10
- |
-LL | for &a in &f.a { //~ ERROR cannot move out
- | -^
- | ||
- | |cannot move out of `*__next` which is behind a `&` reference
- | |`__next` is a `&` reference, so the data it refers to cannot be moved
- | help: consider changing this to be a mutable reference: `&mut a`
-
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:15
|
LL | for &a in &f.a { //~ ERROR cannot move out
| ^
-error[E0507]: cannot move out of `*__next` which is behind a `&` reference
- --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:10
- |
-LL | for &a in x.iter() { //~ ERROR cannot move out
- | -^
- | ||
- | |cannot move out of `*__next` which is behind a `&` reference
- | |`__next` is a `&` reference, so the data it refers to cannot be moved
- | help: consider changing this to be a mutable reference: `&mut a`
-
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:15
|
LL | for &a in x.iter() { //~ ERROR cannot move out
| ^
-error: aborting due to 6 previous errors
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0507`.
LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable
| ^ cannot move out of captured variable in an `Fn` closure
-error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure
- --> $DIR/borrowck-in-static.rs:15:17
- |
-LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable
- | ^
- | |
- | cannot move out of `x`, as it is a captured variable in a `Fn` closure
- | cannot move
- |
-help: consider changing this to accept closures that implement `FnMut`
- --> $DIR/borrowck-in-static.rs:15:14
- |
-LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable
- | ^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
| cannot move out of borrowed content
| help: consider removing the `*`: `y`
-error[E0507]: cannot move out of `*y` which is behind a `&` reference
- --> $DIR/borrowck-issue-2657-2.rs:17:18
- |
-LL | Some(ref y) => {
- | ----- help: consider changing this to be a mutable reference: `ref mut y`
-LL | let _b = *y; //~ ERROR cannot move out
- | ^^
- | |
- | cannot move out of `*y` which is behind a `&` reference
- | `y` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
It represents potential unsoundness in your code.
This warning will become a hard error in the future.
-warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard
- --> $DIR/borrowck-migrate-to-nll.rs:35:17
- |
-LL | (|| { let bar = foo; bar.take() })();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | cannot move out of `foo`, as it is immutable for the pattern guard
- | cannot move
- |
- = note: variables bound in patterns are immutable until the end of the pattern guard
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-
It represents potential unsoundness in your code.
This warning will become a hard error in the future.
-warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard
- --> $DIR/borrowck-migrate-to-nll.rs:35:17
- |
-LL | (|| { let bar = foo; bar.take() })();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | cannot move out of `foo`, as it is immutable for the pattern guard
- | cannot move
- |
- = note: variables bound in patterns are immutable until the end of the pattern guard
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-
LL | Foo::Foo2(num) => (),
| ^^^
-error[E0507]: cannot move out of `f.0` which is behind a `&` reference
- --> $DIR/borrowck-move-error-with-note.rs:23:19
- |
-LL | let f = &Foo::Foo1(box 1, box 2);
- | ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)`
-...
-LL | Foo::Foo1(num1,
- | ^^^^
- | |
- | cannot move out of `f.0` which is behind a `&` reference
- | `f` is a `&` reference, so the data it refers to cannot be moved
-
-error[E0507]: cannot move out of `f.1` which is behind a `&` reference
- --> $DIR/borrowck-move-error-with-note.rs:24:19
- |
-LL | let f = &Foo::Foo1(box 1, box 2);
- | ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)`
-...
-LL | num2) => (),
- | ^^^^
- | |
- | cannot move out of `f.1` which is behind a `&` reference
- | `f` is a `&` reference, so the data it refers to cannot be moved
-
-error[E0507]: cannot move out of `f.0` which is behind a `&` reference
- --> $DIR/borrowck-move-error-with-note.rs:25:19
- |
-LL | let f = &Foo::Foo1(box 1, box 2);
- | ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)`
-...
-LL | Foo::Foo2(num) => (),
- | ^^^
- | |
- | cannot move out of `f.0` which is behind a `&` reference
- | `f` is a `&` reference, so the data it refers to cannot be moved
-
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
--> $DIR/borrowck-move-error-with-note.rs:39:11
|
LL | n => {
| ^
-error[E0507]: cannot move out of `a.a` which is behind a `&` reference
- --> $DIR/borrowck-move-error-with-note.rs:59:9
- |
-LL | let a = &A { a: box 1 };
- | --------------- help: consider changing this to be a mutable reference: `&mut A { a: box 1 }`
-...
-LL | n => {
- | ^
- | |
- | cannot move out of `a.a` which is behind a `&` reference
- | `a` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 7 previous errors
+error: aborting due to 3 previous errors
Some errors occurred: E0507, E0509.
For more information about an error, try `rustc --explain E0507`.
| cannot move out of dereference of raw pointer
| help: consider removing the `*`: `x`
-error[E0507]: cannot move out of `*x` which is behind a `*const` pointer
- --> $DIR/borrowck-move-from-unsafe-ptr.rs:13:13
- |
-LL | unsafe fn foo(x: *const Box<isize>) -> Box<isize> {
- | ----------------- help: consider changing this to be a mutable pointer: `*mut std::boxed::Box<isize>`
-LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer
- | ^^
- | |
- | cannot move out of `*x` which is behind a `*const` pointer
- | `x` is a `*const` pointer, so the data it refers to cannot be moved
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
LL | fn arg_item(&_x: &String) {}
| ^^
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/borrowck-move-in-irrefut-pat.rs:16:14
- |
-LL | fn arg_item(&_x: &String) {}
- | ^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-in-irrefut-pat.rs:21:11
|
LL | with(|&_x| ())
| ^^
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/borrowck-move-in-irrefut-pat.rs:21:12
- |
-LL | with(|&_x| ())
- | ^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/borrowck-move-in-irrefut-pat.rs:27:10
- |
-LL | let &_x = &"hi".to_string();
- | ^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of borrowed content
--> $DIR/borrowck-move-in-irrefut-pat.rs:27:15
|
LL | let &_x = &"hi".to_string();
| ^^
-error: aborting due to 6 previous errors
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0507`.
LL | let _x = Rc::new(vec![1, 2]).into_iter();
| ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14
- |
-LL | let _x = Rc::new(vec![1, 2]).into_iter();
- | ^^^^^^^^^^^^^^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
| cannot move out of an `Rc`
| help: consider removing the `*`: `Rc::new("hi".to_string())`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/borrowck-move-out-of-overloaded-deref.rs:14:14
- |
-LL | let _x = *Rc::new("hi".to_string());
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
+++ /dev/null
-error[E0507]: cannot move out of static item
- --> $DIR/borrowck-move-out-of-static-item.rs:28:10
- |
-LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
- | ^^^ cannot move out of static item
-
-error[E0507]: cannot move out of immutable static item `BAR`
- --> $DIR/borrowck-move-out-of-static-item.rs:28:10
- |
-LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
- | ^^^
- | |
- | cannot move out of immutable static item `BAR`
- | cannot move
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0507`.
LL | Foo { string: b }] => {
|
-error[E0507]: cannot move out of `tail[..].string` which is behind a `&` reference
- --> $DIR/borrowck-move-out-of-vec-tail.rs:30:33
- |
-LL | [_, ref tail..] => {
- | -------- help: consider changing this to be a mutable reference: `ref mut tail`
-LL | match tail {
-LL | &[Foo { string: a },
- | ^
- | |
- | cannot move out of `tail[..].string` which is behind a `&` reference
- | `tail` is a `&` reference, so the data it refers to cannot be moved
-
-error[E0507]: cannot move out of `tail[..].string` which is behind a `&` reference
- --> $DIR/borrowck-move-out-of-vec-tail.rs:34:33
- |
-LL | [_, ref tail..] => {
- | -------- help: consider changing this to be a mutable reference: `ref mut tail`
-...
-LL | Foo { string: b }] => {
- | ^
- | |
- | cannot move out of `tail[..].string` which is behind a `&` reference
- | `tail` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 3 previous errors
+error: aborting due to previous error
-Some errors occurred: E0507, E0508.
-For more information about an error, try `rustc --explain E0507`.
+For more information about this error, try `rustc --explain E0508`.
| cannot move out of borrowed content
| help: consider borrowing here: `&v[0]`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/borrowck-overloaded-index-move-from-vec.rs:30:15
- |
-LL | let bad = v[0];
- | ^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
LL | let opt = a.iter().enumerate().find(|(_, &s)| {
| ^
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-51415.rs:16:47
- |
-LL | let opt = a.iter().enumerate().find(|(_, &s)| {
- | ^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
--- /dev/null
+error[E0595]: closure cannot assign to immutable argument `x`
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:22
+ |
+LL | let mut c1 = |y: &'static mut isize| x = y;
+ | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably
+help: consider removing the `&mut`, as it is an immutable binding to a mutable reference
+ |
+LL | x
+ |
+
+error[E0595]: closure cannot assign to immutable argument `x`
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:29:22
+ |
+LL | let mut c1 = |z: &'static mut isize| {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably
+help: consider removing the `&mut`, as it is an immutable binding to a mutable reference
+ |
+LL | x
+ |
+
+error[E0595]: closure cannot assign to immutable argument `x`
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:9
+ |
+LL | pub fn capture_assign_whole(x: (i32,)) {
+ | - help: make this binding mutable: `mut x`
+LL | || { x = (1,); };
+ | ^^ cannot borrow mutably
+
+error[E0595]: closure cannot assign to immutable argument `x`
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:9
+ |
+LL | pub fn capture_assign_part(x: (i32,)) {
+ | - help: make this binding mutable: `mut x`
+LL | || { x.0 = 1; };
+ | ^^ cannot borrow mutably
+
+error[E0595]: closure cannot assign to immutable argument `x`
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:9
+ |
+LL | pub fn capture_reborrow_whole(x: (i32,)) {
+ | - help: make this binding mutable: `mut x`
+LL | || { &mut x; };
+ | ^^ cannot borrow mutably
+
+error[E0595]: closure cannot assign to immutable argument `x`
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:9
+ |
+LL | pub fn capture_reborrow_part(x: (i32,)) {
+ | - help: make this binding mutable: `mut x`
+LL | || { &mut x.0; };
+ | ^^ cannot borrow mutably
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0595`.
--- /dev/null
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46
+ |
+LL | pub fn e(x: &'static mut isize) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | static mut Y: isize = 3;
+LL | let mut c1 = |y: &'static mut isize| x = y;
+ | ^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50
+ |
+LL | pub fn ee(x: &'static mut isize) {
+ | - help: consider changing this to be mutable: `mut x`
+...
+LL | let mut c2 = |y: &'static mut isize| x = y;
+ | ^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:14
+ |
+LL | pub fn capture_assign_whole(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { x = (1,); };
+ | ^^^^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:14
+ |
+LL | pub fn capture_assign_part(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { x.0 = 1; };
+ | ^^^^^^^ cannot assign
+
+error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14
+ |
+LL | pub fn capture_reborrow_whole(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { &mut x; };
+ | ^^^^^^ cannot borrow as mutable
+
+error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:14
+ |
+LL | pub fn capture_reborrow_part(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { &mut x.0; };
+ | ^^^^^^^^ cannot borrow as mutable
+
+error: aborting due to 6 previous errors
+
+Some errors occurred: E0594, E0596.
+For more information about an error, try `rustc --explain E0594`.
--- /dev/null
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46
+ |
+LL | pub fn e(x: &'static mut isize) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | static mut Y: isize = 3;
+LL | let mut c1 = |y: &'static mut isize| x = y;
+ | ^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50
+ |
+LL | pub fn ee(x: &'static mut isize) {
+ | - help: consider changing this to be mutable: `mut x`
+...
+LL | let mut c2 = |y: &'static mut isize| x = y;
+ | ^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:14
+ |
+LL | pub fn capture_assign_whole(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { x = (1,); };
+ | ^^^^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:14
+ |
+LL | pub fn capture_assign_part(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { x.0 = 1; };
+ | ^^^^^^^ cannot assign
+
+error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14
+ |
+LL | pub fn capture_reborrow_whole(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { &mut x; };
+ | ^^^^^^ cannot borrow as mutable
+
+error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
+ --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:14
+ |
+LL | pub fn capture_reborrow_part(x: (i32,)) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | || { &mut x.0; };
+ | ^^^^^^^^ cannot borrow as mutable
+
+error: aborting due to 6 previous errors
+
+Some errors occurred: E0594, E0596.
+For more information about an error, try `rustc --explain E0594`.
--- /dev/null
+// rust-lang/rust#55492: errors detected during MIR-borrowck's
+// analysis of a closure body may only be caught when AST-borrowck
+// looks at some parent.
+
+// revisions: ast migrate nll
+
+// Since we are testing nll (and migration) explicitly as a separate
+// revisions, don't worry about the --compare-mode=nll on this test.
+
+// ignore-compare-mode-nll
+
+//[ast]compile-flags: -Z borrowck=ast
+//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
+//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows
+
+
+// transcribed from borrowck-closures-unique.rs
+mod borrowck_closures_unique {
+ pub fn e(x: &'static mut isize) {
+ static mut Y: isize = 3;
+ let mut c1 = |y: &'static mut isize| x = y;
+ unsafe { c1(&mut Y); }
+ }
+}
+
+mod borrowck_closures_unique_grandparent {
+ pub fn ee(x: &'static mut isize) {
+ static mut Z: isize = 3;
+ let mut c1 = |z: &'static mut isize| {
+ let mut c2 = |y: &'static mut isize| x = y;
+ c2(z);
+ };
+ unsafe { c1(&mut Z); }
+ }
+}
+
+// adapted from mutability_errors.rs
+mod mutability_errors {
+ pub fn capture_assign_whole(x: (i32,)) {
+ || { x = (1,); };
+ }
+ pub fn capture_assign_part(x: (i32,)) {
+ || { x.0 = 1; };
+ }
+ pub fn capture_reborrow_whole(x: (i32,)) {
+ || { &mut x; };
+ }
+ pub fn capture_reborrow_part(x: (i32,)) {
+ || { &mut x.0; };
+ }
+}
+
+fn main() {
+ static mut X: isize = 2;
+ unsafe { borrowck_closures_unique::e(&mut X); }
+
+ mutability_errors::capture_assign_whole((1000,));
+ mutability_errors::capture_assign_part((2000,));
+ mutability_errors::capture_reborrow_whole((3000,));
+ mutability_errors::capture_reborrow_part((4000,));
+}
+++ /dev/null
-error[E0507]: cannot move out of borrowed content
- --> $DIR/move-in-static-initializer-issue-38520.rs:25:23
- |
-LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
- | ^^^ cannot move out of borrowed content
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/move-in-static-initializer-issue-38520.rs:25:23
- |
-LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error[E0507]: cannot move out of borrowed content
- --> $DIR/move-in-static-initializer-issue-38520.rs:27:22
- |
-LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507
- | ^^^ cannot move out of borrowed content
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/move-in-static-initializer-issue-38520.rs:27:22
- |
-LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0507`.
LL | &mut x.0; //~ ERROR
| ^^^^^^^^ cannot borrow as mutable
-warning[E0594]: cannot assign to `x`, as it is not declared as mutable
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/mutability-errors.rs:70:9
|
LL | fn imm_capture(x: (i32,)) {
LL | || { //~ ERROR
LL | x = (1,);
| ^^^^^^^^ cannot assign
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-warning[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
+error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
--> $DIR/mutability-errors.rs:71:9
|
LL | fn imm_capture(x: (i32,)) {
...
LL | x.0 = 1;
| ^^^^^^^ cannot assign
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-warning[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
+error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> $DIR/mutability-errors.rs:72:9
|
LL | fn imm_capture(x: (i32,)) {
...
LL | &mut x;
| ^^^^^^ cannot borrow as mutable
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-warning[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
+error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
--> $DIR/mutability-errors.rs:73:9
|
LL | fn imm_capture(x: (i32,)) {
...
LL | &mut x.0;
| ^^^^^^^^ cannot borrow as mutable
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/mutability-errors.rs:76:9
LL | &mut X.0; //~ ERROR
| ^^^^^^^^ cannot borrow as mutable
-error: aborting due to 34 previous errors
+error: aborting due to 38 previous errors
Some errors occurred: E0594, E0596.
For more information about an error, try `rustc --explain E0594`.
LL | y.into_iter();
| ^ cannot move out of captured variable in an `Fn` closure
-error[E0507]: cannot move out of `y`, as it is a captured variable in a `Fn` closure
- --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:21:9
- |
-LL | y.into_iter();
- | ^
- | |
- | cannot move out of `y`, as it is a captured variable in a `Fn` closure
- | cannot move
- |
-help: consider changing this to accept closures that implement `FnMut`
- --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:20:10
- |
-LL | call(|| {
- | __________^
-LL | | y.into_iter();
-LL | | //~^ ERROR cannot move out of captured outer variable in an `Fn` closure
-LL | | });
- | |_____^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| ^^^^^^^^^^
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/by-move-pattern-binding.rs:26:17
- |
-LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
- | ^^^^^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
| cannot move out of static item
| help: consider borrowing here: `&x`
-error[E0507]: cannot move out of immutable static item `x`
- --> $DIR/check-static-values-constraints.rs:120:45
- |
-LL | let y = { static x: Box<isize> = box 3; x };
- | ^
- | |
- | cannot move out of immutable static item `x`
- | cannot move
-
error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:120:38
|
LL | let y = { static x: Box<isize> = box 3; x };
| ^^^^^ allocation not allowed in statics
-error: aborting due to 11 previous errors
+error: aborting due to 10 previous errors
Some errors occurred: E0010, E0015, E0493, E0507.
For more information about an error, try `rustc --explain E0010`.
--- /dev/null
+// issue-49296: Unsafe shenigans in constants can result in missing errors
+
+#![feature(const_fn)]
+#![feature(const_fn_union)]
+
+const unsafe fn transmute<T: Copy, U: Copy>(t: T) -> U {
+ union Transmute<T: Copy, U: Copy> {
+ from: T,
+ to: U,
+ }
+
+ Transmute { from: t }.to
+}
+
+const fn wat(x: u64) -> &'static u64 {
+ unsafe { transmute(&x) }
+}
+const X: u64 = *wat(42);
+//~^ ERROR any use of this value will cause an error
+
+fn main() {
+ println!("{}", X);
+}
--- /dev/null
+error: any use of this value will cause an error
+ --> $DIR/issue-49296.rs:18:1
+ |
+LL | const X: u64 = *wat(42);
+ | ^^^^^^^^^^^^^^^--------^
+ | |
+ | dangling pointer was dereferenced
+ |
+ = note: #[deny(const_err)] on by default
+
+error: aborting due to previous error
+
--- /dev/null
+// https://github.com/rust-lang/rust/issues/55454
+// compile-pass
+
+struct This<T>(T);
+
+const C: This<Option<&i32>> = This(Some(&1));
+
+fn main() {
+}
--- /dev/null
+// https://github.com/rust-lang/rust/issues/55454
+// compile-pass
+
+#[derive(PartialEq)]
+struct This<T>(T);
+
+fn main() {
+ This(Some(&1)) == This(Some(&1));
+}
LL | S[0];
| ^^^^ cannot move out of borrowed content
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/dst-index.rs:41:5
- |
-LL | S[0];
- | ^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of borrowed content
--> $DIR/dst-index.rs:44:5
|
LL | T[0];
| ^^^^ cannot move out of borrowed content
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/dst-index.rs:44:5
- |
-LL | T[0];
- | ^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 6 previous errors
+error: aborting due to 4 previous errors
Some errors occurred: E0161, E0507.
For more information about an error, try `rustc --explain E0161`.
LL | let _x: Box<str> = box *"hello world";
| ^^^^^^^^^^^^^^ cannot move out of borrowed content
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/dst-rvalue.rs:16:28
- |
-LL | let _x: Box<str> = box *"hello world";
- | ^^^^^^^^^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0508]: cannot move out of type `[isize]`, a non-copy slice
--> $DIR/dst-rvalue.rs:21:32
|
LL | let _x: Box<[isize]> = box *array;
| ^^^^^^ cannot move out of here
-error[E0507]: cannot move out of `*array` which is behind a `&` reference
- --> $DIR/dst-rvalue.rs:21:32
- |
-LL | let array: &[isize] = &[1, 2, 3];
- | ---------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3]`
-LL | let _x: Box<[isize]> = box *array;
- | ^^^^^^
- | |
- | cannot move out of `*array` which is behind a `&` reference
- | `array` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 6 previous errors
+error: aborting due to 4 previous errors
Some errors occurred: E0161, E0507, E0508.
For more information about an error, try `rustc --explain E0161`.
+++ /dev/null
-error[E0507]: cannot move out of borrowed content
- --> $DIR/E0507.rs:22:5
- |
-LL | x.borrow().nothing_is_true(); //~ ERROR E0507
- | ^^^^^^^^^^ cannot move out of borrowed content
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/E0507.rs:22:5
- |
-LL | x.borrow().nothing_is_true(); //~ ERROR E0507
- | ^^^^^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0507`.
LL | (&[hd1, ..], &[hd2, ..])
| ^^^
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-12567.rs:16:17
- |
-LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
- | ^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-12567.rs:16:31
- |
-LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
- | ^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-12567.rs:20:12
- |
-LL | (&[hd1, ..], &[hd2, ..])
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-12567.rs:20:24
- |
-LL | (&[hd1, ..], &[hd2, ..])
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 6 previous errors
+error: aborting due to 2 previous errors
-Some errors occurred: E0507, E0508.
-For more information about an error, try `rustc --explain E0507`.
+For more information about this error, try `rustc --explain E0508`.
| cannot move out of static item
| help: consider borrowing here: `&FOO`
-error[E0507]: cannot move out of immutable static item `FOO`
- --> $DIR/issue-17718-static-move.rs:16:14
- |
-LL | let _a = FOO; //~ ERROR: cannot move out of static item
- | ^^^
- | |
- | cannot move out of immutable static item `FOO`
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
| cannot move out of borrowed content
| help: consider removing the `*`: `imm_ref()`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-20801.rs:39:22
- |
-LL | let b = unsafe { *imm_ref() };
- | ^^^^^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of dereference of raw pointer
--> $DIR/issue-20801.rs:42:22
|
| cannot move out of dereference of raw pointer
| help: consider removing the `*`: `const_ptr()`
-error[E0507]: cannot move out of data in a `*const` pointer
- --> $DIR/issue-20801.rs:45:22
- |
-LL | let d = unsafe { *const_ptr() };
- | ^^^^^^^^^^^^
- | |
- | cannot move out of data in a `*const` pointer
- | cannot move
-
-error: aborting due to 6 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0507`.
LL | self.tokens //~ ERROR cannot move out of borrowed content
| ^^^^^^^^^^^ cannot move out of borrowed content
-error[E0507]: cannot move out of `self.tokens` which is behind a `&` reference
- --> $DIR/issue-2590.rs:22:9
- |
-LL | fn parse(&self) -> Vec<isize> {
- | ----- help: consider changing this to be a mutable reference: `&mut self`
-LL | self.tokens //~ ERROR cannot move out of borrowed content
- | ^^^^^^^^^^^
- | |
- | cannot move out of `self.tokens` which is behind a `&` reference
- | `self` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
LL | &X(*Y)
| ^^ cannot move out of here
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-30355.rs:15:8
- |
-LL | &X(*Y)
- | ^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
-Some errors occurred: E0161, E0507, E0508.
+Some errors occurred: E0161, E0508.
For more information about an error, try `rustc --explain E0161`.
| cannot move out of borrowed content
| help: consider borrowing here: `&f.v[0]`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-40402-1.rs:19:13
- |
-LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content
- | ^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-40402-2.rs:15:10
- |
-LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
- | ^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/issue-40402-2.rs:15:13
- |
-LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
- | ^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-40402-2.rs:15:18
|
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
| ^ ^
-error: aborting due to 3 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
LL | id(Box::new(|| *v))
| ^^ cannot move out of captured variable in an `FnMut` closure
-error[E0507]: cannot move out of `*v` which is behind a `&` reference
- --> $DIR/issue-4335.rs:16:20
- |
-LL | id(Box::new(|| *v))
- | ^^
- | |
- | cannot move out of `*v` which is behind a `&` reference
- | cannot move
-
error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function
--> $DIR/issue-4335.rs:16:17
|
LL | id(Box::new(move || *v))
| ^^^^^^^
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
Some errors occurred: E0373, E0507.
For more information about an error, try `rustc --explain E0373`.
// We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
// the malformed `1 / (2 + 3`
let _a = (1 / (2 + 3));
+ f();
+}
+
+fn f() -> bool {
+ loop {
+ if (break { return true }) {
+ }
+ }
+ false
}
LL | box E::Bar(x) => println!("{}", x.to_string()),
| ^
-error[E0507]: cannot move out of `hellothere.x.0` which is behind a `&` reference
- --> $DIR/moves-based-on-type-block-bad.rs:37:28
- |
-LL | f(&s, |hellothere| {
- | ---------- help: consider changing this to be a mutable reference: `&mut S`
-...
-LL | box E::Bar(x) => println!("{}", x.to_string()),
- | ^
- | |
- | cannot move out of `hellothere.x.0` which is behind a `&` reference
- | `hellothere` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out
| ^ cannot move out of captured variable in an `Fn` closure
-error[E0507]: cannot move out of `i`, as it is a captured variable in a `Fn` closure
- --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:28
- |
-LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out
- | ^
- | |
- | cannot move out of `i`, as it is a captured variable in a `Fn` closure
- | cannot move
- |
-help: consider changing this to accept closures that implement `FnMut`
- --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:20
- |
-LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out
- | ^^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
-error[E0507]: cannot move out of `*r` which is behind a `&` reference
- --> $DIR/cannot-move-block-spans.rs:15:15
- |
-LL | pub fn deref(r: &String) {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-LL | let x = { *r }; //~ ERROR
- | ^^
- | |
- | cannot move out of `*r` which is behind a `&` reference
- | `r` is a `&` reference, so the data it refers to cannot be moved
-
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:16:22
|
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
-error[E0507]: cannot move out of `*r` which is behind a `&` reference
- --> $DIR/cannot-move-block-spans.rs:16:22
- |
-LL | pub fn deref(r: &String) {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-LL | let x = { *r }; //~ ERROR
-LL | let y = unsafe { *r }; //~ ERROR
- | ^^
- | |
- | cannot move out of `*r` which is behind a `&` reference
- | `r` is a `&` reference, so the data it refers to cannot be moved
-
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:17:26
|
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
-error[E0507]: cannot move out of `*r` which is behind a `&` reference
- --> $DIR/cannot-move-block-spans.rs:17:26
- |
-LL | pub fn deref(r: &String) {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-...
-LL | let z = loop { break *r; }; //~ ERROR
- | ^^
- | |
- | cannot move out of `*r` which is behind a `&` reference
- | `r` is a `&` reference, so the data it refers to cannot be moved
-
error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:21:15
|
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
-error[E0507]: cannot move out of `*r` which is behind a `&` reference
- --> $DIR/cannot-move-block-spans.rs:27:38
- |
-LL | pub fn additional_statement_cases(r: &String) {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR
- | ^^
- | |
- | cannot move out of `*r` which is behind a `&` reference
- | `r` is a `&` reference, so the data it refers to cannot be moved
-
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:28:45
|
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
-error[E0507]: cannot move out of `*r` which is behind a `&` reference
- --> $DIR/cannot-move-block-spans.rs:28:45
- |
-LL | pub fn additional_statement_cases(r: &String) {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR
-LL | let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR
- | ^^
- | |
- | cannot move out of `*r` which is behind a `&` reference
- | `r` is a `&` reference, so the data it refers to cannot be moved
-
error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:29:49
|
| cannot move out of borrowed content
| help: consider removing the `*`: `r`
-error[E0507]: cannot move out of `*r` which is behind a `&` reference
- --> $DIR/cannot-move-block-spans.rs:29:49
- |
-LL | pub fn additional_statement_cases(r: &String) {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-...
-LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR
- | ^^
- | |
- | cannot move out of `*r` which is behind a `&` reference
- | `r` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 15 previous errors
+error: aborting due to 9 previous errors
Some errors occurred: E0507, E0508.
For more information about an error, try `rustc --explain E0507`.
It represents potential unsoundness in your code.
This warning will become a hard error in the future.
-warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard
- --> $DIR/match-guards-always-borrow.rs:23:13
- |
-LL | (|| { let bar = foo; bar.take() })();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | cannot move out of `foo`, as it is immutable for the pattern guard
- | cannot move
- |
- = note: variables bound in patterns are immutable until the end of the pattern guard
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-
error: compilation successful
--> $DIR/match-guards-always-borrow.rs:57:1
|
+++ /dev/null
-error[E0507]: cannot move out of static item
- --> $DIR/static-items-cant-move.rs:28:10
- |
-LL | test(BAR); //~ ERROR cannot move out of static item
- | ^^^ cannot move out of static item
-
-error[E0507]: cannot move out of immutable static item `BAR`
- --> $DIR/static-items-cant-move.rs:28:10
- |
-LL | test(BAR); //~ ERROR cannot move out of static item
- | ^^^
- | |
- | cannot move out of immutable static item `BAR`
- | cannot move
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0507`.
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/std-uncopyable-atomics.rs:19:13
- |
-LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of borrowed content
--> $DIR/std-uncopyable-atomics.rs:21:13
|
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/std-uncopyable-atomics.rs:21:13
- |
-LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of borrowed content
--> $DIR/std-uncopyable-atomics.rs:23:13
|
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/std-uncopyable-atomics.rs:23:13
- |
-LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
error[E0507]: cannot move out of borrowed content
--> $DIR/std-uncopyable-atomics.rs:25:13
|
| cannot move out of borrowed content
| help: consider removing the `*`: `&x`
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/std-uncopyable-atomics.rs:25:13
- |
-LL | let x = *&x; //~ ERROR: cannot move out of borrowed content
- | ^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 8 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0507`.
+++ /dev/null
-error[E0507]: cannot move out of borrowed content
- --> $DIR/trivial-bounds-leak-copy.rs:19:5
- |
-LL | *t //~ ERROR
- | ^^ cannot move out of borrowed content
-
-error[E0507]: cannot move out of `*t` which is behind a `&` reference
- --> $DIR/trivial-bounds-leak-copy.rs:19:5
- |
-LL | fn move_out_string(t: &String) -> String {
- | ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
-LL | *t //~ ERROR
- | ^^
- | |
- | cannot move out of `*t` which is behind a `&` reference
- | `t` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0507`.
LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move
| ^ cannot move out of captured variable in an `Fn` closure
-error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure
- --> $DIR/unboxed-closure-illegal-move.rs:25:31
- |
-LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move
- | ^
- | |
- | cannot move out of `x`, as it is a captured variable in a `Fn` closure
- | cannot move
- |
-help: consider changing this to accept closures that implement `FnMut`
- --> $DIR/unboxed-closure-illegal-move.rs:25:23
- |
-LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move
- | ^^^^^^^^^^
-
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/unboxed-closure-illegal-move.rs:29:35
|
LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move
| ^ cannot move out of captured variable in an `Fn` closure
-error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure
- --> $DIR/unboxed-closure-illegal-move.rs:38:36
- |
-LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move
- | ^
- | |
- | cannot move out of `x`, as it is a captured variable in a `Fn` closure
- | cannot move
- |
-help: consider changing this to accept closures that implement `FnMut`
- --> $DIR/unboxed-closure-illegal-move.rs:38:23
- |
-LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move
- | ^^^^^^^^^^^^^^^
-
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/unboxed-closure-illegal-move.rs:42:40
|
LL | let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move
| ^ cannot move out of captured variable in an `FnMut` closure
-error: aborting due to 6 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0507`.
LL | move || set(&mut x); //~ ERROR cannot borrow
| ^^^^^^ cannot borrow as mutable
-warning[E0594]: cannot assign to `x`, as it is not declared as mutable
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/unboxed-closure-immutable-capture.rs:23:8
|
LL | let x = 0;
...
LL | || x = 1; //~ ERROR cannot assign
| ^^^^^ cannot assign
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-warning[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
+error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> $DIR/unboxed-closure-immutable-capture.rs:25:12
|
LL | let x = 0;
...
LL | || set(&mut x); //~ ERROR cannot assign
| ^^^^^^ cannot borrow as mutable
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-warning[E0594]: cannot assign to `x`, as it is not declared as mutable
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/unboxed-closure-immutable-capture.rs:26:8
|
LL | let x = 0;
...
LL | || x = 1; //~ ERROR cannot assign
| ^^^^^ cannot assign
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-warning[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
+error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> $DIR/unboxed-closure-immutable-capture.rs:28:12
|
LL | let x = 0;
...
LL | || set(&mut x); //~ ERROR cannot assign
| ^^^^^^ cannot borrow as mutable
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
-error: aborting due to 4 previous errors
+error: aborting due to 8 previous errors
Some errors occurred: E0594, E0596.
For more information about an error, try `rustc --explain E0594`.
-warning[E0596]: cannot borrow `tick1` as mutable, as it is not declared as mutable
+error[E0596]: cannot borrow `tick1` as mutable, as it is not declared as mutable
--> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:27:9
|
LL | let tick1 = || {
...
LL | tick1();
| ^^^^^ cannot borrow as mutable
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
error[E0596]: cannot borrow `tick2` as mutable, as it is not declared as mutable
--> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:30:5
LL | tick2(); //~ ERROR cannot borrow
| ^^^^^ cannot borrow as mutable
-error: aborting due to previous error
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0596`.
-warning[E0594]: cannot assign to `n`, as it is not declared as mutable
+error[E0594]: cannot assign to `n`, as it is not declared as mutable
--> $DIR/unboxed-closures-mutate-upvar.rs:25:9
|
LL | let n = 0;
LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign
LL | n += 1;
| ^^^^^^ cannot assign
- |
- = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
- It represents potential unsoundness in your code.
- This warning will become a hard error in the future.
error[E0594]: cannot assign to `n`, as it is not declared as mutable
--> $DIR/unboxed-closures-mutate-upvar.rs:42:9
LL | | });
| |_____^
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0594`.
LL | !*n; //~ ERROR: cannot move out of borrowed content
| ^^ cannot move out of borrowed content
-error[E0507]: cannot move out of `*n` which is behind a `&` reference
- --> $DIR/unop-move-semantics.rs:36:6
- |
-LL | let n = &y;
- | -- help: consider changing this to be a mutable reference: `&mut y`
-...
-LL | !*n; //~ ERROR: cannot move out of borrowed content
- | ^^
- | |
- | cannot move out of `*n` which is behind a `&` reference
- | `n` is a `&` reference, so the data it refers to cannot be moved
-
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
Some errors occurred: E0382, E0507.
For more information about an error, try `rustc --explain E0382`.
LL | udrop::<[u8]>(foo()[..]);
| ^^^^^^^^^ cannot move out of here
-error[E0507]: cannot move out of data in a `&` reference
- --> $DIR/unsized-exprs2.rs:22:19
- |
-LL | udrop::<[u8]>(foo()[..]);
- | ^^^^^^^^^
- | |
- | cannot move out of data in a `&` reference
- | cannot move
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
-Some errors occurred: E0507, E0508.
-For more information about an error, try `rustc --explain E0507`.
+For more information about this error, try `rustc --explain E0508`.
-Subproject commit 2d0863f657e6f45159fc7412267eee3e659185e5
+Subproject commit 1fa30882067703202d13ad0bd53d630bc2c1de66
-Subproject commit b1d0343749bdc87e5cbbe7f1aeaa9d2a2c9dbc5b
+Subproject commit 481f7880df428020480eb343c209072c6db10503
// Ignore if using system LLVM and actual version
// is smaller the minimum required version
config.system_llvm && &actual_version[..] < min_version
+ } else if line.starts_with("ignore-llvm-version") {
+ // Syntax is: "ignore-llvm-version <version1> [- <version2>]"
+ let range_components = line.split(' ')
+ .skip(1) // Skip the directive.
+ .map(|s| s.trim())
+ .filter(|word| !word.is_empty() && word != &"-")
+ .take(3) // 3 or more = invalid, so take at most 3.
+ .collect::<Vec<&str>>();
+ match range_components.len() {
+ 1 => {
+ &actual_version[..] == range_components[0]
+ }
+ 2 => {
+ let v_min = range_components[0];
+ let v_max = range_components[1];
+ if v_max < v_min {
+ panic!("Malformed LLVM version range: max < min")
+ }
+ // Ignore if version lies inside of range.
+ &actual_version[..] >= v_min && &actual_version[..] <= v_max
+ }
+ _ => panic!("Malformed LLVM version directive"),
+ }
} else {
false
}
-Subproject commit 7728fa22bebea288abfea3b70cf795c60b93df3a
+Subproject commit 29bf48582812212450f4caf7da1af3f18c52bfef