]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #52536 - alexcrichton:attr-spans, r=nikomatsakis
authorbors <bors@rust-lang.org>
Sat, 21 Jul 2018 04:19:15 +0000 (04:19 +0000)
committerbors <bors@rust-lang.org>
Sat, 21 Jul 2018 04:19:15 +0000 (04:19 +0000)
proc_macro: Preserve spans of attributes on functions

This commit updates the tokenization of items which are subsequently passed to
`proc_macro` to ensure that span information is preserved on attributes as much
as possible. Previously this area of the code suffered from #43081 where we
haven't actually implemented converting an attribute to to a token tree yet, but
a local fix was possible here.

Closes #47941

388 files changed:
src/ci/docker/run.sh
src/libcore/slice/rotate.rs
src/librustc/hir/check_attr.rs
src/librustc/hir/def.rs
src/librustc/hir/intravisit.rs
src/librustc/hir/lowering.rs
src/librustc/hir/map/blocks.rs
src/librustc/hir/map/def_collector.rs
src/librustc/hir/map/definitions.rs
src/librustc/hir/map/mod.rs
src/librustc/hir/mod.rs
src/librustc/hir/print.rs
src/librustc/ich/impls_cstore.rs
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_ty.rs
src/librustc/infer/anon_types/mod.rs
src/librustc/infer/error_reporting/mod.rs
src/librustc/infer/mod.rs
src/librustc/lint/mod.rs
src/librustc/middle/cstore.rs
src/librustc/middle/dead.rs
src/librustc/middle/reachable.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/ty/fold.rs
src/librustc/ty/item_path.rs
src/librustc/ty/mod.rs
src/librustc/ty/query/mod.rs
src/librustc/ty/query/plumbing.rs
src/librustc/ty/sty.rs
src/librustc/ty/wf.rs
src/librustc/util/ppaux.rs
src/librustc_codegen_llvm/abi.rs
src/librustc_codegen_llvm/attributes.rs
src/librustc_codegen_llvm/back/link.rs
src/librustc_codegen_llvm/back/lto.rs
src/librustc_codegen_llvm/back/wasm.rs
src/librustc_codegen_llvm/builder.rs
src/librustc_driver/lib.rs
src/librustc_incremental/persist/dirty_clean.rs
src/librustc_lint/builtin.rs
src/librustc_llvm/ffi.rs
src/librustc_metadata/decoder.rs
src/librustc_metadata/encoder.rs
src/librustc_metadata/native_libs.rs
src/librustc_metadata/schema.rs
src/librustc_mir/interpret/cast.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/transform/const_prop.rs
src/librustc_privacy/lib.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/lib.rs
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/sig.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/namespace.rs
src/librustdoc/clean/mod.rs
src/librustdoc/doctree.rs
src/librustdoc/fold.rs
src/librustdoc/html/item_type.rs
src/librustdoc/html/render.rs
src/librustdoc/html/static/main.js
src/librustdoc/html/static/rustdoc.css
src/librustdoc/html/static/themes/dark.css
src/librustdoc/html/static/themes/light.css
src/librustdoc/lib.rs
src/librustdoc/passes/mod.rs
src/librustdoc/visit_ast.rs
src/libstd/sync/once.rs
src/libsyntax/ast.rs
src/libsyntax/ext/expand.rs
src/libsyntax/feature_gate.rs
src/libsyntax/fold.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/libsyntax_pos/symbol.rs
src/rustllvm/PassWrapper.cpp
src/test/parse-fail/issue-20711-2.rs
src/test/parse-fail/issue-20711.rs
src/test/parse-fail/removed-syntax-static-fn.rs
src/test/run-make-fulldeps/exit-code/Makefile [new file with mode: 0644]
src/test/run-make-fulldeps/exit-code/compile-error.rs [new file with mode: 0644]
src/test/run-make-fulldeps/exit-code/lint-failure.rs [new file with mode: 0644]
src/test/run-make-fulldeps/exit-code/success.rs [new file with mode: 0644]
src/test/run-make/wasm-import-module/bar.rs
src/test/run-make/wasm-import-module/foo.rs
src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs [new file with mode: 0644]
src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs [new file with mode: 0644]
src/test/run-pass/cast-rfc0401.rs
src/test/run-pass/const-block.rs
src/test/run-pass/existential_type.rs [new file with mode: 0644]
src/test/run-pass/sepcomp-lib-lto.rs
src/test/ui/as-ref.rs [new file with mode: 0644]
src/test/ui/as-ref.stderr [new file with mode: 0644]
src/test/ui/auxiliary/m1.rs [new file with mode: 0644]
src/test/ui/auxiliary/m2.rs [new file with mode: 0644]
src/test/ui/auxiliary/macro-in-other-crate.rs [new file with mode: 0644]
src/test/ui/auxiliary/removing-extern-crate.rs [new file with mode: 0644]
src/test/ui/closure-immutable-outer-variable.fixed [new file with mode: 0644]
src/test/ui/closure-immutable-outer-variable.nll.stderr [new file with mode: 0644]
src/test/ui/closure-immutable-outer-variable.rs [new file with mode: 0644]
src/test/ui/closure-immutable-outer-variable.rs.fixed [new file with mode: 0644]
src/test/ui/closure-immutable-outer-variable.stderr [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-18343.rs [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-18343.stderr [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-2392.rs [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-2392.stderr [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-32128.rs [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-32128.stderr [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-33784.rs [new file with mode: 0644]
src/test/ui/confuse-field-and-method/issue-33784.stderr [new file with mode: 0644]
src/test/ui/confuse-field-and-method/private-field.rs [new file with mode: 0644]
src/test/ui/confuse-field-and-method/private-field.stderr [new file with mode: 0644]
src/test/ui/const-eval/promoted_errors.rs
src/test/ui/const-eval/promoted_errors.stderr
src/test/ui/const-type-mismatch.rs [new file with mode: 0644]
src/test/ui/const-type-mismatch.stderr [new file with mode: 0644]
src/test/ui/conversion-methods.rs [new file with mode: 0644]
src/test/ui/conversion-methods.stderr [new file with mode: 0644]
src/test/ui/dont-suggest-private-trait-method.rs [new file with mode: 0644]
src/test/ui/dont-suggest-private-trait-method.stderr [new file with mode: 0644]
src/test/ui/dotdotdot-expr.rs [new file with mode: 0644]
src/test/ui/dotdotdot-expr.stderr [new file with mode: 0644]
src/test/ui/error-codes/E0458.stderr
src/test/ui/existential_types/bound_reduction.rs [new file with mode: 0644]
src/test/ui/existential_types/bound_reduction2.rs [new file with mode: 0644]
src/test/ui/existential_types/bound_reduction2.stderr [new file with mode: 0644]
src/test/ui/existential_types/declared_but_never_defined.rs [new file with mode: 0644]
src/test/ui/existential_types/declared_but_never_defined.stderr [new file with mode: 0644]
src/test/ui/existential_types/declared_but_not_defined_in_scope.rs [new file with mode: 0644]
src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr [new file with mode: 0644]
src/test/ui/existential_types/different_defining_uses.rs [new file with mode: 0644]
src/test/ui/existential_types/different_defining_uses.stderr [new file with mode: 0644]
src/test/ui/existential_types/different_defining_uses_never_type.rs [new file with mode: 0644]
src/test/ui/existential_types/different_defining_uses_never_type.stderr [new file with mode: 0644]
src/test/ui/existential_types/different_defining_uses_never_type2.rs [new file with mode: 0644]
src/test/ui/existential_types/existential-associated-type.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_different_defining_uses.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_different_defining_uses.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_lifetime_param.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_lifetime_param.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_duplicate_param_use.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_lifetime_param.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_nondefining_use.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_nondefining_use.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_not_used.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_not_used.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_underconstrained.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_underconstrained.stderr [new file with mode: 0644]
src/test/ui/existential_types/generic_underconstrained2.rs [new file with mode: 0644]
src/test/ui/existential_types/generic_underconstrained2.stderr [new file with mode: 0644]
src/test/ui/existential_types/never_reveal_concrete_type.rs [new file with mode: 0644]
src/test/ui/existential_types/never_reveal_concrete_type.stderr [new file with mode: 0644]
src/test/ui/existential_types/no_revealing_outside_defining_module.rs [new file with mode: 0644]
src/test/ui/existential_types/no_revealing_outside_defining_module.stderr [new file with mode: 0644]
src/test/ui/existential_types/not_well_formed.rs [new file with mode: 0644]
src/test/ui/existential_types/not_well_formed.stderr [new file with mode: 0644]
src/test/ui/existential_types/unused_generic_param.rs [new file with mode: 0644]
src/test/ui/existential_types/unused_generic_param.stderr [new file with mode: 0644]
src/test/ui/extern-crate-rename.rs [new file with mode: 0644]
src/test/ui/extern-crate-rename.stderr [new file with mode: 0644]
src/test/ui/feature-gate-existential-type.rs [new file with mode: 0644]
src/test/ui/feature-gate-existential-type.stderr [new file with mode: 0644]
src/test/ui/feature-gate-wasm_import_module.rs [deleted file]
src/test/ui/feature-gate-wasm_import_module.stderr [deleted file]
src/test/ui/fn-closure-mutable-capture.nll.stderr [new file with mode: 0644]
src/test/ui/fn-closure-mutable-capture.rs [new file with mode: 0644]
src/test/ui/fn-closure-mutable-capture.stderr [new file with mode: 0644]
src/test/ui/for-c-in-str.rs [new file with mode: 0644]
src/test/ui/for-c-in-str.stderr [new file with mode: 0644]
src/test/ui/impl-trait/auto-trait-leak.rs
src/test/ui/impl-trait/auto-trait-leak.stderr
src/test/ui/issue-20801.rs
src/test/ui/issue-32354-suggest-import-rename.fixed [new file with mode: 0644]
src/test/ui/issue-32354-suggest-import-rename.rs [new file with mode: 0644]
src/test/ui/issue-32354-suggest-import-rename.stderr [new file with mode: 0644]
src/test/ui/issue-43420-no-over-suggest.rs [new file with mode: 0644]
src/test/ui/issue-43420-no-over-suggest.stderr [new file with mode: 0644]
src/test/ui/issue-43926.stderr
src/test/ui/issue-45562.fixed [new file with mode: 0644]
src/test/ui/issue-45562.rs [new file with mode: 0644]
src/test/ui/issue-45562.stderr [new file with mode: 0644]
src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed [new file with mode: 0644]
src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs [new file with mode: 0644]
src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr [new file with mode: 0644]
src/test/ui/issue-46302.rs [new file with mode: 0644]
src/test/ui/issue-46302.stderr [new file with mode: 0644]
src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.fixed [new file with mode: 0644]
src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.rs [new file with mode: 0644]
src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.stderr [new file with mode: 0644]
src/test/ui/issue-48364.rs [new file with mode: 0644]
src/test/ui/issue-48364.stderr [new file with mode: 0644]
src/test/ui/issue-51244.nll.stderr [new file with mode: 0644]
src/test/ui/issue-51244.rs [new file with mode: 0644]
src/test/ui/issue-51244.stderr [new file with mode: 0644]
src/test/ui/issue-51515.rs [new file with mode: 0644]
src/test/ui/issue-51515.stderr [new file with mode: 0644]
src/test/ui/issue-52049.nll.stderr [new file with mode: 0644]
src/test/ui/issue-52049.rs [new file with mode: 0644]
src/test/ui/issue-52049.stderr [new file with mode: 0644]
src/test/ui/lint/auxiliary/lints-in-foreign-macros.rs [new file with mode: 0644]
src/test/ui/lint/lints-in-foreign-macros.rs [new file with mode: 0644]
src/test/ui/lint/lints-in-foreign-macros.stderr [new file with mode: 0644]
src/test/ui/method-on-ambiguous-numeric-type.rs [new file with mode: 0644]
src/test/ui/method-on-ambiguous-numeric-type.stderr [new file with mode: 0644]
src/test/ui/missing-comma-in-match.fixed [new file with mode: 0644]
src/test/ui/missing-comma-in-match.rs [new file with mode: 0644]
src/test/ui/missing-comma-in-match.stderr [new file with mode: 0644]
src/test/ui/numeric-cast-2.rs [new file with mode: 0644]
src/test/ui/numeric-cast-2.stderr [new file with mode: 0644]
src/test/ui/numeric-cast.rs [new file with mode: 0644]
src/test/ui/numeric-cast.stderr [new file with mode: 0644]
src/test/ui/placement-syntax.rs [new file with mode: 0644]
src/test/ui/placement-syntax.stderr [new file with mode: 0644]
src/test/ui/pub-ident-fn-2.rs [new file with mode: 0644]
src/test/ui/pub-ident-fn-2.stderr [new file with mode: 0644]
src/test/ui/pub-ident-fn-or-struct-2.rs [new file with mode: 0644]
src/test/ui/pub-ident-fn-or-struct-2.stderr [new file with mode: 0644]
src/test/ui/pub-ident-fn-or-struct.rs [new file with mode: 0644]
src/test/ui/pub-ident-fn-or-struct.stderr [new file with mode: 0644]
src/test/ui/pub-ident-fn.fixed [new file with mode: 0644]
src/test/ui/pub-ident-fn.rs [new file with mode: 0644]
src/test/ui/pub-ident-fn.stderr [new file with mode: 0644]
src/test/ui/pub-ident-struct.rs [new file with mode: 0644]
src/test/ui/pub-ident-struct.stderr [new file with mode: 0644]
src/test/ui/removing-extern-crate.fixed [new file with mode: 0644]
src/test/ui/removing-extern-crate.rs [new file with mode: 0644]
src/test/ui/removing-extern-crate.stderr [new file with mode: 0644]
src/test/ui/repr.rs [new file with mode: 0644]
src/test/ui/repr.stderr [new file with mode: 0644]
src/test/ui/return-type.rs [new file with mode: 0644]
src/test/ui/return-type.stderr [new file with mode: 0644]
src/test/ui/single-use-lifetime/one-use-in-fn-argument-in-band.stderr
src/test/ui/str-array-assignment.rs [new file with mode: 0644]
src/test/ui/str-array-assignment.stderr [new file with mode: 0644]
src/test/ui/str-as-char.fixed [new file with mode: 0644]
src/test/ui/str-as-char.rs [new file with mode: 0644]
src/test/ui/str-as-char.stderr [new file with mode: 0644]
src/test/ui/suggest-labels.rs [new file with mode: 0644]
src/test/ui/suggest-labels.stderr [new file with mode: 0644]
src/test/ui/suggest-methods.rs [new file with mode: 0644]
src/test/ui/suggest-methods.stderr [new file with mode: 0644]
src/test/ui/suggest-ref-mut.rs [new file with mode: 0644]
src/test/ui/suggest-ref-mut.stderr [new file with mode: 0644]
src/test/ui/suggestions/as-ref.rs [deleted file]
src/test/ui/suggestions/as-ref.stderr [deleted file]
src/test/ui/suggestions/auxiliary/m1.rs [deleted file]
src/test/ui/suggestions/auxiliary/m2.rs [deleted file]
src/test/ui/suggestions/auxiliary/macro-in-other-crate.rs [deleted file]
src/test/ui/suggestions/auxiliary/removing-extern-crate.rs [deleted file]
src/test/ui/suggestions/closure-immutable-outer-variable.fixed [deleted file]
src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed [deleted file]
src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr [deleted file]
src/test/ui/suggestions/closure-immutable-outer-variable.rs [deleted file]
src/test/ui/suggestions/closure-immutable-outer-variable.rs.fixed [deleted file]
src/test/ui/suggestions/closure-immutable-outer-variable.stderr [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-18343.rs [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-18343.stderr [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-2392.rs [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-2392.stderr [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-32128.rs [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-32128.stderr [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-33784.rs [deleted file]
src/test/ui/suggestions/confuse-field-and-method/issue-33784.stderr [deleted file]
src/test/ui/suggestions/confuse-field-and-method/private-field.rs [deleted file]
src/test/ui/suggestions/confuse-field-and-method/private-field.stderr [deleted file]
src/test/ui/suggestions/const-type-mismatch.rs [deleted file]
src/test/ui/suggestions/const-type-mismatch.stderr [deleted file]
src/test/ui/suggestions/conversion-methods.rs [deleted file]
src/test/ui/suggestions/conversion-methods.stderr [deleted file]
src/test/ui/suggestions/dont-suggest-private-trait-method.rs [deleted file]
src/test/ui/suggestions/dont-suggest-private-trait-method.stderr [deleted file]
src/test/ui/suggestions/dotdotdot-expr.rs [deleted file]
src/test/ui/suggestions/dotdotdot-expr.stderr [deleted file]
src/test/ui/suggestions/extern-crate-rename.rs [deleted file]
src/test/ui/suggestions/extern-crate-rename.stderr [deleted file]
src/test/ui/suggestions/fn-closure-mutable-capture.nll.stderr [deleted file]
src/test/ui/suggestions/fn-closure-mutable-capture.rs [deleted file]
src/test/ui/suggestions/fn-closure-mutable-capture.stderr [deleted file]
src/test/ui/suggestions/for-c-in-str.rs [deleted file]
src/test/ui/suggestions/for-c-in-str.stderr [deleted file]
src/test/ui/suggestions/issue-32354-suggest-import-rename.fixed [deleted file]
src/test/ui/suggestions/issue-32354-suggest-import-rename.rs [deleted file]
src/test/ui/suggestions/issue-32354-suggest-import-rename.stderr [deleted file]
src/test/ui/suggestions/issue-43420-no-over-suggest.rs [deleted file]
src/test/ui/suggestions/issue-43420-no-over-suggest.stderr [deleted file]
src/test/ui/suggestions/issue-45562.fixed [deleted file]
src/test/ui/suggestions/issue-45562.rs [deleted file]
src/test/ui/suggestions/issue-45562.stderr [deleted file]
src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed [deleted file]
src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs [deleted file]
src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr [deleted file]
src/test/ui/suggestions/issue-46302.rs [deleted file]
src/test/ui/suggestions/issue-46302.stderr [deleted file]
src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed [deleted file]
src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs [deleted file]
src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr [deleted file]
src/test/ui/suggestions/issue-48364.rs [deleted file]
src/test/ui/suggestions/issue-48364.stderr [deleted file]
src/test/ui/suggestions/issue-51244.nll.stderr [deleted file]
src/test/ui/suggestions/issue-51244.rs [deleted file]
src/test/ui/suggestions/issue-51244.stderr [deleted file]
src/test/ui/suggestions/issue-51515.rs [deleted file]
src/test/ui/suggestions/issue-51515.stderr [deleted file]
src/test/ui/suggestions/issue-52049.nll.stderr [deleted file]
src/test/ui/suggestions/issue-52049.rs [deleted file]
src/test/ui/suggestions/issue-52049.stderr [deleted file]
src/test/ui/suggestions/method-on-ambiguous-numeric-type.rs [deleted file]
src/test/ui/suggestions/method-on-ambiguous-numeric-type.stderr [deleted file]
src/test/ui/suggestions/missing-comma-in-match.fixed [deleted file]
src/test/ui/suggestions/missing-comma-in-match.rs [deleted file]
src/test/ui/suggestions/missing-comma-in-match.stderr [deleted file]
src/test/ui/suggestions/numeric-cast-2.rs [deleted file]
src/test/ui/suggestions/numeric-cast-2.stderr [deleted file]
src/test/ui/suggestions/numeric-cast.rs [deleted file]
src/test/ui/suggestions/numeric-cast.stderr [deleted file]
src/test/ui/suggestions/placement-syntax.rs [deleted file]
src/test/ui/suggestions/placement-syntax.stderr [deleted file]
src/test/ui/suggestions/pub-ident-fn-2.rs [deleted file]
src/test/ui/suggestions/pub-ident-fn-2.stderr [deleted file]
src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs [deleted file]
src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr [deleted file]
src/test/ui/suggestions/pub-ident-fn-or-struct.rs [deleted file]
src/test/ui/suggestions/pub-ident-fn-or-struct.stderr [deleted file]
src/test/ui/suggestions/pub-ident-fn.fixed [deleted file]
src/test/ui/suggestions/pub-ident-fn.rs [deleted file]
src/test/ui/suggestions/pub-ident-fn.stderr [deleted file]
src/test/ui/suggestions/pub-ident-struct.rs [deleted file]
src/test/ui/suggestions/pub-ident-struct.stderr [deleted file]
src/test/ui/suggestions/removing-extern-crate.fixed [deleted file]
src/test/ui/suggestions/removing-extern-crate.rs [deleted file]
src/test/ui/suggestions/removing-extern-crate.stderr [deleted file]
src/test/ui/suggestions/repr.rs [deleted file]
src/test/ui/suggestions/repr.stderr [deleted file]
src/test/ui/suggestions/return-type.rs [deleted file]
src/test/ui/suggestions/return-type.stderr [deleted file]
src/test/ui/suggestions/str-array-assignment.rs [deleted file]
src/test/ui/suggestions/str-array-assignment.stderr [deleted file]
src/test/ui/suggestions/str-as-char.fixed [deleted file]
src/test/ui/suggestions/str-as-char.rs [deleted file]
src/test/ui/suggestions/str-as-char.stderr [deleted file]
src/test/ui/suggestions/suggest-labels.rs [deleted file]
src/test/ui/suggestions/suggest-labels.stderr [deleted file]
src/test/ui/suggestions/suggest-methods.rs [deleted file]
src/test/ui/suggestions/suggest-methods.stderr [deleted file]
src/test/ui/suggestions/suggest-ref-mut.rs [deleted file]
src/test/ui/suggestions/suggest-ref-mut.stderr [deleted file]
src/test/ui/suggestions/try-on-option.rs [deleted file]
src/test/ui/suggestions/try-on-option.stderr [deleted file]
src/test/ui/suggestions/try-operator-on-main.rs [deleted file]
src/test/ui/suggestions/try-operator-on-main.stderr [deleted file]
src/test/ui/suggestions/tuple-float-index.fixed [deleted file]
src/test/ui/suggestions/tuple-float-index.rs [deleted file]
src/test/ui/suggestions/tuple-float-index.stderr [deleted file]
src/test/ui/suggestions/type-ascription-instead-of-initializer.rs [deleted file]
src/test/ui/suggestions/type-ascription-instead-of-initializer.stderr [deleted file]
src/test/ui/suggestions/type-ascription-instead-of-statement-end.rs [deleted file]
src/test/ui/suggestions/type-ascription-instead-of-statement-end.stderr [deleted file]
src/test/ui/suggestions/type-ascription-with-fn-call.rs [deleted file]
src/test/ui/suggestions/type-ascription-with-fn-call.stderr [deleted file]
src/test/ui/token/issue-41155.stderr
src/test/ui/try-on-option.rs [new file with mode: 0644]
src/test/ui/try-on-option.stderr [new file with mode: 0644]
src/test/ui/try-operator-on-main.rs [new file with mode: 0644]
src/test/ui/try-operator-on-main.stderr [new file with mode: 0644]
src/test/ui/tuple-float-index.fixed [new file with mode: 0644]
src/test/ui/tuple-float-index.rs [new file with mode: 0644]
src/test/ui/tuple-float-index.stderr [new file with mode: 0644]
src/test/ui/type-ascription-instead-of-initializer.rs [new file with mode: 0644]
src/test/ui/type-ascription-instead-of-initializer.stderr [new file with mode: 0644]
src/test/ui/type-ascription-instead-of-statement-end.rs [new file with mode: 0644]
src/test/ui/type-ascription-instead-of-statement-end.stderr [new file with mode: 0644]
src/test/ui/type-ascription-with-fn-call.rs [new file with mode: 0644]
src/test/ui/type-ascription-with-fn-call.stderr [new file with mode: 0644]
src/test/ui/wasm-import-module.rs
src/test/ui/wasm-import-module.stderr
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/runtest.rs

index 931c28f1ca98e95f3bd944c2123ba91156e0fe8d..b1ee636644ec79e76415e4cb2eb76d64fa3c6f84 100755 (executable)
@@ -99,7 +99,7 @@ objdir=$root_dir/obj
 
 mkdir -p $HOME/.cargo
 mkdir -p $objdir/tmp
-mkdir $objdir/cores
+mkdir -p $objdir/cores
 
 args=
 if [ "$SCCACHE_BUCKET" != "" ]; then
index e4a4e33c1729efb94bd924b552915d048480d6c5..28ef53ccb5cb6b50547b5619bd7d5b7af86049c7 100644 (file)
@@ -48,7 +48,6 @@ fn cap() -> usize {
 /// # Safety
 ///
 /// The specified range must be valid for reading and writing.
-/// The type `T` must have non-zero size.
 ///
 /// # Algorithm
 ///
@@ -73,6 +72,7 @@ pub unsafe fn ptr_rotate<T>(mut left: usize, mid: *mut T, mut right: usize) {
     loop {
         let delta = cmp::min(left, right);
         if delta <= RawArray::<T>::cap() {
+            // We will always hit this immediately for ZST.
             break;
         }
 
index 79d0aed10ed78fec554391695c2feec281f6854d..05e0257cdafd20993cb0dfabacf778bd49da6b1a 100644 (file)
@@ -65,35 +65,14 @@ fn check_attributes(&self, item: &hir::Item, target: Target) {
                 .emit();
         }
 
-        let mut has_wasm_import_module = false;
         for attr in &item.attrs {
             if attr.check_name("inline") {
                 self.check_inline(attr, &item.span, target)
             } else if attr.check_name("non_exhaustive") {
                 self.check_non_exhaustive(attr, item, target)
-            } else if attr.check_name("wasm_import_module") {
-                has_wasm_import_module = true;
-                if attr.value_str().is_none() {
-                    self.tcx.sess.span_err(attr.span, "\
-                        must be of the form #[wasm_import_module = \"...\"]");
-                }
-                if target != Target::ForeignMod {
-                    self.tcx.sess.span_err(attr.span, "\
-                        must only be attached to foreign modules");
-                }
             }
         }
 
-        if target == Target::ForeignMod &&
-            !has_wasm_import_module &&
-            self.tcx.sess.target.target.arch == "wasm32" &&
-            false // FIXME: eventually enable this warning when stable
-        {
-            self.tcx.sess.span_warn(item.span, "\
-                must have a #[wasm_import_module = \"...\"] attribute, this \
-                will become a hard error before too long");
-        }
-
         self.check_repr(item, target);
         self.check_used(item, target);
     }
index 7a26a239aeffadb777733841e1411434752f789a..1c355e35fd6eafffbc048e23c6fe21dae2874291 100644 (file)
@@ -37,11 +37,15 @@ pub enum Def {
     Enum(DefId),
     Variant(DefId),
     Trait(DefId),
+    /// `existential type Foo: Bar;`
     Existential(DefId),
+    /// `type Foo = Bar;`
     TyAlias(DefId),
     TyForeign(DefId),
     TraitAlias(DefId),
     AssociatedTy(DefId),
+    /// `existential type Foo: Bar;`
+    AssociatedExistential(DefId),
     PrimTy(hir::PrimTy),
     TyParam(DefId),
     SelfTy(Option<DefId> /* trait */, Option<DefId> /* impl */),
@@ -245,7 +249,7 @@ pub fn def_id(&self) -> DefId {
             Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
             Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
             Def::AssociatedConst(id) | Def::Macro(id, ..) |
-            Def::Existential(id) |
+            Def::Existential(id) | Def::AssociatedExistential(id) |
             Def::GlobalAsm(id) | Def::TyForeign(id) => {
                 id
             }
@@ -276,6 +280,7 @@ pub fn kind_name(&self) -> &'static str {
             Def::TyAlias(..) => "type alias",
             Def::TraitAlias(..) => "trait alias",
             Def::AssociatedTy(..) => "associated type",
+            Def::AssociatedExistential(..) => "associated existential type",
             Def::Struct(..) => "struct",
             Def::StructCtor(.., CtorKind::Fn) => "tuple struct",
             Def::StructCtor(.., CtorKind::Const) => "unit struct",
index 2fefd2b33189c9e3d289a5286a4fb2ad7542d1c4..4274cd3a0a6559e6759a13b5734714503f22588c 100644 (file)
@@ -907,6 +907,10 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
             visitor.visit_id(impl_item.id);
             visitor.visit_ty(ty);
         }
+        ImplItemKind::Existential(ref bounds) => {
+            visitor.visit_id(impl_item.id);
+            walk_list!(visitor, visit_param_bound, bounds);
+        }
     }
 }
 
index 93fb282546bb05de85533dc1dc3c7cec3e06ce23..99db718bdf80f4e1e110e1754be670ba69d70500 100644 (file)
@@ -323,6 +323,7 @@ fn visit_item(&mut self, item: &'lcx Item) {
                     | ItemKind::Union(_, ref generics)
                     | ItemKind::Enum(_, ref generics)
                     | ItemKind::Ty(_, ref generics)
+                    | ItemKind::Existential(_, ref generics)
                     | ItemKind::Trait(_, _, ref generics, ..) => {
                         let def_id = self.lctx.resolver.definitions().local_def_id(item.id);
                         let count = generics
@@ -2632,6 +2633,11 @@ fn lower_item_kind(
                 self.lower_ty(t, ImplTraitContext::Disallowed),
                 self.lower_generics(generics, ImplTraitContext::Disallowed),
             ),
+            ItemKind::Existential(ref b, ref generics) => hir::ItemKind::Existential(hir::ExistTy {
+                generics: self.lower_generics(generics, ImplTraitContext::Disallowed),
+                bounds: self.lower_param_bounds(b, ImplTraitContext::Disallowed),
+                impl_trait_fn: None,
+            }),
             ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemKind::Enum(
                 hir::EnumDef {
                     variants: enum_definition
@@ -3037,6 +3043,12 @@ fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
                 self.lower_generics(&i.generics, ImplTraitContext::Disallowed),
                 hir::ImplItemKind::Type(self.lower_ty(ty, ImplTraitContext::Disallowed)),
             ),
+            ImplItemKind::Existential(ref bounds) => (
+                self.lower_generics(&i.generics, ImplTraitContext::Disallowed),
+                hir::ImplItemKind::Existential(
+                    self.lower_param_bounds(bounds, ImplTraitContext::Disallowed),
+                ),
+            ),
             ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"),
         };
 
@@ -3065,6 +3077,7 @@ fn lower_impl_item_ref(&mut self, i: &ImplItem) -> hir::ImplItemRef {
             kind: match i.node {
                 ImplItemKind::Const(..) => hir::AssociatedItemKind::Const,
                 ImplItemKind::Type(..) => hir::AssociatedItemKind::Type,
+                ImplItemKind::Existential(..) => hir::AssociatedItemKind::Existential,
                 ImplItemKind::Method(ref sig, _) => hir::AssociatedItemKind::Method {
                     has_self: sig.decl.has_self(),
                 },
@@ -4335,7 +4348,7 @@ fn lower_visibility(
         respan(v.span, node)
     }
 
-    fn lower_defaultness(&mut self, d: Defaultness, has_value: bool) -> hir::Defaultness {
+    fn lower_defaultness(&self, d: Defaultness, has_value: bool) -> hir::Defaultness {
         match d {
             Defaultness::Default => hir::Defaultness::Default {
                 has_value: has_value,
index 5a595d14db7aa5970452c520221835f7cbd38a46..f2f7f95426ab827e977cab992111d409df00bfa5 100644 (file)
@@ -51,6 +51,12 @@ fn is_fn_like(&self) -> bool {
     }
 }
 
+impl MaybeFnLike for ast::ImplItem {
+    fn is_fn_like(&self) -> bool {
+        match self.node { ast::ImplItemKind::Method(..) => true, _ => false, }
+    }
+}
+
 impl MaybeFnLike for ast::TraitItem {
     fn is_fn_like(&self) -> bool {
         match self.node {
@@ -141,7 +147,7 @@ pub fn from_node(node: Node) -> Option<FnLikeNode> {
         let fn_like = match node {
             map::NodeItem(item) => item.is_fn_like(),
             map::NodeTraitItem(tm) => tm.is_fn_like(),
-            map::NodeImplItem(_) => true,
+            map::NodeImplItem(it) => it.is_fn_like(),
             map::NodeExpr(e) => e.is_fn_like(),
             _ => false
         };
index c1de6c15d41b3797e95d586a5c8b572ec4adae71..cab620aeec548317a71eff72c2065a0f67b56f0a 100644 (file)
@@ -116,7 +116,7 @@ fn visit_item(&mut self, i: &'a Item) {
             ItemKind::Impl(..) => DefPathData::Impl,
             ItemKind::Trait(..) => DefPathData::Trait(i.ident.as_interned_str()),
             ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) |
-            ItemKind::TraitAlias(..) |
+            ItemKind::TraitAlias(..) | ItemKind::Existential(..) |
             ItemKind::ExternCrate(..) | ItemKind::ForeignMod(..) | ItemKind::Ty(..) =>
                 DefPathData::TypeNs(i.ident.as_interned_str()),
             ItemKind::Mod(..) if i.ident == keywords::Invalid.ident() => {
@@ -250,6 +250,9 @@ fn visit_impl_item(&mut self, ii: &'a ImplItem) {
             ImplItemKind::Method(..) | ImplItemKind::Const(..) =>
                 DefPathData::ValueNs(ii.ident.as_interned_str()),
             ImplItemKind::Type(..) => DefPathData::AssocTypeInImpl(ii.ident.as_interned_str()),
+            ImplItemKind::Existential(..) => {
+                DefPathData::AssocExistentialInImpl(ii.ident.as_interned_str())
+            },
             ImplItemKind::Macro(..) => return self.visit_macro_invoc(ii.id),
         };
 
index 9b1bb3310f2fd3807b88235eb1412e40ec3a9648..c4b28fe2c4332ad5b1a077f48128f271ce9675d6 100644 (file)
@@ -330,6 +330,8 @@ pub enum DefPathData {
     AssocTypeInTrait(InternedString),
     /// An associated type **value** (i.e., in an impl)
     AssocTypeInImpl(InternedString),
+    /// An existential associated type **value** (i.e., in an impl)
+    AssocExistentialInImpl(InternedString),
     /// Something in the type NS
     TypeNs(InternedString),
     /// Something in the value NS
@@ -605,6 +607,7 @@ pub fn get_opt_name(&self) -> Option<InternedString> {
             Trait(name) |
             AssocTypeInTrait(name) |
             AssocTypeInImpl(name) |
+            AssocExistentialInImpl(name) |
             ValueNs(name) |
             Module(name) |
             MacroDef(name) |
@@ -631,6 +634,7 @@ pub fn as_interned_str(&self) -> InternedString {
             Trait(name) |
             AssocTypeInTrait(name) |
             AssocTypeInImpl(name) |
+            AssocExistentialInImpl(name) |
             ValueNs(name) |
             Module(name) |
             MacroDef(name) |
index d413a544c4e410e5e535bc7808808eb23491e33e..49231e58cf0fc574d39cad754c6f46cea58dbf22 100644 (file)
@@ -470,6 +470,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
                     ImplItemKind::Const(..) => Some(Def::AssociatedConst(def_id)),
                     ImplItemKind::Method(..) => Some(Def::Method(def_id)),
                     ImplItemKind::Type(..) => Some(Def::AssociatedTy(def_id)),
+                    ImplItemKind::Existential(..) => Some(Def::AssociatedExistential(def_id)),
                 }
             }
             NodeVariant(variant) => {
@@ -1323,7 +1324,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
                 ItemKind::ForeignMod(..) => "foreign mod",
                 ItemKind::GlobalAsm(..) => "global asm",
                 ItemKind::Ty(..) => "ty",
-                ItemKind::Existential(..) => "existential",
+                ItemKind::Existential(..) => "existential type",
                 ItemKind::Enum(..) => "enum",
                 ItemKind::Struct(..) => "struct",
                 ItemKind::Union(..) => "union",
@@ -1347,6 +1348,9 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
                 ImplItemKind::Type(_) => {
                     format!("assoc type {} in {}{}", ii.ident, path_str(), id_str)
                 }
+                ImplItemKind::Existential(_) => {
+                    format!("assoc existential type {} in {}{}", ii.ident, path_str(), id_str)
+                }
             }
         }
         Some(NodeTraitItem(ti)) => {
index 1df756d204de7b4d8c67676de69e0a4c09fe21b8..610add90b8577253eaee6501e7d8b535a9425cfb 100644 (file)
@@ -1620,6 +1620,8 @@ pub enum ImplItemKind {
     Method(MethodSig, BodyId),
     /// An associated type
     Type(P<Ty>),
+    /// An associated existential type
+    Existential(GenericBounds),
 }
 
 // Bind a type to an associated type: `A=Foo`.
@@ -2080,7 +2082,7 @@ pub enum ItemKind {
     GlobalAsm(P<GlobalAsm>),
     /// A type alias, e.g. `type Foo = Bar<u8>`
     Ty(P<Ty>, Generics),
-    /// A type alias, e.g. `type Foo = Bar<u8>`
+    /// An existential type definition, e.g. `existential type Foo: Bar;`
     Existential(ExistTy),
     /// An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}`
     Enum(EnumDef, Generics),
@@ -2138,6 +2140,7 @@ pub fn generics(&self) -> Option<&Generics> {
         Some(match *self {
             ItemKind::Fn(_, _, ref generics, _) |
             ItemKind::Ty(_, ref generics) |
+            ItemKind::Existential(ExistTy { ref generics, impl_trait_fn: None, .. }) |
             ItemKind::Enum(_, ref generics) |
             ItemKind::Struct(_, ref generics) |
             ItemKind::Union(_, ref generics) |
@@ -2184,6 +2187,7 @@ pub enum AssociatedItemKind {
     Const,
     Method { has_self: bool },
     Type,
+    Existential,
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
index e637a18d1cd0a2af9ad998c906f7ade6b87805cd..4499a378be21a928a435fefcc00588186c2511c1 100644 (file)
@@ -627,9 +627,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 self.end()?
             }
             hir::ItemKind::Ty(ref ty, ref generics) => {
-                self.ibox(indent_unit)?;
-                self.ibox(0)?;
-                self.word_nbsp(&visibility_qualified(&item.vis, "type"))?;
+                self.head(&visibility_qualified(&item.vis, "type"))?;
                 self.print_name(item.name)?;
                 self.print_generic_params(&generics.params)?;
                 self.end()?; // end the inner ibox
@@ -642,9 +640,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 self.end()?; // end the outer ibox
             }
             hir::ItemKind::Existential(ref exist) => {
-                self.ibox(indent_unit)?;
-                self.ibox(0)?;
-                self.word_nbsp(&visibility_qualified(&item.vis, "existential type"))?;
+                self.head(&visibility_qualified(&item.vis, "existential type"))?;
                 self.print_name(item.name)?;
                 self.print_generic_params(&exist.generics.params)?;
                 self.end()?; // end the inner ibox
@@ -994,6 +990,10 @@ pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
             hir::ImplItemKind::Type(ref ty) => {
                 self.print_associated_type(ii.ident, None, Some(ty))?;
             }
+            hir::ImplItemKind::Existential(ref bounds) => {
+                self.word_space("existential")?;
+                self.print_associated_type(ii.ident, Some(bounds), None)?;
+            }
         }
         self.ann.post(self, NodeSubItem(ii.id))
     }
index 96d7cb6b041a83508866c568a7a48572a37ecf64..f8cd3b8a18a3bafed902e57f26f93490bb6159cb 100644 (file)
@@ -31,7 +31,8 @@
     kind,
     name,
     cfg,
-    foreign_module
+    foreign_module,
+    wasm_import_module
 });
 
 impl_stable_hash_for!(struct middle::cstore::ForeignModule {
index 28f3f20a82bc5d617af7b98cde64c89788ea8b1e..410d578d4044c9524101d400402e9fd53e9ffe37 100644 (file)
@@ -701,6 +701,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 impl_stable_hash_for!(enum hir::ImplItemKind {
     Const(t, body),
     Method(sig, body),
+    Existential(bounds),
     Type(t)
 });
 
@@ -890,6 +891,7 @@ fn hash_stable<W: StableHasherResult>(&self,
         mem::discriminant(self).hash_stable(hcx, hasher);
         match *self {
             hir::AssociatedItemKind::Const |
+            hir::AssociatedItemKind::Existential |
             hir::AssociatedItemKind::Type => {
                 // No fields to hash.
             }
@@ -997,6 +999,7 @@ fn to_stable_hash_key(&self,
     TyAlias(def_id),
     TraitAlias(def_id),
     AssociatedTy(def_id),
+    AssociatedExistential(def_id),
     PrimTy(prim_ty),
     TyParam(def_id),
     SelfTy(trait_def_id, impl_def_id),
index a3600c04800176d447f14787779c65d76ca765a1..cb685f83aba1eb670852fcb33970e6fb4a5a98f8 100644 (file)
@@ -1055,6 +1055,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 impl_stable_hash_for!(enum ty::AssociatedKind {
     Const,
     Method,
+    Existential,
     Type
 });
 
index 2924016670bf8377b3d4af5b0a7506b46d9318d9..ae4d88704a098e830c10bc3faafd19b5c1095f5d 100644 (file)
@@ -653,6 +653,7 @@ fn instantiate_anon_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: &T) ->
         let tcx = self.infcx.tcx;
         value.fold_with(&mut BottomUpFolder {
             tcx,
+            reg_op: |reg| reg,
             fldop: |ty| {
                 if let ty::TyAnon(def_id, substs) = ty.sty {
                     // Check that this is `impl Trait` type is
@@ -690,26 +691,35 @@ fn instantiate_anon_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: &T) ->
                     // }
                     // ```
                     if let Some(anon_node_id) = tcx.hir.as_local_node_id(def_id) {
-                        let anon_parent_def_id = match tcx.hir.expect_item(anon_node_id).node {
+                        let in_definition_scope = match tcx.hir.expect_item(anon_node_id).node {
+                            // impl trait
                             hir::ItemKind::Existential(hir::ExistTy {
                                 impl_trait_fn: Some(parent),
                                 ..
-                            }) => parent,
+                            }) => parent == self.parent_def_id,
+                            // named existential types
+                            hir::ItemKind::Existential(hir::ExistTy {
+                                impl_trait_fn: None,
+                                ..
+                            }) => may_define_existential_type(
+                                tcx,
+                                self.parent_def_id,
+                                anon_node_id,
+                            ),
                             _ => {
                                 let anon_parent_node_id = tcx.hir.get_parent(anon_node_id);
-                                tcx.hir.local_def_id(anon_parent_node_id)
+                                self.parent_def_id == tcx.hir.local_def_id(anon_parent_node_id)
                             },
                         };
-                        if self.parent_def_id == anon_parent_def_id {
+                        if in_definition_scope {
                             return self.fold_anon_ty(ty, def_id, substs);
                         }
 
                         debug!(
                             "instantiate_anon_types_in_map: \
-                             encountered anon with wrong parent \
-                             def_id={:?} \
-                             anon_parent_def_id={:?}",
-                            def_id, anon_parent_def_id
+                             encountered anon outside it's definition scope \
+                             def_id={:?}",
+                            def_id,
                         );
                     }
                 }
@@ -742,6 +752,10 @@ fn fold_anon_ty(
         let ty_var = infcx.next_ty_var(TypeVariableOrigin::TypeInference(span));
 
         let predicates_of = tcx.predicates_of(def_id);
+        debug!(
+            "instantiate_anon_types: predicates: {:#?}",
+            predicates_of,
+        );
         let bounds = predicates_of.instantiate(tcx, substs);
         debug!("instantiate_anon_types: bounds={:?}", bounds);
 
@@ -751,6 +765,18 @@ fn fold_anon_ty(
             required_region_bounds
         );
 
+        // make sure that we are in fact defining the *entire* type
+        // e.g. `existential type Foo<T: Bound>: Bar;` needs to be
+        // defined by a function like `fn foo<T: Bound>() -> Foo<T>`.
+        debug!(
+            "instantiate_anon_types: param_env: {:#?}",
+            self.param_env,
+        );
+        debug!(
+            "instantiate_anon_types: generics: {:#?}",
+            tcx.generics_of(def_id),
+        );
+
         self.anon_types.insert(
             def_id,
             AnonTypeDecl {
@@ -778,3 +804,42 @@ fn fold_anon_ty(
         ty_var
     }
 }
+
+/// Whether `anon_node_id` is a sibling or a child of a sibling of `def_id`
+///
+/// ```rust
+/// pub mod foo {
+///     pub mod bar {
+///         pub existential type Baz;
+///
+///         fn f1() -> Baz { .. }
+///     }
+///
+///     fn f2() -> bar::Baz { .. }
+/// }
+/// ```
+///
+/// Here, `def_id` will be the `DefId` of the existential type `Baz`.
+/// `anon_node_id` is the `NodeId` of the reference to Baz -- so either the return type of f1 or f2.
+/// We will return true if the reference is within the same module as the existential type
+/// So true for f1, false for f2.
+pub fn may_define_existential_type(
+    tcx: TyCtxt,
+    def_id: DefId,
+    anon_node_id: ast::NodeId,
+) -> bool {
+    let mut node_id = tcx
+        .hir
+        .as_local_node_id(def_id)
+        .unwrap();
+    // named existential types can be defined by any siblings or
+    // children of siblings
+    let mod_id = tcx.hir.get_parent(anon_node_id);
+    // so we walk up the node tree until we hit the root or the parent
+    // of the anon type
+    while node_id != mod_id && node_id != ast::CRATE_NODE_ID {
+        node_id = tcx.hir.get_parent(node_id);
+    }
+    // syntactically we are allowed to define the concrete type
+    node_id == mod_id
+}
index 8da0dc365b04e0d1edded2db941b6908f12ae292..1ec9c9489e9b7b60c17e0d3f0df405226d184a7e 100644 (file)
@@ -279,7 +279,9 @@ fn trait_item_scope_tag(item: &hir::TraitItem) -> &'static str {
     fn impl_item_scope_tag(item: &hir::ImplItem) -> &'static str {
         match item.node {
             hir::ImplItemKind::Method(..) => "method body",
-            hir::ImplItemKind::Const(..) | hir::ImplItemKind::Type(_) => "associated item",
+            hir::ImplItemKind::Const(..) |
+            hir::ImplItemKind::Existential(..) |
+            hir::ImplItemKind::Type(..) => "associated item",
         }
     }
 
index 5b5ae6473f84011cdf3215cc4d3a7e8e532d19f1..9283705b7b78e89dd5f23ff88939774b1dd43c0c 100644 (file)
@@ -562,36 +562,25 @@ pub fn type_is_unconstrained_numeric(&'a self, ty: Ty) -> UnconstrainedNumeric {
     }
 
     pub fn unsolved_variables(&self) -> Vec<Ty<'tcx>> {
-        let mut variables = Vec::new();
-
-        {
-            let mut type_variables = self.type_variables.borrow_mut();
-            variables.extend(
-                type_variables
-                    .unsolved_variables()
-                    .into_iter()
-                    .map(|t| self.tcx.mk_var(t)));
-        }
-
-        {
-            let mut int_unification_table = self.int_unification_table.borrow_mut();
-            variables.extend(
+        let mut type_variables = self.type_variables.borrow_mut();
+        let mut int_unification_table = self.int_unification_table.borrow_mut();
+        let mut float_unification_table = self.float_unification_table.borrow_mut();
+
+        type_variables
+            .unsolved_variables()
+            .into_iter()
+            .map(|t| self.tcx.mk_var(t))
+            .chain(
                 (0..int_unification_table.len())
                     .map(|i| ty::IntVid { index: i as u32 })
                     .filter(|&vid| int_unification_table.probe_value(vid).is_none())
-                    .map(|v| self.tcx.mk_int_var(v)));
-        }
-
-        {
-            let mut float_unification_table = self.float_unification_table.borrow_mut();
-            variables.extend(
+                    .map(|v| self.tcx.mk_int_var(v))
+            ).chain(
                 (0..float_unification_table.len())
                     .map(|i| ty::FloatVid { index: i as u32 })
                     .filter(|&vid| float_unification_table.probe_value(vid).is_none())
-                    .map(|v| self.tcx.mk_float_var(v)));
-        }
-
-        return variables;
+                    .map(|v| self.tcx.mk_float_var(v))
+            ).collect()
     }
 
     fn combine_fields(&'a self, trace: TypeTrace<'tcx>, param_env: ty::ParamEnv<'tcx>)
index e3d35a7c105eab9b792a18c1c211401b9af675a2..8efce297a9117414117f48afddfd44980e6ed8bf 100644 (file)
@@ -41,7 +41,7 @@
 use session::{Session, DiagnosticMessageId};
 use std::hash;
 use syntax::ast;
-use syntax::codemap::MultiSpan;
+use syntax::codemap::{MultiSpan, ExpnFormat};
 use syntax::edition::Edition;
 use syntax::symbol::Symbol;
 use syntax::visit as ast_visit;
@@ -572,6 +572,22 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
                                future_incompatible.reference);
         err.warn(&explanation);
         err.note(&citation);
+
+    // If this lint is *not* a future incompatibility warning then we want to be
+    // sure to not be too noisy in some situations. If this code originates in a
+    // foreign macro, aka something that this crate did not itself author, then
+    // it's likely that there's nothing this crate can do about it. We probably
+    // want to skip the lint entirely.
+    //
+    // For some lints though (like unreachable code) there's clear actionable
+    // items to take care of (delete the macro invocation). As a result we have
+    // a few lints we whitelist here for allowing a lint even though it's in a
+    // foreign macro invocation.
+    } else if lint_id != LintId::of(builtin::UNREACHABLE_CODE) &&
+        lint_id != LintId::of(builtin::DEPRECATED) {
+        if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
+            err.cancel();
+        }
     }
 
     return err
@@ -673,3 +689,32 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
 pub fn provide(providers: &mut Providers) {
     providers.lint_levels = lint_levels;
 }
+
+/// Returns whether `span` originates in a foreign crate's external macro.
+///
+/// This is used to test whether a lint should be entirely aborted above.
+pub fn in_external_macro(sess: &Session, span: Span) -> bool {
+    let info = match span.ctxt().outer().expn_info() {
+        Some(info) => info,
+        // no ExpnInfo means this span doesn't come from a macro
+        None => return false,
+    };
+
+    match info.format {
+        ExpnFormat::MacroAttribute(..) => return true, // definitely a plugin
+        ExpnFormat::CompilerDesugaring(_) => return true, // well, it's "external"
+        ExpnFormat::MacroBang(..) => {} // check below
+    }
+
+    let def_site = match info.def_site {
+        Some(span) => span,
+        // no span for the def_site means it's an external macro
+        None => return true,
+    };
+
+    match sess.codemap().span_to_snippet(def_site) {
+        Ok(code) => !code.starts_with("macro_rules"),
+        // no snippet = external macro or compiler-builtin expansion
+        Err(_) => true,
+    }
+}
index 12c8d07eb00f0cdbe59688fa4ce384fa402c3b97..54169acac46acabb00e36be540a6f64aa9e58591 100644 (file)
@@ -128,9 +128,10 @@ pub enum NativeLibraryKind {
 #[derive(Clone, RustcEncodable, RustcDecodable)]
 pub struct NativeLibrary {
     pub kind: NativeLibraryKind,
-    pub name: Symbol,
+    pub name: Option<Symbol>,
     pub cfg: Option<ast::MetaItem>,
     pub foreign_module: Option<DefId>,
+    pub wasm_import_module: Option<Symbol>,
 }
 
 #[derive(Clone, Hash, RustcEncodable, RustcDecodable)]
index 126abb0d359bb0fd63614bad796070b0205aef9e..e4fc1b09fcebc7dd475e6c6fea82cc2b1705ea06 100644 (file)
@@ -391,16 +391,12 @@ fn visit_impl_item(&mut self, _item: &hir::ImplItem) {
 fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                       access_levels: &privacy::AccessLevels,
                                       krate: &hir::Crate)
-                                      -> Vec<ast::NodeId> {
-    let mut worklist = Vec::new();
-    for (id, _) in &access_levels.map {
-        worklist.push(*id);
-    }
-
-    // Seed entry point
-    if let Some((id, _, _)) = *tcx.sess.entry_fn.borrow() {
-        worklist.push(id);
-    }
+                                      -> Vec<ast::NodeId>
+{
+    let worklist = access_levels.map.iter().map(|(&id, _)| id).chain(
+        // Seed entry point
+        tcx.sess.entry_fn.borrow().map(|(id, _, _)| id)
+    ).collect::<Vec<_>>();
 
     // Seed implemented trait items
     let mut life_seeder = LifeSeeder {
@@ -617,6 +613,7 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
                 }
                 self.visit_nested_body(body_id)
             }
+            hir::ImplItemKind::Existential(..) |
             hir::ImplItemKind::Type(..) => {}
         }
     }
index a504697008ef4b93de0fa81fca11b6f7088ef870..7f4b0bb126bbe46fe1173e74eadae93361e03d96 100644 (file)
@@ -210,6 +210,7 @@ fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool {
                             }
                         }
                     }
+                    hir::ImplItemKind::Existential(..) |
                     hir::ImplItemKind::Type(_) => false,
                 }
             }
@@ -319,6 +320,7 @@ fn propagate_node(&mut self, node: &hir_map::Node<'tcx>,
                             self.visit_nested_body(body)
                         }
                     }
+                    hir::ImplItemKind::Existential(..) |
                     hir::ImplItemKind::Type(_) => {}
                 }
             }
index 05a6cd9c243d25c1e5d69a40c4ea5f4927a34820..39a57e985e89bd6e2f1673c74e48401bd365c4cd 100644 (file)
@@ -627,6 +627,30 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
             }
             hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
                 if let Def::Existential(exist_ty_did) = path.def {
+                    let id = self.tcx.hir.as_local_node_id(exist_ty_did).unwrap();
+
+                    // Resolve the lifetimes in the bounds to the lifetime defs in the generics.
+                    // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
+                    // `abstract type MyAnonTy<'b>: MyTrait<'b>;`
+                    //                          ^            ^ this gets resolved in the scope of
+                    //                                         the exist_ty generics
+                    let (generics, bounds) = match self.tcx.hir.expect_item(id).node {
+                        // named existential types don't need these hacks
+                        hir::ItemKind::Existential(hir::ExistTy{ impl_trait_fn: None, .. }) => {
+                            intravisit::walk_ty(self, ty);
+                            return;
+                        },
+                        hir::ItemKind::Existential(hir::ExistTy{
+                            ref generics,
+                            ref bounds,
+                            ..
+                        }) => (
+                            generics,
+                            bounds,
+                        ),
+                        ref i => bug!("impl Trait pointed to non-existential type?? {:#?}", i),
+                    };
+
                     assert!(exist_ty_did.is_local());
                     // Resolve the lifetimes that are applied to the existential type.
                     // These are resolved in the current scope.
@@ -667,23 +691,6 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
                         }
                     }
 
-                    let id = self.tcx.hir.as_local_node_id(exist_ty_did).unwrap();
-
-                    // Resolve the lifetimes in the bounds to the lifetime defs in the generics.
-                    // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to
-                    // `abstract type MyAnonTy<'b>: MyTrait<'b>;`
-                    //                          ^            ^ this gets resolved in the scope of
-                    //                                         the exist_ty generics
-                    let (generics, bounds) = match self.tcx.hir.expect_item(id).node {
-                        hir::ItemKind::Existential(
-                            hir::ExistTy { ref generics, ref bounds, .. }
-                        ) => (
-                            generics,
-                            bounds,
-                        ),
-                        ref i => bug!("impl Trait pointed to non-existential type?? {:#?}", i),
-                    };
-
                     // We want to start our early-bound indices at the end of the parent scope,
                     // not including any parent `impl Trait`s.
                     let mut index = self.next_early_index_for_abstract_type();
@@ -847,6 +854,35 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
                     this.visit_ty(ty);
                 });
             }
+            Existential(ref bounds) => {
+                let generics = &impl_item.generics;
+                let mut index = self.next_early_index();
+                let mut next_early_index = index;
+                debug!("visit_ty: index = {}", index);
+                let lifetimes = generics.params.iter().filter_map(|param| match param.kind {
+                    GenericParamKind::Lifetime { .. } => {
+                        Some(Region::early(&self.tcx.hir, &mut index, param))
+                    }
+                    GenericParamKind::Type { .. } => {
+                        next_early_index += 1;
+                        None
+                    }
+                }).collect();
+
+                let scope = Scope::Binder {
+                    lifetimes,
+                    next_early_index,
+                    s: self.scope,
+                    track_lifetime_uses: true,
+                    abstract_type_parent: true,
+                };
+                self.with(scope, |_old_scope, this| {
+                    this.visit_generics(generics);
+                    for bound in bounds {
+                        this.visit_param_bound(bound);
+                    }
+                });
+            }
             Const(_, _) => {
                 // Only methods and types support generics.
                 assert!(impl_item.generics.params.is_empty());
@@ -1213,6 +1249,7 @@ fn compute_object_lifetime_defaults(
             hir::ItemKind::Struct(_, ref generics)
             | hir::ItemKind::Union(_, ref generics)
             | hir::ItemKind::Enum(_, ref generics)
+            | hir::ItemKind::Existential(hir::ExistTy { ref generics, impl_trait_fn: None, .. })
             | hir::ItemKind::Ty(_, ref generics)
             | hir::ItemKind::Trait(_, _, ref generics, ..) => {
                 let result = object_lifetime_defaults_for_item(tcx, generics);
index 1380d10e493a8deaca0c5d2cb667406724181828..e4484041b065ce829306f816f8a7e04e1212482c 100644 (file)
@@ -200,15 +200,18 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
 ///////////////////////////////////////////////////////////////////////////
 // Some sample folders
 
-pub struct BottomUpFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a, F>
-    where F: FnMut(Ty<'tcx>) -> Ty<'tcx>
+pub struct BottomUpFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a, F, G>
+    where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
+          G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
 {
     pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
     pub fldop: F,
+    pub reg_op: G,
 }
 
-impl<'a, 'gcx, 'tcx, F> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx, 'tcx, F>
+impl<'a, 'gcx, 'tcx, F, G> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'a, 'gcx, 'tcx, F, G>
     where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
+          G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
 {
     fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx }
 
@@ -216,6 +219,11 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
         let t1 = ty.super_fold_with(self);
         (self.fldop)(t1)
     }
+
+    fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
+        let r = r.super_fold_with(self);
+        (self.reg_op)(r)
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////
index 95da68bc9ffc2e147125a0300eff1a13a4a191c6..a44962c77b5f5de489bb0692aee56ba3fe807ffb 100644 (file)
@@ -212,6 +212,7 @@ pub fn push_item_path<T>(self, buffer: &mut T, def_id: DefId)
             data @ DefPathData::Trait(..) |
             data @ DefPathData::AssocTypeInTrait(..) |
             data @ DefPathData::AssocTypeInImpl(..) |
+            data @ DefPathData::AssocExistentialInImpl(..) |
             data @ DefPathData::ValueNs(..) |
             data @ DefPathData::Module(..) |
             data @ DefPathData::TypeParam(..) |
index 5aa6542a027da1996539e32fb9ba87dbe76e6e49..178f0d3cdcbc109cdfd3df17bc4346dcb7c190ed 100644 (file)
@@ -192,6 +192,7 @@ pub struct AssociatedItem {
 pub enum AssociatedKind {
     Const,
     Method,
+    Existential,
     Type
 }
 
@@ -201,6 +202,7 @@ pub fn def(&self) -> Def {
             AssociatedKind::Const => Def::AssociatedConst(self.def_id),
             AssociatedKind::Method => Def::Method(self.def_id),
             AssociatedKind::Type => Def::AssociatedTy(self.def_id),
+            AssociatedKind::Existential => Def::AssociatedExistential(self.def_id),
         }
     }
 
@@ -208,7 +210,8 @@ pub fn def(&self) -> Def {
     /// for !
     pub fn relevant_for_never<'tcx>(&self) -> bool {
         match self.kind {
-            AssociatedKind::Const => true,
+            AssociatedKind::Existential |
+            AssociatedKind::Const |
             AssociatedKind::Type => true,
             // FIXME(canndrew): Be more thorough here, check if any argument is uninhabited.
             AssociatedKind::Method => !self.method_has_self_argument,
@@ -225,6 +228,7 @@ pub fn signature<'a, 'tcx>(&self, tcx: &TyCtxt<'a, 'tcx, 'tcx>) -> String {
                 format!("{}", tcx.fn_sig(self.def_id).skip_binder())
             }
             ty::AssociatedKind::Type => format!("type {};", self.ident),
+            ty::AssociatedKind::Existential => format!("existential type {};", self.ident),
             ty::AssociatedKind::Const => {
                 format!("const {}: {:?};", self.ident, tcx.type_of(self.def_id))
             }
@@ -2491,6 +2495,7 @@ fn associated_item_from_trait_item_ref(self,
                 (ty::AssociatedKind::Method, has_self)
             }
             hir::AssociatedItemKind::Type => (ty::AssociatedKind::Type, false),
+            hir::AssociatedItemKind::Existential => bug!("only impls can have existentials"),
         };
 
         AssociatedItem {
@@ -2516,6 +2521,7 @@ fn associated_item_from_impl_item_ref(self,
                 (ty::AssociatedKind::Method, has_self)
             }
             hir::AssociatedItemKind::Type => (ty::AssociatedKind::Type, false),
+            hir::AssociatedItemKind::Existential => (ty::AssociatedKind::Existential, false),
         };
 
         AssociatedItem {
@@ -2850,14 +2856,25 @@ fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option
         })
 }
 
+/// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition
+pub fn is_impl_trait_defn(tcx: TyCtxt, def_id: DefId) -> Option<DefId> {
+    if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
+        if let hir::map::NodeItem(item) = tcx.hir.get(node_id) {
+            if let hir::ItemKind::Existential(ref exist_ty) = item.node {
+                return exist_ty.impl_trait_fn;
+            }
+        }
+    }
+    None
+}
+
 /// See `ParamEnv` struct def'n for details.
 fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                        def_id: DefId)
                        -> ParamEnv<'tcx> {
 
-    // The param_env of an existential type is its parent's param_env
-    if let Some(Def::Existential(_)) = tcx.describe_def(def_id) {
-        let parent = tcx.parent_def_id(def_id).expect("impl trait item w/o a parent");
+    // The param_env of an impl Trait type is its defining function's param_env
+    if let Some(parent) = is_impl_trait_defn(tcx, def_id) {
         return param_env(tcx, parent);
     }
     // Compute the bounds on Self and the type parameters.
index 3581dd87f6f8d80d615b6ac47194faf1dcf98ea0..2fb289d023606ab821615981d27d6cddfcd92233 100644 (file)
 // Queries marked with `fatal_cycle` do not need the latter implementation,
 // as they will raise an fatal error on query cycles instead.
 define_queries! { <'tcx>
-    /// Records the type of every item.
-    [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
-
-    /// Maps from the def-id of an item (trait/struct/enum/fn) to its
-    /// associated generics.
-    [] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
-
-    /// Maps from the def-id of an item (trait/struct/enum/fn) to the
-    /// predicates (where clauses) that must be proven true in order
-    /// to reference it. This is almost always the "predicates query"
-    /// that you want.
-    ///
-    /// `predicates_of` builds on `predicates_defined_on` -- in fact,
-    /// it is almost always the same as that query, except for the
-    /// case of traits. For traits, `predicates_of` contains
-    /// an additional `Self: Trait<...>` predicate that users don't
-    /// actually write. This reflects the fact that to invoke the
-    /// trait (e.g., via `Default::default`) you must supply types
-    /// that actually implement the trait. (However, this extra
-    /// predicate gets in the way of some checks, which are intended
-    /// to operate over only the actual where-clauses written by the
-    /// user.)
-    [] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
-
-    /// Maps from the def-id of an item (trait/struct/enum/fn) to the
-    /// predicates (where clauses) directly defined on it. This is
-    /// equal to the `explicit_predicates_of` predicates plus the
-    /// `inferred_outlives_of` predicates.
-    [] fn predicates_defined_on: PredicatesDefinedOnItem(DefId) -> ty::GenericPredicates<'tcx>,
-
-    /// Returns the predicates written explicit by the user.
-    [] fn explicit_predicates_of: ExplicitPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
-
-    /// Returns the inferred outlives predicates (e.g., for `struct
-    /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
-    [] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Lrc<Vec<ty::Predicate<'tcx>>>,
-
-    /// Maps from the def-id of a trait to the list of
-    /// super-predicates. This is a subset of the full list of
-    /// predicates. We store these in a separate map because we must
-    /// evaluate them even during type conversion, often before the
-    /// full predicates are available (note that supertraits have
-    /// additional acyclicity requirements).
-    [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
-
-    /// To avoid cycles within the predicates of a single item we compute
-    /// per-type-parameter predicates for resolving `T::AssocTy`.
-    [] fn type_param_predicates: type_param_predicates((DefId, DefId))
-        -> ty::GenericPredicates<'tcx>,
-
-    [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
-    [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
-    [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
-    [] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
-    [] fn adt_dtorck_constraint: DtorckConstraint(
-        DefId
-    ) -> Result<DtorckConstraint<'tcx>, NoSolution>,
-
-    /// True if this is a const fn
-    [] fn is_const_fn: IsConstFn(DefId) -> bool,
-
-    /// True if this is a foreign item (i.e., linked via `extern { ... }`).
-    [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
-
-    /// Get a map with the variance of every item; use `item_variance`
-    /// instead.
-    [] fn crate_variances: crate_variances(CrateNum) -> Lrc<ty::CrateVariancesMap>,
-
-    /// Maps from def-id of a type or region parameter to its
-    /// (inferred) variance.
-    [] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,
-
-    /// Maps from def-id of a type to its (inferred) outlives.
-    [] fn inferred_outlives_crate: InferredOutlivesCrate(CrateNum)
-        -> Lrc<ty::CratePredicatesMap<'tcx>>,
-
-    /// Maps from an impl/trait def-id to a list of the def-ids of its items
-    [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc<Vec<DefId>>,
-
-    /// Maps from a trait item to the trait item "descriptor"
-    [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
-
-    [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
-    [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
-
-    /// Maps a DefId of a type to a list of its inherent impls.
-    /// Contains implementations of methods that are inherent to a type.
-    /// Methods in these implementations don't need to be exported.
-    [] fn inherent_impls: InherentImpls(DefId) -> Lrc<Vec<DefId>>,
-
-    /// Set of all the def-ids in this crate that have MIR associated with
-    /// them. This includes all the body owners, but also things like struct
-    /// constructors.
-    [] fn mir_keys: mir_keys(CrateNum) -> Lrc<DefIdSet>,
-
-    /// Maps DefId's that have an associated Mir to the result
-    /// of the MIR qualify_consts pass. The actual meaning of
-    /// the value isn't known except to the pass itself.
-    [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc<IdxSetBuf<mir::Local>>),
-
-    /// Fetch the MIR for a given def-id right after it's built - this includes
-    /// unreachable code.
-    [] fn mir_built: MirBuilt(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
-
-    /// Fetch the MIR for a given def-id up till the point where it is
-    /// ready for const evaluation.
-    ///
-    /// See the README for the `mir` module for details.
-    [] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
-
-    [] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
-
-    /// MIR after our optimization passes have run. This is MIR that is ready
-    /// for codegen. This is also the only query that can fetch non-local MIR, at present.
-    [] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
-
-    /// The result of unsafety-checking this def-id.
-    [] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
-
-    /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
-    [] fn unsafe_derive_on_repr_packed: UnsafeDeriveOnReprPacked(DefId) -> (),
-
-    /// The signature of functions and closures.
-    [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
-
-    /// Caches CoerceUnsized kinds for impls on custom types.
-    [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
-        -> ty::adjustment::CoerceUnsizedInfo,
-
-    [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
-
-    [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
-
-    [] fn used_trait_imports: UsedTraitImports(DefId) -> Lrc<DefIdSet>,
-
-    [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
-
-    [] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
-
-    [] fn borrowck: BorrowCheck(DefId) -> Lrc<BorrowCheckResult>,
-
-    /// Borrow checks the function body. If this is a closure, returns
-    /// additional requirements that the closure's creator must verify.
-    [] fn mir_borrowck: MirBorrowCheck(DefId) -> mir::BorrowCheckResult<'tcx>,
-
-    /// Gets a complete map from all types to their inherent impls.
-    /// Not meant to be used directly outside of coherence.
-    /// (Defined only for LOCAL_CRATE)
-    [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
-
-    /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
-    /// Not meant to be used directly outside of coherence.
-    /// (Defined only for LOCAL_CRATE)
-    [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
-
-    /// Results of evaluating const items or constants embedded in
-    /// other items (such as enum variant explicit discriminants).
-    [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
-        -> ConstEvalResult<'tcx>,
-
-    /// Converts a constant value to an constant allocation
-    [] fn const_value_to_allocation: const_value_to_allocation(
-        &'tcx ty::Const<'tcx>
-    ) -> &'tcx Allocation,
-
-    [] fn check_match: CheckMatch(DefId)
-        -> Result<(), ErrorReported>,
-
-    /// Performs the privacy check and computes "access levels".
-    [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
-
-    [] fn reachable_set: reachability_dep_node(CrateNum) -> ReachableSet,
-
-    /// Per-body `region::ScopeTree`. The `DefId` should be the owner-def-id for the body;
-    /// in the case of closures, this will be redirected to the enclosing function.
-    [] fn region_scope_tree: RegionScopeTree(DefId) -> Lrc<region::ScopeTree>,
-
-    [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
-
-    [] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
-    [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
-
-    [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
-    [] fn def_span: DefSpan(DefId) -> Span,
-    [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
-    [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
-    [] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
-    [] fn codegen_fn_attrs: codegen_fn_attrs(DefId) -> CodegenFnAttrs,
-    [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
-    /// Gets the rendered value of the specified constant or associated constant.
-    /// Used by rustdoc.
-    [] fn rendered_const: RenderedConst(DefId) -> String,
-    [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
-    [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
-    [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
-    [] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
-    [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
-    [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
-                          -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>,
-
-    [] fn codegen_fulfill_obligation: fulfill_obligation_dep_node(
-        (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Vtable<'tcx, ()>,
-    [] fn trait_impls_of: TraitImpls(DefId) -> Lrc<ty::trait_def::TraitImpls>,
-    [] fn specialization_graph_of: SpecializationGraph(DefId) -> Lrc<specialization_graph::Graph>,
-    [] fn is_object_safe: ObjectSafety(DefId) -> bool,
-
-    // Get the ParameterEnvironment for a given item; this environment
-    // will be in "user-facing" mode, meaning that it is suitabe for
-    // type-checking etc, and it does not normalize specializable
-    // associated types. This is almost always what you want,
-    // unless you are doing MIR optimizations, in which case you
-    // might want to use `reveal_all()` method to change modes.
-    [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
-
-    // Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
-    // `ty.is_copy()`, etc, since that will prune the environment where possible.
-    [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
-    [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
-    [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
-    [] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
-    [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
-                                  -> Result<&'tcx ty::layout::LayoutDetails,
-                                            ty::layout::LayoutError<'tcx>>,
-
-    [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
-                                    -> Lrc<Vec<(CrateNum, LinkagePreference)>>,
-
-    [fatal_cycle] fn is_panic_runtime: IsPanicRuntime(CrateNum) -> bool,
-    [fatal_cycle] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
-    [fatal_cycle] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
-    [fatal_cycle] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
-    [fatal_cycle] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
-    [fatal_cycle] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
-    [fatal_cycle] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
-
-    [] fn extern_crate: ExternCrate(DefId) -> Lrc<Option<ExternCrate>>,
-
-    [] fn specializes: specializes_node((DefId, DefId)) -> bool,
-    [] fn in_scope_traits_map: InScopeTraits(DefIndex)
-        -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>>,
-    [] fn module_exports: ModuleExports(DefId) -> Option<Lrc<Vec<Export>>>,
-    [] fn lint_levels: lint_levels_node(CrateNum) -> Lrc<lint::LintLevelMap>,
-
-    [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
-
-    [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
-    [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
-    [] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
-
-    // The DefIds of all non-generic functions and statics in the given crate
-    // that can be reached from outside the crate.
-    //
-    // We expect this items to be available for being linked to.
-    //
-    // This query can also be called for LOCAL_CRATE. In this case it will
-    // compute which items will be reachable to other crates, taking into account
-    // the kind of crate that is currently compiled. Crates with only a
-    // C interface have fewer reachable things.
-    //
-    // Does not include external symbols that don't have a corresponding DefId,
-    // like the compiler-generated `main` function and so on.
-    [] fn reachable_non_generics: ReachableNonGenerics(CrateNum)
-        -> Lrc<DefIdMap<SymbolExportLevel>>,
-    [] fn is_reachable_non_generic: IsReachableNonGeneric(DefId) -> bool,
-    [] fn is_unreachable_local_definition: IsUnreachableLocalDefinition(DefId) -> bool,
-
-    [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum)
-        -> Lrc<DefIdMap<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>>,
-    [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId)
-        -> Option<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>,
-
-    [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc<Vec<NativeLibrary>>,
-
-    [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc<Vec<ForeignModule>>,
-
-    [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
-    [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
-    [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator,
-    [] fn crate_hash: CrateHash(CrateNum) -> Svh,
-    [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
-    [] fn extra_filename: ExtraFileName(CrateNum) -> String,
-
-    [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
-        -> Lrc<Vec<DefId>>,
-    [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
-        -> Lrc<Vec<DefId>>,
-
-    [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum)
-        -> Lrc<FxHashSet<DefId>>,
-    [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
-    [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
-    [] fn native_library_kind: NativeLibraryKind(DefId)
-        -> Option<NativeLibraryKind>,
-    [] fn link_args: link_args_node(CrateNum) -> Lrc<Vec<String>>,
-
-    // Lifetime resolution. See `middle::resolve_lifetimes`.
-    [] fn resolve_lifetimes: ResolveLifetimes(CrateNum) -> Lrc<ResolveLifetimes>,
-    [] fn named_region_map: NamedRegion(DefIndex) ->
-        Option<Lrc<FxHashMap<ItemLocalId, Region>>>,
-    [] fn is_late_bound_map: IsLateBound(DefIndex) ->
-        Option<Lrc<FxHashSet<ItemLocalId>>>,
-    [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
-        -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>>,
-
-    [] fn visibility: Visibility(DefId) -> ty::Visibility,
-    [] fn dep_kind: DepKind(CrateNum) -> DepKind,
-    [] fn crate_name: CrateName(CrateNum) -> Symbol,
-    [] fn item_children: ItemChildren(DefId) -> Lrc<Vec<Export>>,
-    [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
-
-    [] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
-    [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
-    [] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
-    [] fn visible_parent_map: visible_parent_map_node(CrateNum)
-        -> Lrc<DefIdMap<DefId>>,
-    [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
-    [] fn used_crate_source: UsedCrateSource(CrateNum) -> Lrc<CrateSource>,
-    [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
-
-    [] fn freevars: Freevars(DefId) -> Option<Lrc<Vec<hir::Freevar>>>,
-    [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
-    [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
-        -> Lrc<Vec<(DefId, Span)>>,
-
-    [] fn stability_index: stability_index_node(CrateNum) -> Lrc<stability::Index<'tcx>>,
-    [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
-
-    /// A vector of every trait accessible in the whole crate
-    /// (i.e. including those from subcrates). This is used only for
-    /// error reporting.
-    [] fn all_traits: all_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
-
-    [] fn exported_symbols: ExportedSymbols(CrateNum)
-        -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>>,
-    [] fn collect_and_partition_mono_items:
-        collect_and_partition_mono_items_node(CrateNum)
-        -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
-    [] fn is_codegened_item: IsCodegenedItem(DefId) -> bool,
-    [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
-    [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats,
-    [] fn output_filenames: output_filenames_node(CrateNum)
-        -> Arc<OutputFilenames>,
-
-    // Erases regions from `ty` to yield a new type.
-    // Normally you would just use `tcx.erase_regions(&value)`,
-    // however, which uses this query as a kind of cache.
-    [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>,
-
-    /// Do not call this query directly: invoke `normalize` instead.
-    [] fn normalize_projection_ty: NormalizeProjectionTy(
-        CanonicalProjectionGoal<'tcx>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, NormalizationResult<'tcx>>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
-    [] fn normalize_ty_after_erasing_regions: NormalizeTyAfterErasingRegions(
-        ParamEnvAnd<'tcx, Ty<'tcx>>
-    ) -> Ty<'tcx>,
-
-    /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
-    [] fn dropck_outlives: DropckOutlives(
-        CanonicalTyGoal<'tcx>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
-    /// `infcx.predicate_must_hold()` instead.
-    [] fn evaluate_obligation: EvaluateObligation(
-        CanonicalPredicateGoal<'tcx>
-    ) -> Result<traits::EvaluationResult, traits::OverflowError>,
-
-    /// Do not call this query directly: part of the `Eq` type-op
-    [] fn type_op_eq: TypeOpEq(
-        CanonicalTypeOpEqGoal<'tcx>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: part of the `Subtype` type-op
-    [] fn type_op_subtype: TypeOpSubtype(
-        CanonicalTypeOpSubtypeGoal<'tcx>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: part of the `ProvePredicate` type-op
-    [] fn type_op_prove_predicate: TypeOpProvePredicate(
-        CanonicalTypeOpProvePredicateGoal<'tcx>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: part of the `Normalize` type-op
-    [] fn type_op_normalize_ty: TypeOpNormalizeTy(
-        CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, Ty<'tcx>>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: part of the `Normalize` type-op
-    [] fn type_op_normalize_predicate: TypeOpNormalizePredicate(
-        CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::Predicate<'tcx>>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: part of the `Normalize` type-op
-    [] fn type_op_normalize_poly_fn_sig: TypeOpNormalizePolyFnSig(
-        CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::PolyFnSig<'tcx>>>>,
-        NoSolution,
-    >,
-
-    /// Do not call this query directly: part of the `Normalize` type-op
-    [] fn type_op_normalize_fn_sig: TypeOpNormalizeFnSig(
-        CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
-    ) -> Result<
-        Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::FnSig<'tcx>>>>,
-        NoSolution,
-    >,
-
-    [] fn substitute_normalize_and_test_predicates:
-        substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool,
-
-    [] fn target_features_whitelist:
-        target_features_whitelist_node(CrateNum) -> Lrc<FxHashMap<String, Option<String>>>,
-
-    // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
-    [] fn instance_def_size_estimate: instance_def_size_estimate_dep_node(ty::InstanceDef<'tcx>)
-        -> usize,
-
-    [] fn features_query: features_node(CrateNum) -> Lrc<feature_gate::Features>,
-
-    [] fn program_clauses_for: ProgramClausesFor(DefId) -> Clauses<'tcx>,
-
-    [] fn program_clauses_for_env: ProgramClausesForEnv(
-        ty::ParamEnv<'tcx>
-    ) -> Clauses<'tcx>,
-
-    [] fn wasm_import_module_map: WasmImportModuleMap(CrateNum)
-        -> Lrc<FxHashMap<DefId, String>>,
+    Other {
+        /// Records the type of every item.
+        [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
+
+        /// Maps from the def-id of an item (trait/struct/enum/fn) to its
+        /// associated generics.
+        [] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
+
+        /// Maps from the def-id of an item (trait/struct/enum/fn) to the
+        /// predicates (where clauses) that must be proven true in order
+        /// to reference it. This is almost always the "predicates query"
+        /// that you want.
+        ///
+        /// `predicates_of` builds on `predicates_defined_on` -- in fact,
+        /// it is almost always the same as that query, except for the
+        /// case of traits. For traits, `predicates_of` contains
+        /// an additional `Self: Trait<...>` predicate that users don't
+        /// actually write. This reflects the fact that to invoke the
+        /// trait (e.g., via `Default::default`) you must supply types
+        /// that actually implement the trait. (However, this extra
+        /// predicate gets in the way of some checks, which are intended
+        /// to operate over only the actual where-clauses written by the
+        /// user.)
+        [] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
+
+        /// Maps from the def-id of an item (trait/struct/enum/fn) to the
+        /// predicates (where clauses) directly defined on it. This is
+        /// equal to the `explicit_predicates_of` predicates plus the
+        /// `inferred_outlives_of` predicates.
+        [] fn predicates_defined_on: PredicatesDefinedOnItem(DefId) -> ty::GenericPredicates<'tcx>,
+
+        /// Returns the predicates written explicit by the user.
+        [] fn explicit_predicates_of: ExplicitPredicatesOfItem(DefId)
+            -> ty::GenericPredicates<'tcx>,
+
+        /// Returns the inferred outlives predicates (e.g., for `struct
+        /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
+        [] fn inferred_outlives_of: InferredOutlivesOf(DefId) -> Lrc<Vec<ty::Predicate<'tcx>>>,
+
+        /// Maps from the def-id of a trait to the list of
+        /// super-predicates. This is a subset of the full list of
+        /// predicates. We store these in a separate map because we must
+        /// evaluate them even during type conversion, often before the
+        /// full predicates are available (note that supertraits have
+        /// additional acyclicity requirements).
+        [] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
+
+        /// To avoid cycles within the predicates of a single item we compute
+        /// per-type-parameter predicates for resolving `T::AssocTy`.
+        [] fn type_param_predicates: type_param_predicates((DefId, DefId))
+            -> ty::GenericPredicates<'tcx>,
+
+        [] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
+        [] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
+        [] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
+        [] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
+        [] fn adt_dtorck_constraint: DtorckConstraint(
+            DefId
+        ) -> Result<DtorckConstraint<'tcx>, NoSolution>,
+
+        /// True if this is a const fn
+        [] fn is_const_fn: IsConstFn(DefId) -> bool,
+
+        /// True if this is a foreign item (i.e., linked via `extern { ... }`).
+        [] fn is_foreign_item: IsForeignItem(DefId) -> bool,
+
+        /// Get a map with the variance of every item; use `item_variance`
+        /// instead.
+        [] fn crate_variances: crate_variances(CrateNum) -> Lrc<ty::CrateVariancesMap>,
+
+        /// Maps from def-id of a type or region parameter to its
+        /// (inferred) variance.
+        [] fn variances_of: ItemVariances(DefId) -> Lrc<Vec<ty::Variance>>,
+    },
+
+    TypeChecking {
+        /// Maps from def-id of a type to its (inferred) outlives.
+        [] fn inferred_outlives_crate: InferredOutlivesCrate(CrateNum)
+            -> Lrc<ty::CratePredicatesMap<'tcx>>,
+    },
+
+    Other {
+        /// Maps from an impl/trait def-id to a list of the def-ids of its items
+        [] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Lrc<Vec<DefId>>,
+
+        /// Maps from a trait item to the trait item "descriptor"
+        [] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
+
+        [] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
+        [] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
+    },
+
+    TypeChecking {
+        /// Maps a DefId of a type to a list of its inherent impls.
+        /// Contains implementations of methods that are inherent to a type.
+        /// Methods in these implementations don't need to be exported.
+        [] fn inherent_impls: InherentImpls(DefId) -> Lrc<Vec<DefId>>,
+    },
+
+    Codegen {
+        /// Set of all the def-ids in this crate that have MIR associated with
+        /// them. This includes all the body owners, but also things like struct
+        /// constructors.
+        [] fn mir_keys: mir_keys(CrateNum) -> Lrc<DefIdSet>,
+
+        /// Maps DefId's that have an associated Mir to the result
+        /// of the MIR qualify_consts pass. The actual meaning of
+        /// the value isn't known except to the pass itself.
+        [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc<IdxSetBuf<mir::Local>>),
+
+        /// Fetch the MIR for a given def-id right after it's built - this includes
+        /// unreachable code.
+        [] fn mir_built: MirBuilt(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
+
+        /// Fetch the MIR for a given def-id up till the point where it is
+        /// ready for const evaluation.
+        ///
+        /// See the README for the `mir` module for details.
+        [] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
+
+        [] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
+
+        /// MIR after our optimization passes have run. This is MIR that is ready
+        /// for codegen. This is also the only query that can fetch non-local MIR, at present.
+        [] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
+    },
+
+    TypeChecking {
+        /// The result of unsafety-checking this def-id.
+        [] fn unsafety_check_result: UnsafetyCheckResult(DefId) -> mir::UnsafetyCheckResult,
+
+        /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
+        [] fn unsafe_derive_on_repr_packed: UnsafeDeriveOnReprPacked(DefId) -> (),
+
+        /// The signature of functions and closures.
+        [] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
+    },
+
+    Other {
+        /// Caches CoerceUnsized kinds for impls on custom types.
+        [] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
+            -> ty::adjustment::CoerceUnsizedInfo,
+    },
+
+    TypeChecking {
+        [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
+
+        [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
+    },
+
+    Other {
+        [] fn used_trait_imports: UsedTraitImports(DefId) -> Lrc<DefIdSet>,
+    },
+
+    TypeChecking {
+        [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
+
+        [] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
+    },
+
+    BorrowChecking {
+        [] fn borrowck: BorrowCheck(DefId) -> Lrc<BorrowCheckResult>,
+
+        /// Borrow checks the function body. If this is a closure, returns
+        /// additional requirements that the closure's creator must verify.
+        [] fn mir_borrowck: MirBorrowCheck(DefId) -> mir::BorrowCheckResult<'tcx>,
+    },
+
+    TypeChecking {
+        /// Gets a complete map from all types to their inherent impls.
+        /// Not meant to be used directly outside of coherence.
+        /// (Defined only for LOCAL_CRATE)
+        [] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
+
+        /// Checks all types in the krate for overlap in their inherent impls. Reports errors.
+        /// Not meant to be used directly outside of coherence.
+        /// (Defined only for LOCAL_CRATE)
+        [] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum)
+            -> (),
+    },
+
+    Other {
+        /// Results of evaluating const items or constants embedded in
+        /// other items (such as enum variant explicit discriminants).
+        [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
+            -> ConstEvalResult<'tcx>,
+
+        /// Converts a constant value to an constant allocation
+        [] fn const_value_to_allocation: const_value_to_allocation(
+            &'tcx ty::Const<'tcx>
+        ) -> &'tcx Allocation,
+    },
+
+    TypeChecking {
+        [] fn check_match: CheckMatch(DefId)
+            -> Result<(), ErrorReported>,
+
+        /// Performs the privacy check and computes "access levels".
+        [] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,
+    },
+
+    Other {
+        [] fn reachable_set: reachability_dep_node(CrateNum) -> ReachableSet,
+
+        /// Per-body `region::ScopeTree`. The `DefId` should be the owner-def-id for the body;
+        /// in the case of closures, this will be redirected to the enclosing function.
+        [] fn region_scope_tree: RegionScopeTree(DefId) -> Lrc<region::ScopeTree>,
+
+        [] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
+
+        [] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
+        [] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
+
+        [] fn describe_def: DescribeDef(DefId) -> Option<Def>,
+        [] fn def_span: DefSpan(DefId) -> Span,
+        [] fn lookup_stability: LookupStability(DefId) -> Option<&'tcx attr::Stability>,
+        [] fn lookup_deprecation_entry: LookupDeprecationEntry(DefId) -> Option<DeprecationEntry>,
+        [] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
+    },
+
+    Codegen {
+        [] fn codegen_fn_attrs: codegen_fn_attrs(DefId) -> CodegenFnAttrs,
+    },
+
+    Other {
+        [] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
+        /// Gets the rendered value of the specified constant or associated constant.
+        /// Used by rustdoc.
+        [] fn rendered_const: RenderedConst(DefId) -> String,
+        [] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
+    },
+
+    TypeChecking {
+        [] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
+        [] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
+        [] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
+    },
+
+    Codegen {
+        [] fn is_mir_available: IsMirAvailable(DefId) -> bool,
+    },
+
+    Other {
+        [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
+                            -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>,
+    },
+
+    Codegen {
+        [] fn codegen_fulfill_obligation: fulfill_obligation_dep_node(
+            (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Vtable<'tcx, ()>,
+    },
+
+    TypeChecking {
+        [] fn trait_impls_of: TraitImpls(DefId) -> Lrc<ty::trait_def::TraitImpls>,
+        [] fn specialization_graph_of: SpecializationGraph(DefId)
+            -> Lrc<specialization_graph::Graph>,
+        [] fn is_object_safe: ObjectSafety(DefId) -> bool,
+
+        // Get the ParameterEnvironment for a given item; this environment
+        // will be in "user-facing" mode, meaning that it is suitabe for
+        // type-checking etc, and it does not normalize specializable
+        // associated types. This is almost always what you want,
+        // unless you are doing MIR optimizations, in which case you
+        // might want to use `reveal_all()` method to change modes.
+        [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
+
+        // Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
+        // `ty.is_copy()`, etc, since that will prune the environment where possible.
+        [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
+        [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
+        [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
+        [] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
+        [] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
+                                    -> Result<&'tcx ty::layout::LayoutDetails,
+                                                ty::layout::LayoutError<'tcx>>,
+    },
+
+    Other {
+        [] fn dylib_dependency_formats: DylibDepFormats(CrateNum)
+                                        -> Lrc<Vec<(CrateNum, LinkagePreference)>>,
+    },
+
+    Codegen {
+        [fatal_cycle] fn is_panic_runtime: IsPanicRuntime(CrateNum) -> bool,
+        [fatal_cycle] fn is_compiler_builtins: IsCompilerBuiltins(CrateNum) -> bool,
+        [fatal_cycle] fn has_global_allocator: HasGlobalAllocator(CrateNum) -> bool,
+        [fatal_cycle] fn is_sanitizer_runtime: IsSanitizerRuntime(CrateNum) -> bool,
+        [fatal_cycle] fn is_profiler_runtime: IsProfilerRuntime(CrateNum) -> bool,
+        [fatal_cycle] fn panic_strategy: GetPanicStrategy(CrateNum) -> PanicStrategy,
+        [fatal_cycle] fn is_no_builtins: IsNoBuiltins(CrateNum) -> bool,
+
+        [] fn extern_crate: ExternCrate(DefId) -> Lrc<Option<ExternCrate>>,
+    },
+
+    TypeChecking {
+        [] fn specializes: specializes_node((DefId, DefId)) -> bool,
+        [] fn in_scope_traits_map: InScopeTraits(DefIndex)
+            -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<StableVec<TraitCandidate>>>>>,
+    },
+
+    Other {
+        [] fn module_exports: ModuleExports(DefId) -> Option<Lrc<Vec<Export>>>,
+        [] fn lint_levels: lint_levels_node(CrateNum) -> Lrc<lint::LintLevelMap>,
+    },
+
+    TypeChecking {
+        [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
+
+        [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
+        [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
+        [] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
+    },
+
+    Linking {
+        // The DefIds of all non-generic functions and statics in the given crate
+        // that can be reached from outside the crate.
+        //
+        // We expect this items to be available for being linked to.
+        //
+        // This query can also be called for LOCAL_CRATE. In this case it will
+        // compute which items will be reachable to other crates, taking into account
+        // the kind of crate that is currently compiled. Crates with only a
+        // C interface have fewer reachable things.
+        //
+        // Does not include external symbols that don't have a corresponding DefId,
+        // like the compiler-generated `main` function and so on.
+        [] fn reachable_non_generics: ReachableNonGenerics(CrateNum)
+            -> Lrc<DefIdMap<SymbolExportLevel>>,
+        [] fn is_reachable_non_generic: IsReachableNonGeneric(DefId) -> bool,
+        [] fn is_unreachable_local_definition: IsUnreachableLocalDefinition(DefId) -> bool,
+    },
+
+    Codegen {
+        [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum)
+            -> Lrc<DefIdMap<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>>,
+        [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId)
+            -> Option<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>,
+    },
+
+    Other {
+        [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc<Vec<NativeLibrary>>,
+
+        [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc<Vec<ForeignModule>>,
+
+        [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option<DefId>,
+        [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option<DefId>,
+        [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator,
+        [] fn crate_hash: CrateHash(CrateNum) -> Svh,
+        [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol,
+        [] fn extra_filename: ExtraFileName(CrateNum) -> String,
+    },
+
+    TypeChecking {
+        [] fn implementations_of_trait: implementations_of_trait_node((CrateNum, DefId))
+            -> Lrc<Vec<DefId>>,
+        [] fn all_trait_implementations: AllTraitImplementations(CrateNum)
+            -> Lrc<Vec<DefId>>,
+    },
+
+    Other {
+        [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum)
+            -> Lrc<FxHashSet<DefId>>,
+        [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool,
+        [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool,
+        [] fn native_library_kind: NativeLibraryKind(DefId)
+            -> Option<NativeLibraryKind>,
+    },
+
+    Linking {
+        [] fn link_args: link_args_node(CrateNum) -> Lrc<Vec<String>>,
+    },
+
+    BorrowChecking {
+        // Lifetime resolution. See `middle::resolve_lifetimes`.
+        [] fn resolve_lifetimes: ResolveLifetimes(CrateNum) -> Lrc<ResolveLifetimes>,
+        [] fn named_region_map: NamedRegion(DefIndex) ->
+            Option<Lrc<FxHashMap<ItemLocalId, Region>>>,
+        [] fn is_late_bound_map: IsLateBound(DefIndex) ->
+            Option<Lrc<FxHashSet<ItemLocalId>>>,
+        [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
+            -> Option<Lrc<FxHashMap<ItemLocalId, Lrc<Vec<ObjectLifetimeDefault>>>>>,
+    },
+
+    TypeChecking {
+        [] fn visibility: Visibility(DefId) -> ty::Visibility,
+    },
+
+    Other {
+        [] fn dep_kind: DepKind(CrateNum) -> DepKind,
+        [] fn crate_name: CrateName(CrateNum) -> Symbol,
+        [] fn item_children: ItemChildren(DefId) -> Lrc<Vec<Export>>,
+        [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
+
+        [] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
+        [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
+        [] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
+        [] fn visible_parent_map: visible_parent_map_node(CrateNum)
+            -> Lrc<DefIdMap<DefId>>,
+        [] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
+        [] fn used_crate_source: UsedCrateSource(CrateNum) -> Lrc<CrateSource>,
+        [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
+
+        [] fn freevars: Freevars(DefId) -> Option<Lrc<Vec<hir::Freevar>>>,
+        [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
+        [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
+            -> Lrc<Vec<(DefId, Span)>>,
+
+        [] fn stability_index: stability_index_node(CrateNum) -> Lrc<stability::Index<'tcx>>,
+        [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Lrc<Vec<CrateNum>>,
+
+        /// A vector of every trait accessible in the whole crate
+        /// (i.e. including those from subcrates). This is used only for
+        /// error reporting.
+        [] fn all_traits: all_traits_node(CrateNum) -> Lrc<Vec<DefId>>,
+    },
+
+    Linking {
+        [] fn exported_symbols: ExportedSymbols(CrateNum)
+            -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>>,
+    },
+
+    Codegen {
+        [] fn collect_and_partition_mono_items:
+            collect_and_partition_mono_items_node(CrateNum)
+            -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
+        [] fn is_codegened_item: IsCodegenedItem(DefId) -> bool,
+        [] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,
+        [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats,
+    },
+
+    Other {
+        [] fn output_filenames: output_filenames_node(CrateNum)
+            -> Arc<OutputFilenames>,
+    },
+
+    TypeChecking {
+        // Erases regions from `ty` to yield a new type.
+        // Normally you would just use `tcx.erase_regions(&value)`,
+        // however, which uses this query as a kind of cache.
+        [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>,
+
+        /// Do not call this query directly: invoke `normalize` instead.
+        [] fn normalize_projection_ty: NormalizeProjectionTy(
+            CanonicalProjectionGoal<'tcx>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, NormalizationResult<'tcx>>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
+        [] fn normalize_ty_after_erasing_regions: NormalizeTyAfterErasingRegions(
+            ParamEnvAnd<'tcx, Ty<'tcx>>
+        ) -> Ty<'tcx>,
+
+        /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
+        [] fn dropck_outlives: DropckOutlives(
+            CanonicalTyGoal<'tcx>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
+        /// `infcx.predicate_must_hold()` instead.
+        [] fn evaluate_obligation: EvaluateObligation(
+            CanonicalPredicateGoal<'tcx>
+        ) -> Result<traits::EvaluationResult, traits::OverflowError>,
+
+        /// Do not call this query directly: part of the `Eq` type-op
+        [] fn type_op_eq: TypeOpEq(
+            CanonicalTypeOpEqGoal<'tcx>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: part of the `Subtype` type-op
+        [] fn type_op_subtype: TypeOpSubtype(
+            CanonicalTypeOpSubtypeGoal<'tcx>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: part of the `ProvePredicate` type-op
+        [] fn type_op_prove_predicate: TypeOpProvePredicate(
+            CanonicalTypeOpProvePredicateGoal<'tcx>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ()>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: part of the `Normalize` type-op
+        [] fn type_op_normalize_ty: TypeOpNormalizeTy(
+            CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, Ty<'tcx>>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: part of the `Normalize` type-op
+        [] fn type_op_normalize_predicate: TypeOpNormalizePredicate(
+            CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::Predicate<'tcx>>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: part of the `Normalize` type-op
+        [] fn type_op_normalize_poly_fn_sig: TypeOpNormalizePolyFnSig(
+            CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::PolyFnSig<'tcx>>>>,
+            NoSolution,
+        >,
+
+        /// Do not call this query directly: part of the `Normalize` type-op
+        [] fn type_op_normalize_fn_sig: TypeOpNormalizeFnSig(
+            CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
+        ) -> Result<
+            Lrc<Canonical<'tcx, canonical::QueryResult<'tcx, ty::FnSig<'tcx>>>>,
+            NoSolution,
+        >,
+
+        [] fn substitute_normalize_and_test_predicates:
+            substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool,
+    },
+
+    Other {
+        [] fn target_features_whitelist:
+            target_features_whitelist_node(CrateNum) -> Lrc<FxHashMap<String, Option<String>>>,
+
+        // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
+        [] fn instance_def_size_estimate: instance_def_size_estimate_dep_node(ty::InstanceDef<'tcx>)
+            -> usize,
+
+        [] fn features_query: features_node(CrateNum) -> Lrc<feature_gate::Features>,
+    },
+
+    TypeChecking {
+        [] fn program_clauses_for: ProgramClausesFor(DefId) -> Clauses<'tcx>,
+
+        [] fn program_clauses_for_env: ProgramClausesForEnv(
+            ty::ParamEnv<'tcx>
+        ) -> Clauses<'tcx>,
+    },
+
+    Linking {
+        [] fn wasm_import_module_map: WasmImportModuleMap(CrateNum)
+            -> Lrc<FxHashMap<DefId, String>>,
+    },
 }
 
 // `try_get_query` can't be public because it uses the private query
index 9dc8321f82575092efefde3190b97208f93df534..78e1a6425465b8a2c40401ee8414253c6d78dbe7 100644 (file)
@@ -631,9 +631,19 @@ macro_rules! handle_cycle_error {
 }
 
 macro_rules! define_queries {
+    (<$tcx:tt> $($category:tt {
+        $($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*
+    },)*) => {
+        define_queries_inner! { <$tcx>
+            $($( $(#[$attr])* category<$category> [$($modifiers)*] fn $name: $node($K) -> $V,)*)*
+        }
+    }
+}
+
+macro_rules! define_queries_inner {
     (<$tcx:tt>
-     $($(#[$attr:meta])*
-       [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
+     $($(#[$attr:meta])* category<$category:tt>
+        [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
 
         use std::mem;
         #[cfg(parallel_queries)]
index 934bf9a416a95f3e9a9f68d03a13c0976e63bd8d..dd38188824338f7a1a5bb648c701f7dd5865696a 100644 (file)
@@ -158,8 +158,10 @@ pub enum TypeVariants<'tcx> {
     TyProjection(ProjectionTy<'tcx>),
 
     /// Anonymized (`impl Trait`) type found in a return type.
-    /// The DefId comes from the `impl Trait` ast::Ty node, and the
-    /// substitutions are for the generics of the function in question.
+    /// The DefId comes either from
+    /// * the `impl Trait` ast::Ty node,
+    /// * or the `existential type` declaration
+    /// The substitutions are for the generics of the function in question.
     /// After typeck, the concrete type can be found in the `types` map.
     TyAnon(DefId, &'tcx Substs<'tcx>),
 
index 5376acca0d8cdabf5402fc13631a2731f63abfb9..b99cdd59773aa71f18dfbf97332e4eed4c11a8a8 100644 (file)
@@ -360,10 +360,16 @@ fn compute(&mut self, ty0: Ty<'tcx>) -> bool {
                     // types appearing in the fn signature
                 }
 
-                ty::TyAnon(..) => {
+                ty::TyAnon(did, substs) => {
                     // all of the requirements on type parameters
                     // should've been checked by the instantiation
                     // of whatever returned this exact `impl Trait`.
+
+                    // for named existential types we still need to check them
+                    if super::is_impl_trait_defn(self.infcx.tcx, did).is_none() {
+                        let obligations = self.nominal_obligations(did, substs);
+                        self.out.extend(obligations);
+                    }
                 }
 
                 ty::TyDynamic(data, r) => {
index c17fd79df2af0bb01f547b95e395cf331a210126..c67453d2b201a9bce0efe1bb3f3694872abb22fd 100644 (file)
@@ -271,6 +271,7 @@ fn parameterized<F: fmt::Write>(&mut self,
                 match key.disambiguated_data.data {
                     DefPathData::AssocTypeInTrait(_) |
                     DefPathData::AssocTypeInImpl(_) |
+                    DefPathData::AssocExistentialInImpl(_) |
                     DefPathData::Trait(_) |
                     DefPathData::TypeNs(_) => {
                         break;
@@ -1081,6 +1082,20 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                     }
 
                     ty::tls::with(|tcx| {
+                        let def_key = tcx.def_key(def_id);
+                        if let Some(name) = def_key.disambiguated_data.data.get_opt_name() {
+                            write!(f, "{}", name)?;
+                            let mut substs = substs.iter();
+                            if let Some(first) = substs.next() {
+                                write!(f, "::<")?;
+                                write!(f, "{}", first)?;
+                                for subst in substs {
+                                    write!(f, ", {}", subst)?;
+                                }
+                                write!(f, ">")?;
+                            }
+                            return Ok(());
+                        }
                         // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
                         // by looking up the projections associated with the def_id.
                         let predicates_of = tcx.predicates_of(def_id);
index b1502902079b9f2c81d4f6280384ba375540f7db..f1a6e9913d6bdfc0cc81161af8a3912c32d2b2c1 100644 (file)
@@ -565,7 +565,13 @@ fn adjust_for_abi(&mut self,
     }
 
     fn llvm_type(&self, cx: &CodegenCx<'a, 'tcx>) -> Type {
-        let mut llargument_tys = Vec::new();
+        let args_capacity: usize = self.args.iter().map(|arg|
+            if arg.pad.is_some() { 1 } else { 0 } +
+            if let PassMode::Pair(_, _) = arg.mode { 2 } else { 1 }
+        ).sum();
+        let mut llargument_tys = Vec::with_capacity(
+            if let PassMode::Indirect(_) = self.ret.mode { 1 } else { 0 } + args_capacity
+        );
 
         let llreturn_ty = match self.ret.mode {
             PassMode::Ignore => Type::void(cx),
index 8246bb243669444ade1dc835cb737dbcacae6c87..3b5f927d52f005e801e3c3deb06790a0f6bd8d5c 100644 (file)
@@ -226,13 +226,22 @@ pub fn provide(providers: &mut Providers) {
 
 pub fn provide_extern(providers: &mut Providers) {
     providers.wasm_import_module_map = |tcx, cnum| {
+        // Build up a map from DefId to a `NativeLibrary` structure, where
+        // `NativeLibrary` internally contains information about
+        // `#[link(wasm_import_module = "...")]` for example.
+        let native_libs = tcx.native_libraries(cnum);
+        let mut def_id_to_native_lib = FxHashMap();
+        for lib in native_libs.iter() {
+            if let Some(id) = lib.foreign_module {
+                def_id_to_native_lib.insert(id, lib);
+            }
+        }
+
         let mut ret = FxHashMap();
         for lib in tcx.foreign_modules(cnum).iter() {
-            let attrs = tcx.get_attrs(lib.def_id);
-            let mut module = None;
-            for attr in attrs.iter().filter(|a| a.check_name("wasm_import_module")) {
-                module = attr.value_str();
-            }
+            let module = def_id_to_native_lib
+                .get(&lib.def_id)
+                .and_then(|s| s.wasm_import_module);
             let module = match module {
                 Some(s) => s,
                 None => continue,
@@ -244,7 +253,7 @@ pub fn provide_extern(providers: &mut Providers) {
         }
 
         Lrc::new(ret)
-    }
+    };
 }
 
 fn wasm_import_module(tcx: TyCtxt, id: DefId) -> Option<CString> {
index a7f0910a6fcccff6e1fe9eb48b1ea26d213499b9..f2b17584adcba2dd517ee9d6e1adff117d9ae3ec 100644 (file)
@@ -449,7 +449,9 @@ fn link_rlib<'a>(sess: &'a Session,
             NativeLibraryKind::NativeFramework |
             NativeLibraryKind::NativeUnknown => continue,
         }
-        ab.add_native_library(&lib.name.as_str());
+        if let Some(name) = lib.name {
+            ab.add_native_library(&name.as_str());
+        }
     }
 
     // After adding all files to the archive, we need to update the
@@ -583,21 +585,24 @@ fn link_staticlib(sess: &Session,
 fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLibrary]) {
     let lib_args: Vec<_> = all_native_libs.iter()
         .filter(|l| relevant_lib(sess, l))
-        .filter_map(|lib| match lib.kind {
-            NativeLibraryKind::NativeStaticNobundle |
-            NativeLibraryKind::NativeUnknown => {
-                if sess.target.target.options.is_like_msvc {
-                    Some(format!("{}.lib", lib.name))
-                } else {
-                    Some(format!("-l{}", lib.name))
-                }
-            },
-            NativeLibraryKind::NativeFramework => {
-                // ld-only syntax, since there are no frameworks in MSVC
-                Some(format!("-framework {}", lib.name))
-            },
-            // These are included, no need to print them
-            NativeLibraryKind::NativeStatic => None,
+        .filter_map(|lib| {
+            let name = lib.name?;
+            match lib.kind {
+                NativeLibraryKind::NativeStaticNobundle |
+                NativeLibraryKind::NativeUnknown => {
+                    if sess.target.target.options.is_like_msvc {
+                        Some(format!("{}.lib", name))
+                    } else {
+                        Some(format!("-l{}", name))
+                    }
+                },
+                NativeLibraryKind::NativeFramework => {
+                    // ld-only syntax, since there are no frameworks in MSVC
+                    Some(format!("-framework {}", name))
+                },
+                // These are included, no need to print them
+                NativeLibraryKind::NativeStatic => None,
+            }
         })
         .collect();
     if !lib_args.is_empty() {
@@ -1211,11 +1216,15 @@ fn add_local_native_libraries(cmd: &mut dyn Linker,
 
     let search_path = archive_search_paths(sess);
     for lib in relevant_libs {
+        let name = match lib.name {
+            Some(ref l) => l,
+            None => continue,
+        };
         match lib.kind {
-            NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name.as_str()),
-            NativeLibraryKind::NativeFramework => cmd.link_framework(&lib.name.as_str()),
-            NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&lib.name.as_str()),
-            NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&lib.name.as_str(),
+            NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
+            NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
+            NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()),
+            NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(),
                                                                         &search_path)
         }
     }
@@ -1578,19 +1587,23 @@ fn add_upstream_native_libraries(cmd: &mut dyn Linker,
     let crates = &codegen_results.crate_info.used_crates_static;
     for &(cnum, _) in crates {
         for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
+            let name = match lib.name {
+                Some(ref l) => l,
+                None => continue,
+            };
             if !relevant_lib(sess, &lib) {
                 continue
             }
             match lib.kind {
-                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name.as_str()),
-                NativeLibraryKind::NativeFramework => cmd.link_framework(&lib.name.as_str()),
+                NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
+                NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
                 NativeLibraryKind::NativeStaticNobundle => {
                     // Link "static-nobundle" native libs only if the crate they originate from
                     // is being linked statically to the current crate.  If it's linked dynamically
                     // or is an rlib already included via some other dylib crate, the symbols from
                     // native libs will have already been included in that dylib.
                     if data[cnum.as_usize() - 1] == Linkage::Static {
-                        cmd.link_staticlib(&lib.name.as_str())
+                        cmd.link_staticlib(&name.as_str())
                     }
                 },
                 // ignore statically included native libraries here as we've
index a33f8b569d0a8585e3cee4a92ffbf70e90b19699..60b5cf2ec765134f4d95ca629e34a574acf825d1 100644 (file)
@@ -759,20 +759,6 @@ unsafe fn optimize(&mut self, cgcx: &CodegenContext, timeline: &mut Timeline)
         cgcx.save_temp_bitcode(&module, "thin-lto-after-pm");
         timeline.record("thin-done");
 
-        // FIXME: this is a hack around a bug in LLVM right now. Discovered in
-        // #46910 it was found out that on 32-bit MSVC LLVM will hit a codegen
-        // error if there's an available_externally function in the LLVM module.
-        // Typically we don't actually use these functions but ThinLTO makes
-        // heavy use of them when inlining across modules.
-        //
-        // Tracked upstream at https://bugs.llvm.org/show_bug.cgi?id=35736 this
-        // function call (and its definition on the C++ side of things)
-        // shouldn't be necessary eventually and we can safetly delete these few
-        // lines.
-        llvm::LLVMRustThinLTORemoveAvailableExternally(llmod);
-        cgcx.save_temp_bitcode(&module, "thin-lto-after-rm-ae");
-        timeline.record("no-ae");
-
         Ok(module)
     }
 }
index d378d5af1c0f60e46098d29b09a318ebbeb0a0c3..f37854b7bcae0b3386b06c5f4d95cc68da87163d 100644 (file)
@@ -34,9 +34,9 @@
 ///
 /// This function is intended as a hack for now where we manually rewrite the
 /// wasm output by LLVM to have the correct import modules listed. The
-/// `#[wasm_import_module]` attribute in Rust translates to the module that each
-/// symbol is imported from, so here we manually go through the wasm file,
-/// decode it, rewrite imports, and then rewrite the wasm module.
+/// `#[link(wasm_import_module = "...")]` attribute in Rust translates to the
+/// module that each symbol is imported from, so here we manually go through the
+/// wasm file, decode it, rewrite imports, and then rewrite the wasm module.
 ///
 /// Support for this was added to LLVM in
 /// https://github.com/llvm-mirror/llvm/commit/0f32e1365, although support still
index c71e49b0d8821888b952f700ed09868c3f337853..e4acb2ad4b161d2d684a403acc62605b48099e8f 100644 (file)
@@ -13,7 +13,7 @@
 use llvm;
 use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
 use llvm::{Opcode, IntPredicate, RealPredicate, False, OperandBundleDef};
-use llvm::{ValueRef, BasicBlockRef, BuilderRef, ModuleRef};
+use llvm::{ValueRef, BasicBlockRef, BuilderRef};
 use common::*;
 use type_::Type;
 use value::Value;
@@ -1157,23 +1157,6 @@ pub fn ptrdiff(&self, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
         }
     }
 
-    pub fn trap(&self) {
-        unsafe {
-            let bb: BasicBlockRef = llvm::LLVMGetInsertBlock(self.llbuilder);
-            let fn_: ValueRef = llvm::LLVMGetBasicBlockParent(bb);
-            let m: ModuleRef = llvm::LLVMGetGlobalParent(fn_);
-            let p = "llvm.trap\0".as_ptr();
-            let t: ValueRef = llvm::LLVMGetNamedFunction(m, p as *const _);
-            assert!((t as isize != 0));
-            let args: &[ValueRef] = &[];
-            self.count_insn("trap");
-            llvm::LLVMRustBuildCall(self.llbuilder, t,
-                                    args.as_ptr(), args.len() as c_uint,
-                                    ptr::null_mut(),
-                                    noname());
-        }
-    }
-
     pub fn landing_pad(&self, ty: Type, pers_fn: ValueRef,
                        num_clauses: usize) -> ValueRef {
         self.count_insn("landingpad");
index 0e1ba6e444dc6eec55aec7495f309e9b4a9e7f17..f60954ea02166398216ae597daee4879783a1257 100644 (file)
@@ -94,7 +94,9 @@
 use std::default::Default;
 use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
 use std::env;
+use std::error::Error;
 use std::ffi::OsString;
+use std::fmt::{self, Display};
 use std::io::{self, Read, Write};
 use std::iter::repeat;
 use std::mem;
@@ -146,6 +148,12 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig,
     }
 }
 
+/// Exit status code used for successful compilation and help output.
+pub const EXIT_SUCCESS: isize = 0;
+
+/// Exit status code used for compilation failures and  invalid flags.
+pub const EXIT_FAILURE: isize = 1;
+
 const BUG_REPORT_URL: &'static str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\
                                       md#bug-reports";
 
@@ -178,7 +186,7 @@ pub fn abort_on_err<T>(result: Result<T, CompileIncomplete>, sess: &Session) ->
 pub fn run<F>(run_compiler: F) -> isize
     where F: FnOnce() -> (CompileResult, Option<Session>) + Send + 'static
 {
-    monitor(move || {
+    let result = monitor(move || {
         let (result, session) = run_compiler();
         if let Err(CompileIncomplete::Errored(_)) = result {
             match session {
@@ -201,7 +209,11 @@ pub fn run<F>(run_compiler: F) -> isize
             }
         }
     });
-    0
+
+    match result {
+        Ok(()) => EXIT_SUCCESS,
+        Err(_) => EXIT_FAILURE,
+    }
 }
 
 fn load_backend_from_dylib(path: &Path) -> fn() -> Box<dyn CodegenBackend> {
@@ -1625,20 +1637,30 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
     }
 }
 
+#[derive(Debug)]
+pub struct CompilationFailure;
+
+impl Error for CompilationFailure {}
+
+impl Display for CompilationFailure {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "compilation had errors")
+    }
+}
+
 /// Run a procedure which will detect panics in the compiler and print nicer
 /// error messages rather than just failing the test.
 ///
 /// The diagnostic emitter yielded to the procedure should be used for reporting
 /// errors of the compiler.
-pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
-    let result = in_rustc_thread(move || {
+pub fn monitor<F: FnOnce() + Send + 'static>(f: F) -> Result<(), CompilationFailure> {
+    in_rustc_thread(move || {
         f()
-    });
-
-    if let Err(value) = result {
-        // Thread panicked without emitting a fatal diagnostic
-        if !value.is::<errors::FatalErrorMarker>() {
-            // Emit a newline
+    }).map_err(|value| {
+        if value.is::<errors::FatalErrorMarker>() {
+            CompilationFailure
+        } else {
+            // Thread panicked without emitting a fatal diagnostic
             eprintln!("");
 
             let emitter =
@@ -1677,10 +1699,10 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
                              &note,
                              errors::Level::Note);
             }
-        }
 
-        panic::resume_unwind(Box::new(errors::FatalErrorMarker));
-    }
+            panic::resume_unwind(Box::new(errors::FatalErrorMarker));
+        }
+    })
 }
 
 pub fn diagnostics_registry() -> errors::registry::Registry {
index 39e674a6095b66392cce0ff05a89ef5c3ea8f0e7..7f2da5a326aceca1e3be76bc2e4ee6fa44ef00e0 100644 (file)
@@ -417,6 +417,7 @@ fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static s
                     ImplItemKind::Method(..) => ("NodeImplItem", LABELS_FN_IN_IMPL),
                     ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
                     ImplItemKind::Type(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
+                    ImplItemKind::Existential(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
                 }
             },
             _ => self.tcx.sess.span_fatal(
index 6b5dba536b46ea0d4cae5e871c0df0cc9c679ff7..3ffbdc7b7dc3abe70a9ac41f576ca1bd1e9ef3a6 100644 (file)
@@ -462,6 +462,7 @@ fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) {
             hir::ImplItemKind::Const(..) => "an associated constant",
             hir::ImplItemKind::Method(..) => "a method",
             hir::ImplItemKind::Type(_) => "an associated type",
+            hir::ImplItemKind::Existential(_) => "an associated existential type",
         };
         self.check_missing_docs_attrs(cx,
                                       Some(impl_item.id),
index b4483557dd33fe53816ae93598df910fa67b169f..8d04438eea29000edf06fbeb0b26af50010d19e2 100644 (file)
@@ -1791,7 +1791,6 @@ pub fn LLVMRustThinLTOGetDICompileUnit(M: ModuleRef,
                                            CU1: *mut *mut c_void,
                                            CU2: *mut *mut c_void);
     pub fn LLVMRustThinLTOPatchDICompileUnit(M: ModuleRef, CU: *mut c_void);
-    pub fn LLVMRustThinLTORemoveAvailableExternally(M: ModuleRef);
 
     pub fn LLVMRustLinkerNew(M: ModuleRef) -> LinkerRef;
     pub fn LLVMRustLinkerAdd(linker: LinkerRef,
index b8c643839506637b85f504285dc858e9bbed6086..ab566654c389cd366c5be633b33149f4bb57f922 100644 (file)
@@ -421,6 +421,7 @@ fn to_def(&self, did: DefId) -> Option<Def> {
             EntryKind::Type => Def::TyAlias(did),
             EntryKind::Existential => Def::Existential(did),
             EntryKind::AssociatedType(_) => Def::AssociatedTy(did),
+            EntryKind::AssociatedExistential(_) => Def::AssociatedExistential(did),
             EntryKind::Mod(_) => Def::Mod(did),
             EntryKind::Variant(_) => Def::Variant(did),
             EntryKind::Trait(_) => Def::Trait(did),
index b9cb97ed7d0c53cb559063ba9212d45110f32560..7ed991e0de3a1d010474cd55462dfb6ba5fea203 100644 (file)
@@ -840,6 +840,8 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> {
                 }))
             }
             ty::AssociatedKind::Type => EntryKind::AssociatedType(container),
+            ty::AssociatedKind::Existential =>
+                span_bug!(ast_item.span, "existential type in trait"),
         };
 
         Entry {
@@ -863,6 +865,7 @@ fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> {
                         None
                     }
                 }
+                ty::AssociatedKind::Existential => unreachable!(),
             },
             inherent_impls: LazySeq::empty(),
             variances: if trait_item.kind == ty::AssociatedKind::Method {
@@ -933,6 +936,7 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) -> Entry<'tcx> {
                     has_self: impl_item.method_has_self_argument,
                 }))
             }
+            ty::AssociatedKind::Existential => EntryKind::AssociatedExistential(container),
             ty::AssociatedKind::Type => EntryKind::AssociatedType(container)
         };
 
@@ -948,6 +952,7 @@ fn encode_info_for_impl_item(&mut self, def_id: DefId) -> Entry<'tcx> {
                     let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
                     needs_inline || is_const_fn || always_encode_mir
                 },
+                hir::ImplItemKind::Existential(..) |
                 hir::ImplItemKind::Type(..) => false,
             };
 
index 327b2abc4d318b8829d4dff13d322576205e380a..078295c99bdf7e028f94ad4a641fce290d916ad0 100644 (file)
@@ -61,56 +61,75 @@ fn visit_item(&mut self, it: &'tcx hir::Item) {
                 Some(item) => item,
                 None => continue,
             };
-            let kind = items.iter().find(|k| {
-                k.check_name("kind")
-            }).and_then(|a| a.value_str()).map(Symbol::as_str);
-            let kind = match kind.as_ref().map(|s| &s[..]) {
-                Some("static") => cstore::NativeStatic,
-                Some("static-nobundle") => cstore::NativeStaticNobundle,
-                Some("dylib") => cstore::NativeUnknown,
-                Some("framework") => cstore::NativeFramework,
-                Some(k) => {
-                    struct_span_err!(self.tcx.sess, m.span, E0458,
-                              "unknown kind: `{}`", k)
-                        .span_label(m.span, "unknown kind").emit();
-                    cstore::NativeUnknown
-                }
-                None => cstore::NativeUnknown
-            };
-            let n = items.iter().find(|n| {
-                n.check_name("name")
-            }).and_then(|a| a.value_str());
-            let n = match n {
-                Some(n) => n,
-                None => {
-                    struct_span_err!(self.tcx.sess, m.span, E0459,
-                                     "#[link(...)] specified without `name = \"foo\"`")
-                        .span_label(m.span, "missing `name` argument").emit();
-                    Symbol::intern("foo")
-                }
+            let mut lib = NativeLibrary {
+                name: None,
+                kind: cstore::NativeUnknown,
+                cfg: None,
+                foreign_module: Some(self.tcx.hir.local_def_id(it.id)),
+                wasm_import_module: None,
             };
-            let cfg = items.iter().find(|k| {
-                k.check_name("cfg")
-            }).and_then(|a| a.meta_item_list());
-            let cfg = if let Some(list) = cfg {
-                if list.is_empty() {
-                    self.tcx.sess.span_err(m.span(), "`cfg()` must have an argument");
-                    return;
-                } else if let cfg @ Some(..) = list[0].meta_item() {
-                    cfg.cloned()
+            let mut kind_specified = false;
+
+            for item in items.iter() {
+                if item.check_name("kind") {
+                    kind_specified = true;
+                    let kind = match item.value_str() {
+                        Some(name) => name,
+                        None => continue, // skip like historical compilers
+                    };
+                    lib.kind = match &kind.as_str()[..] {
+                        "static" => cstore::NativeStatic,
+                        "static-nobundle" => cstore::NativeStaticNobundle,
+                        "dylib" => cstore::NativeUnknown,
+                        "framework" => cstore::NativeFramework,
+                        k => {
+                            struct_span_err!(self.tcx.sess, m.span, E0458,
+                                      "unknown kind: `{}`", k)
+                                .span_label(item.span, "unknown kind").emit();
+                            cstore::NativeUnknown
+                        }
+                    };
+                } else if item.check_name("name") {
+                    lib.name = item.value_str();
+                } else if item.check_name("cfg") {
+                    let cfg = match item.meta_item_list() {
+                        Some(list) => list,
+                        None => continue, // skip like historical compilers
+                    };
+                    if cfg.is_empty() {
+                        self.tcx.sess.span_err(
+                            item.span(),
+                            "`cfg()` must have an argument",
+                        );
+                    } else if let cfg @ Some(..) = cfg[0].meta_item() {
+                        lib.cfg = cfg.cloned();
+                    } else {
+                        self.tcx.sess.span_err(cfg[0].span(), "invalid argument for `cfg(..)`");
+                    }
+                } else if item.check_name("wasm_import_module") {
+                    match item.value_str() {
+                        Some(s) => lib.wasm_import_module = Some(s),
+                        None => {
+                            let msg = "must be of the form #[link(wasm_import_module = \"...\")]";
+                            self.tcx.sess.span_err(item.span(), msg);
+                        }
+                    }
                 } else {
-                    self.tcx.sess.span_err(list[0].span(), "invalid argument for `cfg(..)`");
-                    return;
+                    // currently, like past compilers, ignore unknown
+                    // directives here.
                 }
-            } else {
-                None
-            };
-            let lib = NativeLibrary {
-                name: n,
-                kind,
-                cfg,
-                foreign_module: Some(self.tcx.hir.local_def_id(it.id)),
-            };
+            }
+
+            // In general we require #[link(name = "...")] but we allow
+            // #[link(wasm_import_module = "...")] without the `name`.
+            let requires_name = kind_specified || lib.wasm_import_module.is_none();
+            if lib.name.is_none() && requires_name {
+                struct_span_err!(self.tcx.sess, m.span, E0459,
+                                 "#[link(...)] specified without \
+                                  `name = \"foo\"`")
+                    .span_label(m.span, "missing `name` argument")
+                    .emit();
+            }
             self.register_native_lib(Some(m.span), lib);
         }
     }
@@ -121,7 +140,7 @@ fn visit_impl_item(&mut self, _it: &'tcx hir::ImplItem) {}
 
 impl<'a, 'tcx> Collector<'a, 'tcx> {
     fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLibrary) {
-        if lib.name.as_str().is_empty() {
+        if lib.name.as_ref().map(|s| s.as_str().is_empty()).unwrap_or(false) {
             match span {
                 Some(span) => {
                     struct_span_err!(self.tcx.sess, span, E0454,
@@ -167,10 +186,14 @@ fn process_command_line(&mut self) {
         let mut renames = FxHashSet();
         for &(ref name, ref new_name, _) in &self.tcx.sess.opts.libs {
             if let &Some(ref new_name) = new_name {
+                let any_duplicate = self.libs
+                    .iter()
+                    .filter_map(|lib| lib.name.as_ref())
+                    .any(|n| n == name);
                 if new_name.is_empty() {
                     self.tcx.sess.err(
                         &format!("an empty renaming target was specified for library `{}`",name));
-                } else if !self.libs.iter().any(|lib| lib.name == name as &str) {
+                } else if !any_duplicate {
                     self.tcx.sess.err(&format!("renaming of the library `{}` was specified, \
                                                 however this crate contains no #[link(...)] \
                                                 attributes referencing this library.", name));
@@ -189,14 +212,18 @@ fn process_command_line(&mut self) {
         for &(ref name, ref new_name, kind) in &self.tcx.sess.opts.libs {
             let mut found = false;
             for lib in self.libs.iter_mut() {
-                if lib.name == name as &str {
+                let lib_name = match lib.name {
+                    Some(n) => n,
+                    None => continue,
+                };
+                if lib_name == name as &str {
                     let mut changed = false;
                     if let Some(k) = kind {
                         lib.kind = k;
                         changed = true;
                     }
                     if let &Some(ref new_name) = new_name {
-                        lib.name = Symbol::intern(new_name);
+                        lib.name = Some(Symbol::intern(new_name));
                         changed = true;
                     }
                     if !changed {
@@ -212,10 +239,11 @@ fn process_command_line(&mut self) {
                 // Add if not found
                 let new_name = new_name.as_ref().map(|s| &**s); // &Option<String> -> Option<&str>
                 let lib = NativeLibrary {
-                    name: Symbol::intern(new_name.unwrap_or(name)),
+                    name: Some(Symbol::intern(new_name.unwrap_or(name))),
                     kind: if let Some(k) = kind { k } else { cstore::NativeUnknown },
                     cfg: None,
                     foreign_module: None,
+                    wasm_import_module: None,
                 };
                 self.register_native_lib(None, lib);
             }
index 430cbf9b529fbecef55869fe74664a64b69f1a1c..d7c54cbc81d9414b66c4c7253c112c1868237a0f 100644 (file)
@@ -321,6 +321,7 @@ pub enum EntryKind<'tcx> {
     Impl(Lazy<ImplData<'tcx>>),
     Method(Lazy<MethodData<'tcx>>),
     AssociatedType(AssociatedContainer),
+    AssociatedExistential(AssociatedContainer),
     AssociatedConst(AssociatedContainer, ConstQualif, Lazy<RenderedConst>),
 }
 
@@ -382,6 +383,7 @@ fn hash_stable<W: StableHasherResult>(&self,
             EntryKind::Method(ref method_data) => {
                 method_data.hash_stable(hcx, hasher);
             }
+            EntryKind::AssociatedExistential(associated_container) |
             EntryKind::AssociatedType(associated_container) => {
                 associated_container.hash_stable(hcx, hasher);
             }
index e69e7a522ab73e62bfdc7d5014db72f3cb7392a5..7bcf4ef6588d53d9335a767b077016d5b798b817 100644 (file)
-use rustc::ty::Ty;
-use rustc::ty::layout::LayoutOf;
+use rustc::ty::{self, Ty};
+use rustc::ty::layout::{self, LayoutOf};
 use syntax::ast::{FloatTy, IntTy, UintTy};
 
 use rustc_apfloat::ieee::{Single, Double};
 use super::{EvalContext, Machine};
-use rustc::mir::interpret::{Scalar, EvalResult, Pointer, PointerArithmetic};
+use rustc::mir::interpret::{Scalar, EvalResult, Pointer, PointerArithmetic, Value, EvalErrorKind};
+use rustc::mir::CastKind;
 use rustc_apfloat::Float;
+use interpret::eval_context::ValTy;
+use interpret::Place;
 
 impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
+    crate fn cast(
+        &mut self,
+        src: ValTy<'tcx>,
+        kind: CastKind,
+        dest_ty: Ty<'tcx>,
+        dest: Place,
+    ) -> EvalResult<'tcx> {
+        use rustc::mir::CastKind::*;
+        match kind {
+            Unsize => {
+                let src_layout = self.layout_of(src.ty)?;
+                let dst_layout = self.layout_of(dest_ty)?;
+                self.unsize_into(src.value, src_layout, dest, dst_layout)?;
+            }
+
+            Misc => {
+                if self.type_is_fat_ptr(src.ty) {
+                    match (src.value, self.type_is_fat_ptr(dest_ty)) {
+                        (Value::ByRef { .. }, _) |
+                        // pointers to extern types
+                        (Value::Scalar(_),_) |
+                        // slices and trait objects to other slices/trait objects
+                        (Value::ScalarPair(..), true) => {
+                            let valty = ValTy {
+                                value: src.value,
+                                ty: dest_ty,
+                            };
+                            self.write_value(valty, dest)?;
+                        }
+                        // slices and trait objects to thin pointers (dropping the metadata)
+                        (Value::ScalarPair(data, _), false) => {
+                            let valty = ValTy {
+                                value: Value::Scalar(data),
+                                ty: dest_ty,
+                            };
+                            self.write_value(valty, dest)?;
+                        }
+                    }
+                } else {
+                    let src_layout = self.layout_of(src.ty)?;
+                    match src_layout.variants {
+                        layout::Variants::Single { index } => {
+                            if let Some(def) = src.ty.ty_adt_def() {
+                                let discr_val = def
+                                    .discriminant_for_variant(*self.tcx, index)
+                                    .val;
+                                let defined = self
+                                    .layout_of(dest_ty)
+                                    .unwrap()
+                                    .size
+                                    .bits() as u8;
+                                return self.write_scalar(
+                                    dest,
+                                    Scalar::Bits {
+                                        bits: discr_val,
+                                        defined,
+                                    },
+                                    dest_ty);
+                            }
+                        }
+                        layout::Variants::Tagged { .. } |
+                        layout::Variants::NicheFilling { .. } => {},
+                    }
+
+                    let src_val = self.value_to_scalar(src)?;
+                    let dest_val = self.cast_scalar(src_val, src.ty, dest_ty)?;
+                    let valty = ValTy {
+                        value: Value::Scalar(dest_val),
+                        ty: dest_ty,
+                    };
+                    self.write_value(valty, dest)?;
+                }
+            }
+
+            ReifyFnPointer => {
+                match src.ty.sty {
+                    ty::TyFnDef(def_id, substs) => {
+                        if self.tcx.has_attr(def_id, "rustc_args_required_const") {
+                            bug!("reifying a fn ptr that requires \
+                                    const arguments");
+                        }
+                        let instance: EvalResult<'tcx, _> = ty::Instance::resolve(
+                            *self.tcx,
+                            self.param_env,
+                            def_id,
+                            substs,
+                        ).ok_or_else(|| EvalErrorKind::TooGeneric.into());
+                        let fn_ptr = self.memory.create_fn_alloc(instance?);
+                        let valty = ValTy {
+                            value: Value::Scalar(fn_ptr.into()),
+                            ty: dest_ty,
+                        };
+                        self.write_value(valty, dest)?;
+                    }
+                    ref other => bug!("reify fn pointer on {:?}", other),
+                }
+            }
+
+            UnsafeFnPointer => {
+                match dest_ty.sty {
+                    ty::TyFnPtr(_) => {
+                        let mut src = src;
+                        src.ty = dest_ty;
+                        self.write_value(src, dest)?;
+                    }
+                    ref other => bug!("fn to unsafe fn cast on {:?}", other),
+                }
+            }
+
+            ClosureFnPointer => {
+                match src.ty.sty {
+                    ty::TyClosure(def_id, substs) => {
+                        let substs = self.tcx.subst_and_normalize_erasing_regions(
+                            self.substs(),
+                            ty::ParamEnv::reveal_all(),
+                            &substs,
+                        );
+                        let instance = ty::Instance::resolve_closure(
+                            *self.tcx,
+                            def_id,
+                            substs,
+                            ty::ClosureKind::FnOnce,
+                        );
+                        let fn_ptr = self.memory.create_fn_alloc(instance);
+                        let valty = ValTy {
+                            value: Value::Scalar(fn_ptr.into()),
+                            ty: dest_ty,
+                        };
+                        self.write_value(valty, dest)?;
+                    }
+                    ref other => bug!("closure fn pointer on {:?}", other),
+                }
+            }
+        }
+        Ok(())
+    }
+
     pub(super) fn cast_scalar(
         &self,
         val: Scalar,
index a92c81e046a0ffd9f01d650d54875ab30191c272..fac6e8b69efaba35e83ff9922a710e5f83370d61 100644 (file)
@@ -770,135 +770,8 @@ pub(super) fn eval_rvalue_into_place(
 
             Cast(kind, ref operand, cast_ty) => {
                 debug_assert_eq!(self.monomorphize(cast_ty, self.substs()), dest_ty);
-                use rustc::mir::CastKind::*;
-                match kind {
-                    Unsize => {
-                        let src = self.eval_operand(operand)?;
-                        let src_layout = self.layout_of(src.ty)?;
-                        let dst_layout = self.layout_of(dest_ty)?;
-                        self.unsize_into(src.value, src_layout, dest, dst_layout)?;
-                    }
-
-                    Misc => {
-                        let src = self.eval_operand(operand)?;
-                        if self.type_is_fat_ptr(src.ty) {
-                            match (src.value, self.type_is_fat_ptr(dest_ty)) {
-                                (Value::ByRef { .. }, _) |
-                                // pointers to extern types
-                                (Value::Scalar(_),_) |
-                                // slices and trait objects to other slices/trait objects
-                                (Value::ScalarPair(..), true) => {
-                                    let valty = ValTy {
-                                        value: src.value,
-                                        ty: dest_ty,
-                                    };
-                                    self.write_value(valty, dest)?;
-                                }
-                                // slices and trait objects to thin pointers (dropping the metadata)
-                                (Value::ScalarPair(data, _), false) => {
-                                    let valty = ValTy {
-                                        value: Value::Scalar(data),
-                                        ty: dest_ty,
-                                    };
-                                    self.write_value(valty, dest)?;
-                                }
-                            }
-                        } else {
-                            let src_layout = self.layout_of(src.ty)?;
-                            match src_layout.variants {
-                                layout::Variants::Single { index } => {
-                                    if let Some(def) = src.ty.ty_adt_def() {
-                                        let discr_val = def
-                                            .discriminant_for_variant(*self.tcx, index)
-                                            .val;
-                                        let defined = self
-                                            .layout_of(dest_ty)
-                                            .unwrap()
-                                            .size
-                                            .bits() as u8;
-                                        return self.write_scalar(
-                                            dest,
-                                            Scalar::Bits {
-                                                bits: discr_val,
-                                                defined,
-                                            },
-                                            dest_ty);
-                                    }
-                                }
-                                layout::Variants::Tagged { .. } |
-                                layout::Variants::NicheFilling { .. } => {},
-                            }
-
-                            let src_val = self.value_to_scalar(src)?;
-                            let dest_val = self.cast_scalar(src_val, src.ty, dest_ty)?;
-                            let valty = ValTy {
-                                value: Value::Scalar(dest_val),
-                                ty: dest_ty,
-                            };
-                            self.write_value(valty, dest)?;
-                        }
-                    }
-
-                    ReifyFnPointer => {
-                        match self.eval_operand(operand)?.ty.sty {
-                            ty::TyFnDef(def_id, substs) => {
-                                if self.tcx.has_attr(def_id, "rustc_args_required_const") {
-                                    bug!("reifying a fn ptr that requires \
-                                          const arguments");
-                                }
-                                let instance: EvalResult<'tcx, _> = ty::Instance::resolve(
-                                    *self.tcx,
-                                    self.param_env,
-                                    def_id,
-                                    substs,
-                                ).ok_or_else(|| EvalErrorKind::TooGeneric.into());
-                                let fn_ptr = self.memory.create_fn_alloc(instance?);
-                                let valty = ValTy {
-                                    value: Value::Scalar(fn_ptr.into()),
-                                    ty: dest_ty,
-                                };
-                                self.write_value(valty, dest)?;
-                            }
-                            ref other => bug!("reify fn pointer on {:?}", other),
-                        }
-                    }
-
-                    UnsafeFnPointer => {
-                        match dest_ty.sty {
-                            ty::TyFnPtr(_) => {
-                                let mut src = self.eval_operand(operand)?;
-                                src.ty = dest_ty;
-                                self.write_value(src, dest)?;
-                            }
-                            ref other => bug!("fn to unsafe fn cast on {:?}", other),
-                        }
-                    }
-
-                    ClosureFnPointer => {
-                        match self.eval_operand(operand)?.ty.sty {
-                            ty::TyClosure(def_id, substs) => {
-                                let substs = self.tcx.subst_and_normalize_erasing_regions(
-                                    self.substs(),
-                                    ty::ParamEnv::reveal_all(),
-                                    &substs,
-                                );
-                                let instance = ty::Instance::resolve_closure(
-                                    *self.tcx,
-                                    def_id,
-                                    substs,
-                                    ty::ClosureKind::FnOnce,
-                                );
-                                let fn_ptr = self.memory.create_fn_alloc(instance);
-                                let valty = ValTy {
-                                    value: Value::Scalar(fn_ptr.into()),
-                                    ty: dest_ty,
-                                };
-                                self.write_value(valty, dest)?;
-                            }
-                            ref other => bug!("closure fn pointer on {:?}", other),
-                        }
-                    }
-                }
+                let src = self.eval_operand(operand)?;
+                self.cast(src, kind, dest_ty, dest)?;
             }
 
             Discriminant(ref place) => {
@@ -1565,7 +1438,7 @@ fn unsize_into_ptr(
         }
     }
 
-    fn unsize_into(
+    crate fn unsize_into(
         &mut self,
         src: Value,
         src_layout: TyLayout<'tcx>,
index 3b3c28f6ae2655c2dbd9df61e247ad1be3e33b81..d15dd14084aad5faf2521d3e91942d012bf6ff8d 100644 (file)
@@ -17,7 +17,7 @@
 use rustc::mir::{NullOp, StatementKind, Statement, BasicBlock, LocalKind};
 use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
 use rustc::mir::visit::{Visitor, PlaceContext};
-use rustc::mir::interpret::ConstEvalErr;
+use rustc::mir::interpret::{ConstEvalErr, EvalErrorKind};
 use rustc::ty::{TyCtxt, self, Instance};
 use rustc::mir::interpret::{Value, Scalar, GlobalId, EvalResult};
 use interpret::EvalContext;
@@ -145,17 +145,23 @@ fn use_ecx<F, T>(
         let r = match f(self) {
             Ok(val) => Some(val),
             Err(err) => {
-                let (frames, span) = self.ecx.generate_stacktrace(None);
-                let err = ConstEvalErr {
-                    span,
-                    error: err,
-                    stacktrace: frames,
-                };
-                err.report_as_lint(
-                    self.ecx.tcx,
-                    "this expression will panic at runtime",
-                    lint_root,
-                );
+                match err.kind {
+                    // don't report these, they make no sense in a const prop context
+                    EvalErrorKind::MachineError(_) => {},
+                    _ => {
+                        let (frames, span) = self.ecx.generate_stacktrace(None);
+                        let err = ConstEvalErr {
+                            span,
+                            error: err,
+                            stacktrace: frames,
+                        };
+                        err.report_as_lint(
+                            self.ecx.tcx,
+                            "this expression will panic at runtime",
+                            lint_root,
+                        );
+                    }
+                }
                 None
             },
         };
@@ -257,10 +263,25 @@ fn const_prop(
             },
             Rvalue::Repeat(..) |
             Rvalue::Ref(..) |
-            Rvalue::Cast(..) |
             Rvalue::Aggregate(..) |
             Rvalue::NullaryOp(NullOp::Box, _) |
             Rvalue::Discriminant(..) => None,
+
+            Rvalue::Cast(kind, ref operand, _) => {
+                let (value, ty, span) = self.eval_operand(operand, source_info)?;
+                self.use_ecx(source_info, |this| {
+                    let dest_ptr = this.ecx.alloc_ptr(place_ty)?;
+                    let place_align = this.ecx.layout_of(place_ty)?.align;
+                    let dest = ::interpret::Place::from_ptr(dest_ptr, place_align);
+                    this.ecx.cast(ValTy { value, ty }, kind, place_ty, dest)?;
+                    Ok((
+                        Value::ByRef(dest_ptr.into(), place_align),
+                        place_ty,
+                        span,
+                    ))
+                })
+            }
+
             // FIXME(oli-obk): evaluate static/constant slice lengths
             Rvalue::Len(_) => None,
             Rvalue::NullaryOp(NullOp::SizeOf, ty) => {
@@ -354,7 +375,6 @@ fn const_prop(
                     )
                 } else {
                     if overflow {
-                        use rustc::mir::interpret::EvalErrorKind;
                         let err = EvalErrorKind::Overflow(op).into();
                         let _: Option<()> = self.use_ecx(source_info, |_| Err(err));
                         return None;
index ab383287773a1e14e835ae559f168d18cd9175f4..7b13c98b31ddf4ba31438711da3000c36f488e6a 100644 (file)
@@ -237,7 +237,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             hir::ItemKind::Use(..) => {}
             // The interface is empty
             hir::ItemKind::GlobalAsm(..) => {}
-            hir::ItemKind::Existential(..) => {
+            hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => {
                 if item_level.is_some() {
                     // Reach the (potentially private) type and the API being exposed
                     self.reach(item.id).ty().predicates();
@@ -245,6 +245,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             }
             // Visit everything
             hir::ItemKind::Const(..) | hir::ItemKind::Static(..) |
+            hir::ItemKind::Existential(..) |
             hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => {
                 if item_level.is_some() {
                     self.reach(item.id).generics().predicates().ty();
@@ -1165,6 +1166,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
                                          hir::ImplItemKind::Method(..) => {
                                              self.access_levels.is_reachable(impl_item.id)
                                          }
+                                         hir::ImplItemKind::Existential(..) |
                                          hir::ImplItemKind::Type(_) => false,
                                      }
                                  });
@@ -1566,7 +1568,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             hir::ItemKind::Use(..) => {}
             // No subitems
             hir::ItemKind::GlobalAsm(..) => {}
-            hir::ItemKind::Existential(..) => {
+            hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => {
                 // Check the traits being exposed, as they're separate,
                 // e.g. `impl Iterator<Item=T>` has two predicates,
                 // `X: Iterator` and `<X as Iterator>::Item == T`,
@@ -1577,6 +1579,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             }
             // Subitems of these items have inherited publicity
             hir::ItemKind::Const(..) | hir::ItemKind::Static(..) | hir::ItemKind::Fn(..) |
+            hir::ItemKind::Existential(..) |
             hir::ItemKind::Ty(..) => {
                 self.check(item.id, item_visibility).generics().predicates().ty();
 
index 29312912a2423a85c5371ada81ef20e087b496df..e00919547fc437b60ce67abb3c3639093c671dc5 100644 (file)
@@ -361,6 +361,11 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, expansion: Mark) {
                 self.define(parent, ident, TypeNS, (def, vis, sp, expansion));
             }
 
+            ItemKind::Existential(_, _) => {
+                let def = Def::Existential(self.definitions.local_def_id(item.id));
+                self.define(parent, ident, TypeNS, (def, vis, sp, expansion));
+            }
+
             ItemKind::Enum(ref enum_definition, _) => {
                 let def = Def::Enum(self.definitions.local_def_id(item.id));
                 let module_kind = ModuleKind::Def(def, ident.name);
index 177e4ed8cf376d31a08d3f8530d798dd278c729c..d98434796d5bdba35f144e6796740bcf1f51e213 100644 (file)
@@ -207,7 +207,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
                 Def::AssociatedTy(..) | Def::PrimTy(..) | Def::Fn(..) | Def::Const(..) |
                 Def::Static(..) | Def::StructCtor(..) | Def::VariantCtor(..) | Def::Method(..) |
                 Def::AssociatedConst(..) | Def::Local(..) | Def::Upvar(..) | Def::Label(..) |
-                Def::Existential(..) |
+                Def::Existential(..) | Def::AssociatedExistential(..) |
                 Def::Macro(..) | Def::GlobalAsm(..) | Def::Err =>
                     bug!("TypeParametersFromOuterFunction should only be used with Def::SelfTy or \
                          Def::TyParam")
@@ -535,6 +535,7 @@ fn is_expected(self, def: Def) -> bool {
                 Def::Struct(..) | Def::Union(..) | Def::Enum(..) |
                 Def::Trait(..) | Def::TyAlias(..) | Def::AssociatedTy(..) |
                 Def::PrimTy(..) | Def::TyParam(..) | Def::SelfTy(..) |
+                Def::Existential(..) |
                 Def::TyForeign(..) => true,
                 _ => false,
             },
@@ -2148,6 +2149,7 @@ fn resolve_item(&mut self, item: &Item) {
         match item.node {
             ItemKind::Enum(_, ref generics) |
             ItemKind::Ty(_, ref generics) |
+            ItemKind::Existential(_, ref generics) |
             ItemKind::Struct(_, ref generics) |
             ItemKind::Union(_, ref generics) |
             ItemKind::Fn(_, _, ref generics, _) => {
@@ -2486,6 +2488,18 @@ fn resolve_implementation(&mut self,
 
                                             this.visit_ty(ty);
                                         }
+                                        ImplItemKind::Existential(ref bounds) => {
+                                            // If this is a trait impl, ensure the type
+                                            // exists in trait
+                                            this.check_trait_item(impl_item.ident,
+                                                                TypeNS,
+                                                                impl_item.span,
+                                                |n, s| TypeNotMemberOfTrait(n, s));
+
+                                            for bound in bounds {
+                                                this.visit_param_bound(bound);
+                                            }
+                                        }
                                         ImplItemKind::Macro(_) =>
                                             panic!("unexpanded macro in resolve!"),
                                     }
index 34dcdfb757f7390f99fc7c9b8d13c8cca505c60e..ac7085a55cfe04751e62d5edf1d6c790843b7dfe 100644 (file)
@@ -1238,6 +1238,16 @@ fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
                 // trait.
                 self.visit_ty(ty)
             }
+            ast::ImplItemKind::Existential(ref bounds) => {
+                // FIXME uses of the assoc type should ideally point to this
+                // 'def' and the name here should be a ref to the def in the
+                // trait.
+                for bound in bounds.iter() {
+                    if let ast::GenericBound::Trait(trait_ref, _) = bound {
+                        self.process_path(trait_ref.trait_ref.ref_id, &trait_ref.trait_ref.path)
+                    }
+                }
+            }
             ast::ImplItemKind::Macro(_) => {}
         }
     }
@@ -1477,6 +1487,36 @@ fn visit_item(&mut self, item: &'l ast::Item) {
                 self.visit_ty(&ty);
                 self.process_generic_params(ty_params, item.span, &qualname, item.id);
             }
+            Existential(ref _bounds, ref ty_params) => {
+                let qualname = format!("::{}", self.tcx.node_path_str(item.id));
+                // FIXME do something with _bounds
+                let value = String::new();
+                let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type);
+                if !self.span.filter_generated(sub_span, item.span) {
+                    let span = self.span_from_span(sub_span.expect("No span found for typedef"));
+                    let id = ::id_from_node_id(item.id, &self.save_ctxt);
+
+                    self.dumper.dump_def(
+                        &access_from!(self.save_ctxt, item),
+                        Def {
+                            kind: DefKind::Type,
+                            id,
+                            span,
+                            name: item.ident.to_string(),
+                            qualname: qualname.clone(),
+                            value,
+                            parent: None,
+                            children: vec![],
+                            decl_id: None,
+                            docs: self.save_ctxt.docs_for_attrs(&item.attrs),
+                            sig: sig::item_signature(item, &self.save_ctxt),
+                            attributes: lower_attributes(item.attrs.clone(), &self.save_ctxt),
+                        },
+                    );
+                }
+
+                self.process_generic_params(ty_params, item.span, &qualname, item.id);
+            }
             Mac(_) => (),
             _ => visit::walk_item(self, item),
         }
index f2620c04754b8ab2fd05fd30a64c3cfc11f4dbc0..c84f194f0232a7b3fd81944773af6806910ffbe3 100644 (file)
@@ -749,6 +749,7 @@ fn fn_type(path: &ast::Path) -> bool {
             HirDef::TyAlias(def_id) |
             HirDef::TyForeign(def_id) |
             HirDef::TraitAlias(def_id) |
+            HirDef::AssociatedExistential(def_id) |
             HirDef::AssociatedTy(def_id) |
             HirDef::Trait(def_id) |
             HirDef::Existential(def_id) |
index 70feba1eff866bf2a571269847e8c4cb9226b27a..130325628796ecbd74f0d253e290c02954631ac7 100644 (file)
@@ -444,6 +444,18 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
                     refs: vec![],
                 })
             }
+            ast::ItemKind::Existential(ref bounds, ref generics) => {
+                let text = "existential type ".to_owned();
+                let mut sig = name_and_generics(text, offset, generics, self.id, self.ident, scx)?;
+
+                if !bounds.is_empty() {
+                    sig.text.push_str(": ");
+                    sig.text.push_str(&pprust::bounds_to_string(bounds));
+                }
+                sig.text.push(';');
+
+                Ok(sig)
+            }
             ast::ItemKind::Ty(ref ty, ref generics) => {
                 let text = "type ".to_owned();
                 let mut sig = name_and_generics(text, offset, generics, self.id, self.ident, scx)?;
index f85e7b0685889f35a8bf19dbf6ff569ad6577211..a2dbf2aaca30e0d0e2b04696d5261932fe7dcdec 100644 (file)
@@ -1035,6 +1035,20 @@ pub fn def_to_ty(&self,
 
         let span = path.span;
         match path.def {
+            Def::Existential(did) => {
+                // check for desugared impl trait
+                if ty::is_impl_trait_defn(tcx, did).is_some() {
+                    let lifetimes = &path.segments[0].args.as_ref().unwrap().args;
+                    return self.impl_trait_ty_to_ty(did, lifetimes);
+                }
+                let item_segment = path.segments.split_last().unwrap();
+                self.prohibit_generics(item_segment.1);
+                let substs = self.ast_path_substs_for_ty(span, did, item_segment.0);
+                self.normalize_ty(
+                    span,
+                    tcx.mk_anon(did, substs),
+                )
+            }
             Def::Enum(did) | Def::TyAlias(did) | Def::Struct(did) |
             Def::Union(did) | Def::TyForeign(did) => {
                 assert_eq!(opt_self_ty, None);
@@ -1095,11 +1109,6 @@ pub fn def_to_ty(&self,
                     hir::TyStr => tcx.mk_str()
                 }
             }
-            Def::Existential(exist_ty_did) => {
-                assert!(exist_ty_did.is_local());
-                let lifetimes = &path.segments[0].args.as_ref().unwrap().args;
-                self.impl_trait_ty_to_ty(exist_ty_did, lifetimes)
-            }
             Def::Err => {
                 self.set_tainted_by_errors();
                 return self.tcx().types.err;
@@ -1464,35 +1473,34 @@ impl<'a, 'gcx, 'tcx> Bounds<'tcx> {
     pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, param_ty: Ty<'tcx>)
                       -> Vec<ty::Predicate<'tcx>>
     {
-        let mut vec = Vec::new();
-
         // If it could be sized, and is, add the sized predicate
-        if self.implicitly_sized {
-            if let Some(sized) = tcx.lang_items().sized_trait() {
+        let sized_predicate = if self.implicitly_sized {
+            tcx.lang_items().sized_trait().map(|sized| {
                 let trait_ref = ty::TraitRef {
                     def_id: sized,
                     substs: tcx.mk_substs_trait(param_ty, &[])
                 };
-                vec.push(trait_ref.to_predicate());
-            }
-        }
-
-        for &region_bound in &self.region_bounds {
-            // account for the binder being introduced below; no need to shift `param_ty`
-            // because, at present at least, it can only refer to early-bound regions
-            let region_bound = tcx.mk_region(ty::fold::shift_region(*region_bound, 1));
-            vec.push(
-                ty::Binder::dummy(ty::OutlivesPredicate(param_ty, region_bound)).to_predicate());
-        }
-
-        for bound_trait_ref in &self.trait_bounds {
-            vec.push(bound_trait_ref.to_predicate());
-        }
-
-        for projection in &self.projection_bounds {
-            vec.push(projection.to_predicate());
-        }
+                trait_ref.to_predicate()
+            })
+        } else {
+            None
+        };
 
-        vec
+        sized_predicate.into_iter().chain(
+            self.region_bounds.iter().map(|&region_bound| {
+                // account for the binder being introduced below; no need to shift `param_ty`
+                // because, at present at least, it can only refer to early-bound regions
+                let region_bound = tcx.mk_region(ty::fold::shift_region(*region_bound, 1));
+                ty::Binder::dummy(ty::OutlivesPredicate(param_ty, region_bound)).to_predicate()
+            }).chain(
+                self.trait_bounds.iter().map(|bound_trait_ref| {
+                    bound_trait_ref.to_predicate()
+                })
+            ).chain(
+                self.projection_bounds.iter().map(|projection| {
+                    projection.to_predicate()
+                })
+            )
+        ).collect()
     }
 }
index bee866db9e467d5560ca2daf3fbfdcb824311206..301072778d094e6bc1d43074d60f8089ac570d04 100644 (file)
@@ -1332,6 +1332,7 @@ fn has_applicable_self(&self, item: &ty::AssociatedItem) -> bool {
         match self.mode {
             Mode::MethodCall => item.method_has_self_argument,
             Mode::Path => match item.kind {
+                ty::AssociatedKind::Existential |
                 ty::AssociatedKind::Type => false,
                 ty::AssociatedKind::Method | ty::AssociatedKind::Const => true
             },
index 6e09b83a7b059dffe330c6a56026fd11e07020c8..4af89d2148dfc5c0684ccac1abf87af3f120573c 100644 (file)
@@ -1307,6 +1307,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
       hir::ItemKind::Union(..) => {
         check_union(tcx, it.id, it.span);
       }
+      hir::ItemKind::Existential(..) |
       hir::ItemKind::Ty(..) => {
         let def_id = tcx.hir.local_def_id(it.id);
         let pty_ty = tcx.type_of(def_id);
@@ -1427,6 +1428,7 @@ fn check_specialization_validity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let kind = match impl_item.node {
         hir::ImplItemKind::Const(..) => ty::AssociatedKind::Const,
         hir::ImplItemKind::Method(..) => ty::AssociatedKind::Method,
+        hir::ImplItemKind::Existential(..) => ty::AssociatedKind::Existential,
         hir::ImplItemKind::Type(_) => ty::AssociatedKind::Type
     };
 
@@ -1520,6 +1522,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                          err.emit()
                     }
                 }
+                hir::ImplItemKind::Existential(..) |
                 hir::ImplItemKind::Type(_) => {
                     if ty_trait_item.kind == ty::AssociatedKind::Type {
                         if ty_trait_item.defaultness.has_value() {
index d876f41ce13078ce37891c40ebe38e892dd49784..03ecb945cbd3c9497f0f71182ba58ada0d49d37d 100644 (file)
 
 use hir::def_id::DefId;
 use rustc::traits::{self, ObligationCauseCode};
-use rustc::ty::{self, Lift, Ty, TyCtxt, GenericParamDefKind};
-use rustc::ty::subst::Substs;
+use rustc::ty::{self, Lift, Ty, TyCtxt, GenericParamDefKind, TypeFoldable};
+use rustc::ty::subst::{Subst, Substs};
 use rustc::ty::util::ExplicitSelf;
 use rustc::util::nodemap::{FxHashSet, FxHashMap};
 use rustc::middle::lang_items;
+use rustc::infer::anon_types::may_define_existential_type;
 
 use syntax::ast;
 use syntax::feature_gate::{self, GateIssue};
@@ -209,6 +210,10 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     fcx.register_wf_obligation(ty, span, code.clone());
                 }
             }
+            ty::AssociatedKind::Existential => {
+                // FIXME(oli-obk) implement existential types in trait impls
+                unimplemented!()
+            }
         }
 
         implied_bounds
@@ -282,7 +287,7 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             }
         }
 
-        check_where_clauses(tcx, fcx, item.span, def_id);
+        check_where_clauses(tcx, fcx, item.span, def_id, None);
 
         vec![] // no implied bounds in a struct def'n
     });
@@ -291,7 +296,7 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
     let trait_def_id = tcx.hir.local_def_id(item.id);
     for_item(tcx, item).with_fcx(|fcx, _| {
-        check_where_clauses(tcx, fcx, item.span, trait_def_id);
+        check_where_clauses(tcx, fcx, item.span, trait_def_id, None);
         vec![]
     });
 }
@@ -357,7 +362,7 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             }
         }
 
-        check_where_clauses(tcx, fcx, item.span, item_def_id);
+        check_where_clauses(tcx, fcx, item.span, item_def_id, None);
 
         fcx.impl_implied_bounds(item_def_id, item.span)
     });
@@ -369,6 +374,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(
     fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
     span: Span,
     def_id: DefId,
+    return_ty: Option<Ty<'tcx>>,
 ) {
     use ty::subst::Subst;
     use rustc::ty::TypeFoldable;
@@ -482,7 +488,12 @@ fn visit_region(&mut self, _: ty::Region<'tcx>) -> bool {
         traits::Obligation::new(cause, fcx.param_env, pred)
     });
 
-    let predicates = predicates.instantiate_identity(fcx.tcx);
+    let mut predicates = predicates.instantiate_identity(fcx.tcx);
+
+    if let Some(return_ty) = return_ty {
+        predicates.predicates.extend(check_existential_types(tcx, fcx, def_id, span, return_ty));
+    }
+
     let predicates = fcx.normalize_associated_types_in(span, &predicates);
 
     debug!("check_where_clauses: predicates={:?}", predicates.predicates);
@@ -521,7 +532,145 @@ fn check_fn_or_method<'a, 'fcx, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
     // FIXME(#25759) return types should not be implied bounds
     implied_bounds.push(sig.output());
 
-    check_where_clauses(tcx, fcx, span, def_id);
+    check_where_clauses(tcx, fcx, span, def_id, Some(sig.output()));
+}
+
+/// Checks "defining uses" of existential types to ensure that they meet the restrictions laid for
+/// "higher-order pattern unification".
+/// This ensures that inference is tractable.
+/// In particular, definitions of existential types can only use other generics as arguments,
+/// and they cannot repeat an argument. Example:
+///
+/// ```rust
+/// existential type Foo<A, B>;
+///
+/// // ok -- `Foo` is applied to two distinct, generic types.
+/// fn a<T, U>() -> Foo<T, U> { .. }
+///
+/// // not ok -- `Foo` is applied to `T` twice.
+/// fn b<T>() -> Foo<T, T> { .. }
+///
+///
+/// // not ok -- `Foo` is applied to a non-generic type.
+/// fn b<T>() -> Foo<T, u32> { .. }
+/// ```
+///
+fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>(
+    tcx: TyCtxt<'a, 'gcx, 'gcx>,
+    fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
+    fn_def_id: DefId,
+    span: Span,
+    ty: Ty<'tcx>,
+) -> Vec<ty::Predicate<'tcx>> {
+    trace!("check_existential_types: {:?}, {:?}", ty, ty.sty);
+    let mut substituted_predicates = Vec::new();
+    ty.fold_with(&mut ty::fold::BottomUpFolder {
+        tcx: fcx.tcx,
+        fldop: |ty| {
+            if let ty::TyAnon(def_id, substs) = ty.sty {
+                trace!("check_existential_types: anon_ty, {:?}, {:?}", def_id, substs);
+                let generics = tcx.generics_of(def_id);
+                // only check named existential types
+                if generics.parent.is_none() {
+                    let anon_node_id = tcx.hir.as_local_node_id(def_id).unwrap();
+                    if may_define_existential_type(tcx, fn_def_id, anon_node_id) {
+                        trace!("check_existential_types may define. Generics: {:#?}", generics);
+                        let mut seen: FxHashMap<_, Vec<_>> = FxHashMap();
+                        for (subst, param) in substs.iter().zip(&generics.params) {
+                            match subst.unpack() {
+                                ty::subst::UnpackedKind::Type(ty) => match ty.sty {
+                                    ty::TyParam(..) => {},
+                                    // prevent `fn foo() -> Foo<u32>` from being defining
+                                    _ => {
+                                        tcx
+                                            .sess
+                                            .struct_span_err(
+                                                span,
+                                                "non-defining existential type use \
+                                                 in defining scope",
+                                            )
+                                            .span_note(
+                                                tcx.def_span(param.def_id),
+                                                &format!(
+                                                    "used non-generic type {} for \
+                                                     generic parameter",
+                                                    ty,
+                                                ),
+                                            )
+                                            .emit();
+                                    },
+                                }, // match ty
+                                ty::subst::UnpackedKind::Lifetime(region) => {
+                                    let param_span = tcx.def_span(param.def_id);
+                                    if let ty::ReStatic = region {
+                                        tcx
+                                            .sess
+                                            .struct_span_err(
+                                                span,
+                                                "non-defining existential type use \
+                                                    in defining scope",
+                                            )
+                                            .span_label(
+                                                param_span,
+                                                "cannot use static lifetime, use a bound lifetime \
+                                                instead or remove the lifetime parameter from the \
+                                                existential type",
+                                            )
+                                            .emit();
+                                    } else {
+                                        seen.entry(region).or_default().push(param_span);
+                                    }
+                                },
+                            } // match subst
+                        } // for (subst, param)
+                        for (_, spans) in seen {
+                            if spans.len() > 1 {
+                                tcx
+                                    .sess
+                                    .struct_span_err(
+                                        span,
+                                        "non-defining existential type use \
+                                            in defining scope",
+                                    ).
+                                    span_note(
+                                        spans,
+                                        "lifetime used multiple times",
+                                    )
+                                    .emit();
+                            }
+                        }
+                    } // if may_define_existential_type
+
+                    // now register the bounds on the parameters of the existential type
+                    // so the parameters given by the function need to fulfil them
+                    // ```rust
+                    // existential type Foo<T: Bar>: 'static;
+                    // fn foo<U>() -> Foo<U> { .. *}
+                    // ```
+                    // becomes
+                    // ```rust
+                    // existential type Foo<T: Bar>: 'static;
+                    // fn foo<U: Bar>() -> Foo<U> { .. *}
+                    // ```
+                    let predicates = tcx.predicates_of(def_id);
+                    trace!(
+                        "check_existential_types may define. adding predicates: {:#?}",
+                        predicates,
+                    );
+                    for &pred in predicates.predicates.iter() {
+                        let substituted_pred = pred.subst(fcx.tcx, substs);
+                        // Avoid duplication of predicates that contain no parameters, for example.
+                        if !predicates.predicates.contains(&substituted_pred) {
+                            substituted_predicates.push(substituted_pred);
+                        }
+                    }
+                } // if is_named_existential_type
+            } // if let TyAnon
+            ty
+        },
+        reg_op: |reg| reg,
+    });
+    substituted_predicates
 }
 
 fn check_method_receiver<'fcx, 'gcx, 'tcx>(fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
index 3207ac44948f471885937034d32a4d5716010b10..b37f489b2c721419002f3ad2d96fae2e51153ecd 100644 (file)
 use rustc::hir::def_id::{DefId, DefIndex};
 use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
 use rustc::infer::InferCtxt;
+use rustc::ty::subst::UnpackedKind;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::adjustment::{Adjust, Adjustment};
-use rustc::ty::fold::{TypeFoldable, TypeFolder};
+use rustc::ty::fold::{TypeFoldable, TypeFolder, BottomUpFolder};
 use rustc::util::nodemap::DefIdSet;
 use syntax::ast;
 use syntax_pos::Span;
@@ -388,11 +389,109 @@ fn visit_anon_types(&mut self, span: Span) {
         for (&def_id, anon_defn) in self.fcx.anon_types.borrow().iter() {
             let node_id = self.tcx().hir.as_local_node_id(def_id).unwrap();
             let instantiated_ty = self.resolve(&anon_defn.concrete_ty, &node_id);
-            let definition_ty = self.fcx.infer_anon_definition_from_instantiation(
-                def_id,
-                anon_defn,
-                instantiated_ty,
-            );
+
+            let generics = self.tcx().generics_of(def_id);
+
+            let definition_ty = if generics.parent.is_some() {
+                // impl trait
+                self.fcx.infer_anon_definition_from_instantiation(
+                    def_id,
+                    anon_defn,
+                    instantiated_ty,
+                )
+            } else {
+                // prevent
+                // * `fn foo<T>() -> Foo<T>`
+                // * `fn foo<T: Bound + Other>() -> Foo<T>`
+                // from being defining
+
+                // Also replace all generic params with the ones from the existential type
+                // definition so
+                // ```rust
+                // existential type Foo<T>: 'static;
+                // fn foo<U>() -> Foo<U> { .. }
+                // ```
+                // figures out the concrete type with `U`, but the stored type is with `T`
+                instantiated_ty.fold_with(&mut BottomUpFolder {
+                    tcx: self.tcx().global_tcx(),
+                    fldop: |ty| {
+                        trace!("checking type {:?}: {:#?}", ty, ty.sty);
+                        // find a type parameter
+                        if let ty::TyParam(..) = ty.sty {
+                            // look it up in the substitution list
+                            assert_eq!(anon_defn.substs.len(), generics.params.len());
+                            for (subst, param) in anon_defn.substs.iter().zip(&generics.params) {
+                                if let UnpackedKind::Type(subst) = subst.unpack() {
+                                    if subst == ty {
+                                        // found it in the substitution list, replace with the
+                                        // parameter from the existential type
+                                        return self
+                                            .tcx()
+                                            .global_tcx()
+                                            .mk_ty_param(param.index, param.name);
+                                    }
+                                }
+                            }
+                            self.tcx()
+                                .sess
+                                .struct_span_err(
+                                    span,
+                                    &format!(
+                                        "type parameter `{}` is part of concrete type but not used \
+                                        in parameter list for existential type",
+                                        ty,
+                                    ),
+                                )
+                                .emit();
+                            return self.tcx().types.err;
+                        }
+                        ty
+                    },
+                    reg_op: |region| {
+                        match region {
+                            // ignore static regions
+                            ty::ReStatic => region,
+                            _ => {
+                                trace!("checking {:?}", region);
+                                for (subst, p) in anon_defn.substs.iter().zip(&generics.params) {
+                                    if let UnpackedKind::Lifetime(subst) = subst.unpack() {
+                                        if subst == region {
+                                            // found it in the substitution list, replace with the
+                                            // parameter from the existential type
+                                            let reg = ty::EarlyBoundRegion {
+                                                def_id: p.def_id,
+                                                index: p.index,
+                                                name: p.name,
+                                            };
+                                            trace!("replace {:?} with {:?}", region, reg);
+                                            return self.tcx().global_tcx()
+                                                .mk_region(ty::ReEarlyBound(reg));
+                                        }
+                                    }
+                                }
+                                trace!("anon_defn: {:#?}", anon_defn);
+                                trace!("generics: {:#?}", generics);
+                                self.tcx().sess
+                                    .struct_span_err(
+                                        span,
+                                        "non-defining existential type use in defining scope",
+                                    )
+                                    .span_label(
+                                        span,
+                                        format!(
+                                            "lifetime `{}` is part of concrete type but not used \
+                                            in parameter list of existential type",
+                                            region,
+                                        ),
+                                    )
+                                    .emit();
+                                self.tcx().global_tcx().mk_region(ty::ReStatic)
+                            }
+                        }
+                    }
+                })
+            };
+
             let old = self.tables.concrete_existential_types.insert(def_id, definition_ty);
             if let Some(old) = old {
                 if old != definition_ty {
index 03fa7f521d9ad7dec011e3d35fb062bca388be7d..5193113d82c8a4133db12fd50e8a855b0457713a 100644 (file)
@@ -269,6 +269,7 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 ItemKind::Fn(.., ref generics, _) |
                 ItemKind::Impl(_, _, _, ref generics, ..) |
                 ItemKind::Ty(_, ref generics) |
+                ItemKind::Existential(ExistTy { ref generics, impl_trait_fn: None, ..}) |
                 ItemKind::Enum(_, ref generics) |
                 ItemKind::Struct(_, ref generics) |
                 ItemKind::Union(_, ref generics) => generics,
@@ -419,7 +420,11 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
                 convert_variant_ctor(tcx, struct_def.id());
             }
         },
-        hir::ItemKind::Existential(..) => {}
+
+        // Desugared from `impl Trait` -> visited by the function's return type
+        hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => {}
+
+        hir::ItemKind::Existential(..) |
         hir::ItemKind::Ty(..) |
         hir::ItemKind::Static(..) |
         hir::ItemKind::Const(..) |
@@ -1002,6 +1007,13 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     })
 }
 
+fn report_assoc_ty_on_inherent_impl<'a, 'tcx>(
+    tcx: TyCtxt<'a, 'tcx, 'tcx>,
+    span: Span,
+) {
+    span_err!(tcx.sess, span, E0202, "associated types are not allowed in inherent impls");
+}
+
 fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                      def_id: DefId)
                      -> Ty<'tcx> {
@@ -1034,10 +1046,16 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     tcx.mk_fn_def(def_id, substs)
                 }
                 ImplItemKind::Const(ref ty, _) => icx.to_ty(ty),
+                ImplItemKind::Existential(ref _bounds) => {
+                    if tcx.impl_trait_ref(tcx.hir.get_parent_did(node_id)).is_none() {
+                        report_assoc_ty_on_inherent_impl(tcx, item.span);
+                    }
+                    // FIXME(oli-obk) implement existential types in trait impls
+                    unimplemented!()
+                }
                 ImplItemKind::Type(ref ty) => {
                     if tcx.impl_trait_ref(tcx.hir.get_parent_did(node_id)).is_none() {
-                        span_err!(tcx.sess, item.span, E0202,
-                                  "associated types are not allowed in inherent impls");
+                        report_assoc_ty_on_inherent_impl(tcx, item.span);
                     }
 
                     icx.to_ty(ty)
@@ -1062,8 +1080,9 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     let substs = Substs::identity_for_item(tcx, def_id);
                     tcx.mk_adt(def, substs)
                 }
-                // this is only reachable once we have named existential types
-                ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, .. }) => unimplemented!(),
+                ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, .. }) => {
+                    find_existential_constraints(tcx, def_id)
+                },
                 // existential types desugared from impl Trait
                 ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(owner), .. }) => {
                     tcx.typeck_tables_of(owner).concrete_existential_types[&def_id]
@@ -1153,6 +1172,98 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     }
 }
 
+fn find_existential_constraints<'a, 'tcx>(
+    tcx: TyCtxt<'a, 'tcx, 'tcx>,
+    def_id: DefId,
+) -> ty::Ty<'tcx> {
+    use rustc::hir::map::*;
+    use rustc::hir::*;
+
+    struct ConstraintLocator<'a, 'tcx: 'a> {
+        tcx: TyCtxt<'a, 'tcx, 'tcx>,
+        def_id: DefId,
+        found: Option<(Span, ty::Ty<'tcx>)>,
+    }
+    impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> {
+        fn check(&mut self, def_id: DefId) {
+            // don't try to check items that cannot possibly constrain the type
+            if !self.tcx.has_typeck_tables(def_id) {
+                return;
+            }
+            let ty = self
+                .tcx
+                .typeck_tables_of(def_id)
+                .concrete_existential_types
+                .get(&self.def_id)
+                .cloned();
+            if let Some(ty) = ty {
+                // FIXME(oli-obk): trace the actual span from inference to improve errors
+                let span = self.tcx.def_span(def_id);
+                if let Some((prev_span, prev_ty)) = self.found {
+                    if ty != prev_ty {
+                        // found different concrete types for the existential type
+                        let mut err = self.tcx.sess.struct_span_err(
+                            span,
+                            "defining existential type use differs from previous",
+                        );
+                        err.span_note(prev_span, "previous use here");
+                        err.emit();
+                    }
+                } else {
+                    self.found = Some((span, ty));
+                }
+            }
+        }
+    }
+    impl<'a, 'tcx> intravisit::Visitor<'tcx> for ConstraintLocator<'a, 'tcx> {
+        fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
+            intravisit::NestedVisitorMap::All(&self.tcx.hir)
+        }
+        fn visit_item(&mut self, it: &'tcx Item) {
+            let def_id = self.tcx.hir.local_def_id(it.id);
+            // the existential type itself or its children are not within its reveal scope
+            if def_id != self.def_id {
+                self.check(def_id);
+                intravisit::walk_item(self, it);
+            }
+        }
+        fn visit_impl_item(&mut self, it: &'tcx ImplItem) {
+            let def_id = self.tcx.hir.local_def_id(it.id);
+            // the existential type itself or its children are not within its reveal scope
+            if def_id != self.def_id {
+                self.check(def_id);
+                intravisit::walk_impl_item(self, it);
+            }
+        }
+        fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
+            let def_id = self.tcx.hir.local_def_id(it.id);
+            self.check(def_id);
+            intravisit::walk_trait_item(self, it);
+        }
+    }
+    let mut locator = ConstraintLocator { def_id, tcx, found: None };
+    let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
+    let parent = tcx.hir.get_parent(node_id);
+    if parent == ast::CRATE_NODE_ID {
+        intravisit::walk_crate(&mut locator, tcx.hir.krate());
+    } else {
+        match tcx.hir.get(parent) {
+            NodeItem(ref it) => intravisit::walk_item(&mut locator, it),
+            NodeImplItem(ref it) => intravisit::walk_impl_item(&mut locator, it),
+            NodeTraitItem(ref it) => intravisit::walk_trait_item(&mut locator, it),
+            other => bug!("{:?} is not a valid parent of an existential type item", other),
+        }
+    }
+    match locator.found {
+        Some((_, ty)) => ty,
+        None => {
+            let span = tcx.def_span(def_id);
+            tcx.sess.span_err(span, "could not find defining uses");
+            tcx.types.err
+        }
+    }
+}
+
 fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     def_id: DefId)
                     -> ty::PolyFnSig<'tcx> {
@@ -1366,6 +1477,9 @@ fn explicit_predicates_of<'a, 'tcx>(
 
     let icx = ItemCtxt::new(tcx, def_id);
     let no_generics = hir::Generics::empty();
+
+    let mut predicates = vec![];
+
     let ast_generics = match node {
         NodeTraitItem(item) => {
             &item.generics
@@ -1391,23 +1505,28 @@ fn explicit_predicates_of<'a, 'tcx>(
                     is_trait = Some((ty::TraitRef::identity(tcx, def_id), items));
                     generics
                 }
-                ItemKind::Existential(ref exist_ty) => {
+                ItemKind::Existential(ExistTy { ref bounds, impl_trait_fn, ref generics }) => {
                     let substs = Substs::identity_for_item(tcx, def_id);
                     let anon_ty = tcx.mk_anon(def_id, substs);
 
                     // Collect the bounds, i.e. the `A+B+'c` in `impl A+B+'c`.
                     let bounds = compute_bounds(&icx,
                                                 anon_ty,
-                                                &exist_ty.bounds,
+                                                bounds,
                                                 SizedByDefault::Yes,
                                                 tcx.def_span(def_id));
 
-                    let predicates = bounds.predicates(tcx, anon_ty);
-
-                    return ty::GenericPredicates {
-                        parent: None,
-                        predicates: predicates
-                    };
+                    if impl_trait_fn.is_some() {
+                        // impl Trait
+                        return ty::GenericPredicates {
+                            parent: None,
+                            predicates: bounds.predicates(tcx, anon_ty),
+                        };
+                    } else {
+                        // named existential types
+                        predicates.extend(bounds.predicates(tcx, anon_ty));
+                        generics
+                    }
                 }
 
                 _ => &no_generics,
@@ -1429,8 +1548,6 @@ fn explicit_predicates_of<'a, 'tcx>(
     let parent_count = generics.parent_count as u32;
     let has_own_self = generics.has_self && parent_count == 0;
 
-    let mut predicates = vec![];
-
     // Below we'll consider the bounds on the type parameters (including `Self`)
     // and the explicit where-clauses, but to get the full set of predicates
     // on a trait we need to add in the supertrait bounds and bounds found on
index 6f0e46b3afee11ba60c5445fd7e19726f6939d6d..690bf1c550c0e5d2236783c86f26d7d3c4235e41 100644 (file)
@@ -21,6 +21,7 @@ pub enum Namespace {
 impl From<ty::AssociatedKind> for Namespace {
     fn from(a_kind: ty::AssociatedKind) -> Self {
         match a_kind {
+            ty::AssociatedKind::Existential |
             ty::AssociatedKind::Type => Namespace::Type,
             ty::AssociatedKind::Const |
             ty::AssociatedKind::Method => Namespace::Value,
@@ -31,6 +32,7 @@ fn from(a_kind: ty::AssociatedKind) -> Self {
 impl<'a> From <&'a hir::ImplItemKind> for Namespace {
     fn from(impl_kind: &'a hir::ImplItemKind) -> Self {
         match *impl_kind {
+            hir::ImplItemKind::Existential(..) |
             hir::ImplItemKind::Type(..) => Namespace::Type,
             hir::ImplItemKind::Const(..) |
             hir::ImplItemKind::Method(..) => Namespace::Value,
index 2bf1f6e553f3ddab6acc186990d9a5cf18594a1a..b7edf73f7ceda7afd782e04003f60effceab47cc 100644 (file)
@@ -496,6 +496,11 @@ pub fn stable_since(&self) -> Option<&str> {
         self.stability.as_ref().map(|s| &s.since[..])
     }
 
+    pub fn is_non_exhaustive(&self) -> bool {
+        self.attrs.other_attrs.iter()
+            .any(|a| a.name().as_str() == "non_exhaustive")
+    }
+
     /// Returns a documentation-level item type from the item.
     pub fn type_(&self) -> ItemType {
         ItemType::from(self)
@@ -512,6 +517,7 @@ pub enum ItemEnum {
     FunctionItem(Function),
     ModuleItem(Module),
     TypedefItem(Typedef, bool /* is associated type */),
+    ExistentialItem(Existential, bool /* is associated type */),
     StaticItem(Static),
     ConstantItem(Constant),
     TraitItem(Trait),
@@ -545,6 +551,7 @@ pub fn generics(&self) -> Option<&Generics> {
             ItemEnum::EnumItem(ref e) => &e.generics,
             ItemEnum::FunctionItem(ref f) => &f.generics,
             ItemEnum::TypedefItem(ref t, _) => &t.generics,
+            ItemEnum::ExistentialItem(ref t, _) => &t.generics,
             ItemEnum::TraitItem(ref t) => &t.generics,
             ItemEnum::ImplItem(ref i) => &i.generics,
             ItemEnum::TyMethodItem(ref i) => &i.generics,
@@ -596,6 +603,7 @@ fn clean(&self, cx: &DocContext) -> Item {
         items.extend(self.foreigns.iter().flat_map(|x| x.clean(cx)));
         items.extend(self.mods.iter().map(|x| x.clean(cx)));
         items.extend(self.typedefs.iter().map(|x| x.clean(cx)));
+        items.extend(self.existentials.iter().map(|x| x.clean(cx)));
         items.extend(self.statics.iter().map(|x| x.clean(cx)));
         items.extend(self.constants.iter().map(|x| x.clean(cx)));
         items.extend(self.traits.iter().map(|x| x.clean(cx)));
@@ -2411,6 +2419,10 @@ fn clean(&self, cx: &DocContext) -> Item {
                 type_: ty.clean(cx),
                 generics: Generics::default(),
             }, true),
+            hir::ImplItemKind::Existential(ref bounds) => ExistentialItem(Existential {
+                bounds: bounds.clean(cx),
+                generics: Generics::default(),
+            }, true),
         };
         Item {
             name: Some(self.ident.name.clean(cx)),
@@ -2554,6 +2566,7 @@ fn clean(&self, cx: &DocContext) -> Item {
                     }, true)
                 }
             }
+            ty::AssociatedKind::Existential => unimplemented!(),
         };
 
         let visibility = match self.container {
@@ -3696,6 +3709,30 @@ fn clean(&self, cx: &DocContext) -> Item {
     }
 }
 
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
+pub struct Existential {
+    pub bounds: Vec<GenericBound>,
+    pub generics: Generics,
+}
+
+impl Clean<Item> for doctree::Existential {
+    fn clean(&self, cx: &DocContext) -> Item {
+        Item {
+            name: Some(self.name.clean(cx)),
+            attrs: self.attrs.clean(cx),
+            source: self.whence.clean(cx),
+            def_id: cx.tcx.hir.local_def_id(self.id.clone()),
+            visibility: self.vis.clean(cx),
+            stability: self.stab.clean(cx),
+            deprecation: self.depr.clean(cx),
+            inner: ExistentialItem(Existential {
+                bounds: self.exist_ty.bounds.clean(cx),
+                generics: self.exist_ty.generics.clean(cx),
+            }, false),
+        }
+    }
+}
+
 #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
 pub struct BareFunctionDecl {
     pub unsafety: hir::Unsafety,
index 6fd9ef234f42317d006a993130b6990d29cf821b..591c660138aeeec490d91d2289452e95233c8814 100644 (file)
@@ -37,6 +37,7 @@ pub struct Module {
     pub mods: Vec<Module>,
     pub id: NodeId,
     pub typedefs: Vec<Typedef>,
+    pub existentials: Vec<Existential>,
     pub statics: Vec<Static>,
     pub constants: Vec<Constant>,
     pub traits: Vec<Trait>,
@@ -68,6 +69,7 @@ pub fn new(name: Option<Name>) -> Module {
             fns        : Vec::new(),
             mods       : Vec::new(),
             typedefs   : Vec::new(),
+            existentials: Vec::new(),
             statics    : Vec::new(),
             constants  : Vec::new(),
             traits     : Vec::new(),
@@ -167,6 +169,17 @@ pub struct Typedef {
     pub depr: Option<attr::Deprecation>,
 }
 
+pub struct Existential {
+    pub exist_ty: hir::ExistTy,
+    pub name: Name,
+    pub id: ast::NodeId,
+    pub attrs: hir::HirVec<ast::Attribute>,
+    pub whence: Span,
+    pub vis: hir::Visibility,
+    pub stab: Option<attr::Stability>,
+    pub depr: Option<attr::Deprecation>,
+}
+
 #[derive(Debug)]
 pub struct Static {
     pub type_: P<hir::Ty>,
index 8e8566cbbde264ca1135f6aaf569d52e73af088f..ddc5d56b474fcecf2ea08fa6b14fe0214e2ad998 100644 (file)
@@ -92,7 +92,16 @@ fn fold_inner_recur(&mut self, inner: ItemEnum) -> ItemEnum {
 
     /// don't override!
     fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
-        let Item { attrs, name, source, visibility, def_id, inner, stability, deprecation } = item;
+        let Item {
+            attrs,
+            name,
+            source,
+            visibility,
+            def_id,
+            inner,
+            stability,
+            deprecation,
+        } = item;
 
         let inner = match inner {
             StrippedItem(box i) => StrippedItem(box self.fold_inner_recur(i)),
index 9b8ada1f6e6b29968e9db708499584b8a01ce396..a5131e327e08e85df06fce1199ce12d0dbb08c55 100644 (file)
@@ -43,6 +43,7 @@ pub enum ItemType {
     Union           = 19,
     ForeignType     = 20,
     Keyword         = 21,
+    Existential     = 22,
 }
 
 
@@ -70,6 +71,7 @@ fn from(item: &'a clean::Item) -> ItemType {
             clean::EnumItem(..)            => ItemType::Enum,
             clean::FunctionItem(..)        => ItemType::Function,
             clean::TypedefItem(..)         => ItemType::Typedef,
+            clean::ExistentialItem(..)     => ItemType::Existential,
             clean::StaticItem(..)          => ItemType::Static,
             clean::ConstantItem(..)        => ItemType::Constant,
             clean::TraitItem(..)           => ItemType::Trait,
@@ -135,6 +137,7 @@ pub fn css_class(&self) -> &'static str {
             ItemType::AssociatedConst => "associatedconstant",
             ItemType::ForeignType     => "foreigntype",
             ItemType::Keyword         => "keyword",
+            ItemType::Existential     => "existential",
         }
     }
 
@@ -148,6 +151,7 @@ pub fn name_space(&self) -> NameSpace {
             ItemType::Trait |
             ItemType::Primitive |
             ItemType::AssociatedType |
+            ItemType::Existential |
             ItemType::ForeignType => NameSpace::Type,
 
             ItemType::ExternCrate |
index 3070458d0beba1fb610266e3326b8385ec78076f..ade33c8dd7d197c7bbb6106aa402f5222e40a415 100644 (file)
@@ -1570,6 +1570,7 @@ struct AllTypes {
     macros: HashSet<ItemEntry>,
     functions: HashSet<ItemEntry>,
     typedefs: HashSet<ItemEntry>,
+    existentials: HashSet<ItemEntry>,
     statics: HashSet<ItemEntry>,
     constants: HashSet<ItemEntry>,
     keywords: HashSet<ItemEntry>,
@@ -1586,6 +1587,7 @@ fn new() -> AllTypes {
             macros: HashSet::with_capacity(100),
             functions: HashSet::with_capacity(100),
             typedefs: HashSet::with_capacity(100),
+            existentials: HashSet::with_capacity(100),
             statics: HashSet::with_capacity(100),
             constants: HashSet::with_capacity(100),
             keywords: HashSet::with_capacity(100),
@@ -1607,6 +1609,7 @@ fn append(&mut self, item_name: String, item_type: &ItemType) {
                 ItemType::Macro => self.macros.insert(ItemEntry::new(new_url, name)),
                 ItemType::Function => self.functions.insert(ItemEntry::new(new_url, name)),
                 ItemType::Typedef => self.typedefs.insert(ItemEntry::new(new_url, name)),
+                ItemType::Existential => self.existentials.insert(ItemEntry::new(new_url, name)),
                 ItemType::Static => self.statics.insert(ItemEntry::new(new_url, name)),
                 ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)),
                 _ => true,
@@ -1650,6 +1653,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         print_entries(f, &self.macros, "Macros", "macros")?;
         print_entries(f, &self.functions, "Functions", "functions")?;
         print_entries(f, &self.typedefs, "Typedefs", "typedefs")?;
+        print_entries(f, &self.existentials, "Existentials", "existentials")?;
         print_entries(f, &self.statics, "Statics", "statics")?;
         print_entries(f, &self.constants, "Constants", "constants")
     }
@@ -2098,6 +2102,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
             clean::ConstantItem(..) => write!(fmt, "Constant ")?,
             clean::ForeignTypeItem => write!(fmt, "Foreign Type ")?,
             clean::KeywordItem(..) => write!(fmt, "Keyword ")?,
+            clean::ExistentialItem(..) => write!(fmt, "Existential Type ")?,
             _ => {
                 // We don't generate pages for any other type.
                 unreachable!();
@@ -2162,6 +2167,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
             clean::ConstantItem(ref c) => item_constant(fmt, self.cx, self.item, c),
             clean::ForeignTypeItem => item_foreign_type(fmt, self.cx, self.item),
             clean::KeywordItem(ref k) => item_keyword(fmt, self.cx, self.item, k),
+            clean::ExistentialItem(ref e, _) => item_existential(fmt, self.cx, self.item, e),
             _ => {
                 // We don't generate pages for any other type.
                 unreachable!();
@@ -2276,6 +2282,37 @@ fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item)
     Ok(())
 }
 
+fn document_non_exhaustive_header(item: &clean::Item) -> &str {
+    if item.is_non_exhaustive() { " (Non-exhaustive)" } else { "" }
+}
+
+fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
+    if item.is_non_exhaustive() {
+        write!(w, "<div class='docblock non-exhaustive non-exhaustive-{}'>", {
+            if item.is_struct() { "struct" } else if item.is_enum() { "enum" } else { "type" }
+        })?;
+
+        if item.is_struct() {
+            write!(w, "Non-exhaustive structs could have additional fields added in future. \
+                       Therefore, non-exhaustive structs cannot be constructed in external crates \
+                       using the traditional <code>Struct {{ .. }}</code> syntax; cannot be \
+                       matched against without a wildcard <code>..</code>; and \
+                       struct update syntax will not work.")?;
+        } else if item.is_enum() {
+            write!(w, "Non-exhaustive enums could have additional variants added in future. \
+                       Therefore, when matching against variants of non-exhaustive enums, an \
+                       extra wildcard arm must be added to account for any future variants.")?;
+        } else {
+            write!(w, "This type will require a wildcard arm in any match statements or \
+                       constructors.")?;
+        }
+
+        write!(w, "</div>")?;
+    }
+
+    Ok(())
+}
+
 fn name_key(name: &str) -> (&str, u64, usize) {
     // find number at end
     let split = name.bytes().rposition(|b| b < b'0' || b'9' < b).map_or(0, |s| s + 1);
@@ -2680,18 +2717,17 @@ fn render_impls(cx: &Context, w: &mut fmt::Formatter,
     Ok(())
 }
 
-fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
-              t: &clean::Trait) -> fmt::Result {
+fn bounds(t_bounds: &[clean::GenericBound]) -> String {
     let mut bounds = String::new();
     let mut bounds_plain = String::new();
-    if !t.bounds.is_empty() {
+    if !t_bounds.is_empty() {
         if !bounds.is_empty() {
             bounds.push(' ');
             bounds_plain.push(' ');
         }
         bounds.push_str(": ");
         bounds_plain.push_str(": ");
-        for (i, p) in t.bounds.iter().enumerate() {
+        for (i, p) in t_bounds.iter().enumerate() {
             if i > 0 {
                 bounds.push_str(" + ");
                 bounds_plain.push_str(" + ");
@@ -2700,7 +2736,16 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
             bounds_plain.push_str(&format!("{:#}", *p));
         }
     }
+    bounds
+}
 
+fn item_trait(
+    w: &mut fmt::Formatter,
+    cx: &Context,
+    it: &clean::Item,
+    t: &clean::Trait,
+) -> fmt::Result {
+    let bounds = bounds(&t.bounds);
     let types = t.items.iter().filter(|m| m.is_associated_type()).collect::<Vec<_>>();
     let consts = t.items.iter().filter(|m| m.is_associated_const()).collect::<Vec<_>>();
     let required = t.items.iter().filter(|m| m.is_ty_method()).collect::<Vec<_>>();
@@ -3136,7 +3181,9 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
     if let doctree::Plain = s.struct_type {
         if fields.peek().is_some() {
             write!(w, "<h2 id='fields' class='fields small-section-header'>
-                       Fields<a href='#fields' class='anchor'></a></h2>")?;
+                       Fields{}<a href='#fields' class='anchor'></a></h2>",
+                       document_non_exhaustive_header(it))?;
+            document_non_exhaustive(w, it)?;
             for (field, ty) in fields {
                 let id = derive_id(format!("{}.{}",
                                            ItemType::StructField,
@@ -3268,7 +3315,9 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
     document(w, cx, it)?;
     if !e.variants.is_empty() {
         write!(w, "<h2 id='variants' class='variants small-section-header'>
-                   Variants<a href='#variants' class='anchor'></a></h2>\n")?;
+                   Variants{}<a href='#variants' class='anchor'></a></h2>\n",
+                   document_non_exhaustive_header(it))?;
+        document_non_exhaustive(w, it)?;
         for variant in &e.variants {
             let id = derive_id(format!("{}.{}",
                                        ItemType::Variant,
@@ -3369,7 +3418,8 @@ fn render_attribute(attr: &ast::MetaItem) -> Option<String> {
     "must_use",
     "no_mangle",
     "repr",
-    "unsafe_destructor_blind_to_params"
+    "unsafe_destructor_blind_to_params",
+    "non_exhaustive"
 ];
 
 fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
@@ -3900,6 +3950,29 @@ fn render_default_items(w: &mut fmt::Formatter,
     Ok(())
 }
 
+fn item_existential(
+    w: &mut fmt::Formatter,
+    cx: &Context,
+    it: &clean::Item,
+    t: &clean::Existential,
+) -> fmt::Result {
+    write!(w, "<pre class='rust existential'>")?;
+    render_attributes(w, it)?;
+    write!(w, "existential type {}{}{where_clause}: {bounds};</pre>",
+           it.name.as_ref().unwrap(),
+           t.generics,
+           where_clause = WhereClause { gens: &t.generics, indent: 0, end_newline: true },
+           bounds = bounds(&t.bounds))?;
+
+    document(w, cx, it)?;
+
+    // Render any items associated directly to this alias, as otherwise they
+    // won't be visible anywhere in the docs. It would be nice to also show
+    // associated items from the aliased type (see discussion in #32077), but
+    // we need #14072 to make sense of the generics.
+    render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
+}
+
 fn item_typedef(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
                 t: &clean::Typedef) -> fmt::Result {
     write!(w, "<pre class='rust typedef'>")?;
@@ -4399,6 +4472,7 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) {
         ItemType::AssociatedConst => ("associated-consts", "Associated Constants"),
         ItemType::ForeignType     => ("foreign-types", "Foreign Types"),
         ItemType::Keyword         => ("keywords", "Keywords"),
+        ItemType::Existential     => ("existentials", "Existentials"),
     }
 }
 
index 3bd343c0c0b6813d93804bf02e8268133d0cace2..62ef5626ee5bb4f1165ac09b34d4e3413ac38872 100644 (file)
         onEach(e.getElementsByClassName('associatedconstant'), func);
     });
 
-    function createToggle(otherMessage, extraClass) {
+    function createToggle(otherMessage, fontSize, extraClass) {
         var span = document.createElement('span');
         span.className = 'toggle-label';
         span.style.display = 'none';
             span.innerHTML = '&nbsp;Expand&nbsp;description';
         } else {
             span.innerHTML = otherMessage;
-            span.style.fontSize = '20px';
+        }
+
+        if (fontSize) {
+            span.style.fontSize = fontSize;
         }
 
         var mainToggle = toggle.cloneNode(true);
         }
         if (e.parentNode.id === "main") {
             var otherMessage;
+            var fontSize;
             var extraClass;
+
             if (hasClass(e, "type-decl")) {
+                fontSize = "20px";
                 otherMessage = '&nbsp;Show&nbsp;declaration';
+            } else if (hasClass(e, "non-exhaustive")) {
+                otherMessage = '&nbsp;This&nbsp;';
+                if (hasClass(e, "non-exhaustive-struct")) {
+                    otherMessage += 'struct';
+                } else if (hasClass(e, "non-exhaustive-enum")) {
+                    otherMessage += 'enum';
+                } else if (hasClass(e, "non-exhaustive-type")) {
+                    otherMessage += 'type';
+                }
+                otherMessage += '&nbsp;is&nbsp;marked&nbsp;as&nbsp;non-exhaustive';
             } else if (hasClass(e.childNodes[0], "impl-items")) {
                 extraClass = "marg-left";
             }
-            e.parentNode.insertBefore(createToggle(otherMessage, extraClass), e);
+
+            e.parentNode.insertBefore(createToggle(otherMessage, fontSize, extraClass), e);
             if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
                 collapseDocs(e.previousSibling.childNodes[0], "toggle");
             }
index 575a7ea27921f0e9581e4276f30ce6ec2311a1ae..b689e2fa3854e3608f2344b8f8ebd7ab4e745891 100644 (file)
@@ -1358,4 +1358,8 @@ kbd {
 }
 #all-types > p {
        margin: 5px 0;
-}
\ No newline at end of file
+}
+
+.non-exhaustive {
+       margin-bottom: 1em;
+}
index 649ee0b781e484888ea0eb395a329112f0f53c25..b4342f4749185cd84eaa85796b15968f5b2fb020 100644 (file)
@@ -406,4 +406,4 @@ kbd {
 }
 .search-results td span.grey {
        color: #ccc;
-}
\ No newline at end of file
+}
index 7d9980363de9c582021c6b311a401209abc76177..e84e3cb56636e485048b3be7d856e3225f47e891 100644 (file)
@@ -400,4 +400,4 @@ kbd {
 }
 .search-results td span.grey {
        color: #999;
-}
\ No newline at end of file
+}
index 3e26ed2b97c23c893bb05f1f0857076a2e230c7f..ae64c6f1bfd7fb3f47ee6e2fe8d0cdebc86eb3ed 100644 (file)
@@ -57,6 +57,7 @@
 use std::collections::{BTreeMap, BTreeSet};
 use std::default::Default;
 use std::env;
+use std::panic;
 use std::path::{Path, PathBuf};
 use std::process;
 use std::sync::mpsc::channel;
@@ -115,7 +116,7 @@ pub fn main() {
         syntax::with_globals(move || {
             get_args().map(|args| main_args(&args)).unwrap_or(1)
         })
-    }).unwrap().join().unwrap_or(101);
+    }).unwrap().join().unwrap_or(rustc_driver::EXIT_FAILURE);
     process::exit(res as i32);
 }
 
@@ -309,19 +310,19 @@ pub fn opts() -> Vec<RustcOptGroup> {
                        "disable-minification",
                        "Disable minification applied on JS files")
         }),
-        unstable("warn", |o| {
+        stable("warn", |o| {
             o.optmulti("W", "warn", "Set lint warnings", "OPT")
         }),
-        unstable("allow", |o| {
+        stable("allow", |o| {
             o.optmulti("A", "allow", "Set lint allowed", "OPT")
         }),
-        unstable("deny", |o| {
+        stable("deny", |o| {
             o.optmulti("D", "deny", "Set lint denied", "OPT")
         }),
-        unstable("forbid", |o| {
+        stable("forbid", |o| {
             o.optmulti("F", "forbid", "Set lint forbidden", "OPT")
         }),
-        unstable("cap-lints", |o| {
+        stable("cap-lints", |o| {
             o.optmulti(
                 "",
                 "cap-lints",
@@ -667,7 +668,7 @@ fn rust_input<R, F>(cratefile: PathBuf,
 
     let (tx, rx) = channel();
 
-    rustc_driver::monitor(move || syntax::with_globals(move || {
+    let result = rustc_driver::monitor(move || syntax::with_globals(move || {
         use rustc::session::config::Input;
 
         let (mut krate, renderinfo) =
@@ -771,7 +772,11 @@ fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
 
         tx.send(f(Output { krate: krate, renderinfo: renderinfo, passes: passes })).unwrap();
     }));
-    rx.recv().unwrap()
+
+    match result {
+        Ok(()) => rx.recv().unwrap(),
+        Err(_) => panic::resume_unwind(Box::new(errors::FatalErrorMarker)),
+    }
 }
 
 /// Prints deprecation warnings for deprecated options
index fe116a22eccbfa4e465a8a9d21471f8931add8c1..699ee25436a10ea784abe8791ab1d17980b3adb5 100644 (file)
@@ -84,6 +84,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
                 return ret;
             }
             // These items can all get re-exported
+            clean::ExistentialItem(..) |
             clean::TypedefItem(..) | clean::StaticItem(..) |
             clean::StructItem(..) | clean::EnumItem(..) |
             clean::TraitItem(..) | clean::FunctionItem(..) |
index 875ba111ec002ebae6aaae2f7a33ffdbf537ee82..267b70009482f28f062592fd31eabec8f6ac5979 100644 (file)
@@ -439,6 +439,19 @@ pub fn visit_item(&mut self, item: &hir::Item,
                 };
                 om.typedefs.push(t);
             },
+            hir::ItemKind::Existential(ref exist_ty) => {
+                let t = Existential {
+                    exist_ty: exist_ty.clone(),
+                    name,
+                    id: item.id,
+                    attrs: item.attrs.clone(),
+                    whence: item.span,
+                    vis: item.vis.clone(),
+                    stab: self.stability(item.id),
+                    depr: self.deprecation(item.id),
+                };
+                om.existentials.push(t);
+            },
             hir::ItemKind::Static(ref ty, ref mut_, ref exp) => {
                 let s = Static {
                     type_: ty.clone(),
@@ -523,9 +536,6 @@ pub fn visit_item(&mut self, item: &hir::Item,
                     om.impls.push(i);
                 }
             },
-            hir::ItemKind::Existential(_) => {
-                // FIXME(oli-obk): actually generate docs for real existential items
-            }
         }
     }
 
index 51c42995d5e71947c60783b12935bc17e9940eb1..443e2a6980d9eb85571a8db0bd4dda60211e3547 100644 (file)
@@ -220,7 +220,11 @@ pub const fn new() -> Once {
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn call_once<F>(&self, f: F) where F: FnOnce() {
         // Fast path, just see if we've completed initialization.
-        if self.state.load(Ordering::SeqCst) == COMPLETE {
+        // An `Acquire` load is enough because that makes all the initialization
+        // operations visible to us. The cold path uses SeqCst consistently
+        // because the performance difference really does not matter there,
+        // and SeqCst minimizes the chances of something going wrong.
+        if self.state.load(Ordering::Acquire) == COMPLETE {
             return
         }
 
@@ -277,7 +281,11 @@ pub fn call_once<F>(&self, f: F) where F: FnOnce() {
     #[unstable(feature = "once_poison", issue = "33577")]
     pub fn call_once_force<F>(&self, f: F) where F: FnOnce(&OnceState) {
         // same as above, just with a different parameter to `call_inner`.
-        if self.state.load(Ordering::SeqCst) == COMPLETE {
+        // An `Acquire` load is enough because that makes all the initialization
+        // operations visible to us. The cold path uses SeqCst consistently
+        // because the performance difference really does not matter there,
+        // and SeqCst minimizes the chances of something going wrong.
+        if self.state.load(Ordering::Acquire) == COMPLETE {
             return
         }
 
index bcdad92bc32e7e2864752fea0d72a75e6635f7bd..1b6b47f5489d7ce2e03471fe27df33d836bf2d89 100644 (file)
@@ -1394,6 +1394,7 @@ pub enum ImplItemKind {
     Const(P<Ty>, P<Expr>),
     Method(MethodSig, P<Block>),
     Type(P<Ty>),
+    Existential(GenericBounds),
     Macro(Mac),
 }
 
@@ -2132,6 +2133,10 @@ pub enum ItemKind {
     ///
     /// E.g. `type Foo = Bar<u8>;`
     Ty(P<Ty>, Generics),
+    /// An existential type declaration (`existential type`).
+    ///
+    /// E.g. `existential type Foo: Bar + Boo;`
+    Existential(GenericBounds, Generics),
     /// An enum definition (`enum` or `pub enum`).
     ///
     /// E.g. `enum Foo<A, B> { C<A>, D<B> }`
@@ -2183,6 +2188,7 @@ pub fn descriptive_variant(&self) -> &str {
             ItemKind::ForeignMod(..) => "foreign module",
             ItemKind::GlobalAsm(..) => "global asm",
             ItemKind::Ty(..) => "type alias",
+            ItemKind::Existential(..) => "existential type",
             ItemKind::Enum(..) => "enum",
             ItemKind::Struct(..) => "struct",
             ItemKind::Union(..) => "union",
index 1241e230b26d60a5bc5d29f15c3f910d0e73541c..d64f3de8daa97491bc045ded1e81964ed02e121a 100644 (file)
@@ -240,6 +240,13 @@ pub fn span(&self) -> Span {
             InvocationKind::Derive { ref path, .. } => path.span,
         }
     }
+
+    pub fn attr_id(&self) -> Option<ast::AttrId> {
+        match self.kind {
+            InvocationKind::Attr { attr: Some(ref attr), .. } => Some(attr.id),
+            _ => None,
+        }
+    }
 }
 
 pub struct MacroExpander<'a, 'b:'a> {
@@ -331,10 +338,20 @@ fn expand_fragment(&mut self, input_fragment: AstFragment) -> AstFragment {
 
             let scope =
                 if self.monotonic { invoc.expansion_data.mark } else { orig_expansion_data.mark };
+            let attr_id_before = invoc.attr_id();
             let ext = match self.cx.resolver.resolve_invoc(&mut invoc, scope, force) {
                 Ok(ext) => Some(ext),
                 Err(Determinacy::Determined) => None,
                 Err(Determinacy::Undetermined) => {
+                    // Sometimes attributes which we thought were invocations
+                    // end up being custom attributes for custom derives. If
+                    // that's the case our `invoc` will have changed out from
+                    // under us. If this is the case we're making progress so we
+                    // want to flag it as such, and we test this by looking if
+                    // the `attr_id()` method has been changing over time.
+                    if invoc.attr_id() != attr_id_before {
+                        progress = true;
+                    }
                     undetermined_invocations.push(invoc);
                     continue
                 }
index 84b5f9659b5aa1be1da0d019995e75311315b0a0..d35249b6343f4ffcd4b90055c22596cf2831e67e 100644 (file)
@@ -407,15 +407,15 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     // `use path as _;` and `extern crate c as _;`
     (active, underscore_imports, "1.26.0", Some(48216), None),
 
-    // The #![wasm_import_module] attribute
-    (active, wasm_import_module, "1.26.0", Some(52090), None),
-
     // Allows keywords to be escaped for use as identifiers
     (active, raw_identifiers, "1.26.0", Some(48589), None),
 
     // Allows macro invocations in `extern {}` blocks
     (active, macros_in_extern, "1.27.0", Some(49476), None),
 
+    // `existential type`
+    (active, existential_type, "1.28.0", Some(34511), None),
+
     // unstable #[target_feature] directives
     (active, arm_target_feature, "1.27.0", Some(44839), None),
     (active, aarch64_target_feature, "1.27.0", Some(44839), None),
@@ -969,10 +969,6 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
         "the `#[no_debug]` attribute was an experimental feature that has been \
          deprecated due to lack of demand",
         cfg_fn!(no_debug))),
-    ("wasm_import_module", Normal, Gated(Stability::Unstable,
-                                 "wasm_import_module",
-                                 "experimental attribute",
-                                 cfg_fn!(wasm_import_module))),
     ("omit_gdb_pretty_printer_section", Whitelisted, Gated(Stability::Unstable,
                                                        "omit_gdb_pretty_printer_section",
                                                        "the `#[omit_gdb_pretty_printer_section]` \
@@ -1635,6 +1631,15 @@ fn visit_item(&mut self, i: &'a ast::Item) {
                 gate_feature_post!(&self, decl_macro, i.span, msg);
             }
 
+            ast::ItemKind::Existential(..) => {
+                gate_feature_post!(
+                    &self,
+                    existential_type,
+                    i.span,
+                    "existential types are unstable"
+                );
+            }
+
             _ => {}
         }
 
@@ -1834,6 +1839,15 @@ fn visit_impl_item(&mut self, ii: &'a ast::ImplItem) {
                     gate_feature_post!(&self, const_fn, ii.span, "const fn is unstable");
                 }
             }
+            ast::ImplItemKind::Existential(..) => {
+                gate_feature_post!(
+                    &self,
+                    existential_type,
+                    ii.span,
+                    "existential types are unstable"
+                );
+            }
+
             ast::ImplItemKind::Type(_) if !ii.generics.params.is_empty() => {
                 gate_feature_post!(&self, generic_associated_types, ii.span,
                                    "generic associated types are unstable");
index d9d3febc4fe4d2312e33df78c4e37d86eaaee4a2..9d5982c1e28613387c8a38662668d74c3030a234 100644 (file)
@@ -912,6 +912,10 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
         ItemKind::Ty(t, generics) => {
             ItemKind::Ty(folder.fold_ty(t), folder.fold_generics(generics))
         }
+        ItemKind::Existential(bounds, generics) => ItemKind::Existential(
+            folder.fold_bounds(bounds),
+            folder.fold_generics(generics),
+        ),
         ItemKind::Enum(enum_definition, generics) => {
             let generics = folder.fold_generics(generics);
             let variants = enum_definition.variants.move_map(|x| folder.fold_variant(x));
@@ -1002,6 +1006,9 @@ pub fn noop_fold_impl_item<T: Folder>(i: ImplItem, folder: &mut T)
                                folder.fold_block(body))
             }
             ast::ImplItemKind::Type(ty) => ast::ImplItemKind::Type(folder.fold_ty(ty)),
+            ast::ImplItemKind::Existential(bounds) => {
+                ast::ImplItemKind::Existential(folder.fold_bounds(bounds))
+            },
             ast::ImplItemKind::Macro(mac) => ast::ImplItemKind::Macro(folder.fold_mac(mac))
         },
         span: folder.new_span(i.span),
index 62bb5fbd04f7bc5ba702719a31a8b378d9d7cc21..2eaa56ebeb82649548d733ea7687f0d8d8879d96 100644 (file)
 use std::path::{self, Path, PathBuf};
 use std::slice;
 
+#[derive(Debug)]
+/// Whether the type alias or associated type is a concrete type or an existential type
+pub enum AliasKind {
+    /// Just a new name for the same type
+    Weak(P<Ty>),
+    /// Only trait impls of the type will be usable, not the actual type itself
+    Existential(GenericBounds),
+}
+
 bitflags! {
     struct Restrictions: u8 {
         const STMT_EXPR         = 1 << 0;
@@ -5502,16 +5511,13 @@ fn parse_impl_item_(&mut self,
         let lo = self.span;
         let vis = self.parse_visibility(false)?;
         let defaultness = self.parse_defaultness();
-        let (name, node, generics) = if self.eat_keyword(keywords::Type) {
-            // This parses the grammar:
-            //     ImplItemAssocTy = Ident ["<"...">"] ["where" ...] "=" Ty ";"
-            let name = self.parse_ident()?;
-            let mut generics = self.parse_generics()?;
-            generics.where_clause = self.parse_where_clause()?;
-            self.expect(&token::Eq)?;
-            let typ = self.parse_ty()?;
-            self.expect(&token::Semi)?;
-            (name, ast::ImplItemKind::Type(typ), generics)
+        let (name, node, generics) = if let Some(type_) = self.eat_type() {
+            let (name, alias, generics) = type_?;
+            let kind = match alias {
+                AliasKind::Weak(typ) => ast::ImplItemKind::Type(typ),
+                AliasKind::Existential(bounds) => ast::ImplItemKind::Existential(bounds),
+            };
+            (name, kind, generics)
         } else if self.is_const_item() {
             // This parses the grammar:
             //     ImplItemConst = "const" Ident ":" Ty "=" Expr ";"
@@ -6563,14 +6569,43 @@ fn parse_item_foreign_mod(&mut self,
     }
 
     /// Parse type Foo = Bar;
-    fn parse_item_type(&mut self) -> PResult<'a, ItemInfo> {
+    /// or
+    /// existential type Foo: Bar;
+    /// or
+    /// return None without modifying the parser state
+    fn eat_type(&mut self) -> Option<PResult<'a, (Ident, AliasKind, ast::Generics)>> {
+        // This parses the grammar:
+        //     Ident ["<"...">"] ["where" ...] ("=" | ":") Ty ";"
+        if self.check_keyword(keywords::Type) ||
+           self.check_keyword(keywords::Existential) &&
+                self.look_ahead(1, |t| t.is_keyword(keywords::Type)) {
+            let existential = self.eat_keyword(keywords::Existential);
+            assert!(self.eat_keyword(keywords::Type));
+            Some(self.parse_existential_or_alias(existential))
+        } else {
+            None
+        }
+    }
+
+    /// Parse type alias or existential type
+    fn parse_existential_or_alias(
+        &mut self,
+        existential: bool,
+    ) -> PResult<'a, (Ident, AliasKind, ast::Generics)> {
         let ident = self.parse_ident()?;
         let mut tps = self.parse_generics()?;
         tps.where_clause = self.parse_where_clause()?;
-        self.expect(&token::Eq)?;
-        let ty = self.parse_ty()?;
+        let alias = if existential {
+            self.expect(&token::Colon)?;
+            let bounds = self.parse_generic_bounds()?;
+            AliasKind::Existential(bounds)
+        } else {
+            self.expect(&token::Eq)?;
+            let ty = self.parse_ty()?;
+            AliasKind::Weak(ty)
+        };
         self.expect(&token::Semi)?;
-        Ok((ident, ItemKind::Ty(ty, tps), None))
+        Ok((ident, alias, tps))
     }
 
     /// Parse the part of an "enum" decl following the '{'
@@ -6926,15 +6961,19 @@ fn parse_item_(&mut self, attrs: Vec<Attribute>,
                                     maybe_append(attrs, extra_attrs));
             return Ok(Some(item));
         }
-        if self.eat_keyword(keywords::Type) {
+        if let Some(type_) = self.eat_type() {
+            let (ident, alias, generics) = type_?;
             // TYPE ITEM
-            let (ident, item_, extra_attrs) = self.parse_item_type()?;
+            let item_ = match alias {
+                AliasKind::Weak(ty) => ItemKind::Ty(ty, generics),
+                AliasKind::Existential(bounds) => ItemKind::Existential(bounds, generics),
+            };
             let prev_span = self.prev_span;
             let item = self.mk_item(lo.to(prev_span),
                                     ident,
                                     item_,
                                     visibility,
-                                    maybe_append(attrs, extra_attrs));
+                                    attrs);
             return Ok(Some(item));
         }
         if self.eat_keyword(keywords::Enum) {
index b0a9003a45620dabe5416105ba0f8ccfde63bf0a..de68780ef2ca203ca2b7793a0b6e0f1a9727cbc8 100644 (file)
@@ -1280,9 +1280,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> io::Result<()> {
                 self.end()?;
             }
             ast::ItemKind::Ty(ref ty, ref generics) => {
-                self.ibox(INDENT_UNIT)?;
-                self.ibox(0)?;
-                self.word_nbsp(&visibility_qualified(&item.vis, "type"))?;
+                self.head(&visibility_qualified(&item.vis, "type"))?;
                 self.print_ident(item.ident)?;
                 self.print_generic_params(&generics.params)?;
                 self.end()?; // end the inner ibox
@@ -1294,6 +1292,18 @@ pub fn print_item(&mut self, item: &ast::Item) -> io::Result<()> {
                 self.s.word(";")?;
                 self.end()?; // end the outer ibox
             }
+            ast::ItemKind::Existential(ref bounds, ref generics) => {
+                self.head(&visibility_qualified(&item.vis, "existential type"))?;
+                self.print_ident(item.ident)?;
+                self.print_generic_params(&generics.params)?;
+                self.end()?; // end the inner ibox
+
+                self.print_where_clause(&generics.where_clause)?;
+                self.s.space()?;
+                self.print_type_bounds(":", bounds)?;
+                self.s.word(";")?;
+                self.end()?; // end the outer ibox
+            }
             ast::ItemKind::Enum(ref enum_definition, ref params) => {
                 self.print_enum_def(
                     enum_definition,
@@ -1501,8 +1511,8 @@ pub fn print_visibility(&mut self, vis: &ast::Visibility) -> io::Result<()> {
         }
     }
 
-    pub fn print_defaultness(&mut self, defatulness: ast::Defaultness) -> io::Result<()> {
-        if let ast::Defaultness::Default = defatulness {
+    pub fn print_defaultness(&mut self, defaultness: ast::Defaultness) -> io::Result<()> {
+        if let ast::Defaultness::Default = defaultness {
             try!(self.word_nbsp("default"));
         }
         Ok(())
@@ -1650,6 +1660,10 @@ pub fn print_impl_item(&mut self, ii: &ast::ImplItem) -> io::Result<()> {
             ast::ImplItemKind::Type(ref ty) => {
                 self.print_associated_type(ii.ident, None, Some(ty))?;
             }
+            ast::ImplItemKind::Existential(ref bounds) => {
+                self.word_space("existential")?;
+                self.print_associated_type(ii.ident, Some(bounds), None)?;
+            }
             ast::ImplItemKind::Macro(ref mac) => {
                 self.print_mac(mac)?;
                 match mac.node.delim {
index 9211a2383b6961b133037d05944c00f775690658..51be129737e565a1234d79cb9fef9865848f59c5 100644 (file)
@@ -252,6 +252,10 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
             visitor.visit_ty(typ);
             visitor.visit_generics(type_parameters)
         }
+        ItemKind::Existential(ref bounds, ref type_parameters) => {
+            walk_list!(visitor, visit_param_bound, bounds);
+            visitor.visit_generics(type_parameters)
+        }
         ItemKind::Enum(ref enum_definition, ref type_parameters) => {
             visitor.visit_generics(type_parameters);
             visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
@@ -600,6 +604,9 @@ pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplIt
         ImplItemKind::Type(ref ty) => {
             visitor.visit_ty(ty);
         }
+        ImplItemKind::Existential(ref bounds) => {
+            walk_list!(visitor, visit_param_bound, bounds);
+        }
         ImplItemKind::Macro(ref mac) => {
             visitor.visit_mac(mac);
         }
index 9a0c92f679366929916399b3aa08c655fe863dbb..62f22475e7de750cdd0179eb564f83fb681960a1 100644 (file)
@@ -426,6 +426,7 @@ pub fn fresh() -> Self {
     (56, Default,            "default")
     (57, Dyn,                "dyn")
     (58, Union,              "union")
+    (59, Existential,        "existential")
 }
 
 impl Symbol {
index a00ff3b345d116e4c0127fde7c4d3f07f15ea6ab..2f28c5b32fb88de32c0e490a1df7301dc55a5dcc 100644 (file)
@@ -1228,15 +1228,6 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
   MD->addOperand(Unit);
 }
 
-extern "C" void
-LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
-  Module *M = unwrap(Mod);
-  for (Function &F : M->functions()) {
-    if (F.hasAvailableExternallyLinkage())
-      F.deleteBody();
-  }
-}
-
 #else
 
 extern "C" bool
@@ -1328,9 +1319,4 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod) {
   report_fatal_error("ThinLTO not available");
 }
 
-extern "C" void
-LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
-  report_fatal_error("ThinLTO not available");
-}
-
 #endif // LLVM_VERSION_GE(4, 0)
index 05df16d21d85bcf5d65268fe57c0a696aa1c6758..d0836d4af9737e06d38f87bf0927b26b8e49161b 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // compile-flags: -Z parse-only
+// ignore-tidy-linelength
 
 struct Foo;
 
@@ -16,6 +17,6 @@ impl Foo {
     fn foo() {}
 
     #[stable(feature = "rust1", since = "1.0.0")]
-} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or
+} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or
 
 fn main() {}
index f30e20ad7dbdb3968194a357a6e399e7097d1e58..d944224798852df1fa64a8351d6a7b861e80c54c 100644 (file)
@@ -9,11 +9,12 @@
 // except according to those terms.
 
 // compile-flags: -Z parse-only
+// ignore-tidy-linelength
 
 struct Foo;
 
 impl Foo {
     #[stable(feature = "rust1", since = "1.0.0")]
-} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or
+} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or
 
 fn main() {}
index fbc6848f372f5666e9cd27c664941c24cbea6733..4c0cd3358ddbde397db01202d12113b848af22d9 100644 (file)
@@ -9,10 +9,11 @@
 // except according to those terms.
 
 // compile-flags: -Z parse-only
+// ignore-tidy-linelength
 
 struct S;
 
 impl S {
     static fn f() {}
 }
-//~^^ ERROR expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`,
+//~^^ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`,
diff --git a/src/test/run-make-fulldeps/exit-code/Makefile b/src/test/run-make-fulldeps/exit-code/Makefile
new file mode 100644 (file)
index 0000000..007f198
--- /dev/null
@@ -0,0 +1,11 @@
+-include ../tools.mk
+
+all:
+       $(RUSTC) success.rs; [ $$? -eq 0 ]
+       $(RUSTC) --invalid-arg-foo; [ $$? -eq 1 ]
+       $(RUSTC) compile-error.rs; [ $$? -eq 1 ]
+       $(RUSTC) -Ztreat-err-as-bug compile-error.rs; [ $$? -eq 101 ]
+       $(RUSTDOC) -o $(TMPDIR)/exit-code success.rs; [ $$? -eq 0 ]
+       $(RUSTDOC) --invalid-arg-foo; [ $$? -eq 1 ]
+       $(RUSTDOC) compile-error.rs; [ $$? -eq 1 ]
+       $(RUSTDOC) lint-failure.rs; [ $$? -eq 1 ]
diff --git a/src/test/run-make-fulldeps/exit-code/compile-error.rs b/src/test/run-make-fulldeps/exit-code/compile-error.rs
new file mode 100644 (file)
index 0000000..8c05318
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    compile_error!("kaboom");
+}
diff --git a/src/test/run-make-fulldeps/exit-code/lint-failure.rs b/src/test/run-make-fulldeps/exit-code/lint-failure.rs
new file mode 100644 (file)
index 0000000..3bf40b7
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(intra_doc_link_resolution_failure)]
+
+/// [intradoc::failure]
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/src/test/run-make-fulldeps/exit-code/success.rs b/src/test/run-make-fulldeps/exit-code/success.rs
new file mode 100644 (file)
index 0000000..9f6c573
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/// Main function
+fn main() {
+    println!("Hello, world!");
+}
index 9e659223c651c8835a16ebbf302da480647784c4..bd27be32b2134d06001ff3db97f687a8006455f4 100644 (file)
@@ -9,12 +9,11 @@
 // except according to those terms.
 
 #![crate_type = "cdylib"]
-#![feature(wasm_import_module)]
 #![deny(warnings)]
 
 extern crate foo;
 
-#[wasm_import_module = "./me"]
+#[link(wasm_import_module = "./me")]
 extern {
     #[link_name = "me_in_dep"]
     fn dep();
index bcd2ca70befaa4d30793b02747bc496acd820db4..e4009253fd288020d3e045727835a907ce1ffcde 100644 (file)
@@ -9,10 +9,9 @@
 // except according to those terms.
 
 #![crate_type = "rlib"]
-#![feature(wasm_import_module)]
 #![deny(warnings)]
 
-#[wasm_import_module = "./dep"]
+#[link(wasm_import_module = "./dep")]
 extern {
     pub fn dep();
 }
diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs
new file mode 100644 (file)
index 0000000..d02edb5
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::*;
+
+#[proc_macro_derive(A, attributes(b))]
+pub fn foo(_x: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs
new file mode 100644 (file)
index 0000000..6a0a3b3
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:derive-two-attrs.rs
+
+#![feature(use_extern_macros)]
+
+extern crate derive_two_attrs as foo;
+
+use foo::A;
+
+#[derive(A)]
+#[b]
+#[b]
+struct B;
+
+fn main() {}
index 5b6f6ccc627a41f4c245799df9f2fe7763e3fe39..022ed6c28c3bdf8400f205951a08f4f6ec14955a 100644 (file)
@@ -166,7 +166,12 @@ fn bar() {
 
     assert!(foo as usize != bar as usize);
 
-    assert_eq!(foo as i16, foo as usize as i16);
+    // Taking a few bits of a function's address is totally pointless and we detect that
+    // Disabling the lint to ensure that the assertion can still be run
+    #[allow(const_err)]
+    {
+        assert_eq!(foo as i16, foo as usize as i16);
+    }
 
     // fptr-ptr-cast
 
index e56d01d7ba8ce205edeef9172e941a57eef50dfc..e6f191ea9522f4e33a59c7b1f2d7d049de919e5c 100644 (file)
@@ -39,13 +39,6 @@ fn foo<T>(a: T) -> T {
 
 static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option<usize> = { Some };
 
-// FIXME #13972
-// static BLOCK_UNSAFE_SAFE_PTR: &'static isize = unsafe { &*(0xdeadbeef as *const isize) };
-// static BLOCK_UNSAFE_SAFE_PTR_2: &'static isize = unsafe {
-//     const X: *const isize = 0xdeadbeef as *const isize;
-//     &*X
-// };
-
 pub fn main() {
     assert_eq!(BLOCK_INTEGRAL, 1);
     assert_eq!(BLOCK_EXPLICIT_UNIT, ());
@@ -58,7 +51,4 @@ pub fn main() {
     assert_eq!(BLOCK_FN_INFERRED(300), 300);
     assert_eq!(BLOCK_FN(300), 300);
     assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200));
-    // FIXME #13972
-    // assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef);
-    // assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef);
 }
diff --git a/src/test/run-pass/existential_type.rs b/src/test/run-pass/existential_type.rs
new file mode 100644 (file)
index 0000000..e63d5c2
--- /dev/null
@@ -0,0 +1,94 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+
+fn main() {
+    assert_eq!(foo().to_string(), "foo");
+    assert_eq!(bar1().to_string(), "bar1");
+    assert_eq!(bar2().to_string(), "bar2");
+    let mut x = bar1();
+    x = bar2();
+    assert_eq!(boo::boo().to_string(), "boo");
+    assert_eq!(my_iter(42u8).collect::<Vec<u8>>(), vec![42u8]);
+}
+
+// single definition
+existential type Foo: std::fmt::Display;
+
+fn foo() -> Foo {
+    "foo"
+}
+
+// two definitions
+existential type Bar: std::fmt::Display;
+
+fn bar1() -> Bar {
+    "bar1"
+}
+
+fn bar2() -> Bar {
+    "bar2"
+}
+
+// definition in submodule
+existential type Boo: std::fmt::Display;
+
+mod boo {
+    pub fn boo() -> super::Boo {
+        "boo"
+    }
+}
+
+existential type MyIter<T>: Iterator<Item = T>;
+
+fn my_iter<T>(t: T) -> MyIter<T> {
+    std::iter::once(t)
+}
+
+fn my_iter2<T>(t: T) -> MyIter<T> {
+    std::iter::once(t)
+}
+
+// param names should not have an effect!
+fn my_iter3<U>(u: U) -> MyIter<U> {
+    std::iter::once(u)
+}
+
+// param position should not have an effect!
+fn my_iter4<U, V>(_: U, v: V) -> MyIter<V> {
+    std::iter::once(v)
+}
+
+// param names should not have an effect!
+existential type MyOtherIter<T>: Iterator<Item = T>;
+
+fn my_other_iter<U>(u: U) -> MyOtherIter<U> {
+    std::iter::once(u)
+}
+
+trait Trait {}
+existential type GenericBound<'a, T: Trait>: 'a;
+
+fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> {
+    t
+}
+
+mod pass_through {
+    pub existential type Passthrough<T>: 'static;
+
+    fn define_passthrough<T: 'static>(t: T) -> Passthrough<T> {
+        t
+    }
+}
+
+fn use_passthrough(x: pass_through::Passthrough<u32>) -> pass_through::Passthrough<u32> {
+    x
+}
index f3e52fbd32f3e92d0ff2d1fcedf59ec9f9c75879..8d73f4db7d234c23a715800748652b41a44bfd0b 100644 (file)
@@ -14,7 +14,6 @@
 // aux-build:sepcomp_lib.rs
 // compile-flags: -C lto -g
 // no-prefer-dynamic
-// ignore-android FIXME #18800
 
 extern crate sepcomp_lib;
 use sepcomp_lib::a::one;
diff --git a/src/test/ui/as-ref.rs b/src/test/ui/as-ref.rs
new file mode 100644 (file)
index 0000000..ae1c98c
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct Foo;
+fn takes_ref(_: &Foo) {}
+
+fn main() {
+  let ref opt = Some(Foo);
+  opt.map(|arg| takes_ref(arg));
+  //~^ ERROR mismatched types [E0308]
+  opt.and_then(|arg| Some(takes_ref(arg)));
+  //~^ ERROR mismatched types [E0308]
+  let ref opt: Result<_, ()> = Ok(Foo);
+  opt.map(|arg| takes_ref(arg));
+  //~^ ERROR mismatched types [E0308]
+  opt.and_then(|arg| Ok(takes_ref(arg)));
+  //~^ ERROR mismatched types [E0308]
+}
diff --git a/src/test/ui/as-ref.stderr b/src/test/ui/as-ref.stderr
new file mode 100644 (file)
index 0000000..2701644
--- /dev/null
@@ -0,0 +1,47 @@
+error[E0308]: mismatched types
+  --> $DIR/as-ref.rs:16:27
+   |
+LL |   opt.map(|arg| takes_ref(arg));
+   |       -                   ^^^ expected &Foo, found struct `Foo`
+   |       |
+   |       help: consider using `as_ref` instead: `as_ref().`
+   |
+   = note: expected type `&Foo`
+              found type `Foo`
+
+error[E0308]: mismatched types
+  --> $DIR/as-ref.rs:18:37
+   |
+LL |   opt.and_then(|arg| Some(takes_ref(arg)));
+   |       -                             ^^^ expected &Foo, found struct `Foo`
+   |       |
+   |       help: consider using `as_ref` instead: `as_ref().`
+   |
+   = note: expected type `&Foo`
+              found type `Foo`
+
+error[E0308]: mismatched types
+  --> $DIR/as-ref.rs:21:27
+   |
+LL |   opt.map(|arg| takes_ref(arg));
+   |       -                   ^^^ expected &Foo, found struct `Foo`
+   |       |
+   |       help: consider using `as_ref` instead: `as_ref().`
+   |
+   = note: expected type `&Foo`
+              found type `Foo`
+
+error[E0308]: mismatched types
+  --> $DIR/as-ref.rs:23:35
+   |
+LL |   opt.and_then(|arg| Ok(takes_ref(arg)));
+   |       -                           ^^^ expected &Foo, found struct `Foo`
+   |       |
+   |       help: consider using `as_ref` instead: `as_ref().`
+   |
+   = note: expected type `&Foo`
+              found type `Foo`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/auxiliary/m1.rs b/src/test/ui/auxiliary/m1.rs
new file mode 100644 (file)
index 0000000..b61667c
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub fn foo() {}
diff --git a/src/test/ui/auxiliary/m2.rs b/src/test/ui/auxiliary/m2.rs
new file mode 100644 (file)
index 0000000..94ff5e4
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub fn bar() {}
diff --git a/src/test/ui/auxiliary/macro-in-other-crate.rs b/src/test/ui/auxiliary/macro-in-other-crate.rs
new file mode 100644 (file)
index 0000000..01282f2
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[macro_export]
+macro_rules! mac {
+    ($ident:ident) => { let $ident = 42; }
+}
diff --git a/src/test/ui/auxiliary/removing-extern-crate.rs b/src/test/ui/auxiliary/removing-extern-crate.rs
new file mode 100644 (file)
index 0000000..4275e80
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// intentionally blank
diff --git a/src/test/ui/closure-immutable-outer-variable.fixed b/src/test/ui/closure-immutable-outer-variable.fixed
new file mode 100644 (file)
index 0000000..b3a0d59
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+// Point at the captured immutable outer variable
+
+fn foo(mut f: Box<FnMut()>) {
+    f();
+}
+
+fn main() {
+    let mut y = true;
+    foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
+}
diff --git a/src/test/ui/closure-immutable-outer-variable.nll.stderr b/src/test/ui/closure-immutable-outer-variable.nll.stderr
new file mode 100644 (file)
index 0000000..335ccef
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0594]: cannot assign to immutable item `y`
+  --> $DIR/closure-immutable-outer-variable.rs:21:26
+   |
+LL |     foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
+   |                          ^^^^^^^^^ cannot assign
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/closure-immutable-outer-variable.rs b/src/test/ui/closure-immutable-outer-variable.rs
new file mode 100644 (file)
index 0000000..e162678
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+// Point at the captured immutable outer variable
+
+fn foo(mut f: Box<FnMut()>) {
+    f();
+}
+
+fn main() {
+    let y = true;
+    foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
+}
diff --git a/src/test/ui/closure-immutable-outer-variable.rs.fixed b/src/test/ui/closure-immutable-outer-variable.rs.fixed
new file mode 100644 (file)
index 0000000..80a5a45
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Point at the captured immutable outer variable
+
+fn foo(mut f: Box<FnMut()>) {
+    f();
+}
+
+fn main() {
+    let mut y = true;
+    foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
+}
diff --git a/src/test/ui/closure-immutable-outer-variable.stderr b/src/test/ui/closure-immutable-outer-variable.stderr
new file mode 100644 (file)
index 0000000..0ee11d8
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
+  --> $DIR/closure-immutable-outer-variable.rs:21:26
+   |
+LL |     let y = true;
+   |         - help: consider making `y` mutable: `mut y`
+LL |     foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
+   |                          ^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/confuse-field-and-method/issue-18343.rs b/src/test/ui/confuse-field-and-method/issue-18343.rs
new file mode 100644 (file)
index 0000000..ef1566a
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct Obj<F> where F: FnMut() -> u32 {
+    closure: F,
+}
+
+fn main() {
+    let o = Obj { closure: || 42 };
+    o.closure();
+    //~^ ERROR no method named `closure` found
+}
diff --git a/src/test/ui/confuse-field-and-method/issue-18343.stderr b/src/test/ui/confuse-field-and-method/issue-18343.stderr
new file mode 100644 (file)
index 0000000..b1e3105
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-18343.rs:16:28: 16:33]>` in the current scope
+  --> $DIR/issue-18343.rs:17:7
+   |
+LL | struct Obj<F> where F: FnMut() -> u32 {
+   | ------------------------------------- method `closure` not found for this
+...
+LL |     o.closure();
+   |       ^^^^^^^ field, not a method
+   |
+   = help: use `(o.closure)(...)` if you meant to call the function stored in the `closure` field
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/confuse-field-and-method/issue-2392.rs b/src/test/ui/confuse-field-and-method/issue-2392.rs
new file mode 100644 (file)
index 0000000..f0c5a2a
--- /dev/null
@@ -0,0 +1,83 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(core, fnbox)]
+
+use std::boxed::FnBox;
+
+struct FuncContainer {
+    f1: fn(data: u8),
+    f2: extern "C" fn(data: u8),
+    f3: unsafe fn(data: u8),
+}
+
+struct FuncContainerOuter {
+    container: Box<FuncContainer>
+}
+
+struct Obj<F> where F: FnOnce() -> u32 {
+    closure: F,
+    not_closure: usize,
+}
+
+struct BoxedObj {
+    boxed_closure: Box<FnBox() -> u32>,
+}
+
+struct Wrapper<F> where F: FnMut() -> u32 {
+    wrap: Obj<F>,
+}
+
+fn func() -> u32 {
+    0
+}
+
+fn check_expression() -> Obj<Box<FnBox() -> u32>> {
+    Obj { closure: Box::new(|| 42_u32) as Box<FnBox() -> u32>, not_closure: 42 }
+}
+
+fn main() {
+    // test variations of function
+
+    let o_closure = Obj { closure: || 42, not_closure: 42 };
+    o_closure.closure(); //~ ERROR no method named `closure` found
+
+    o_closure.not_closure();
+    //~^ ERROR no method named `not_closure` found
+
+    let o_func = Obj { closure: func, not_closure: 5 };
+    o_func.closure(); //~ ERROR no method named `closure` found
+
+    let boxed_fn = BoxedObj { boxed_closure: Box::new(func) };
+    boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found
+
+    let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<FnBox() -> u32> };
+    boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found
+
+    // test expression writing in the notes
+
+    let w = Wrapper { wrap: o_func };
+    w.wrap.closure();//~ ERROR no method named `closure` found
+
+    w.wrap.not_closure();
+    //~^ ERROR no method named `not_closure` found
+
+    check_expression().closure();//~ ERROR no method named `closure` found
+}
+
+impl FuncContainerOuter {
+    fn run(&self) {
+        unsafe {
+            (*self.container).f1(1); //~ ERROR no method named `f1` found
+            (*self.container).f2(1); //~ ERROR no method named `f2` found
+            (*self.container).f3(1); //~ ERROR no method named `f3` found
+        }
+    }
+}
diff --git a/src/test/ui/confuse-field-and-method/issue-2392.stderr b/src/test/ui/confuse-field-and-method/issue-2392.stderr
new file mode 100644 (file)
index 0000000..9049ffd
--- /dev/null
@@ -0,0 +1,124 @@
+error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-2392.rs:49:36: 49:41]>` in the current scope
+  --> $DIR/issue-2392.rs:50:15
+   |
+LL | struct Obj<F> where F: FnOnce() -> u32 {
+   | -------------------------------------- method `closure` not found for this
+...
+LL |     o_closure.closure(); //~ ERROR no method named `closure` found
+   |               ^^^^^^^ field, not a method
+   |
+   = help: use `(o_closure.closure)(...)` if you meant to call the function stored in the `closure` field
+
+error[E0599]: no method named `not_closure` found for type `Obj<[closure@$DIR/issue-2392.rs:49:36: 49:41]>` in the current scope
+  --> $DIR/issue-2392.rs:52:15
+   |
+LL | struct Obj<F> where F: FnOnce() -> u32 {
+   | -------------------------------------- method `not_closure` not found for this
+...
+LL |     o_closure.not_closure();
+   |               ^^^^^^^^^^^ field, not a method
+   |
+   = help: did you mean to write `o_closure.not_closure` instead of `o_closure.not_closure(...)`?
+
+error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
+  --> $DIR/issue-2392.rs:56:12
+   |
+LL | struct Obj<F> where F: FnOnce() -> u32 {
+   | -------------------------------------- method `closure` not found for this
+...
+LL |     o_func.closure(); //~ ERROR no method named `closure` found
+   |            ^^^^^^^ field, not a method
+   |
+   = help: use `(o_func.closure)(...)` if you meant to call the function stored in the `closure` field
+
+error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
+  --> $DIR/issue-2392.rs:59:14
+   |
+LL | struct BoxedObj {
+   | --------------- method `boxed_closure` not found for this
+...
+LL |     boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found
+   |              ^^^^^^^^^^^^^ field, not a method
+   |
+   = help: use `(boxed_fn.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field
+
+error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
+  --> $DIR/issue-2392.rs:62:19
+   |
+LL | struct BoxedObj {
+   | --------------- method `boxed_closure` not found for this
+...
+LL |     boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found
+   |                   ^^^^^^^^^^^^^ field, not a method
+   |
+   = help: use `(boxed_closure.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field
+
+error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
+  --> $DIR/issue-2392.rs:67:12
+   |
+LL | struct Obj<F> where F: FnOnce() -> u32 {
+   | -------------------------------------- method `closure` not found for this
+...
+LL |     w.wrap.closure();//~ ERROR no method named `closure` found
+   |            ^^^^^^^ field, not a method
+   |
+   = help: use `(w.wrap.closure)(...)` if you meant to call the function stored in the `closure` field
+
+error[E0599]: no method named `not_closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
+  --> $DIR/issue-2392.rs:69:12
+   |
+LL | struct Obj<F> where F: FnOnce() -> u32 {
+   | -------------------------------------- method `not_closure` not found for this
+...
+LL |     w.wrap.not_closure();
+   |            ^^^^^^^^^^^ field, not a method
+   |
+   = help: did you mean to write `w.wrap.not_closure` instead of `w.wrap.not_closure(...)`?
+
+error[E0599]: no method named `closure` found for type `Obj<std::boxed::Box<(dyn std::boxed::FnBox<(), Output=u32> + 'static)>>` in the current scope
+  --> $DIR/issue-2392.rs:72:24
+   |
+LL | struct Obj<F> where F: FnOnce() -> u32 {
+   | -------------------------------------- method `closure` not found for this
+...
+LL |     check_expression().closure();//~ ERROR no method named `closure` found
+   |                        ^^^^^^^ field, not a method
+   |
+   = help: use `(check_expression().closure)(...)` if you meant to call the function stored in the `closure` field
+
+error[E0599]: no method named `f1` found for type `FuncContainer` in the current scope
+  --> $DIR/issue-2392.rs:78:31
+   |
+LL | struct FuncContainer {
+   | -------------------- method `f1` not found for this
+...
+LL |             (*self.container).f1(1); //~ ERROR no method named `f1` found
+   |                               ^^ field, not a method
+   |
+   = help: use `((*self.container).f1)(...)` if you meant to call the function stored in the `f1` field
+
+error[E0599]: no method named `f2` found for type `FuncContainer` in the current scope
+  --> $DIR/issue-2392.rs:79:31
+   |
+LL | struct FuncContainer {
+   | -------------------- method `f2` not found for this
+...
+LL |             (*self.container).f2(1); //~ ERROR no method named `f2` found
+   |                               ^^ field, not a method
+   |
+   = help: use `((*self.container).f2)(...)` if you meant to call the function stored in the `f2` field
+
+error[E0599]: no method named `f3` found for type `FuncContainer` in the current scope
+  --> $DIR/issue-2392.rs:80:31
+   |
+LL | struct FuncContainer {
+   | -------------------- method `f3` not found for this
+...
+LL |             (*self.container).f3(1); //~ ERROR no method named `f3` found
+   |                               ^^ field, not a method
+   |
+   = help: use `((*self.container).f3)(...)` if you meant to call the function stored in the `f3` field
+
+error: aborting due to 11 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/confuse-field-and-method/issue-32128.rs b/src/test/ui/confuse-field-and-method/issue-32128.rs
new file mode 100644 (file)
index 0000000..d306b38
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct Example {
+    example: Box<Fn(i32) -> i32>
+}
+
+fn main() {
+    let demo = Example {
+        example: Box::new(|x| {
+            x + 1
+        })
+    };
+
+    demo.example(1);
+    //~^ ERROR no method named `example`
+    // (demo.example)(1);
+}
diff --git a/src/test/ui/confuse-field-and-method/issue-32128.stderr b/src/test/ui/confuse-field-and-method/issue-32128.stderr
new file mode 100644 (file)
index 0000000..95b764b
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0599]: no method named `example` found for type `Example` in the current scope
+  --> $DIR/issue-32128.rs:22:10
+   |
+LL | struct Example {
+   | -------------- method `example` not found for this
+...
+LL |     demo.example(1);
+   |          ^^^^^^^ field, not a method
+   |
+   = help: use `(demo.example)(...)` if you meant to call the function stored in the `example` field
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/confuse-field-and-method/issue-33784.rs b/src/test/ui/confuse-field-and-method/issue-33784.rs
new file mode 100644 (file)
index 0000000..4cd50be
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::ops::Deref;
+
+struct Obj<F> where F: FnMut() -> u32 {
+    fn_ptr: fn() -> (),
+    closure: F,
+}
+
+struct C {
+    c_fn_ptr: fn() -> (),
+}
+
+struct D(C);
+
+impl Deref for D {
+    type Target = C;
+    fn deref(&self) -> &C {
+        &self.0
+    }
+}
+
+
+fn empty() {}
+
+fn main() {
+    let o = Obj { fn_ptr: empty, closure: || 42 };
+    let p = &o;
+    p.closure(); //~ ERROR no method named `closure` found
+    let q = &p;
+    q.fn_ptr(); //~ ERROR no method named `fn_ptr` found
+    let r = D(C { c_fn_ptr: empty });
+    let s = &r;
+    s.c_fn_ptr(); //~ ERROR no method named `c_fn_ptr` found
+}
diff --git a/src/test/ui/confuse-field-and-method/issue-33784.stderr b/src/test/ui/confuse-field-and-method/issue-33784.stderr
new file mode 100644 (file)
index 0000000..b7f1332
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0599]: no method named `closure` found for type `&Obj<[closure@$DIR/issue-33784.rs:35:43: 35:48]>` in the current scope
+  --> $DIR/issue-33784.rs:37:7
+   |
+LL |     p.closure(); //~ ERROR no method named `closure` found
+   |       ^^^^^^^ field, not a method
+   |
+   = help: use `(p.closure)(...)` if you meant to call the function stored in the `closure` field
+
+error[E0599]: no method named `fn_ptr` found for type `&&Obj<[closure@$DIR/issue-33784.rs:35:43: 35:48]>` in the current scope
+  --> $DIR/issue-33784.rs:39:7
+   |
+LL |     q.fn_ptr(); //~ ERROR no method named `fn_ptr` found
+   |       ^^^^^^ field, not a method
+   |
+   = help: use `(q.fn_ptr)(...)` if you meant to call the function stored in the `fn_ptr` field
+
+error[E0599]: no method named `c_fn_ptr` found for type `&D` in the current scope
+  --> $DIR/issue-33784.rs:42:7
+   |
+LL |     s.c_fn_ptr(); //~ ERROR no method named `c_fn_ptr` found
+   |       ^^^^^^^^ field, not a method
+   |
+   = help: use `(s.c_fn_ptr)(...)` if you meant to call the function stored in the `c_fn_ptr` field
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/confuse-field-and-method/private-field.rs b/src/test/ui/confuse-field-and-method/private-field.rs
new file mode 100644 (file)
index 0000000..4cf939b
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub mod animal {
+    pub struct Dog {
+        pub age: usize,
+        dog_age: usize,
+    }
+
+    impl Dog {
+        pub fn new(age: usize) -> Dog {
+            Dog { age: age, dog_age: age * 7 }
+        }
+    }
+}
+
+fn main() {
+    let dog = animal::Dog::new(3);
+    let dog_age = dog.dog_age(); //~ ERROR no method
+    //let dog_age = dog.dog_age;
+    println!("{}", dog_age);
+}
diff --git a/src/test/ui/confuse-field-and-method/private-field.stderr b/src/test/ui/confuse-field-and-method/private-field.stderr
new file mode 100644 (file)
index 0000000..145df8b
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0599]: no method named `dog_age` found for type `animal::Dog` in the current scope
+  --> $DIR/private-field.rs:26:23
+   |
+LL |     pub struct Dog {
+   |     -------------- method `dog_age` not found for this
+...
+LL |     let dog_age = dog.dog_age(); //~ ERROR no method
+   |                       ^^^^^^^ private field, not a method
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
index a39afb9bdd4a477e3f14c5a741ee46e8182fb0c1..04e9bfbc03e27bbe6267d0e851674c3dc3643b9d 100644 (file)
@@ -24,5 +24,8 @@ fn main() {
     //~| WARN const_err
     println!("{}", 1/(false as u32));
     //~^ WARN const_err
+    //~| WARN const_err
     let _x = 1/(false as u32);
+    //~^ WARN const_err
+    //~| WARN const_err
 }
index a4c1c48a03dfe30f1a5a5f6f3076b9e7ccd884a8..9afe5f20af39402071ba632d149c00d671821bde 100644 (file)
@@ -34,9 +34,27 @@ warning: this expression will panic at runtime
 LL |     let _x = 1/(1-1);
    |              ^^^^^^^ attempt to divide by zero
 
+warning: attempt to divide by zero
+  --> $DIR/promoted_errors.rs:25:20
+   |
+LL |     println!("{}", 1/(false as u32));
+   |                    ^^^^^^^^^^^^^^^^
+
 warning: this expression will panic at runtime
   --> $DIR/promoted_errors.rs:25:20
    |
 LL |     println!("{}", 1/(false as u32));
    |                    ^^^^^^^^^^^^^^^^ attempt to divide by zero
 
+warning: attempt to divide by zero
+  --> $DIR/promoted_errors.rs:28:14
+   |
+LL |     let _x = 1/(false as u32);
+   |              ^^^^^^^^^^^^^^^^
+
+warning: this expression will panic at runtime
+  --> $DIR/promoted_errors.rs:28:14
+   |
+LL |     let _x = 1/(false as u32);
+   |              ^^^^^^^^^^^^^^^^ attempt to divide by zero
+
diff --git a/src/test/ui/const-type-mismatch.rs b/src/test/ui/const-type-mismatch.rs
new file mode 100644 (file)
index 0000000..ddad4e7
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// `const`s shouldn't suggest `.into()`
+
+const TEN: u8 = 10;
+const TWELVE: u16 = TEN + 2;
+//~^ ERROR mismatched types [E0308]
+
+fn main() {
+    const TEN: u8 = 10;
+    const ALSO_TEN: u16 = TEN;
+    //~^ ERROR mismatched types [E0308]
+}
diff --git a/src/test/ui/const-type-mismatch.stderr b/src/test/ui/const-type-mismatch.stderr
new file mode 100644 (file)
index 0000000..965995f
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0308]: mismatched types
+  --> $DIR/const-type-mismatch.rs:14:21
+   |
+LL | const TWELVE: u16 = TEN + 2;
+   |                     ^^^^^^^ expected u16, found u8
+
+error[E0308]: mismatched types
+  --> $DIR/const-type-mismatch.rs:19:27
+   |
+LL |     const ALSO_TEN: u16 = TEN;
+   |                           ^^^ expected u16, found u8
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/conversion-methods.rs b/src/test/ui/conversion-methods.rs
new file mode 100644 (file)
index 0000000..8a53bc3
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::path::{Path, PathBuf};
+
+
+fn main() {
+    let _tis_an_instants_play: String = "'Tis a fond Ambush—"; //~ ERROR mismatched types
+    let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise");
+    //~^ ERROR mismatched types
+
+    let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here
+    //~^ ERROR mismatched types
+
+    let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3]; //~ ERROR mismatched types
+}
diff --git a/src/test/ui/conversion-methods.stderr b/src/test/ui/conversion-methods.stderr
new file mode 100644 (file)
index 0000000..970ccad
--- /dev/null
@@ -0,0 +1,51 @@
+error[E0308]: mismatched types
+  --> $DIR/conversion-methods.rs:15:41
+   |
+LL |     let _tis_an_instants_play: String = "'Tis a fond Ambush—"; //~ ERROR mismatched types
+   |                                         ^^^^^^^^^^^^^^^^^^^^^
+   |                                         |
+   |                                         expected struct `std::string::String`, found reference
+   |                                         help: try using a conversion method: `"'Tis a fond Ambush—".to_string()`
+   |
+   = note: expected type `std::string::String`
+              found type `&'static str`
+
+error[E0308]: mismatched types
+  --> $DIR/conversion-methods.rs:16:40
+   |
+LL |     let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise");
+   |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                                        |
+   |                                        expected struct `std::path::PathBuf`, found reference
+   |                                        help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()`
+   |
+   = note: expected type `std::path::PathBuf`
+              found type `&std::path::Path`
+
+error[E0308]: mismatched types
+  --> $DIR/conversion-methods.rs:19:40
+   |
+LL |     let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here
+   |                                        ^
+   |                                        |
+   |                                        expected struct `std::string::String`, found integral variable
+   |                                        help: try using a conversion method: `2.to_string()`
+   |
+   = note: expected type `std::string::String`
+              found type `{integer}`
+
+error[E0308]: mismatched types
+  --> $DIR/conversion-methods.rs:22:47
+   |
+LL |     let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3]; //~ ERROR mismatched types
+   |                                               ^^^^^^^^^^
+   |                                               |
+   |                                               expected struct `std::vec::Vec`, found reference
+   |                                               help: try using a conversion method: `&[1, 2, 3].to_vec()`
+   |
+   = note: expected type `std::vec::Vec<usize>`
+              found type `&[{integer}; 3]`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/dont-suggest-private-trait-method.rs b/src/test/ui/dont-suggest-private-trait-method.rs
new file mode 100644 (file)
index 0000000..99bee0d
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct T;
+
+fn main() {
+    T::new();
+    //~^ ERROR no function or associated item named `new` found for type `T` in the current scope
+}
diff --git a/src/test/ui/dont-suggest-private-trait-method.stderr b/src/test/ui/dont-suggest-private-trait-method.stderr
new file mode 100644 (file)
index 0000000..81ecc54
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0599]: no function or associated item named `new` found for type `T` in the current scope
+  --> $DIR/dont-suggest-private-trait-method.rs:14:5
+   |
+LL | struct T;
+   | --------- function or associated item `new` not found for this
+...
+LL |     T::new();
+   |     ^^^^^^ function or associated item not found in `T`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/dotdotdot-expr.rs b/src/test/ui/dotdotdot-expr.rs
new file mode 100644 (file)
index 0000000..afb73a5
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let _redemptive = 1...21;
+    //~^ ERROR unexpected token
+}
diff --git a/src/test/ui/dotdotdot-expr.stderr b/src/test/ui/dotdotdot-expr.stderr
new file mode 100644 (file)
index 0000000..3315538
--- /dev/null
@@ -0,0 +1,16 @@
+error: unexpected token: `...`
+  --> $DIR/dotdotdot-expr.rs:12:24
+   |
+LL |     let _redemptive = 1...21;
+   |                        ^^^
+help: use `..` for an exclusive range
+   |
+LL |     let _redemptive = 1..21;
+   |                        ^^
+help: or `..=` for an inclusive range
+   |
+LL |     let _redemptive = 1..=21;
+   |                        ^^^
+
+error: aborting due to previous error
+
index 5304e7c2d2717e77236b3efbee25c5231e46b222..fa99ba6a417e39988835b4db1b2bb9c176fb552d 100644 (file)
@@ -2,7 +2,9 @@ error[E0458]: unknown kind: `wonderful_unicorn`
   --> $DIR/E0458.rs:11:1
    |
 LL | #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown kind
+   | ^^^^^^^--------------------------^^
+   |        |
+   |        unknown kind
 
 error[E0459]: #[link(...)] specified without `name = "foo"`
   --> $DIR/E0458.rs:11:1
diff --git a/src/test/ui/existential_types/bound_reduction.rs b/src/test/ui/existential_types/bound_reduction.rs
new file mode 100644 (file)
index 0000000..2e42c92
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-pass
+
+#![allow(warnings)]
+
+#![feature(existential_type)]
+
+fn main() {
+}
+
+existential type Foo<V>: std::fmt::Debug;
+
+trait Trait<U> {}
+
+fn foo_desugared<T: Trait<[u32; {
+    #[no_mangle]
+    static FOO: usize = 42;
+    3
+}]>>(_: T) -> Foo<T> {
+    (42, std::marker::PhantomData::<T>)
+}
diff --git a/src/test/ui/existential_types/bound_reduction2.rs b/src/test/ui/existential_types/bound_reduction2.rs
new file mode 100644 (file)
index 0000000..d098a4e
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+
+fn main() {
+}
+
+trait TraitWithAssoc {
+    type Assoc;
+}
+
+existential type Foo<V>: Trait<V>;
+
+trait Trait<U> {}
+
+impl<W> Trait<W> for () {}
+
+fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { //~ ERROR non-defining
+    ()
+}
diff --git a/src/test/ui/existential_types/bound_reduction2.stderr b/src/test/ui/existential_types/bound_reduction2.stderr
new file mode 100644 (file)
index 0000000..33b8b71
--- /dev/null
@@ -0,0 +1,16 @@
+error: non-defining existential type use in defining scope
+  --> $DIR/bound_reduction2.rs:26:1
+   |
+LL | / fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { //~ ERROR non-defining
+LL | |     ()
+LL | | }
+   | |_^
+   |
+note: used non-generic type <T as TraitWithAssoc>::Assoc for generic parameter
+  --> $DIR/bound_reduction2.rs:20:22
+   |
+LL | existential type Foo<V>: Trait<V>;
+   |                      ^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/declared_but_never_defined.rs b/src/test/ui/existential_types/declared_but_never_defined.rs
new file mode 100644 (file)
index 0000000..c0f08fe
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+// declared but never defined
+existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
diff --git a/src/test/ui/existential_types/declared_but_never_defined.stderr b/src/test/ui/existential_types/declared_but_never_defined.stderr
new file mode 100644 (file)
index 0000000..29ae10c
--- /dev/null
@@ -0,0 +1,8 @@
+error: could not find defining uses
+  --> $DIR/declared_but_never_defined.rs:17:1
+   |
+LL | existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs b/src/test/ui/existential_types/declared_but_not_defined_in_scope.rs
new file mode 100644 (file)
index 0000000..6d0a9b8
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+mod boo {
+    // declared in module but not defined inside of it
+    pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
+}
+
+fn bomp() -> boo::Boo {
+    ""
+}
diff --git a/src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr b/src/test/ui/existential_types/declared_but_not_defined_in_scope.stderr
new file mode 100644 (file)
index 0000000..fcd8e2a
--- /dev/null
@@ -0,0 +1,8 @@
+error: could not find defining uses
+  --> $DIR/declared_but_not_defined_in_scope.rs:18:5
+   |
+LL |     pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/different_defining_uses.rs b/src/test/ui/existential_types/different_defining_uses.rs
new file mode 100644 (file)
index 0000000..c58ca3f
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+// two definitions with different types
+existential type Foo: std::fmt::Debug;
+
+fn foo() -> Foo {
+    ""
+}
+
+fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+    42i32
+}
diff --git a/src/test/ui/existential_types/different_defining_uses.stderr b/src/test/ui/existential_types/different_defining_uses.stderr
new file mode 100644 (file)
index 0000000..63177e8
--- /dev/null
@@ -0,0 +1,18 @@
+error: defining existential type use differs from previous
+  --> $DIR/different_defining_uses.rs:23:1
+   |
+LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | |     42i32
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/different_defining_uses.rs:19:1
+   |
+LL | / fn foo() -> Foo {
+LL | |     ""
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/different_defining_uses_never_type.rs b/src/test/ui/existential_types/different_defining_uses_never_type.rs
new file mode 100644 (file)
index 0000000..5bf46ef
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+// two definitions with different types
+existential type Foo: std::fmt::Debug;
+
+fn foo() -> Foo {
+    ""
+}
+
+fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+    panic!()
+}
+
+fn boo() -> Foo { //~ ERROR defining existential type use differs from previous
+    loop {}
+}
diff --git a/src/test/ui/existential_types/different_defining_uses_never_type.stderr b/src/test/ui/existential_types/different_defining_uses_never_type.stderr
new file mode 100644 (file)
index 0000000..f0e9f50
--- /dev/null
@@ -0,0 +1,34 @@
+error: defining existential type use differs from previous
+  --> $DIR/different_defining_uses_never_type.rs:23:1
+   |
+LL | / fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | |     panic!()
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/different_defining_uses_never_type.rs:19:1
+   |
+LL | / fn foo() -> Foo {
+LL | |     ""
+LL | | }
+   | |_^
+
+error: defining existential type use differs from previous
+  --> $DIR/different_defining_uses_never_type.rs:27:1
+   |
+LL | / fn boo() -> Foo { //~ ERROR defining existential type use differs from previous
+LL | |     loop {}
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/different_defining_uses_never_type.rs:19:1
+   |
+LL | / fn foo() -> Foo {
+LL | |     ""
+LL | | }
+   | |_^
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/existential_types/different_defining_uses_never_type2.rs b/src/test/ui/existential_types/different_defining_uses_never_type2.rs
new file mode 100644 (file)
index 0000000..0e40221
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-pass
+
+#![feature(existential_type)]
+
+fn main() {}
+
+// two definitions with different types
+existential type Foo: std::fmt::Debug;
+
+fn foo() -> Foo {
+    ""
+}
+
+fn bar(arg: bool) -> Foo {
+    if arg {
+        panic!()
+    } else {
+        "bar"
+    }
+}
+
+fn boo(arg: bool) -> Foo {
+    if arg {
+        loop {}
+    } else {
+        "boo"
+    }
+}
+
+fn bar2(arg: bool) -> Foo {
+    if arg {
+        "bar2"
+    } else {
+        panic!()
+    }
+}
+
+fn boo2(arg: bool) -> Foo {
+    if arg {
+        "boo2"
+    } else {
+        loop {}
+    }
+}
diff --git a/src/test/ui/existential_types/existential-associated-type.rs b/src/test/ui/existential_types/existential-associated-type.rs
new file mode 100644 (file)
index 0000000..af393fe
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+// compile-pass
+
+trait Bar {}
+struct Dummy;
+impl Bar for Dummy {}
+
+trait Foo {
+    type Assoc: Bar;
+    fn foo() -> Self::Assoc;
+    fn bar() -> Self::Assoc;
+}
+
+existential type Helper: Bar;
+
+impl Foo for i32 {
+    type Assoc = Helper;
+    fn foo() -> Helper {
+        Dummy
+    }
+    fn bar() -> Helper {
+        Dummy
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/existential_types/generic_different_defining_uses.rs b/src/test/ui/existential_types/generic_different_defining_uses.rs
new file mode 100644 (file)
index 0000000..109f1cd
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type MyIter<T>: Iterator<Item = T>;
+
+fn my_iter<T>(t: T) -> MyIter<T> {
+    std::iter::once(t)
+}
+
+fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
+    Some(t).into_iter()
+}
diff --git a/src/test/ui/existential_types/generic_different_defining_uses.stderr b/src/test/ui/existential_types/generic_different_defining_uses.stderr
new file mode 100644 (file)
index 0000000..bc71af4
--- /dev/null
@@ -0,0 +1,18 @@
+error: defining existential type use differs from previous
+  --> $DIR/generic_different_defining_uses.rs:22:1
+   |
+LL | / fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
+LL | |     Some(t).into_iter()
+LL | | }
+   | |_^
+   |
+note: previous use here
+  --> $DIR/generic_different_defining_uses.rs:18:1
+   |
+LL | / fn my_iter<T>(t: T) -> MyIter<T> {
+LL | |     std::iter::once(t)
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/generic_duplicate_lifetime_param.rs b/src/test/ui/existential_types/generic_duplicate_lifetime_param.rs
new file mode 100644 (file)
index 0000000..92b234a
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type Two<'a, 'b>: std::fmt::Debug;
+
+fn one<'a>(t: &'a ()) -> Two<'a, 'a> { //~ ERROR non-defining existential type use
+    t
+}
diff --git a/src/test/ui/existential_types/generic_duplicate_lifetime_param.stderr b/src/test/ui/existential_types/generic_duplicate_lifetime_param.stderr
new file mode 100644 (file)
index 0000000..0316832
--- /dev/null
@@ -0,0 +1,16 @@
+error: non-defining existential type use in defining scope
+  --> $DIR/generic_duplicate_lifetime_param.rs:18:1
+   |
+LL | / fn one<'a>(t: &'a ()) -> Two<'a, 'a> { //~ ERROR non-defining existential type use
+LL | |     t
+LL | | }
+   | |_^
+   |
+note: lifetime used multiple times
+  --> $DIR/generic_duplicate_lifetime_param.rs:16:22
+   |
+LL | existential type Two<'a, 'b>: std::fmt::Debug;
+   |                      ^^  ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use.rs b/src/test/ui/existential_types/generic_duplicate_param_use.rs
new file mode 100644 (file)
index 0000000..52e36fa
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type Two<T, U>: 'static; //~ ERROR type parameter `U` is unused
+
+fn one<T: 'static>(t: T) -> Two<T, T> {
+    t
+}
diff --git a/src/test/ui/existential_types/generic_duplicate_param_use.stderr b/src/test/ui/existential_types/generic_duplicate_param_use.stderr
new file mode 100644 (file)
index 0000000..e4a92db
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0091]: type parameter `U` is unused
+  --> $DIR/generic_duplicate_param_use.rs:16:25
+   |
+LL | existential type Two<T, U>: 'static; //~ ERROR type parameter `U` is unused
+   |                         ^ unused type parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0091`.
diff --git a/src/test/ui/existential_types/generic_lifetime_param.rs b/src/test/ui/existential_types/generic_lifetime_param.rs
new file mode 100644 (file)
index 0000000..3bdb69e
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-pass
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type Region<'a>: std::fmt::Debug;
+
+fn region<'b>(a: &'b ()) -> Region<'b> {
+    a
+}
diff --git a/src/test/ui/existential_types/generic_nondefining_use.rs b/src/test/ui/existential_types/generic_nondefining_use.rs
new file mode 100644 (file)
index 0000000..a4b74d6
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type Cmp<T>: 'static;
+
+// not a defining use, because it doesn't define *all* possible generics
+fn cmp() -> Cmp<u32> { //~ ERROR non-defining existential type use in defining scope
+    5u32
+}
diff --git a/src/test/ui/existential_types/generic_nondefining_use.stderr b/src/test/ui/existential_types/generic_nondefining_use.stderr
new file mode 100644 (file)
index 0000000..3c82670
--- /dev/null
@@ -0,0 +1,16 @@
+error: non-defining existential type use in defining scope
+  --> $DIR/generic_nondefining_use.rs:19:1
+   |
+LL | / fn cmp() -> Cmp<u32> { //~ ERROR non-defining existential type use in defining scope
+LL | |     5u32
+LL | | }
+   | |_^
+   |
+note: used non-generic type u32 for generic parameter
+  --> $DIR/generic_nondefining_use.rs:16:22
+   |
+LL | existential type Cmp<T>: 'static;
+   |                      ^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/generic_not_used.rs b/src/test/ui/existential_types/generic_not_used.rs
new file mode 100644 (file)
index 0000000..b090cf2
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type WrongGeneric<T: 'static>: 'static;
+
+fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
+//~^ ERROR type parameter `V` is part of concrete type but not used in parameter list
+    v
+}
diff --git a/src/test/ui/existential_types/generic_not_used.stderr b/src/test/ui/existential_types/generic_not_used.stderr
new file mode 100644 (file)
index 0000000..34d82c0
--- /dev/null
@@ -0,0 +1,12 @@
+error: type parameter `V` is part of concrete type but not used in parameter list for existential type
+  --> $DIR/generic_not_used.rs:18:73
+   |
+LL |   fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> {
+   |  _________________________________________________________________________^
+LL | | //~^ ERROR type parameter `V` is part of concrete type but not used in parameter list
+LL | |     v
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr
new file mode 100644 (file)
index 0000000..84af8e1
--- /dev/null
@@ -0,0 +1,18 @@
+error[E0308]: mismatched types
+  --> $DIR/generic_type_does_not_live_long_enough.rs:16:18
+   |
+LL |     let z: i32 = x; //~ ERROR mismatched types
+   |                  ^ expected i32, found anonymized type
+   |
+   = note: expected type `i32`
+              found type `WrongGeneric::<&{integer}>`
+
+warning: not reporting region error due to nll
+  --> $DIR/generic_type_does_not_live_long_enough.rs:19:1
+   |
+LL | existential type WrongGeneric<T>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.rs
new file mode 100644 (file)
index 0000000..440fc2d
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+
+fn main() {
+    let y = 42;
+    let x = wrong_generic(&y);
+    let z: i32 = x; //~ ERROR mismatched types
+}
+
+existential type WrongGeneric<T>: 'static;
+//~^ ERROR the parameter type `T` may not live long enough
+
+fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
+    t
+}
diff --git a/src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr b/src/test/ui/existential_types/generic_type_does_not_live_long_enough.stderr
new file mode 100644 (file)
index 0000000..189ad7d
--- /dev/null
@@ -0,0 +1,28 @@
+error[E0308]: mismatched types
+  --> $DIR/generic_type_does_not_live_long_enough.rs:16:18
+   |
+LL |     let z: i32 = x; //~ ERROR mismatched types
+   |                  ^ expected i32, found anonymized type
+   |
+   = note: expected type `i32`
+              found type `WrongGeneric::<&{integer}>`
+
+error[E0310]: the parameter type `T` may not live long enough
+  --> $DIR/generic_type_does_not_live_long_enough.rs:19:1
+   |
+LL | existential type WrongGeneric<T>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
+   |                  - help: consider adding an explicit lifetime bound `T: 'static`...
+   |
+note: ...so that the type `T` will meet its required lifetime bounds
+  --> $DIR/generic_type_does_not_live_long_enough.rs:19:1
+   |
+LL | existential type WrongGeneric<T>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+Some errors occurred: E0308, E0310.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/existential_types/generic_underconstrained.rs b/src/test/ui/existential_types/generic_underconstrained.rs
new file mode 100644 (file)
index 0000000..fdc7a79
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+trait Trait {}
+existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
+
+// no `Trait` bound
+fn underconstrain<T>(_: T) -> Underconstrained<T> {
+    unimplemented!()
+}
diff --git a/src/test/ui/existential_types/generic_underconstrained.stderr b/src/test/ui/existential_types/generic_underconstrained.stderr
new file mode 100644 (file)
index 0000000..1454ba5
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `T: Trait` is not satisfied
+  --> $DIR/generic_underconstrained.rs:17:1
+   |
+LL | existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
+   |
+   = help: consider adding a `where T: Trait` bound
+   = note: the return type of a function must have a statically known size
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_types/generic_underconstrained2.rs b/src/test/ui/existential_types/generic_underconstrained2.rs
new file mode 100644 (file)
index 0000000..bffb6b5
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+existential type Underconstrained<T: std::fmt::Debug>: 'static;
+//~^ ERROR `U` doesn't implement `std::fmt::Debug`
+
+// not a defining use, because it doesn't define *all* possible generics
+fn underconstrained<U>(_: U) -> Underconstrained<U> {
+    5u32
+}
+
+existential type Underconstrained2<T: std::fmt::Debug>: 'static;
+//~^ ERROR `V` doesn't implement `std::fmt::Debug`
+
+// not a defining use, because it doesn't define *all* possible generics
+fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
+    5u32
+}
diff --git a/src/test/ui/existential_types/generic_underconstrained2.stderr b/src/test/ui/existential_types/generic_underconstrained2.stderr
new file mode 100644 (file)
index 0000000..78e79e7
--- /dev/null
@@ -0,0 +1,23 @@
+error[E0277]: `U` doesn't implement `std::fmt::Debug`
+  --> $DIR/generic_underconstrained2.rs:16:1
+   |
+LL | existential type Underconstrained<T: std::fmt::Debug>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |
+   = help: the trait `std::fmt::Debug` is not implemented for `U`
+   = help: consider adding a `where U: std::fmt::Debug` bound
+   = note: the return type of a function must have a statically known size
+
+error[E0277]: `V` doesn't implement `std::fmt::Debug`
+  --> $DIR/generic_underconstrained2.rs:24:1
+   |
+LL | existential type Underconstrained2<T: std::fmt::Debug>: 'static;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
+   |
+   = help: the trait `std::fmt::Debug` is not implemented for `V`
+   = help: consider adding a `where V: std::fmt::Debug` bound
+   = note: the return type of a function must have a statically known size
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/existential_types/never_reveal_concrete_type.rs b/src/test/ui/existential_types/never_reveal_concrete_type.rs
new file mode 100644 (file)
index 0000000..4517eca
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+// don't reveal the concrete type
+existential type NoReveal: std::fmt::Debug;
+
+fn define_no_reveal() -> NoReveal {
+    ""
+}
+
+fn no_reveal(x: NoReveal) {
+    let _: &'static str = x; //~ mismatched types
+    let _ = x as &'static str; //~ non-primitive cast
+}
diff --git a/src/test/ui/existential_types/never_reveal_concrete_type.stderr b/src/test/ui/existential_types/never_reveal_concrete_type.stderr
new file mode 100644 (file)
index 0000000..449799c
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0308]: mismatched types
+  --> $DIR/never_reveal_concrete_type.rs:24:27
+   |
+LL |     let _: &'static str = x; //~ mismatched types
+   |                           ^ expected reference, found anonymized type
+   |
+   = note: expected type `&'static str`
+              found type `NoReveal`
+
+error[E0605]: non-primitive cast: `NoReveal` as `&'static str`
+  --> $DIR/never_reveal_concrete_type.rs:25:13
+   |
+LL |     let _ = x as &'static str; //~ non-primitive cast
+   |             ^^^^^^^^^^^^^^^^^
+   |
+   = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
+
+error: aborting due to 2 previous errors
+
+Some errors occurred: E0308, E0605.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/existential_types/no_revealing_outside_defining_module.rs b/src/test/ui/existential_types/no_revealing_outside_defining_module.rs
new file mode 100644 (file)
index 0000000..f646891
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+#![feature(existential_type)]
+
+fn main() {}
+
+mod boo {
+    pub existential type Boo: ::std::fmt::Debug;
+    fn bomp() -> Boo {
+        ""
+    }
+}
+
+// don't actually know the type here
+
+fn bomp2() {
+    let _: &str = bomp(); //~ ERROR mismatched types
+}
+
+fn bomp() -> boo::Boo {
+    "" //~ ERROR mismatched types
+}
+
+fn bomp_loop() -> boo::Boo {
+    loop {}
+}
diff --git a/src/test/ui/existential_types/no_revealing_outside_defining_module.stderr b/src/test/ui/existential_types/no_revealing_outside_defining_module.stderr
new file mode 100644 (file)
index 0000000..a1c98c6
--- /dev/null
@@ -0,0 +1,23 @@
+error[E0308]: mismatched types
+  --> $DIR/no_revealing_outside_defining_module.rs:26:19
+   |
+LL |     let _: &str = bomp(); //~ ERROR mismatched types
+   |                   ^^^^^^ expected &str, found anonymized type
+   |
+   = note: expected type `&str`
+              found type `Boo`
+
+error[E0308]: mismatched types
+  --> $DIR/no_revealing_outside_defining_module.rs:30:5
+   |
+LL | fn bomp() -> boo::Boo {
+   |              -------- expected `Boo` because of return type
+LL |     "" //~ ERROR mismatched types
+   |     ^^ expected anonymized type, found reference
+   |
+   = note: expected type `Boo`
+              found type `&'static str`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/existential_types/not_well_formed.rs b/src/test/ui/existential_types/not_well_formed.rs
new file mode 100644 (file)
index 0000000..b3d38ae
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+
+fn main() {
+}
+
+trait TraitWithAssoc {
+    type Assoc;
+}
+
+existential type Foo<V>: Trait<V::Assoc>; //~ associated type `Assoc` not found for `V`
+
+trait Trait<U> {}
+
+impl<W> Trait<W> for () {}
+
+fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T> {
+    ()
+}
diff --git a/src/test/ui/existential_types/not_well_formed.stderr b/src/test/ui/existential_types/not_well_formed.stderr
new file mode 100644 (file)
index 0000000..6b7d1be
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0220]: associated type `Assoc` not found for `V`
+  --> $DIR/not_well_formed.rs:20:32
+   |
+LL | existential type Foo<V>: Trait<V::Assoc>; //~ associated type `Assoc` not found for `V`
+   |                                ^^^^^^^^ associated type `Assoc` not found
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0220`.
diff --git a/src/test/ui/existential_types/unused_generic_param.rs b/src/test/ui/existential_types/unused_generic_param.rs
new file mode 100644 (file)
index 0000000..420ce89
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+
+fn main() {
+}
+
+existential type PartiallyDefined<T>: 'static; //~ `T` is unused
+
+fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> {
+    4u32
+}
+
+existential type PartiallyDefined2<T>: 'static; //~ `T` is unused
+
+fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> {
+    4u32
+}
+
+fn partially_defined22<T>(_: T) -> PartiallyDefined2<T> {
+    4u32
+}
diff --git a/src/test/ui/existential_types/unused_generic_param.stderr b/src/test/ui/existential_types/unused_generic_param.stderr
new file mode 100644 (file)
index 0000000..7ad5eab
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0091]: type parameter `T` is unused
+  --> $DIR/unused_generic_param.rs:16:35
+   |
+LL | existential type PartiallyDefined<T>: 'static; //~ `T` is unused
+   |                                   ^ unused type parameter
+
+error[E0091]: type parameter `T` is unused
+  --> $DIR/unused_generic_param.rs:22:36
+   |
+LL | existential type PartiallyDefined2<T>: 'static; //~ `T` is unused
+   |                                    ^ unused type parameter
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0091`.
diff --git a/src/test/ui/extern-crate-rename.rs b/src/test/ui/extern-crate-rename.rs
new file mode 100644 (file)
index 0000000..b58149f
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:m1.rs
+// aux-build:m2.rs
+
+
+extern crate m1;
+extern crate m2 as m1; //~ ERROR is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/extern-crate-rename.stderr b/src/test/ui/extern-crate-rename.stderr
new file mode 100644 (file)
index 0000000..2c2723f
--- /dev/null
@@ -0,0 +1,16 @@
+error[E0259]: the name `m1` is defined multiple times
+  --> $DIR/extern-crate-rename.rs:16:1
+   |
+LL | extern crate m1;
+   | ---------------- previous import of the extern crate `m1` here
+LL | extern crate m2 as m1; //~ ERROR is defined multiple times
+   | ^^^^^^^^^^^^^^^^^^^^^^
+   | |
+   | `m1` reimported here
+   | You can use `as` to change the binding name of the import
+   |
+   = note: `m1` must be defined only once in the type namespace of this module
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0259`.
diff --git a/src/test/ui/feature-gate-existential-type.rs b/src/test/ui/feature-gate-existential-type.rs
new file mode 100644 (file)
index 0000000..b35a391
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check that existential types must be ungated to use the `existential` keyword
+
+
+
+existential type Foo: std::fmt::Debug; //~ ERROR existential types are unstable
+
+trait Bar {
+    type Baa: std::fmt::Debug;
+}
+
+impl Bar for () {
+    existential type Baa: std::fmt::Debug; //~ ERROR existential types are unstable
+}
+
+fn main() {}
diff --git a/src/test/ui/feature-gate-existential-type.stderr b/src/test/ui/feature-gate-existential-type.stderr
new file mode 100644 (file)
index 0000000..6db5fa2
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0658]: existential types are unstable (see issue #34511)
+  --> $DIR/feature-gate-existential-type.rs:15:1
+   |
+LL | existential type Foo: std::fmt::Debug; //~ ERROR existential types are unstable
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add #![feature(existential_type)] to the crate attributes to enable
+
+error[E0658]: existential types are unstable (see issue #34511)
+  --> $DIR/feature-gate-existential-type.rs:22:5
+   |
+LL |     existential type Baa: std::fmt::Debug; //~ ERROR existential types are unstable
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add #![feature(existential_type)] to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/feature-gate-wasm_import_module.rs b/src/test/ui/feature-gate-wasm_import_module.rs
deleted file mode 100644 (file)
index c5898a9..0000000
+++ /dev/null
@@ -1,15 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[wasm_import_module = "test"] //~ ERROR: experimental
-extern {
-}
-
-fn main() {}
diff --git a/src/test/ui/feature-gate-wasm_import_module.stderr b/src/test/ui/feature-gate-wasm_import_module.stderr
deleted file mode 100644 (file)
index 5430f6b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0658]: experimental attribute (see issue #52090)
-  --> $DIR/feature-gate-wasm_import_module.rs:11:1
-   |
-LL | #[wasm_import_module = "test"] //~ ERROR: experimental
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(wasm_import_module)] to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/fn-closure-mutable-capture.nll.stderr b/src/test/ui/fn-closure-mutable-capture.nll.stderr
new file mode 100644 (file)
index 0000000..7ef21d3
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0594]: cannot assign to `x` which is behind a `&` reference
+  --> $DIR/fn-closure-mutable-capture.rs:15:17
+   |
+LL |     bar(move || x = 1);
+   |                 ^^^^^ cannot assign
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/fn-closure-mutable-capture.rs b/src/test/ui/fn-closure-mutable-capture.rs
new file mode 100644 (file)
index 0000000..385efeb
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub fn bar<F: Fn()>(_f: F) {}
+
+pub fn foo() {
+    let mut x = 0;
+    bar(move || x = 1);
+    //~^ ERROR cannot assign to captured outer variable in an `Fn` closure
+    //~| NOTE `Fn` closures cannot capture their enclosing environment for modifications
+}
+
+fn main() {}
diff --git a/src/test/ui/fn-closure-mutable-capture.stderr b/src/test/ui/fn-closure-mutable-capture.stderr
new file mode 100644 (file)
index 0000000..a58d663
--- /dev/null
@@ -0,0 +1,16 @@
+error[E0594]: cannot assign to captured outer variable in an `Fn` closure
+  --> $DIR/fn-closure-mutable-capture.rs:15:17
+   |
+LL |     bar(move || x = 1);
+   |                 ^^^^^
+   |
+   = note: `Fn` closures cannot capture their enclosing environment for modifications
+help: consider changing this closure to take self by mutable reference
+  --> $DIR/fn-closure-mutable-capture.rs:15:9
+   |
+LL |     bar(move || x = 1);
+   |         ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/for-c-in-str.rs b/src/test/ui/for-c-in-str.rs
new file mode 100644 (file)
index 0000000..011886e
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// E0277 should point exclusively at line 14, not the entire for loop span
+
+fn main() {
+    for c in "asdf" {
+    //~^ ERROR the trait bound `&str: std::iter::Iterator` is not satisfied
+    //~| NOTE `&str` is not an iterator
+    //~| HELP the trait `std::iter::Iterator` is not implemented for `&str`
+    //~| NOTE required by `std::iter::IntoIterator::into_iter`
+        println!("");
+    }
+}
diff --git a/src/test/ui/for-c-in-str.stderr b/src/test/ui/for-c-in-str.stderr
new file mode 100644 (file)
index 0000000..b249df3
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied
+  --> $DIR/for-c-in-str.rs:14:14
+   |
+LL |     for c in "asdf" {
+   |              ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()`
+   |
+   = help: the trait `std::iter::Iterator` is not implemented for `&str`
+   = note: required by `std::iter::IntoIterator::into_iter`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
index a594ee8aab42a7033de49326de2e48e50b895234..a241ba53461ff97ac595d5d404cbf26ff9a56f8b 100644 (file)
@@ -23,7 +23,9 @@ fn main() {
 // return type, which can't depend on the obligation.
 fn cycle1() -> impl Clone {
     //~^ ERROR cycle detected
+    //~| ERROR cycle detected
     send(cycle2().clone());
+    //~^ ERROR cannot be sent between threads safely
 
     Rc::new(Cell::new(5))
 }
index 6681116f0f3936cb40469f582203144298798aac..10711d1cd8cece6719d8f9b1e6fefaccfd203e2b 100644 (file)
@@ -1,29 +1,67 @@
-error[E0391]: cycle detected when processing `cycle1`
+error[E0391]: cycle detected when processing `cycle1::{{impl-Trait}}`
+  --> $DIR/auto-trait-leak.rs:24:16
+   |
+LL | fn cycle1() -> impl Clone {
+   |                ^^^^^^^^^^
+   |
+note: ...which requires processing `cycle1`...
   --> $DIR/auto-trait-leak.rs:24:1
    |
 LL | fn cycle1() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
 note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
 note: ...which requires processing `cycle2::{{impl-Trait}}`...
-  --> $DIR/auto-trait-leak.rs:31:16
+  --> $DIR/auto-trait-leak.rs:33:16
    |
 LL | fn cycle2() -> impl Clone {
    |                ^^^^^^^^^^
 note: ...which requires processing `cycle2`...
-  --> $DIR/auto-trait-leak.rs:31:1
+  --> $DIR/auto-trait-leak.rs:33:1
    |
 LL | fn cycle2() -> impl Clone {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
-note: ...which requires processing `cycle1::{{impl-Trait}}`...
+   = note: ...which again requires processing `cycle1::{{impl-Trait}}`, completing the cycle
+
+error[E0391]: cycle detected when processing `cycle1::{{impl-Trait}}`
   --> $DIR/auto-trait-leak.rs:24:16
    |
 LL | fn cycle1() -> impl Clone {
    |                ^^^^^^^^^^
-   = note: ...which again requires processing `cycle1`, completing the cycle
-note: cycle used when type-checking all item bodies
+   |
+note: ...which requires processing `cycle1`...
+  --> $DIR/auto-trait-leak.rs:24:1
+   |
+LL | fn cycle1() -> impl Clone {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
+note: ...which requires processing `cycle2::{{impl-Trait}}`...
+  --> $DIR/auto-trait-leak.rs:33:16
+   |
+LL | fn cycle2() -> impl Clone {
+   |                ^^^^^^^^^^
+note: ...which requires processing `cycle2`...
+  --> $DIR/auto-trait-leak.rs:33:1
+   |
+LL | fn cycle2() -> impl Clone {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which again requires processing `cycle1::{{impl-Trait}}`, completing the cycle
+
+error[E0277]: `std::rc::Rc<std::string::String>` cannot be sent between threads safely
+  --> $DIR/auto-trait-leak.rs:27:5
+   |
+LL |     send(cycle2().clone());
+   |     ^^^^ `std::rc::Rc<std::string::String>` cannot be sent between threads safely
+   |
+   = help: within `impl std::clone::Clone`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<std::string::String>`
+   = note: required because it appears within the type `impl std::clone::Clone`
+note: required by `send`
+  --> $DIR/auto-trait-leak.rs:16:1
+   |
+LL | fn send<T: Send>(_: T) {}
+   | ^^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to previous error
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0391`.
+Some errors occurred: E0277, E0391.
+For more information about an error, try `rustc --explain E0277`.
index d3b97a9c058633a45fd9f15717e0c2717c4856ff..0e8b7fb903769e7797d25d5c38cc91aa107de0f9 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-test currently ICEs when using NLL (#52416)
+
 // We used to ICE when moving out of a `*mut T` or `*const T`.
 
 struct T(u8);
diff --git a/src/test/ui/issue-32354-suggest-import-rename.fixed b/src/test/ui/issue-32354-suggest-import-rename.fixed
new file mode 100644 (file)
index 0000000..251f7eb
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+#![allow(unused_imports)]
+
+pub mod extension1 {
+    pub trait ConstructorExtension {}
+}
+
+pub mod extension2 {
+    pub trait ConstructorExtension {}
+}
+
+use extension1::ConstructorExtension;
+use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/issue-32354-suggest-import-rename.rs b/src/test/ui/issue-32354-suggest-import-rename.rs
new file mode 100644 (file)
index 0000000..57cbeb4
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+#![allow(unused_imports)]
+
+pub mod extension1 {
+    pub trait ConstructorExtension {}
+}
+
+pub mod extension2 {
+    pub trait ConstructorExtension {}
+}
+
+use extension1::ConstructorExtension;
+use extension2::ConstructorExtension; //~ ERROR is defined multiple times
+
+fn main() {}
diff --git a/src/test/ui/issue-32354-suggest-import-rename.stderr b/src/test/ui/issue-32354-suggest-import-rename.stderr
new file mode 100644 (file)
index 0000000..f45a5f7
--- /dev/null
@@ -0,0 +1,17 @@
+error[E0252]: the name `ConstructorExtension` is defined multiple times
+  --> $DIR/issue-32354-suggest-import-rename.rs:24:5
+   |
+LL | use extension1::ConstructorExtension;
+   |     -------------------------------- previous import of the trait `ConstructorExtension` here
+LL | use extension2::ConstructorExtension; //~ ERROR is defined multiple times
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here
+   |
+   = note: `ConstructorExtension` must be defined only once in the type namespace of this module
+help: You can use `as` to change the binding name of the import
+   |
+LL | use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0252`.
diff --git a/src/test/ui/issue-43420-no-over-suggest.rs b/src/test/ui/issue-43420-no-over-suggest.rs
new file mode 100644 (file)
index 0000000..8c5bde4
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// check that we substitute type parameters before we suggest anything - otherwise
+// we would suggest function such as `as_slice` for the `&[u16]`.
+
+fn foo(b: &[u16]) {}
+
+fn main() {
+    let a: Vec<u8> = Vec::new();
+    foo(&a); //~ ERROR mismatched types
+}
diff --git a/src/test/ui/issue-43420-no-over-suggest.stderr b/src/test/ui/issue-43420-no-over-suggest.stderr
new file mode 100644 (file)
index 0000000..80bbdd1
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-43420-no-over-suggest.rs:18:9
+   |
+LL |     foo(&a); //~ ERROR mismatched types
+   |         ^^ expected slice, found struct `std::vec::Vec`
+   |
+   = note: expected type `&[u16]`
+              found type `&std::vec::Vec<u8>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
index 9719a87b31bc347a0f21a086888b09b41d560756..80d8c5c9814366297ddefb55561fe2466ef65aa8 100644 (file)
@@ -1,8 +1,8 @@
 error: `cfg()` must have an argument
-  --> $DIR/issue-43926.rs:11:1
+  --> $DIR/issue-43926.rs:11:20
    |
 LL | #[link(name="foo", cfg())] //~ ERROR `cfg()` must have an argument
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                    ^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issue-45562.fixed b/src/test/ui/issue-45562.fixed
new file mode 100644 (file)
index 0000000..7c01f0d
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+#[no_mangle] pub static RAH: usize = 5;
+//~^ ERROR const items should never be #[no_mangle]
+
+fn main() {}
diff --git a/src/test/ui/issue-45562.rs b/src/test/ui/issue-45562.rs
new file mode 100644 (file)
index 0000000..c27d52f
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+#[no_mangle] pub const RAH: usize = 5;
+//~^ ERROR const items should never be #[no_mangle]
+
+fn main() {}
diff --git a/src/test/ui/issue-45562.stderr b/src/test/ui/issue-45562.stderr
new file mode 100644 (file)
index 0000000..d9e624c
--- /dev/null
@@ -0,0 +1,12 @@
+error: const items should never be #[no_mangle]
+  --> $DIR/issue-45562.rs:13:14
+   |
+LL | #[no_mangle] pub const RAH: usize = 5;
+   |              ---------^^^^^^^^^^^^^^^^
+   |              |
+   |              help: try a static value: `pub static`
+   |
+   = note: #[deny(no_mangle_const_items)] on by default
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed
new file mode 100644 (file)
index 0000000..e328703
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+extern crate std as other_std;
+fn main() {}
+//~^^ ERROR the name `std` is defined multiple times [E0259]
diff --git a/src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs b/src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs
new file mode 100644 (file)
index 0000000..f47ea47
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+extern crate std;
+fn main() {}
+//~^^ ERROR the name `std` is defined multiple times [E0259]
diff --git a/src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/src/test/ui/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr
new file mode 100644 (file)
index 0000000..ecdfec2
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0259]: the name `std` is defined multiple times
+  --> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:13:1
+   |
+LL | extern crate std;
+   | ^^^^^^^^^^^^^^^^^ `std` reimported here
+   |
+   = note: `std` must be defined only once in the type namespace of this module
+help: You can use `as` to change the binding name of the import
+   |
+LL | extern crate std as other_std;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0259`.
diff --git a/src/test/ui/issue-46302.rs b/src/test/ui/issue-46302.rs
new file mode 100644 (file)
index 0000000..6ae6b54
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn foo() {
+  let s = "abc";
+  let u: &str = if true { s[..2] } else { s };
+  //~^ ERROR mismatched types
+}
+
+fn main() {
+    foo();
+}
diff --git a/src/test/ui/issue-46302.stderr b/src/test/ui/issue-46302.stderr
new file mode 100644 (file)
index 0000000..8e39913
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-46302.rs:13:27
+   |
+LL |   let u: &str = if true { s[..2] } else { s };
+   |                           ^^^^^^
+   |                           |
+   |                           expected &str, found str
+   |                           help: consider borrowing here: `&s[..2]`
+   |
+   = note: expected type `&str`
+              found type `str`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.fixed b/src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.fixed
new file mode 100644 (file)
index 0000000..77171ca
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+#![allow(unused)]
+
+fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
+    and_yet + 1
+}
+
+fn main() {
+    let behold: isize = 2;
+    let with_tears: usize = 3;
+    light_flows_our_war_of_mocking_words(&(behold as usize));
+    //~^ ERROR mismatched types [E0308]
+    light_flows_our_war_of_mocking_words(&(with_tears + 4));
+    //~^ ERROR mismatched types [E0308]
+}
diff --git a/src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.rs b/src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.rs
new file mode 100644 (file)
index 0000000..e5ea9b5
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+#![allow(unused)]
+
+fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
+    and_yet + 1
+}
+
+fn main() {
+    let behold: isize = 2;
+    let with_tears: usize = 3;
+    light_flows_our_war_of_mocking_words(behold as usize);
+    //~^ ERROR mismatched types [E0308]
+    light_flows_our_war_of_mocking_words(with_tears + 4);
+    //~^ ERROR mismatched types [E0308]
+}
diff --git a/src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.stderr b/src/test/ui/issue-46756-consider-borrowing-cast-or-binexpr.stderr
new file mode 100644 (file)
index 0000000..9c49275
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42
+   |
+LL |     light_flows_our_war_of_mocking_words(behold as usize);
+   |                                          ^^^^^^^^^^^^^^^
+   |                                          |
+   |                                          expected &usize, found usize
+   |                                          help: consider borrowing here: `&(behold as usize)`
+   |
+   = note: expected type `&usize`
+              found type `usize`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:24:42
+   |
+LL |     light_flows_our_war_of_mocking_words(with_tears + 4);
+   |                                          ^^^^^^^^^^^^^^
+   |                                          |
+   |                                          expected &usize, found usize
+   |                                          help: consider borrowing here: `&(with_tears + 4)`
+   |
+   = note: expected type `&usize`
+              found type `usize`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/issue-48364.rs b/src/test/ui/issue-48364.rs
new file mode 100644 (file)
index 0000000..82cb722
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn foo() -> bool {
+    b"".starts_with(stringify!(foo))
+    //~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/issue-48364.stderr b/src/test/ui/issue-48364.stderr
new file mode 100644 (file)
index 0000000..b420654
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-48364.rs:12:21
+   |
+LL |     b"".starts_with(stringify!(foo))
+   |                     ^^^^^^^^^^^^^^^ expected slice, found str
+   |
+   = note: expected type `&[u8]`
+              found type `&'static str`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/issue-51244.nll.stderr b/src/test/ui/issue-51244.nll.stderr
new file mode 100644 (file)
index 0000000..ce02ae2
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference
+  --> $DIR/issue-51244.rs:13:5
+   |
+LL |     let ref my_ref @ _ = 0;
+   |         -------------- help: consider changing this to be a mutable reference: `ref mut my_ref @ _`
+LL |     *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594]
+   |     ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/issue-51244.rs b/src/test/ui/issue-51244.rs
new file mode 100644 (file)
index 0000000..50a2118
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let ref my_ref @ _ = 0;
+    *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594]
+}
diff --git a/src/test/ui/issue-51244.stderr b/src/test/ui/issue-51244.stderr
new file mode 100644 (file)
index 0000000..997a742
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0594]: cannot assign to immutable borrowed content `*my_ref`
+  --> $DIR/issue-51244.rs:13:5
+   |
+LL |     let ref my_ref @ _ = 0;
+   |         -------------- help: use a mutable reference instead: `ref mut my_ref @ _`
+LL |     *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594]
+   |     ^^^^^^^^^^^ cannot borrow as mutable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/issue-51515.rs b/src/test/ui/issue-51515.rs
new file mode 100644 (file)
index 0000000..3e0a3b7
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(nll)]
+
+fn main() {
+    let foo = &16;
+    //~^ HELP consider changing this to be a mutable reference
+    //~| SUGGESTION &mut 16
+    *foo = 32;
+    //~^ ERROR cannot assign to `*foo` which is behind a `&` reference
+    let bar = foo;
+    //~^ HELP consider changing this to be a mutable reference
+    //~| SUGGESTION &mut i32
+    *bar = 64;
+    //~^ ERROR cannot assign to `*bar` which is behind a `&` reference
+}
diff --git a/src/test/ui/issue-51515.stderr b/src/test/ui/issue-51515.stderr
new file mode 100644 (file)
index 0000000..3e7349b
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0594]: cannot assign to `*foo` which is behind a `&` reference
+  --> $DIR/issue-51515.rs:17:5
+   |
+LL |     let foo = &16;
+   |               --- help: consider changing this to be a mutable reference: `&mut 16`
+...
+LL |     *foo = 32;
+   |     ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
+
+error[E0594]: cannot assign to `*bar` which is behind a `&` reference
+  --> $DIR/issue-51515.rs:22:5
+   |
+LL |     let bar = foo;
+   |         --- help: consider changing this to be a mutable reference: `&mut i32`
+...
+LL |     *bar = 64;
+   |     ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/issue-52049.nll.stderr b/src/test/ui/issue-52049.nll.stderr
new file mode 100644 (file)
index 0000000..6f71f16
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/issue-52049.rs:16:10
+   |
+LL |     foo(&unpromotable(5u32));
+   |          ^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
+LL | }
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/issue-52049.rs b/src/test/ui/issue-52049.rs
new file mode 100644 (file)
index 0000000..daff225
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn foo(_: &'static u32) {}
+
+fn unpromotable<T>(t: T) -> T { t }
+
+fn main() {
+    foo(&unpromotable(5u32));
+}
+//~^^ ERROR borrowed value does not live long enough
diff --git a/src/test/ui/issue-52049.stderr b/src/test/ui/issue-52049.stderr
new file mode 100644 (file)
index 0000000..e1e5010
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/issue-52049.rs:16:10
+   |
+LL |     foo(&unpromotable(5u32));
+   |          ^^^^^^^^^^^^^^^^^^ - temporary value only lives until here
+   |          |
+   |          temporary value does not live long enough
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/lint/auxiliary/lints-in-foreign-macros.rs b/src/test/ui/lint/auxiliary/lints-in-foreign-macros.rs
new file mode 100644 (file)
index 0000000..cf8e9c1
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[macro_export]
+macro_rules! bar {
+    () => {use std::string::ToString;}
+}
+
+#[macro_export]
+macro_rules! baz {
+    ($i:item) => ($i)
+}
+
+#[macro_export]
+macro_rules! baz2 {
+    ($($i:tt)*) => ($($i)*)
+}
diff --git a/src/test/ui/lint/lints-in-foreign-macros.rs b/src/test/ui/lint/lints-in-foreign-macros.rs
new file mode 100644 (file)
index 0000000..0f90038
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:lints-in-foreign-macros.rs
+// compile-pass
+
+#![warn(unused_imports)]
+
+#[macro_use]
+extern crate lints_in_foreign_macros;
+
+macro_rules! foo {
+    () => {use std::string::ToString;} //~ WARN: unused import
+}
+
+mod a { foo!(); }
+mod b { bar!(); }
+mod c { baz!(use std::string::ToString;); } //~ WARN: unused import
+mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import
+
+fn main() {}
diff --git a/src/test/ui/lint/lints-in-foreign-macros.stderr b/src/test/ui/lint/lints-in-foreign-macros.stderr
new file mode 100644 (file)
index 0000000..e9f6d3d
--- /dev/null
@@ -0,0 +1,27 @@
+warning: unused import: `std::string::ToString`
+  --> $DIR/lints-in-foreign-macros.rs:20:16
+   |
+LL |     () => {use std::string::ToString;} //~ WARN: unused import
+   |                ^^^^^^^^^^^^^^^^^^^^^
+...
+LL | mod a { foo!(); }
+   |         ------- in this macro invocation
+   |
+note: lint level defined here
+  --> $DIR/lints-in-foreign-macros.rs:14:9
+   |
+LL | #![warn(unused_imports)]
+   |         ^^^^^^^^^^^^^^
+
+warning: unused import: `std::string::ToString`
+  --> $DIR/lints-in-foreign-macros.rs:25:18
+   |
+LL | mod c { baz!(use std::string::ToString;); } //~ WARN: unused import
+   |                  ^^^^^^^^^^^^^^^^^^^^^
+
+warning: unused import: `std::string::ToString`
+  --> $DIR/lints-in-foreign-macros.rs:26:19
+   |
+LL | mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import
+   |                   ^^^^^^^^^^^^^^^^^^^^^
+
diff --git a/src/test/ui/method-on-ambiguous-numeric-type.rs b/src/test/ui/method-on-ambiguous-numeric-type.rs
new file mode 100644 (file)
index 0000000..2b6e830
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:macro-in-other-crate.rs
+
+#[macro_use] extern crate macro_in_other_crate;
+
+macro_rules! local_mac {
+    ($ident:ident) => { let $ident = 42; }
+}
+
+fn main() {
+    let x = 2.0.neg();
+    //~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
+
+    let y = 2.0;
+    let x = y.neg();
+    //~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
+    println!("{:?}", x);
+
+    for i in 0..100 {
+        println!("{}", i.pow(2));
+        //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+    }
+
+    local_mac!(local_bar);
+    local_bar.pow(2);
+    //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+}
+
+fn qux() {
+    mac!(bar);
+    bar.pow(2);
+    //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+}
diff --git a/src/test/ui/method-on-ambiguous-numeric-type.stderr b/src/test/ui/method-on-ambiguous-numeric-type.stderr
new file mode 100644 (file)
index 0000000..796520e
--- /dev/null
@@ -0,0 +1,51 @@
+error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
+  --> $DIR/method-on-ambiguous-numeric-type.rs:20:17
+   |
+LL |     let x = 2.0.neg();
+   |                 ^^^
+help: you must specify a concrete type for this numeric value, like `f32`
+   |
+LL |     let x = 2.0_f32.neg();
+   |             ^^^^^^^
+
+error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
+  --> $DIR/method-on-ambiguous-numeric-type.rs:24:15
+   |
+LL |     let x = y.neg();
+   |               ^^^
+help: you must specify a type for this binding, like `f32`
+   |
+LL |     let y: f32 = 2.0;
+   |         ^^^^^^
+
+error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
+  --> $DIR/method-on-ambiguous-numeric-type.rs:29:26
+   |
+LL |     for i in 0..100 {
+   |         - you must specify a type for this binding, like `i32`
+LL |         println!("{}", i.pow(2));
+   |                          ^^^
+
+error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
+  --> $DIR/method-on-ambiguous-numeric-type.rs:34:15
+   |
+LL |     local_bar.pow(2);
+   |               ^^^
+help: you must specify a type for this binding, like `i32`
+   |
+LL |     ($ident:ident) => { let $ident: i32 = 42; }
+   |                             ^^^^^^^^^^^
+
+error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
+  --> $DIR/method-on-ambiguous-numeric-type.rs:40:9
+   |
+LL |     mac!(bar);
+   |     ---------- you must specify a type for this binding, like `i32`
+LL |     bar.pow(2);
+   |         ^^^
+   |
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0689`.
diff --git a/src/test/ui/missing-comma-in-match.fixed b/src/test/ui/missing-comma-in-match.fixed
new file mode 100644 (file)
index 0000000..4832f35
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+fn main() {
+    match &Some(3) {
+        &None => 1,
+        &Some(2) => { 3 }
+        //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
+        //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here
+        _ => 2
+    };
+}
diff --git a/src/test/ui/missing-comma-in-match.rs b/src/test/ui/missing-comma-in-match.rs
new file mode 100644 (file)
index 0000000..e39b20e
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+fn main() {
+    match &Some(3) {
+        &None => 1
+        &Some(2) => { 3 }
+        //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
+        //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here
+        _ => 2
+    };
+}
diff --git a/src/test/ui/missing-comma-in-match.stderr b/src/test/ui/missing-comma-in-match.stderr
new file mode 100644 (file)
index 0000000..7793593
--- /dev/null
@@ -0,0 +1,10 @@
+error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
+  --> $DIR/missing-comma-in-match.rs:16:18
+   |
+LL |         &None => 1
+   |                   - help: missing a comma here to end this `match` arm
+LL |         &Some(2) => { 3 }
+   |                  ^^ expected one of `,`, `.`, `?`, `}`, or an operator here
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/numeric-cast-2.rs b/src/test/ui/numeric-cast-2.rs
new file mode 100644 (file)
index 0000000..2092b6b
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn foo() -> i32 {
+    4
+}
+fn main() {
+    let x: u16 = foo();
+    //~^ ERROR mismatched types
+    let y: i64 = x + x;
+    //~^ ERROR mismatched types
+    let z: i32 = x + x;
+    //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/numeric-cast-2.stderr b/src/test/ui/numeric-cast-2.stderr
new file mode 100644 (file)
index 0000000..3d48558
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-2.rs:15:18
+   |
+LL |     let x: u16 = foo();
+   |                  ^^^^^ expected u16, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-2.rs:17:18
+   |
+LL |     let y: i64 = x + x;
+   |                  ^^^^^ expected i64, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast-2.rs:19:18
+   |
+LL |     let z: i32 = x + x;
+   |                  ^^^^^ expected i32, found u16
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/numeric-cast.rs b/src/test/ui/numeric-cast.rs
new file mode 100644 (file)
index 0000000..69bfdfa
--- /dev/null
@@ -0,0 +1,320 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+fn foo<N>(_x: N) {}
+
+fn main() {
+    let x_usize: usize = 1;
+    let x_u64: u64 = 2;
+    let x_u32: u32 = 3;
+    let x_u16: u16 = 4;
+    let x_u8: u8 = 5;
+    let x_isize: isize = 6;
+    let x_i64: i64 = 7;
+    let x_i32: i32 = 8;
+    let x_i16: i16 = 9;
+    let x_i8: i8 = 10;
+    let x_f64: f64 = 11.0;
+    let x_f32: f32 = 12.0;
+
+    foo::<usize>(x_usize);
+    foo::<usize>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<usize>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<isize>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_isize);
+    foo::<isize>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<isize>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u64>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_u64);
+    foo::<u64>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<u64>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i64>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_i64);
+    foo::<i64>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<i64>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u32>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_u32);
+    foo::<u32>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<u32>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i32>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_i32);
+    foo::<i32>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<i32>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u16>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_u16);
+    foo::<u16>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<u16>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i16>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_i16);
+    foo::<i16>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<i16>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<u8>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_u8);
+    foo::<u8>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<u8>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<i8>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_i8);
+    foo::<i8>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<i8>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<f64>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<f64>(x_f64);
+    foo::<f64>(x_f32);
+    //~^ ERROR mismatched types
+
+    foo::<f32>(x_usize);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u64);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u16);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_u8);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_isize);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i64);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i32);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i16);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_i8);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_f64);
+    //~^ ERROR mismatched types
+    foo::<f32>(x_f32);
+
+    foo::<u32>(x_u8 as u16);
+    //~^ ERROR mismatched types
+    foo::<i32>(-x_i8);
+    //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/numeric-cast.stderr b/src/test/ui/numeric-cast.stderr
new file mode 100644 (file)
index 0000000..4aac65f
--- /dev/null
@@ -0,0 +1,907 @@
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:29:18
+   |
+LL |     foo::<usize>(x_u64);
+   |                  ^^^^^ expected usize, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:31:18
+   |
+LL |     foo::<usize>(x_u32);
+   |                  ^^^^^ expected usize, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:33:18
+   |
+LL |     foo::<usize>(x_u16);
+   |                  ^^^^^ expected usize, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:35:18
+   |
+LL |     foo::<usize>(x_u8);
+   |                  ^^^^ expected usize, found u8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:37:18
+   |
+LL |     foo::<usize>(x_isize);
+   |                  ^^^^^^^ expected usize, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:39:18
+   |
+LL |     foo::<usize>(x_i64);
+   |                  ^^^^^ expected usize, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:41:18
+   |
+LL |     foo::<usize>(x_i32);
+   |                  ^^^^^ expected usize, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:43:18
+   |
+LL |     foo::<usize>(x_i16);
+   |                  ^^^^^ expected usize, found i16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:45:18
+   |
+LL |     foo::<usize>(x_i8);
+   |                  ^^^^ expected usize, found i8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:47:18
+   |
+LL |     foo::<usize>(x_f64);
+   |                  ^^^^^ expected usize, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:49:18
+   |
+LL |     foo::<usize>(x_f32);
+   |                  ^^^^^ expected usize, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:52:18
+   |
+LL |     foo::<isize>(x_usize);
+   |                  ^^^^^^^ expected isize, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:54:18
+   |
+LL |     foo::<isize>(x_u64);
+   |                  ^^^^^ expected isize, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:56:18
+   |
+LL |     foo::<isize>(x_u32);
+   |                  ^^^^^ expected isize, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:58:18
+   |
+LL |     foo::<isize>(x_u16);
+   |                  ^^^^^ expected isize, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:60:18
+   |
+LL |     foo::<isize>(x_u8);
+   |                  ^^^^ expected isize, found u8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:63:18
+   |
+LL |     foo::<isize>(x_i64);
+   |                  ^^^^^ expected isize, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:65:18
+   |
+LL |     foo::<isize>(x_i32);
+   |                  ^^^^^ expected isize, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:67:18
+   |
+LL |     foo::<isize>(x_i16);
+   |                  ^^^^^ expected isize, found i16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:69:18
+   |
+LL |     foo::<isize>(x_i8);
+   |                  ^^^^ expected isize, found i8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:71:18
+   |
+LL |     foo::<isize>(x_f64);
+   |                  ^^^^^ expected isize, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:73:18
+   |
+LL |     foo::<isize>(x_f32);
+   |                  ^^^^^ expected isize, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:76:16
+   |
+LL |     foo::<u64>(x_usize);
+   |                ^^^^^^^ expected u64, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:79:16
+   |
+LL |     foo::<u64>(x_u32);
+   |                ^^^^^ expected u64, found u32
+help: you can cast an `u32` to `u64`, which will zero-extend the source value
+   |
+LL |     foo::<u64>(x_u32.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:81:16
+   |
+LL |     foo::<u64>(x_u16);
+   |                ^^^^^ expected u64, found u16
+help: you can cast an `u16` to `u64`, which will zero-extend the source value
+   |
+LL |     foo::<u64>(x_u16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:83:16
+   |
+LL |     foo::<u64>(x_u8);
+   |                ^^^^ expected u64, found u8
+help: you can cast an `u8` to `u64`, which will zero-extend the source value
+   |
+LL |     foo::<u64>(x_u8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:85:16
+   |
+LL |     foo::<u64>(x_isize);
+   |                ^^^^^^^ expected u64, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:87:16
+   |
+LL |     foo::<u64>(x_i64);
+   |                ^^^^^ expected u64, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:89:16
+   |
+LL |     foo::<u64>(x_i32);
+   |                ^^^^^ expected u64, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:91:16
+   |
+LL |     foo::<u64>(x_i16);
+   |                ^^^^^ expected u64, found i16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:93:16
+   |
+LL |     foo::<u64>(x_i8);
+   |                ^^^^ expected u64, found i8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:95:16
+   |
+LL |     foo::<u64>(x_f64);
+   |                ^^^^^ expected u64, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:97:16
+   |
+LL |     foo::<u64>(x_f32);
+   |                ^^^^^ expected u64, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:100:16
+   |
+LL |     foo::<i64>(x_usize);
+   |                ^^^^^^^ expected i64, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:102:16
+   |
+LL |     foo::<i64>(x_u64);
+   |                ^^^^^ expected i64, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:104:16
+   |
+LL |     foo::<i64>(x_u32);
+   |                ^^^^^ expected i64, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:106:16
+   |
+LL |     foo::<i64>(x_u16);
+   |                ^^^^^ expected i64, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:108:16
+   |
+LL |     foo::<i64>(x_u8);
+   |                ^^^^ expected i64, found u8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:110:16
+   |
+LL |     foo::<i64>(x_isize);
+   |                ^^^^^^^ expected i64, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:113:16
+   |
+LL |     foo::<i64>(x_i32);
+   |                ^^^^^ expected i64, found i32
+help: you can cast an `i32` to `i64`, which will sign-extend the source value
+   |
+LL |     foo::<i64>(x_i32.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:115:16
+   |
+LL |     foo::<i64>(x_i16);
+   |                ^^^^^ expected i64, found i16
+help: you can cast an `i16` to `i64`, which will sign-extend the source value
+   |
+LL |     foo::<i64>(x_i16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:117:16
+   |
+LL |     foo::<i64>(x_i8);
+   |                ^^^^ expected i64, found i8
+help: you can cast an `i8` to `i64`, which will sign-extend the source value
+   |
+LL |     foo::<i64>(x_i8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:119:16
+   |
+LL |     foo::<i64>(x_f64);
+   |                ^^^^^ expected i64, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:121:16
+   |
+LL |     foo::<i64>(x_f32);
+   |                ^^^^^ expected i64, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:124:16
+   |
+LL |     foo::<u32>(x_usize);
+   |                ^^^^^^^ expected u32, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:126:16
+   |
+LL |     foo::<u32>(x_u64);
+   |                ^^^^^ expected u32, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:129:16
+   |
+LL |     foo::<u32>(x_u16);
+   |                ^^^^^ expected u32, found u16
+help: you can cast an `u16` to `u32`, which will zero-extend the source value
+   |
+LL |     foo::<u32>(x_u16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:131:16
+   |
+LL |     foo::<u32>(x_u8);
+   |                ^^^^ expected u32, found u8
+help: you can cast an `u8` to `u32`, which will zero-extend the source value
+   |
+LL |     foo::<u32>(x_u8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:133:16
+   |
+LL |     foo::<u32>(x_isize);
+   |                ^^^^^^^ expected u32, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:135:16
+   |
+LL |     foo::<u32>(x_i64);
+   |                ^^^^^ expected u32, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:137:16
+   |
+LL |     foo::<u32>(x_i32);
+   |                ^^^^^ expected u32, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:139:16
+   |
+LL |     foo::<u32>(x_i16);
+   |                ^^^^^ expected u32, found i16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:141:16
+   |
+LL |     foo::<u32>(x_i8);
+   |                ^^^^ expected u32, found i8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:143:16
+   |
+LL |     foo::<u32>(x_f64);
+   |                ^^^^^ expected u32, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:145:16
+   |
+LL |     foo::<u32>(x_f32);
+   |                ^^^^^ expected u32, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:148:16
+   |
+LL |     foo::<i32>(x_usize);
+   |                ^^^^^^^ expected i32, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:150:16
+   |
+LL |     foo::<i32>(x_u64);
+   |                ^^^^^ expected i32, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:152:16
+   |
+LL |     foo::<i32>(x_u32);
+   |                ^^^^^ expected i32, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:154:16
+   |
+LL |     foo::<i32>(x_u16);
+   |                ^^^^^ expected i32, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:156:16
+   |
+LL |     foo::<i32>(x_u8);
+   |                ^^^^ expected i32, found u8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:158:16
+   |
+LL |     foo::<i32>(x_isize);
+   |                ^^^^^^^ expected i32, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:160:16
+   |
+LL |     foo::<i32>(x_i64);
+   |                ^^^^^ expected i32, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:163:16
+   |
+LL |     foo::<i32>(x_i16);
+   |                ^^^^^ expected i32, found i16
+help: you can cast an `i16` to `i32`, which will sign-extend the source value
+   |
+LL |     foo::<i32>(x_i16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:165:16
+   |
+LL |     foo::<i32>(x_i8);
+   |                ^^^^ expected i32, found i8
+help: you can cast an `i8` to `i32`, which will sign-extend the source value
+   |
+LL |     foo::<i32>(x_i8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:167:16
+   |
+LL |     foo::<i32>(x_f64);
+   |                ^^^^^ expected i32, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:169:16
+   |
+LL |     foo::<i32>(x_f32);
+   |                ^^^^^ expected i32, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:172:16
+   |
+LL |     foo::<u16>(x_usize);
+   |                ^^^^^^^ expected u16, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:174:16
+   |
+LL |     foo::<u16>(x_u64);
+   |                ^^^^^ expected u16, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:176:16
+   |
+LL |     foo::<u16>(x_u32);
+   |                ^^^^^ expected u16, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:179:16
+   |
+LL |     foo::<u16>(x_u8);
+   |                ^^^^ expected u16, found u8
+help: you can cast an `u8` to `u16`, which will zero-extend the source value
+   |
+LL |     foo::<u16>(x_u8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:181:16
+   |
+LL |     foo::<u16>(x_isize);
+   |                ^^^^^^^ expected u16, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:183:16
+   |
+LL |     foo::<u16>(x_i64);
+   |                ^^^^^ expected u16, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:185:16
+   |
+LL |     foo::<u16>(x_i32);
+   |                ^^^^^ expected u16, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:187:16
+   |
+LL |     foo::<u16>(x_i16);
+   |                ^^^^^ expected u16, found i16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:189:16
+   |
+LL |     foo::<u16>(x_i8);
+   |                ^^^^ expected u16, found i8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:191:16
+   |
+LL |     foo::<u16>(x_f64);
+   |                ^^^^^ expected u16, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:193:16
+   |
+LL |     foo::<u16>(x_f32);
+   |                ^^^^^ expected u16, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:196:16
+   |
+LL |     foo::<i16>(x_usize);
+   |                ^^^^^^^ expected i16, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:198:16
+   |
+LL |     foo::<i16>(x_u64);
+   |                ^^^^^ expected i16, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:200:16
+   |
+LL |     foo::<i16>(x_u32);
+   |                ^^^^^ expected i16, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:202:16
+   |
+LL |     foo::<i16>(x_u16);
+   |                ^^^^^ expected i16, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:204:16
+   |
+LL |     foo::<i16>(x_u8);
+   |                ^^^^ expected i16, found u8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:206:16
+   |
+LL |     foo::<i16>(x_isize);
+   |                ^^^^^^^ expected i16, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:208:16
+   |
+LL |     foo::<i16>(x_i64);
+   |                ^^^^^ expected i16, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:210:16
+   |
+LL |     foo::<i16>(x_i32);
+   |                ^^^^^ expected i16, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:213:16
+   |
+LL |     foo::<i16>(x_i8);
+   |                ^^^^ expected i16, found i8
+help: you can cast an `i8` to `i16`, which will sign-extend the source value
+   |
+LL |     foo::<i16>(x_i8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:215:16
+   |
+LL |     foo::<i16>(x_f64);
+   |                ^^^^^ expected i16, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:217:16
+   |
+LL |     foo::<i16>(x_f32);
+   |                ^^^^^ expected i16, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:220:15
+   |
+LL |     foo::<u8>(x_usize);
+   |               ^^^^^^^ expected u8, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:222:15
+   |
+LL |     foo::<u8>(x_u64);
+   |               ^^^^^ expected u8, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:224:15
+   |
+LL |     foo::<u8>(x_u32);
+   |               ^^^^^ expected u8, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:226:15
+   |
+LL |     foo::<u8>(x_u16);
+   |               ^^^^^ expected u8, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:229:15
+   |
+LL |     foo::<u8>(x_isize);
+   |               ^^^^^^^ expected u8, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:231:15
+   |
+LL |     foo::<u8>(x_i64);
+   |               ^^^^^ expected u8, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:233:15
+   |
+LL |     foo::<u8>(x_i32);
+   |               ^^^^^ expected u8, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:235:15
+   |
+LL |     foo::<u8>(x_i16);
+   |               ^^^^^ expected u8, found i16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:237:15
+   |
+LL |     foo::<u8>(x_i8);
+   |               ^^^^ expected u8, found i8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:239:15
+   |
+LL |     foo::<u8>(x_f64);
+   |               ^^^^^ expected u8, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:241:15
+   |
+LL |     foo::<u8>(x_f32);
+   |               ^^^^^ expected u8, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:244:15
+   |
+LL |     foo::<i8>(x_usize);
+   |               ^^^^^^^ expected i8, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:246:15
+   |
+LL |     foo::<i8>(x_u64);
+   |               ^^^^^ expected i8, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:248:15
+   |
+LL |     foo::<i8>(x_u32);
+   |               ^^^^^ expected i8, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:250:15
+   |
+LL |     foo::<i8>(x_u16);
+   |               ^^^^^ expected i8, found u16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:252:15
+   |
+LL |     foo::<i8>(x_u8);
+   |               ^^^^ expected i8, found u8
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:254:15
+   |
+LL |     foo::<i8>(x_isize);
+   |               ^^^^^^^ expected i8, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:256:15
+   |
+LL |     foo::<i8>(x_i64);
+   |               ^^^^^ expected i8, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:258:15
+   |
+LL |     foo::<i8>(x_i32);
+   |               ^^^^^ expected i8, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:260:15
+   |
+LL |     foo::<i8>(x_i16);
+   |               ^^^^^ expected i8, found i16
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:263:15
+   |
+LL |     foo::<i8>(x_f64);
+   |               ^^^^^ expected i8, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:265:15
+   |
+LL |     foo::<i8>(x_f32);
+   |               ^^^^^ expected i8, found f32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:268:16
+   |
+LL |     foo::<f64>(x_usize);
+   |                ^^^^^^^ expected f64, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:270:16
+   |
+LL |     foo::<f64>(x_u64);
+   |                ^^^^^ expected f64, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:272:16
+   |
+LL |     foo::<f64>(x_u32);
+   |                ^^^^^ expected f64, found u32
+help: you can cast an `u32` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(x_u32.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:274:16
+   |
+LL |     foo::<f64>(x_u16);
+   |                ^^^^^ expected f64, found u16
+help: you can cast an `u16` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(x_u16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:276:16
+   |
+LL |     foo::<f64>(x_u8);
+   |                ^^^^ expected f64, found u8
+help: you can cast an `u8` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(x_u8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:278:16
+   |
+LL |     foo::<f64>(x_isize);
+   |                ^^^^^^^ expected f64, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:280:16
+   |
+LL |     foo::<f64>(x_i64);
+   |                ^^^^^ expected f64, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:282:16
+   |
+LL |     foo::<f64>(x_i32);
+   |                ^^^^^ expected f64, found i32
+help: you can cast an `i32` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(x_i32.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:284:16
+   |
+LL |     foo::<f64>(x_i16);
+   |                ^^^^^ expected f64, found i16
+help: you can cast an `i16` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(x_i16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:286:16
+   |
+LL |     foo::<f64>(x_i8);
+   |                ^^^^ expected f64, found i8
+help: you can cast an `i8` to `f64`, producing the floating point representation of the integer
+   |
+LL |     foo::<f64>(x_i8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:289:16
+   |
+LL |     foo::<f64>(x_f32);
+   |                ^^^^^ expected f64, found f32
+help: you can cast an `f32` to `f64` in a lossless way
+   |
+LL |     foo::<f64>(x_f32.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:292:16
+   |
+LL |     foo::<f32>(x_usize);
+   |                ^^^^^^^ expected f32, found usize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:294:16
+   |
+LL |     foo::<f32>(x_u64);
+   |                ^^^^^ expected f32, found u64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:296:16
+   |
+LL |     foo::<f32>(x_u32);
+   |                ^^^^^ expected f32, found u32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:298:16
+   |
+LL |     foo::<f32>(x_u16);
+   |                ^^^^^ expected f32, found u16
+help: you can cast an `u16` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(x_u16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:300:16
+   |
+LL |     foo::<f32>(x_u8);
+   |                ^^^^ expected f32, found u8
+help: you can cast an `u8` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(x_u8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:302:16
+   |
+LL |     foo::<f32>(x_isize);
+   |                ^^^^^^^ expected f32, found isize
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:304:16
+   |
+LL |     foo::<f32>(x_i64);
+   |                ^^^^^ expected f32, found i64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:306:16
+   |
+LL |     foo::<f32>(x_i32);
+   |                ^^^^^ expected f32, found i32
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:308:16
+   |
+LL |     foo::<f32>(x_i16);
+   |                ^^^^^ expected f32, found i16
+help: you can cast an `i16` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(x_i16.into());
+   |                ^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:310:16
+   |
+LL |     foo::<f32>(x_i8);
+   |                ^^^^ expected f32, found i8
+help: you can cast an `i8` to `f32`, producing the floating point representation of the integer
+   |
+LL |     foo::<f32>(x_i8.into());
+   |                ^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:312:16
+   |
+LL |     foo::<f32>(x_f64);
+   |                ^^^^^ expected f32, found f64
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:316:16
+   |
+LL |     foo::<u32>(x_u8 as u16);
+   |                ^^^^^^^^^^^ expected u32, found u16
+help: you can cast an `u16` to `u32`, which will zero-extend the source value
+   |
+LL |     foo::<u32>((x_u8 as u16).into());
+   |                ^^^^^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/numeric-cast.rs:318:16
+   |
+LL |     foo::<i32>(-x_i8);
+   |                ^^^^^ expected i32, found i8
+help: you can cast an `i8` to `i32`, which will sign-extend the source value
+   |
+LL |     foo::<i32>((-x_i8).into());
+   |                ^^^^^^^^^^^^^^
+
+error: aborting due to 134 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/placement-syntax.rs b/src/test/ui/placement-syntax.rs
new file mode 100644 (file)
index 0000000..3925259
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x = -5;
+    if x<-1 {
+    //~^ ERROR emplacement syntax is obsolete
+        println!("ok");
+    }
+}
diff --git a/src/test/ui/placement-syntax.stderr b/src/test/ui/placement-syntax.stderr
new file mode 100644 (file)
index 0000000..933ba96
--- /dev/null
@@ -0,0 +1,14 @@
+error: emplacement syntax is obsolete (for now, anyway)
+  --> $DIR/placement-syntax.rs:13:8
+   |
+LL |     if x<-1 {
+   |        ^^^^
+   |
+   = note: for more information, see <https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>
+help: if you meant to write a comparison against a negative value, add a space in between `<` and `-`
+   |
+LL |     if x< -1 {
+   |         ^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/pub-ident-fn-2.rs b/src/test/ui/pub-ident-fn-2.rs
new file mode 100644 (file)
index 0000000..44884bf
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub foo(s: usize) { bar() }
+//~^ ERROR missing `fn` for method definition
+
+fn main() {
+    foo(2);
+}
diff --git a/src/test/ui/pub-ident-fn-2.stderr b/src/test/ui/pub-ident-fn-2.stderr
new file mode 100644 (file)
index 0000000..bbbb3df
--- /dev/null
@@ -0,0 +1,12 @@
+error: missing `fn` for method definition
+  --> $DIR/pub-ident-fn-2.rs:11:4
+   |
+LL | pub foo(s: usize) { bar() }
+   |    ^
+help: add `fn` here to parse `foo` as a public method
+   |
+LL | pub fn foo(s: usize) { bar() }
+   |     ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/pub-ident-fn-or-struct-2.rs b/src/test/ui/pub-ident-fn-or-struct-2.rs
new file mode 100644 (file)
index 0000000..1ccadc8
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub S();
+//~^ ERROR missing `fn` or `struct` for method or struct definition
+
+fn main() {}
diff --git a/src/test/ui/pub-ident-fn-or-struct-2.stderr b/src/test/ui/pub-ident-fn-or-struct-2.stderr
new file mode 100644 (file)
index 0000000..e492a8c
--- /dev/null
@@ -0,0 +1,8 @@
+error: missing `fn` or `struct` for method or struct definition
+  --> $DIR/pub-ident-fn-or-struct-2.rs:11:4
+   |
+LL | pub S();
+   | ---^- help: if you meant to call a macro, try: `S!`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/pub-ident-fn-or-struct.rs b/src/test/ui/pub-ident-fn-or-struct.rs
new file mode 100644 (file)
index 0000000..0664918
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub S (foo) bar
+//~^ ERROR missing `fn` or `struct` for method or struct definition
+
+fn main() {}
diff --git a/src/test/ui/pub-ident-fn-or-struct.stderr b/src/test/ui/pub-ident-fn-or-struct.stderr
new file mode 100644 (file)
index 0000000..c1bff34
--- /dev/null
@@ -0,0 +1,8 @@
+error: missing `fn` or `struct` for method or struct definition
+  --> $DIR/pub-ident-fn-or-struct.rs:11:4
+   |
+LL | pub S (foo) bar
+   | ---^- help: if you meant to call a macro, try: `S!`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/pub-ident-fn.fixed b/src/test/ui/pub-ident-fn.fixed
new file mode 100644 (file)
index 0000000..f2d0c6c
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+pub fn foo(_s: usize) -> bool { true }
+//~^ ERROR missing `fn` for method definition
+
+fn main() {
+    foo(2);
+}
diff --git a/src/test/ui/pub-ident-fn.rs b/src/test/ui/pub-ident-fn.rs
new file mode 100644 (file)
index 0000000..82c32f5
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+pub   foo(_s: usize) -> bool { true }
+//~^ ERROR missing `fn` for method definition
+
+fn main() {
+    foo(2);
+}
diff --git a/src/test/ui/pub-ident-fn.stderr b/src/test/ui/pub-ident-fn.stderr
new file mode 100644 (file)
index 0000000..f7c96b8
--- /dev/null
@@ -0,0 +1,12 @@
+error: missing `fn` for method definition
+  --> $DIR/pub-ident-fn.rs:13:4
+   |
+LL | pub   foo(_s: usize) -> bool { true }
+   |    ^^^
+help: add `fn` here to parse `foo` as a public method
+   |
+LL | pub fn foo(_s: usize) -> bool { true }
+   |     ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/pub-ident-struct.rs b/src/test/ui/pub-ident-struct.rs
new file mode 100644 (file)
index 0000000..d08d498
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub S {
+//~^ ERROR missing `struct` for struct definition
+}
+fn main() {}
diff --git a/src/test/ui/pub-ident-struct.stderr b/src/test/ui/pub-ident-struct.stderr
new file mode 100644 (file)
index 0000000..cd53cea
--- /dev/null
@@ -0,0 +1,12 @@
+error: missing `struct` for struct definition
+  --> $DIR/pub-ident-struct.rs:11:4
+   |
+LL | pub S {
+   |    ^
+help: add `struct` here to parse `S` as a public struct
+   |
+LL | pub struct S {
+   |     ^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/removing-extern-crate.fixed b/src/test/ui/removing-extern-crate.fixed
new file mode 100644 (file)
index 0000000..83b35ce
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: --edition 2018
+// aux-build:removing-extern-crate.rs
+// run-rustfix
+// compile-pass
+
+#![warn(rust_2018_idioms)]
+#![allow(unused_imports)]
+
+
+
+
+mod another {
+    
+    
+}
+
+fn main() {}
diff --git a/src/test/ui/removing-extern-crate.rs b/src/test/ui/removing-extern-crate.rs
new file mode 100644 (file)
index 0000000..2947908
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: --edition 2018
+// aux-build:removing-extern-crate.rs
+// run-rustfix
+// compile-pass
+
+#![warn(rust_2018_idioms)]
+#![allow(unused_imports)]
+
+extern crate std as foo;
+extern crate core;
+
+mod another {
+    extern crate std as foo;
+    extern crate std;
+}
+
+fn main() {}
diff --git a/src/test/ui/removing-extern-crate.stderr b/src/test/ui/removing-extern-crate.stderr
new file mode 100644 (file)
index 0000000..f2eed27
--- /dev/null
@@ -0,0 +1,31 @@
+warning: unused extern crate
+  --> $DIR/removing-extern-crate.rs:19:1
+   |
+LL | extern crate std as foo;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
+   |
+note: lint level defined here
+  --> $DIR/removing-extern-crate.rs:16:9
+   |
+LL | #![warn(rust_2018_idioms)]
+   |         ^^^^^^^^^^^^^^^^
+   = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]
+
+warning: unused extern crate
+  --> $DIR/removing-extern-crate.rs:20:1
+   |
+LL | extern crate core;
+   | ^^^^^^^^^^^^^^^^^^ help: remove it
+
+warning: unused extern crate
+  --> $DIR/removing-extern-crate.rs:23:5
+   |
+LL |     extern crate std as foo;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
+
+warning: unused extern crate
+  --> $DIR/removing-extern-crate.rs:24:5
+   |
+LL |     extern crate std;
+   |     ^^^^^^^^^^^^^^^^^ help: remove it
+
diff --git a/src/test/ui/repr.rs b/src/test/ui/repr.rs
new file mode 100644 (file)
index 0000000..312f602
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-pass
+
+#[repr]
+//^ WARN `repr` attribute must have a hint
+struct _A {}
+
+#[repr = "B"]
+//^ WARN `repr` attribute isn't configurable with a literal
+struct _B {}
+
+#[repr = "C"]
+//^ WARN `repr` attribute isn't configurable with a literal
+struct _C {}
+
+#[repr(C)]
+struct _D {}
+
+fn main() {}
diff --git a/src/test/ui/repr.stderr b/src/test/ui/repr.stderr
new file mode 100644 (file)
index 0000000..7a99d8c
--- /dev/null
@@ -0,0 +1,25 @@
+warning: `repr` attribute must have a hint
+  --> $DIR/repr.rs:13:1
+   |
+LL | #[repr]
+   | ^^^^^^^ needs a hint
+   |
+   = note: #[warn(bad_repr)] on by default
+   = help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
+   = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
+
+warning: `repr` attribute isn't configurable with a literal
+  --> $DIR/repr.rs:17:1
+   |
+LL | #[repr = "B"]
+   | ^^^^^^^^^^^^^ needs a hint
+   |
+   = help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
+   = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
+
+warning: `repr` attribute isn't configurable with a literal
+  --> $DIR/repr.rs:21:1
+   |
+LL | #[repr = "C"]
+   | ^^^^^^^^^^^^^ help: give `repr` a hint: `#[repr(C)]`
+
diff --git a/src/test/ui/return-type.rs b/src/test/ui/return-type.rs
new file mode 100644 (file)
index 0000000..e637879
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct S<T> {
+    t: T,
+}
+
+fn foo<T>(x: T) -> S<T> {
+    S { t: x }
+}
+
+fn bar() {
+    foo(4 as usize)
+    //~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/return-type.stderr b/src/test/ui/return-type.stderr
new file mode 100644 (file)
index 0000000..7d7653e
--- /dev/null
@@ -0,0 +1,20 @@
+error[E0308]: mismatched types
+  --> $DIR/return-type.rs:20:5
+   |
+LL |     foo(4 as usize)
+   |     ^^^^^^^^^^^^^^^ expected (), found struct `S`
+   |
+   = note: expected type `()`
+              found type `S<usize>`
+help: try adding a semicolon
+   |
+LL |     foo(4 as usize);
+   |                    ^
+help: try adding a return type
+   |
+LL | fn bar() -> S<usize> {
+   |          ^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
index 3dd2675646cde0918112259118a93d20b61ee72f..6d18075ba37cf1174e56e34afe268672d0a38d7d 100644 (file)
@@ -1,11 +1,11 @@
-error: lifetime parameter `'b` only used once
-  --> $DIR/one-use-in-fn-argument-in-band.rs:19:22
+error: lifetime parameter `'a` only used once
+  --> $DIR/one-use-in-fn-argument-in-band.rs:19:10
    |
 LL | fn a(x: &'a u32, y: &'b u32) {
-   |                      ^^
-   |                      |
-   |                      this lifetime...
-   |                      ...is used only here
+   |          ^^
+   |          |
+   |          this lifetime...
+   |          ...is used only here
    |
 note: lint level defined here
   --> $DIR/one-use-in-fn-argument-in-band.rs:12:9
@@ -13,14 +13,14 @@ note: lint level defined here
 LL | #![deny(single_use_lifetimes)]
    |         ^^^^^^^^^^^^^^^^^^^^
 
-error: lifetime parameter `'a` only used once
-  --> $DIR/one-use-in-fn-argument-in-band.rs:19:10
+error: lifetime parameter `'b` only used once
+  --> $DIR/one-use-in-fn-argument-in-band.rs:19:22
    |
 LL | fn a(x: &'a u32, y: &'b u32) {
-   |          ^^
-   |          |
-   |          this lifetime...
-   |          ...is used only here
+   |                      ^^
+   |                      |
+   |                      this lifetime...
+   |                      ...is used only here
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/str-array-assignment.rs b/src/test/ui/str-array-assignment.rs
new file mode 100644 (file)
index 0000000..9d6cf5f
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+  let s = "abc";
+  let t = if true { s[..2] } else { s };
+  //~^ ERROR if and else have incompatible types
+  let u: &str = if true { s[..2] } else { s };
+  //~^ ERROR mismatched types
+  let v = s[..2];
+  //~^ ERROR the size for values of type
+  let w: &str = s[..2];
+  //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/str-array-assignment.stderr b/src/test/ui/str-array-assignment.stderr
new file mode 100644 (file)
index 0000000..7a774ca
--- /dev/null
@@ -0,0 +1,49 @@
+error[E0308]: if and else have incompatible types
+  --> $DIR/str-array-assignment.rs:13:11
+   |
+LL |   let t = if true { s[..2] } else { s };
+   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found &str
+   |
+   = note: expected type `str`
+              found type `&str`
+
+error[E0308]: mismatched types
+  --> $DIR/str-array-assignment.rs:15:27
+   |
+LL |   let u: &str = if true { s[..2] } else { s };
+   |                           ^^^^^^
+   |                           |
+   |                           expected &str, found str
+   |                           help: consider borrowing here: `&s[..2]`
+   |
+   = note: expected type `&str`
+              found type `str`
+
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/str-array-assignment.rs:17:7
+   |
+LL |   let v = s[..2];
+   |       ^   ------ help: consider borrowing here: `&s[..2]`
+   |       |
+   |       doesn't have a size known at compile-time
+   |
+   = help: the trait `std::marker::Sized` is not implemented for `str`
+   = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized>
+   = note: all local variables must have a statically known size
+
+error[E0308]: mismatched types
+  --> $DIR/str-array-assignment.rs:19:17
+   |
+LL |   let w: &str = s[..2];
+   |                 ^^^^^^
+   |                 |
+   |                 expected &str, found str
+   |                 help: consider borrowing here: `&s[..2]`
+   |
+   = note: expected type `&str`
+              found type `str`
+
+error: aborting due to 4 previous errors
+
+Some errors occurred: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/str-as-char.fixed b/src/test/ui/str-as-char.fixed
new file mode 100644 (file)
index 0000000..c0dad38
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+fn main() {
+    println!("●●");
+    //~^ ERROR character literal may only contain one codepoint
+}
diff --git a/src/test/ui/str-as-char.rs b/src/test/ui/str-as-char.rs
new file mode 100644 (file)
index 0000000..b5a5df0
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+fn main() {
+    println!('●●');
+    //~^ ERROR character literal may only contain one codepoint
+}
diff --git a/src/test/ui/str-as-char.stderr b/src/test/ui/str-as-char.stderr
new file mode 100644 (file)
index 0000000..60eb182
--- /dev/null
@@ -0,0 +1,12 @@
+error: character literal may only contain one codepoint
+  --> $DIR/str-as-char.rs:14:14
+   |
+LL |     println!('●●');
+   |              ^^^^
+help: if you meant to write a `str` literal, use double quotes
+   |
+LL |     println!("●●");
+   |              ^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/suggest-labels.rs b/src/test/ui/suggest-labels.rs
new file mode 100644 (file)
index 0000000..9fb519c
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[allow(unreachable_code, unused_labels)]
+fn main() {
+    'foo: loop {
+        break 'fo; //~ ERROR use of undeclared label
+    }
+
+    'bar: loop {
+        continue 'bor; //~ ERROR use of undeclared label
+    }
+
+    'longlabel: loop {
+        'longlabel1: loop {
+            break 'longlable; //~ ERROR use of undeclared label
+        }
+    }
+}
diff --git a/src/test/ui/suggest-labels.stderr b/src/test/ui/suggest-labels.stderr
new file mode 100644 (file)
index 0000000..671ff1a
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0426]: use of undeclared label `'fo`
+  --> $DIR/suggest-labels.rs:14:15
+   |
+LL |         break 'fo; //~ ERROR use of undeclared label
+   |               ^^^ did you mean `'foo`?
+
+error[E0426]: use of undeclared label `'bor`
+  --> $DIR/suggest-labels.rs:18:18
+   |
+LL |         continue 'bor; //~ ERROR use of undeclared label
+   |                  ^^^^ did you mean `'bar`?
+
+error[E0426]: use of undeclared label `'longlable`
+  --> $DIR/suggest-labels.rs:23:19
+   |
+LL |             break 'longlable; //~ ERROR use of undeclared label
+   |                   ^^^^^^^^^^ did you mean `'longlabel1`?
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0426`.
diff --git a/src/test/ui/suggest-methods.rs b/src/test/ui/suggest-methods.rs
new file mode 100644 (file)
index 0000000..49027de
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct Foo;
+
+impl Foo {
+    fn bar(self) {}
+    fn baz(&self, x: f64) {}
+}
+
+trait FooT {
+    fn bag(&self);
+}
+
+impl FooT for Foo {
+    fn bag(&self) {}
+}
+
+fn main() {
+    let f = Foo;
+    f.bat(1.0); //~ ERROR no method named
+
+    let s = "foo".to_string();
+    let _ = s.is_emtpy(); //~ ERROR no method named
+
+    // Generates a warning for `count_zeros()`. `count_ones()` is also a close
+    // match, but the former is closer.
+    let _ = 63u32.count_eos(); //~ ERROR no method named
+
+    // Does not generate a warning
+    let _ = 63u32.count_o(); //~ ERROR no method named
+
+}
diff --git a/src/test/ui/suggest-methods.stderr b/src/test/ui/suggest-methods.stderr
new file mode 100644 (file)
index 0000000..cb35236
--- /dev/null
@@ -0,0 +1,36 @@
+error[E0599]: no method named `bat` found for type `Foo` in the current scope
+  --> $DIR/suggest-methods.rs:28:7
+   |
+LL | struct Foo;
+   | ----------- method `bat` not found for this
+...
+LL |     f.bat(1.0); //~ ERROR no method named
+   |       ^^^
+   |
+   = help: did you mean `bar`?
+
+error[E0599]: no method named `is_emtpy` found for type `std::string::String` in the current scope
+  --> $DIR/suggest-methods.rs:31:15
+   |
+LL |     let _ = s.is_emtpy(); //~ ERROR no method named
+   |               ^^^^^^^^
+   |
+   = help: did you mean `is_empty`?
+
+error[E0599]: no method named `count_eos` found for type `u32` in the current scope
+  --> $DIR/suggest-methods.rs:35:19
+   |
+LL |     let _ = 63u32.count_eos(); //~ ERROR no method named
+   |                   ^^^^^^^^^
+   |
+   = help: did you mean `count_zeros`?
+
+error[E0599]: no method named `count_o` found for type `u32` in the current scope
+  --> $DIR/suggest-methods.rs:38:19
+   |
+LL |     let _ = 63u32.count_o(); //~ ERROR no method named
+   |                   ^^^^^^^
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggest-ref-mut.rs b/src/test/ui/suggest-ref-mut.rs
new file mode 100644 (file)
index 0000000..30b5371
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(nll)]
+
+struct X(usize);
+
+impl X {
+    fn zap(&self) {
+        //~^ HELP
+        //~| SUGGESTION &mut self
+        self.0 = 32;
+        //~^ ERROR
+    }
+}
+
+fn main() {
+    let ref foo = 16;
+    //~^ HELP
+    //~| SUGGESTION ref mut foo
+    *foo = 32;
+    //~^ ERROR
+    if let Some(ref bar) = Some(16) {
+        //~^ HELP
+        //~| SUGGESTION ref mut bar
+        *bar = 32;
+        //~^ ERROR
+    }
+    match 16 {
+        ref quo => { *quo = 32; },
+        //~^ ERROR
+        //~| HELP
+        //~| SUGGESTION ref mut quo
+    }
+}
diff --git a/src/test/ui/suggest-ref-mut.stderr b/src/test/ui/suggest-ref-mut.stderr
new file mode 100644 (file)
index 0000000..0b2b240
--- /dev/null
@@ -0,0 +1,38 @@
+error[E0594]: cannot assign to `self.0` which is behind a `&` reference
+  --> $DIR/suggest-ref-mut.rs:19:9
+   |
+LL |     fn zap(&self) {
+   |            ----- help: consider changing this to be a mutable reference: `&mut self`
+...
+LL |         self.0 = 32;
+   |         ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+
+error[E0594]: cannot assign to `*foo` which is behind a `&` reference
+  --> $DIR/suggest-ref-mut.rs:28:5
+   |
+LL |     let ref foo = 16;
+   |         ------- help: consider changing this to be a mutable reference: `ref mut foo`
+...
+LL |     *foo = 32;
+   |     ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
+
+error[E0594]: cannot assign to `*bar` which is behind a `&` reference
+  --> $DIR/suggest-ref-mut.rs:33:9
+   |
+LL |     if let Some(ref bar) = Some(16) {
+   |                 ------- help: consider changing this to be a mutable reference: `ref mut bar`
+...
+LL |         *bar = 32;
+   |         ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
+
+error[E0594]: cannot assign to `*quo` which is behind a `&` reference
+  --> $DIR/suggest-ref-mut.rs:37:22
+   |
+LL |         ref quo => { *quo = 32; },
+   |         -------      ^^^^^^^^^ `quo` is a `&` reference, so the data it refers to cannot be written
+   |         |
+   |         help: consider changing this to be a mutable reference: `ref mut quo`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/as-ref.rs b/src/test/ui/suggestions/as-ref.rs
deleted file mode 100644 (file)
index ae1c98c..0000000
+++ /dev/null
@@ -1,25 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct Foo;
-fn takes_ref(_: &Foo) {}
-
-fn main() {
-  let ref opt = Some(Foo);
-  opt.map(|arg| takes_ref(arg));
-  //~^ ERROR mismatched types [E0308]
-  opt.and_then(|arg| Some(takes_ref(arg)));
-  //~^ ERROR mismatched types [E0308]
-  let ref opt: Result<_, ()> = Ok(Foo);
-  opt.map(|arg| takes_ref(arg));
-  //~^ ERROR mismatched types [E0308]
-  opt.and_then(|arg| Ok(takes_ref(arg)));
-  //~^ ERROR mismatched types [E0308]
-}
diff --git a/src/test/ui/suggestions/as-ref.stderr b/src/test/ui/suggestions/as-ref.stderr
deleted file mode 100644 (file)
index 2701644..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/as-ref.rs:16:27
-   |
-LL |   opt.map(|arg| takes_ref(arg));
-   |       -                   ^^^ expected &Foo, found struct `Foo`
-   |       |
-   |       help: consider using `as_ref` instead: `as_ref().`
-   |
-   = note: expected type `&Foo`
-              found type `Foo`
-
-error[E0308]: mismatched types
-  --> $DIR/as-ref.rs:18:37
-   |
-LL |   opt.and_then(|arg| Some(takes_ref(arg)));
-   |       -                             ^^^ expected &Foo, found struct `Foo`
-   |       |
-   |       help: consider using `as_ref` instead: `as_ref().`
-   |
-   = note: expected type `&Foo`
-              found type `Foo`
-
-error[E0308]: mismatched types
-  --> $DIR/as-ref.rs:21:27
-   |
-LL |   opt.map(|arg| takes_ref(arg));
-   |       -                   ^^^ expected &Foo, found struct `Foo`
-   |       |
-   |       help: consider using `as_ref` instead: `as_ref().`
-   |
-   = note: expected type `&Foo`
-              found type `Foo`
-
-error[E0308]: mismatched types
-  --> $DIR/as-ref.rs:23:35
-   |
-LL |   opt.and_then(|arg| Ok(takes_ref(arg)));
-   |       -                           ^^^ expected &Foo, found struct `Foo`
-   |       |
-   |       help: consider using `as_ref` instead: `as_ref().`
-   |
-   = note: expected type `&Foo`
-              found type `Foo`
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/auxiliary/m1.rs b/src/test/ui/suggestions/auxiliary/m1.rs
deleted file mode 100644 (file)
index b61667c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub fn foo() {}
diff --git a/src/test/ui/suggestions/auxiliary/m2.rs b/src/test/ui/suggestions/auxiliary/m2.rs
deleted file mode 100644 (file)
index 94ff5e4..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub fn bar() {}
diff --git a/src/test/ui/suggestions/auxiliary/macro-in-other-crate.rs b/src/test/ui/suggestions/auxiliary/macro-in-other-crate.rs
deleted file mode 100644 (file)
index 01282f2..0000000
+++ /dev/null
@@ -1,14 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[macro_export]
-macro_rules! mac {
-    ($ident:ident) => { let $ident = 42; }
-}
diff --git a/src/test/ui/suggestions/auxiliary/removing-extern-crate.rs b/src/test/ui/suggestions/auxiliary/removing-extern-crate.rs
deleted file mode 100644 (file)
index 4275e80..0000000
+++ /dev/null
@@ -1,11 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// intentionally blank
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.fixed
deleted file mode 100644 (file)
index b3a0d59..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-// Point at the captured immutable outer variable
-
-fn foo(mut f: Box<FnMut()>) {
-    f();
-}
-
-fn main() {
-    let mut y = true;
-    foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
-}
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed
deleted file mode 100644 (file)
index e162678..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-// Point at the captured immutable outer variable
-
-fn foo(mut f: Box<FnMut()>) {
-    f();
-}
-
-fn main() {
-    let y = true;
-    foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
-}
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr b/src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr
deleted file mode 100644 (file)
index 335ccef..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0594]: cannot assign to immutable item `y`
-  --> $DIR/closure-immutable-outer-variable.rs:21:26
-   |
-LL |     foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
-   |                          ^^^^^^^^^ cannot assign
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.rs b/src/test/ui/suggestions/closure-immutable-outer-variable.rs
deleted file mode 100644 (file)
index e162678..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-// Point at the captured immutable outer variable
-
-fn foo(mut f: Box<FnMut()>) {
-    f();
-}
-
-fn main() {
-    let y = true;
-    foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
-}
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.rs.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.rs.fixed
deleted file mode 100644 (file)
index 80a5a45..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Point at the captured immutable outer variable
-
-fn foo(mut f: Box<FnMut()>) {
-    f();
-}
-
-fn main() {
-    let mut y = true;
-    foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
-}
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.stderr b/src/test/ui/suggestions/closure-immutable-outer-variable.stderr
deleted file mode 100644 (file)
index 0ee11d8..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
-  --> $DIR/closure-immutable-outer-variable.rs:21:26
-   |
-LL |     let y = true;
-   |         - help: consider making `y` mutable: `mut y`
-LL |     foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
-   |                          ^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-18343.rs b/src/test/ui/suggestions/confuse-field-and-method/issue-18343.rs
deleted file mode 100644 (file)
index ef1566a..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct Obj<F> where F: FnMut() -> u32 {
-    closure: F,
-}
-
-fn main() {
-    let o = Obj { closure: || 42 };
-    o.closure();
-    //~^ ERROR no method named `closure` found
-}
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-18343.stderr b/src/test/ui/suggestions/confuse-field-and-method/issue-18343.stderr
deleted file mode 100644 (file)
index b1e3105..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-18343.rs:16:28: 16:33]>` in the current scope
-  --> $DIR/issue-18343.rs:17:7
-   |
-LL | struct Obj<F> where F: FnMut() -> u32 {
-   | ------------------------------------- method `closure` not found for this
-...
-LL |     o.closure();
-   |       ^^^^^^^ field, not a method
-   |
-   = help: use `(o.closure)(...)` if you meant to call the function stored in the `closure` field
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-2392.rs b/src/test/ui/suggestions/confuse-field-and-method/issue-2392.rs
deleted file mode 100644 (file)
index f0c5a2a..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(core, fnbox)]
-
-use std::boxed::FnBox;
-
-struct FuncContainer {
-    f1: fn(data: u8),
-    f2: extern "C" fn(data: u8),
-    f3: unsafe fn(data: u8),
-}
-
-struct FuncContainerOuter {
-    container: Box<FuncContainer>
-}
-
-struct Obj<F> where F: FnOnce() -> u32 {
-    closure: F,
-    not_closure: usize,
-}
-
-struct BoxedObj {
-    boxed_closure: Box<FnBox() -> u32>,
-}
-
-struct Wrapper<F> where F: FnMut() -> u32 {
-    wrap: Obj<F>,
-}
-
-fn func() -> u32 {
-    0
-}
-
-fn check_expression() -> Obj<Box<FnBox() -> u32>> {
-    Obj { closure: Box::new(|| 42_u32) as Box<FnBox() -> u32>, not_closure: 42 }
-}
-
-fn main() {
-    // test variations of function
-
-    let o_closure = Obj { closure: || 42, not_closure: 42 };
-    o_closure.closure(); //~ ERROR no method named `closure` found
-
-    o_closure.not_closure();
-    //~^ ERROR no method named `not_closure` found
-
-    let o_func = Obj { closure: func, not_closure: 5 };
-    o_func.closure(); //~ ERROR no method named `closure` found
-
-    let boxed_fn = BoxedObj { boxed_closure: Box::new(func) };
-    boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found
-
-    let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<FnBox() -> u32> };
-    boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found
-
-    // test expression writing in the notes
-
-    let w = Wrapper { wrap: o_func };
-    w.wrap.closure();//~ ERROR no method named `closure` found
-
-    w.wrap.not_closure();
-    //~^ ERROR no method named `not_closure` found
-
-    check_expression().closure();//~ ERROR no method named `closure` found
-}
-
-impl FuncContainerOuter {
-    fn run(&self) {
-        unsafe {
-            (*self.container).f1(1); //~ ERROR no method named `f1` found
-            (*self.container).f2(1); //~ ERROR no method named `f2` found
-            (*self.container).f3(1); //~ ERROR no method named `f3` found
-        }
-    }
-}
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-2392.stderr b/src/test/ui/suggestions/confuse-field-and-method/issue-2392.stderr
deleted file mode 100644 (file)
index 9049ffd..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-2392.rs:49:36: 49:41]>` in the current scope
-  --> $DIR/issue-2392.rs:50:15
-   |
-LL | struct Obj<F> where F: FnOnce() -> u32 {
-   | -------------------------------------- method `closure` not found for this
-...
-LL |     o_closure.closure(); //~ ERROR no method named `closure` found
-   |               ^^^^^^^ field, not a method
-   |
-   = help: use `(o_closure.closure)(...)` if you meant to call the function stored in the `closure` field
-
-error[E0599]: no method named `not_closure` found for type `Obj<[closure@$DIR/issue-2392.rs:49:36: 49:41]>` in the current scope
-  --> $DIR/issue-2392.rs:52:15
-   |
-LL | struct Obj<F> where F: FnOnce() -> u32 {
-   | -------------------------------------- method `not_closure` not found for this
-...
-LL |     o_closure.not_closure();
-   |               ^^^^^^^^^^^ field, not a method
-   |
-   = help: did you mean to write `o_closure.not_closure` instead of `o_closure.not_closure(...)`?
-
-error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
-  --> $DIR/issue-2392.rs:56:12
-   |
-LL | struct Obj<F> where F: FnOnce() -> u32 {
-   | -------------------------------------- method `closure` not found for this
-...
-LL |     o_func.closure(); //~ ERROR no method named `closure` found
-   |            ^^^^^^^ field, not a method
-   |
-   = help: use `(o_func.closure)(...)` if you meant to call the function stored in the `closure` field
-
-error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
-  --> $DIR/issue-2392.rs:59:14
-   |
-LL | struct BoxedObj {
-   | --------------- method `boxed_closure` not found for this
-...
-LL |     boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found
-   |              ^^^^^^^^^^^^^ field, not a method
-   |
-   = help: use `(boxed_fn.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field
-
-error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
-  --> $DIR/issue-2392.rs:62:19
-   |
-LL | struct BoxedObj {
-   | --------------- method `boxed_closure` not found for this
-...
-LL |     boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found
-   |                   ^^^^^^^^^^^^^ field, not a method
-   |
-   = help: use `(boxed_closure.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field
-
-error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
-  --> $DIR/issue-2392.rs:67:12
-   |
-LL | struct Obj<F> where F: FnOnce() -> u32 {
-   | -------------------------------------- method `closure` not found for this
-...
-LL |     w.wrap.closure();//~ ERROR no method named `closure` found
-   |            ^^^^^^^ field, not a method
-   |
-   = help: use `(w.wrap.closure)(...)` if you meant to call the function stored in the `closure` field
-
-error[E0599]: no method named `not_closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
-  --> $DIR/issue-2392.rs:69:12
-   |
-LL | struct Obj<F> where F: FnOnce() -> u32 {
-   | -------------------------------------- method `not_closure` not found for this
-...
-LL |     w.wrap.not_closure();
-   |            ^^^^^^^^^^^ field, not a method
-   |
-   = help: did you mean to write `w.wrap.not_closure` instead of `w.wrap.not_closure(...)`?
-
-error[E0599]: no method named `closure` found for type `Obj<std::boxed::Box<(dyn std::boxed::FnBox<(), Output=u32> + 'static)>>` in the current scope
-  --> $DIR/issue-2392.rs:72:24
-   |
-LL | struct Obj<F> where F: FnOnce() -> u32 {
-   | -------------------------------------- method `closure` not found for this
-...
-LL |     check_expression().closure();//~ ERROR no method named `closure` found
-   |                        ^^^^^^^ field, not a method
-   |
-   = help: use `(check_expression().closure)(...)` if you meant to call the function stored in the `closure` field
-
-error[E0599]: no method named `f1` found for type `FuncContainer` in the current scope
-  --> $DIR/issue-2392.rs:78:31
-   |
-LL | struct FuncContainer {
-   | -------------------- method `f1` not found for this
-...
-LL |             (*self.container).f1(1); //~ ERROR no method named `f1` found
-   |                               ^^ field, not a method
-   |
-   = help: use `((*self.container).f1)(...)` if you meant to call the function stored in the `f1` field
-
-error[E0599]: no method named `f2` found for type `FuncContainer` in the current scope
-  --> $DIR/issue-2392.rs:79:31
-   |
-LL | struct FuncContainer {
-   | -------------------- method `f2` not found for this
-...
-LL |             (*self.container).f2(1); //~ ERROR no method named `f2` found
-   |                               ^^ field, not a method
-   |
-   = help: use `((*self.container).f2)(...)` if you meant to call the function stored in the `f2` field
-
-error[E0599]: no method named `f3` found for type `FuncContainer` in the current scope
-  --> $DIR/issue-2392.rs:80:31
-   |
-LL | struct FuncContainer {
-   | -------------------- method `f3` not found for this
-...
-LL |             (*self.container).f3(1); //~ ERROR no method named `f3` found
-   |                               ^^ field, not a method
-   |
-   = help: use `((*self.container).f3)(...)` if you meant to call the function stored in the `f3` field
-
-error: aborting due to 11 previous errors
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-32128.rs b/src/test/ui/suggestions/confuse-field-and-method/issue-32128.rs
deleted file mode 100644 (file)
index d306b38..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct Example {
-    example: Box<Fn(i32) -> i32>
-}
-
-fn main() {
-    let demo = Example {
-        example: Box::new(|x| {
-            x + 1
-        })
-    };
-
-    demo.example(1);
-    //~^ ERROR no method named `example`
-    // (demo.example)(1);
-}
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-32128.stderr b/src/test/ui/suggestions/confuse-field-and-method/issue-32128.stderr
deleted file mode 100644 (file)
index 95b764b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0599]: no method named `example` found for type `Example` in the current scope
-  --> $DIR/issue-32128.rs:22:10
-   |
-LL | struct Example {
-   | -------------- method `example` not found for this
-...
-LL |     demo.example(1);
-   |          ^^^^^^^ field, not a method
-   |
-   = help: use `(demo.example)(...)` if you meant to call the function stored in the `example` field
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-33784.rs b/src/test/ui/suggestions/confuse-field-and-method/issue-33784.rs
deleted file mode 100644 (file)
index 4cd50be..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::ops::Deref;
-
-struct Obj<F> where F: FnMut() -> u32 {
-    fn_ptr: fn() -> (),
-    closure: F,
-}
-
-struct C {
-    c_fn_ptr: fn() -> (),
-}
-
-struct D(C);
-
-impl Deref for D {
-    type Target = C;
-    fn deref(&self) -> &C {
-        &self.0
-    }
-}
-
-
-fn empty() {}
-
-fn main() {
-    let o = Obj { fn_ptr: empty, closure: || 42 };
-    let p = &o;
-    p.closure(); //~ ERROR no method named `closure` found
-    let q = &p;
-    q.fn_ptr(); //~ ERROR no method named `fn_ptr` found
-    let r = D(C { c_fn_ptr: empty });
-    let s = &r;
-    s.c_fn_ptr(); //~ ERROR no method named `c_fn_ptr` found
-}
diff --git a/src/test/ui/suggestions/confuse-field-and-method/issue-33784.stderr b/src/test/ui/suggestions/confuse-field-and-method/issue-33784.stderr
deleted file mode 100644 (file)
index b7f1332..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-error[E0599]: no method named `closure` found for type `&Obj<[closure@$DIR/issue-33784.rs:35:43: 35:48]>` in the current scope
-  --> $DIR/issue-33784.rs:37:7
-   |
-LL |     p.closure(); //~ ERROR no method named `closure` found
-   |       ^^^^^^^ field, not a method
-   |
-   = help: use `(p.closure)(...)` if you meant to call the function stored in the `closure` field
-
-error[E0599]: no method named `fn_ptr` found for type `&&Obj<[closure@$DIR/issue-33784.rs:35:43: 35:48]>` in the current scope
-  --> $DIR/issue-33784.rs:39:7
-   |
-LL |     q.fn_ptr(); //~ ERROR no method named `fn_ptr` found
-   |       ^^^^^^ field, not a method
-   |
-   = help: use `(q.fn_ptr)(...)` if you meant to call the function stored in the `fn_ptr` field
-
-error[E0599]: no method named `c_fn_ptr` found for type `&D` in the current scope
-  --> $DIR/issue-33784.rs:42:7
-   |
-LL |     s.c_fn_ptr(); //~ ERROR no method named `c_fn_ptr` found
-   |       ^^^^^^^^ field, not a method
-   |
-   = help: use `(s.c_fn_ptr)(...)` if you meant to call the function stored in the `c_fn_ptr` field
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/confuse-field-and-method/private-field.rs b/src/test/ui/suggestions/confuse-field-and-method/private-field.rs
deleted file mode 100644 (file)
index 4cf939b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub mod animal {
-    pub struct Dog {
-        pub age: usize,
-        dog_age: usize,
-    }
-
-    impl Dog {
-        pub fn new(age: usize) -> Dog {
-            Dog { age: age, dog_age: age * 7 }
-        }
-    }
-}
-
-fn main() {
-    let dog = animal::Dog::new(3);
-    let dog_age = dog.dog_age(); //~ ERROR no method
-    //let dog_age = dog.dog_age;
-    println!("{}", dog_age);
-}
diff --git a/src/test/ui/suggestions/confuse-field-and-method/private-field.stderr b/src/test/ui/suggestions/confuse-field-and-method/private-field.stderr
deleted file mode 100644 (file)
index 145df8b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0599]: no method named `dog_age` found for type `animal::Dog` in the current scope
-  --> $DIR/private-field.rs:26:23
-   |
-LL |     pub struct Dog {
-   |     -------------- method `dog_age` not found for this
-...
-LL |     let dog_age = dog.dog_age(); //~ ERROR no method
-   |                       ^^^^^^^ private field, not a method
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/const-type-mismatch.rs b/src/test/ui/suggestions/const-type-mismatch.rs
deleted file mode 100644 (file)
index ddad4e7..0000000
+++ /dev/null
@@ -1,21 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// `const`s shouldn't suggest `.into()`
-
-const TEN: u8 = 10;
-const TWELVE: u16 = TEN + 2;
-//~^ ERROR mismatched types [E0308]
-
-fn main() {
-    const TEN: u8 = 10;
-    const ALSO_TEN: u16 = TEN;
-    //~^ ERROR mismatched types [E0308]
-}
diff --git a/src/test/ui/suggestions/const-type-mismatch.stderr b/src/test/ui/suggestions/const-type-mismatch.stderr
deleted file mode 100644 (file)
index 965995f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/const-type-mismatch.rs:14:21
-   |
-LL | const TWELVE: u16 = TEN + 2;
-   |                     ^^^^^^^ expected u16, found u8
-
-error[E0308]: mismatched types
-  --> $DIR/const-type-mismatch.rs:19:27
-   |
-LL |     const ALSO_TEN: u16 = TEN;
-   |                           ^^^ expected u16, found u8
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/conversion-methods.rs b/src/test/ui/suggestions/conversion-methods.rs
deleted file mode 100644 (file)
index 8a53bc3..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::path::{Path, PathBuf};
-
-
-fn main() {
-    let _tis_an_instants_play: String = "'Tis a fond Ambush—"; //~ ERROR mismatched types
-    let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise");
-    //~^ ERROR mismatched types
-
-    let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here
-    //~^ ERROR mismatched types
-
-    let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3]; //~ ERROR mismatched types
-}
diff --git a/src/test/ui/suggestions/conversion-methods.stderr b/src/test/ui/suggestions/conversion-methods.stderr
deleted file mode 100644 (file)
index 970ccad..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/conversion-methods.rs:15:41
-   |
-LL |     let _tis_an_instants_play: String = "'Tis a fond Ambush—"; //~ ERROR mismatched types
-   |                                         ^^^^^^^^^^^^^^^^^^^^^
-   |                                         |
-   |                                         expected struct `std::string::String`, found reference
-   |                                         help: try using a conversion method: `"'Tis a fond Ambush—".to_string()`
-   |
-   = note: expected type `std::string::String`
-              found type `&'static str`
-
-error[E0308]: mismatched types
-  --> $DIR/conversion-methods.rs:16:40
-   |
-LL |     let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise");
-   |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |                                        |
-   |                                        expected struct `std::path::PathBuf`, found reference
-   |                                        help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()`
-   |
-   = note: expected type `std::path::PathBuf`
-              found type `&std::path::Path`
-
-error[E0308]: mismatched types
-  --> $DIR/conversion-methods.rs:19:40
-   |
-LL |     let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here
-   |                                        ^
-   |                                        |
-   |                                        expected struct `std::string::String`, found integral variable
-   |                                        help: try using a conversion method: `2.to_string()`
-   |
-   = note: expected type `std::string::String`
-              found type `{integer}`
-
-error[E0308]: mismatched types
-  --> $DIR/conversion-methods.rs:22:47
-   |
-LL |     let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3]; //~ ERROR mismatched types
-   |                                               ^^^^^^^^^^
-   |                                               |
-   |                                               expected struct `std::vec::Vec`, found reference
-   |                                               help: try using a conversion method: `&[1, 2, 3].to_vec()`
-   |
-   = note: expected type `std::vec::Vec<usize>`
-              found type `&[{integer}; 3]`
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/dont-suggest-private-trait-method.rs b/src/test/ui/suggestions/dont-suggest-private-trait-method.rs
deleted file mode 100644 (file)
index 99bee0d..0000000
+++ /dev/null
@@ -1,16 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct T;
-
-fn main() {
-    T::new();
-    //~^ ERROR no function or associated item named `new` found for type `T` in the current scope
-}
diff --git a/src/test/ui/suggestions/dont-suggest-private-trait-method.stderr b/src/test/ui/suggestions/dont-suggest-private-trait-method.stderr
deleted file mode 100644 (file)
index 81ecc54..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0599]: no function or associated item named `new` found for type `T` in the current scope
-  --> $DIR/dont-suggest-private-trait-method.rs:14:5
-   |
-LL | struct T;
-   | --------- function or associated item `new` not found for this
-...
-LL |     T::new();
-   |     ^^^^^^ function or associated item not found in `T`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/dotdotdot-expr.rs b/src/test/ui/suggestions/dotdotdot-expr.rs
deleted file mode 100644 (file)
index afb73a5..0000000
+++ /dev/null
@@ -1,14 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
-    let _redemptive = 1...21;
-    //~^ ERROR unexpected token
-}
diff --git a/src/test/ui/suggestions/dotdotdot-expr.stderr b/src/test/ui/suggestions/dotdotdot-expr.stderr
deleted file mode 100644 (file)
index 3315538..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error: unexpected token: `...`
-  --> $DIR/dotdotdot-expr.rs:12:24
-   |
-LL |     let _redemptive = 1...21;
-   |                        ^^^
-help: use `..` for an exclusive range
-   |
-LL |     let _redemptive = 1..21;
-   |                        ^^
-help: or `..=` for an inclusive range
-   |
-LL |     let _redemptive = 1..=21;
-   |                        ^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/extern-crate-rename.rs b/src/test/ui/suggestions/extern-crate-rename.rs
deleted file mode 100644 (file)
index b58149f..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// aux-build:m1.rs
-// aux-build:m2.rs
-
-
-extern crate m1;
-extern crate m2 as m1; //~ ERROR is defined multiple times
-
-fn main() {}
diff --git a/src/test/ui/suggestions/extern-crate-rename.stderr b/src/test/ui/suggestions/extern-crate-rename.stderr
deleted file mode 100644 (file)
index 2c2723f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0259]: the name `m1` is defined multiple times
-  --> $DIR/extern-crate-rename.rs:16:1
-   |
-LL | extern crate m1;
-   | ---------------- previous import of the extern crate `m1` here
-LL | extern crate m2 as m1; //~ ERROR is defined multiple times
-   | ^^^^^^^^^^^^^^^^^^^^^^
-   | |
-   | `m1` reimported here
-   | You can use `as` to change the binding name of the import
-   |
-   = note: `m1` must be defined only once in the type namespace of this module
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0259`.
diff --git a/src/test/ui/suggestions/fn-closure-mutable-capture.nll.stderr b/src/test/ui/suggestions/fn-closure-mutable-capture.nll.stderr
deleted file mode 100644 (file)
index 7ef21d3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0594]: cannot assign to `x` which is behind a `&` reference
-  --> $DIR/fn-closure-mutable-capture.rs:15:17
-   |
-LL |     bar(move || x = 1);
-   |                 ^^^^^ cannot assign
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/fn-closure-mutable-capture.rs b/src/test/ui/suggestions/fn-closure-mutable-capture.rs
deleted file mode 100644 (file)
index 385efeb..0000000
+++ /dev/null
@@ -1,20 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub fn bar<F: Fn()>(_f: F) {}
-
-pub fn foo() {
-    let mut x = 0;
-    bar(move || x = 1);
-    //~^ ERROR cannot assign to captured outer variable in an `Fn` closure
-    //~| NOTE `Fn` closures cannot capture their enclosing environment for modifications
-}
-
-fn main() {}
diff --git a/src/test/ui/suggestions/fn-closure-mutable-capture.stderr b/src/test/ui/suggestions/fn-closure-mutable-capture.stderr
deleted file mode 100644 (file)
index a58d663..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0594]: cannot assign to captured outer variable in an `Fn` closure
-  --> $DIR/fn-closure-mutable-capture.rs:15:17
-   |
-LL |     bar(move || x = 1);
-   |                 ^^^^^
-   |
-   = note: `Fn` closures cannot capture their enclosing environment for modifications
-help: consider changing this closure to take self by mutable reference
-  --> $DIR/fn-closure-mutable-capture.rs:15:9
-   |
-LL |     bar(move || x = 1);
-   |         ^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/for-c-in-str.rs b/src/test/ui/suggestions/for-c-in-str.rs
deleted file mode 100644 (file)
index 011886e..0000000
+++ /dev/null
@@ -1,21 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// E0277 should point exclusively at line 14, not the entire for loop span
-
-fn main() {
-    for c in "asdf" {
-    //~^ ERROR the trait bound `&str: std::iter::Iterator` is not satisfied
-    //~| NOTE `&str` is not an iterator
-    //~| HELP the trait `std::iter::Iterator` is not implemented for `&str`
-    //~| NOTE required by `std::iter::IntoIterator::into_iter`
-        println!("");
-    }
-}
diff --git a/src/test/ui/suggestions/for-c-in-str.stderr b/src/test/ui/suggestions/for-c-in-str.stderr
deleted file mode 100644 (file)
index b249df3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied
-  --> $DIR/for-c-in-str.rs:14:14
-   |
-LL |     for c in "asdf" {
-   |              ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()`
-   |
-   = help: the trait `std::iter::Iterator` is not implemented for `&str`
-   = note: required by `std::iter::IntoIterator::into_iter`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/issue-32354-suggest-import-rename.fixed b/src/test/ui/suggestions/issue-32354-suggest-import-rename.fixed
deleted file mode 100644 (file)
index 251f7eb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-#![allow(unused_imports)]
-
-pub mod extension1 {
-    pub trait ConstructorExtension {}
-}
-
-pub mod extension2 {
-    pub trait ConstructorExtension {}
-}
-
-use extension1::ConstructorExtension;
-use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times
-
-fn main() {}
diff --git a/src/test/ui/suggestions/issue-32354-suggest-import-rename.rs b/src/test/ui/suggestions/issue-32354-suggest-import-rename.rs
deleted file mode 100644 (file)
index 57cbeb4..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-#![allow(unused_imports)]
-
-pub mod extension1 {
-    pub trait ConstructorExtension {}
-}
-
-pub mod extension2 {
-    pub trait ConstructorExtension {}
-}
-
-use extension1::ConstructorExtension;
-use extension2::ConstructorExtension; //~ ERROR is defined multiple times
-
-fn main() {}
diff --git a/src/test/ui/suggestions/issue-32354-suggest-import-rename.stderr b/src/test/ui/suggestions/issue-32354-suggest-import-rename.stderr
deleted file mode 100644 (file)
index f45a5f7..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0252]: the name `ConstructorExtension` is defined multiple times
-  --> $DIR/issue-32354-suggest-import-rename.rs:24:5
-   |
-LL | use extension1::ConstructorExtension;
-   |     -------------------------------- previous import of the trait `ConstructorExtension` here
-LL | use extension2::ConstructorExtension; //~ ERROR is defined multiple times
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here
-   |
-   = note: `ConstructorExtension` must be defined only once in the type namespace of this module
-help: You can use `as` to change the binding name of the import
-   |
-LL | use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0252`.
diff --git a/src/test/ui/suggestions/issue-43420-no-over-suggest.rs b/src/test/ui/suggestions/issue-43420-no-over-suggest.rs
deleted file mode 100644 (file)
index 8c5bde4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// check that we substitute type parameters before we suggest anything - otherwise
-// we would suggest function such as `as_slice` for the `&[u16]`.
-
-fn foo(b: &[u16]) {}
-
-fn main() {
-    let a: Vec<u8> = Vec::new();
-    foo(&a); //~ ERROR mismatched types
-}
diff --git a/src/test/ui/suggestions/issue-43420-no-over-suggest.stderr b/src/test/ui/suggestions/issue-43420-no-over-suggest.stderr
deleted file mode 100644 (file)
index 80bbdd1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/issue-43420-no-over-suggest.rs:18:9
-   |
-LL |     foo(&a); //~ ERROR mismatched types
-   |         ^^ expected slice, found struct `std::vec::Vec`
-   |
-   = note: expected type `&[u16]`
-              found type `&std::vec::Vec<u8>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/issue-45562.fixed b/src/test/ui/suggestions/issue-45562.fixed
deleted file mode 100644 (file)
index 7c01f0d..0000000
+++ /dev/null
@@ -1,16 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-#[no_mangle] pub static RAH: usize = 5;
-//~^ ERROR const items should never be #[no_mangle]
-
-fn main() {}
diff --git a/src/test/ui/suggestions/issue-45562.rs b/src/test/ui/suggestions/issue-45562.rs
deleted file mode 100644 (file)
index c27d52f..0000000
+++ /dev/null
@@ -1,16 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-#[no_mangle] pub const RAH: usize = 5;
-//~^ ERROR const items should never be #[no_mangle]
-
-fn main() {}
diff --git a/src/test/ui/suggestions/issue-45562.stderr b/src/test/ui/suggestions/issue-45562.stderr
deleted file mode 100644 (file)
index d9e624c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error: const items should never be #[no_mangle]
-  --> $DIR/issue-45562.rs:13:14
-   |
-LL | #[no_mangle] pub const RAH: usize = 5;
-   |              ---------^^^^^^^^^^^^^^^^
-   |              |
-   |              help: try a static value: `pub static`
-   |
-   = note: #[deny(no_mangle_const_items)] on by default
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed
deleted file mode 100644 (file)
index e328703..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-extern crate std as other_std;
-fn main() {}
-//~^^ ERROR the name `std` is defined multiple times [E0259]
diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs
deleted file mode 100644 (file)
index f47ea47..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-extern crate std;
-fn main() {}
-//~^^ ERROR the name `std` is defined multiple times [E0259]
diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr
deleted file mode 100644 (file)
index ecdfec2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0259]: the name `std` is defined multiple times
-  --> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:13:1
-   |
-LL | extern crate std;
-   | ^^^^^^^^^^^^^^^^^ `std` reimported here
-   |
-   = note: `std` must be defined only once in the type namespace of this module
-help: You can use `as` to change the binding name of the import
-   |
-LL | extern crate std as other_std;
-   |
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0259`.
diff --git a/src/test/ui/suggestions/issue-46302.rs b/src/test/ui/suggestions/issue-46302.rs
deleted file mode 100644 (file)
index 6ae6b54..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn foo() {
-  let s = "abc";
-  let u: &str = if true { s[..2] } else { s };
-  //~^ ERROR mismatched types
-}
-
-fn main() {
-    foo();
-}
diff --git a/src/test/ui/suggestions/issue-46302.stderr b/src/test/ui/suggestions/issue-46302.stderr
deleted file mode 100644 (file)
index 8e39913..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/issue-46302.rs:13:27
-   |
-LL |   let u: &str = if true { s[..2] } else { s };
-   |                           ^^^^^^
-   |                           |
-   |                           expected &str, found str
-   |                           help: consider borrowing here: `&s[..2]`
-   |
-   = note: expected type `&str`
-              found type `str`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed
deleted file mode 100644 (file)
index 77171ca..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-#![allow(unused)]
-
-fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
-    and_yet + 1
-}
-
-fn main() {
-    let behold: isize = 2;
-    let with_tears: usize = 3;
-    light_flows_our_war_of_mocking_words(&(behold as usize));
-    //~^ ERROR mismatched types [E0308]
-    light_flows_our_war_of_mocking_words(&(with_tears + 4));
-    //~^ ERROR mismatched types [E0308]
-}
diff --git a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs
deleted file mode 100644 (file)
index e5ea9b5..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-#![allow(unused)]
-
-fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
-    and_yet + 1
-}
-
-fn main() {
-    let behold: isize = 2;
-    let with_tears: usize = 3;
-    light_flows_our_war_of_mocking_words(behold as usize);
-    //~^ ERROR mismatched types [E0308]
-    light_flows_our_war_of_mocking_words(with_tears + 4);
-    //~^ ERROR mismatched types [E0308]
-}
diff --git a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr
deleted file mode 100644 (file)
index 9c49275..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42
-   |
-LL |     light_flows_our_war_of_mocking_words(behold as usize);
-   |                                          ^^^^^^^^^^^^^^^
-   |                                          |
-   |                                          expected &usize, found usize
-   |                                          help: consider borrowing here: `&(behold as usize)`
-   |
-   = note: expected type `&usize`
-              found type `usize`
-
-error[E0308]: mismatched types
-  --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:24:42
-   |
-LL |     light_flows_our_war_of_mocking_words(with_tears + 4);
-   |                                          ^^^^^^^^^^^^^^
-   |                                          |
-   |                                          expected &usize, found usize
-   |                                          help: consider borrowing here: `&(with_tears + 4)`
-   |
-   = note: expected type `&usize`
-              found type `usize`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/issue-48364.rs b/src/test/ui/suggestions/issue-48364.rs
deleted file mode 100644 (file)
index 82cb722..0000000
+++ /dev/null
@@ -1,16 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn foo() -> bool {
-    b"".starts_with(stringify!(foo))
-    //~^ ERROR mismatched types
-}
-
-fn main() {}
diff --git a/src/test/ui/suggestions/issue-48364.stderr b/src/test/ui/suggestions/issue-48364.stderr
deleted file mode 100644 (file)
index b420654..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/issue-48364.rs:12:21
-   |
-LL |     b"".starts_with(stringify!(foo))
-   |                     ^^^^^^^^^^^^^^^ expected slice, found str
-   |
-   = note: expected type `&[u8]`
-              found type `&'static str`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/issue-51244.nll.stderr b/src/test/ui/suggestions/issue-51244.nll.stderr
deleted file mode 100644 (file)
index ce02ae2..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference
-  --> $DIR/issue-51244.rs:13:5
-   |
-LL |     let ref my_ref @ _ = 0;
-   |         -------------- help: consider changing this to be a mutable reference: `ref mut my_ref @ _`
-LL |     *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594]
-   |     ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/issue-51244.rs b/src/test/ui/suggestions/issue-51244.rs
deleted file mode 100644 (file)
index 50a2118..0000000
+++ /dev/null
@@ -1,14 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
-    let ref my_ref @ _ = 0;
-    *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594]
-}
diff --git a/src/test/ui/suggestions/issue-51244.stderr b/src/test/ui/suggestions/issue-51244.stderr
deleted file mode 100644 (file)
index 997a742..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0594]: cannot assign to immutable borrowed content `*my_ref`
-  --> $DIR/issue-51244.rs:13:5
-   |
-LL |     let ref my_ref @ _ = 0;
-   |         -------------- help: use a mutable reference instead: `ref mut my_ref @ _`
-LL |     *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594]
-   |     ^^^^^^^^^^^ cannot borrow as mutable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/issue-51515.rs b/src/test/ui/suggestions/issue-51515.rs
deleted file mode 100644 (file)
index 3e0a3b7..0000000
+++ /dev/null
@@ -1,24 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(nll)]
-
-fn main() {
-    let foo = &16;
-    //~^ HELP consider changing this to be a mutable reference
-    //~| SUGGESTION &mut 16
-    *foo = 32;
-    //~^ ERROR cannot assign to `*foo` which is behind a `&` reference
-    let bar = foo;
-    //~^ HELP consider changing this to be a mutable reference
-    //~| SUGGESTION &mut i32
-    *bar = 64;
-    //~^ ERROR cannot assign to `*bar` which is behind a `&` reference
-}
diff --git a/src/test/ui/suggestions/issue-51515.stderr b/src/test/ui/suggestions/issue-51515.stderr
deleted file mode 100644 (file)
index 3e7349b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0594]: cannot assign to `*foo` which is behind a `&` reference
-  --> $DIR/issue-51515.rs:17:5
-   |
-LL |     let foo = &16;
-   |               --- help: consider changing this to be a mutable reference: `&mut 16`
-...
-LL |     *foo = 32;
-   |     ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
-
-error[E0594]: cannot assign to `*bar` which is behind a `&` reference
-  --> $DIR/issue-51515.rs:22:5
-   |
-LL |     let bar = foo;
-   |         --- help: consider changing this to be a mutable reference: `&mut i32`
-...
-LL |     *bar = 64;
-   |     ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/issue-52049.nll.stderr b/src/test/ui/suggestions/issue-52049.nll.stderr
deleted file mode 100644 (file)
index 6f71f16..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0597]: borrowed value does not live long enough
-  --> $DIR/issue-52049.rs:16:10
-   |
-LL |     foo(&unpromotable(5u32));
-   |          ^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
-LL | }
-   | - temporary value only lives until here
-   |
-   = note: borrowed value must be valid for the static lifetime...
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/suggestions/issue-52049.rs b/src/test/ui/suggestions/issue-52049.rs
deleted file mode 100644 (file)
index daff225..0000000
+++ /dev/null
@@ -1,18 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn foo(_: &'static u32) {}
-
-fn unpromotable<T>(t: T) -> T { t }
-
-fn main() {
-    foo(&unpromotable(5u32));
-}
-//~^^ ERROR borrowed value does not live long enough
diff --git a/src/test/ui/suggestions/issue-52049.stderr b/src/test/ui/suggestions/issue-52049.stderr
deleted file mode 100644 (file)
index e1e5010..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0597]: borrowed value does not live long enough
-  --> $DIR/issue-52049.rs:16:10
-   |
-LL |     foo(&unpromotable(5u32));
-   |          ^^^^^^^^^^^^^^^^^^ - temporary value only lives until here
-   |          |
-   |          temporary value does not live long enough
-   |
-   = note: borrowed value must be valid for the static lifetime...
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/suggestions/method-on-ambiguous-numeric-type.rs b/src/test/ui/suggestions/method-on-ambiguous-numeric-type.rs
deleted file mode 100644 (file)
index 2b6e830..0000000
+++ /dev/null
@@ -1,42 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// aux-build:macro-in-other-crate.rs
-
-#[macro_use] extern crate macro_in_other_crate;
-
-macro_rules! local_mac {
-    ($ident:ident) => { let $ident = 42; }
-}
-
-fn main() {
-    let x = 2.0.neg();
-    //~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
-
-    let y = 2.0;
-    let x = y.neg();
-    //~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
-    println!("{:?}", x);
-
-    for i in 0..100 {
-        println!("{}", i.pow(2));
-        //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
-    }
-
-    local_mac!(local_bar);
-    local_bar.pow(2);
-    //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
-}
-
-fn qux() {
-    mac!(bar);
-    bar.pow(2);
-    //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
-}
diff --git a/src/test/ui/suggestions/method-on-ambiguous-numeric-type.stderr b/src/test/ui/suggestions/method-on-ambiguous-numeric-type.stderr
deleted file mode 100644 (file)
index 796520e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
-  --> $DIR/method-on-ambiguous-numeric-type.rs:20:17
-   |
-LL |     let x = 2.0.neg();
-   |                 ^^^
-help: you must specify a concrete type for this numeric value, like `f32`
-   |
-LL |     let x = 2.0_f32.neg();
-   |             ^^^^^^^
-
-error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
-  --> $DIR/method-on-ambiguous-numeric-type.rs:24:15
-   |
-LL |     let x = y.neg();
-   |               ^^^
-help: you must specify a type for this binding, like `f32`
-   |
-LL |     let y: f32 = 2.0;
-   |         ^^^^^^
-
-error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
-  --> $DIR/method-on-ambiguous-numeric-type.rs:29:26
-   |
-LL |     for i in 0..100 {
-   |         - you must specify a type for this binding, like `i32`
-LL |         println!("{}", i.pow(2));
-   |                          ^^^
-
-error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
-  --> $DIR/method-on-ambiguous-numeric-type.rs:34:15
-   |
-LL |     local_bar.pow(2);
-   |               ^^^
-help: you must specify a type for this binding, like `i32`
-   |
-LL |     ($ident:ident) => { let $ident: i32 = 42; }
-   |                             ^^^^^^^^^^^
-
-error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
-  --> $DIR/method-on-ambiguous-numeric-type.rs:40:9
-   |
-LL |     mac!(bar);
-   |     ---------- you must specify a type for this binding, like `i32`
-LL |     bar.pow(2);
-   |         ^^^
-   |
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0689`.
diff --git a/src/test/ui/suggestions/missing-comma-in-match.fixed b/src/test/ui/suggestions/missing-comma-in-match.fixed
deleted file mode 100644 (file)
index 4832f35..0000000
+++ /dev/null
@@ -1,21 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-fn main() {
-    match &Some(3) {
-        &None => 1,
-        &Some(2) => { 3 }
-        //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
-        //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here
-        _ => 2
-    };
-}
diff --git a/src/test/ui/suggestions/missing-comma-in-match.rs b/src/test/ui/suggestions/missing-comma-in-match.rs
deleted file mode 100644 (file)
index e39b20e..0000000
+++ /dev/null
@@ -1,21 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-fn main() {
-    match &Some(3) {
-        &None => 1
-        &Some(2) => { 3 }
-        //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
-        //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here
-        _ => 2
-    };
-}
diff --git a/src/test/ui/suggestions/missing-comma-in-match.stderr b/src/test/ui/suggestions/missing-comma-in-match.stderr
deleted file mode 100644 (file)
index 7793593..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
-  --> $DIR/missing-comma-in-match.rs:16:18
-   |
-LL |         &None => 1
-   |                   - help: missing a comma here to end this `match` arm
-LL |         &Some(2) => { 3 }
-   |                  ^^ expected one of `,`, `.`, `?`, `}`, or an operator here
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/numeric-cast-2.rs b/src/test/ui/suggestions/numeric-cast-2.rs
deleted file mode 100644 (file)
index 2092b6b..0000000
+++ /dev/null
@@ -1,21 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn foo() -> i32 {
-    4
-}
-fn main() {
-    let x: u16 = foo();
-    //~^ ERROR mismatched types
-    let y: i64 = x + x;
-    //~^ ERROR mismatched types
-    let z: i32 = x + x;
-    //~^ ERROR mismatched types
-}
diff --git a/src/test/ui/suggestions/numeric-cast-2.stderr b/src/test/ui/suggestions/numeric-cast-2.stderr
deleted file mode 100644 (file)
index 3d48558..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast-2.rs:15:18
-   |
-LL |     let x: u16 = foo();
-   |                  ^^^^^ expected u16, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast-2.rs:17:18
-   |
-LL |     let y: i64 = x + x;
-   |                  ^^^^^ expected i64, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast-2.rs:19:18
-   |
-LL |     let z: i32 = x + x;
-   |                  ^^^^^ expected i32, found u16
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/numeric-cast.rs b/src/test/ui/suggestions/numeric-cast.rs
deleted file mode 100644 (file)
index 69bfdfa..0000000
+++ /dev/null
@@ -1,320 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-fn foo<N>(_x: N) {}
-
-fn main() {
-    let x_usize: usize = 1;
-    let x_u64: u64 = 2;
-    let x_u32: u32 = 3;
-    let x_u16: u16 = 4;
-    let x_u8: u8 = 5;
-    let x_isize: isize = 6;
-    let x_i64: i64 = 7;
-    let x_i32: i32 = 8;
-    let x_i16: i16 = 9;
-    let x_i8: i8 = 10;
-    let x_f64: f64 = 11.0;
-    let x_f32: f32 = 12.0;
-
-    foo::<usize>(x_usize);
-    foo::<usize>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<usize>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<isize>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_isize);
-    foo::<isize>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<isize>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<u64>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_u64);
-    foo::<u64>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u64>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<i64>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_i64);
-    foo::<i64>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i64>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<u32>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_u32);
-    foo::<u32>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u32>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<i32>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_i32);
-    foo::<i32>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i32>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<u16>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_u16);
-    foo::<u16>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u16>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<i16>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_i16);
-    foo::<i16>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i16>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<u8>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_u8);
-    foo::<u8>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<u8>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<i8>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_i8);
-    foo::<i8>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<i8>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<f64>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<f64>(x_f64);
-    foo::<f64>(x_f32);
-    //~^ ERROR mismatched types
-
-    foo::<f32>(x_usize);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_u64);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_u32);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_u16);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_u8);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_isize);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_i64);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_i32);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_i16);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_i8);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_f64);
-    //~^ ERROR mismatched types
-    foo::<f32>(x_f32);
-
-    foo::<u32>(x_u8 as u16);
-    //~^ ERROR mismatched types
-    foo::<i32>(-x_i8);
-    //~^ ERROR mismatched types
-}
diff --git a/src/test/ui/suggestions/numeric-cast.stderr b/src/test/ui/suggestions/numeric-cast.stderr
deleted file mode 100644 (file)
index 4aac65f..0000000
+++ /dev/null
@@ -1,907 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:29:18
-   |
-LL |     foo::<usize>(x_u64);
-   |                  ^^^^^ expected usize, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:31:18
-   |
-LL |     foo::<usize>(x_u32);
-   |                  ^^^^^ expected usize, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:33:18
-   |
-LL |     foo::<usize>(x_u16);
-   |                  ^^^^^ expected usize, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:35:18
-   |
-LL |     foo::<usize>(x_u8);
-   |                  ^^^^ expected usize, found u8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:37:18
-   |
-LL |     foo::<usize>(x_isize);
-   |                  ^^^^^^^ expected usize, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:39:18
-   |
-LL |     foo::<usize>(x_i64);
-   |                  ^^^^^ expected usize, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:41:18
-   |
-LL |     foo::<usize>(x_i32);
-   |                  ^^^^^ expected usize, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:43:18
-   |
-LL |     foo::<usize>(x_i16);
-   |                  ^^^^^ expected usize, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:45:18
-   |
-LL |     foo::<usize>(x_i8);
-   |                  ^^^^ expected usize, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:47:18
-   |
-LL |     foo::<usize>(x_f64);
-   |                  ^^^^^ expected usize, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:49:18
-   |
-LL |     foo::<usize>(x_f32);
-   |                  ^^^^^ expected usize, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:52:18
-   |
-LL |     foo::<isize>(x_usize);
-   |                  ^^^^^^^ expected isize, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:54:18
-   |
-LL |     foo::<isize>(x_u64);
-   |                  ^^^^^ expected isize, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:56:18
-   |
-LL |     foo::<isize>(x_u32);
-   |                  ^^^^^ expected isize, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:58:18
-   |
-LL |     foo::<isize>(x_u16);
-   |                  ^^^^^ expected isize, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:60:18
-   |
-LL |     foo::<isize>(x_u8);
-   |                  ^^^^ expected isize, found u8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:63:18
-   |
-LL |     foo::<isize>(x_i64);
-   |                  ^^^^^ expected isize, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:65:18
-   |
-LL |     foo::<isize>(x_i32);
-   |                  ^^^^^ expected isize, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:67:18
-   |
-LL |     foo::<isize>(x_i16);
-   |                  ^^^^^ expected isize, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:69:18
-   |
-LL |     foo::<isize>(x_i8);
-   |                  ^^^^ expected isize, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:71:18
-   |
-LL |     foo::<isize>(x_f64);
-   |                  ^^^^^ expected isize, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:73:18
-   |
-LL |     foo::<isize>(x_f32);
-   |                  ^^^^^ expected isize, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:76:16
-   |
-LL |     foo::<u64>(x_usize);
-   |                ^^^^^^^ expected u64, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:79:16
-   |
-LL |     foo::<u64>(x_u32);
-   |                ^^^^^ expected u64, found u32
-help: you can cast an `u32` to `u64`, which will zero-extend the source value
-   |
-LL |     foo::<u64>(x_u32.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:81:16
-   |
-LL |     foo::<u64>(x_u16);
-   |                ^^^^^ expected u64, found u16
-help: you can cast an `u16` to `u64`, which will zero-extend the source value
-   |
-LL |     foo::<u64>(x_u16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:83:16
-   |
-LL |     foo::<u64>(x_u8);
-   |                ^^^^ expected u64, found u8
-help: you can cast an `u8` to `u64`, which will zero-extend the source value
-   |
-LL |     foo::<u64>(x_u8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:85:16
-   |
-LL |     foo::<u64>(x_isize);
-   |                ^^^^^^^ expected u64, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:87:16
-   |
-LL |     foo::<u64>(x_i64);
-   |                ^^^^^ expected u64, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:89:16
-   |
-LL |     foo::<u64>(x_i32);
-   |                ^^^^^ expected u64, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:91:16
-   |
-LL |     foo::<u64>(x_i16);
-   |                ^^^^^ expected u64, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:93:16
-   |
-LL |     foo::<u64>(x_i8);
-   |                ^^^^ expected u64, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:95:16
-   |
-LL |     foo::<u64>(x_f64);
-   |                ^^^^^ expected u64, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:97:16
-   |
-LL |     foo::<u64>(x_f32);
-   |                ^^^^^ expected u64, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:100:16
-   |
-LL |     foo::<i64>(x_usize);
-   |                ^^^^^^^ expected i64, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:102:16
-   |
-LL |     foo::<i64>(x_u64);
-   |                ^^^^^ expected i64, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:104:16
-   |
-LL |     foo::<i64>(x_u32);
-   |                ^^^^^ expected i64, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:106:16
-   |
-LL |     foo::<i64>(x_u16);
-   |                ^^^^^ expected i64, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:108:16
-   |
-LL |     foo::<i64>(x_u8);
-   |                ^^^^ expected i64, found u8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:110:16
-   |
-LL |     foo::<i64>(x_isize);
-   |                ^^^^^^^ expected i64, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:113:16
-   |
-LL |     foo::<i64>(x_i32);
-   |                ^^^^^ expected i64, found i32
-help: you can cast an `i32` to `i64`, which will sign-extend the source value
-   |
-LL |     foo::<i64>(x_i32.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:115:16
-   |
-LL |     foo::<i64>(x_i16);
-   |                ^^^^^ expected i64, found i16
-help: you can cast an `i16` to `i64`, which will sign-extend the source value
-   |
-LL |     foo::<i64>(x_i16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:117:16
-   |
-LL |     foo::<i64>(x_i8);
-   |                ^^^^ expected i64, found i8
-help: you can cast an `i8` to `i64`, which will sign-extend the source value
-   |
-LL |     foo::<i64>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:119:16
-   |
-LL |     foo::<i64>(x_f64);
-   |                ^^^^^ expected i64, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:121:16
-   |
-LL |     foo::<i64>(x_f32);
-   |                ^^^^^ expected i64, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:124:16
-   |
-LL |     foo::<u32>(x_usize);
-   |                ^^^^^^^ expected u32, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:126:16
-   |
-LL |     foo::<u32>(x_u64);
-   |                ^^^^^ expected u32, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:129:16
-   |
-LL |     foo::<u32>(x_u16);
-   |                ^^^^^ expected u32, found u16
-help: you can cast an `u16` to `u32`, which will zero-extend the source value
-   |
-LL |     foo::<u32>(x_u16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:131:16
-   |
-LL |     foo::<u32>(x_u8);
-   |                ^^^^ expected u32, found u8
-help: you can cast an `u8` to `u32`, which will zero-extend the source value
-   |
-LL |     foo::<u32>(x_u8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:133:16
-   |
-LL |     foo::<u32>(x_isize);
-   |                ^^^^^^^ expected u32, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:135:16
-   |
-LL |     foo::<u32>(x_i64);
-   |                ^^^^^ expected u32, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:137:16
-   |
-LL |     foo::<u32>(x_i32);
-   |                ^^^^^ expected u32, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:139:16
-   |
-LL |     foo::<u32>(x_i16);
-   |                ^^^^^ expected u32, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:141:16
-   |
-LL |     foo::<u32>(x_i8);
-   |                ^^^^ expected u32, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:143:16
-   |
-LL |     foo::<u32>(x_f64);
-   |                ^^^^^ expected u32, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:145:16
-   |
-LL |     foo::<u32>(x_f32);
-   |                ^^^^^ expected u32, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:148:16
-   |
-LL |     foo::<i32>(x_usize);
-   |                ^^^^^^^ expected i32, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:150:16
-   |
-LL |     foo::<i32>(x_u64);
-   |                ^^^^^ expected i32, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:152:16
-   |
-LL |     foo::<i32>(x_u32);
-   |                ^^^^^ expected i32, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:154:16
-   |
-LL |     foo::<i32>(x_u16);
-   |                ^^^^^ expected i32, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:156:16
-   |
-LL |     foo::<i32>(x_u8);
-   |                ^^^^ expected i32, found u8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:158:16
-   |
-LL |     foo::<i32>(x_isize);
-   |                ^^^^^^^ expected i32, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:160:16
-   |
-LL |     foo::<i32>(x_i64);
-   |                ^^^^^ expected i32, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:163:16
-   |
-LL |     foo::<i32>(x_i16);
-   |                ^^^^^ expected i32, found i16
-help: you can cast an `i16` to `i32`, which will sign-extend the source value
-   |
-LL |     foo::<i32>(x_i16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:165:16
-   |
-LL |     foo::<i32>(x_i8);
-   |                ^^^^ expected i32, found i8
-help: you can cast an `i8` to `i32`, which will sign-extend the source value
-   |
-LL |     foo::<i32>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:167:16
-   |
-LL |     foo::<i32>(x_f64);
-   |                ^^^^^ expected i32, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:169:16
-   |
-LL |     foo::<i32>(x_f32);
-   |                ^^^^^ expected i32, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:172:16
-   |
-LL |     foo::<u16>(x_usize);
-   |                ^^^^^^^ expected u16, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:174:16
-   |
-LL |     foo::<u16>(x_u64);
-   |                ^^^^^ expected u16, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:176:16
-   |
-LL |     foo::<u16>(x_u32);
-   |                ^^^^^ expected u16, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:179:16
-   |
-LL |     foo::<u16>(x_u8);
-   |                ^^^^ expected u16, found u8
-help: you can cast an `u8` to `u16`, which will zero-extend the source value
-   |
-LL |     foo::<u16>(x_u8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:181:16
-   |
-LL |     foo::<u16>(x_isize);
-   |                ^^^^^^^ expected u16, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:183:16
-   |
-LL |     foo::<u16>(x_i64);
-   |                ^^^^^ expected u16, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:185:16
-   |
-LL |     foo::<u16>(x_i32);
-   |                ^^^^^ expected u16, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:187:16
-   |
-LL |     foo::<u16>(x_i16);
-   |                ^^^^^ expected u16, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:189:16
-   |
-LL |     foo::<u16>(x_i8);
-   |                ^^^^ expected u16, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:191:16
-   |
-LL |     foo::<u16>(x_f64);
-   |                ^^^^^ expected u16, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:193:16
-   |
-LL |     foo::<u16>(x_f32);
-   |                ^^^^^ expected u16, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:196:16
-   |
-LL |     foo::<i16>(x_usize);
-   |                ^^^^^^^ expected i16, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:198:16
-   |
-LL |     foo::<i16>(x_u64);
-   |                ^^^^^ expected i16, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:200:16
-   |
-LL |     foo::<i16>(x_u32);
-   |                ^^^^^ expected i16, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:202:16
-   |
-LL |     foo::<i16>(x_u16);
-   |                ^^^^^ expected i16, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:204:16
-   |
-LL |     foo::<i16>(x_u8);
-   |                ^^^^ expected i16, found u8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:206:16
-   |
-LL |     foo::<i16>(x_isize);
-   |                ^^^^^^^ expected i16, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:208:16
-   |
-LL |     foo::<i16>(x_i64);
-   |                ^^^^^ expected i16, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:210:16
-   |
-LL |     foo::<i16>(x_i32);
-   |                ^^^^^ expected i16, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:213:16
-   |
-LL |     foo::<i16>(x_i8);
-   |                ^^^^ expected i16, found i8
-help: you can cast an `i8` to `i16`, which will sign-extend the source value
-   |
-LL |     foo::<i16>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:215:16
-   |
-LL |     foo::<i16>(x_f64);
-   |                ^^^^^ expected i16, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:217:16
-   |
-LL |     foo::<i16>(x_f32);
-   |                ^^^^^ expected i16, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:220:15
-   |
-LL |     foo::<u8>(x_usize);
-   |               ^^^^^^^ expected u8, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:222:15
-   |
-LL |     foo::<u8>(x_u64);
-   |               ^^^^^ expected u8, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:224:15
-   |
-LL |     foo::<u8>(x_u32);
-   |               ^^^^^ expected u8, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:226:15
-   |
-LL |     foo::<u8>(x_u16);
-   |               ^^^^^ expected u8, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:229:15
-   |
-LL |     foo::<u8>(x_isize);
-   |               ^^^^^^^ expected u8, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:231:15
-   |
-LL |     foo::<u8>(x_i64);
-   |               ^^^^^ expected u8, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:233:15
-   |
-LL |     foo::<u8>(x_i32);
-   |               ^^^^^ expected u8, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:235:15
-   |
-LL |     foo::<u8>(x_i16);
-   |               ^^^^^ expected u8, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:237:15
-   |
-LL |     foo::<u8>(x_i8);
-   |               ^^^^ expected u8, found i8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:239:15
-   |
-LL |     foo::<u8>(x_f64);
-   |               ^^^^^ expected u8, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:241:15
-   |
-LL |     foo::<u8>(x_f32);
-   |               ^^^^^ expected u8, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:244:15
-   |
-LL |     foo::<i8>(x_usize);
-   |               ^^^^^^^ expected i8, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:246:15
-   |
-LL |     foo::<i8>(x_u64);
-   |               ^^^^^ expected i8, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:248:15
-   |
-LL |     foo::<i8>(x_u32);
-   |               ^^^^^ expected i8, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:250:15
-   |
-LL |     foo::<i8>(x_u16);
-   |               ^^^^^ expected i8, found u16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:252:15
-   |
-LL |     foo::<i8>(x_u8);
-   |               ^^^^ expected i8, found u8
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:254:15
-   |
-LL |     foo::<i8>(x_isize);
-   |               ^^^^^^^ expected i8, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:256:15
-   |
-LL |     foo::<i8>(x_i64);
-   |               ^^^^^ expected i8, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:258:15
-   |
-LL |     foo::<i8>(x_i32);
-   |               ^^^^^ expected i8, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:260:15
-   |
-LL |     foo::<i8>(x_i16);
-   |               ^^^^^ expected i8, found i16
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:263:15
-   |
-LL |     foo::<i8>(x_f64);
-   |               ^^^^^ expected i8, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:265:15
-   |
-LL |     foo::<i8>(x_f32);
-   |               ^^^^^ expected i8, found f32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:268:16
-   |
-LL |     foo::<f64>(x_usize);
-   |                ^^^^^^^ expected f64, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:270:16
-   |
-LL |     foo::<f64>(x_u64);
-   |                ^^^^^ expected f64, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:272:16
-   |
-LL |     foo::<f64>(x_u32);
-   |                ^^^^^ expected f64, found u32
-help: you can cast an `u32` to `f64`, producing the floating point representation of the integer
-   |
-LL |     foo::<f64>(x_u32.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:274:16
-   |
-LL |     foo::<f64>(x_u16);
-   |                ^^^^^ expected f64, found u16
-help: you can cast an `u16` to `f64`, producing the floating point representation of the integer
-   |
-LL |     foo::<f64>(x_u16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:276:16
-   |
-LL |     foo::<f64>(x_u8);
-   |                ^^^^ expected f64, found u8
-help: you can cast an `u8` to `f64`, producing the floating point representation of the integer
-   |
-LL |     foo::<f64>(x_u8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:278:16
-   |
-LL |     foo::<f64>(x_isize);
-   |                ^^^^^^^ expected f64, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:280:16
-   |
-LL |     foo::<f64>(x_i64);
-   |                ^^^^^ expected f64, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:282:16
-   |
-LL |     foo::<f64>(x_i32);
-   |                ^^^^^ expected f64, found i32
-help: you can cast an `i32` to `f64`, producing the floating point representation of the integer
-   |
-LL |     foo::<f64>(x_i32.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:284:16
-   |
-LL |     foo::<f64>(x_i16);
-   |                ^^^^^ expected f64, found i16
-help: you can cast an `i16` to `f64`, producing the floating point representation of the integer
-   |
-LL |     foo::<f64>(x_i16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:286:16
-   |
-LL |     foo::<f64>(x_i8);
-   |                ^^^^ expected f64, found i8
-help: you can cast an `i8` to `f64`, producing the floating point representation of the integer
-   |
-LL |     foo::<f64>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:289:16
-   |
-LL |     foo::<f64>(x_f32);
-   |                ^^^^^ expected f64, found f32
-help: you can cast an `f32` to `f64` in a lossless way
-   |
-LL |     foo::<f64>(x_f32.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:292:16
-   |
-LL |     foo::<f32>(x_usize);
-   |                ^^^^^^^ expected f32, found usize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:294:16
-   |
-LL |     foo::<f32>(x_u64);
-   |                ^^^^^ expected f32, found u64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:296:16
-   |
-LL |     foo::<f32>(x_u32);
-   |                ^^^^^ expected f32, found u32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:298:16
-   |
-LL |     foo::<f32>(x_u16);
-   |                ^^^^^ expected f32, found u16
-help: you can cast an `u16` to `f32`, producing the floating point representation of the integer
-   |
-LL |     foo::<f32>(x_u16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:300:16
-   |
-LL |     foo::<f32>(x_u8);
-   |                ^^^^ expected f32, found u8
-help: you can cast an `u8` to `f32`, producing the floating point representation of the integer
-   |
-LL |     foo::<f32>(x_u8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:302:16
-   |
-LL |     foo::<f32>(x_isize);
-   |                ^^^^^^^ expected f32, found isize
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:304:16
-   |
-LL |     foo::<f32>(x_i64);
-   |                ^^^^^ expected f32, found i64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:306:16
-   |
-LL |     foo::<f32>(x_i32);
-   |                ^^^^^ expected f32, found i32
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:308:16
-   |
-LL |     foo::<f32>(x_i16);
-   |                ^^^^^ expected f32, found i16
-help: you can cast an `i16` to `f32`, producing the floating point representation of the integer
-   |
-LL |     foo::<f32>(x_i16.into());
-   |                ^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:310:16
-   |
-LL |     foo::<f32>(x_i8);
-   |                ^^^^ expected f32, found i8
-help: you can cast an `i8` to `f32`, producing the floating point representation of the integer
-   |
-LL |     foo::<f32>(x_i8.into());
-   |                ^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:312:16
-   |
-LL |     foo::<f32>(x_f64);
-   |                ^^^^^ expected f32, found f64
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:316:16
-   |
-LL |     foo::<u32>(x_u8 as u16);
-   |                ^^^^^^^^^^^ expected u32, found u16
-help: you can cast an `u16` to `u32`, which will zero-extend the source value
-   |
-LL |     foo::<u32>((x_u8 as u16).into());
-   |                ^^^^^^^^^^^^^^^^^^^^
-
-error[E0308]: mismatched types
-  --> $DIR/numeric-cast.rs:318:16
-   |
-LL |     foo::<i32>(-x_i8);
-   |                ^^^^^ expected i32, found i8
-help: you can cast an `i8` to `i32`, which will sign-extend the source value
-   |
-LL |     foo::<i32>((-x_i8).into());
-   |                ^^^^^^^^^^^^^^
-
-error: aborting due to 134 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/placement-syntax.rs b/src/test/ui/suggestions/placement-syntax.rs
deleted file mode 100644 (file)
index 3925259..0000000
+++ /dev/null
@@ -1,17 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
-    let x = -5;
-    if x<-1 {
-    //~^ ERROR emplacement syntax is obsolete
-        println!("ok");
-    }
-}
diff --git a/src/test/ui/suggestions/placement-syntax.stderr b/src/test/ui/suggestions/placement-syntax.stderr
deleted file mode 100644 (file)
index 933ba96..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error: emplacement syntax is obsolete (for now, anyway)
-  --> $DIR/placement-syntax.rs:13:8
-   |
-LL |     if x<-1 {
-   |        ^^^^
-   |
-   = note: for more information, see <https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>
-help: if you meant to write a comparison against a negative value, add a space in between `<` and `-`
-   |
-LL |     if x< -1 {
-   |         ^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/pub-ident-fn-2.rs b/src/test/ui/suggestions/pub-ident-fn-2.rs
deleted file mode 100644 (file)
index 44884bf..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub foo(s: usize) { bar() }
-//~^ ERROR missing `fn` for method definition
-
-fn main() {
-    foo(2);
-}
diff --git a/src/test/ui/suggestions/pub-ident-fn-2.stderr b/src/test/ui/suggestions/pub-ident-fn-2.stderr
deleted file mode 100644 (file)
index bbbb3df..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error: missing `fn` for method definition
-  --> $DIR/pub-ident-fn-2.rs:11:4
-   |
-LL | pub foo(s: usize) { bar() }
-   |    ^
-help: add `fn` here to parse `foo` as a public method
-   |
-LL | pub fn foo(s: usize) { bar() }
-   |     ^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.rs
deleted file mode 100644 (file)
index 1ccadc8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub S();
-//~^ ERROR missing `fn` or `struct` for method or struct definition
-
-fn main() {}
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr b/src/test/ui/suggestions/pub-ident-fn-or-struct-2.stderr
deleted file mode 100644 (file)
index e492a8c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-error: missing `fn` or `struct` for method or struct definition
-  --> $DIR/pub-ident-fn-or-struct-2.rs:11:4
-   |
-LL | pub S();
-   | ---^- help: if you meant to call a macro, try: `S!`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct.rs b/src/test/ui/suggestions/pub-ident-fn-or-struct.rs
deleted file mode 100644 (file)
index 0664918..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub S (foo) bar
-//~^ ERROR missing `fn` or `struct` for method or struct definition
-
-fn main() {}
diff --git a/src/test/ui/suggestions/pub-ident-fn-or-struct.stderr b/src/test/ui/suggestions/pub-ident-fn-or-struct.stderr
deleted file mode 100644 (file)
index c1bff34..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-error: missing `fn` or `struct` for method or struct definition
-  --> $DIR/pub-ident-fn-or-struct.rs:11:4
-   |
-LL | pub S (foo) bar
-   | ---^- help: if you meant to call a macro, try: `S!`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/pub-ident-fn.fixed b/src/test/ui/suggestions/pub-ident-fn.fixed
deleted file mode 100644 (file)
index f2d0c6c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-pub fn foo(_s: usize) -> bool { true }
-//~^ ERROR missing `fn` for method definition
-
-fn main() {
-    foo(2);
-}
diff --git a/src/test/ui/suggestions/pub-ident-fn.rs b/src/test/ui/suggestions/pub-ident-fn.rs
deleted file mode 100644 (file)
index 82c32f5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-pub   foo(_s: usize) -> bool { true }
-//~^ ERROR missing `fn` for method definition
-
-fn main() {
-    foo(2);
-}
diff --git a/src/test/ui/suggestions/pub-ident-fn.stderr b/src/test/ui/suggestions/pub-ident-fn.stderr
deleted file mode 100644 (file)
index f7c96b8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error: missing `fn` for method definition
-  --> $DIR/pub-ident-fn.rs:13:4
-   |
-LL | pub   foo(_s: usize) -> bool { true }
-   |    ^^^
-help: add `fn` here to parse `foo` as a public method
-   |
-LL | pub fn foo(_s: usize) -> bool { true }
-   |     ^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/pub-ident-struct.rs b/src/test/ui/suggestions/pub-ident-struct.rs
deleted file mode 100644 (file)
index d08d498..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub S {
-//~^ ERROR missing `struct` for struct definition
-}
-fn main() {}
diff --git a/src/test/ui/suggestions/pub-ident-struct.stderr b/src/test/ui/suggestions/pub-ident-struct.stderr
deleted file mode 100644 (file)
index cd53cea..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error: missing `struct` for struct definition
-  --> $DIR/pub-ident-struct.rs:11:4
-   |
-LL | pub S {
-   |    ^
-help: add `struct` here to parse `S` as a public struct
-   |
-LL | pub struct S {
-   |     ^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/removing-extern-crate.fixed b/src/test/ui/suggestions/removing-extern-crate.fixed
deleted file mode 100644 (file)
index 83b35ce..0000000
+++ /dev/null
@@ -1,27 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags: --edition 2018
-// aux-build:removing-extern-crate.rs
-// run-rustfix
-// compile-pass
-
-#![warn(rust_2018_idioms)]
-#![allow(unused_imports)]
-
-
-
-
-mod another {
-    
-    
-}
-
-fn main() {}
diff --git a/src/test/ui/suggestions/removing-extern-crate.rs b/src/test/ui/suggestions/removing-extern-crate.rs
deleted file mode 100644 (file)
index 2947908..0000000
+++ /dev/null
@@ -1,27 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags: --edition 2018
-// aux-build:removing-extern-crate.rs
-// run-rustfix
-// compile-pass
-
-#![warn(rust_2018_idioms)]
-#![allow(unused_imports)]
-
-extern crate std as foo;
-extern crate core;
-
-mod another {
-    extern crate std as foo;
-    extern crate std;
-}
-
-fn main() {}
diff --git a/src/test/ui/suggestions/removing-extern-crate.stderr b/src/test/ui/suggestions/removing-extern-crate.stderr
deleted file mode 100644 (file)
index f2eed27..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-warning: unused extern crate
-  --> $DIR/removing-extern-crate.rs:19:1
-   |
-LL | extern crate std as foo;
-   | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
-   |
-note: lint level defined here
-  --> $DIR/removing-extern-crate.rs:16:9
-   |
-LL | #![warn(rust_2018_idioms)]
-   |         ^^^^^^^^^^^^^^^^
-   = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]
-
-warning: unused extern crate
-  --> $DIR/removing-extern-crate.rs:20:1
-   |
-LL | extern crate core;
-   | ^^^^^^^^^^^^^^^^^^ help: remove it
-
-warning: unused extern crate
-  --> $DIR/removing-extern-crate.rs:23:5
-   |
-LL |     extern crate std as foo;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
-
-warning: unused extern crate
-  --> $DIR/removing-extern-crate.rs:24:5
-   |
-LL |     extern crate std;
-   |     ^^^^^^^^^^^^^^^^^ help: remove it
-
diff --git a/src/test/ui/suggestions/repr.rs b/src/test/ui/suggestions/repr.rs
deleted file mode 100644 (file)
index 312f602..0000000
+++ /dev/null
@@ -1,28 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-pass
-
-#[repr]
-//^ WARN `repr` attribute must have a hint
-struct _A {}
-
-#[repr = "B"]
-//^ WARN `repr` attribute isn't configurable with a literal
-struct _B {}
-
-#[repr = "C"]
-//^ WARN `repr` attribute isn't configurable with a literal
-struct _C {}
-
-#[repr(C)]
-struct _D {}
-
-fn main() {}
diff --git a/src/test/ui/suggestions/repr.stderr b/src/test/ui/suggestions/repr.stderr
deleted file mode 100644 (file)
index 7a99d8c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-warning: `repr` attribute must have a hint
-  --> $DIR/repr.rs:13:1
-   |
-LL | #[repr]
-   | ^^^^^^^ needs a hint
-   |
-   = note: #[warn(bad_repr)] on by default
-   = help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
-   = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
-
-warning: `repr` attribute isn't configurable with a literal
-  --> $DIR/repr.rs:17:1
-   |
-LL | #[repr = "B"]
-   | ^^^^^^^^^^^^^ needs a hint
-   |
-   = help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]`
-   = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html>
-
-warning: `repr` attribute isn't configurable with a literal
-  --> $DIR/repr.rs:21:1
-   |
-LL | #[repr = "C"]
-   | ^^^^^^^^^^^^^ help: give `repr` a hint: `#[repr(C)]`
-
diff --git a/src/test/ui/suggestions/return-type.rs b/src/test/ui/suggestions/return-type.rs
deleted file mode 100644 (file)
index e637879..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct S<T> {
-    t: T,
-}
-
-fn foo<T>(x: T) -> S<T> {
-    S { t: x }
-}
-
-fn bar() {
-    foo(4 as usize)
-    //~^ ERROR mismatched types
-}
-
-fn main() {}
diff --git a/src/test/ui/suggestions/return-type.stderr b/src/test/ui/suggestions/return-type.stderr
deleted file mode 100644 (file)
index 7d7653e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/return-type.rs:20:5
-   |
-LL |     foo(4 as usize)
-   |     ^^^^^^^^^^^^^^^ expected (), found struct `S`
-   |
-   = note: expected type `()`
-              found type `S<usize>`
-help: try adding a semicolon
-   |
-LL |     foo(4 as usize);
-   |                    ^
-help: try adding a return type
-   |
-LL | fn bar() -> S<usize> {
-   |          ^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/str-array-assignment.rs b/src/test/ui/suggestions/str-array-assignment.rs
deleted file mode 100644 (file)
index 9d6cf5f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
-  let s = "abc";
-  let t = if true { s[..2] } else { s };
-  //~^ ERROR if and else have incompatible types
-  let u: &str = if true { s[..2] } else { s };
-  //~^ ERROR mismatched types
-  let v = s[..2];
-  //~^ ERROR the size for values of type
-  let w: &str = s[..2];
-  //~^ ERROR mismatched types
-}
diff --git a/src/test/ui/suggestions/str-array-assignment.stderr b/src/test/ui/suggestions/str-array-assignment.stderr
deleted file mode 100644 (file)
index 7a774ca..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-error[E0308]: if and else have incompatible types
-  --> $DIR/str-array-assignment.rs:13:11
-   |
-LL |   let t = if true { s[..2] } else { s };
-   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found &str
-   |
-   = note: expected type `str`
-              found type `&str`
-
-error[E0308]: mismatched types
-  --> $DIR/str-array-assignment.rs:15:27
-   |
-LL |   let u: &str = if true { s[..2] } else { s };
-   |                           ^^^^^^
-   |                           |
-   |                           expected &str, found str
-   |                           help: consider borrowing here: `&s[..2]`
-   |
-   = note: expected type `&str`
-              found type `str`
-
-error[E0277]: the size for values of type `str` cannot be known at compilation time
-  --> $DIR/str-array-assignment.rs:17:7
-   |
-LL |   let v = s[..2];
-   |       ^   ------ help: consider borrowing here: `&s[..2]`
-   |       |
-   |       doesn't have a size known at compile-time
-   |
-   = help: the trait `std::marker::Sized` is not implemented for `str`
-   = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized>
-   = note: all local variables must have a statically known size
-
-error[E0308]: mismatched types
-  --> $DIR/str-array-assignment.rs:19:17
-   |
-LL |   let w: &str = s[..2];
-   |                 ^^^^^^
-   |                 |
-   |                 expected &str, found str
-   |                 help: consider borrowing here: `&s[..2]`
-   |
-   = note: expected type `&str`
-              found type `str`
-
-error: aborting due to 4 previous errors
-
-Some errors occurred: E0277, E0308.
-For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/str-as-char.fixed b/src/test/ui/suggestions/str-as-char.fixed
deleted file mode 100644 (file)
index c0dad38..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-fn main() {
-    println!("●●");
-    //~^ ERROR character literal may only contain one codepoint
-}
diff --git a/src/test/ui/suggestions/str-as-char.rs b/src/test/ui/suggestions/str-as-char.rs
deleted file mode 100644 (file)
index b5a5df0..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-
-fn main() {
-    println!('●●');
-    //~^ ERROR character literal may only contain one codepoint
-}
diff --git a/src/test/ui/suggestions/str-as-char.stderr b/src/test/ui/suggestions/str-as-char.stderr
deleted file mode 100644 (file)
index 60eb182..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error: character literal may only contain one codepoint
-  --> $DIR/str-as-char.rs:14:14
-   |
-LL |     println!('●●');
-   |              ^^^^
-help: if you meant to write a `str` literal, use double quotes
-   |
-LL |     println!("●●");
-   |              ^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/suggest-labels.rs b/src/test/ui/suggestions/suggest-labels.rs
deleted file mode 100644 (file)
index 9fb519c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[allow(unreachable_code, unused_labels)]
-fn main() {
-    'foo: loop {
-        break 'fo; //~ ERROR use of undeclared label
-    }
-
-    'bar: loop {
-        continue 'bor; //~ ERROR use of undeclared label
-    }
-
-    'longlabel: loop {
-        'longlabel1: loop {
-            break 'longlable; //~ ERROR use of undeclared label
-        }
-    }
-}
diff --git a/src/test/ui/suggestions/suggest-labels.stderr b/src/test/ui/suggestions/suggest-labels.stderr
deleted file mode 100644 (file)
index 671ff1a..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0426]: use of undeclared label `'fo`
-  --> $DIR/suggest-labels.rs:14:15
-   |
-LL |         break 'fo; //~ ERROR use of undeclared label
-   |               ^^^ did you mean `'foo`?
-
-error[E0426]: use of undeclared label `'bor`
-  --> $DIR/suggest-labels.rs:18:18
-   |
-LL |         continue 'bor; //~ ERROR use of undeclared label
-   |                  ^^^^ did you mean `'bar`?
-
-error[E0426]: use of undeclared label `'longlable`
-  --> $DIR/suggest-labels.rs:23:19
-   |
-LL |             break 'longlable; //~ ERROR use of undeclared label
-   |                   ^^^^^^^^^^ did you mean `'longlabel1`?
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0426`.
diff --git a/src/test/ui/suggestions/suggest-methods.rs b/src/test/ui/suggestions/suggest-methods.rs
deleted file mode 100644 (file)
index 49027de..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct Foo;
-
-impl Foo {
-    fn bar(self) {}
-    fn baz(&self, x: f64) {}
-}
-
-trait FooT {
-    fn bag(&self);
-}
-
-impl FooT for Foo {
-    fn bag(&self) {}
-}
-
-fn main() {
-    let f = Foo;
-    f.bat(1.0); //~ ERROR no method named
-
-    let s = "foo".to_string();
-    let _ = s.is_emtpy(); //~ ERROR no method named
-
-    // Generates a warning for `count_zeros()`. `count_ones()` is also a close
-    // match, but the former is closer.
-    let _ = 63u32.count_eos(); //~ ERROR no method named
-
-    // Does not generate a warning
-    let _ = 63u32.count_o(); //~ ERROR no method named
-
-}
diff --git a/src/test/ui/suggestions/suggest-methods.stderr b/src/test/ui/suggestions/suggest-methods.stderr
deleted file mode 100644 (file)
index cb35236..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-error[E0599]: no method named `bat` found for type `Foo` in the current scope
-  --> $DIR/suggest-methods.rs:28:7
-   |
-LL | struct Foo;
-   | ----------- method `bat` not found for this
-...
-LL |     f.bat(1.0); //~ ERROR no method named
-   |       ^^^
-   |
-   = help: did you mean `bar`?
-
-error[E0599]: no method named `is_emtpy` found for type `std::string::String` in the current scope
-  --> $DIR/suggest-methods.rs:31:15
-   |
-LL |     let _ = s.is_emtpy(); //~ ERROR no method named
-   |               ^^^^^^^^
-   |
-   = help: did you mean `is_empty`?
-
-error[E0599]: no method named `count_eos` found for type `u32` in the current scope
-  --> $DIR/suggest-methods.rs:35:19
-   |
-LL |     let _ = 63u32.count_eos(); //~ ERROR no method named
-   |                   ^^^^^^^^^
-   |
-   = help: did you mean `count_zeros`?
-
-error[E0599]: no method named `count_o` found for type `u32` in the current scope
-  --> $DIR/suggest-methods.rs:38:19
-   |
-LL |     let _ = 63u32.count_o(); //~ ERROR no method named
-   |                   ^^^^^^^
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/suggestions/suggest-ref-mut.rs b/src/test/ui/suggestions/suggest-ref-mut.rs
deleted file mode 100644 (file)
index 30b5371..0000000
+++ /dev/null
@@ -1,42 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(nll)]
-
-struct X(usize);
-
-impl X {
-    fn zap(&self) {
-        //~^ HELP
-        //~| SUGGESTION &mut self
-        self.0 = 32;
-        //~^ ERROR
-    }
-}
-
-fn main() {
-    let ref foo = 16;
-    //~^ HELP
-    //~| SUGGESTION ref mut foo
-    *foo = 32;
-    //~^ ERROR
-    if let Some(ref bar) = Some(16) {
-        //~^ HELP
-        //~| SUGGESTION ref mut bar
-        *bar = 32;
-        //~^ ERROR
-    }
-    match 16 {
-        ref quo => { *quo = 32; },
-        //~^ ERROR
-        //~| HELP
-        //~| SUGGESTION ref mut quo
-    }
-}
diff --git a/src/test/ui/suggestions/suggest-ref-mut.stderr b/src/test/ui/suggestions/suggest-ref-mut.stderr
deleted file mode 100644 (file)
index 0b2b240..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-error[E0594]: cannot assign to `self.0` which is behind a `&` reference
-  --> $DIR/suggest-ref-mut.rs:19:9
-   |
-LL |     fn zap(&self) {
-   |            ----- help: consider changing this to be a mutable reference: `&mut self`
-...
-LL |         self.0 = 32;
-   |         ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
-
-error[E0594]: cannot assign to `*foo` which is behind a `&` reference
-  --> $DIR/suggest-ref-mut.rs:28:5
-   |
-LL |     let ref foo = 16;
-   |         ------- help: consider changing this to be a mutable reference: `ref mut foo`
-...
-LL |     *foo = 32;
-   |     ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
-
-error[E0594]: cannot assign to `*bar` which is behind a `&` reference
-  --> $DIR/suggest-ref-mut.rs:33:9
-   |
-LL |     if let Some(ref bar) = Some(16) {
-   |                 ------- help: consider changing this to be a mutable reference: `ref mut bar`
-...
-LL |         *bar = 32;
-   |         ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written
-
-error[E0594]: cannot assign to `*quo` which is behind a `&` reference
-  --> $DIR/suggest-ref-mut.rs:37:22
-   |
-LL |         ref quo => { *quo = 32; },
-   |         -------      ^^^^^^^^^ `quo` is a `&` reference, so the data it refers to cannot be written
-   |         |
-   |         help: consider changing this to be a mutable reference: `ref mut quo`
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/try-on-option.rs b/src/test/ui/suggestions/try-on-option.rs
deleted file mode 100644 (file)
index 65ca234..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(try_trait)]
-
-fn main() {}
-
-fn foo() -> Result<u32, ()> {
-    let x: Option<u32> = None;
-    x?; //~ the trait bound
-    Ok(22)
-}
-
-fn bar() -> u32 {
-    let x: Option<u32> = None;
-    x?; //~ the `?` operator
-    22
-}
diff --git a/src/test/ui/suggestions/try-on-option.stderr b/src/test/ui/suggestions/try-on-option.stderr
deleted file mode 100644 (file)
index 265ee59..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-error[E0277]: the trait bound `(): std::convert::From<std::option::NoneError>` is not satisfied
-  --> $DIR/try-on-option.rs:17:5
-   |
-LL |     x?; //~ the trait bound
-   |     ^^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `()`
-   |
-   = note: required by `std::convert::From::from`
-
-error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
-  --> $DIR/try-on-option.rs:23:5
-   |
-LL |     x?; //~ the `?` operator
-   |     ^^ cannot use the `?` operator in a function that returns `u32`
-   |
-   = help: the trait `std::ops::Try` is not implemented for `u32`
-   = note: required by `std::ops::Try::from_error`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/try-operator-on-main.rs b/src/test/ui/suggestions/try-operator-on-main.rs
deleted file mode 100644 (file)
index e52ef45..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// ignore-cloudabi no std::fs support
-
-#![feature(try_trait)]
-
-use std::ops::Try;
-
-fn main() {
-    // error for a `Try` type on a non-`Try` fn
-    std::fs::File::open("foo")?; //~ ERROR the `?` operator can only
-
-    // a non-`Try` type on a non-`Try` fn
-    ()?; //~ ERROR the `?` operator can only
-
-    // an unrelated use of `Try`
-    try_trait_generic::<()>(); //~ ERROR the trait bound
-}
-
-
-
-fn try_trait_generic<T: Try>() -> T {
-    // and a non-`Try` object on a `Try` fn.
-    ()?; //~ ERROR the `?` operator can only
-
-    loop {}
-}
diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr
deleted file mode 100644 (file)
index 121ae14..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
-  --> $DIR/try-operator-on-main.rs:19:5
-   |
-LL |     std::fs::File::open("foo")?; //~ ERROR the `?` operator can only
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the `?` operator in a function that returns `()`
-   |
-   = help: the trait `std::ops::Try` is not implemented for `()`
-   = note: required by `std::ops::Try::from_error`
-
-error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
-  --> $DIR/try-operator-on-main.rs:22:5
-   |
-LL |     ()?; //~ ERROR the `?` operator can only
-   |     ^^^ the `?` operator cannot be applied to type `()`
-   |
-   = help: the trait `std::ops::Try` is not implemented for `()`
-   = note: required by `std::ops::Try::into_result`
-
-error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
-  --> $DIR/try-operator-on-main.rs:25:5
-   |
-LL |     try_trait_generic::<()>(); //~ ERROR the trait bound
-   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()`
-   |
-note: required by `try_trait_generic`
-  --> $DIR/try-operator-on-main.rs:30:1
-   |
-LL | fn try_trait_generic<T: Try>() -> T {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
-  --> $DIR/try-operator-on-main.rs:32:5
-   |
-LL |     ()?; //~ ERROR the `?` operator can only
-   |     ^^^ the `?` operator cannot be applied to type `()`
-   |
-   = help: the trait `std::ops::Try` is not implemented for `()`
-   = note: required by `std::ops::Try::into_result`
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/tuple-float-index.fixed b/src/test/ui/suggestions/tuple-float-index.fixed
deleted file mode 100644 (file)
index 55bc2f7..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-// compile-flags: -Z parse-only
-
-fn main () {
-    ((1, (2, 3)).1).1; //~ ERROR unexpected token: `1.1`
-}
diff --git a/src/test/ui/suggestions/tuple-float-index.rs b/src/test/ui/suggestions/tuple-float-index.rs
deleted file mode 100644 (file)
index d569ca4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// run-rustfix
-// compile-flags: -Z parse-only
-
-fn main () {
-    (1, (2, 3)).1.1; //~ ERROR unexpected token: `1.1`
-}
diff --git a/src/test/ui/suggestions/tuple-float-index.stderr b/src/test/ui/suggestions/tuple-float-index.stderr
deleted file mode 100644 (file)
index 15af083..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error: unexpected token: `1.1`
-  --> $DIR/tuple-float-index.rs:15:17
-   |
-LL |     (1, (2, 3)).1.1; //~ ERROR unexpected token: `1.1`
-   |     ------------^^^
-   |     |           |
-   |     |           unexpected token
-   |     help: try parenthesizing the first index: `((1, (2, 3)).1).1`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/suggestions/type-ascription-instead-of-initializer.rs b/src/test/ui/suggestions/type-ascription-instead-of-initializer.rs
deleted file mode 100644 (file)
index d80dad8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() {
-    let x: Vec::with_capacity(10, 20);  //~ ERROR expected type, found `10`
-    //~^ ERROR this function takes 1 parameter
-}
diff --git a/src/test/ui/suggestions/type-ascription-instead-of-initializer.stderr b/src/test/ui/suggestions/type-ascription-instead-of-initializer.stderr
deleted file mode 100644 (file)
index 3722d2a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-error: expected type, found `10`
-  --> $DIR/type-ascription-instead-of-initializer.rs:12:31
-   |
-LL |     let x: Vec::with_capacity(10, 20);  //~ ERROR expected type, found `10`
-   |         --                    ^^
-   |         ||
-   |         |help: use `=` if you meant to assign
-   |         while parsing the type for `x`
-
-error[E0061]: this function takes 1 parameter but 2 parameters were supplied
-  --> $DIR/type-ascription-instead-of-initializer.rs:12:12
-   |
-LL |     let x: Vec::with_capacity(10, 20);  //~ ERROR expected type, found `10`
-   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0061`.
diff --git a/src/test/ui/suggestions/type-ascription-instead-of-statement-end.rs b/src/test/ui/suggestions/type-ascription-instead-of-statement-end.rs
deleted file mode 100644 (file)
index 01d773d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(type_ascription)]
-
-fn main() {
-    println!("test"):
-    0; //~ ERROR expected type, found `0`
-}
-
-fn foo() {
-    println!("test"): 0; //~ ERROR expected type, found `0`
-}
diff --git a/src/test/ui/suggestions/type-ascription-instead-of-statement-end.stderr b/src/test/ui/suggestions/type-ascription-instead-of-statement-end.stderr
deleted file mode 100644 (file)
index 314c906..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error: expected type, found `0`
-  --> $DIR/type-ascription-instead-of-statement-end.rs:15:5
-   |
-LL |     println!("test"):
-   |                     - help: try using a semicolon: `;`
-LL |     0; //~ ERROR expected type, found `0`
-   |     ^ expecting a type here because of type ascription
-
-error: expected type, found `0`
-  --> $DIR/type-ascription-instead-of-statement-end.rs:19:23
-   |
-LL |     println!("test"): 0; //~ ERROR expected type, found `0`
-   |                       ^ expecting a type here because of type ascription
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/suggestions/type-ascription-with-fn-call.rs b/src/test/ui/suggestions/type-ascription-with-fn-call.rs
deleted file mode 100644 (file)
index b2c25c3..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(type_ascription)]
-
-fn main() {
-    f()  :
-    f(); //~ ERROR expected type, found function
-}
-
-fn f() {}
diff --git a/src/test/ui/suggestions/type-ascription-with-fn-call.stderr b/src/test/ui/suggestions/type-ascription-with-fn-call.stderr
deleted file mode 100644 (file)
index 78df971..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0573]: expected type, found function `f`
-  --> $DIR/type-ascription-with-fn-call.rs:15:5
-   |
-LL |     f()  :
-   |          - help: did you mean to use `;` here instead?
-LL |     f(); //~ ERROR expected type, found function
-   |     ^^^
-   |     |
-   |     not a type
-   |     expecting a type here because of type ascription
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0573`.
index 84dbc7ffc2f8f50826e597f4aacf69b5b254d43d..5c1aae29c2fdf5075280a6d6251724a4036b997a 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}`
+error: expected one of `(`, `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `}`
   --> $DIR/issue-41155.rs:13:1
    |
 LL |     pub
-   |        - expected one of 8 possible tokens here
+   |        - expected one of 9 possible tokens here
 LL | } //~ ERROR expected one of
    | ^ unexpected token
 
diff --git a/src/test/ui/try-on-option.rs b/src/test/ui/try-on-option.rs
new file mode 100644 (file)
index 0000000..65ca234
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(try_trait)]
+
+fn main() {}
+
+fn foo() -> Result<u32, ()> {
+    let x: Option<u32> = None;
+    x?; //~ the trait bound
+    Ok(22)
+}
+
+fn bar() -> u32 {
+    let x: Option<u32> = None;
+    x?; //~ the `?` operator
+    22
+}
diff --git a/src/test/ui/try-on-option.stderr b/src/test/ui/try-on-option.stderr
new file mode 100644 (file)
index 0000000..265ee59
--- /dev/null
@@ -0,0 +1,20 @@
+error[E0277]: the trait bound `(): std::convert::From<std::option::NoneError>` is not satisfied
+  --> $DIR/try-on-option.rs:17:5
+   |
+LL |     x?; //~ the trait bound
+   |     ^^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `()`
+   |
+   = note: required by `std::convert::From::from`
+
+error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
+  --> $DIR/try-on-option.rs:23:5
+   |
+LL |     x?; //~ the `?` operator
+   |     ^^ cannot use the `?` operator in a function that returns `u32`
+   |
+   = help: the trait `std::ops::Try` is not implemented for `u32`
+   = note: required by `std::ops::Try::from_error`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/try-operator-on-main.rs b/src/test/ui/try-operator-on-main.rs
new file mode 100644 (file)
index 0000000..e52ef45
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-cloudabi no std::fs support
+
+#![feature(try_trait)]
+
+use std::ops::Try;
+
+fn main() {
+    // error for a `Try` type on a non-`Try` fn
+    std::fs::File::open("foo")?; //~ ERROR the `?` operator can only
+
+    // a non-`Try` type on a non-`Try` fn
+    ()?; //~ ERROR the `?` operator can only
+
+    // an unrelated use of `Try`
+    try_trait_generic::<()>(); //~ ERROR the trait bound
+}
+
+
+
+fn try_trait_generic<T: Try>() -> T {
+    // and a non-`Try` object on a `Try` fn.
+    ()?; //~ ERROR the `?` operator can only
+
+    loop {}
+}
diff --git a/src/test/ui/try-operator-on-main.stderr b/src/test/ui/try-operator-on-main.stderr
new file mode 100644 (file)
index 0000000..121ae14
--- /dev/null
@@ -0,0 +1,42 @@
+error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
+  --> $DIR/try-operator-on-main.rs:19:5
+   |
+LL |     std::fs::File::open("foo")?; //~ ERROR the `?` operator can only
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the `?` operator in a function that returns `()`
+   |
+   = help: the trait `std::ops::Try` is not implemented for `()`
+   = note: required by `std::ops::Try::from_error`
+
+error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
+  --> $DIR/try-operator-on-main.rs:22:5
+   |
+LL |     ()?; //~ ERROR the `?` operator can only
+   |     ^^^ the `?` operator cannot be applied to type `()`
+   |
+   = help: the trait `std::ops::Try` is not implemented for `()`
+   = note: required by `std::ops::Try::into_result`
+
+error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
+  --> $DIR/try-operator-on-main.rs:25:5
+   |
+LL |     try_trait_generic::<()>(); //~ ERROR the trait bound
+   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()`
+   |
+note: required by `try_trait_generic`
+  --> $DIR/try-operator-on-main.rs:30:1
+   |
+LL | fn try_trait_generic<T: Try>() -> T {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
+  --> $DIR/try-operator-on-main.rs:32:5
+   |
+LL |     ()?; //~ ERROR the `?` operator can only
+   |     ^^^ the `?` operator cannot be applied to type `()`
+   |
+   = help: the trait `std::ops::Try` is not implemented for `()`
+   = note: required by `std::ops::Try::into_result`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/tuple-float-index.fixed b/src/test/ui/tuple-float-index.fixed
new file mode 100644 (file)
index 0000000..55bc2f7
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+// compile-flags: -Z parse-only
+
+fn main () {
+    ((1, (2, 3)).1).1; //~ ERROR unexpected token: `1.1`
+}
diff --git a/src/test/ui/tuple-float-index.rs b/src/test/ui/tuple-float-index.rs
new file mode 100644 (file)
index 0000000..d569ca4
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+// compile-flags: -Z parse-only
+
+fn main () {
+    (1, (2, 3)).1.1; //~ ERROR unexpected token: `1.1`
+}
diff --git a/src/test/ui/tuple-float-index.stderr b/src/test/ui/tuple-float-index.stderr
new file mode 100644 (file)
index 0000000..15af083
--- /dev/null
@@ -0,0 +1,11 @@
+error: unexpected token: `1.1`
+  --> $DIR/tuple-float-index.rs:15:17
+   |
+LL |     (1, (2, 3)).1.1; //~ ERROR unexpected token: `1.1`
+   |     ------------^^^
+   |     |           |
+   |     |           unexpected token
+   |     help: try parenthesizing the first index: `((1, (2, 3)).1).1`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-ascription-instead-of-initializer.rs b/src/test/ui/type-ascription-instead-of-initializer.rs
new file mode 100644 (file)
index 0000000..d80dad8
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let x: Vec::with_capacity(10, 20);  //~ ERROR expected type, found `10`
+    //~^ ERROR this function takes 1 parameter
+}
diff --git a/src/test/ui/type-ascription-instead-of-initializer.stderr b/src/test/ui/type-ascription-instead-of-initializer.stderr
new file mode 100644 (file)
index 0000000..3722d2a
--- /dev/null
@@ -0,0 +1,18 @@
+error: expected type, found `10`
+  --> $DIR/type-ascription-instead-of-initializer.rs:12:31
+   |
+LL |     let x: Vec::with_capacity(10, 20);  //~ ERROR expected type, found `10`
+   |         --                    ^^
+   |         ||
+   |         |help: use `=` if you meant to assign
+   |         while parsing the type for `x`
+
+error[E0061]: this function takes 1 parameter but 2 parameters were supplied
+  --> $DIR/type-ascription-instead-of-initializer.rs:12:12
+   |
+LL |     let x: Vec::with_capacity(10, 20);  //~ ERROR expected type, found `10`
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0061`.
diff --git a/src/test/ui/type-ascription-instead-of-statement-end.rs b/src/test/ui/type-ascription-instead-of-statement-end.rs
new file mode 100644 (file)
index 0000000..01d773d
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(type_ascription)]
+
+fn main() {
+    println!("test"):
+    0; //~ ERROR expected type, found `0`
+}
+
+fn foo() {
+    println!("test"): 0; //~ ERROR expected type, found `0`
+}
diff --git a/src/test/ui/type-ascription-instead-of-statement-end.stderr b/src/test/ui/type-ascription-instead-of-statement-end.stderr
new file mode 100644 (file)
index 0000000..314c906
--- /dev/null
@@ -0,0 +1,16 @@
+error: expected type, found `0`
+  --> $DIR/type-ascription-instead-of-statement-end.rs:15:5
+   |
+LL |     println!("test"):
+   |                     - help: try using a semicolon: `;`
+LL |     0; //~ ERROR expected type, found `0`
+   |     ^ expecting a type here because of type ascription
+
+error: expected type, found `0`
+  --> $DIR/type-ascription-instead-of-statement-end.rs:19:23
+   |
+LL |     println!("test"): 0; //~ ERROR expected type, found `0`
+   |                       ^ expecting a type here because of type ascription
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/type-ascription-with-fn-call.rs b/src/test/ui/type-ascription-with-fn-call.rs
new file mode 100644 (file)
index 0000000..b2c25c3
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(type_ascription)]
+
+fn main() {
+    f()  :
+    f(); //~ ERROR expected type, found function
+}
+
+fn f() {}
diff --git a/src/test/ui/type-ascription-with-fn-call.stderr b/src/test/ui/type-ascription-with-fn-call.stderr
new file mode 100644 (file)
index 0000000..78df971
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0573]: expected type, found function `f`
+  --> $DIR/type-ascription-with-fn-call.rs:15:5
+   |
+LL |     f()  :
+   |          - help: did you mean to use `;` here instead?
+LL |     f(); //~ ERROR expected type, found function
+   |     ^^^
+   |     |
+   |     not a type
+   |     expecting a type here because of type ascription
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0573`.
index 0b743d9e486b6aa79eb89b0eba01ea8764405d8e..62b2d587c7eafac28bd763ab479a61acbaa055e1 100644 (file)
@@ -8,13 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(wasm_import_module)]
+#[link(name = "...", wasm_import_module)] //~ ERROR: must be of the form
+extern {}
 
-#[wasm_import_module] //~ ERROR: must be of the form
+#[link(name = "...", wasm_import_module(x))] //~ ERROR: must be of the form
 extern {}
 
-#[wasm_import_module = "foo"] //~ ERROR: must only be attached to
-fn foo() {}
+#[link(name = "...", wasm_import_module())] //~ ERROR: must be of the form
+extern {}
 
 fn main() {}
 
index bf301ce5269a7f7f103e856ab2a972e0de7c9501..14b3055fea8047976a6312542eec894c9c8d2c20 100644 (file)
@@ -1,14 +1,20 @@
-error: must be of the form #[wasm_import_module = "..."]
-  --> $DIR/wasm-import-module.rs:13:1
+error: must be of the form #[link(wasm_import_module = "...")]
+  --> $DIR/wasm-import-module.rs:11:22
    |
-LL | #[wasm_import_module] //~ ERROR: must be of the form
-   | ^^^^^^^^^^^^^^^^^^^^^
+LL | #[link(name = "...", wasm_import_module)] //~ ERROR: must be of the form
+   |                      ^^^^^^^^^^^^^^^^^^
 
-error: must only be attached to foreign modules
-  --> $DIR/wasm-import-module.rs:16:1
+error: must be of the form #[link(wasm_import_module = "...")]
+  --> $DIR/wasm-import-module.rs:14:22
    |
-LL | #[wasm_import_module = "foo"] //~ ERROR: must only be attached to
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #[link(name = "...", wasm_import_module(x))] //~ ERROR: must be of the form
+   |                      ^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 2 previous errors
+error: must be of the form #[link(wasm_import_module = "...")]
+  --> $DIR/wasm-import-module.rs:17:22
+   |
+LL | #[link(name = "...", wasm_import_module())] //~ ERROR: must be of the form
+   |                      ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
 
index 1dd7fe7f0cb39d5fbdd2414677aef566eb81c3de..edab2a5ec034c15511349c0c86635c4a535c8805 100644 (file)
@@ -14,8 +14,7 @@
 use std::io::BufReader;
 use std::path::{Path, PathBuf};
 
-use common;
-use common::Config;
+use common::{self, Config, Mode};
 use util;
 
 use extract_gdb_version;
@@ -262,7 +261,7 @@ pub fn new() -> Self {
             disable_ui_testing_normalization: false,
             normalize_stdout: vec![],
             normalize_stderr: vec![],
-            failure_status: 101,
+            failure_status: -1,
             run_rustfix: false,
         }
     }
@@ -393,6 +392,11 @@ fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
 
             if let Some(code) = config.parse_failure_status(ln) {
                 self.failure_status = code;
+            } else {
+                self.failure_status = match config.mode {
+                    Mode::RunFail => 101,
+                    _ => 1,
+                };
             }
 
             if !self.run_rustfix {
index 59ddc16715d3b6e52ad8264e894a84e2f5bdeb08..fcc474362253d3dd37e73f001ba24a49aab3407e 100644 (file)
@@ -1170,12 +1170,10 @@ fn check_error_patterns(&self, output_to_check: &str, proc_res: &ProcRes) {
     }
 
     fn check_no_compiler_crash(&self, proc_res: &ProcRes) {
-        for line in proc_res.stderr.lines() {
-            if line.contains("error: internal compiler error") {
-                self.fatal_proc_rec("compiler encountered internal error", proc_res);
-            } else if line.contains(" panicked at ") {
-                self.fatal_proc_rec("compiler panicked", proc_res);
-            }
+        match proc_res.status.code() {
+            Some(101) => self.fatal_proc_rec("compiler encountered internal error", proc_res),
+            None => self.fatal_proc_rec("compiler terminated by signal", proc_res),
+            _ => (),
         }
     }