From 2a5ce10dfb20e794d324cb1621e5ac892b7e421a Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 20 Apr 2018 16:30:14 -0700 Subject: [PATCH] Add test --- src/test/ui/edition-lint-paths.rs | 41 +++++++++++++++++++++++++++ src/test/ui/edition-lint-paths.stderr | 34 ++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/test/ui/edition-lint-paths.rs create mode 100644 src/test/ui/edition-lint-paths.stderr diff --git a/src/test/ui/edition-lint-paths.rs b/src/test/ui/edition-lint-paths.rs new file mode 100644 index 0000000000000..0b49e72ccd94c --- /dev/null +++ b/src/test/ui/edition-lint-paths.rs @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(crate_in_paths)] +#![deny(absolute_path_starting_with_module)] +#![allow(unused)] + +pub mod foo { + use ::bar::Bar; + //~^ ERROR Absolute + //~| WARN this was previously accepted + use super::bar::Bar2; + use crate::bar::Bar3; +} + + +use bar::Bar; +//~^ ERROR Absolute +//~| WARN this was previously accepted + +pub mod bar { + pub struct Bar; + pub type Bar2 = Bar; + pub type Bar3 = Bar; +} + +fn main() { + let x = ::bar::Bar; + //~^ ERROR Absolute + //~| WARN this was previously accepted + let x = bar::Bar; + let x = ::crate::bar::Bar; + let x = self::bar::Bar; +} diff --git a/src/test/ui/edition-lint-paths.stderr b/src/test/ui/edition-lint-paths.stderr new file mode 100644 index 0000000000000..509527e03743c --- /dev/null +++ b/src/test/ui/edition-lint-paths.stderr @@ -0,0 +1,34 @@ +error: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:16:9 + | +LL | use ::bar::Bar; + | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` + | +note: lint level defined here + --> $DIR/edition-lint-paths.rs:12:9 + | +LL | #![deny(absolute_path_starting_with_module)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue TBD + +error: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:24:5 + | +LL | use bar::Bar; + | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue TBD + +error: Absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:35:13 + | +LL | let x = ::bar::Bar; + | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue TBD + +error: aborting due to 3 previous errors +