From 063553fbc083fb1fbffb313300dfb65f460d664c Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 30 Nov 2018 21:16:21 +0300 Subject: [PATCH 01/15] resolve: Avoid "self-confirming" resolutions in import validation --- src/librustc_resolve/build_reduced_graph.rs | 9 +++- src/librustc_resolve/lib.rs | 2 + src/librustc_resolve/macros.rs | 8 ++-- src/librustc_resolve/resolve_imports.rs | 45 ++++++++++++------- .../feature-gate-uniform-paths.stderr | 18 ++------ 5 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 0fa41cb484fc..b9de05f7d6f4 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -230,13 +230,18 @@ impl<'a, 'cl> Resolver<'a, 'cl> { } let subclass = SingleImport { - target: ident, source: source.ident, - result: PerNS { + target: ident, + source_bindings: PerNS { type_ns: Cell::new(Err(Undetermined)), value_ns: Cell::new(Err(Undetermined)), macro_ns: Cell::new(Err(Undetermined)), }, + target_bindings: PerNS { + type_ns: Cell::new(None), + value_ns: Cell::new(None), + macro_ns: Cell::new(None), + }, type_ns_only, }; self.add_import_directive( diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index e39c764e089c..1d768354a686 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1521,6 +1521,7 @@ pub struct Resolver<'a, 'b: 'a> { /// FIXME: Refactor things so that this is passed through arguments and not resolver. last_import_segment: bool, + blacklisted_binding: Option<&'a NameBinding<'a>>, /// The idents for the primitive types. primitive_type_table: PrimitiveTypeTable, @@ -1871,6 +1872,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { current_self_type: None, current_self_item: None, last_import_segment: false, + blacklisted_binding: None, primitive_type_table: PrimitiveTypeTable::new(), diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 5db3efee9f6a..1707eeca1430 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -977,12 +977,14 @@ impl<'a, 'cl> Resolver<'a, 'cl> { let what = self.binding_description(binding, ident, flags.contains(Flags::MISC_FROM_PRELUDE)); let note_msg = format!("this import refers to {what}", what = what); - if binding.span.is_dummy() { + let label_span = if binding.span.is_dummy() { err.note(¬e_msg); + ident.span } else { err.span_note(binding.span, ¬e_msg); - err.span_label(binding.span, "not an extern crate passed with `--extern`"); - } + binding.span + }; + err.span_label(label_span, "not an extern crate passed with `--extern`"); err.emit(); } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index ddcaf54f2a55..28c555d0fcde 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -42,9 +42,10 @@ use std::{mem, ptr}; #[derive(Clone, Debug)] pub enum ImportDirectiveSubclass<'a> { SingleImport { - target: Ident, source: Ident, - result: PerNS, Determinacy>>>, + target: Ident, + source_bindings: PerNS, Determinacy>>>, + target_bindings: PerNS>>>, type_ns_only: bool, }, GlobImport { @@ -227,6 +228,11 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> { } let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| { + if let Some(blacklisted_binding) = this.blacklisted_binding { + if ptr::eq(binding, blacklisted_binding) { + return Err((Determined, Weak::No)); + } + } // `extern crate` are always usable for backwards compatibility, see issue #37020, // remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`. let usable = this.is_accessible(binding.vis) || binding.is_extern_crate(); @@ -646,10 +652,10 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { if let Some((span, err, note)) = self.finalize_import(import) { errors = true; - if let SingleImport { source, ref result, .. } = import.subclass { + if let SingleImport { source, ref source_bindings, .. } = import.subclass { if source.name == "self" { // Silence `unresolved import` error if E0429 is already emitted - if let Err(Determined) = result.value_ns.get() { + if let Err(Determined) = source_bindings.value_ns.get() { continue; } } @@ -769,9 +775,11 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { }; directive.imported_module.set(Some(module)); - let (source, target, result, type_ns_only) = match directive.subclass { - SingleImport { source, target, ref result, type_ns_only } => - (source, target, result, type_ns_only), + let (source, target, source_bindings, target_bindings, type_ns_only) = + match directive.subclass { + SingleImport { source, target, ref source_bindings, + ref target_bindings, type_ns_only } => + (source, target, source_bindings, target_bindings, type_ns_only), GlobImport { .. } => { self.resolve_glob_import(directive); return true; @@ -781,7 +789,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { let mut indeterminate = false; self.per_ns(|this, ns| if !type_ns_only || ns == TypeNS { - if let Err(Undetermined) = result[ns].get() { + if let Err(Undetermined) = source_bindings[ns].get() { // For better failure detection, pretend that the import will // not define any names while resolving its module path. let orig_vis = directive.vis.replace(ty::Visibility::Invisible); @@ -790,13 +798,13 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { ); directive.vis.set(orig_vis); - result[ns].set(binding); + source_bindings[ns].set(binding); } else { return }; let parent = directive.parent_scope.module; - match result[ns].get() { + match source_bindings[ns].get() { Err(Undetermined) => indeterminate = true, Err(Determined) => { this.update_resolution(parent, target, ns, |_, resolution| { @@ -814,6 +822,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { } Ok(binding) => { let imported_binding = this.import(binding, directive); + target_bindings[ns].set(Some(imported_binding)); let conflict = this.try_define(parent, target, ns, imported_binding); if let Err(old_binding) = conflict { this.report_conflict(parent, target, ns, imported_binding, old_binding); @@ -885,8 +894,9 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { PathResult::Indeterminate | PathResult::NonModule(..) => unreachable!(), }; - let (ident, result, type_ns_only) = match directive.subclass { - SingleImport { source, ref result, type_ns_only, .. } => (source, result, type_ns_only), + let (ident, source_bindings, target_bindings, type_ns_only) = match directive.subclass { + SingleImport { source, ref source_bindings, ref target_bindings, type_ns_only, .. } => + (source, source_bindings, target_bindings, type_ns_only), GlobImport { is_prelude, ref max_vis } => { if directive.module_path.len() <= 1 { // HACK(eddyb) `lint_if_path_starts_with_module` needs at least @@ -925,17 +935,20 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { let mut all_ns_err = true; self.per_ns(|this, ns| if !type_ns_only || ns == TypeNS { let orig_vis = directive.vis.replace(ty::Visibility::Invisible); + let orig_blacklisted_binding = + mem::replace(&mut this.blacklisted_binding, target_bindings[ns].get()); let orig_last_import_segment = mem::replace(&mut this.last_import_segment, true); let binding = this.resolve_ident_in_module( module, ident, ns, Some(&directive.parent_scope), true, directive.span ); this.last_import_segment = orig_last_import_segment; + this.blacklisted_binding = orig_blacklisted_binding; directive.vis.set(orig_vis); match binding { Ok(binding) => { // Consistency checks, analogous to `finalize_current_module_macro_resolutions`. - let initial_def = result[ns].get().map(|initial_binding| { + let initial_def = source_bindings[ns].get().map(|initial_binding| { all_ns_err = false; this.record_use(ident, ns, initial_binding, directive.module_path.is_empty()); @@ -1040,7 +1053,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { let mut reexport_error = None; let mut any_successful_reexport = false; self.per_ns(|this, ns| { - if let Ok(binding) = result[ns].get() { + if let Ok(binding) = source_bindings[ns].get() { let vis = directive.vis.get(); if !binding.pseudo_vis().is_at_least(vis, &*this) { reexport_error = Some((ns, binding)); @@ -1084,7 +1097,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { let mut full_path = directive.module_path.clone(); full_path.push(Segment::from_ident(ident)); self.per_ns(|this, ns| { - if let Ok(binding) = result[ns].get() { + if let Ok(binding) = source_bindings[ns].get() { this.lint_if_path_starts_with_module( directive.crate_lint(), &full_path, @@ -1098,7 +1111,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { // Record what this import resolves to for later uses in documentation, // this may resolve to either a value or a type, but for documentation // purposes it's good enough to just favor one over the other. - self.per_ns(|this, ns| if let Some(binding) = result[ns].get().ok() { + self.per_ns(|this, ns| if let Some(binding) = source_bindings[ns].get().ok() { let mut def = binding.def(); if let Def::Macro(def_id, _) = def { // `DefId`s from the "built-in macro crate" should not leak from resolve because diff --git a/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr b/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr index ec8937bbc5f5..0631f2c355f7 100644 --- a/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr +++ b/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr @@ -25,11 +25,7 @@ LL | use inline; //~ ERROR imports can only refer to extern crate names | ^^^^^^ not an extern crate passed with `--extern` | = help: add #![feature(uniform_paths)] to the crate attributes to enable -note: this import refers to the built-in attribute imported here - --> $DIR/feature-gate-uniform-paths.rs:21:5 - | -LL | use inline; //~ ERROR imports can only refer to extern crate names - | ^^^^^^ + = note: this import refers to a built-in attribute error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) --> $DIR/feature-gate-uniform-paths.rs:23:5 @@ -38,11 +34,7 @@ LL | use Vec; //~ ERROR imports can only refer to extern crate names | ^^^ not an extern crate passed with `--extern` | = help: add #![feature(uniform_paths)] to the crate attributes to enable -note: this import refers to the struct imported here - --> $DIR/feature-gate-uniform-paths.rs:23:5 - | -LL | use Vec; //~ ERROR imports can only refer to extern crate names - | ^^^ + = note: this import refers to a struct from prelude error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) --> $DIR/feature-gate-uniform-paths.rs:25:5 @@ -51,11 +43,7 @@ LL | use vec; //~ ERROR imports can only refer to extern crate names | ^^^ not an extern crate passed with `--extern` | = help: add #![feature(uniform_paths)] to the crate attributes to enable -note: this import refers to the macro imported here - --> $DIR/feature-gate-uniform-paths.rs:25:5 - | -LL | use vec; //~ ERROR imports can only refer to extern crate names - | ^^^ + = note: this import refers to a macro from prelude error: aborting due to 4 previous errors From 98e435eff1b181c805f24a99e8ba6166118ebfdb Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 28 Dec 2018 05:20:11 +0300 Subject: [PATCH 02/15] resolve: Fix an ICE in import validation --- src/librustc_resolve/resolve_imports.rs | 18 ++++++++++++------ .../uniform-paths/auxiliary/issue-56596.rs | 1 + .../ui/rust-2018/uniform-paths/issue-56596.rs | 14 ++++++++++++++ .../rust-2018/uniform-paths/issue-56596.stderr | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/rust-2018/uniform-paths/auxiliary/issue-56596.rs create mode 100644 src/test/ui/rust-2018/uniform-paths/issue-56596.rs create mode 100644 src/test/ui/rust-2018/uniform-paths/issue-56596.stderr diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 28c555d0fcde..5a0ccb6a250f 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -228,11 +228,6 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> { } let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| { - if let Some(blacklisted_binding) = this.blacklisted_binding { - if ptr::eq(binding, blacklisted_binding) { - return Err((Determined, Weak::No)); - } - } // `extern crate` are always usable for backwards compatibility, see issue #37020, // remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`. let usable = this.is_accessible(binding.vis) || binding.is_extern_crate(); @@ -240,7 +235,18 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> { }; if record_used { - return resolution.binding.ok_or((Determined, Weak::No)).and_then(|binding| { + return resolution.binding.and_then(|binding| { + // If the primary binding is blacklisted, search further and return the shadowed + // glob binding if it exists. What we really want here is having two separate + // scopes in a module - one for non-globs and one for globs, but until that's done + // use this hack to avoid inconsistent resolution ICEs during import validation. + if let Some(blacklisted_binding) = self.blacklisted_binding { + if ptr::eq(binding, blacklisted_binding) { + return resolution.shadowed_glob; + } + } + Some(binding) + }).ok_or((Determined, Weak::No)).and_then(|binding| { if self.last_import_segment && check_usable(self, binding).is_err() { Err((Determined, Weak::No)) } else { diff --git a/src/test/ui/rust-2018/uniform-paths/auxiliary/issue-56596.rs b/src/test/ui/rust-2018/uniform-paths/auxiliary/issue-56596.rs new file mode 100644 index 000000000000..bc010a3dd2ba --- /dev/null +++ b/src/test/ui/rust-2018/uniform-paths/auxiliary/issue-56596.rs @@ -0,0 +1 @@ +// Nothing here diff --git a/src/test/ui/rust-2018/uniform-paths/issue-56596.rs b/src/test/ui/rust-2018/uniform-paths/issue-56596.rs new file mode 100644 index 000000000000..5c40d78d81c2 --- /dev/null +++ b/src/test/ui/rust-2018/uniform-paths/issue-56596.rs @@ -0,0 +1,14 @@ +// edition:2018 +// compile-flags: --extern issue_56596 +// aux-build:issue-56596.rs + +#![feature(uniform_paths)] + +mod m { + pub mod issue_56596 {} +} + +use m::*; +use issue_56596; //~ ERROR `issue_56596` is ambiguous + +fn main() {} diff --git a/src/test/ui/rust-2018/uniform-paths/issue-56596.stderr b/src/test/ui/rust-2018/uniform-paths/issue-56596.stderr new file mode 100644 index 000000000000..293d0ec6a720 --- /dev/null +++ b/src/test/ui/rust-2018/uniform-paths/issue-56596.stderr @@ -0,0 +1,18 @@ +error[E0659]: `issue_56596` is ambiguous (name vs any other name during import resolution) + --> $DIR/issue-56596.rs:12:5 + | +LL | use issue_56596; //~ ERROR `issue_56596` is ambiguous + | ^^^^^^^^^^^ ambiguous name + | + = note: `issue_56596` could refer to an extern crate passed with `--extern` + = help: use `::issue_56596` to refer to this extern crate unambiguously +note: `issue_56596` could also refer to the module imported here + --> $DIR/issue-56596.rs:11:5 + | +LL | use m::*; + | ^^^^ + = help: use `crate::issue_56596` to refer to this module unambiguously + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. From 62956b5958b6fc787990ad294f415a93fa82701a Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 9 Dec 2018 21:49:21 +0300 Subject: [PATCH 03/15] resolve: Assign `pub` and `pub(crate)` visibilities to `macro_rules` items --- src/librustc_resolve/macros.rs | 10 ++++-- .../ui/rust-2018/uniform-paths/macro-rules.rs | 18 +++++----- .../uniform-paths/macro-rules.stderr | 34 +++---------------- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 1707eeca1430..a1cc684e1756 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -1189,7 +1189,12 @@ impl<'a, 'cl> Resolver<'a, 'cl> { let ident = ident.modern(); self.macro_names.insert(ident); let def = Def::Macro(def_id, MacroKind::Bang); - let vis = ty::Visibility::Invisible; // Doesn't matter for legacy bindings + let is_macro_export = attr::contains_name(&item.attrs, "macro_export"); + let vis = if is_macro_export { + ty::Visibility::Public + } else { + ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)) + }; let binding = (def, vis, item.span, expansion).to_name_binding(self.arenas); self.set_binding_parent_module(binding, self.current_module); let legacy_binding = self.arenas.alloc_legacy_binding(LegacyBinding { @@ -1197,9 +1202,8 @@ impl<'a, 'cl> Resolver<'a, 'cl> { }); *current_legacy_scope = LegacyScope::Binding(legacy_binding); self.all_macros.insert(ident.name, def); - if attr::contains_name(&item.attrs, "macro_export") { + if is_macro_export { let module = self.graph_root; - let vis = ty::Visibility::Public; self.define(module, ident, MacroNS, (def, vis, item.span, expansion, IsMacroExport)); } else { diff --git a/src/test/ui/rust-2018/uniform-paths/macro-rules.rs b/src/test/ui/rust-2018/uniform-paths/macro-rules.rs index e8098a467904..bd098616aa93 100644 --- a/src/test/ui/rust-2018/uniform-paths/macro-rules.rs +++ b/src/test/ui/rust-2018/uniform-paths/macro-rules.rs @@ -1,14 +1,14 @@ // edition:2018 -// For the time being `macro_rules` items are treated as *very* private... - #![feature(underscore_imports, decl_macro, uniform_paths)] mod m1 { + // Non-exported legacy macros are treated as `pub(crate)`. macro_rules! legacy_macro { () => () } - // ... so they can't be imported by themselves, ... - use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported + use legacy_macro as _; // OK + pub(crate) use legacy_macro as _; // OK + pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported } mod m2 { @@ -16,7 +16,7 @@ mod m2 { type legacy_macro = u8; - // ... but don't prevent names from other namespaces from being imported, ... + // Legacy macro imports don't prevent names from other namespaces from being imported. use legacy_macro as _; // OK } @@ -26,19 +26,17 @@ mod m3 { fn f() { macro_rules! legacy_macro { () => () } - // ... but still create ambiguities with other names in the same namespace. + // Legacy macro imports create ambiguities with other names in the same namespace. use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous - //~| ERROR `legacy_macro` is private, and cannot be re-exported } } mod exported { - // Exported macros are treated as private as well, - // some better rules need to be figured out later. + // Exported legacy macros are treated as `pub`. #[macro_export] macro_rules! legacy_macro { () => () } - use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported + pub use legacy_macro as _; // OK } fn main() {} diff --git a/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr b/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr index d7bb233dfe99..004bcc45ea4a 100644 --- a/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr +++ b/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr @@ -1,39 +1,15 @@ error[E0364]: `legacy_macro` is private, and cannot be re-exported - --> $DIR/macro-rules.rs:11:9 + --> $DIR/macro-rules.rs:11:13 | -LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported - | ^^^^^^^^^^^^^^^^^ - | -note: consider marking `legacy_macro` as `pub` in the imported module - --> $DIR/macro-rules.rs:11:9 - | -LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported - | ^^^^^^^^^^^^^^^^^ - -error[E0364]: `legacy_macro` is private, and cannot be re-exported - --> $DIR/macro-rules.rs:30:13 - | -LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous +LL | pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported | ^^^^^^^^^^^^^^^^^ | note: consider marking `legacy_macro` as `pub` in the imported module - --> $DIR/macro-rules.rs:30:13 + --> $DIR/macro-rules.rs:11:13 | -LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous +LL | pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported | ^^^^^^^^^^^^^^^^^ -error[E0364]: `legacy_macro` is private, and cannot be re-exported - --> $DIR/macro-rules.rs:41:9 - | -LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported - | ^^^^^^^^^^^^^^^^^ - | -note: consider marking `legacy_macro` as `pub` in the imported module - --> $DIR/macro-rules.rs:41:9 - | -LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported - | ^^^^^^^^^^^^^^^^^ - error[E0659]: `legacy_macro` is ambiguous (name vs any other name during import resolution) --> $DIR/macro-rules.rs:30:13 | @@ -52,7 +28,7 @@ LL | macro legacy_macro() {} | ^^^^^^^^^^^^^^^^^^^^^^^ = help: use `self::legacy_macro` to refer to this macro unambiguously -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors Some errors occurred: E0364, E0659. For more information about an error, try `rustc --explain E0364`. From 98567b53d40cfcdc3cf59fdef451ba62bc4326bb Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 9 Dec 2018 22:58:51 +0300 Subject: [PATCH 04/15] resolve: Prohibit use of uniform paths in macros originating from 2015 edition ...while still keeping ambiguity errors future-proofing for uniform paths. This corner case is not going to be stabilized for 1.32 and needs some more general experiments about retrofitting 2018 import rules to 2015 edition --- src/librustc_resolve/macros.rs | 13 +++++++++---- .../edition-imports-virtual-2015-gated.stderr | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index a1cc684e1756..55c6ab8728c4 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -953,7 +953,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { // but its `Def` should coincide with a crate passed with `--extern` // (otherwise there would be ambiguity) and we can skip feature error in this case. 'ok: { - if !is_import || self.session.features_untracked().uniform_paths { + if !is_import || (!rust_2015 && self.session.features_untracked().uniform_paths) { break 'ok; } if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() { @@ -969,10 +969,15 @@ impl<'a, 'cl> Resolver<'a, 'cl> { } } - let msg = "imports can only refer to extern crate names \ - passed with `--extern` on stable channel"; + let reason = if rust_2015 { + "in macros originating from 2015 edition" + } else { + "on stable channel" + }; + let msg = format!("imports can only refer to extern crate names \ + passed with `--extern` {}", reason); let mut err = feature_err(&self.session.parse_sess, "uniform_paths", - ident.span, GateIssue::Language, msg); + ident.span, GateIssue::Language, &msg); let what = self.binding_description(binding, ident, flags.contains(Flags::MISC_FROM_PRELUDE)); diff --git a/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr b/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr index 7c1837e3f56e..3cf967dbf70e 100644 --- a/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr +++ b/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr @@ -1,4 +1,4 @@ -error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) +error[E0658]: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition (see issue #53130) --> <::edition_imports_2015::gen_gated macros>:1:50 | LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } } From bfb9b954acf734fc9dfa8da2588b204f3269b50c Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 12 Dec 2018 04:11:46 +0300 Subject: [PATCH 05/15] resolve: Prohibit use of imported non-macro attributes --- src/librustc/hir/def.rs | 2 +- src/librustc_resolve/macros.rs | 19 ++++++++++++++++++- .../rust-2018/uniform-paths/prelude-fail-2.rs | 9 +++++++++ .../uniform-paths/prelude-fail-2.stderr | 14 ++++++++++++++ .../ui/rust-2018/uniform-paths/prelude.rs | 4 ---- 5 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs create mode 100644 src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index 50922ee601da..c5c3e073531f 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -248,7 +248,7 @@ impl CtorKind { } impl NonMacroAttrKind { - fn descr(self) -> &'static str { + pub fn descr(self) -> &'static str { match self { NonMacroAttrKind::Builtin => "built-in attribute", NonMacroAttrKind::Tool => "tool attribute", diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 55c6ab8728c4..e0a275cb5a1e 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -499,6 +499,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { .push((path, path_span, kind, parent_scope.clone(), def.ok())); } + self.prohibit_imported_non_macro_attrs(None, def.ok(), path_span); def } else { let binding = self.early_resolve_ident_in_lexical_scope( @@ -515,7 +516,9 @@ impl<'a, 'cl> Resolver<'a, 'cl> { .push((path[0].ident, kind, parent_scope.clone(), binding.ok())); } - binding.map(|binding| binding.def_ignoring_ambiguity()) + let def = binding.map(|binding| binding.def_ignoring_ambiguity()); + self.prohibit_imported_non_macro_attrs(binding.ok(), def.ok(), path_span); + def } } @@ -1098,6 +1101,20 @@ impl<'a, 'cl> Resolver<'a, 'cl> { } } + fn prohibit_imported_non_macro_attrs(&self, binding: Option<&'a NameBinding<'a>>, + def: Option, span: Span) { + if let Some(Def::NonMacroAttr(kind)) = def { + if kind != NonMacroAttrKind::Tool && binding.map_or(true, |b| b.is_import()) { + let msg = format!("cannot use a {} through an import", kind.descr()); + let mut err = self.session.struct_span_err(span, &msg); + if let Some(binding) = binding { + err.span_note(binding.span, &format!("the {} imported here", kind.descr())); + } + err.emit(); + } + } + } + fn suggest_macro_name(&mut self, name: &str, kind: MacroKind, err: &mut DiagnosticBuilder<'a>, span: Span) { // First check if this is a locally-defined bang macro. diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs new file mode 100644 index 000000000000..6488b89f3698 --- /dev/null +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs @@ -0,0 +1,9 @@ +// edition:2018 + +#![feature(uniform_paths)] + +// Built-in attribute +use inline as imported_inline; + +#[imported_inline] //~ ERROR cannot use a built-in attribute through an import +fn main() {} diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr new file mode 100644 index 000000000000..10dd303aa283 --- /dev/null +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr @@ -0,0 +1,14 @@ +error: cannot use a built-in attribute through an import + --> $DIR/prelude-fail-2.rs:8:3 + | +LL | #[imported_inline] //~ ERROR cannot use a built-in attribute through an import + | ^^^^^^^^^^^^^^^ + | +note: the built-in attribute imported here + --> $DIR/prelude-fail-2.rs:6:5 + | +LL | use inline as imported_inline; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/rust-2018/uniform-paths/prelude.rs b/src/test/ui/rust-2018/uniform-paths/prelude.rs index 5aab5fc3a401..46ce725fdba9 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude.rs +++ b/src/test/ui/rust-2018/uniform-paths/prelude.rs @@ -6,9 +6,6 @@ // Macro imported with `#[macro_use] extern crate` use vec as imported_vec; -// Built-in attribute -use inline as imported_inline; - // Tool module use rustfmt as imported_rustfmt; @@ -20,7 +17,6 @@ use u8 as imported_u8; type A = imported_u8; -#[imported_inline] #[imported_rustfmt::skip] fn main() { imported_vec![0]; From e412291d0592aca385e3949a426106a85962d1d2 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 13 Dec 2018 01:43:44 +0300 Subject: [PATCH 06/15] resolve: Prohibit use of imported tool modules --- src/librustc_resolve/lib.rs | 7 ++++ .../rust-2018/uniform-paths/prelude-fail-2.rs | 12 +++++++ .../uniform-paths/prelude-fail-2.stderr | 34 +++++++++++++++++-- .../ui/rust-2018/uniform-paths/prelude.rs | 4 --- 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 1d768354a686..50704a6838ac 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3860,6 +3860,13 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { module = Some(ModuleOrUniformRoot::Module(next_module)); record_segment_def(self, def); } else if def == Def::ToolMod && i + 1 != path.len() { + if binding.is_import() { + self.session.struct_span_err( + ident.span, "cannot use a tool module through an import" + ).span_note( + binding.span, "the tool module imported here" + ).emit(); + } let def = Def::NonMacroAttr(NonMacroAttrKind::Tool); return PathResult::NonModule(PathResolution::new(def)); } else if def == Def::Err { diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs index 6488b89f3698..e153e868b311 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs @@ -4,6 +4,18 @@ // Built-in attribute use inline as imported_inline; +mod builtin { + pub use inline as imported_inline; +} + +// Tool module +use rustfmt as imported_rustfmt; +mod tool_mod { + pub use rustfmt as imported_rustfmt; +} #[imported_inline] //~ ERROR cannot use a built-in attribute through an import +#[builtin::imported_inline] //~ ERROR cannot use a built-in attribute through an import +#[imported_rustfmt::skip] //~ ERROR cannot use a tool module through an import +#[tool_mod::imported_rustfmt::skip] //~ ERROR cannot use a tool module through an import fn main() {} diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr index 10dd303aa283..4c49cd89bdcb 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr @@ -1,5 +1,5 @@ error: cannot use a built-in attribute through an import - --> $DIR/prelude-fail-2.rs:8:3 + --> $DIR/prelude-fail-2.rs:17:3 | LL | #[imported_inline] //~ ERROR cannot use a built-in attribute through an import | ^^^^^^^^^^^^^^^ @@ -10,5 +10,35 @@ note: the built-in attribute imported here LL | use inline as imported_inline; | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: cannot use a built-in attribute through an import + --> $DIR/prelude-fail-2.rs:18:3 + | +LL | #[builtin::imported_inline] //~ ERROR cannot use a built-in attribute through an import + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: cannot use a tool module through an import + --> $DIR/prelude-fail-2.rs:19:3 + | +LL | #[imported_rustfmt::skip] //~ ERROR cannot use a tool module through an import + | ^^^^^^^^^^^^^^^^ + | +note: the tool module imported here + --> $DIR/prelude-fail-2.rs:12:5 + | +LL | use rustfmt as imported_rustfmt; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: cannot use a tool module through an import + --> $DIR/prelude-fail-2.rs:20:13 + | +LL | #[tool_mod::imported_rustfmt::skip] //~ ERROR cannot use a tool module through an import + | ^^^^^^^^^^^^^^^^ + | +note: the tool module imported here + --> $DIR/prelude-fail-2.rs:14:13 + | +LL | pub use rustfmt as imported_rustfmt; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors diff --git a/src/test/ui/rust-2018/uniform-paths/prelude.rs b/src/test/ui/rust-2018/uniform-paths/prelude.rs index 46ce725fdba9..1a6027f30d78 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude.rs +++ b/src/test/ui/rust-2018/uniform-paths/prelude.rs @@ -6,9 +6,6 @@ // Macro imported with `#[macro_use] extern crate` use vec as imported_vec; -// Tool module -use rustfmt as imported_rustfmt; - // Standard library prelude use Vec as ImportedVec; @@ -17,7 +14,6 @@ use u8 as imported_u8; type A = imported_u8; -#[imported_rustfmt::skip] fn main() { imported_vec![0]; ImportedVec::::new(); From 19836b2fb40c3768dc4f1f258ed29d2a3fea3ceb Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 27 Dec 2018 03:38:43 +0300 Subject: [PATCH 07/15] Stabilize `uniform_paths` --- src/librustc_resolve/macros.rs | 29 ++++------- src/libsyntax/feature_gate.rs | 7 ++- .../uniform-paths/auxiliary/issue-53691.rs | 2 - .../run-pass/uniform-paths/basic-nested.rs | 18 ++----- src/test/run-pass/uniform-paths/basic.rs | 6 +-- .../run-pass/uniform-paths/macros-nested.rs | 16 +----- src/test/run-pass/uniform-paths/macros.rs | 16 +----- src/test/run-pass/uniform-paths/same-crate.rs | 3 -- src/test/ui/editions/edition-imports-2015.rs | 2 - .../ui/editions/edition-imports-2015.stderr | 2 +- .../edition-imports-virtual-2015-gated.stderr | 4 +- .../feature-gate-uniform-paths.rs | 29 ----------- .../feature-gate-uniform-paths.stderr | 50 ------------------- src/test/ui/imports/issue-56125.rs | 2 - src/test/ui/imports/issue-56125.stderr | 14 +++--- .../not-whitelisted.rs | 2 - .../not-whitelisted.stderr | 4 +- .../ui/rust-2018/future-proofing-locals.rs | 3 +- .../rust-2018/local-path-suggestions-2018.rs | 2 - .../local-path-suggestions-2018.stderr | 4 +- .../block-scoped-shadow-nested.rs | 2 - .../block-scoped-shadow-nested.stderr | 6 +-- .../rust-2018/uniform-paths/fn-local-enum.rs | 2 - .../ui/rust-2018/uniform-paths/issue-54390.rs | 11 ---- .../uniform-paths/issue-54390.stderr | 32 ------------ .../ui/rust-2018/uniform-paths/macro-rules.rs | 3 +- .../rust-2018/uniform-paths/prelude-fail-2.rs | 2 - .../uniform-paths/prelude-fail-2.stderr | 14 +++--- .../rust-2018/uniform-paths/prelude-fail.rs | 2 - .../uniform-paths/prelude-fail.stderr | 4 +- .../ui/rust-2018/uniform-paths/prelude.rs | 2 - 31 files changed, 52 insertions(+), 243 deletions(-) delete mode 100644 src/test/ui/feature-gates/feature-gate-uniform-paths.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-uniform-paths.stderr delete mode 100644 src/test/ui/rust-2018/uniform-paths/issue-54390.rs delete mode 100644 src/test/ui/rust-2018/uniform-paths/issue-54390.stderr diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index e0a275cb5a1e..081891cc5ecd 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -956,32 +956,23 @@ impl<'a, 'cl> Resolver<'a, 'cl> { // but its `Def` should coincide with a crate passed with `--extern` // (otherwise there would be ambiguity) and we can skip feature error in this case. 'ok: { - if !is_import || (!rust_2015 && self.session.features_untracked().uniform_paths) { + if !is_import || !rust_2015 { break 'ok; } if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() { break 'ok; } - if rust_2015 { - let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span); - let root_module = self.resolve_crate_root(root_ident); - if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module), - orig_ident, ns, None, false, path_span) - .is_ok() { - break 'ok; - } + let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span); + let root_module = self.resolve_crate_root(root_ident); + if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module), + orig_ident, ns, None, false, path_span) + .is_ok() { + break 'ok; } - let reason = if rust_2015 { - "in macros originating from 2015 edition" - } else { - "on stable channel" - }; - let msg = format!("imports can only refer to extern crate names \ - passed with `--extern` {}", reason); - let mut err = feature_err(&self.session.parse_sess, "uniform_paths", - ident.span, GateIssue::Language, &msg); - + let msg = "imports can only refer to extern crate names passed with \ + `--extern` in macros originating from 2015 edition"; + let mut err = self.session.struct_span_err(ident.span, msg); let what = self.binding_description(binding, ident, flags.contains(Flags::MISC_FROM_PRELUDE)); let note_msg = format!("this import refers to {what}", what = what); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index fac7ff2bf342..8fd36a125cdd 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -459,10 +459,7 @@ declare_features! ( // Support for arbitrary delimited token streams in non-macro attributes (active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None), - // Allows `use x::y;` to resolve through `self::x`, not just `::x` - (active, uniform_paths, "1.30.0", Some(53130), None), - - // Allows unsized rvalues at arguments and parameters + // Allows unsized rvalues at arguments and parameters. (active, unsized_locals, "1.30.0", Some(48055), None), // #![test_runner] @@ -689,6 +686,8 @@ declare_features! ( (accepted, self_struct_ctor, "1.32.0", Some(51994), None), // `Self` in type definitions (RFC 2300) (accepted, self_in_typedefs, "1.32.0", Some(49303), None), + // Allows `use x::y;` to search `x` in the current scope. + (accepted, uniform_paths, "1.32.0", Some(53130), None), ); // If you change this, please modify `src/doc/unstable-book` as well. You must diff --git a/src/test/run-pass/uniform-paths/auxiliary/issue-53691.rs b/src/test/run-pass/uniform-paths/auxiliary/issue-53691.rs index 5845afd72fbe..86d0244cbc26 100644 --- a/src/test/run-pass/uniform-paths/auxiliary/issue-53691.rs +++ b/src/test/run-pass/uniform-paths/auxiliary/issue-53691.rs @@ -10,8 +10,6 @@ // edition:2018 -#![feature(uniform_paths)] - mod m { pub fn f() {} } mod n { pub fn g() {} } diff --git a/src/test/run-pass/uniform-paths/basic-nested.rs b/src/test/run-pass/uniform-paths/basic-nested.rs index a0256187dbba..bccd3eace8ca 100644 --- a/src/test/run-pass/uniform-paths/basic-nested.rs +++ b/src/test/run-pass/uniform-paths/basic-nested.rs @@ -1,22 +1,12 @@ -// 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. +// This test is similar to `basic.rs`, but nested in modules. // run-pass -#![allow(unused_imports)] -#![allow(non_camel_case_types)] - // edition:2018 -#![feature(decl_macro, uniform_paths)] +#![feature(decl_macro)] -// This test is similar to `basic.rs`, but nested in modules. +#![allow(unused_imports)] +#![allow(non_camel_case_types)] mod foo { // Test that ambiguity errors are not emitted between `self::test` and diff --git a/src/test/run-pass/uniform-paths/basic.rs b/src/test/run-pass/uniform-paths/basic.rs index b957b24d6251..be74359752f1 100644 --- a/src/test/run-pass/uniform-paths/basic.rs +++ b/src/test/run-pass/uniform-paths/basic.rs @@ -9,12 +9,10 @@ // except according to those terms. // run-pass -#![allow(unused_imports)] -#![allow(non_camel_case_types)] - // edition:2018 -#![feature(uniform_paths)] +#![allow(unused_imports)] +#![allow(non_camel_case_types)] // Test that ambiguity errors are not emitted between `self::test` and // `::test`, assuming the latter (crate) is not in `extern_prelude`. diff --git a/src/test/run-pass/uniform-paths/macros-nested.rs b/src/test/run-pass/uniform-paths/macros-nested.rs index 373734345fc3..275105c5b3eb 100644 --- a/src/test/run-pass/uniform-paths/macros-nested.rs +++ b/src/test/run-pass/uniform-paths/macros-nested.rs @@ -1,21 +1,9 @@ -// 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. +// This test is similar to `macros.rs`, but nested in modules. // run-pass -#![allow(non_camel_case_types)] - // edition:2018 -#![feature(uniform_paths)] - -// This test is similar to `macros.rs`, but nested in modules. +#![allow(non_camel_case_types)] mod foo { // Test that ambiguity errors are not emitted between `self::test` and diff --git a/src/test/run-pass/uniform-paths/macros.rs b/src/test/run-pass/uniform-paths/macros.rs index 20984eb13dd4..31b809f0cfdc 100644 --- a/src/test/run-pass/uniform-paths/macros.rs +++ b/src/test/run-pass/uniform-paths/macros.rs @@ -1,21 +1,9 @@ -// 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. +// This test is similar to `basic.rs`, but with macros defining local items. // run-pass -#![allow(non_camel_case_types)] - // edition:2018 -#![feature(uniform_paths)] - -// This test is similar to `basic.rs`, but with macros defining local items. +#![allow(non_camel_case_types)] // Test that ambiguity errors are not emitted between `self::test` and // `::test`, assuming the latter (crate) is not in `extern_prelude`. diff --git a/src/test/run-pass/uniform-paths/same-crate.rs b/src/test/run-pass/uniform-paths/same-crate.rs index bb15d6d53ac7..307a80ac99a8 100644 --- a/src/test/run-pass/uniform-paths/same-crate.rs +++ b/src/test/run-pass/uniform-paths/same-crate.rs @@ -9,11 +9,8 @@ // except according to those terms. // run-pass - // edition:2018 -#![feature(uniform_paths)] - pub const A: usize = 0; pub mod foo { diff --git a/src/test/ui/editions/edition-imports-2015.rs b/src/test/ui/editions/edition-imports-2015.rs index b89ca28e279d..5ba45b19dded 100644 --- a/src/test/ui/editions/edition-imports-2015.rs +++ b/src/test/ui/editions/edition-imports-2015.rs @@ -3,8 +3,6 @@ // aux-build:edition-imports-2018.rs // aux-build:absolute.rs -#![feature(uniform_paths)] - #[macro_use] extern crate edition_imports_2018; diff --git a/src/test/ui/editions/edition-imports-2015.stderr b/src/test/ui/editions/edition-imports-2015.stderr index fb6b2e64ef5b..816ab21d8142 100644 --- a/src/test/ui/editions/edition-imports-2015.stderr +++ b/src/test/ui/editions/edition-imports-2015.stderr @@ -1,5 +1,5 @@ error: cannot glob-import all possible crates - --> $DIR/edition-imports-2015.rs:25:5 + --> $DIR/edition-imports-2015.rs:23:5 | LL | gen_glob!(); //~ ERROR cannot glob-import all possible crates | ^^^^^^^^^^^^ diff --git a/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr b/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr index 3cf967dbf70e..7c78fbb26a1b 100644 --- a/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr +++ b/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr @@ -1,4 +1,4 @@ -error[E0658]: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition (see issue #53130) +error: imports can only refer to extern crate names passed with `--extern` in macros originating from 2015 edition --> <::edition_imports_2015::gen_gated macros>:1:50 | LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } } @@ -9,7 +9,6 @@ LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } } LL | gen_gated!(); | ------------- not an extern crate passed with `--extern` | - = help: add #![feature(uniform_paths)] to the crate attributes to enable note: this import refers to the enum defined here --> $DIR/edition-imports-virtual-2015-gated.rs:9:5 | @@ -19,4 +18,3 @@ LL | gen_gated!(); error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-uniform-paths.rs b/src/test/ui/feature-gates/feature-gate-uniform-paths.rs deleted file mode 100644 index ca1cc1d2fd0e..000000000000 --- a/src/test/ui/feature-gates/feature-gate-uniform-paths.rs +++ /dev/null @@ -1,29 +0,0 @@ -// 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. - -// edition:2018 - -pub mod foo { - pub use bar::Bar; //~ ERROR imports can only refer to extern crate names - - pub mod bar { - pub struct Bar; - } -} - -use inline; //~ ERROR imports can only refer to extern crate names - -use Vec; //~ ERROR imports can only refer to extern crate names - -use vec; //~ ERROR imports can only refer to extern crate names - -fn main() { - let _ = foo::Bar; -} diff --git a/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr b/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr deleted file mode 100644 index 0631f2c355f7..000000000000 --- a/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) - --> $DIR/feature-gate-uniform-paths.rs:14:13 - | -LL | pub use bar::Bar; //~ ERROR imports can only refer to extern crate names - | ^^^ -LL | -LL | / pub mod bar { -LL | | pub struct Bar; -LL | | } - | |_____- not an extern crate passed with `--extern` - | - = help: add #![feature(uniform_paths)] to the crate attributes to enable -note: this import refers to the module defined here - --> $DIR/feature-gate-uniform-paths.rs:16:5 - | -LL | / pub mod bar { -LL | | pub struct Bar; -LL | | } - | |_____^ - -error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) - --> $DIR/feature-gate-uniform-paths.rs:21:5 - | -LL | use inline; //~ ERROR imports can only refer to extern crate names - | ^^^^^^ not an extern crate passed with `--extern` - | - = help: add #![feature(uniform_paths)] to the crate attributes to enable - = note: this import refers to a built-in attribute - -error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) - --> $DIR/feature-gate-uniform-paths.rs:23:5 - | -LL | use Vec; //~ ERROR imports can only refer to extern crate names - | ^^^ not an extern crate passed with `--extern` - | - = help: add #![feature(uniform_paths)] to the crate attributes to enable - = note: this import refers to a struct from prelude - -error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) - --> $DIR/feature-gate-uniform-paths.rs:25:5 - | -LL | use vec; //~ ERROR imports can only refer to extern crate names - | ^^^ not an extern crate passed with `--extern` - | - = help: add #![feature(uniform_paths)] to the crate attributes to enable - = note: this import refers to a macro from prelude - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/imports/issue-56125.rs b/src/test/ui/imports/issue-56125.rs index 843b52f18435..b4963e480a60 100644 --- a/src/test/ui/imports/issue-56125.rs +++ b/src/test/ui/imports/issue-56125.rs @@ -2,8 +2,6 @@ // compile-flags:--extern issue_56125 // aux-build:issue-56125.rs -#![feature(uniform_paths)] - mod m1 { use issue_56125::last_segment::*; //~^ ERROR `issue_56125` is ambiguous diff --git a/src/test/ui/imports/issue-56125.stderr b/src/test/ui/imports/issue-56125.stderr index 72d6041765e9..2011184cbc33 100644 --- a/src/test/ui/imports/issue-56125.stderr +++ b/src/test/ui/imports/issue-56125.stderr @@ -11,13 +11,13 @@ LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^^ could not find `last_segment` in `issue_56125` error[E0432]: unresolved import `empty::issue_56125` - --> $DIR/issue-56125.rs:21:9 + --> $DIR/issue-56125.rs:17:9 | LL | use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` | ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty` error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) - --> $DIR/issue-56125.rs:8:9 + --> $DIR/issue-56125.rs:6:9 | LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^ ambiguous name @@ -25,14 +25,14 @@ LL | use issue_56125::last_segment::*; = note: `issue_56125` could refer to an extern crate passed with `--extern` = help: use `::issue_56125` to refer to this extern crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:8:9 + --> $DIR/issue-56125.rs:6:9 | LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) - --> $DIR/issue-56125.rs:14:9 + --> $DIR/issue-56125.rs:11:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^ ambiguous name @@ -40,14 +40,14 @@ LL | use issue_56125::non_last_segment::non_last_segment::*; = note: `issue_56125` could refer to an extern crate passed with `--extern` = help: use `::issue_56125` to refer to this extern crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:14:9 + --> $DIR/issue-56125.rs:11:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) - --> $DIR/issue-56125.rs:22:9 + --> $DIR/issue-56125.rs:18:9 | LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous | ^^^^^^^^^^^ ambiguous name @@ -55,7 +55,7 @@ LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous = note: `issue_56125` could refer to an extern crate passed with `--extern` = help: use `::issue_56125` to refer to this extern crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:22:9 + --> $DIR/issue-56125.rs:17:9 | LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs b/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs index bfe7e4da8456..92541afc0c1c 100644 --- a/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs +++ b/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs @@ -10,8 +10,6 @@ // edition:2018 -#![feature(uniform_paths)] - // Tests that arbitrary crates (other than `core`, `std` and `meta`) // aren't allowed without `--extern`, even if they're in the sysroot. use alloc; //~ ERROR unresolved import `alloc` diff --git a/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr b/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr index 06c11b894ddc..3bea7816b306 100644 --- a/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr +++ b/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr @@ -1,11 +1,11 @@ error: cannot import a built-in macro - --> $DIR/not-whitelisted.rs:18:5 + --> $DIR/not-whitelisted.rs:6:5 | LL | use test; //~ ERROR cannot import a built-in macro | ^^^^ error[E0432]: unresolved import `alloc` - --> $DIR/not-whitelisted.rs:17:5 + --> $DIR/not-whitelisted.rs:5:5 | LL | use alloc; //~ ERROR unresolved import `alloc` | ^^^^^ no `alloc` external crate diff --git a/src/test/ui/rust-2018/future-proofing-locals.rs b/src/test/ui/rust-2018/future-proofing-locals.rs index d2e6dbbb9541..85a122ba11b6 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.rs +++ b/src/test/ui/rust-2018/future-proofing-locals.rs @@ -1,6 +1,7 @@ // edition:2018 -#![feature(uniform_paths, underscore_imports)] +#![feature(underscore_imports)] +#![allow(non_camel_case_types)] mod T { pub struct U; diff --git a/src/test/ui/rust-2018/local-path-suggestions-2018.rs b/src/test/ui/rust-2018/local-path-suggestions-2018.rs index 0d4aefff9316..53c92e1c2059 100644 --- a/src/test/ui/rust-2018/local-path-suggestions-2018.rs +++ b/src/test/ui/rust-2018/local-path-suggestions-2018.rs @@ -12,8 +12,6 @@ // compile-flags:--extern baz // edition:2018 -#![feature(uniform_paths)] - mod foo { pub type Bar = u32; } diff --git a/src/test/ui/rust-2018/local-path-suggestions-2018.stderr b/src/test/ui/rust-2018/local-path-suggestions-2018.stderr index a445a4c612bb..71c8289264ff 100644 --- a/src/test/ui/rust-2018/local-path-suggestions-2018.stderr +++ b/src/test/ui/rust-2018/local-path-suggestions-2018.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `foo` - --> $DIR/local-path-suggestions-2018.rs:22:9 + --> $DIR/local-path-suggestions-2018.rs:10:9 | LL | use foo::Bar; //~ ERROR unresolved import `foo` | ^^^ did you mean `crate::foo`? @@ -7,7 +7,7 @@ LL | use foo::Bar; //~ ERROR unresolved import `foo` = note: `use` statements changed in Rust 2018; read more at error[E0432]: unresolved import `foobar` - --> $DIR/local-path-suggestions-2018.rs:31:5 + --> $DIR/local-path-suggestions-2018.rs:19:5 | LL | use foobar::Baz; //~ ERROR unresolved import `foobar` | ^^^^^^ did you mean `baz::foobar`? diff --git a/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs b/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs index 19be7dc96404..3f5897901a05 100644 --- a/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs +++ b/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs @@ -1,7 +1,5 @@ // edition:2018 -#![feature(uniform_paths)] - mod my { pub mod sub { pub fn bar() {} diff --git a/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr b/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr index 0088296b1a47..4a01ba5088f6 100644 --- a/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr +++ b/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr @@ -1,16 +1,16 @@ error[E0659]: `sub` is ambiguous (name vs any other name during import resolution) - --> $DIR/block-scoped-shadow-nested.rs:18:13 + --> $DIR/block-scoped-shadow-nested.rs:16:13 | LL | use sub::bar; //~ ERROR `sub` is ambiguous | ^^^ ambiguous name | note: `sub` could refer to the module imported here - --> $DIR/block-scoped-shadow-nested.rs:16:9 + --> $DIR/block-scoped-shadow-nested.rs:14:9 | LL | use my::sub; | ^^^^^^^ note: `sub` could also refer to the module defined here - --> $DIR/block-scoped-shadow-nested.rs:11:1 + --> $DIR/block-scoped-shadow-nested.rs:9:1 | LL | / mod sub { LL | | pub fn bar() {} diff --git a/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs b/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs index a7bc625bbf0a..0c2da1884b75 100644 --- a/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs +++ b/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs @@ -1,8 +1,6 @@ // compile-pass // edition:2018 -#![feature(uniform_paths)] - fn main() { enum E { A, B, C } diff --git a/src/test/ui/rust-2018/uniform-paths/issue-54390.rs b/src/test/ui/rust-2018/uniform-paths/issue-54390.rs deleted file mode 100644 index 536cc25e35ac..000000000000 --- a/src/test/ui/rust-2018/uniform-paths/issue-54390.rs +++ /dev/null @@ -1,11 +0,0 @@ -// edition:2018 - -#![deny(unused)] - -use std::fmt; - -// No "unresolved import" + "unused import" combination here. -use fmt::Write; //~ ERROR imports can only refer to extern crate names - //~| ERROR unused import: `fmt::Write` - -fn main() {} diff --git a/src/test/ui/rust-2018/uniform-paths/issue-54390.stderr b/src/test/ui/rust-2018/uniform-paths/issue-54390.stderr deleted file mode 100644 index 8f86698c9c11..000000000000 --- a/src/test/ui/rust-2018/uniform-paths/issue-54390.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) - --> $DIR/issue-54390.rs:8:5 - | -LL | use std::fmt; - | -------- not an extern crate passed with `--extern` -... -LL | use fmt::Write; //~ ERROR imports can only refer to extern crate names - | ^^^ - | - = help: add #![feature(uniform_paths)] to the crate attributes to enable -note: this import refers to the module imported here - --> $DIR/issue-54390.rs:5:5 - | -LL | use std::fmt; - | ^^^^^^^^ - -error: unused import: `fmt::Write` - --> $DIR/issue-54390.rs:8:5 - | -LL | use fmt::Write; //~ ERROR imports can only refer to extern crate names - | ^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/issue-54390.rs:3:9 - | -LL | #![deny(unused)] - | ^^^^^^ - = note: #[deny(unused_imports)] implied by #[deny(unused)] - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rust-2018/uniform-paths/macro-rules.rs b/src/test/ui/rust-2018/uniform-paths/macro-rules.rs index bd098616aa93..dcf1f2b4b7ea 100644 --- a/src/test/ui/rust-2018/uniform-paths/macro-rules.rs +++ b/src/test/ui/rust-2018/uniform-paths/macro-rules.rs @@ -1,6 +1,6 @@ // edition:2018 -#![feature(underscore_imports, decl_macro, uniform_paths)] +#![feature(underscore_imports, decl_macro)] mod m1 { // Non-exported legacy macros are treated as `pub(crate)`. @@ -14,6 +14,7 @@ mod m1 { mod m2 { macro_rules! legacy_macro { () => () } + #[allow(non_camel_case_types)] type legacy_macro = u8; // Legacy macro imports don't prevent names from other namespaces from being imported. diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs index e153e868b311..541fc1be4e82 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.rs @@ -1,7 +1,5 @@ // edition:2018 -#![feature(uniform_paths)] - // Built-in attribute use inline as imported_inline; mod builtin { diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr index 4c49cd89bdcb..40b8fcf7158e 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail-2.stderr @@ -1,41 +1,41 @@ error: cannot use a built-in attribute through an import - --> $DIR/prelude-fail-2.rs:17:3 + --> $DIR/prelude-fail-2.rs:15:3 | LL | #[imported_inline] //~ ERROR cannot use a built-in attribute through an import | ^^^^^^^^^^^^^^^ | note: the built-in attribute imported here - --> $DIR/prelude-fail-2.rs:6:5 + --> $DIR/prelude-fail-2.rs:4:5 | LL | use inline as imported_inline; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: cannot use a built-in attribute through an import - --> $DIR/prelude-fail-2.rs:18:3 + --> $DIR/prelude-fail-2.rs:16:3 | LL | #[builtin::imported_inline] //~ ERROR cannot use a built-in attribute through an import | ^^^^^^^^^^^^^^^^^^^^^^^^ error: cannot use a tool module through an import - --> $DIR/prelude-fail-2.rs:19:3 + --> $DIR/prelude-fail-2.rs:17:3 | LL | #[imported_rustfmt::skip] //~ ERROR cannot use a tool module through an import | ^^^^^^^^^^^^^^^^ | note: the tool module imported here - --> $DIR/prelude-fail-2.rs:12:5 + --> $DIR/prelude-fail-2.rs:10:5 | LL | use rustfmt as imported_rustfmt; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: cannot use a tool module through an import - --> $DIR/prelude-fail-2.rs:20:13 + --> $DIR/prelude-fail-2.rs:18:13 | LL | #[tool_mod::imported_rustfmt::skip] //~ ERROR cannot use a tool module through an import | ^^^^^^^^^^^^^^^^ | note: the tool module imported here - --> $DIR/prelude-fail-2.rs:14:13 + --> $DIR/prelude-fail-2.rs:12:13 | LL | pub use rustfmt as imported_rustfmt; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs b/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs index c5bd50f2f567..d717884c901b 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs @@ -1,7 +1,5 @@ // edition:2018 -#![feature(uniform_paths)] - // Built-in macro use env as env_imported; //~ ERROR cannot import a built-in macro diff --git a/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr b/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr index 794d986b82ef..fdfea416b12f 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr +++ b/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr @@ -1,11 +1,11 @@ error: cannot import a built-in macro - --> $DIR/prelude-fail.rs:6:5 + --> $DIR/prelude-fail.rs:4:5 | LL | use env as env_imported; //~ ERROR cannot import a built-in macro | ^^^^^^^^^^^^^^^^^^^ error[E0432]: unresolved import `rustfmt` - --> $DIR/prelude-fail.rs:9:5 + --> $DIR/prelude-fail.rs:7:5 | LL | use rustfmt::skip as imported_rustfmt_skip; //~ ERROR unresolved import `rustfmt` | ^^^^^^^ not a module `rustfmt` diff --git a/src/test/ui/rust-2018/uniform-paths/prelude.rs b/src/test/ui/rust-2018/uniform-paths/prelude.rs index 1a6027f30d78..9a326b4c728b 100644 --- a/src/test/ui/rust-2018/uniform-paths/prelude.rs +++ b/src/test/ui/rust-2018/uniform-paths/prelude.rs @@ -1,8 +1,6 @@ // compile-pass // edition:2018 -#![feature(uniform_paths)] - // Macro imported with `#[macro_use] extern crate` use vec as imported_vec; From 079f44f9cf73e195bda9a9e0eea238a3fdd97964 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 30 Dec 2018 20:07:43 +0300 Subject: [PATCH 08/15] Fix a hole in generic parameter import future-proofing Add some tests for buggy derive helpers --- src/librustc_resolve/lib.rs | 26 +++++++++++++++---- src/librustc_resolve/resolve_imports.rs | 5 ++++ src/test/ui/imports/issue-56125.stderr | 2 +- .../ui/proc-macro/derive-helper-shadowing.rs | 24 +++++++++++++++-- .../proc-macro/derive-helper-shadowing.stderr | 13 ++++++++-- .../ui/rust-2018/future-proofing-locals.rs | 2 +- .../rust-2018/future-proofing-locals.stderr | 8 +++++- 7 files changed, 68 insertions(+), 12 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 50704a6838ac..5f571dc71eb7 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -75,7 +75,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; use std::cell::{Cell, RefCell}; -use std::{cmp, fmt, iter, ptr}; +use std::{cmp, fmt, iter, mem, ptr}; use std::collections::BTreeSet; use std::mem::replace; use rustc_data_structures::ptr_key::PtrKey; @@ -2394,11 +2394,27 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { ast::UseTreeKind::Simple(..) if segments.len() == 1 => &[TypeNS, ValueNS][..], _ => &[TypeNS], }; + let report_error = |this: &Self, ns| { + let what = if ns == TypeNS { "type parameters" } else { "local variables" }; + this.session.span_err(ident.span, &format!("imports cannot refer to {}", what)); + }; + for &ns in nss { - if let Some(LexicalScopeBinding::Def(..)) = - self.resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span) { - let what = if ns == TypeNS { "type parameters" } else { "local variables" }; - self.session.span_err(ident.span, &format!("imports cannot refer to {}", what)); + match self.resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span) { + Some(LexicalScopeBinding::Def(..)) => { + report_error(self, ns); + } + Some(LexicalScopeBinding::Item(binding)) => { + let orig_blacklisted_binding = + mem::replace(&mut self.blacklisted_binding, Some(binding)); + if let Some(LexicalScopeBinding::Def(..)) = + self.resolve_ident_in_lexical_scope(ident, ns, None, + use_tree.prefix.span) { + report_error(self, ns); + } + self.blacklisted_binding = orig_blacklisted_binding; + } + None => {} } } } else if let ast::UseTreeKind::Nested(use_trees) = &use_tree.kind { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 5a0ccb6a250f..3fa07cbf2397 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -228,6 +228,11 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> { } let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| { + if let Some(blacklisted_binding) = this.blacklisted_binding { + if ptr::eq(binding, blacklisted_binding) { + return Err((Determined, Weak::No)); + } + } // `extern crate` are always usable for backwards compatibility, see issue #37020, // remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`. let usable = this.is_accessible(binding.vis) || binding.is_extern_crate(); diff --git a/src/test/ui/imports/issue-56125.stderr b/src/test/ui/imports/issue-56125.stderr index 2011184cbc33..0a93b2f081e4 100644 --- a/src/test/ui/imports/issue-56125.stderr +++ b/src/test/ui/imports/issue-56125.stderr @@ -55,7 +55,7 @@ LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous = note: `issue_56125` could refer to an extern crate passed with `--extern` = help: use `::issue_56125` to refer to this extern crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:17:9 + --> $DIR/issue-56125.rs:18:9 | LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.rs b/src/test/ui/proc-macro/derive-helper-shadowing.rs index aa9eae0ba317..f6fe9f9fd8b3 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.rs +++ b/src/test/ui/proc-macro/derive-helper-shadowing.rs @@ -5,6 +5,26 @@ use derive_helper_shadowing::*; #[my_attr] //~ ERROR `my_attr` is ambiguous #[derive(MyTrait)] -struct S; +struct S { + // FIXME No ambiguity, attributes in non-macro positions are not resolved properly + #[my_attr] + field: [u8; { + // FIXME No ambiguity, derive helpers are not put into scope for non-attributes + use my_attr; -fn main() {} + // FIXME No ambiguity, derive helpers are not put into scope for inner items + #[my_attr] + struct U; + + mod inner { + #[my_attr] //~ ERROR attribute `my_attr` is currently unknown + struct V; + } + + 0 + }] +} + +fn main() { + let s = S { field: [] }; +} diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr index cc50fefc4645..8180c84d3f6e 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.stderr +++ b/src/test/ui/proc-macro/derive-helper-shadowing.stderr @@ -1,3 +1,11 @@ +error[E0658]: The attribute `my_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/derive-helper-shadowing.rs:20:15 + | +LL | #[my_attr] //~ ERROR attribute `my_attr` is currently unknown + | ^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + error[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name) --> $DIR/derive-helper-shadowing.rs:6:3 | @@ -16,6 +24,7 @@ LL | use derive_helper_shadowing::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::my_attr` to refer to this attribute macro unambiguously -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0659`. +Some errors occurred: E0658, E0659. +For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/rust-2018/future-proofing-locals.rs b/src/test/ui/rust-2018/future-proofing-locals.rs index 85a122ba11b6..ee8136346fcc 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.rs +++ b/src/test/ui/rust-2018/future-proofing-locals.rs @@ -17,7 +17,7 @@ fn type_param() { } fn self_import() { - use T; // FIXME Should be an error, but future-proofing fails due to `T` being "self-shadowed" + use T; //~ ERROR imports cannot refer to type parameters } fn let_binding() { diff --git a/src/test/ui/rust-2018/future-proofing-locals.stderr b/src/test/ui/rust-2018/future-proofing-locals.stderr index 68354b332a9c..413e199cd646 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.stderr +++ b/src/test/ui/rust-2018/future-proofing-locals.stderr @@ -16,6 +16,12 @@ error: imports cannot refer to type parameters LL | use T::*; //~ ERROR imports cannot refer to type parameters | ^ +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:19:9 + | +LL | use T; //~ ERROR imports cannot refer to type parameters + | ^ + error: imports cannot refer to local variables --> $DIR/future-proofing-locals.rs:25:9 | @@ -46,5 +52,5 @@ error: imports cannot refer to local variables LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters | ^ -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors From bc232d3c6430f93ff2d5991ca9f2eecadce6df01 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 10 Jan 2019 02:08:57 +0300 Subject: [PATCH 09/15] Fix rebase --- src/librustc_resolve/macros.rs | 2 +- src/test/ui/imports/issue-56125.stderr | 14 +++++++------- .../ui/proc-macro/derive-helper-shadowing.rs | 5 ----- .../proc-macro/derive-helper-shadowing.stderr | 13 ++----------- .../not-whitelisted.stderr | 4 ++-- .../ui/rust-2018/future-proofing-locals.stderr | 18 +++++++++--------- .../local-path-suggestions-2018.stderr | 4 ++-- .../ui/rust-2018/uniform-paths/issue-56596.rs | 2 -- .../rust-2018/uniform-paths/issue-56596.stderr | 4 ++-- .../rust-2018/uniform-paths/macro-rules.stderr | 6 +++--- 10 files changed, 28 insertions(+), 44 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 081891cc5ecd..31c2db5d866a 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -962,7 +962,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() { break 'ok; } - let root_ident = Ident::new(keywords::PathRoot.name(), orig_ident.span); + let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span); let root_module = self.resolve_crate_root(root_ident); if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module), orig_ident, ns, None, false, path_span) diff --git a/src/test/ui/imports/issue-56125.stderr b/src/test/ui/imports/issue-56125.stderr index 0a93b2f081e4..a6e45a5655b6 100644 --- a/src/test/ui/imports/issue-56125.stderr +++ b/src/test/ui/imports/issue-56125.stderr @@ -1,17 +1,17 @@ error[E0433]: failed to resolve: could not find `non_last_segment` in `issue_56125` - --> $DIR/issue-56125.rs:14:22 + --> $DIR/issue-56125.rs:12:22 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^^^^^^ could not find `non_last_segment` in `issue_56125` error[E0432]: unresolved import `issue_56125::last_segment` - --> $DIR/issue-56125.rs:8:22 + --> $DIR/issue-56125.rs:6:22 | LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^^ could not find `last_segment` in `issue_56125` error[E0432]: unresolved import `empty::issue_56125` - --> $DIR/issue-56125.rs:17:9 + --> $DIR/issue-56125.rs:19:9 | LL | use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` | ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty` @@ -32,7 +32,7 @@ LL | use issue_56125::last_segment::*; = help: use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) - --> $DIR/issue-56125.rs:11:9 + --> $DIR/issue-56125.rs:12:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^ ambiguous name @@ -40,14 +40,14 @@ LL | use issue_56125::non_last_segment::non_last_segment::*; = note: `issue_56125` could refer to an extern crate passed with `--extern` = help: use `::issue_56125` to refer to this extern crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:11:9 + --> $DIR/issue-56125.rs:12:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) - --> $DIR/issue-56125.rs:18:9 + --> $DIR/issue-56125.rs:20:9 | LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous | ^^^^^^^^^^^ ambiguous name @@ -55,7 +55,7 @@ LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous = note: `issue_56125` could refer to an extern crate passed with `--extern` = help: use `::issue_56125` to refer to this extern crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:18:9 + --> $DIR/issue-56125.rs:20:9 | LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.rs b/src/test/ui/proc-macro/derive-helper-shadowing.rs index f6fe9f9fd8b3..d4a0721147ab 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.rs +++ b/src/test/ui/proc-macro/derive-helper-shadowing.rs @@ -16,11 +16,6 @@ struct S { #[my_attr] struct U; - mod inner { - #[my_attr] //~ ERROR attribute `my_attr` is currently unknown - struct V; - } - 0 }] } diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr index 8180c84d3f6e..cc50fefc4645 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.stderr +++ b/src/test/ui/proc-macro/derive-helper-shadowing.stderr @@ -1,11 +1,3 @@ -error[E0658]: The attribute `my_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/derive-helper-shadowing.rs:20:15 - | -LL | #[my_attr] //~ ERROR attribute `my_attr` is currently unknown - | ^^^^^^^ - | - = help: add #![feature(custom_attribute)] to the crate attributes to enable - error[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name) --> $DIR/derive-helper-shadowing.rs:6:3 | @@ -24,7 +16,6 @@ LL | use derive_helper_shadowing::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::my_attr` to refer to this attribute macro unambiguously -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0658, E0659. -For more information about an error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr b/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr index 3bea7816b306..e70a359b5752 100644 --- a/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr +++ b/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr @@ -1,11 +1,11 @@ error: cannot import a built-in macro - --> $DIR/not-whitelisted.rs:6:5 + --> $DIR/not-whitelisted.rs:16:5 | LL | use test; //~ ERROR cannot import a built-in macro | ^^^^ error[E0432]: unresolved import `alloc` - --> $DIR/not-whitelisted.rs:5:5 + --> $DIR/not-whitelisted.rs:15:5 | LL | use alloc; //~ ERROR unresolved import `alloc` | ^^^^^ no `alloc` external crate diff --git a/src/test/ui/rust-2018/future-proofing-locals.stderr b/src/test/ui/rust-2018/future-proofing-locals.stderr index 413e199cd646..6b4baab0df4b 100644 --- a/src/test/ui/rust-2018/future-proofing-locals.stderr +++ b/src/test/ui/rust-2018/future-proofing-locals.stderr @@ -1,53 +1,53 @@ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:13:9 + --> $DIR/future-proofing-locals.rs:14:9 | LL | use T as _; //~ ERROR imports cannot refer to type parameters | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:14:9 + --> $DIR/future-proofing-locals.rs:15:9 | LL | use T::U; //~ ERROR imports cannot refer to type parameters | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:15:9 + --> $DIR/future-proofing-locals.rs:16:9 | LL | use T::*; //~ ERROR imports cannot refer to type parameters | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:19:9 + --> $DIR/future-proofing-locals.rs:20:9 | LL | use T; //~ ERROR imports cannot refer to type parameters | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:25:9 + --> $DIR/future-proofing-locals.rs:26:9 | LL | use x as _; //~ ERROR imports cannot refer to local variables | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:31:9 + --> $DIR/future-proofing-locals.rs:32:9 | LL | use x; //~ ERROR imports cannot refer to local variables | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:37:17 + --> $DIR/future-proofing-locals.rs:38:17 | LL | use x; //~ ERROR imports cannot refer to local variables | ^ error: imports cannot refer to type parameters - --> $DIR/future-proofing-locals.rs:45:10 + --> $DIR/future-proofing-locals.rs:46:10 | LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters | ^ error: imports cannot refer to local variables - --> $DIR/future-proofing-locals.rs:45:18 + --> $DIR/future-proofing-locals.rs:46:18 | LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters | ^ diff --git a/src/test/ui/rust-2018/local-path-suggestions-2018.stderr b/src/test/ui/rust-2018/local-path-suggestions-2018.stderr index 71c8289264ff..4fb1a0501504 100644 --- a/src/test/ui/rust-2018/local-path-suggestions-2018.stderr +++ b/src/test/ui/rust-2018/local-path-suggestions-2018.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `foo` - --> $DIR/local-path-suggestions-2018.rs:10:9 + --> $DIR/local-path-suggestions-2018.rs:20:9 | LL | use foo::Bar; //~ ERROR unresolved import `foo` | ^^^ did you mean `crate::foo`? @@ -7,7 +7,7 @@ LL | use foo::Bar; //~ ERROR unresolved import `foo` = note: `use` statements changed in Rust 2018; read more at error[E0432]: unresolved import `foobar` - --> $DIR/local-path-suggestions-2018.rs:19:5 + --> $DIR/local-path-suggestions-2018.rs:29:5 | LL | use foobar::Baz; //~ ERROR unresolved import `foobar` | ^^^^^^ did you mean `baz::foobar`? diff --git a/src/test/ui/rust-2018/uniform-paths/issue-56596.rs b/src/test/ui/rust-2018/uniform-paths/issue-56596.rs index 5c40d78d81c2..ec5bb656ad4e 100644 --- a/src/test/ui/rust-2018/uniform-paths/issue-56596.rs +++ b/src/test/ui/rust-2018/uniform-paths/issue-56596.rs @@ -2,8 +2,6 @@ // compile-flags: --extern issue_56596 // aux-build:issue-56596.rs -#![feature(uniform_paths)] - mod m { pub mod issue_56596 {} } diff --git a/src/test/ui/rust-2018/uniform-paths/issue-56596.stderr b/src/test/ui/rust-2018/uniform-paths/issue-56596.stderr index 293d0ec6a720..01bbe139c7d6 100644 --- a/src/test/ui/rust-2018/uniform-paths/issue-56596.stderr +++ b/src/test/ui/rust-2018/uniform-paths/issue-56596.stderr @@ -1,5 +1,5 @@ error[E0659]: `issue_56596` is ambiguous (name vs any other name during import resolution) - --> $DIR/issue-56596.rs:12:5 + --> $DIR/issue-56596.rs:10:5 | LL | use issue_56596; //~ ERROR `issue_56596` is ambiguous | ^^^^^^^^^^^ ambiguous name @@ -7,7 +7,7 @@ LL | use issue_56596; //~ ERROR `issue_56596` is ambiguous = note: `issue_56596` could refer to an extern crate passed with `--extern` = help: use `::issue_56596` to refer to this extern crate unambiguously note: `issue_56596` could also refer to the module imported here - --> $DIR/issue-56596.rs:11:5 + --> $DIR/issue-56596.rs:9:5 | LL | use m::*; | ^^^^ diff --git a/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr b/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr index 004bcc45ea4a..684f5fceac15 100644 --- a/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr +++ b/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr @@ -11,18 +11,18 @@ LL | pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and can | ^^^^^^^^^^^^^^^^^ error[E0659]: `legacy_macro` is ambiguous (name vs any other name during import resolution) - --> $DIR/macro-rules.rs:30:13 + --> $DIR/macro-rules.rs:31:13 | LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous | ^^^^^^^^^^^^ ambiguous name | note: `legacy_macro` could refer to the macro defined here - --> $DIR/macro-rules.rs:27:9 + --> $DIR/macro-rules.rs:28:9 | LL | macro_rules! legacy_macro { () => () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `legacy_macro` could also refer to the macro defined here - --> $DIR/macro-rules.rs:24:5 + --> $DIR/macro-rules.rs:25:5 | LL | macro legacy_macro() {} | ^^^^^^^^^^^^^^^^^^^^^^^ From e3f88cb3e36e4c3cacf5f5f545b04eb7e33055d8 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 5 Jan 2019 17:57:47 +0200 Subject: [PATCH 10/15] use the correct supertrait substitution in `object_ty_for_trait` Fixes #57156. --- src/librustc/traits/object_safety.rs | 33 ++++++++++++++++++++-------- src/test/ui/issues/issue-57156.rs | 23 +++++++++++++++++++ 2 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 src/test/ui/issues/issue-57156.rs diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index a9afe755c146..756d8fcc3478 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -262,6 +262,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { method: &ty::AssociatedItem) -> Option { + debug!("object_safety_violation_for_method({:?}, {:?})", trait_def_id, method); // Any method that has a `Self : Sized` requisite is otherwise // exempt from the regulations. if self.generics_require_sized_self(method.def_id) { @@ -280,6 +281,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { method: &ty::AssociatedItem) -> bool { + debug!("is_vtable_safe_method({:?}, {:?})", trait_def_id, method); // Any method that has a `Self : Sized` requisite can't be called. if self.generics_require_sized_self(method.def_id) { return false; @@ -399,6 +401,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { fn receiver_for_self_ty( self, receiver_ty: Ty<'tcx>, self_ty: Ty<'tcx>, method_def_id: DefId ) -> Ty<'tcx> { + debug!("receiver_for_self_ty({:?}, {:?}, {:?})", receiver_ty, self_ty, method_def_id); let substs = Substs::for_item(self, method_def_id, |param, _| { if param.index == 0 { self_ty.into() @@ -407,7 +410,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { } }); - receiver_ty.subst(self, substs) + let result = receiver_ty.subst(self, substs); + debug!("receiver_for_self_ty({:?}, {:?}, {:?}) = {:?}", + receiver_ty, self_ty, method_def_id, result); + result } /// creates the object type for the current trait. For example, @@ -423,18 +429,26 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { ); let mut associated_types = traits::supertraits(self, ty::Binder::dummy(trait_ref)) - .flat_map(|trait_ref| self.associated_items(trait_ref.def_id())) - .filter(|item| item.kind == ty::AssociatedKind::Type) + .flat_map(|super_trait_ref| { + self.associated_items(super_trait_ref.def_id()) + .map(move |item| (super_trait_ref, item)) + }) + .filter(|(_, item)| item.kind == ty::AssociatedKind::Type) .collect::>(); // existential predicates need to be in a specific order - associated_types.sort_by_cached_key(|item| self.def_path_hash(item.def_id)); - - let projection_predicates = associated_types.into_iter().map(|item| { + associated_types.sort_by_cached_key(|(_, item)| self.def_path_hash(item.def_id)); + + let projection_predicates = associated_types.into_iter().map(|(super_trait_ref, item)| { + // We *can* get bound lifetimes here in cases like + // `trait MyTrait: for<'s> OtherTrait<&'s T, Output=bool>`. + // + // binder moved to (*)... + let super_trait_ref = super_trait_ref.skip_binder(); ty::ExistentialPredicate::Projection(ty::ExistentialProjection { - ty: self.mk_projection(item.def_id, trait_ref.substs), + ty: self.mk_projection(item.def_id, super_trait_ref.substs), item_def_id: item.def_id, - substs: trait_ref.substs, + substs: super_trait_ref.substs, }) }); @@ -443,7 +457,8 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { ); let object_ty = self.mk_dynamic( - ty::Binder::dummy(existential_predicates), + // (*) ... binder re-introduced here + ty::Binder::bind(existential_predicates), lifetime, ); diff --git a/src/test/ui/issues/issue-57156.rs b/src/test/ui/issues/issue-57156.rs new file mode 100644 index 000000000000..f20b0f41c7fa --- /dev/null +++ b/src/test/ui/issues/issue-57156.rs @@ -0,0 +1,23 @@ +// compile-pass + +trait Foo { + type Output; +} + +trait Bar<'a, T>: for<'s> Foo<&'s T, Output=bool> { + fn cb(&self) -> Box>; +} + +impl<'s> Foo<&'s ()> for () { + type Output = bool; +} + +impl<'a> Bar<'a, ()> for () { + fn cb(&self) -> Box> { + Box::new(*self) + } +} + +fn main() { + let _t = ().cb(); +} From 1bf2bcad4b2b284d446bfb119558fb4b442c8c92 Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Wed, 9 Jan 2019 16:12:12 +0100 Subject: [PATCH 11/15] Updated RELEASES.md for 1.32.0 --- RELEASES.md | 263 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 7022a86a45c5..887b6e9c39f7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,266 @@ +Version 1.32.0 (2019-01-17) +========================== + +Language +-------- +#### 2018 edition +- [You can now use the `?` operator in macro definitions.][56245] The `?` + operator allows you to specify zero or one repetitions similar to the `*` and + `+` operators. + +#### All editions +- [You can now match against `PhantomData` types.][55837] +- [You can now match against literals in macros with the `literal` + specifier.][56072] This will match against a literal of any type. + E.g. `1`, `'A'`, `"Hello World"` +- [Self can now be used as a constructor and pattern.][56365] E.g. + ```rust + struct Point(i32, i32); + + impl Point { + pub fn new(x: i32, y: i32) -> Self { + Self(x, y) + } + + pub fn is_origin(&self) -> bool { + match self { + Self(0, 0) => true, + _ => false, + } + } + } + ``` +- [Self can also now be used in type definitions.][56366] E.g. + ```rust + enum List + where + Self: PartialOrd // can write `Self` instead of `List` + { + Nil, + Cons(T, Box) // likewise here + } + ``` + +Compiler +-------- +- [You can now mark traits with `#[must_use]`.][55663] Providing a warning if + they unused in a program. +- [The default allocator has changed from jemalloc to the default allocator on + your system.][55238] The compiler itself on Linux & macOS will still use + jemalloc, but programs compiled with them will use the system allocator. +- [Added the `aarch64-pc-windows-msvc` target.][55702] + +Libraries +--------- +- [`PathBuf` now implements `FromStr`.][55148] +- [`Box<[T]>` now implements `FromIterator`.][55843] +- [The `dbg!` macro has been stabilized.][56395] This macro enables you to + easily debug expressions in your rust program. E.g. + ```rust + let a = 2; + let b = dbg!(a * 2) + 1; + // ^-- prints: [src/main.rs:4] a * 2 = 4 + assert_eq!(b, 5); + ``` + +The following APIs are now `const` functions and can be used in a +`const` context. + +- [`Cell::as_ptr`] +- [`UnsafeCell::get`] +- [`char::is_ascii`] +- [`iter::empty`] +- [`ManuallyDrop::new`] +- [`ManuallyDrop::into_inner`] +- [`RangeInclusive::start`] +- [`RangeInclusive::end`] +- [`NonNull::as_ptr`] +- [`[T]::as_ptr`] +- [`str::as_ptr`] +- [`Duration::as_secs`] +- [`Duration::subsec_millis`] +- [`Duration::subsec_micros`] +- [`Duration::subsec_nanos`] +- [`CStr::as_ptr`] +- [`Ipv4Addr::is_unspecified`] +- [`Ipv6Addr::new`] +- [`Ipv6Addr::octets`] + +Stabilized APIs +--------------- +- [`i8::to_be_bytes`] +- [`i8::to_le_bytes`] +- [`i8::to_ne_bytes`] +- [`i8::from_be_bytes`] +- [`i8::from_le_bytes`] +- [`i8::from_ne_bytes`] +- [`i16::to_be_bytes`] +- [`i16::to_le_bytes`] +- [`i16::to_ne_bytes`] +- [`i16::from_be_bytes`] +- [`i16::from_le_bytes`] +- [`i16::from_ne_bytes`] +- [`i32::to_be_bytes`] +- [`i32::to_le_bytes`] +- [`i32::to_ne_bytes`] +- [`i32::from_be_bytes`] +- [`i32::from_le_bytes`] +- [`i32::from_ne_bytes`] +- [`i64::to_be_bytes`] +- [`i64::to_le_bytes`] +- [`i64::to_ne_bytes`] +- [`i64::from_be_bytes`] +- [`i64::from_le_bytes`] +- [`i64::from_ne_bytes`] +- [`isize::to_be_bytes`] +- [`isize::to_le_bytes`] +- [`isize::to_ne_bytes`] +- [`isize::from_be_bytes`] +- [`isize::from_le_bytes`] +- [`isize::from_ne_bytes`] +- [`u8::to_be_bytes`] +- [`u8::to_le_bytes`] +- [`u8::to_ne_bytes`] +- [`u8::from_be_bytes`] +- [`u8::from_le_bytes`] +- [`u8::from_ne_bytes`] +- [`u16::to_be_bytes`] +- [`u16::to_le_bytes`] +- [`u16::to_ne_bytes`] +- [`u16::from_be_bytes`] +- [`u16::from_le_bytes`] +- [`u16::from_ne_bytes`] +- [`u32::to_be_bytes`] +- [`u32::to_le_bytes`] +- [`u32::to_ne_bytes`] +- [`u32::from_be_bytes`] +- [`u32::from_le_bytes`] +- [`u32::from_ne_bytes`] +- [`u64::to_be_bytes`] +- [`u64::to_le_bytes`] +- [`u64::to_ne_bytes`] +- [`u64::from_be_bytes`] +- [`u64::from_le_bytes`] +- [`u64::from_ne_bytes`] +- [`usize::to_be_bytes`] +- [`usize::to_le_bytes`] +- [`usize::to_ne_bytes`] +- [`usize::from_be_bytes`] +- [`usize::from_le_bytes`] +- [`usize::from_ne_bytes`] + +Cargo +----- +- [You can now run `cargo c` as an alias for `cargo check`.][cargo/6218] +- [Usernames are now allowed in alt registry URLs.][cargo/6242] + +Misc +---- +- [`libproc_macro` has been added to the `rust-src` distribution.][55280] + +Compatibility Notes +------------------- +- [The argument types for AVX's + `_mm256_stream_si256`, `_mm256_stream_pd`, `_mm256_stream_ps`][55610] have + been changed from `*const` to `*mut` as the previous implementation + was unsound. + +[55148]: https://github.com/rust-lang/rust/pull/55148/ +[55238]: https://github.com/rust-lang/rust/pull/55238/ +[55280]: https://github.com/rust-lang/rust/pull/55280/ +[55610]: https://github.com/rust-lang/rust/pull/55610/ +[55663]: https://github.com/rust-lang/rust/pull/55663/ +[55702]: https://github.com/rust-lang/rust/pull/55702/ +[55837]: https://github.com/rust-lang/rust/pull/55837/ +[55843]: https://github.com/rust-lang/rust/pull/55843/ +[56072]: https://github.com/rust-lang/rust/pull/56072/ +[56245]: https://github.com/rust-lang/rust/pull/56245/ +[56365]: https://github.com/rust-lang/rust/pull/56365/ +[56366]: https://github.com/rust-lang/rust/pull/56366/ +[56395]: https://github.com/rust-lang/rust/pull/56395/ +[cargo/6218]: https://github.com/rust-lang/cargo/pull/6218/ +[cargo/6242]: https://github.com/rust-lang/cargo/pull/6242/ +[`CStr::as_ptr`]: https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.as_ptr +[`Cell::as_ptr`]: https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_ptr +[`Duration::as_secs`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.as_secs +[`Duration::subsec_micros`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.subsec_micros +[`Duration::subsec_millis`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.subsec_millis +[`Duration::subsec_nanos`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.subsec_nanos +[`Ipv4Addr::is_unspecified`]: https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html#method.is_unspecified +[`Ipv6Addr::new`]: https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html#method.new +[`Ipv6Addr::octets`]: https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html#method.octets +[`ManuallyDrop::into_inner`]: https://doc.rust-lang.org/std/mem/struct.ManuallyDrop.html#method.into_inner +[`ManuallyDrop::new`]: https://doc.rust-lang.org/std/mem/struct.ManuallyDrop.html#method.new +[`NonNull::as_ptr`]: https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.as_ptr +[`RangeInclusive::end`]: https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html#method.end +[`RangeInclusive::start`]: https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html#method.start +[`UnsafeCell::get`]: https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.get +[`[T]::as_ptr`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_ptr +[`char::is_ascii`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii +[`i16::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_be_bytes +[`i16::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_le_bytes +[`i16::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_ne_bytes +[`i16::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.to_be_bytes +[`i16::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.to_le_bytes +[`i16::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.to_ne_bytes +[`i32::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.from_be_bytes +[`i32::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.from_le_bytes +[`i32::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.from_ne_bytes +[`i32::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.to_be_bytes +[`i32::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.to_le_bytes +[`i32::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i32.html#method.to_ne_bytes +[`i64::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.from_be_bytes +[`i64::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.from_le_bytes +[`i64::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.from_ne_bytes +[`i64::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.to_be_bytes +[`i64::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.to_le_bytes +[`i64::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i64.html#method.to_ne_bytes +[`i8::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.from_be_bytes +[`i8::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.from_le_bytes +[`i8::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.from_ne_bytes +[`i8::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.to_be_bytes +[`i8::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.to_le_bytes +[`i8::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.to_ne_bytes +[`isize::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.from_be_bytes +[`isize::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.from_le_bytes +[`isize::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.from_ne_bytes +[`isize::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.to_be_bytes +[`isize::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.to_le_bytes +[`isize::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.to_ne_bytes +[`iter::empty`]: https://doc.rust-lang.org/std/iter/fn.empty.html +[`str::as_ptr`]: https://doc.rust-lang.org/std/primitive.str.html#method.as_ptr +[`u16::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.from_be_bytes +[`u16::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.from_le_bytes +[`u16::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.from_ne_bytes +[`u16::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.to_be_bytes +[`u16::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.to_le_bytes +[`u16::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.to_ne_bytes +[`u32::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.from_be_bytes +[`u32::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.from_le_bytes +[`u32::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.from_ne_bytes +[`u32::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.to_be_bytes +[`u32::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.to_le_bytes +[`u32::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u32.html#method.to_ne_bytes +[`u64::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.from_be_bytes +[`u64::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.from_le_bytes +[`u64::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.from_ne_bytes +[`u64::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.to_be_bytes +[`u64::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.to_le_bytes +[`u64::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u64.html#method.to_ne_bytes +[`u8::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.from_be_bytes +[`u8::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.from_le_bytes +[`u8::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.from_ne_bytes +[`u8::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.to_be_bytes +[`u8::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.to_le_bytes +[`u8::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.to_ne_bytes +[`usize::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.from_be_bytes +[`usize::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.from_le_bytes +[`usize::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.from_ne_bytes +[`usize::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.to_be_bytes +[`usize::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.to_le_bytes +[`usize::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.usize.html#method.to_ne_bytes + + Version 1.31.1 (2018-12-20) =========================== From 071b0772ac616491e6a41a1bf6f3d9df563c99e8 Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Thu, 10 Jan 2019 10:08:07 +0100 Subject: [PATCH 12/15] Update RELEASES.md --- RELEASES.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 887b6e9c39f7..fec9046a0832 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -40,11 +40,11 @@ Language Cons(T, Box) // likewise here } ``` +- [You can now mark traits with `#[must_use]`.][55663] This provides a warning if + a `impl Trait` or `dyn Trait` is returned and unused in the program. Compiler -------- -- [You can now mark traits with `#[must_use]`.][55663] Providing a warning if - they unused in a program. - [The default allocator has changed from jemalloc to the default allocator on your system.][55238] The compiler itself on Linux & macOS will still use jemalloc, but programs compiled with them will use the system allocator. @@ -75,7 +75,7 @@ The following APIs are now `const` functions and can be used in a - [`RangeInclusive::start`] - [`RangeInclusive::end`] - [`NonNull::as_ptr`] -- [`[T]::as_ptr`] +- [`slice::as_ptr`] - [`str::as_ptr`] - [`Duration::as_secs`] - [`Duration::subsec_millis`] @@ -165,6 +165,7 @@ Compatibility Notes been changed from `*const` to `*mut` as the previous implementation was unsound. + [55148]: https://github.com/rust-lang/rust/pull/55148/ [55238]: https://github.com/rust-lang/rust/pull/55238/ [55280]: https://github.com/rust-lang/rust/pull/55280/ @@ -195,7 +196,7 @@ Compatibility Notes [`RangeInclusive::end`]: https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html#method.end [`RangeInclusive::start`]: https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html#method.start [`UnsafeCell::get`]: https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.get -[`[T]::as_ptr`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_ptr +[`slice::as_ptr`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_ptr [`char::is_ascii`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii [`i16::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_be_bytes [`i16::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_le_bytes From 696ecd92b3a05ed8fc81e140fca1a05b7c1a6ce4 Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Thu, 10 Jan 2019 10:08:32 +0100 Subject: [PATCH 13/15] Apply suggestions from code review Co-Authored-By: Aaronepower --- RELEASES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index fec9046a0832..8179132c3552 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -13,7 +13,7 @@ Language - [You can now match against literals in macros with the `literal` specifier.][56072] This will match against a literal of any type. E.g. `1`, `'A'`, `"Hello World"` -- [Self can now be used as a constructor and pattern.][56365] E.g. +- [Self can now be used as a constructor and pattern for unit and tuple structs.][56365] E.g. ```rust struct Point(i32, i32); @@ -34,7 +34,7 @@ Language ```rust enum List where - Self: PartialOrd // can write `Self` instead of `List` + Self: PartialOrd // can write `Self` instead of `List` { Nil, Cons(T, Box) // likewise here @@ -47,7 +47,7 @@ Compiler -------- - [The default allocator has changed from jemalloc to the default allocator on your system.][55238] The compiler itself on Linux & macOS will still use - jemalloc, but programs compiled with them will use the system allocator. + jemalloc, but programs compiled with it will use the system allocator. - [Added the `aarch64-pc-windows-msvc` target.][55702] Libraries From 70b641d08920ee7e7ebb5563b9ecafb02805ecd7 Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Thu, 10 Jan 2019 23:07:38 +0100 Subject: [PATCH 14/15] Update RELEASES.md --- RELEASES.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 8179132c3552..e82a8a613b95 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -7,6 +7,15 @@ Language - [You can now use the `?` operator in macro definitions.][56245] The `?` operator allows you to specify zero or one repetitions similar to the `*` and `+` operators. +- [Module paths with no leading keyword like `super`, `self`, or `crate`, will + now always resolve to the item (`enum`, `struct`, etc.) available in the + module if present, before resolving to a external crate or an item the prelude.][56759] + E.g. + ```rust + enum Color { Red, Green, Blue } + + use Color::*; + ``` #### All editions - [You can now match against `PhantomData` types.][55837] @@ -179,6 +188,7 @@ Compatibility Notes [56365]: https://github.com/rust-lang/rust/pull/56365/ [56366]: https://github.com/rust-lang/rust/pull/56366/ [56395]: https://github.com/rust-lang/rust/pull/56395/ +[56759]: https://github.com/rust-lang/rust/pull/56759/ [cargo/6218]: https://github.com/rust-lang/cargo/pull/6218/ [cargo/6242]: https://github.com/rust-lang/cargo/pull/6242/ [`CStr::as_ptr`]: https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.as_ptr From b9f08d24717fe3dd39a900b5d74034151190d84c Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Thu, 10 Jan 2019 23:28:18 +0100 Subject: [PATCH 15/15] Update RELEASES.md --- RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index e82a8a613b95..aae25ab9988e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -45,8 +45,8 @@ Language where Self: PartialOrd // can write `Self` instead of `List` { - Nil, - Cons(T, Box) // likewise here + Nil, + Cons(T, Box) // likewise here } ``` - [You can now mark traits with `#[must_use]`.][55663] This provides a warning if