From ac9dd1bd0cb6a2c1c86f52f3331db20768704de5 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Fri, 5 Jul 2019 18:22:08 +0100 Subject: [PATCH 1/4] Fixed up a few comments. --- src/bootstrap/lib.rs | 16 ++++++++-------- src/librustc_typeck/check/mod.rs | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 7f652c0d7a7..4d297fa918a 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -197,11 +197,11 @@ pub struct Compiler { #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum DocTests { - // Default, run normal tests and doc tests. + /// Run normal tests and doc tests (default). Yes, - // Do not run any doc tests. + /// Do not run any doc tests. No, - // Only run doc tests. + /// Only run doc tests. Only, } @@ -221,10 +221,10 @@ pub enum GitRepo { /// methods specifically on this structure itself (to make it easier to /// organize). pub struct Build { - // User-specified configuration via config.toml + /// User-specified configuration from `config.toml`. config: Config, - // Derived properties from the above two configurations + // Properties derived from the above configuration src: PathBuf, out: PathBuf, rust_info: channel::GitInfo, @@ -240,12 +240,12 @@ pub struct Build { doc_tests: DocTests, verbosity: usize, - // Targets for which to build. + // Targets for which to build build: Interned, hosts: Vec>, targets: Vec>, - // Stage 0 (downloaded) compiler and cargo or their local rust equivalents. + // Stage 0 (downloaded) compiler and cargo or their local rust equivalents initial_rustc: PathBuf, initial_cargo: PathBuf, @@ -255,7 +255,7 @@ pub struct Build { cxx: HashMap, cc::Tool>, ar: HashMap, PathBuf>, ranlib: HashMap, PathBuf>, - // Misc + // Miscellaneous crates: HashMap, Crate>, is_sudo: bool, ci_env: CiEnv, diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index efe9079e19e..783bccd0709 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4458,7 +4458,7 @@ pub fn check_bounds_are_used<'tcx>(tcx: TyCtxt<'tcx>, generics: &ty::Generics, t return; } - // Make a vector of booleans initially false, set to true when used. + // Make a vector of booleans initially `false`; set to `true` when used. let mut types_used = vec![false; own_counts.types]; for leaf_ty in ty.walk() { @@ -4467,7 +4467,7 @@ pub fn check_bounds_are_used<'tcx>(tcx: TyCtxt<'tcx>, generics: &ty::Generics, t types_used[index as usize - own_counts.lifetimes] = true; } else if let ty::Error = leaf_ty.sty { // If there is already another error, do not emit - // an error for not using a type Parameter. + // an error for not using a type parameter. assert!(tcx.sess.has_errors()); return; } From da441412f5fab6c34c2b5d01f04ac330ccf38988 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Fri, 5 Jul 2019 18:22:26 +0100 Subject: [PATCH 2/4] Fixed ICEs. --- src/librustc_resolve/lib.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 13b9855dbd7..e5dcca4779b 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2518,17 +2518,7 @@ impl<'a> Resolver<'a> { debug!("(resolving item) resolving {} ({:?})", name, item.node); match item.node { - ItemKind::Ty(_, ref generics) => { - self.with_current_self_item(item, |this| { - this.with_generic_param_rib(HasGenericParams(generics, ItemRibKind), |this| { - let item_def_id = this.definitions.local_def_id(item.id); - this.with_self_rib(Res::SelfTy(Some(item_def_id), None), |this| { - visit::walk_item(this, item) - }) - }) - }); - } - + ItemKind::Ty(_, ref generics) | ItemKind::Existential(_, ref generics) | ItemKind::Fn(_, _, ref generics, _) => { self.with_generic_param_rib( From 11228ca3a08295fe452891a3d468b89bb874bc47 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 6 Jul 2019 16:15:27 +0100 Subject: [PATCH 3/4] Added tests for issues. --- src/test/ui/{cast_char.rs => cast-char.rs} | 0 src/test/ui/{cast_char.stderr => cast-char.stderr} | 6 +++--- src/test/ui/type-alias/issue-62263-self-in-atb.rs | 8 ++++++++ src/test/ui/type-alias/issue-62305-self-assoc-ty.rs | 4 ++++ src/test/ui/type-alias/issue-62364-self-ty-arg.rs | 8 ++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) rename src/test/ui/{cast_char.rs => cast-char.rs} (100%) rename src/test/ui/{cast_char.stderr => cast-char.stderr} (85%) create mode 100644 src/test/ui/type-alias/issue-62263-self-in-atb.rs create mode 100644 src/test/ui/type-alias/issue-62305-self-assoc-ty.rs create mode 100644 src/test/ui/type-alias/issue-62364-self-ty-arg.rs diff --git a/src/test/ui/cast_char.rs b/src/test/ui/cast-char.rs similarity index 100% rename from src/test/ui/cast_char.rs rename to src/test/ui/cast-char.rs diff --git a/src/test/ui/cast_char.stderr b/src/test/ui/cast-char.stderr similarity index 85% rename from src/test/ui/cast_char.stderr rename to src/test/ui/cast-char.stderr index 37ef98bcb50..1729e5cbf09 100644 --- a/src/test/ui/cast_char.stderr +++ b/src/test/ui/cast-char.stderr @@ -1,17 +1,17 @@ error: only `u8` can be cast into `char` - --> $DIR/cast_char.rs:4:23 + --> $DIR/cast-char.rs:4:23 | LL | const XYZ: char = 0x1F888 as char; | ^^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{1F888}'` | note: lint level defined here - --> $DIR/cast_char.rs:1:9 + --> $DIR/cast-char.rs:1:9 | LL | #![deny(overflowing_literals)] | ^^^^^^^^^^^^^^^^^^^^ error: only `u8` can be cast into `char` - --> $DIR/cast_char.rs:6:22 + --> $DIR/cast-char.rs:6:22 | LL | const XY: char = 129160 as char; | ^^^^^^^^^^^^^^ help: use a `char` literal instead: `'\u{1F888}'` diff --git a/src/test/ui/type-alias/issue-62263-self-in-atb.rs b/src/test/ui/type-alias/issue-62263-self-in-atb.rs new file mode 100644 index 00000000000..5e812db4d23 --- /dev/null +++ b/src/test/ui/type-alias/issue-62263-self-in-atb.rs @@ -0,0 +1,8 @@ +pub trait Trait { + type A; +} + +pub type Alias = dyn Trait; +//~^ ERROR failed to resolve: use of undeclared type or module `Self` [E0433] + +fn main() {} diff --git a/src/test/ui/type-alias/issue-62305-self-assoc-ty.rs b/src/test/ui/type-alias/issue-62305-self-assoc-ty.rs new file mode 100644 index 00000000000..0b95ddeb19e --- /dev/null +++ b/src/test/ui/type-alias/issue-62305-self-assoc-ty.rs @@ -0,0 +1,4 @@ +type Alias = Self::Target; +//~^ ERROR failed to resolve: use of undeclared type or module `Self` [E0433] + +fn main() {} diff --git a/src/test/ui/type-alias/issue-62364-self-ty-arg.rs b/src/test/ui/type-alias/issue-62364-self-ty-arg.rs new file mode 100644 index 00000000000..bebb4a9021a --- /dev/null +++ b/src/test/ui/type-alias/issue-62364-self-ty-arg.rs @@ -0,0 +1,8 @@ +struct Struct { + field: P1, +} + +type Alias<'a> = Struct<&'a Self>; +//~^ ERROR cannot find type `Self` in this scope [E0411] + +fn main() {} From f035630089a4d7b037183cd9ded8b275e37601d6 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 6 Jul 2019 16:16:12 +0100 Subject: [PATCH 4/4] Blessed tests. --- src/test/ui/type-alias/issue-62263-self-in-atb.stderr | 9 +++++++++ src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr | 9 +++++++++ src/test/ui/type-alias/issue-62364-self-ty-arg.stderr | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/test/ui/type-alias/issue-62263-self-in-atb.stderr create mode 100644 src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr create mode 100644 src/test/ui/type-alias/issue-62364-self-ty-arg.stderr diff --git a/src/test/ui/type-alias/issue-62263-self-in-atb.stderr b/src/test/ui/type-alias/issue-62263-self-in-atb.stderr new file mode 100644 index 00000000000..a642d029f93 --- /dev/null +++ b/src/test/ui/type-alias/issue-62263-self-in-atb.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: use of undeclared type or module `Self` + --> $DIR/issue-62263-self-in-atb.rs:5:32 + | +LL | pub type Alias = dyn Trait; + | ^^^^ use of undeclared type or module `Self` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr b/src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr new file mode 100644 index 00000000000..6eb445e9dbc --- /dev/null +++ b/src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: use of undeclared type or module `Self` + --> $DIR/issue-62305-self-assoc-ty.rs:1:14 + | +LL | type Alias = Self::Target; + | ^^^^ use of undeclared type or module `Self` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/type-alias/issue-62364-self-ty-arg.stderr b/src/test/ui/type-alias/issue-62364-self-ty-arg.stderr new file mode 100644 index 00000000000..5ed27760a82 --- /dev/null +++ b/src/test/ui/type-alias/issue-62364-self-ty-arg.stderr @@ -0,0 +1,9 @@ +error[E0411]: cannot find type `Self` in this scope + --> $DIR/issue-62364-self-ty-arg.rs:5:29 + | +LL | type Alias<'a> = Struct<&'a Self>; + | ^^^^ `Self` is only available in impls, traits, and type definitions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0411`.