From 5d61dcaad56a3b6aeaba71c45a7d47cebe9bb4b0 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 30 May 2022 17:10:51 -0700 Subject: [PATCH 001/150] Add documentation on v0 symbol mangling. --- src/doc/rustc/book.toml | 3 + src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/codegen-options/index.md | 6 +- .../src/codegen-options/symbol-mangling.md | 1225 +++++++++++++++++ 4 files changed, 1233 insertions(+), 2 deletions(-) create mode 100644 src/doc/rustc/src/codegen-options/symbol-mangling.md diff --git a/src/doc/rustc/book.toml b/src/doc/rustc/book.toml index cea6033ede20..14ae1a7207ac 100644 --- a/src/doc/rustc/book.toml +++ b/src/doc/rustc/book.toml @@ -6,3 +6,6 @@ title = "The rustc book" [output.html] git-repository-url = "https://github.com/rust-lang/rust/tree/master/src/doc/rustc" edit-url-template = "https://github.com/rust-lang/rust/edit/master/src/doc/rustc/{path}" + +[output.html.playground] +runnable = false diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 73343ba9df51..b06f62f89166 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -3,6 +3,7 @@ - [What is rustc?](what-is-rustc.md) - [Command-line Arguments](command-line-arguments.md) - [Codegen Options](codegen-options/index.md) + - [Symbol Mangling](codegen-options/symbol-mangling.md) - [Lints](lints/index.md) - [Lint Levels](lints/levels.md) - [Lint Groups](lints/groups.md) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 1041d5026690..f77851cdec2d 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -569,13 +569,15 @@ for the purpose of generating object code and linking. Supported values for this option are: -* `v0` — The "v0" mangling scheme. The specific format is not specified at - this time. +* `v0` — The "v0" mangling scheme. The default, if not specified, will use a compiler-chosen default which may change in the future. +See the [Symbol Mangling] chapter for details on symbol mangling and the mangling format. + [name mangling]: https://en.wikipedia.org/wiki/Name_mangling +[Symbol Mangling]: symbol-mangling.md ## target-cpu diff --git a/src/doc/rustc/src/codegen-options/symbol-mangling.md b/src/doc/rustc/src/codegen-options/symbol-mangling.md new file mode 100644 index 000000000000..1f7c4b805e3d --- /dev/null +++ b/src/doc/rustc/src/codegen-options/symbol-mangling.md @@ -0,0 +1,1225 @@ +# Symbol Mangling + +[Symbol name mangling] is used by `rustc` to encode a unique name for symbols that are used during code generation. +The encoded names are used by the linker to associate the name with the thing it refers to. + +The method for mangling the names can be controlled with the [`-C symbol-mangling-version`] option. + +[Symbol name mangling]: https://en.wikipedia.org/wiki/Name_mangling +[`-C symbol-mangling-version`]: index.md#symbol-mangling-version + +## Per-item control + +The [`#[no_mangle]` attribute][reference-no_mangle] can be used on items to disable name mangling on that item. + +The [`#[export_name]`attribute][reference-export_name] can be used to specify the exact name that will be used for a function or static. + +Items listed in an [`extern` block][reference-extern-block] use the identifier of the item without mangling to refer to the item. +The [`#[link_name]` attribute][reference-link_name] can be used to change that name. + + + +[reference-no_mangle]: ../../reference/abi.html#the-no_mangle-attribute +[reference-export_name]: ../../reference/abi.html#the-export_name-attribute +[reference-link_name]: ../../reference/items/external-blocks.html#the-link_name-attribute +[reference-extern-block]: ../../reference/items/external-blocks.html + +## Decoding + +The encoded names may need to be decoded in some situations. +For example, debuggers and other tooling may need to demangle the name so that it is more readable to the user. +Recent versions of `gdb` and `lldb` have built-in support for demangling Rust identifiers. +In situations where you need to do your own demangling, the [`rustc-demangle`] crate can be used to programmatically demangle names. +[`rustfilt`] is a CLI tool which can demangle names. + +An example of running rustfilt: + +```text +$ rustfilt _RNvCskwGfYPst2Cb_3foo16example_function +foo::example_function +``` + +[`rustc-demangle`]: https://crates.io/crates/rustc-demangle +[`rustfilt`]: https://crates.io/crates/rustfilt + +## Mangling versions + +`rustc` supports different mangling versions which encode the names in different ways. +The legacy version (which is currently the default) is not described here. +The "v0" mangling scheme addresses several limitations of the legacy format, +and is [described below](#v0-mangling-format). + +## v0 mangling format + +The v0 mangling format was introduced in [RFC 2603]. +It has the following properties: + +- It provides an unambiguous string encoding for everything that can end up in a binary's symbol table. +- It encodes information about generic parameters in a reversible way. +- The mangled symbols are *decodable* such that demangled form should be easily identifiable as some concrete instance of e.g. a polymorphic function. +- It has a consistent definition that does not rely on pretty-printing certain language constructs. +- Symbols can be restricted to only consist of the characters `A-Z`, `a-z`, `0-9`, and `_`. + This helps ensure that it is platform-independent, + where other characters might have special meaning in some context (e.g. `.` for MSVC `DEF` files). + Unicode symbols are optionally supported. +- It tries to stay efficient, avoiding unnecessarily long names, + and avoiding computationally expensive operations to demangle. + +The v0 format is not intended to be compatible with other mangling schemes (such as C++). + +The v0 format is not presented as a stable ABI for Rust. +This format is currently intended to be well-defined enough that a demangler can produce a reasonable human-readable form of the symbol. +There are several implementation-defined portions that result in it not being possible to entirely predict how a given Rust entity will be encoded. + +The sections below define the encoding of a v0 symbol. +There is no standardized demangled form of the symbols, +though suggestions are provided for how to demangle a symbol. +Implementers may choose to demangle in different ways. + +### Grammar notation + +The format of an encoded symbol is illustrated as a context free grammar in an extended BNF-like syntax. +A consolidated summary can be found in the [Symbol grammar summary][summary]. + +| Name | Syntax | Example | Description | +|------|--------|---------|-------------| +| Rule | → | A → *B* *C* | A production. | +| Concatenation | whitespace | A → *B* *C* *D* | Individual elements in sequence left-to-right. | +| Alternative | \| | A → *B* \| *C* | Matches either one or the other. | +| Grouping | () | A → *B* (*C* \| *D*) *E* | Groups multiple elements as one. | +| Repetition | {} | A → {*B*} | Repeats the enclosed zero or more times. | +| Option | opt | A → *B*opt *C* | An optional element. | +| Literal | `monospace` | A → `G` | A terminal matching the exact characters case-sensitive. | + +### Symbol name +[symbol-name]: #symbol-name + +> symbol-name → `_R` *[decimal-number]*opt *[path]* *[instantiating-crate]*opt *[vendor-specific-suffix]*opt + +A mangled symbol starts with the two characters `_R` which is a prefix to identify the symbol as a Rust symbol. +The prefix can optionally be followed by a *[decimal-number]* which specifies the encoding version. +This number is currently not used, and is never present in the current encoding. +Following that is a *[path]* which encodes the path to an entity. +The path is followed by an optional *[instantiating-crate]* which helps to disambiguate entities which may be instantiated multiple times in separate crates. +The final part is an optional *[vendor-specific-suffix]*. + +> **Recommended Demangling** +> +> A *symbol-name* should be displayed as the *[path]*. +> The *[instantiating-crate]* and the *[vendor-specific-suffix]* usually need not be displayed. + +> Example: +> ```rust +> std::path::PathBuf::new(); +> ``` +> +> The symbol for `PathBuf::new` in crate `mycrate` is: +> +> ```text +> _RNvMsr_NtCs3ssYzQotkvD_3std4pathNtB5_7PathBuf3newCs15kBYyAo9fc_7mycrate +> ├┘└───────────────────────┬──────────────────────┘└──────────┬─────────┘ +> │ │ │ +> │ │ └── instantiating-crate path "mycrate" +> │ └───────────────────────────────────── path to std::path::PathBuf::new +> └─────────────────────────────────────────────────────────────── `_R` symbol prefix +> ``` +> +> Recommended demangling: `::new` + +### Symbol path +[path]: #symbol-path + +> path → \ +>       *[crate-root]* \ +>    | *[inherent-impl]* \ +>    | *[trait-impl]* \ +>    | *[trait-definition]* \ +>    | *[nested-path]* \ +>    | *[generic-args]* \ +>    | *[backref]* + +A *path* represents a variant of a [Rust path][reference-paths] to some entity. +In addition to typical Rust path segments using identifiers, +it uses extra elements to represent unnameable entities (like an `impl`) or generic arguments for monomorphized items. + +The initial tag character can be used to determine which kind of path it represents: + +| Tag | Rule | Description | +|-----|------|-------------| +| `C` | *[crate-root]* | The root of a crate path. | +| `M` | *[inherent-impl]* | An inherent implementation. | +| `X` | *[trait-impl]* | A trait implementation. | +| `Y` | *[trait-definition]* | A trait definition. | +| `N` | *[nested-path]* | A nested path. | +| `I` | *[generic-args]* | Generic arguments. | +| `B` | *[backref]* | A back reference. | + +#### Path: Crate root +[crate-root]: #path-crate-root + +> crate-root → `C` *[identifier]* + +A *crate-root* indicates a path referring to the root of a crate's module tree. +It consists of the character `C` followed by the crate name as an *[identifier]*. + +The crate name is the name as seen from the defining crate. +Since Rust supports linking multiple crates with the same name, +the *[disambiguator]* is used to make the name unique across the crate graph. + +> **Recommended Demangling** +> +> A *crate-root* can be displayed as the identifier such as `mycrate`. +> +> Usually the disambiguator in the identifier need not be displayed, +> but as an alternate form the disambiguator can be shown in hex such as +> `mycrate[ca63f166dbe9294]`. + +> Example: +> ```rust +> fn example() {} +> ``` +> +> The symbol for `example` in crate `mycrate` is: +> +> ```text +> _RNvCs15kBYyAo9fc_7mycrate7example +> │└────┬─────┘││└──┬──┘ +> │ │ ││ │ +> │ │ ││ └── crate-root identifier "mycrate" +> │ │ │└────── length 7 of "mycrate" +> │ │ └─────── end of base-62-number +> │ └────────────── disambiguator for crate-root "mycrate" 0xca63f166dbe9293 + 1 +> └──────────────────── crate-root +> ``` +> +> Recommended demangling: `mycrate::example` + +#### Path: Inherent impl +[inherent-impl]: #path-inherent-impl + +> inherent-impl → `M` *[impl-path]* *[type]* + +An *inherent-impl* indicates a path to an [inherent implementation][reference-inherent-impl]. +It consists of the character `M` followed by an *[impl-path]* to the impl's parent followed by the *[type]* representing the `Self` type of the impl. + +> **Recommended Demangling** +> +> An *inherent-impl* can be displayed as a qualified path segment to the *[type]* within angled brackets. +> The *[impl-path]* usually need not be displayed. + +> Example: +> ```rust +> struct Example; +> impl Example { +> fn foo() {} +> } +> ``` +> +> The symbol for `foo` in the impl for `Example` is: +> +> ```text +> _RNvMCs15kBYyAo9fc_7mycrateNtB2_7Example3foo +> │└─────────┬──────────┘└────┬──────┘ +> │ │ │ +> │ │ └── Self type "Example" +> │ └─────────────────── path to the impl's parent "mycrate" +> └────────────────────────────── inherent-impl +> ``` +> +> Recommended demangling: `::foo` + +#### Path: Trait impl +[trait-impl]: #path-trait-impl + +> trait-impl → `X` *[impl-path]* *[type]* *[path]* + +A *trait-impl* indicates a path to a [trait implementation][reference-trait-impl]. +It consists of the character `X` followed by an *[impl-path]* to the impl's parent followed by the *[type]* representing the `Self` type of the impl followed by a *[path]* to the trait. + +> **Recommended Demangling** +> +> A *trait-impl* can be displayed as a qualified path segment using the `<` *type* `as` *path* `>` syntax. +> The *[impl-path]* usually need not be displayed. + +> Example: +> ```rust +> struct Example; +> trait Trait { +> fn foo(); +> } +> impl Trait for Example { +> fn foo() {} +> } +> ``` +> +> The symbol for `foo` in the trait impl for `Example` is: +> +> ```text +> _RNvXCs15kBYyAo9fc_7mycrateNtB2_7ExampleNtB2_5Trait3foo +> │└─────────┬──────────┘└─────┬─────┘└────┬────┘ +> │ │ │ │ +> │ │ │ └── path to the trait "Trait" +> │ │ └────────────── Self type "Example" +> │ └──────────────────────────────── path to the impl's parent "mycrate" +> └─────────────────────────────────────────── trait-impl +> ``` +> +> Recommended demangling: `::foo` + +#### Path: Impl +[impl-path]: #path-impl + +> impl-path → *[disambiguator]*opt *[path]* + +An *impl-path* is a path used for *[inherent-impl]* and *[trait-impl]* to indicate the path to parent of an [implementation][reference-implementations]. +It consists of an optional *[disambiguator]* followed by a *[path]*. +The *[path]* is the path to the parent that contains the impl. +The *[disambiguator]* can be used to distinguish between multiple impls within the same parent. + +> **Recommended Demangling** +> +> An *impl-path* usually need not be displayed (unless the location of the impl is desired). + +> Example: +> ```rust +> struct Example; +> impl Example { +> fn foo() {} +> } +> impl Example { +> fn bar() {} +> } +> ``` +> +> The symbol for `foo` in the impl for `Example` is: +> +> ```text +> _RNvMCs7qp2U7fqm6G_7mycrateNtB2_7Example3foo +> └─────────┬──────────┘ +> │ +> └── path to the impl's parent crate-root "mycrate" +> ``` +> +> The symbol for `bar` is similar, though it has a disambiguator to indicate it is in a different impl block. +> +> ```text +> _RNvMs_Cs7qp2U7fqm6G_7mycrateNtB4_7Example3bar +> ├┘└─────────┬──────────┘ +> │ │ +> │ └── path to the impl's parent crate-root "mycrate" +> └────────────── disambiguator 1 +> ``` +> +> Recommended demangling: +> * `foo`: `::foo` +> * `bar`: `::bar` + +#### Path: Trait definition +[trait-definition]: #path-trait-definition + +> trait-definition → `Y` *[type]* *[path]* + +A *trait-definition* is a path to a [trait definition][reference-traits]. +It consists of the character `Y` followed by the *[type]* which is the `Self` type of the referrer, followed by the *[path]* to the trait definition. + +> **Recommended Demangling** +> +> A *trait-definition* can be displayed as a qualified path segment using the `<` *type* `as` *path* `>` syntax. + +> Example: +> ```rust +> trait Trait { +> fn example() {} +> } +> struct Example; +> impl Trait for Example {} +> ``` +> +> The symbol for `example` in the trait `Trait` implemented for `Example` is: +> +> ```text +> _RNvYNtCs15kBYyAo9fc_7mycrate7ExampleNtB4_5Trait7exampleB4_ +> │└──────────────┬───────────────┘└────┬────┘ +> │ │ │ +> │ │ └── path to the trait "Trait" +> │ └──────────────────────── path to the implementing type "mycrate::Example" +> └──────────────────────────────────────── trait-definition +> ``` +> +> Recommended demangling: `::example` + +#### Path: Nested path +[nested-path]: #path-nested-path + +> nested-path → `N` *[namespace]* *[path]* *[identifier]* + +A *nested-path* is a path representing an optionally named entity. +It consists of the character `N` followed by a *[namespace]* indicating the namespace of the entity, +followed by a *[path]* which is a path representing the parent of the entity, +followed by an *[identifier]* of the entity. + +The identifier of the entity may be empty when the entity is not named. +For example, entities like closures, tuple-like struct constructors, and anonymous constants may not have a name. + +> **Recommended Demangling** +> +> A *nested-path* can be displayed by first displaying the *[path]* followed by a `::` separator followed by the *[identifier]*. +> If the *[identifier]* is empty, then the separating `::` should not be displayed. +> +> If a *[namespace]* is specified, then extra context may be added such as: \ +> *[path]* `::{` *[namespace]* (`:` *[identifier]*)opt `#` *disambiguator*as base-10 number `}` +> +> Here the namespace `C` may be printed as `closure` and `S` as `shim`. +> Others may be printed by their character tag. +> The `:` *name* portion may be skipped if the name is empty. +> +> The *[disambiguator]* in the *[identifier]* may be displayed if a *[namespace]* is specified. +> In other situations, it is usually not necessary to display the *[disambiguator]*. +> If it is displayed, it is recommended to place it in brackets, for example `[284a76a8b41a7fd3]`. +> If the *[disambiguator]* is not present, then its value is 0 and it can always be omitted from display. + +> Example: +> ```rust +> fn main() { +> let x = || {}; +> let y = || {}; +> x(); +> y(); +> } +> ``` +> +> The symbol for the closure `x` in crate `mycrate` is: +> +> ```text +> _RNCNvCsgStHSCytQ6I_7mycrate4main0B3_ +> ││└─────────────┬─────────────┘│ +> ││ │ │ +> ││ │ └── identifier with length 0 +> ││ └───────────────── path to "mycrate::main" +> │└──────────────────────────────── closure namespace +> └───────────────────────────────── nested-path +> ``` +> +> The symbol for the closure `y` is similar, with a disambiguator: +> +> ```text +> _RNCNvCsgStHSCytQ6I_7mycrate4mains_0B3_ +> ││ +> │└── base-62-number 0 +> └─── disambiguator 1 (base-62-number+1) +> ``` +> +> Recommended demangling: +> * `x`: `mycrate::main::{closure#0}` +> * `y`: `mycrate::main::{closure#1}` + +#### Path: Generic arguments +[generic-args]: #path-generic-arguments +[generic-arg]: #path-generic-arguments + +> generic-args → `I` *[path]* {*[generic-arg]*} `E` +> +> generic-arg → \ +>       *[lifetime]* \ +>    | *[type]* \ +>    | `K` *[const]* + +A *generic-args* is a path representing a list of generic arguments. +It consists of the character `I` followed by a *[path]* to the defining entity, followed by zero or more [generic-arg]s terminated by the character `E`. + +Each *[generic-arg]* is either a *[lifetime]* (starting with the character `L`), a *[type]*, or the character `K` followed by a *[const]* representing a const argument. + +> **Recommended Demangling** +> +> A *generic-args* may be printed as: *[path]* `::`opt `<` comma-separated list of args `>` +> The `::` separator may be elided for type paths (similar to Rust's rules). + +> > Example: +> ```rust +> fn main() { +> example([123]); +> } +> +> fn example(x: [T; N]) {} +> ``` +> +> The symbol for the function `example` is: +> +> ```text +> _RINvCsgStHSCytQ6I_7mycrate7examplelKj1_EB2_ +> │└──────────────┬───────────────┘││││││ +> │ │ │││││└── end of generic-args +> │ │ ││││└─── end of const-data +> │ │ │││└──── const value `1` +> │ │ ││└───── const type `usize` +> │ │ │└────── const generic +> │ │ └─────── generic type i32 +> │ └──────────────────────── path to "mycrate::example" +> └──────────────────────────────────────── generic-args +> ``` +> +> Recommended demangling: `mycrate::example::` + +#### Namespace +[namespace]: #namespace + +> namespace → *[lower]* | *[upper]* + +A *namespace* is used to segregate names into separate logical groups, allowing identical names to otherwise avoid collisions. +It consists of a single character of an upper or lowercase ASCII letter. +Lowercase letters are reserved for implementation-internal disambiguation categories (and demanglers should never show them). +Uppercase letters are used for special namespaces which demanglers may display in a special way. + +Uppercase namespaces are: + +* `C` — A closure. +* `S` — A shim. Shims are added by the compiler in some situations where an intermediate is needed. + For example, a `fn()` pointer to a function with the [`#[track_caller]` attribute][reference-track_caller] needs a shim to deal with the implicit caller location. + +> **Recommended Demangling** +> +> See *[nested-path]* for recommended demangling. + +### Identifier +[identifier]: #identifier +[undisambiguated-identifier]: #identifier +[bytes]: #identifier + +> identifier → *[disambiguator]*opt *[undisambiguated-identifier]* +> +> undisambiguated-identifier → `u`opt *[decimal-number]* `_`opt *[bytes]* +> +> bytes → {*UTF-8 bytes*} + +An *identifier* is a named label used in a *[path]* to refer to an entity. +It consists of an optional *[disambiguator]* followed by an *[undisambiguated-identifier]*. + +The disambiguator is used to disambiguate identical identifiers that should not otherwise be considered the same. +For example, closures have no name, so the disambiguator is the only differentiating element between two different closures in the same parent path. + +The undisambiguated-identifier starts with an optional `u` character, +which indicates that the identifier is encoded in [Punycode][Punycode identifiers]. +The next part is a *[decimal-number]* which indicates the length of the *bytes*. + +Following the identifier size is an optional `_` character which is used to separate the length value from the identifier itself. +The `_` is mandatory if the *bytes* starts with a decimal digit or `_` in order to keep it unambiguous where the *decimal-number* ends and the *bytes* starts. + +*bytes* is the identifier itself encoded in UTF-8. + +> **Recommended Demangling** +> +> The display of an *identifier* can depend on its context. +> If it is Punycode-encoded, then it may first be decoded before being displayed. +> +> The *[disambiguator]* may or may not be displayed; see recommendations for rules that use *identifier*. + +#### Punycode identifiers +[Punycode identifiers]: #punycode-identifiers + +Because some environments are restricted to ASCII alphanumerics and `_`, +Rust's [Unicode identifiers][reference-identifiers] may be encoded using a modified version of [Punycode]. + +For example, the function: + +```rust +mod gödel { + mod escher { + fn bach() {} + } +} +``` + +would be mangled as: + +```text +_RNvNtNtCsgOH4LzxkuMq_7mycrateu8gdel_5qa6escher4bach + ││└───┬───┘ + ││ │ + ││ └── gdel_5qa translates to gödel + │└─────── 8 is the length + └──────── `u` indicates it is a Unicode identifier +``` + +Standard Punycode generates strings of the form `([[:ascii:]]+-)?[[:alnum:]]+`. +This is problematic because the `-` character +(which is used to separate the ASCII part from the base-36 encoding) +is not in the supported character set for symbols. +For this reason, `-` characters in the Punycode encoding are replaced with `_`. + +Here are some examples: + +| Original | Punycode | Punycode + Encoding | +|-----------------|-----------------|---------------------| +| føø | f-5gaa | f_5gaa | +| α_ω | _-ylb7e | __ylb7e | +| 铁锈 | n84amf | n84amf | +| 🤦 | fq9h | fq9h | +| ρυστ | 2xaedc | 2xaedc | + +> Note: It is up to the compiler to decide whether or not to encode identifiers using Punycode or not. +> Some platforms may have native support for UTF-8 symbols, +> and the compiler may decide to use the UTF-8 encoding directly. +> Demanglers should be prepared to support either form. + +[Punycode]: https://tools.ietf.org/html/rfc3492 + +### Disambiguator +[disambiguator]: #disambiguator + +> disambiguator → `s` *[base-62-number]* + +A *disambiguator* is used in various parts of a symbol *[path]* to uniquely identify path elements that would otherwise be identical but should not be considered the same. +It starts with the character `s` and is followed by a *[base-62-number]*. + +If the *disambiguator* is not specified, then its value can be assumed to be zero. +Otherwise, when demangling, the value 1 should be added to the *[base-62-number]* +(thus a *base-62-number* of zero encoded as `_` has a value of 1). +This allows disambiguators that are encoded sequentially to use minimal bytes. + +> **Recommended Demangling** +> +> The *disambiguator* may or may not be displayed; see recommendations for rules that use *disambiguator*. + +### Lifetime +[lifetime]: #lifetime + +> lifetime → `L` *[base-62-number]* + +A *lifetime* is used to encode an anonymous (numbered) lifetime, either erased or [higher-ranked](#binder). +It starts with the character `L` and is followed by a *[base-62-number]*. +Index 0 is always erased. +Indices starting from 1 refer (as de Bruijn indices) to a higher-ranked lifetime bound by one of the enclosing [binder]s. + +> **Recommended Demangling** +> +> A *lifetime* may be displayed like a Rust lifetime using a single quote. +> Index 0 should be displayed as `'_`. +> +> Lifetimes starting from 1 may be translated to single lowercase letters starting with `'a`. +> Indices over 25 may consider printing the numeric lifetime index as in `_123`. +> +> Index 0 should not be displayed for lifetimes in a *[ref-type]*, *[mut-ref-type]*, or *[dyn-trait-type]*. +> +> Nested binders may consider tracking their indices so that lifetime lettering can start back with `'a` within a nested binder. +> See *[binder]* for more on lifetime indexes and ordering. + +> Example: +> ```rust +> fn main() { +> example::(); +> } +> +> pub fn example() {} +> ``` +> +> The symbol for the function `example` is: +> +> ```text +> _RINvCs7qp2U7fqm6G_7mycrate7exampleFG0_RL1_hRL0_tEuEB2_ +> │└┬┘│└┬┘││└┬┘││ +> │ │ │ │ ││ │ │└── end of input types +> │ │ │ │ ││ │ └─── type u16 +> │ │ │ │ ││ └───── lifetime #1 'b +> │ │ │ │ │└─────── reference type +> │ │ │ │ └──────── type u8 +> │ │ │ └────────── lifetime #2 'a +> │ │ └──────────── reference type +> │ └────────────── binder with 2 lifetimes +> └──────────────── function type +> ``` +> +> Recommended demangling: `mycrate::example:: fn(&'a u8, &'b u16)>` + +### Const +[const]: #const +[const-data]: #const +[hex-digit]: #const + +> const → \ +>       *[type]* *[const-data]* \ +>    | `p` \ +>    | *[backref]* +> +> const-data → `n`opt {*[hex-digit]*} `_` +> +> [hex-digit] → *[digit]* | `a` | `b` | `c` | `d` | `e` | `f` + +A *const* is used to encode a const value used in generics and types. +It has the following forms: + +* A constant value encoded as a *[type]* which represents the type of the constant and *[const-data]* which is the constant value, followed by `_` to terminate the *const*. +* The character `p` which represents a placeholder. +* A *[backref]* to a previously encoded *const* of the same value. + +The encoding of the *const-data* depends on the type: + +* `bool` — The value `false` is encoded as `0_`, the value true is encoded as `1_`. +* `char` — The Unicode scalar value of the character is encoded in hexadecimal. +* Unsigned integers — The value is encoded in hexadecimal. +* Signed integers — The character `n` is a prefix to indicate that it is negative, + followed by the absolute value encoded in hexadecimal. + +> **Recommended Demangling** +> +> A *const* may be displayed by the const value depending on the type. +> +> The `p` placeholder should be displayed as the `_` character. +> +> For specific types: +> * `b` (bool) — Display as `true` or `false`. +> * `c` (char) — Display the character in as a Rust character (such as `'A'` or `'\n'`). +> * integers — Display the integer (either in decimal or hex). + +> Example: +> ```rust +> fn main() { +> example::<0x12345678>(); +> } +> +> pub fn example() {} +> ``` +> +> The symbol for function `example` is: +> +> ```text +> _RINvCs7qp2U7fqm6G_7mycrate7exampleKy12345678_EB2_ +> ││└───┬───┘ +> ││ │ +> ││ └── const-data 0x12345678 +> │└─────── const type u64 +> └──────── const generic arg +> ``` +> +> Recommended demangling: `mycrate::example::<305419896>` + + +### Type +[type]: #type +[basic-type]: #basic-type +[array-type]: #array-type +[slice-type]: #slice-type +[tuple-type]: #tuple-type +[ref-type]: #ref-type +[mut-ref-type]: #mut-ref-type +[const-ptr-type]: #const-ptr-type +[mut-ptr-type]: #mut-ptr-type +[fn-type]: #fn-type +[dyn-trait-type]: #dyn-trait-type + +> type → \ +>       *[basic-type]* \ +>    | *[array-type]* \ +>    | *[slice-type]* \ +>    | *[tuple-type]* \ +>    | *[ref-type]* \ +>    | *[mut-ref-type]* \ +>    | *[const-ptr-type]* \ +>    | *[mut-ptr-type]* \ +>    | *[fn-type]* \ +>    | *[dyn-trait-type]* \ +>    | *[path]* \ +>    | *[backref]* + +A *type* represents a Rust [type][reference-types]. +The initial character can be used to distinguish which type is encoded. +The type encodings based on the initial tag character are: + +* A *basic-type* is encoded as a single character: + * `a` — `i8` + * `b` — `bool` + * `c` — `char` + * `d` — `f64` + * `e` — `str` + * `f` — `f32` + * `h` — `u8` + * `i` — `isize` + * `j` — `usize` + * `l` — `i32` + * `m` — `u32` + * `n` — `i128` + * `o` — `u128` + * `s` — `i16` + * `t` — `u16` + * `u` — unit `()` + * `v` — variadic `...` + * `x` — `i64` + * `y` — `u64` + * `z` — `!` + * `p` — placeholder `_` + +* `A` — An [array][reference-array] `[T; N]`. + + > array-type → `A` *[type]* *[const]* + + The tag `A` is followed by the *[type]* of the array followed by a *[const]* for the array size. + +* `S` — A [slice][reference-slice] `[T]`. + + > slice-type → `S` *[type]* + + The tag `S` is followed by the *[type]* of the slice. + +* `T` — A [tuple][reference-tuple] `(T1, T2, T3, ...)`. + + > tuple-type → `T` {*[type]*} `E` + + The tag `T` is followed by one or more [type]s indicating the type of each field, followed by a terminating `E` character. + + Note that a zero-length tuple (unit) is encoded with the `u` *[basic-type]*. + +* `R` — A [reference][reference-shared-reference] `&T`. + + > ref-type → `R` *[lifetime]*opt *[type]* + + The tag `R` is followed by an optional *[lifetime]* followed by the *[type]* of the reference. + The lifetime is not included if it has been erased. + +* `Q` — A [mutable reference][reference-mutable-reference] `&mut T`. + + > mut-ref-type → `Q` *[lifetime]*opt *[type]* + + The tag `Q` is followed by an optional *[lifetime]* followed by the *[type]* of the mutable reference. + The lifetime is not included if it has been erased. + +* `P` — A [constant raw pointer][reference-raw-pointer] `*const T`. + + The tag `P` is followed by the *[type]* of the pointer. + + > const-ptr-type → `P` *[type]* + +* `O` — A [mutable raw pointer][reference-raw-pointer] `*mut T`. + + > mut-ptr-type → `O` *[type]* + + The tag `O` is followed by the *[type]* of the pointer. + +* `F` — A [function pointer][reference-fn-pointer] `fn(…) -> …`. + + > fn-type → `F` *[fn-sig]* + > + > fn-sig → *[binder]*opt `U`opt (`K` *[abi]*)opt {*[type]*} `E` *[type]* + > + > abi → \ + >       `C` \ + >    | *[undisambiguated-identifier]* + + The tag `F` is followed by a *[fn-sig]* of the function signature. + A *fn-sig* is the signature for a function pointer. + + It starts with an optional *[binder]* which represents the higher-ranked trait bounds (`for<…>`). + + Following that is an optional `U` character which is present for an `unsafe` function. + + Following that is an optional `K` character which indicates that an *[abi]* is specified. + If the ABI is not specified, it is assumed to be the `"Rust"` ABI. + + The *[abi]* can be the letter `C` to indicate it is the `"C"` ABI. + Otherwise it is an *[undisambiguated-identifier]* of the ABI string with dashes converted to underscores. + + Following that is zero or more [type]s which indicate the input parameters of the function. + + Following that is the character `E` and then the *[type]* of the return value. + +[fn-sig]: #fn-sig +[abi]: #abi + +* `D` — A [trait object][reference-trait-object] `dyn Trait + Send + 'a`. + + > dyn-trait-type → `D` *[dyn-bounds]* *[lifetime]* + > + > dyn-bounds → *[binder]*opt {*[dyn-trait]*} `E` + > + > dyn-trait → *[path]* {*[dyn-trait-assoc-binding]*} + > + > dyn-trait-assoc-binding → `p` *[undisambiguated-identifier]* *[type]* + + The tag `D` is followed by a *[dyn-bounds]* which encodes the trait bounds, + followed by a *[lifetime]* of the trait object lifetime bound. + + A *dyn-bounds* starts with an optional *[binder]* which represents the higher-ranked trait bounds (`for<…>`). + Following that is a sequence of *[dyn-trait]* terminated by the character `E`. + + Each *[dyn-trait]* represents a trait bound, which consists of a *[path]* to the trait followed by zero or more *[dyn-trait-assoc-binding]* which list the associated types. + + Each *[dyn-trait-assoc-binding]* consists of a character `p` followed a *[undisambiguated-identifier]* representing the associated binding name, and finally a *[type]*. + +[dyn-bounds]: #dyn-bounds +[dyn-trait]: #dyn-trait +[dyn-trait-assoc-binding]: #dyn-trait-assoc-binding + + +* A *[path]* to a named type. + +* A *[backref]* to refer to a previously encoded type. + +> **Recommended Demangling** +> +> A *[type]* may be displayed as the type it represents, using typical Rust syntax to represent the type. + +> Example: +> ```rust +> fn main() { +> example::<[u16; 8]>(); +> } +> +> pub fn example() {} +> ``` +> +> The symbol for function `example` is: +> +> ```text +> _RINvCs7qp2U7fqm6G_7mycrate7exampleAtj8_EB2_ +> │││├┘│ +> ││││ └─── end of generic args +> │││└───── const data 8 +> ││└────── const type usize +> │└─────── array element type u16 +> └──────── array type +> ``` +> +> Recommended demangling: `mycrate::example::<[u16; 8]>` + +### Binder +[binder]: #binder + +> binder → `G` *[base-62-number]* + +A *binder* represents the number of [higher-ranked trait bound][reference-hrtb] lifetimes to bind. +It consists of the character `G` followed by a *[base-62-number]*. +The value 1 should be added to the *[base-62-number]* when decoding +(such that the *base-62-number* encoding of `_` is interpreted as having 1 binder). + +A *lifetime* rule can then refer to these numbered lifetimes. +The lowest indices represent the innermost lifetimes. +The number of bound lifetimes is the value of *[base-62-number]* plus one. + +For example, in `for<'a, 'b> fn(for<'c> fn (...))`, any [lifetime]s in `...` +(but not inside more binders) will observe the indices 1, 2, and 3 to refer to `'c`, `'b`, and `'a`, respectively. + +> **Recommended Demangling** +> +> A *binder* may be printed using `for<…>` syntax listing the lifetimes as recommended in *[lifetime]*. +> See *[lifetime]* for an example. + +### Backref +[backref]: #backref + +> backref → `B` *[base-62-number]* + +A *backref* is used to refer to a previous part of the mangled symbol. +This provides a simple form of compression to reduce the length of the mangled symbol. +This can help reduce the amount of work and resources needed by the compiler, linker, and loader. + +It consists of the character `B` followed by a *[base-62-number]*. +The number indicates the 0-based offset in bytes starting from just after the `_R` prefix of the symbol. +The *backref* represents the corresponding element starting at that position. + +backrefs always refer to a position before the *backref* itself. + +The *backref* compression relies on the fact that all substitutable symbol elements have a self-terminating mangled form. +Given the start position of the encoded node, the grammar guarantees that it is always unambiguous where the node ends. +This is ensured by not allowing optional or repeating elements at the end of substitutable productions. + +> **Recommended Demangling** +> +> A *backref* should be demangled by rendering the element that it points to. +> Care should be considered when handling deeply nested backrefs to avoid using too much stack. + +> Example: +> ```rust +> fn main() { +> example::(); +> } +> +> struct Example; +> +> pub fn example() {} +> ``` +> +> The symbol for function `example` is: +> +> ```text +> _RINvCs7qp2U7fqm6G_7mycrate7exampleNtB2_7ExampleBw_EB2_ +> │├┘ │├┘ │├┘ +> ││ ││ ││ +> ││ ││ │└── backref to offset 3 (crate-root) +> ││ ││ └─── backref for instantiating-crate path +> ││ │└────── backref to offset 33 (path to Example) +> ││ └─────── backref for second generic-arg +> │└───────────────── backref to offset 3 (crate-root) +> └────────────────── backref for first generic-arg (first segment of Example path) +> ``` +> +> Recommended demangling: `mycrate::example::` + +### Instantiating crate +[instantiating-crate]: #instantiating-crate + +> instantiating-crate → *[path]* + +The *instantiating-crate* is an optional element of the *[symbol-name]* which can be used to indicate which crate is instantiating the symbol. +It consists of a single *[path]*. + +This helps differentiate symbols that would otherwise be identical, +for example the monomorphization of a function from an external crate may result in a duplicate if another crate is also instantiating the same generic function with the same types. + +In practice, the instantiating crate is also the crate where the symbol is defined, +so it is usually encoded as a *[backref]* to the *[crate-root]* encoded elsewhere in the symbol. + +> **Recommended Demangling** +> +> The *instantiating-crate* usually need not be displayed. + +> Example: +> ```rust +> std::path::Path::new("example"); +> ``` +> +> The symbol for `Path::new::` instantiated from the `mycrate` crate is: +> +> ```text +> _RINvMsY_NtCseXNvpPnDBDp_3std4pathNtB6_4Path3neweECs7qp2U7fqm6G_7mycrate +> └──┬───┘ +> │ +> └── instantiating crate identifier `mycrate` +> ``` +> +> Recommended demangling: `::new::` + +### Vendor-specific suffix +[vendor-specific-suffix]: #vendor-specific-suffix +[suffix]: #vendor-specific-suffix + +> vendor-specific-suffix → (`.` | `$`) *[suffix]* +> +> suffix → {*byte*} + +The *vendor-specific-suffix* is an optional element at the end of the *[symbol-name]*. +It consists of either a `.` or `$` character followed by zero or more bytes. +There are no restrictions on the characters following the period or dollar sign. + +This suffix is added as needed by the implementation. +One example where this can happen is when locally unique names need to become globally unique. +LLVM can append a `.llvm.` suffix during LTO to ensure a unique name, +and `$` can be used for thread-local data on Mach-O. +In these situations it's generally fine to ignore the suffix; +the suffixed name has the same semantics as the original. + +> **Recommended Demangling** +> +> The *vendor-specific-suffix* usually need not be displayed. + +> Example: +> ```rust +> # use std::cell::RefCell; +> thread_local! { +> pub static EXAMPLE: RefCell = RefCell::new(1); +> } +> ``` +> +> The symbol for `EXAMPLE` on macOS may have the following for thread-local data: +> +> ```text +> _RNvNvNvCs7qp2U7fqm6G_7mycrate7EXAMPLE7___getit5___KEY$tlv$init +> └───┬───┘ +> │ +> └── vendor-specific-suffix +> ``` +> +> Recommended demangling: `mycrate::EXAMPLE::__getit::__KEY` + +### Common rules +[decimal-number]: #common-rules +[digit]: #common-rules +[lower]: #common-rules +[upper]: #common-rules + +> [decimal-number] → *[digit]* {*[digit]*} +> +> [digit] → `0` | `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` +> +> [lower] → `a` |`b` |`c` |`d` |`e` |`f` |`g` |`h` |`i` |`j` |`k` |`l` |`m` |`n` |`o` |`p` |`q` |`r` |`s` |`t` |`u` |`v` |`w` |`x` |`y` |`z` +> +> [upper] → `A` | `B` | `C` | `D` | `E` | `F` | `G` | `H` | `I` | `J` | `K` | `L` | `M` | `N` | `O` | `P` | `Q` | `R` | `S` | `T` | `U` | `V` | `W` | `X` | `Y` | `Z` + +A *decimal-number* is encoded as one or more [digit]s indicating a numeric value in decimal. + +The value zero is encoded as a single byte `0`. +Beware that there are situations where `0` may be followed by another digit that should not be decoded as part of the decimal-number. +For example, a zero-length *[identifier]* within a *[nested-path]* which is in turn inside another *[nested-path]* will result in two identifiers in a row, where the first one only has the encoding of `0`. + +A *digit* is an ASCII number. + +A *lower* and *upper* is an ASCII lower and uppercase letter respectively. + +### base-62-number +[base-62-number]: #base-62-number + +> [base-62-number] → { *[digit]* | *[lower]* | *[upper]* } `_` + +A *base-62-number* is an encoding of a 64-bit numeric value. +It uses ASCII numbers and lowercase and uppercase letters. +The value is terminated with the `_` character. +If the value is 0, then the encoding is the `_` character without any digits. +Otherwise, one is subtracted from the value, and it is encoded with the mapping: + +* `0`-`9` maps to 0-9 +* `a`-`z` maps to 10 to 35 +* `A`-`Z` maps to 36 to 61 + +The number is repeatedly divided by 62 (with integer division round towards zero) +to choose the next character in the sequence. +The remainder of each division is used in the mapping to choose the next character. +This is repeated until the number is 0. +The final sequence of characters is then reversed. + +Decoding is a similar process in reverse. + +Examples: + +| Value | Encoding | +|-------|----------| +| 0 | `_` | +| 1 | `0_` | +| 11 | `a_` | +| 62 | `Z_` | +| 63 | `10_` | +| 1000 | `g7_` | + +### Symbol grammar summary +[summary]: #symbol-grammar-summary + +The following is a summary of all of the productions of the symbol grammar. + +> [symbol-name] → `_R` *[decimal-number]*opt *[path]* *[instantiating-crate]*opt *[vendor-specific-suffix]*opt +> +> [path] → \ +>       *[crate-root]* \ +>    | *[inherent-impl]* \ +>    | *[trait-impl]* \ +>    | *[trait-definition]* \ +>    | *[nested-path]* \ +>    | *[generic-args]* \ +>    | *[backref]* +> +> [crate-root] → `C` *[identifier]* \ +> [inherent-impl] → `M` *[impl-path]* *[type]* \ +> [trait-impl] → `X` *[impl-path]* *[type]* *[path]* \ +> [trait-definition] → `Y` *[type]* *[path]* \ +> [nested-path] → `N` *[namespace]* *[path]* *[identifier]* \ +> [generic-args] → `I` *[path]* {*[generic-arg]*} `E` +> +> [identifier] → *[disambiguator]*opt *[undisambiguated-identifier]* \ +> [undisambiguated-identifier] → `u`opt *[decimal-number]* `_`opt *[bytes]* \ +> [bytes] → {*UTF-8 bytes*} +> +> [disambiguator] → `s` *[base-62-number]* +> +> [impl-path] → *[disambiguator]*opt *[path]* +> +> [type] → \ +>       *[basic-type]* \ +>    | *[array-type]* \ +>    | *[slice-type]* \ +>    | *[tuple-type]* \ +>    | *[ref-type]* \ +>    | *[mut-ref-type]* \ +>    | *[const-ptr-type]* \ +>    | *[mut-ptr-type]* \ +>    | *[fn-type]* \ +>    | *[dyn-trait-type]* \ +>    | *[path]* \ +>    | *[backref]* +> +> [basic-type] → *[lower]* \ +> [array-type] → `A` *[type]* *[const]* \ +> [slice-type] → `S` *[type]* \ +> [tuple-type] → `T` {*[type]*} `E` \ +> [ref-type] → `R` *[lifetime]*opt *[type]* \ +> [mut-ref-type] → `Q` *[lifetime]*opt *[type]* \ +> [const-ptr-type] → `P` *[type]* \ +> [mut-ptr-type] → `O` *[type]* \ +> [fn-type] → `F` *[fn-sig]* \ +> [dyn-trait-type] → `D` *[dyn-bounds]* *[lifetime]* +> +> [namespace] → *[lower]* | *[upper]* +> +> [generic-arg] → \ +>       *[lifetime]* \ +>    | *[type]* \ +>    | `K` *[const]* +> +> [lifetime] → `L` *[base-62-number]* +> +> [const] → \ +>       *[type]* *[const-data]* \ +>    | `p` \ +>    | *[backref]* +> +> [const-data] → `n`opt {*[hex-digit]*} `_` +> +> [hex-digit] → *[digit]* | `a` | `b` | `c` | `d` | `e` | `f` +> +> [fn-sig] → *[binder]*opt `U`opt (`K` *[abi]*)opt {*[type]*} `E` *[type]* +> +> [abi] → \ +>       `C` \ +>    | *[undisambiguated-identifier]* +> +> [dyn-bounds] → *[binder]*opt {*[dyn-trait]*} `E` \ +> [dyn-trait] → *[path]* {*[dyn-trait-assoc-binding]*} \ +> [dyn-trait-assoc-binding] → `p` *[undisambiguated-identifier]* *[type]* +> +> [binder] → `G` *[base-62-number]* +> +> [backref] → `B` *[base-62-number]* +> +> [instantiating-crate] → *[path]* +> +> [vendor-specific-suffix] → (`.` | `$`) *[suffix]* \ +> [suffix] → {*byte*} +> +> [decimal-number] → *[digit]* {*[digit]*} +> +> [base-62-number] → { *[digit]* | *[lower]* | *[upper]* } `_` +> +> [digit] → `0` | `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` \ +> [lower] → `a` |`b` |`c` |`d` |`e` |`f` |`g` |`h` |`i` |`j` |`k` |`l` |`m` |`n` |`o` |`p` |`q` |`r` |`s` |`t` |`u` |`v` |`w` |`x` |`y` |`z` \ +> [upper] → `A` | `B` | `C` | `D` | `E` | `F` | `G` | `H` | `I` | `J` | `K` | `L` | `M` | `N` | `O` | `P` | `Q` | `R` | `S` | `T` | `U` | `V` | `W` | `X` | `Y` | `Z` + +### Encoding of Rust entities + +The following are guidelines for how Rust entities are encoded in a symbol. +The compiler has some latitude in how an entity is encoded as long as the symbol is unambiguous. + +* Named functions, methods, and statics shall be represented by a *[path]* production. + +* Paths should be rooted at the inner-most entity that can act as a path root. + Roots can be crate-ids, inherent impls, trait impls, and (for items within default methods) trait definitions. + +* The compiler is free to choose disambiguation indices and namespace tags from + the reserved ranges as long as it ascertains identifier unambiguity. + +* Generic arguments that are equal to the default should not be encoded in order to save space. + + +[RFC 2603]: https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html +[reference-array]: ../../reference/types/array.html +[reference-fn-pointer]: ../../reference/types/function-pointer.html +[reference-hrtb]: ../../reference/trait-bounds.html#higher-ranked-trait-bounds +[reference-identifiers]: ../../reference/identifiers.html +[reference-implementations]: ../../reference/items/implementations.html +[reference-inherent-impl]: ../../reference/items/implementations.html#inherent-implementations +[reference-mutable-reference]: ../../reference/types/pointer.html#mutable-references-mut +[reference-paths]: ../../reference/paths.html +[reference-raw-pointer]: ../../reference/types/pointer.html#raw-pointers-const-and-mut +[reference-shared-reference]: ../../reference/types/pointer.html#shared-references- +[reference-slice]: ../../reference/types/slice.html +[reference-track_caller]: ../../reference/attributes/codegen.html#the-track_caller-attribute +[reference-trait-impl]: ../../reference/items/implementations.html#trait-implementations +[reference-trait-object]: ../../reference/types/trait-object.html +[reference-traits]: ../../reference/items/traits.html +[reference-tuple]: ../../reference/types/tuple.html +[reference-types]: ../../reference/types.html From d5d4619e98a459fa8018c906e9f0c0352231ce17 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 1 Jun 2022 14:01:22 -0700 Subject: [PATCH 002/150] Rearrange symbol-mangling chapter out of codegen-options. --- src/doc/rustc/src/SUMMARY.md | 3 +- src/doc/rustc/src/codegen-options/index.md | 2 +- src/doc/rustc/src/symbol-mangling/index.md | 52 +++++++++ .../v0.md} | 105 +++++------------- 4 files changed, 81 insertions(+), 81 deletions(-) create mode 100644 src/doc/rustc/src/symbol-mangling/index.md rename src/doc/rustc/src/{codegen-options/symbol-mangling.md => symbol-mangling/v0.md} (94%) diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index b06f62f89166..e5ad2f1bf592 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -3,7 +3,6 @@ - [What is rustc?](what-is-rustc.md) - [Command-line Arguments](command-line-arguments.md) - [Codegen Options](codegen-options/index.md) - - [Symbol Mangling](codegen-options/symbol-mangling.md) - [Lints](lints/index.md) - [Lint Levels](lints/levels.md) - [Lint Groups](lints/groups.md) @@ -53,4 +52,6 @@ - [Instrumentation-based Code Coverage](instrument-coverage.md) - [Linker-plugin-based LTO](linker-plugin-lto.md) - [Exploit Mitigations](exploit-mitigations.md) +- [Symbol Mangling](symbol-mangling/index.md) + - [v0 Symbol Format](symbol-mangling/v0.md) - [Contributing to `rustc`](contributing.md) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index f77851cdec2d..38666ba726bd 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -577,7 +577,7 @@ change in the future. See the [Symbol Mangling] chapter for details on symbol mangling and the mangling format. [name mangling]: https://en.wikipedia.org/wiki/Name_mangling -[Symbol Mangling]: symbol-mangling.md +[Symbol Mangling]: ../symbol-mangling/index.md ## target-cpu diff --git a/src/doc/rustc/src/symbol-mangling/index.md b/src/doc/rustc/src/symbol-mangling/index.md new file mode 100644 index 000000000000..be58f2b41b8d --- /dev/null +++ b/src/doc/rustc/src/symbol-mangling/index.md @@ -0,0 +1,52 @@ +# Symbol Mangling + +[Symbol name mangling] is used by `rustc` to encode a unique name for symbols that are used during code generation. +The encoded names are used by the linker to associate the name with the thing it refers to. + +The method for mangling the names can be controlled with the [`-C symbol-mangling-version`] option. + +[Symbol name mangling]: https://en.wikipedia.org/wiki/Name_mangling +[`-C symbol-mangling-version`]: ../codegen-options/index.md#symbol-mangling-version + +## Per-item control + +The [`#[no_mangle]` attribute][reference-no_mangle] can be used on items to disable name mangling on that item. + +The [`#[export_name]`attribute][reference-export_name] can be used to specify the exact name that will be used for a function or static. + +Items listed in an [`extern` block][reference-extern-block] use the identifier of the item without mangling to refer to the item. +The [`#[link_name]` attribute][reference-link_name] can be used to change that name. + + + +[reference-no_mangle]: ../../reference/abi.html#the-no_mangle-attribute +[reference-export_name]: ../../reference/abi.html#the-export_name-attribute +[reference-link_name]: ../../reference/items/external-blocks.html#the-link_name-attribute +[reference-extern-block]: ../../reference/items/external-blocks.html + +## Decoding + +The encoded names may need to be decoded in some situations. +For example, debuggers and other tooling may need to demangle the name so that it is more readable to the user. +Recent versions of `gdb` and `lldb` have built-in support for demangling Rust identifiers. +In situations where you need to do your own demangling, the [`rustc-demangle`] crate can be used to programmatically demangle names. +[`rustfilt`] is a CLI tool which can demangle names. + +An example of running rustfilt: + +```text +$ rustfilt _RNvCskwGfYPst2Cb_3foo16example_function +foo::example_function +``` + +[`rustc-demangle`]: https://crates.io/crates/rustc-demangle +[`rustfilt`]: https://crates.io/crates/rustfilt + +## Mangling versions + +`rustc` supports different mangling versions which encode the names in different ways. +The legacy version (which is currently the default) is not described here. +The "v0" mangling scheme addresses several limitations of the legacy format, +and is described in the [v0 Symbol Format](v0.md) chapter. diff --git a/src/doc/rustc/src/codegen-options/symbol-mangling.md b/src/doc/rustc/src/symbol-mangling/v0.md similarity index 94% rename from src/doc/rustc/src/codegen-options/symbol-mangling.md rename to src/doc/rustc/src/symbol-mangling/v0.md index 1f7c4b805e3d..408e6b1244a3 100644 --- a/src/doc/rustc/src/codegen-options/symbol-mangling.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -1,57 +1,4 @@ -# Symbol Mangling - -[Symbol name mangling] is used by `rustc` to encode a unique name for symbols that are used during code generation. -The encoded names are used by the linker to associate the name with the thing it refers to. - -The method for mangling the names can be controlled with the [`-C symbol-mangling-version`] option. - -[Symbol name mangling]: https://en.wikipedia.org/wiki/Name_mangling -[`-C symbol-mangling-version`]: index.md#symbol-mangling-version - -## Per-item control - -The [`#[no_mangle]` attribute][reference-no_mangle] can be used on items to disable name mangling on that item. - -The [`#[export_name]`attribute][reference-export_name] can be used to specify the exact name that will be used for a function or static. - -Items listed in an [`extern` block][reference-extern-block] use the identifier of the item without mangling to refer to the item. -The [`#[link_name]` attribute][reference-link_name] can be used to change that name. - - - -[reference-no_mangle]: ../../reference/abi.html#the-no_mangle-attribute -[reference-export_name]: ../../reference/abi.html#the-export_name-attribute -[reference-link_name]: ../../reference/items/external-blocks.html#the-link_name-attribute -[reference-extern-block]: ../../reference/items/external-blocks.html - -## Decoding - -The encoded names may need to be decoded in some situations. -For example, debuggers and other tooling may need to demangle the name so that it is more readable to the user. -Recent versions of `gdb` and `lldb` have built-in support for demangling Rust identifiers. -In situations where you need to do your own demangling, the [`rustc-demangle`] crate can be used to programmatically demangle names. -[`rustfilt`] is a CLI tool which can demangle names. - -An example of running rustfilt: - -```text -$ rustfilt _RNvCskwGfYPst2Cb_3foo16example_function -foo::example_function -``` - -[`rustc-demangle`]: https://crates.io/crates/rustc-demangle -[`rustfilt`]: https://crates.io/crates/rustfilt - -## Mangling versions - -`rustc` supports different mangling versions which encode the names in different ways. -The legacy version (which is currently the default) is not described here. -The "v0" mangling scheme addresses several limitations of the legacy format, -and is [described below](#v0-mangling-format). - -## v0 mangling format +# v0 Symbol Format The v0 mangling format was introduced in [RFC 2603]. It has the following properties: @@ -78,7 +25,7 @@ There is no standardized demangled form of the symbols, though suggestions are provided for how to demangle a symbol. Implementers may choose to demangle in different ways. -### Grammar notation +## Grammar notation The format of an encoded symbol is illustrated as a context free grammar in an extended BNF-like syntax. A consolidated summary can be found in the [Symbol grammar summary][summary]. @@ -93,7 +40,7 @@ A consolidated summary can be found in the [Symbol grammar summary][summary]. | Option | opt | A → *B*opt *C* | An optional element. | | Literal | `monospace` | A → `G` | A terminal matching the exact characters case-sensitive. | -### Symbol name +## Symbol name [symbol-name]: #symbol-name > symbol-name → `_R` *[decimal-number]*opt *[path]* *[instantiating-crate]*opt *[vendor-specific-suffix]*opt @@ -128,7 +75,7 @@ The final part is an optional *[vendor-specific-suffix]*. > > Recommended demangling: `::new` -### Symbol path +## Symbol path [path]: #symbol-path > path → \ @@ -156,7 +103,7 @@ The initial tag character can be used to determine which kind of path it represe | `I` | *[generic-args]* | Generic arguments. | | `B` | *[backref]* | A back reference. | -#### Path: Crate root +### Path: Crate root [crate-root]: #path-crate-root > crate-root → `C` *[identifier]* @@ -196,7 +143,7 @@ the *[disambiguator]* is used to make the name unique across the crate graph. > > Recommended demangling: `mycrate::example` -#### Path: Inherent impl +### Path: Inherent impl [inherent-impl]: #path-inherent-impl > inherent-impl → `M` *[impl-path]* *[type]* @@ -230,7 +177,7 @@ It consists of the character `M` followed by an *[impl-path]* to the impl's pare > > Recommended demangling: `::foo` -#### Path: Trait impl +### Path: Trait impl [trait-impl]: #path-trait-impl > trait-impl → `X` *[impl-path]* *[type]* *[path]* @@ -268,7 +215,7 @@ It consists of the character `X` followed by an *[impl-path]* to the impl's pare > > Recommended demangling: `::foo` -#### Path: Impl +### Path: Impl [impl-path]: #path-impl > impl-path → *[disambiguator]*opt *[path]* @@ -316,7 +263,7 @@ The *[disambiguator]* can be used to distinguish between multiple impls within t > * `foo`: `::foo` > * `bar`: `::bar` -#### Path: Trait definition +### Path: Trait definition [trait-definition]: #path-trait-definition > trait-definition → `Y` *[type]* *[path]* @@ -350,7 +297,7 @@ It consists of the character `Y` followed by the *[type]* which is the `Self` ty > > Recommended demangling: `::example` -#### Path: Nested path +### Path: Nested path [nested-path]: #path-nested-path > nested-path → `N` *[namespace]* *[path]* *[identifier]* @@ -415,7 +362,7 @@ For example, entities like closures, tuple-like struct constructors, and anonymo > * `x`: `mycrate::main::{closure#0}` > * `y`: `mycrate::main::{closure#1}` -#### Path: Generic arguments +### Path: Generic arguments [generic-args]: #path-generic-arguments [generic-arg]: #path-generic-arguments @@ -462,7 +409,7 @@ Each *[generic-arg]* is either a *[lifetime]* (starting with the character `L`), > > Recommended demangling: `mycrate::example::` -#### Namespace +### Namespace [namespace]: #namespace > namespace → *[lower]* | *[upper]* @@ -482,7 +429,7 @@ Uppercase namespaces are: > > See *[nested-path]* for recommended demangling. -### Identifier +## Identifier [identifier]: #identifier [undisambiguated-identifier]: #identifier [bytes]: #identifier @@ -515,7 +462,7 @@ The `_` is mandatory if the *bytes* starts with a decimal digit or `_` in order > > The *[disambiguator]* may or may not be displayed; see recommendations for rules that use *identifier*. -#### Punycode identifiers +### Punycode identifiers [Punycode identifiers]: #punycode-identifiers Because some environments are restricted to ASCII alphanumerics and `_`, @@ -565,7 +512,7 @@ Here are some examples: [Punycode]: https://tools.ietf.org/html/rfc3492 -### Disambiguator +## Disambiguator [disambiguator]: #disambiguator > disambiguator → `s` *[base-62-number]* @@ -582,7 +529,7 @@ This allows disambiguators that are encoded sequentially to use minimal bytes. > > The *disambiguator* may or may not be displayed; see recommendations for rules that use *disambiguator*. -### Lifetime +## Lifetime [lifetime]: #lifetime > lifetime → `L` *[base-62-number]* @@ -632,7 +579,7 @@ Indices starting from 1 refer (as de Bruijn indices) to a higher-ranked lifetime > > Recommended demangling: `mycrate::example:: fn(&'a u8, &'b u16)>` -### Const +## Const [const]: #const [const-data]: #const [hex-digit]: #const @@ -695,7 +642,7 @@ The encoding of the *const-data* depends on the type: > Recommended demangling: `mycrate::example::<305419896>` -### Type +## Type [type]: #type [basic-type]: #basic-type [array-type]: #array-type @@ -881,7 +828,7 @@ The type encodings based on the initial tag character are: > > Recommended demangling: `mycrate::example::<[u16; 8]>` -### Binder +## Binder [binder]: #binder > binder → `G` *[base-62-number]* @@ -903,7 +850,7 @@ For example, in `for<'a, 'b> fn(for<'c> fn (...))`, any [lifetime]s in > A *binder* may be printed using `for<…>` syntax listing the lifetimes as recommended in *[lifetime]*. > See *[lifetime]* for an example. -### Backref +## Backref [backref]: #backref > backref → `B` *[base-62-number]* @@ -954,7 +901,7 @@ This is ensured by not allowing optional or repeating elements at the end of sub > > Recommended demangling: `mycrate::example::` -### Instantiating crate +## Instantiating crate [instantiating-crate]: #instantiating-crate > instantiating-crate → *[path]* @@ -988,7 +935,7 @@ so it is usually encoded as a *[backref]* to the *[crate-root]* encoded elsewher > > Recommended demangling: `::new::` -### Vendor-specific suffix +## Vendor-specific suffix [vendor-specific-suffix]: #vendor-specific-suffix [suffix]: #vendor-specific-suffix @@ -1030,7 +977,7 @@ the suffixed name has the same semantics as the original. > > Recommended demangling: `mycrate::EXAMPLE::__getit::__KEY` -### Common rules +## Common rules [decimal-number]: #common-rules [digit]: #common-rules [lower]: #common-rules @@ -1054,7 +1001,7 @@ A *digit* is an ASCII number. A *lower* and *upper* is an ASCII lower and uppercase letter respectively. -### base-62-number +## base-62-number [base-62-number]: #base-62-number > [base-62-number] → { *[digit]* | *[lower]* | *[upper]* } `_` @@ -1088,7 +1035,7 @@ Examples: | 63 | `10_` | | 1000 | `g7_` | -### Symbol grammar summary +## Symbol grammar summary [summary]: #symbol-grammar-summary The following is a summary of all of the productions of the symbol grammar. @@ -1189,7 +1136,7 @@ The following is a summary of all of the productions of the symbol grammar. > [lower] → `a` |`b` |`c` |`d` |`e` |`f` |`g` |`h` |`i` |`j` |`k` |`l` |`m` |`n` |`o` |`p` |`q` |`r` |`s` |`t` |`u` |`v` |`w` |`x` |`y` |`z` \ > [upper] → `A` | `B` | `C` | `D` | `E` | `F` | `G` | `H` | `I` | `J` | `K` | `L` | `M` | `N` | `O` | `P` | `Q` | `R` | `S` | `T` | `U` | `V` | `W` | `X` | `Y` | `Z` -### Encoding of Rust entities +## Encoding of Rust entities The following are guidelines for how Rust entities are encoded in a symbol. The compiler has some latitude in how an entity is encoded as long as the symbol is unambiguous. From ddd26b46cdd7d37e88b7908d956a85bd97f1a744 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 1 Jun 2022 14:03:41 -0700 Subject: [PATCH 003/150] Remove 64-bit limit for base-62-numbers. Demanglers should be prepared for any arbitrary length number. --- src/doc/rustc/src/symbol-mangling/v0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 408e6b1244a3..1d7992e077d9 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -1006,7 +1006,7 @@ A *lower* and *upper* is an ASCII lower and uppercase letter respectively. > [base-62-number] → { *[digit]* | *[lower]* | *[upper]* } `_` -A *base-62-number* is an encoding of a 64-bit numeric value. +A *base-62-number* is an encoding of a numeric value. It uses ASCII numbers and lowercase and uppercase letters. The value is terminated with the `_` character. If the value is 0, then the encoding is the `_` character without any digits. From d782e8748b441335c4bed80ae791a60b770658f2 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 9 Jun 2022 19:09:47 -0700 Subject: [PATCH 004/150] Update from review from michaelwoerister. --- src/doc/rustc/src/symbol-mangling/v0.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 1d7992e077d9..797491a4ab30 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -149,7 +149,8 @@ the *[disambiguator]* is used to make the name unique across the crate graph. > inherent-impl → `M` *[impl-path]* *[type]* An *inherent-impl* indicates a path to an [inherent implementation][reference-inherent-impl]. -It consists of the character `M` followed by an *[impl-path]* to the impl's parent followed by the *[type]* representing the `Self` type of the impl. +It consists of the character `M` followed by an *[impl-path]*, which uniquely identifies the impl block the item is defined in. +Following that is a *[type]* representing the `Self` type of the impl. > **Recommended Demangling** > @@ -167,12 +168,13 @@ It consists of the character `M` followed by an *[impl-path]* to the impl's pare > The symbol for `foo` in the impl for `Example` is: > > ```text -> _RNvMCs15kBYyAo9fc_7mycrateNtB2_7Example3foo -> │└─────────┬──────────┘└────┬──────┘ -> │ │ │ -> │ │ └── Self type "Example" -> │ └─────────────────── path to the impl's parent "mycrate" -> └────────────────────────────── inherent-impl +> _RNvMs_Cs4Cv8Wi1oAIB_7mycrateNtB4_7Example3foo +> │├┘└─────────┬──────────┘└────┬──────┘ +> ││ │ │ +> ││ │ └── Self type "Example" +> ││ └─────────────────── path to the impl's parent "mycrate" +> │└─────────────────────────────── disambiguator 1 +> └──────────────────────────────── inherent-impl > ``` > > Recommended demangling: `::foo` @@ -307,8 +309,9 @@ It consists of the character `N` followed by a *[namespace]* indicating the name followed by a *[path]* which is a path representing the parent of the entity, followed by an *[identifier]* of the entity. -The identifier of the entity may be empty when the entity is not named. +The identifier of the entity may have a length of 0 when the entity is not named. For example, entities like closures, tuple-like struct constructors, and anonymous constants may not have a name. +The identifier may still have a disambiguator unless the disambiguator is 0. > **Recommended Demangling** > @@ -912,7 +915,7 @@ It consists of a single *[path]*. This helps differentiate symbols that would otherwise be identical, for example the monomorphization of a function from an external crate may result in a duplicate if another crate is also instantiating the same generic function with the same types. -In practice, the instantiating crate is also the crate where the symbol is defined, +In practice, the instantiating crate is also often the crate where the symbol is defined, so it is usually encoded as a *[backref]* to the *[crate-root]* encoded elsewhere in the symbol. > **Recommended Demangling** From 769f938aea2c0d270cafc8f66c283d98461f701a Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 10 Jun 2022 11:15:13 -0700 Subject: [PATCH 005/150] Clarify missing tick. --- src/doc/rustc/src/symbol-mangling/v0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 797491a4ab30..dfd53434251c 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -548,7 +548,7 @@ Indices starting from 1 refer (as de Bruijn indices) to a higher-ranked lifetime > Index 0 should be displayed as `'_`. > > Lifetimes starting from 1 may be translated to single lowercase letters starting with `'a`. -> Indices over 25 may consider printing the numeric lifetime index as in `_123`. +> Indices over 25 may consider printing the numeric lifetime index as in `'_123`. > > Index 0 should not be displayed for lifetimes in a *[ref-type]*, *[mut-ref-type]*, or *[dyn-trait-type]*. > From 9e0c19d5c20d2f5e2323e1b9f0fadd3276df4daf Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 10 Jun 2022 11:16:48 -0700 Subject: [PATCH 006/150] Clarify grammar for decimal-number cannot have leading zeroes. --- src/doc/rustc/src/symbol-mangling/v0.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index dfd53434251c..fbb813a339a8 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -983,12 +983,16 @@ the suffixed name has the same semantics as the original. ## Common rules [decimal-number]: #common-rules [digit]: #common-rules +[non-zero-digit]: #common-rules [lower]: #common-rules [upper]: #common-rules -> [decimal-number] → *[digit]* {*[digit]*} +> [decimal-number] → \ +>       `0` \ +>    | *[non-zero-digit]* {*[digit]*} > -> [digit] → `0` | `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` +> [non-zero-digit] → `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` \ +> [digit] → `0` | *[non-zero-digit]* > > [lower] → `a` |`b` |`c` |`d` |`e` |`f` |`g` |`h` |`i` |`j` |`k` |`l` |`m` |`n` |`o` |`p` |`q` |`r` |`s` |`t` |`u` |`v` |`w` |`x` |`y` |`z` > @@ -1131,11 +1135,14 @@ The following is a summary of all of the productions of the symbol grammar. > [vendor-specific-suffix] → (`.` | `$`) *[suffix]* \ > [suffix] → {*byte*} > -> [decimal-number] → *[digit]* {*[digit]*} +> [decimal-number] → \ +>       `0` \ +>    | *[non-zero-digit]* {*[digit]*} > > [base-62-number] → { *[digit]* | *[lower]* | *[upper]* } `_` > -> [digit] → `0` | `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` \ +> [non-zero-digit] → `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | `9` \ +> [digit] → `0` | *[non-zero-digit]* \ > [lower] → `a` |`b` |`c` |`d` |`e` |`f` |`g` |`h` |`i` |`j` |`k` |`l` |`m` |`n` |`o` |`p` |`q` |`r` |`s` |`t` |`u` |`v` |`w` |`x` |`y` |`z` \ > [upper] → `A` | `B` | `C` | `D` | `E` | `F` | `G` | `H` | `I` | `J` | `K` | `L` | `M` | `N` | `O` | `P` | `Q` | `R` | `S` | `T` | `U` | `V` | `W` | `X` | `Y` | `Z` From 0e66b0024cbdbc30e97c226292461e1b608a424a Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 10 Jun 2022 11:28:30 -0700 Subject: [PATCH 007/150] Rewrite recommended demangling for lifetimes using "De Bruijn level". --- src/doc/rustc/src/symbol-mangling/v0.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index fbb813a339a8..2bd17cd28fed 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -545,14 +545,14 @@ Indices starting from 1 refer (as de Bruijn indices) to a higher-ranked lifetime > **Recommended Demangling** > > A *lifetime* may be displayed like a Rust lifetime using a single quote. +> > Index 0 should be displayed as `'_`. -> -> Lifetimes starting from 1 may be translated to single lowercase letters starting with `'a`. -> Indices over 25 may consider printing the numeric lifetime index as in `'_123`. -> > Index 0 should not be displayed for lifetimes in a *[ref-type]*, *[mut-ref-type]*, or *[dyn-trait-type]*. > -> Nested binders may consider tracking their indices so that lifetime lettering can start back with `'a` within a nested binder. +> A lifetime can be displayed by converting the De Bruijn index to a De Bruijn level +> (level = number of bound lifetimes - index) and selecting a unique name for each level. +> For example, starting with single lowercase letters such as `'a` for level 0. +> Levels over 25 may consider printing the numeric lifetime as in `'_123`. > See *[binder]* for more on lifetime indexes and ordering. > Example: From b2d401f6a5959a5047176fa8398e5f27a363c7d9 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 19:02:30 -0700 Subject: [PATCH 008/150] Add an example of placeholders. --- src/doc/rustc/src/symbol-mangling/v0.md | 36 +++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 2bd17cd28fed..4f130191bfa7 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -600,7 +600,7 @@ A *const* is used to encode a const value used in generics and types. It has the following forms: * A constant value encoded as a *[type]* which represents the type of the constant and *[const-data]* which is the constant value, followed by `_` to terminate the *const*. -* The character `p` which represents a placeholder. +* The character `p` which represents a [placeholder]. * A *[backref]* to a previously encoded *const* of the same value. The encoding of the *const-data* depends on the type: @@ -644,6 +644,38 @@ The encoding of the *const-data* depends on the type: > > Recommended demangling: `mycrate::example::<305419896>` +### Placeholders +[placeholder]: #placeholders + +A *placeholder* may occur in circumstances where a type or const value is not relevant. + +> Example: +> ```rust +> pub struct Example([T; N]); +> +> impl Example { +> pub fn foo() -> &'static () { +> static EXAMPLE_STATIC: () = (); +> &EXAMPLE_STATIC +> } +> } +> ``` +> +> In this example, the static `EXAMPLE_STATIC` would not be monomorphized by the type or const parameters `T` and `N`. +> Those will use the placeholder for those generic arguments. +> Its symbol is: +> +> ```text +> _RNvNvMCsd9PVOYlP1UU_7mycrateINtB4_7ExamplepKpE3foo14EXAMPLE_STATIC +> │ │││ +> │ ││└── const placeholder +> │ │└─── const generic argument +> │ └──── type placeholder +> └────────────────── generic-args +> ``` +> +> Recommended demangling: `>::foo::EXAMPLE_STATIC` + ## Type [type]: #type @@ -697,7 +729,7 @@ The type encodings based on the initial tag character are: * `x` — `i64` * `y` — `u64` * `z` — `!` - * `p` — placeholder `_` + * `p` — [placeholder] `_` * `A` — An [array][reference-array] `[T; N]`. From ceda03d3c7a17708f69ef2a91b369e08c1139a3f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 13 May 2023 19:48:45 -0700 Subject: [PATCH 009/150] Add missing word "the". --- src/doc/rustc/src/symbol-mangling/v0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 4f130191bfa7..50075e729634 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -5,7 +5,7 @@ It has the following properties: - It provides an unambiguous string encoding for everything that can end up in a binary's symbol table. - It encodes information about generic parameters in a reversible way. -- The mangled symbols are *decodable* such that demangled form should be easily identifiable as some concrete instance of e.g. a polymorphic function. +- The mangled symbols are *decodable* such that the demangled form should be easily identifiable as some concrete instance of e.g. a polymorphic function. - It has a consistent definition that does not rely on pretty-printing certain language constructs. - Symbols can be restricted to only consist of the characters `A-Z`, `a-z`, `0-9`, and `_`. This helps ensure that it is platform-independent, From d376e63384d7b0ad467bb0464eaf15f737f72666 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 5 Jun 2023 11:55:16 -0700 Subject: [PATCH 010/150] Add description of forwards-compatible behavior. --- src/doc/rustc/src/symbol-mangling/v0.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 50075e729634..13f7be315c95 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -25,6 +25,14 @@ There is no standardized demangled form of the symbols, though suggestions are provided for how to demangle a symbol. Implementers may choose to demangle in different ways. +## Extensions + +This format may be extended in the future to add new tags as Rust is extended with new language items. +To be forward compatible, demanglers should gracefully handle symbols that have encodings where it encounters a tag character not described in this document. +For example, they may fall back to displaying the mangled symbol. +The format may be extended anywhere there is a tag character, such as the [type] rule. +The meaning of existing tags and encodings will not be changed. + ## Grammar notation The format of an encoded symbol is illustrated as a context free grammar in an extended BNF-like syntax. From 2f093c67eadbf763601fd195dfc0d3e0c421fe82 Mon Sep 17 00:00:00 2001 From: MoskalykA <100430077+MoskalykA@users.noreply.github.com> Date: Wed, 7 Jun 2023 18:40:25 +0200 Subject: [PATCH 011/150] Move two tests from `tests/ui/std` to `library/std/tests` --- .../std => library/std/tests}/issue-15149.rs | 31 +++---------------- .../std/tests}/switch-stdout.rs | 23 +++++++------- 2 files changed, 16 insertions(+), 38 deletions(-) rename {tests/ui/std => library/std/tests}/issue-15149.rs (52%) rename {tests/ui/std => library/std/tests}/switch-stdout.rs (70%) diff --git a/tests/ui/std/issue-15149.rs b/library/std/tests/issue-15149.rs similarity index 52% rename from tests/ui/std/issue-15149.rs rename to library/std/tests/issue-15149.rs index 064472f5785a..52e5b55fb9d4 100644 --- a/tests/ui/std/issue-15149.rs +++ b/library/std/tests/issue-15149.rs @@ -1,38 +1,17 @@ -// run-pass - -#![allow(unused_variables)] -// no-prefer-dynamic -// ignore-cross-compile - use std::env; -use std::ffi::OsStr; use std::fs; -use std::path::PathBuf; use std::process; use std::str; -fn main() { - // If we're the child, make sure we were invoked correctly - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - // FIXME: This should check the whole `args[0]` instead of just - // checking that it ends_with the executable name. This - // is needed because of Windows, which has a different behavior. - // See #15149 for more info. - let my_path = env::current_exe().unwrap(); - return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest"))); - } +mod common; - test(); -} - -fn test() { +#[test] +fn issue_15149() { // If we're the parent, copy our own binary to a new directory. let my_path = env::current_exe().unwrap(); - let my_dir = my_path.parent().unwrap(); - let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); - let child_dir = child_dir.join("issue-15140-child"); + let temp = common::tmpdir(); + let child_dir = temp.join("issue-15140-child"); fs::create_dir_all(&child_dir).unwrap(); let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX)); diff --git a/tests/ui/std/switch-stdout.rs b/library/std/tests/switch-stdout.rs similarity index 70% rename from tests/ui/std/switch-stdout.rs rename to library/std/tests/switch-stdout.rs index 2d936d96b059..2f01504043d6 100644 --- a/tests/ui/std/switch-stdout.rs +++ b/library/std/tests/switch-stdout.rs @@ -1,10 +1,7 @@ -// run-pass -// ignore-wasm (needs file descriptors and env variables) - -use std::env; use std::fs::File; use std::io::{Read, Write}; -use std::path::PathBuf; + +mod common; #[cfg(unix)] fn switch_stdout_to(file: File) { @@ -35,16 +32,18 @@ fn switch_stdout_to(file: File) { } } -fn main() { - let path = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); - let path = path.join("switch-stdout-output"); +#[test] +fn switch_stdout() { + let temp = common::tmpdir(); + let path = temp.join("switch-stdout-output"); let f = File::create(&path).unwrap(); - println!("foo"); - std::io::stdout().flush().unwrap(); + let mut stdout = std::io::stdout(); + stdout.write(b"foo\n").unwrap(); + stdout.flush().unwrap(); switch_stdout_to(f); - println!("bar"); - std::io::stdout().flush().unwrap(); + stdout.write(b"bar\n").unwrap(); + stdout.flush().unwrap(); let mut contents = String::new(); File::open(&path).unwrap().read_to_string(&mut contents).unwrap(); From 4227c0a406f31b7a2b2f4423541234d480a66e70 Mon Sep 17 00:00:00 2001 From: MoskalykA <100430077+MoskalykA@users.noreply.github.com> Date: Wed, 7 Jun 2023 21:51:57 +0200 Subject: [PATCH 012/150] Make Unix or Windows mandatory for the `switch-stdout.rs` test --- library/std/tests/switch-stdout.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/tests/switch-stdout.rs b/library/std/tests/switch-stdout.rs index 2f01504043d6..28ce6dfccd35 100644 --- a/library/std/tests/switch-stdout.rs +++ b/library/std/tests/switch-stdout.rs @@ -1,3 +1,5 @@ +#[cfg(any(target_family = "unix", target_family = "windows"))] + use std::fs::File; use std::io::{Read, Write}; From 3adedc93a9de239a6476833841fba9c1a9796af3 Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 7 May 2021 20:00:17 +0200 Subject: [PATCH 013/150] update auto trait handling --- .../src/traits/select/candidate_assembly.rs | 52 +++++- .../src/traits/select/mod.rs | 25 ++- tests/ui/auto-traits/issue-83857-ub.rs | 31 ++++ tests/ui/auto-traits/issue-83857-ub.stderr | 22 +++ tests/ui/generator/auto-trait-regions.rs | 6 +- tests/ui/impl-trait/auto-trait-leak | 0 ...l-trait-type-indirect.drop_tracking.stderr | 42 ++--- ...ait-type-indirect.drop_tracking_mir.stderr | 42 ++--- ...rait-type-indirect.no_drop_tracking.stderr | 42 ++--- .../recursive-impl-trait-type-indirect.rs | 1 - ...rait-type-indirect.no_drop_tracking.stderr | 154 ++++++++++++++++++ 11 files changed, 339 insertions(+), 78 deletions(-) create mode 100644 tests/ui/auto-traits/issue-83857-ub.rs create mode 100644 tests/ui/auto-traits/issue-83857-ub.stderr create mode 100644 tests/ui/impl-trait/auto-trait-leak create mode 100644 tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index a03292597057..d10998cfed71 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -124,11 +124,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.assemble_candidates_from_projected_tys(obligation, &mut candidates); self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?; - // Auto implementations have lower priority, so we only - // consider triggering a default if there is no other impl that can apply. - if candidates.vec.is_empty() { - self.assemble_candidates_from_auto_impls(obligation, &mut candidates); - } + self.assemble_candidates_from_auto_impls(obligation, &mut candidates); } debug!("candidate list size: {}", candidates.vec.len()); Ok(candidates) @@ -516,7 +512,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // for an example of a test case that exercises // this path. } - ty::Infer(ty::TyVar(_)) => { + ty::Infer(ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_)) => { // The auto impl might apply; we don't know. candidates.ambiguous = true; } @@ -536,7 +532,49 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } - _ => candidates.vec.push(AutoImplCandidate), + ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { + bug!( + "asked to assemble auto trait candidates of unexpected type: {:?}", + self_ty + ); + } + + // Only consider auto impls if there are no manual impls for the root of `self_ty`. + // + // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl + // for `&SomeType: Auto` exists. Due to E0321 the only crate where impls + // for `&SomeType: Auto` can be defined is the crate where `Auto` has been defined. + // + // Generally, we have to guarantee that for all `SimplifiedType`s the only crate + // which may define impls for that type is either the crate defining the type + // or the trait. This should be guaranteed by the orphan check. + ty::Bool + | ty::Char + | ty::Int(_) + | ty::Uint(_) + | ty::Float(_) + | ty::Str + | ty::Array(_, _) + | ty::Slice(_) + | ty::Adt(..) + | ty::RawPtr(_) + | ty::Ref(..) + | ty::FnDef(..) + | ty::FnPtr(_) + | ty::Closure(_, _) + | ty::Generator(..) + | ty::Never + | ty::Tuple(_) + | ty::Alias(_, _) + | ty::GeneratorWitness(_) + | ty::GeneratorWitnessMIR(..) => { + let mut has_impl = false; + self.tcx().for_each_relevant_impl(def_id, self_ty, |_| has_impl = true); + if !has_impl { + candidates.vec.push(AutoImplCandidate) + } + } + ty::Error(_) => {} // do not add an auto trait impl for `ty::Error` for now. } } } diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 26ed1481228f..03f7f7dc9f23 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1814,6 +1814,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { /// candidates and prefer where-clause candidates. /// /// See the comment for "SelectionCandidate" for more details. + #[instrument(level = "debug", skip(self))] fn candidate_should_be_dropped_in_favor_of( &mut self, victim: &EvaluatedCandidate<'tcx>, @@ -1837,13 +1838,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> { // This is a fix for #53123 and prevents winnowing from accidentally extending the // lifetime of a variable. match (&other.candidate, &victim.candidate) { - (_, AutoImplCandidate) | (AutoImplCandidate, _) => { - bug!( - "default implementations shouldn't be recorded \ - when there are other valid candidates" - ); - } - // FIXME(@jswrenn): this should probably be more sophisticated (TransmutabilityCandidate, _) | (_, TransmutabilityCandidate) => DropVictim::No, @@ -1885,6 +1879,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ( ParamCandidate(ref other_cand), ImplCandidate(..) + | AutoImplCandidate | ClosureCandidate { .. } | GeneratorCandidate | FutureCandidate @@ -1912,6 +1907,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { } ( ImplCandidate(_) + | AutoImplCandidate | ClosureCandidate { .. } | GeneratorCandidate | FutureCandidate @@ -1945,6 +1941,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ( ObjectCandidate(_) | ProjectionCandidate(..), ImplCandidate(..) + | AutoImplCandidate | ClosureCandidate { .. } | GeneratorCandidate | FutureCandidate @@ -1958,6 +1955,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ( ImplCandidate(..) + | AutoImplCandidate | ClosureCandidate { .. } | GeneratorCandidate | FutureCandidate @@ -2048,6 +2046,19 @@ impl<'tcx> SelectionContext<'_, 'tcx> { } } + (AutoImplCandidate, ImplCandidate(_)) | (ImplCandidate(_), AutoImplCandidate) => { + DropVictim::No + } + + (AutoImplCandidate, _) | (_, AutoImplCandidate) => { + bug!( + "default implementations shouldn't be recorded \ + when there are other global candidates: {:?} {:?}", + other, + victim + ); + } + // Everything else is ambiguous ( ImplCandidate(_) diff --git a/tests/ui/auto-traits/issue-83857-ub.rs b/tests/ui/auto-traits/issue-83857-ub.rs new file mode 100644 index 000000000000..0a8865295c63 --- /dev/null +++ b/tests/ui/auto-traits/issue-83857-ub.rs @@ -0,0 +1,31 @@ +#![allow(suspicious_auto_trait_impls)] + +struct Always(T, U); +unsafe impl Send for Always {} +struct Foo(Always); + +trait False {} +unsafe impl Send for Foo {} + +trait WithAssoc { + type Output; +} +impl WithAssoc for T { + type Output = Self; +} +impl WithAssoc for Foo { + type Output = Box; +} + +fn generic(v: Foo, f: fn( as WithAssoc>::Output) -> i32) { + //~^ ERROR `Foo` cannot be sent between threads safely + f(foo(v)); +} + +fn foo(x: T) -> ::Output { + x +} + +fn main() { + generic(Foo(Always(0, ())), |b| *b); +} diff --git a/tests/ui/auto-traits/issue-83857-ub.stderr b/tests/ui/auto-traits/issue-83857-ub.stderr new file mode 100644 index 000000000000..d2aef17e7f8d --- /dev/null +++ b/tests/ui/auto-traits/issue-83857-ub.stderr @@ -0,0 +1,22 @@ +error[E0277]: `Foo` cannot be sent between threads safely + --> $DIR/issue-83857-ub.rs:20:38 + | +LL | fn generic(v: Foo, f: fn( as WithAssoc>::Output) -> i32) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be sent between threads safely + | + = help: the trait `Send` is not implemented for `Foo` +note: required for `Foo` to implement `WithAssoc` + --> $DIR/issue-83857-ub.rs:13:15 + | +LL | impl WithAssoc for T { + | ---- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn generic(v: Foo, f: fn( as WithAssoc>::Output) -> i32) where Foo: Send { + | +++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/auto-trait-regions.rs b/tests/ui/generator/auto-trait-regions.rs index fd13e41319f0..350f3cc34ce5 100644 --- a/tests/ui/generator/auto-trait-regions.rs +++ b/tests/ui/generator/auto-trait-regions.rs @@ -26,7 +26,7 @@ fn assert_foo(f: T) {} fn main() { // Make sure 'static is erased for generator interiors so we can't match it in trait selection let x: &'static _ = &OnlyFooIfStaticRef(No); - let gen = || { + let gen = move || { let x = x; yield; assert_foo(x); @@ -36,7 +36,7 @@ fn main() { // Allow impls which matches any lifetime let x = &OnlyFooIfRef(No); - let gen = || { + let gen = move || { let x = x; yield; assert_foo(x); @@ -44,7 +44,7 @@ fn main() { assert_foo(gen); // ok // Disallow impls which relates lifetimes in the generator interior - let gen = || { + let gen = move || { let a = A(&mut true, &mut true, No); //~^ temporary value dropped while borrowed //~| temporary value dropped while borrowed diff --git a/tests/ui/impl-trait/auto-trait-leak b/tests/ui/impl-trait/auto-trait-leak new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr index 43118ae38540..8b6a55558cf3 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr @@ -123,30 +123,32 @@ LL | | x; LL | | } | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]` -error[E0720]: cannot resolve opaque type +error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion_b() - | -------------------- returning here with type `impl Sized` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ---------- returning this opaque type `impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 + | ^^^^^^^^^ + | +note: ...which requires type-checking `mutual_recursion`... + --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | --------- returning this opaque type `impl Sync` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion() - | ------------------ returning here with type `impl Sync` + | ^^^^^^^^^ + = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... + = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 + | +LL | / #![feature(generators)] +LL | | #![allow(unconditional_recursion)] +LL | | +LL | | fn option(i: i32) -> impl Sized { +... | +LL | | +LL | | fn main() {} + | |____________^ -error: aborting due to 14 previous errors +error: aborting due to 13 previous errors -For more information about this error, try `rustc --explain E0720`. +Some errors have detailed explanations: E0391, E0720. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr index 9c67f17e9635..0c84fa026196 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr @@ -118,30 +118,32 @@ LL | fn generator_hold() -> impl Sized { LL | let x = generator_hold(); | - generator captures itself here -error[E0720]: cannot resolve opaque type +error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion_b() - | -------------------- returning here with type `impl Sized` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ---------- returning this opaque type `impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 + | ^^^^^^^^^ + | +note: ...which requires type-checking `mutual_recursion`... + --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | --------- returning this opaque type `impl Sync` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion() - | ------------------ returning here with type `impl Sync` + | ^^^^^^^^^ + = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... + = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 + | +LL | / #![feature(generators)] +LL | | #![allow(unconditional_recursion)] +LL | | +LL | | fn option(i: i32) -> impl Sized { +... | +LL | | +LL | | fn main() {} + | |____________^ -error: aborting due to 14 previous errors +error: aborting due to 13 previous errors -For more information about this error, try `rustc --explain E0720`. +Some errors have detailed explanations: E0391, E0720. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr index 43118ae38540..8b6a55558cf3 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr @@ -123,30 +123,32 @@ LL | | x; LL | | } | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]` -error[E0720]: cannot resolve opaque type +error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion_b() - | -------------------- returning here with type `impl Sized` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ---------- returning this opaque type `impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 + | ^^^^^^^^^ + | +note: ...which requires type-checking `mutual_recursion`... + --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | --------- returning this opaque type `impl Sync` -... -LL | fn mutual_recursion_b() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | mutual_recursion() - | ------------------ returning here with type `impl Sync` + | ^^^^^^^^^ + = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... + = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 + | +LL | / #![feature(generators)] +LL | | #![allow(unconditional_recursion)] +LL | | +LL | | fn option(i: i32) -> impl Sized { +... | +LL | | +LL | | fn main() {} + | |____________^ -error: aborting due to 14 previous errors +error: aborting due to 13 previous errors -For more information about this error, try `rustc --explain E0720`. +Some errors have detailed explanations: E0391, E0720. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs index 630372e13ed5..9d3793940c04 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs @@ -93,7 +93,6 @@ fn mutual_recursion() -> impl Sync { } fn mutual_recursion_b() -> impl Sized { - //~^ ERROR mutual_recursion() } diff --git a/tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr b/tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr new file mode 100644 index 000000000000..8b6a55558cf3 --- /dev/null +++ b/tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr @@ -0,0 +1,154 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:11:22 + | +LL | fn option(i: i32) -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | if i < 0 { None } else { Some((option(i - 1), i)) } + | ---- ------------------------ returning here with type `Option<(impl Sized, i32)>` + | | + | returning here with type `Option<(impl Sized, i32)>` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:16:15 + | +LL | fn tuple() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | (tuple(),) + | ---------- returning here with type `(impl Sized,)` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:21:15 + | +LL | fn array() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | [array()] + | --------- returning here with type `[impl Sized; 1]` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:26:13 + | +LL | fn ptr() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | &ptr() as *const _ + | ------------------ returning here with type `*const impl Sized` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:31:16 + | +LL | fn fn_ptr() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | fn_ptr as fn() -> _ + | ------------------- returning here with type `fn() -> impl Sized` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:36:25 + | +LL | fn closure_capture() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +... +LL | / move || { +LL | | x; + | | - closure captures itself here +LL | | } + | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12]` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:44:29 + | +LL | fn closure_ref_capture() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +... +LL | / move || { +LL | | &x; + | | - closure captures itself here +LL | | } + | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12]` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:52:21 + | +LL | fn closure_sig() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | || closure_sig() + | ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7]` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:57:23 + | +LL | fn generator_sig() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | || generator_sig() + | ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7]` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:62:27 + | +LL | fn generator_capture() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +... +LL | / move || { +LL | | yield; +LL | | x; + | | - generator captures itself here +LL | | } + | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12]` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:71:35 + | +LL | fn substs_change() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | (substs_change::<&T>(),) + | ------------------------ returning here with type `(impl Sized,)` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:76:24 + | +LL | fn generator_hold() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | / move || { +LL | | let x = generator_hold(); + | | - generator captures itself here +LL | | yield; +LL | | x; +LL | | } + | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]` + +error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` + --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 + | +LL | fn mutual_recursion() -> impl Sync { + | ^^^^^^^^^ + | +note: ...which requires type-checking `mutual_recursion`... + --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 + | +LL | fn mutual_recursion() -> impl Sync { + | ^^^^^^^^^ + = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... + = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 + | +LL | / #![feature(generators)] +LL | | #![allow(unconditional_recursion)] +LL | | +LL | | fn option(i: i32) -> impl Sized { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to 13 previous errors + +Some errors have detailed explanations: E0391, E0720. +For more information about an error, try `rustc --explain E0391`. From b5b3f33940f30b05c880c645b42ed1c56281981a Mon Sep 17 00:00:00 2001 From: lcnr Date: Wed, 19 Jan 2022 17:35:26 +0100 Subject: [PATCH 014/150] deal with opaque types without cycling --- .../src/traits/select/candidate_assembly.rs | 34 ++-- tests/ui/impl-trait/recursive-auto-trait.rs | 10 ++ ...l-trait-type-indirect.drop_tracking.stderr | 42 +++-- ...ait-type-indirect.drop_tracking_mir.stderr | 42 +++-- ...rait-type-indirect.no_drop_tracking.stderr | 42 +++-- .../recursive-impl-trait-type-indirect.rs | 1 + ...rait-type-indirect.no_drop_tracking.stderr | 154 ------------------ 7 files changed, 95 insertions(+), 230 deletions(-) create mode 100644 tests/ui/impl-trait/recursive-auto-trait.rs delete mode 100644 tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index d10998cfed71..4330d097aa7f 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -532,22 +532,27 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } - ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { + ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => { bug!( "asked to assemble auto trait candidates of unexpected type: {:?}", self_ty ); } - // Only consider auto impls if there are no manual impls for the root of `self_ty`. - // - // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl - // for `&SomeType: Auto` exists. Due to E0321 the only crate where impls - // for `&SomeType: Auto` can be defined is the crate where `Auto` has been defined. - // - // Generally, we have to guarantee that for all `SimplifiedType`s the only crate - // which may define impls for that type is either the crate defining the type - // or the trait. This should be guaranteed by the orphan check. + ty::Alias(_, _) + if candidates.vec.iter().any(|c| matches!(c, ProjectionCandidate(..))) => + { + // We do not generate an auto impl candidate for `impl Trait`s which already + // reference our auto trait. + // + // For example during candidate assembly for `impl Send: Send`, we don't have + // to look at the constituent types for this opaque types to figure out that this + // trivially holds. + // + // Note that this is only sound as projection candidates of opaque types + // are always applicable for auto traits. + } + ty::Bool | ty::Char | ty::Int(_) @@ -568,6 +573,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Alias(_, _) | ty::GeneratorWitness(_) | ty::GeneratorWitnessMIR(..) => { + // Only consider auto impls if there are no manual impls for the root of `self_ty`. + // + // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl + // for `&SomeType: Auto` exists. Due to E0321 the only crate where impls + // for `&SomeType: Auto` can be defined is the crate where `Auto` has been defined. + // + // Generally, we have to guarantee that for all `SimplifiedType`s the only crate + // which may define impls for that type is either the crate defining the type + // or the trait. This should be guaranteed by the orphan check. let mut has_impl = false; self.tcx().for_each_relevant_impl(def_id, self_ty, |_| has_impl = true); if !has_impl { diff --git a/tests/ui/impl-trait/recursive-auto-trait.rs b/tests/ui/impl-trait/recursive-auto-trait.rs new file mode 100644 index 000000000000..d7b68144ff6b --- /dev/null +++ b/tests/ui/impl-trait/recursive-auto-trait.rs @@ -0,0 +1,10 @@ +// check-pass +fn is_send(_: T) {} +fn foo() -> impl Send { + if false { + is_send(foo()); + } + () +} + +fn main() {} diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr index 8b6a55558cf3..43118ae38540 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr @@ -123,32 +123,30 @@ LL | | x; LL | | } | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]` -error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` +error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - | -note: ...which requires type-checking `mutual_recursion`... - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 + | ^^^^^^^^^ recursive opaque type +LL | +LL | mutual_recursion_b() + | -------------------- returning here with type `impl Sized` +... +LL | fn mutual_recursion_b() -> impl Sized { + | ---------- returning this opaque type `impl Sized` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... - = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 - | -LL | / #![feature(generators)] -LL | | #![allow(unconditional_recursion)] -LL | | -LL | | fn option(i: i32) -> impl Sized { -... | -LL | | -LL | | fn main() {} - | |____________^ + | --------- returning this opaque type `impl Sync` +... +LL | fn mutual_recursion_b() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | mutual_recursion() + | ------------------ returning here with type `impl Sync` -error: aborting due to 13 previous errors +error: aborting due to 14 previous errors -Some errors have detailed explanations: E0391, E0720. -For more information about an error, try `rustc --explain E0391`. +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr index 0c84fa026196..9c67f17e9635 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr @@ -118,32 +118,30 @@ LL | fn generator_hold() -> impl Sized { LL | let x = generator_hold(); | - generator captures itself here -error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` +error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - | -note: ...which requires type-checking `mutual_recursion`... - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 + | ^^^^^^^^^ recursive opaque type +LL | +LL | mutual_recursion_b() + | -------------------- returning here with type `impl Sized` +... +LL | fn mutual_recursion_b() -> impl Sized { + | ---------- returning this opaque type `impl Sized` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... - = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 - | -LL | / #![feature(generators)] -LL | | #![allow(unconditional_recursion)] -LL | | -LL | | fn option(i: i32) -> impl Sized { -... | -LL | | -LL | | fn main() {} - | |____________^ + | --------- returning this opaque type `impl Sync` +... +LL | fn mutual_recursion_b() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | mutual_recursion() + | ------------------ returning here with type `impl Sync` -error: aborting due to 13 previous errors +error: aborting due to 14 previous errors -Some errors have detailed explanations: E0391, E0720. -For more information about an error, try `rustc --explain E0391`. +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr index 8b6a55558cf3..43118ae38540 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr @@ -123,32 +123,30 @@ LL | | x; LL | | } | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]` -error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` +error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - | -note: ...which requires type-checking `mutual_recursion`... - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 + | ^^^^^^^^^ recursive opaque type +LL | +LL | mutual_recursion_b() + | -------------------- returning here with type `impl Sized` +... +LL | fn mutual_recursion_b() -> impl Sized { + | ---------- returning this opaque type `impl Sized` + +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-indirect.rs:95:28 | LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... - = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 - | -LL | / #![feature(generators)] -LL | | #![allow(unconditional_recursion)] -LL | | -LL | | fn option(i: i32) -> impl Sized { -... | -LL | | -LL | | fn main() {} - | |____________^ + | --------- returning this opaque type `impl Sync` +... +LL | fn mutual_recursion_b() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | mutual_recursion() + | ------------------ returning here with type `impl Sync` -error: aborting due to 13 previous errors +error: aborting due to 14 previous errors -Some errors have detailed explanations: E0391, E0720. -For more information about an error, try `rustc --explain E0391`. +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs index 9d3793940c04..630372e13ed5 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs @@ -93,6 +93,7 @@ fn mutual_recursion() -> impl Sync { } fn mutual_recursion_b() -> impl Sized { + //~^ ERROR mutual_recursion() } diff --git a/tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr b/tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr deleted file mode 100644 index 8b6a55558cf3..000000000000 --- a/tests/ui/impl-traitrecursive-impl-trait-type-indirect.no_drop_tracking.stderr +++ /dev/null @@ -1,154 +0,0 @@ -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:11:22 - | -LL | fn option(i: i32) -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | if i < 0 { None } else { Some((option(i - 1), i)) } - | ---- ------------------------ returning here with type `Option<(impl Sized, i32)>` - | | - | returning here with type `Option<(impl Sized, i32)>` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:16:15 - | -LL | fn tuple() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (tuple(),) - | ---------- returning here with type `(impl Sized,)` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:21:15 - | -LL | fn array() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | [array()] - | --------- returning here with type `[impl Sized; 1]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:26:13 - | -LL | fn ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | &ptr() as *const _ - | ------------------ returning here with type `*const impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:31:16 - | -LL | fn fn_ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | fn_ptr as fn() -> _ - | ------------------- returning here with type `fn() -> impl Sized` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:36:25 - | -LL | fn closure_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:44:29 - | -LL | fn closure_ref_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | &x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:52:21 - | -LL | fn closure_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || closure_sig() - | ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:57:23 - | -LL | fn generator_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || generator_sig() - | ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:62:27 - | -LL | fn generator_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | yield; -LL | | x; - | | - generator captures itself here -LL | | } - | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12]` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:71:35 - | -LL | fn substs_change() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (substs_change::<&T>(),) - | ------------------------ returning here with type `(impl Sized,)` - -error[E0720]: cannot resolve opaque type - --> $DIR/recursive-impl-trait-type-indirect.rs:76:24 - | -LL | fn generator_hold() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | / move || { -LL | | let x = generator_hold(); - | | - generator captures itself here -LL | | yield; -LL | | x; -LL | | } - | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]` - -error[E0391]: cycle detected when computing type of `mutual_recursion::{opaque#0}` - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 - | -LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - | -note: ...which requires type-checking `mutual_recursion`... - --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 - | -LL | fn mutual_recursion() -> impl Sync { - | ^^^^^^^^^ - = note: ...which requires evaluating trait selection obligation `mutual_recursion_b::{opaque#0}: core::marker::Sync`... - = note: ...which again requires computing type of `mutual_recursion::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/recursive-impl-trait-type-indirect.rs:8:1 - | -LL | / #![feature(generators)] -LL | | #![allow(unconditional_recursion)] -LL | | -LL | | fn option(i: i32) -> impl Sized { -... | -LL | | -LL | | fn main() {} - | |____________^ - -error: aborting due to 13 previous errors - -Some errors have detailed explanations: E0391, E0720. -For more information about an error, try `rustc --explain E0391`. From 944f237d2da706f7531f28b223fd5225e93312d3 Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Tue, 4 Jul 2023 11:28:19 +0200 Subject: [PATCH 015/150] always emit consider `AutoImplCandidates` for them if they don't also have a `ProjectionCandidate` --- .../src/traits/select/candidate_assembly.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 4330d097aa7f..aff855300643 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -552,6 +552,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Note that this is only sound as projection candidates of opaque types // are always applicable for auto traits. } + ty::Alias(_, _) => candidates.vec.push(AutoImplCandidate), ty::Bool | ty::Char @@ -570,7 +571,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Generator(..) | ty::Never | ty::Tuple(_) - | ty::Alias(_, _) | ty::GeneratorWitness(_) | ty::GeneratorWitnessMIR(..) => { // Only consider auto impls if there are no manual impls for the root of `self_ty`. From d6c93b33d0af1ede78b6097d04492ab36689dc1d Mon Sep 17 00:00:00 2001 From: Dayo Date: Mon, 3 Jul 2023 18:08:49 +0900 Subject: [PATCH 016/150] Implement diagnostic translation for expected lifetime parameter message --- compiler/rustc_errors/messages.ftl | 22 ++++++ compiler/rustc_errors/src/diagnostic_impls.rs | 77 ++++++++++++++++++- compiler/rustc_errors/src/lib.rs | 42 ++++++---- 3 files changed, 125 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_errors/messages.ftl b/compiler/rustc_errors/messages.ftl index 8e8223c3cf8a..d68dba0be5e9 100644 --- a/compiler/rustc_errors/messages.ftl +++ b/compiler/rustc_errors/messages.ftl @@ -1,3 +1,25 @@ +errors_delayed_at_with_newline = + delayed at {$emitted_at} + {$note} + +errors_delayed_at_without_newline = + delayed at {$emitted_at} - {$note} + +errors_expected_lifetime_parameter = + expected lifetime {$count -> + [1] parameter + *[other] parameters + } + +errors_indicate_anonymous_lifetime = + indicate the anonymous {$count -> + [1] lifetime + *[other] lifetimes + } + +errors_invalid_flushed_delayed_diagnostic_level = + `flushed_delayed` got diagnostic with level {$level}, instead of the expected `DelayedBug` + errors_target_inconsistent_architecture = inconsistent target specification: "data-layout" claims architecture is {$dl}-endian, while "target-endian" is `{$target}` diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 10fe7fc74a87..7eca1151a3c4 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -1,15 +1,18 @@ -use crate::{fluent_generated as fluent, AddToDiagnostic}; +use crate::diagnostic::DiagnosticLocation; +use crate::{fluent_generated as fluent, AddToDiagnostic, Diagnostic}; use crate::{DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg}; use rustc_ast as ast; use rustc_ast_pretty::pprust; +use rustc_error_messages::SubdiagnosticMessage; use rustc_hir as hir; -use rustc_lint_defs::Level; +use rustc_lint_defs::{Applicability, Level}; use rustc_span::edition::Edition; use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol}; use rustc_span::Span; use rustc_target::abi::TargetDataLayoutErrors; use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple}; use rustc_type_ir as type_ir; +use std::backtrace::Backtrace; use std::borrow::Cow; use std::fmt; use std::num::ParseIntError; @@ -311,3 +314,73 @@ pub enum LabelKind { Label, Help, } + +#[derive(Subdiagnostic)] +#[label(errors_expected_lifetime_parameter)] +pub struct ExpectedLifetimeParameter { + #[primary_span] + pub span: Span, + pub count: usize, +} + +#[derive(Subdiagnostic)] +#[note(errors_delayed_at_with_newline)] +pub struct DelayedAtWithNewline { + #[primary_span] + pub span: Span, + pub emitted_at: DiagnosticLocation, + pub note: Backtrace, +} +#[derive(Subdiagnostic)] +#[note(errors_delayed_at_without_newline)] +pub struct DelayedAtWithoutNewline { + #[primary_span] + pub span: Span, + pub emitted_at: DiagnosticLocation, + pub note: Backtrace, +} + +impl IntoDiagnosticArg for DiagnosticLocation { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::from(self.to_string())) + } +} + +impl IntoDiagnosticArg for Backtrace { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::from(self.to_string())) + } +} + +#[derive(Subdiagnostic)] +#[note(errors_invalid_flushed_delayed_diagnostic_level)] +pub struct InvalidFlushedDelayedDiagnosticLevel { + #[primary_span] + pub span: Span, + pub level: rustc_errors::Level, +} +impl IntoDiagnosticArg for rustc_errors::Level { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::from(self.to_string())) + } +} + +pub struct IndicateAnonymousLifetime { + pub span: Span, + pub count: usize, + pub suggestion: String, +} + +impl AddToDiagnostic for IndicateAnonymousLifetime { + fn add_to_diagnostic_with(self, diag: &mut Diagnostic, _: F) + where + F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, + { + diag.span_suggestion_verbose( + self.span, + fluent::errors_indicate_anonymous_lifetime, + self.suggestion, + Applicability::MachineApplicable, + ); + } +} diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 24d1cc8af82f..f5e37c36373a 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -22,6 +22,8 @@ extern crate rustc_macros; #[macro_use] extern crate tracing; +extern crate self as rustc_errors; + pub use emitter::ColorConfig; use rustc_lint_defs::LintExpectationId; @@ -375,13 +377,16 @@ pub struct ExplicitBug; /// rather than a failed assertion, etc. pub struct DelayedBugPanic; +use crate::diagnostic_impls::{DelayedAtWithNewline, DelayedAtWithoutNewline}; pub use diagnostic::{ AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgValue, DiagnosticId, DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic, }; pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted}; pub use diagnostic_impls::{ - DiagnosticArgFromDisplay, DiagnosticSymbolList, LabelKind, SingleLabelManySpans, + DiagnosticArgFromDisplay, DiagnosticSymbolList, ExpectedLifetimeParameter, + IndicateAnonymousLifetime, InvalidFlushedDelayedDiagnosticLevel, LabelKind, + SingleLabelManySpans, }; use std::backtrace::{Backtrace, BacktraceStatus}; @@ -1670,11 +1675,10 @@ impl HandlerInner { if bug.level != Level::DelayedBug { // NOTE(eddyb) not panicking here because we're already producing // an ICE, and the more information the merrier. - bug.note(format!( - "`flushed_delayed` got diagnostic with level {:?}, \ - instead of the expected `DelayedBug`", - bug.level, - )); + bug.subdiagnostic(InvalidFlushedDelayedDiagnosticLevel { + span: bug.span.primary_span().unwrap(), + level: bug.level, + }); } bug.level = Level::Bug; @@ -1741,12 +1745,22 @@ impl DelayedDiagnostic { fn decorate(mut self) -> Diagnostic { match self.note.status() { BacktraceStatus::Captured => { - self.inner.note(format!("delayed at {}\n{}", self.inner.emitted_at, self.note)); + let inner = &self.inner; + self.inner.subdiagnostic(DelayedAtWithNewline { + span: inner.span.primary_span().unwrap(), + emitted_at: inner.emitted_at.clone(), + note: self.note, + }); } // Avoid the needless newline when no backtrace has been captured, // the display impl should just be a single line. _ => { - self.inner.note(format!("delayed at {} - {}", self.inner.emitted_at, self.note)); + let inner = &self.inner; + self.inner.subdiagnostic(DelayedAtWithoutNewline { + span: inner.span.primary_span().unwrap(), + emitted_at: inner.emitted_at.clone(), + note: self.note, + }); } } @@ -1838,7 +1852,7 @@ pub fn add_elided_lifetime_in_path_suggestion( incl_angl_brckt: bool, insertion_span: Span, ) { - diag.span_label(path_span, format!("expected lifetime parameter{}", pluralize!(n))); + diag.subdiagnostic(ExpectedLifetimeParameter { span: path_span, count: n }); if !source_map.is_span_accessible(insertion_span) { // Do not try to suggest anything if generated by a proc-macro. return; @@ -1846,12 +1860,12 @@ pub fn add_elided_lifetime_in_path_suggestion( let anon_lts = vec!["'_"; n].join(", "); let suggestion = if incl_angl_brckt { format!("<{}>", anon_lts) } else { format!("{}, ", anon_lts) }; - diag.span_suggestion_verbose( - insertion_span.shrink_to_hi(), - format!("indicate the anonymous lifetime{}", pluralize!(n)), + + diag.subdiagnostic(IndicateAnonymousLifetime { + span: insertion_span.shrink_to_hi(), + count: n, suggestion, - Applicability::MachineApplicable, - ); + }); } #[derive(Clone, Copy, PartialEq, Hash, Debug)] From 3dbbf23e29516218863bda29d2983bd503e6b7fd Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 6 Jul 2023 21:45:24 +0200 Subject: [PATCH 017/150] Rename cast_ref_to_mut lint to invalid_reference_casting --- compiler/rustc_lint/messages.ftl | 4 ++-- compiler/rustc_lint/src/lib.rs | 6 ++--- compiler/rustc_lint/src/lints.rs | 6 ++--- ...ast_ref_to_mut.rs => reference_casting.rs} | 12 +++++----- .../both_borrows/shr_frozen_violation1.rs | 2 +- .../miri/tests/fail/modifying_constants.rs | 2 +- .../const-generics/issues/issue-100313.stderr | 2 +- ...ast_ref_to_mut.rs => reference_casting.rs} | 0 ...to_mut.stderr => reference_casting.stderr} | 22 +++++++++---------- 9 files changed, 28 insertions(+), 28 deletions(-) rename compiler/rustc_lint/src/{cast_ref_to_mut.rs => reference_casting.rs} (82%) rename tests/ui/lint/{cast_ref_to_mut.rs => reference_casting.rs} (100%) rename tests/ui/lint/{cast_ref_to_mut.stderr => reference_casting.stderr} (85%) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 2c92277b50d2..38a1cc5bf7cc 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -155,8 +155,6 @@ lint_builtin_unused_doc_comment = unused doc comment lint_builtin_while_true = denote infinite loops with `loop {"{"} ... {"}"}` .suggestion = use `loop` -lint_cast_ref_to_mut = casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - lint_check_name_deprecated = lint name `{$lint_name}` is deprecated and does not have an effect anymore. Use: {$new_name} lint_check_name_unknown = unknown lint: `{$lint_name}` @@ -322,6 +320,8 @@ lint_invalid_nan_comparisons_eq_ne = incorrect NaN comparison, NaN cannot be dir lint_invalid_nan_comparisons_lt_le_gt_ge = incorrect NaN comparison, NaN is not orderable +lint_invalid_reference_casting = casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + lint_lintpass_by_hand = implementing `LintPass` by hand .help = try using `declare_lint_pass!` or `impl_lint_pass!` instead diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index beb38dbb94c3..53089294fe2e 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -50,7 +50,6 @@ extern crate tracing; mod array_into_iter; pub mod builtin; -mod cast_ref_to_mut; mod context; mod deref_into_dyn_supertrait; mod drop_forget_useless; @@ -78,6 +77,7 @@ mod opaque_hidden_inferred_bound; mod pass_by_value; mod passes; mod redundant_semicolon; +mod reference_casting; mod traits; mod types; mod unused; @@ -99,7 +99,6 @@ use rustc_span::Span; use array_into_iter::ArrayIntoIter; use builtin::*; -use cast_ref_to_mut::*; use deref_into_dyn_supertrait::*; use drop_forget_useless::*; use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums; @@ -119,6 +118,7 @@ use noop_method_call::*; use opaque_hidden_inferred_bound::*; use pass_by_value::*; use redundant_semicolon::*; +use reference_casting::*; use traits::*; use types::*; use unused::*; @@ -218,7 +218,7 @@ late_lint_methods!( BoxPointers: BoxPointers, PathStatements: PathStatements, LetUnderscore: LetUnderscore, - CastRefToMut: CastRefToMut, + InvalidReferenceCasting: InvalidReferenceCasting, // Depends on referenced function signatures in expressions UnusedResults: UnusedResults, NonUpperCaseGlobals: NonUpperCaseGlobals, diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1dea758bb294..a86a5f402cdf 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -743,10 +743,10 @@ pub enum InvalidFromUtf8Diag { }, } -// cast_ref_to_mut.rs +// reference_casting.rs #[derive(LintDiagnostic)] -#[diag(lint_cast_ref_to_mut)] -pub struct CastRefToMutDiag; +#[diag(lint_invalid_reference_casting)] +pub struct InvalidReferenceCastingDiag; // hidden_unicode_codepoints.rs #[derive(LintDiagnostic)] diff --git a/compiler/rustc_lint/src/cast_ref_to_mut.rs b/compiler/rustc_lint/src/reference_casting.rs similarity index 82% rename from compiler/rustc_lint/src/cast_ref_to_mut.rs rename to compiler/rustc_lint/src/reference_casting.rs index 82bb70bc9e78..1a172dd69425 100644 --- a/compiler/rustc_lint/src/cast_ref_to_mut.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -3,10 +3,10 @@ use rustc_hir::{Expr, ExprKind, MutTy, TyKind, UnOp}; use rustc_middle::ty; use rustc_span::sym; -use crate::{lints::CastRefToMutDiag, LateContext, LateLintPass, LintContext}; +use crate::{lints::InvalidReferenceCastingDiag, LateContext, LateLintPass, LintContext}; declare_lint! { - /// The `cast_ref_to_mut` lint checks for casts of `&T` to `&mut T` + /// The `invalid_reference_casting` lint checks for casts of `&T` to `&mut T` /// without using interior mutability. /// /// ### Example @@ -28,14 +28,14 @@ declare_lint! { /// /// `UnsafeCell` is the only way to obtain aliasable data that is considered /// mutable. - CAST_REF_TO_MUT, + INVALID_REFERENCE_CASTING, Deny, "casts of `&T` to `&mut T` without interior mutability" } -declare_lint_pass!(CastRefToMut => [CAST_REF_TO_MUT]); +declare_lint_pass!(InvalidReferenceCasting => [INVALID_REFERENCE_CASTING]); -impl<'tcx> LateLintPass<'tcx> for CastRefToMut { +impl<'tcx> LateLintPass<'tcx> for InvalidReferenceCasting { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { let ExprKind::Unary(UnOp::Deref, e) = &expr.kind else { return; @@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for CastRefToMut { let e = e.peel_blocks(); if let ty::Ref(..) = cx.typeck_results().node_type(e.hir_id).kind() { - cx.emit_spanned_lint(CAST_REF_TO_MUT, expr.span, CastRefToMutDiag); + cx.emit_spanned_lint(INVALID_REFERENCE_CASTING, expr.span, InvalidReferenceCastingDiag); } } } diff --git a/src/tools/miri/tests/fail/both_borrows/shr_frozen_violation1.rs b/src/tools/miri/tests/fail/both_borrows/shr_frozen_violation1.rs index 1edd7748cde1..0c7f4b89711a 100644 --- a/src/tools/miri/tests/fail/both_borrows/shr_frozen_violation1.rs +++ b/src/tools/miri/tests/fail/both_borrows/shr_frozen_violation1.rs @@ -1,7 +1,7 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows -#![allow(cast_ref_to_mut)] +#![allow(invalid_reference_casting)] fn foo(x: &mut i32) -> i32 { *x = 5; diff --git a/src/tools/miri/tests/fail/modifying_constants.rs b/src/tools/miri/tests/fail/modifying_constants.rs index 40ba31dad8f6..0d1bd7929b5b 100644 --- a/src/tools/miri/tests/fail/modifying_constants.rs +++ b/src/tools/miri/tests/fail/modifying_constants.rs @@ -1,7 +1,7 @@ // This should fail even without validation/SB //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -#![allow(cast_ref_to_mut)] +#![allow(invalid_reference_casting)] fn main() { let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index ffc34a3a41e2..17e4850bd12a 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -4,7 +4,7 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[deny(cast_ref_to_mut)]` on by default + = note: `#[deny(invalid_reference_casting)]` on by default error[E0080]: evaluation of constant value failed --> $DIR/issue-100313.rs:10:13 diff --git a/tests/ui/lint/cast_ref_to_mut.rs b/tests/ui/lint/reference_casting.rs similarity index 100% rename from tests/ui/lint/cast_ref_to_mut.rs rename to tests/ui/lint/reference_casting.rs diff --git a/tests/ui/lint/cast_ref_to_mut.stderr b/tests/ui/lint/reference_casting.stderr similarity index 85% rename from tests/ui/lint/cast_ref_to_mut.stderr rename to tests/ui/lint/reference_casting.stderr index baff00d6c041..d1dd1b32ff44 100644 --- a/tests/ui/lint/cast_ref_to_mut.stderr +++ b/tests/ui/lint/reference_casting.stderr @@ -1,61 +1,61 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:19:9 + --> $DIR/reference_casting.rs:19:9 | LL | (*(a as *const _ as *mut String)).push_str(" world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[deny(cast_ref_to_mut)]` on by default + = note: `#[deny(invalid_reference_casting)]` on by default error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:21:9 + --> $DIR/reference_casting.rs:21:9 | LL | *(a as *const _ as *mut _) = String::from("Replaced"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:23:9 + --> $DIR/reference_casting.rs:23:9 | LL | *(a as *const _ as *mut String) += " world"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:25:25 + --> $DIR/reference_casting.rs:25:25 | LL | let _num = &mut *(num as *const i32 as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:27:25 + --> $DIR/reference_casting.rs:27:25 | LL | let _num = &mut *(num as *const i32).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:29:20 + --> $DIR/reference_casting.rs:29:20 | LL | let _num = *{ num as *const i32 }.cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:31:9 + --> $DIR/reference_casting.rs:31:9 | LL | *std::ptr::from_ref(num).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:33:9 + --> $DIR/reference_casting.rs:33:9 | LL | *std::ptr::from_ref({ num }).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:35:9 + --> $DIR/reference_casting.rs:35:9 | LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/cast_ref_to_mut.rs:37:9 + --> $DIR/reference_casting.rs:37:9 | LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From fa15df6f5a85ceb5919a47bb721a337c7b8f0adc Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 8 Jun 2023 18:47:44 +0200 Subject: [PATCH 018/150] Rename cast_ref_to_mut to invalid_reference_casting (clippy side) --- src/tools/clippy/clippy_lints/src/renamed_lints.rs | 2 +- src/tools/clippy/tests/ui/rename.fixed | 4 ++-- src/tools/clippy/tests/ui/rename.rs | 2 +- src/tools/clippy/tests/ui/rename.stderr | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/renamed_lints.rs b/src/tools/clippy/clippy_lints/src/renamed_lints.rs index d24215c22924..e532dd61a829 100644 --- a/src/tools/clippy/clippy_lints/src/renamed_lints.rs +++ b/src/tools/clippy/clippy_lints/src/renamed_lints.rs @@ -31,7 +31,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[ ("clippy::stutter", "clippy::module_name_repetitions"), ("clippy::to_string_in_display", "clippy::recursive_format_impl"), ("clippy::zero_width_space", "clippy::invisible_characters"), - ("clippy::cast_ref_to_mut", "cast_ref_to_mut"), + ("clippy::cast_ref_to_mut", "invalid_reference_casting"), ("clippy::clone_double_ref", "suspicious_double_ref_op"), ("clippy::cmp_nan", "invalid_nan_comparisons"), ("clippy::drop_bounds", "drop_bounds"), diff --git a/src/tools/clippy/tests/ui/rename.fixed b/src/tools/clippy/tests/ui/rename.fixed index cab02bb93c9c..03d9ea41a0b1 100644 --- a/src/tools/clippy/tests/ui/rename.fixed +++ b/src/tools/clippy/tests/ui/rename.fixed @@ -28,9 +28,9 @@ #![allow(clippy::module_name_repetitions)] #![allow(clippy::recursive_format_impl)] #![allow(clippy::invisible_characters)] -#![allow(cast_ref_to_mut)] #![allow(suspicious_double_ref_op)] #![allow(invalid_nan_comparisons)] +#![allow(invalid_reference_casting)] #![allow(drop_bounds)] #![allow(dropping_copy_types)] #![allow(dropping_references)] @@ -79,7 +79,7 @@ #![warn(clippy::module_name_repetitions)] #![warn(clippy::recursive_format_impl)] #![warn(clippy::invisible_characters)] -#![warn(cast_ref_to_mut)] +#![warn(invalid_reference_casting)] #![warn(suspicious_double_ref_op)] #![warn(invalid_nan_comparisons)] #![warn(drop_bounds)] diff --git a/src/tools/clippy/tests/ui/rename.rs b/src/tools/clippy/tests/ui/rename.rs index e5e31452149d..c028fcb5a376 100644 --- a/src/tools/clippy/tests/ui/rename.rs +++ b/src/tools/clippy/tests/ui/rename.rs @@ -28,9 +28,9 @@ #![allow(clippy::module_name_repetitions)] #![allow(clippy::recursive_format_impl)] #![allow(clippy::invisible_characters)] -#![allow(cast_ref_to_mut)] #![allow(suspicious_double_ref_op)] #![allow(invalid_nan_comparisons)] +#![allow(invalid_reference_casting)] #![allow(drop_bounds)] #![allow(dropping_copy_types)] #![allow(dropping_references)] diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index 783608a08410..4d8a7fd70f45 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -174,11 +174,11 @@ error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_ch LL | #![warn(clippy::zero_width_space)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters` -error: lint `clippy::cast_ref_to_mut` has been renamed to `cast_ref_to_mut` +error: lint `clippy::cast_ref_to_mut` has been renamed to `invalid_reference_casting` --> $DIR/rename.rs:82:9 | LL | #![warn(clippy::cast_ref_to_mut)] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `cast_ref_to_mut` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_reference_casting` error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op` --> $DIR/rename.rs:83:9 From f25ad54a4d0febbcb2b7e951835228b7b2320b49 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 6 Jul 2023 21:50:34 +0200 Subject: [PATCH 019/150] Temporarily switch invalid_reference_casting lint to allow-by-default --- compiler/rustc_lint/src/reference_casting.rs | 3 ++- .../ui/const-generics/issues/issue-100313.rs | 1 - .../const-generics/issues/issue-100313.stderr | 12 ++------- tests/ui/lint/reference_casting.rs | 1 + tests/ui/lint/reference_casting.stderr | 26 +++++++++++-------- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_lint/src/reference_casting.rs b/compiler/rustc_lint/src/reference_casting.rs index 1a172dd69425..d343aaf35d5b 100644 --- a/compiler/rustc_lint/src/reference_casting.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -12,6 +12,7 @@ declare_lint! { /// ### Example /// /// ```rust,compile_fail + /// # #![deny(invalid_reference_casting)] /// fn x(r: &i32) { /// unsafe { /// *(r as *const i32 as *mut i32) += 1; @@ -29,7 +30,7 @@ declare_lint! { /// `UnsafeCell` is the only way to obtain aliasable data that is considered /// mutable. INVALID_REFERENCE_CASTING, - Deny, + Allow, "casts of `&T` to `&mut T` without interior mutability" } diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 9a9d4721c849..4e9d3626aa89 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -9,7 +9,6 @@ impl T { unsafe { *(B as *const bool as *mut bool) = false; //~^ ERROR evaluation of constant value failed [E0080] - //~| ERROR casting `&T` to `&mut T` is undefined behavior } } } diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 17e4850bd12a..d4b486376cac 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,11 +1,3 @@ -error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/issue-100313.rs:10:13 - | -LL | *(B as *const bool as *mut bool) = false; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[deny(invalid_reference_casting)]` on by default - error[E0080]: evaluation of constant value failed --> $DIR/issue-100313.rs:10:13 | @@ -18,11 +10,11 @@ note: inside `T::<&true>::set_false` LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside `_` - --> $DIR/issue-100313.rs:19:5 + --> $DIR/issue-100313.rs:18:5 | LL | x.set_false(); | ^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs index 745d70701436..9963820499ed 100644 --- a/tests/ui/lint/reference_casting.rs +++ b/tests/ui/lint/reference_casting.rs @@ -1,6 +1,7 @@ // check-fail #![feature(ptr_from_ref)] +#![deny(invalid_reference_casting)] extern "C" { // N.B., mutability can be easily incorrect in FFI calls -- as diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr index d1dd1b32ff44..d5b9bbef6439 100644 --- a/tests/ui/lint/reference_casting.stderr +++ b/tests/ui/lint/reference_casting.stderr @@ -1,61 +1,65 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:19:9 + --> $DIR/reference_casting.rs:20:9 | LL | (*(a as *const _ as *mut String)).push_str(" world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[deny(invalid_reference_casting)]` on by default +note: the lint level is defined here + --> $DIR/reference_casting.rs:4:9 + | +LL | #![deny(invalid_reference_casting)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:21:9 + --> $DIR/reference_casting.rs:22:9 | LL | *(a as *const _ as *mut _) = String::from("Replaced"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:23:9 + --> $DIR/reference_casting.rs:24:9 | LL | *(a as *const _ as *mut String) += " world"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:25:25 + --> $DIR/reference_casting.rs:26:25 | LL | let _num = &mut *(num as *const i32 as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:27:25 + --> $DIR/reference_casting.rs:28:25 | LL | let _num = &mut *(num as *const i32).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:29:20 + --> $DIR/reference_casting.rs:30:20 | LL | let _num = *{ num as *const i32 }.cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:31:9 + --> $DIR/reference_casting.rs:32:9 | LL | *std::ptr::from_ref(num).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:33:9 + --> $DIR/reference_casting.rs:34:9 | LL | *std::ptr::from_ref({ num }).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:35:9 + --> $DIR/reference_casting.rs:36:9 | LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:37:9 + --> $DIR/reference_casting.rs:38:9 | LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 05c856a760ba058ccd45c899c9257f6f7d6f769f Mon Sep 17 00:00:00 2001 From: Dayo Date: Mon, 17 Jul 2023 15:00:13 +0900 Subject: [PATCH 020/150] Simplify implement diagnostic of errors_indicate_anonymous_lifetime --- compiler/rustc_errors/src/diagnostic_impls.rs | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 7eca1151a3c4..2bc2efbf9302 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -1,11 +1,10 @@ use crate::diagnostic::DiagnosticLocation; -use crate::{fluent_generated as fluent, AddToDiagnostic, Diagnostic}; +use crate::{fluent_generated as fluent, AddToDiagnostic}; use crate::{DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg}; use rustc_ast as ast; use rustc_ast_pretty::pprust; -use rustc_error_messages::SubdiagnosticMessage; use rustc_hir as hir; -use rustc_lint_defs::{Applicability, Level}; +use rustc_lint_defs::Level; use rustc_span::edition::Edition; use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol}; use rustc_span::Span; @@ -365,22 +364,11 @@ impl IntoDiagnosticArg for rustc_errors::Level { } } +#[derive(Subdiagnostic)] +#[suggestion(errors_indicate_anonymous_lifetime, code = "{suggestion}", style = "verbose")] pub struct IndicateAnonymousLifetime { + #[primary_span] pub span: Span, pub count: usize, pub suggestion: String, } - -impl AddToDiagnostic for IndicateAnonymousLifetime { - fn add_to_diagnostic_with(self, diag: &mut Diagnostic, _: F) - where - F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage, - { - diag.span_suggestion_verbose( - self.span, - fluent::errors_indicate_anonymous_lifetime, - self.suggestion, - Applicability::MachineApplicable, - ); - } -} From 9c373e3e5b688160e9be96582fd6877941a6a960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 16 Jul 2023 10:44:32 +0200 Subject: [PATCH 021/150] Try to build LLVM without LTO --- src/tools/opt-dist/src/environment/linux.rs | 4 ++++ src/tools/opt-dist/src/environment/mod.rs | 2 ++ src/tools/opt-dist/src/environment/windows.rs | 4 ++++ src/tools/opt-dist/src/exec.rs | 10 ++++++++++ src/tools/opt-dist/src/main.rs | 12 +++++++++++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/tools/opt-dist/src/environment/linux.rs b/src/tools/opt-dist/src/environment/linux.rs index d4c55c46f7ce..c2a328b1dbcd 100644 --- a/src/tools/opt-dist/src/environment/linux.rs +++ b/src/tools/opt-dist/src/environment/linux.rs @@ -41,6 +41,10 @@ impl Environment for LinuxEnvironment { true } + fn supports_shared_llvm(&self) -> bool { + true + } + fn executable_extension(&self) -> &'static str { "" } diff --git a/src/tools/opt-dist/src/environment/mod.rs b/src/tools/opt-dist/src/environment/mod.rs index f66b9ab41ead..d28983d289c7 100644 --- a/src/tools/opt-dist/src/environment/mod.rs +++ b/src/tools/opt-dist/src/environment/mod.rs @@ -60,6 +60,8 @@ pub trait Environment { fn supports_bolt(&self) -> bool; + fn supports_shared_llvm(&self) -> bool; + /// What is the extension of binary executables in this environment? fn executable_extension(&self) -> &'static str; diff --git a/src/tools/opt-dist/src/environment/windows.rs b/src/tools/opt-dist/src/environment/windows.rs index 36f4c0f29cc4..12a63cbb03c4 100644 --- a/src/tools/opt-dist/src/environment/windows.rs +++ b/src/tools/opt-dist/src/environment/windows.rs @@ -65,6 +65,10 @@ impl Environment for WindowsEnvironment { false } + fn supports_shared_llvm(&self) -> bool { + false + } + fn executable_extension(&self) -> &'static str { ".exe" } diff --git a/src/tools/opt-dist/src/exec.rs b/src/tools/opt-dist/src/exec.rs index d05ddbd4c0e3..3777c7c97184 100644 --- a/src/tools/opt-dist/src/exec.rs +++ b/src/tools/opt-dist/src/exec.rs @@ -139,6 +139,16 @@ impl Bootstrap { self } + pub fn without_llvm_lto(mut self) -> Self { + self.cmd = self + .cmd + .arg("--set") + .arg("llvm.thin-lto=false") + .arg("--set") + .arg("llvm.link-shared=true"); + self + } + pub fn rustc_pgo_optimize(mut self, profile: &RustcPGOProfile) -> Self { self.cmd = self.cmd.arg("--rust-profile-use").arg(profile.0.as_str()); self diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 5e82430416b6..db32cedf731e 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -38,7 +38,17 @@ fn execute_pipeline( let rustc_profile_dir_root = env.opt_artifacts().join("rustc-pgo"); stage.section("Build PGO instrumented rustc and LLVM", |section| { - Bootstrap::build(env).rustc_pgo_instrument(&rustc_profile_dir_root).run(section) + let mut builder = Bootstrap::build(env).rustc_pgo_instrument(&rustc_profile_dir_root); + + if env.supports_shared_llvm() { + // This first LLVM that we build will be thrown away after this stage, and it + // doesn't really need LTO. Without LTO, it builds in ~1 minute thanks to sccache, + // with LTO it takes almost 10 minutes. It makes the followup Rustc PGO + // instrumented/optimized build a bit slower, but it seems to be worth it. + builder = builder.without_llvm_lto(); + } + + builder.run(section) })?; let profile = stage From 8c31219d5c6fe11654060ab968285705f00b1ec8 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 20 Jul 2023 09:52:26 +1000 Subject: [PATCH 022/150] Tweak CGU sorting in a couple of places. In `base.rs`, tweak how the CGU size interleaving works. Since #113777, it's much more common to have multiple CGUs with identical sizes. With the existing code these same-sized items ended up in the opposite-to-desired order due to the stable sorting. The code now starts with a reverse sort (like is done in `partitioning.rs`) which gives the behaviour we want. This doesn't matter much for perf, but makes profiles in `samply` look more like what we expect. In `partitioning.rs`, we can use `sort_by_key` instead of `sort_by_cached_key` because `CGU::size_estimate()` is cheap. (There is an identical CGU sort earlier in that function that already uses `sort_by_key`.) --- compiler/rustc_codegen_ssa/src/base.rs | 5 +++-- compiler/rustc_monomorphize/src/partitioning.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index dc8628032749..79c284ecfbfa 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -38,6 +38,7 @@ use rustc_span::symbol::sym; use rustc_span::Symbol; use rustc_target::abi::{Align, FIRST_VARIANT}; +use std::cmp; use std::collections::BTreeSet; use std::time::{Duration, Instant}; @@ -682,10 +683,10 @@ pub fn codegen_crate( // are large size variations, this can reduce memory usage significantly. let codegen_units: Vec<_> = { let mut sorted_cgus = codegen_units.iter().collect::>(); - sorted_cgus.sort_by_cached_key(|cgu| cgu.size_estimate()); + sorted_cgus.sort_by_key(|cgu| cmp::Reverse(cgu.size_estimate())); let (first_half, second_half) = sorted_cgus.split_at(sorted_cgus.len() / 2); - second_half.iter().rev().interleave(first_half).copied().collect() + first_half.iter().interleave(second_half.iter().rev()).copied().collect() }; // Calculate the CGU reuse diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 71aef53192f4..4a9d6c9e6c8c 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -394,7 +394,7 @@ fn merge_codegen_units<'tcx>( && codegen_units.iter().any(|cgu| cgu.size_estimate() < NON_INCR_MIN_CGU_SIZE) { // Sort small cgus to the back. - codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate())); + codegen_units.sort_by_key(|cgu| cmp::Reverse(cgu.size_estimate())); let mut smallest = codegen_units.pop().unwrap(); let second_smallest = codegen_units.last_mut().unwrap(); From 0333eccfad26466c1ba5e6150f140dd615e99edb Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 18 Jul 2023 16:42:54 -0700 Subject: [PATCH 023/150] ci: Update aarch64-gnu to ubuntu:22.04 --- src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile b/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile index f8701044ec4a..85b0f3b10818 100644 --- a/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile +++ b/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ make \ ninja-build \ @@ -17,9 +18,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins xz-utils \ && rm -rf /var/lib/apt/lists/* -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From b160c8fe5c2cc5ee50798d07932f77070df4f585 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 18 Jul 2023 17:07:17 -0700 Subject: [PATCH 024/150] ci: Update armhf-gnu to ubuntu:22.04 --- .../docker/host-x86_64/armhf-gnu/Dockerfile | 16 +- .../host-x86_64/armhf-gnu/vexpress_config | 645 ++++++++++++------ 2 files changed, 462 insertions(+), 199 deletions(-) diff --git a/src/ci/docker/host-x86_64/armhf-gnu/Dockerfile b/src/ci/docker/host-x86_64/armhf-gnu/Dockerfile index 2d92d23d7b26..015caafc5bd6 100644 --- a/src/ci/docker/host-x86_64/armhf-gnu/Dockerfile +++ b/src/ci/docker/host-x86_64/armhf-gnu/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update -y && apt-get install -y --no-install-recommends \ bc \ bzip2 \ ca-certificates \ @@ -34,14 +35,14 @@ WORKDIR /build # the kernel. This file was generated by running `make vexpress_defconfig` # followed by `make menuconfig` and then enabling the IPv6 protocol page. COPY host-x86_64/armhf-gnu/vexpress_config /build/.config -RUN curl https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.253.tar.xz | \ +RUN curl https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.320.tar.xz | \ tar xJf - && \ - cd /build/linux-4.4.253 && \ + cd /build/linux-4.14.320 && \ cp /build/.config . && \ make -j$(nproc) all && \ cp arch/arm/boot/zImage /tmp && \ cd /build && \ - rm -rf linux-4.4.253 + rm -rf linux-4.14.320 # Compile an instance of busybox as this provides a lightweight system and init # binary which we will boot into. Only trick here is configuring busybox to @@ -59,7 +60,7 @@ RUN curl https://www.busybox.net/downloads/busybox-1.32.1.tar.bz2 | tar xjf - && # Download the ubuntu rootfs, which we'll use as a chroot for all our tests. WORKDIR /tmp RUN mkdir rootfs/ubuntu -RUN curl https://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.1-base-armhf.tar.gz | \ +RUN curl https://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/ubuntu-base-22.04.2-base-armhf.tar.gz | \ tar xzf - -C rootfs/ubuntu && \ cd rootfs && mkdir proc sys dev etc etc/init.d @@ -76,9 +77,6 @@ RUN arm-linux-gnueabihf-gcc addentropy.c -o rootfs/addentropy -static # Source of the file: https://github.com/vfdev-5/qemu-rpi2-vexpress/raw/master/vexpress-v2p-ca15-tc1.dtb RUN curl -O https://ci-mirrors.rust-lang.org/rustc/vexpress-v2p-ca15-tc1.dtb -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/host-x86_64/armhf-gnu/vexpress_config b/src/ci/docker/host-x86_64/armhf-gnu/vexpress_config index b39e5dcf38d7..54c3ae18d60f 100644 --- a/src/ci/docker/host-x86_64/armhf-gnu/vexpress_config +++ b/src/ci/docker/host-x86_64/armhf-gnu/vexpress_config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 4.4.253 Kernel Configuration +# Linux/arm 4.14.320 Kernel Configuration # CONFIG_ARM=y CONFIG_ARM_HAS_SG_CHAIN=y @@ -49,8 +49,8 @@ CONFIG_SYSVIPC=y CONFIG_SYSVIPC_SYSCTL=y # CONFIG_POSIX_MQUEUE is not set CONFIG_CROSS_MEMORY_ATTACH=y -# CONFIG_FHANDLE is not set -CONFIG_USELIB=y +CONFIG_FHANDLE=y +# CONFIG_USELIB is not set # CONFIG_AUDIT is not set CONFIG_HAVE_ARCH_AUDITSYSCALL=y @@ -60,6 +60,7 @@ CONFIG_HAVE_ARCH_AUDITSYSCALL=y CONFIG_GENERIC_IRQ_PROBE=y CONFIG_GENERIC_IRQ_SHOW=y CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y CONFIG_GENERIC_IRQ_MIGRATION=y CONFIG_HARDIRQS_SW_RESEND=y CONFIG_IRQ_DOMAIN=y @@ -68,6 +69,8 @@ CONFIG_HANDLE_DOMAIN_IRQ=y # CONFIG_IRQ_DOMAIN_DEBUG is not set CONFIG_IRQ_FORCED_THREADING=y CONFIG_SPARSE_IRQ=y +# CONFIG_GENERIC_IRQ_DEBUGFS is not set +CONFIG_ARCH_CLOCKSOURCE_DATA=y CONFIG_GENERIC_TIME_VSYSCALL=y CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_ARCH_HAS_TICK_BROADCAST=y @@ -97,28 +100,31 @@ CONFIG_TICK_CPU_ACCOUNTING=y CONFIG_TREE_RCU=y # CONFIG_RCU_EXPERT is not set CONFIG_SRCU=y +CONFIG_TREE_SRCU=y # CONFIG_TASKS_RCU is not set CONFIG_RCU_STALL_COMMON=y -# CONFIG_TREE_RCU_TRACE is not set -# CONFIG_RCU_EXPEDITE_BOOT is not set +CONFIG_RCU_NEED_SEGCBLIST=y CONFIG_BUILD_BIN2C=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_LOG_BUF_SHIFT=14 CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13 CONFIG_GENERIC_SCHED_CLOCK=y CONFIG_CGROUPS=y -# CONFIG_CGROUP_DEBUG is not set -# CONFIG_CGROUP_FREEZER is not set +# CONFIG_MEMCG is not set +# CONFIG_BLK_CGROUP is not set +# CONFIG_CGROUP_SCHED is not set # CONFIG_CGROUP_PIDS is not set -# CONFIG_CGROUP_DEVICE is not set +# CONFIG_CGROUP_RDMA is not set +# CONFIG_CGROUP_FREEZER is not set CONFIG_CPUSETS=y CONFIG_PROC_PID_CPUSET=y +# CONFIG_CGROUP_DEVICE is not set # CONFIG_CGROUP_CPUACCT is not set -# CONFIG_MEMCG is not set # CONFIG_CGROUP_PERF is not set -# CONFIG_CGROUP_SCHED is not set -# CONFIG_BLK_CGROUP is not set +# CONFIG_CGROUP_DEBUG is not set +# CONFIG_SOCK_CGROUP_DATA is not set # CONFIG_CHECKPOINT_RESTORE is not set CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set @@ -149,13 +155,19 @@ CONFIG_MULTIUSER=y # CONFIG_SGETMASK_SYSCALL is not set CONFIG_SYSFS_SYSCALL=y # CONFIG_SYSCTL_SYSCALL is not set +CONFIG_POSIX_TIMERS=y CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_ALL is not set +# CONFIG_KALLSYMS_ABSOLUTE_PERCPU is not set +CONFIG_KALLSYMS_BASE_RELATIVE=y CONFIG_PRINTK=y +CONFIG_PRINTK_NMI=y CONFIG_BUG=y CONFIG_ELF_CORE=y CONFIG_BASE_FULL=y CONFIG_FUTEX=y +CONFIG_FUTEX_PI=y +CONFIG_HAVE_FUTEX_CMPXCHG=y CONFIG_EPOLL=y CONFIG_SIGNALFD=y CONFIG_TIMERFD=y @@ -169,6 +181,7 @@ CONFIG_MEMBARRIER=y # CONFIG_EMBEDDED is not set CONFIG_HAVE_PERF_EVENTS=y CONFIG_PERF_USE_VMALLOC=y +# CONFIG_PC104 is not set # # Kernel Performance Events And Counters @@ -180,25 +193,30 @@ CONFIG_SLUB_DEBUG=y CONFIG_COMPAT_BRK=y # CONFIG_SLAB is not set CONFIG_SLUB=y +CONFIG_SLAB_MERGE_DEFAULT=y +# CONFIG_SLAB_FREELIST_RANDOM is not set +# CONFIG_SLAB_FREELIST_HARDENED is not set CONFIG_SLUB_CPU_PARTIAL=y # CONFIG_SYSTEM_DATA_VERIFICATION is not set CONFIG_PROFILING=y +CONFIG_TRACEPOINTS=y CONFIG_OPROFILE=y CONFIG_HAVE_OPROFILE=y # CONFIG_KPROBES is not set # CONFIG_JUMP_LABEL is not set -# CONFIG_UPROBES is not set +CONFIG_UPROBES=y # CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y CONFIG_ARCH_USE_BUILTIN_BSWAP=y CONFIG_HAVE_KPROBES=y CONFIG_HAVE_KRETPROBES=y CONFIG_HAVE_OPTPROBES=y +CONFIG_HAVE_NMI=y CONFIG_HAVE_ARCH_TRACEHOOK=y -CONFIG_HAVE_DMA_ATTRS=y CONFIG_HAVE_DMA_CONTIGUOUS=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_GENERIC_IDLE_POLL_SETUP=y +CONFIG_ARCH_HAS_SET_MEMORY=y CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y CONFIG_HAVE_CLK=y CONFIG_HAVE_DMA_API_DEBUG=y @@ -208,20 +226,39 @@ CONFIG_HAVE_PERF_USER_STACK_DUMP=y CONFIG_HAVE_ARCH_JUMP_LABEL=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_HAVE_ARCH_SECCOMP_FILTER=y +CONFIG_HAVE_GCC_PLUGINS=y +# CONFIG_GCC_PLUGINS is not set CONFIG_HAVE_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR is not set CONFIG_CC_STACKPROTECTOR_NONE=y # CONFIG_CC_STACKPROTECTOR_REGULAR is not set # CONFIG_CC_STACKPROTECTOR_STRONG is not set +CONFIG_THIN_ARCHIVES=y CONFIG_HAVE_CONTEXT_TRACKING=y CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y CONFIG_HAVE_MOD_ARCH_SPECIFIC=y CONFIG_MODULES_USE_ELF_REL=y CONFIG_ARCH_HAS_ELF_RANDOMIZE=y +CONFIG_HAVE_ARCH_MMAP_RND_BITS=y +CONFIG_HAVE_EXIT_THREAD=y +CONFIG_ARCH_MMAP_RND_BITS_MIN=8 +CONFIG_ARCH_MMAP_RND_BITS_MAX=15 +CONFIG_ARCH_MMAP_RND_BITS=8 +# CONFIG_HAVE_ARCH_HASH is not set +# CONFIG_ISA_BUS_API is not set CONFIG_CLONE_BACKWARDS=y CONFIG_OLD_SIGSUSPEND3=y CONFIG_OLD_SIGACTION=y +# CONFIG_CPU_NO_EFFICIENT_FFS is not set +# CONFIG_HAVE_ARCH_VMAP_STACK is not set +CONFIG_ARCH_OPTIONAL_KERNEL_RWX=y +CONFIG_ARCH_OPTIONAL_KERNEL_RWX_DEFAULT=y +CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y +CONFIG_STRICT_KERNEL_RWX=y +CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y +CONFIG_STRICT_MODULE_RWX=y +# CONFIG_REFCOUNT_FULL is not set # # GCOV-based kernel profiling @@ -240,13 +277,19 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_MODULE_SRCVERSION_ALL is not set # CONFIG_MODULE_SIG is not set # CONFIG_MODULE_COMPRESS is not set +# CONFIG_TRIM_UNUSED_KSYMS is not set CONFIG_MODULES_TREE_LOOKUP=y CONFIG_BLOCK=y # CONFIG_LBDAF is not set +CONFIG_BLK_SCSI_REQUEST=y # CONFIG_BLK_DEV_BSG is not set # CONFIG_BLK_DEV_BSGLIB is not set # CONFIG_BLK_DEV_INTEGRITY is not set +# CONFIG_BLK_DEV_ZONED is not set # CONFIG_BLK_CMDLINE_PARSER is not set +# CONFIG_BLK_WBT is not set +CONFIG_BLK_DEBUG_FS=y +# CONFIG_BLK_SED_OPAL is not set # # Partition Types @@ -254,6 +297,7 @@ CONFIG_BLOCK=y # CONFIG_PARTITION_ADVANCED is not set CONFIG_MSDOS_PARTITION=y CONFIG_EFI_PARTITION=y +CONFIG_BLK_MQ_VIRTIO=y # # IO Schedulers @@ -263,6 +307,9 @@ CONFIG_IOSCHED_NOOP=y # CONFIG_IOSCHED_CFQ is not set CONFIG_DEFAULT_NOOP=y CONFIG_DEFAULT_IOSCHED="noop" +CONFIG_MQ_IOSCHED_DEADLINE=y +CONFIG_MQ_IOSCHED_KYBER=y +# CONFIG_IOSCHED_BFQ is not set CONFIG_INLINE_SPIN_UNLOCK_IRQ=y CONFIG_INLINE_READ_UNLOCK=y CONFIG_INLINE_READ_UNLOCK_IRQ=y @@ -279,10 +326,6 @@ CONFIG_FREEZER=y # CONFIG_MMU=y CONFIG_ARCH_MULTIPLATFORM=y -# CONFIG_ARCH_REALVIEW is not set -# CONFIG_ARCH_VERSATILE is not set -# CONFIG_ARCH_CLPS711X is not set -# CONFIG_ARCH_GEMINI is not set # CONFIG_ARCH_EBSA110 is not set # CONFIG_ARCH_EP93XX is not set # CONFIG_ARCH_FOOTBRIDGE is not set @@ -292,9 +335,6 @@ CONFIG_ARCH_MULTIPLATFORM=y # CONFIG_ARCH_IOP33X is not set # CONFIG_ARCH_IXP4XX is not set # CONFIG_ARCH_DOVE is not set -# CONFIG_ARCH_MV78XX0 is not set -# CONFIG_ARCH_ORION5X is not set -# CONFIG_ARCH_MMP is not set # CONFIG_ARCH_KS8695 is not set # CONFIG_ARCH_W90X900 is not set # CONFIG_ARCH_LPC32XX is not set @@ -302,7 +342,6 @@ CONFIG_ARCH_MULTIPLATFORM=y # CONFIG_ARCH_RPC is not set # CONFIG_ARCH_SA1100 is not set # CONFIG_ARCH_S3C24XX is not set -# CONFIG_ARCH_S3C64XX is not set # CONFIG_ARCH_DAVINCI is not set # CONFIG_ARCH_OMAP1 is not set @@ -319,7 +358,9 @@ CONFIG_ARCH_MULTI_V6_V7=y # CONFIG_ARCH_MULTI_CPU_AUTO is not set # CONFIG_ARCH_VIRT is not set # CONFIG_ARCH_MVEBU is not set +# CONFIG_ARCH_ACTIONS is not set # CONFIG_ARCH_ALPINE is not set +# CONFIG_ARCH_ARTPEC is not set # CONFIG_ARCH_AT91 is not set # CONFIG_ARCH_BCM is not set # CONFIG_ARCH_BERLIN is not set @@ -340,16 +381,19 @@ CONFIG_ARCH_MULTI_V6_V7=y # CONFIG_SOC_AM33XX is not set # CONFIG_SOC_AM43XX is not set # CONFIG_SOC_DRA7XX is not set +# CONFIG_ARCH_MMP is not set # CONFIG_ARCH_QCOM is not set +# CONFIG_ARCH_REALVIEW is not set # CONFIG_ARCH_ROCKCHIP is not set # CONFIG_ARCH_SOCFPGA is not set # CONFIG_PLAT_SPEAR is not set # CONFIG_ARCH_STI is not set # CONFIG_ARCH_S5PV210 is not set # CONFIG_ARCH_EXYNOS is not set -# CONFIG_ARCH_SHMOBILE_MULTI is not set +# CONFIG_ARCH_RENESAS is not set # CONFIG_ARCH_SUNXI is not set # CONFIG_ARCH_SIRF is not set +# CONFIG_ARCH_TANGO is not set # CONFIG_ARCH_TEGRA is not set # CONFIG_ARCH_UNIPHIER is not set # CONFIG_ARCH_U8500 is not set @@ -367,6 +411,7 @@ CONFIG_PLAT_VERSATILE=y # Processor Type # CONFIG_CPU_V7=y +CONFIG_CPU_THUMB_CAPABLE=y CONFIG_CPU_32v6K=y CONFIG_CPU_32v7=y CONFIG_CPU_ABRT_EV7=y @@ -393,12 +438,14 @@ CONFIG_SWP_EMULATE=y # CONFIG_CPU_BPREDICT_DISABLE is not set CONFIG_CPU_SPECTRE=y CONFIG_HARDEN_BRANCH_PREDICTOR=y +CONFIG_HARDEN_BRANCH_HISTORY=y CONFIG_KUSER_HELPERS=y CONFIG_VDSO=y CONFIG_OUTER_CACHE=y CONFIG_OUTER_CACHE_SYNC=y CONFIG_MIGHT_HAVE_CACHE_L2X0=y CONFIG_CACHE_L2X0=y +# CONFIG_CACHE_L2X0_PMU is not set # CONFIG_PL310_ERRATA_588369 is not set # CONFIG_PL310_ERRATA_727915 is not set CONFIG_PL310_ERRATA_753970=y @@ -408,7 +455,7 @@ CONFIG_ARM_L1_CACHE_SHIFT=6 CONFIG_ARM_DMA_MEM_BUFFERABLE=y CONFIG_ARM_HEAVY_MB=y CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y -# CONFIG_ARM_KERNMEM_PERMS is not set +CONFIG_DEBUG_ALIGN_RODATA=y CONFIG_MULTI_IRQ_HANDLER=y # CONFIG_ARM_ERRATA_430973 is not set CONFIG_ARM_ERRATA_643719=y @@ -419,7 +466,11 @@ CONFIG_ARM_ERRATA_720789=y # CONFIG_ARM_ERRATA_775420 is not set # CONFIG_ARM_ERRATA_798181 is not set # CONFIG_ARM_ERRATA_773022 is not set -CONFIG_ICST=y +# CONFIG_ARM_ERRATA_818325_852422 is not set +# CONFIG_ARM_ERRATA_821420 is not set +# CONFIG_ARM_ERRATA_825619 is not set +# CONFIG_ARM_ERRATA_852421 is not set +# CONFIG_ARM_ERRATA_852423 is not set # # Bus support @@ -427,6 +478,15 @@ CONFIG_ICST=y # CONFIG_PCI is not set # CONFIG_PCI_DOMAINS_GENERIC is not set # CONFIG_PCI_SYSCALL is not set + +# +# DesignWare PCI Core Support +# + +# +# PCI Endpoint +# +# CONFIG_PCI_ENDPOINT is not set # CONFIG_PCCARD is not set # @@ -465,6 +525,7 @@ CONFIG_HZ_100=y CONFIG_HZ=100 # CONFIG_SCHED_HRTICK is not set # CONFIG_THUMB2_KERNEL is not set +CONFIG_ARM_PATCH_IDIV=y CONFIG_AEABI=y # CONFIG_OABI_COMPAT is not set # CONFIG_ARCH_SPARSEMEM_DEFAULT is not set @@ -487,9 +548,9 @@ CONFIG_BALLOON_COMPACTION=y CONFIG_COMPACTION=y CONFIG_MIGRATION=y # CONFIG_PHYS_ADDR_T_64BIT is not set -CONFIG_ZONE_DMA_FLAG=0 # CONFIG_KSM is not set CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 +# CONFIG_ARCH_WANTS_THP_SWAP is not set # CONFIG_CLEANCACHE is not set # CONFIG_FRONTSWAP is not set CONFIG_CMA=y @@ -499,13 +560,17 @@ CONFIG_CMA_AREAS=7 # CONFIG_ZPOOL is not set # CONFIG_ZBUD is not set # CONFIG_ZSMALLOC is not set +CONFIG_GENERIC_EARLY_IOREMAP=y # CONFIG_IDLE_PAGE_TRACKING is not set +# CONFIG_PERCPU_STATS is not set CONFIG_FORCE_MAX_ZONEORDER=11 CONFIG_ALIGNMENT_TRAP=y # CONFIG_UACCESS_WITH_MEMCPY is not set # CONFIG_SECCOMP is not set CONFIG_SWIOTLB=y CONFIG_IOMMU_HELPER=y +# CONFIG_PARAVIRT is not set +# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set # CONFIG_XEN is not set # @@ -524,6 +589,7 @@ CONFIG_CMDLINE_FROM_BOOTLOADER=y # CONFIG_KEXEC is not set # CONFIG_CRASH_DUMP is not set CONFIG_AUTO_ZRELADDR=y +# CONFIG_EFI is not set # # CPU Power Management @@ -539,7 +605,7 @@ CONFIG_AUTO_ZRELADDR=y # CONFIG_CPU_IDLE=y CONFIG_CPU_IDLE_GOV_LADDER=y -CONFIG_CPU_IDLE_GOV_MENU=y +# CONFIG_CPU_IDLE_GOV_MENU is not set # # ARM CPU Idle Drivers @@ -565,8 +631,10 @@ CONFIG_NEON=y # Userspace binary formats # CONFIG_BINFMT_ELF=y +CONFIG_ELFCORE=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set CONFIG_BINFMT_SCRIPT=y +# CONFIG_BINFMT_FLAT is not set # CONFIG_HAVE_AOUT is not set # CONFIG_BINFMT_MISC is not set CONFIG_COREDUMP=y @@ -599,7 +667,9 @@ CONFIG_NET=y CONFIG_PACKET=y # CONFIG_PACKET_DIAG is not set CONFIG_UNIX=y +CONFIG_UNIX_SCM=y # CONFIG_UNIX_DIAG is not set +# CONFIG_TLS is not set CONFIG_XFRM=y # CONFIG_XFRM_USER is not set # CONFIG_XFRM_SUB_POLICY is not set @@ -624,15 +694,17 @@ CONFIG_NET_IP_TUNNEL=y # CONFIG_INET_AH is not set # CONFIG_INET_ESP is not set # CONFIG_INET_IPCOMP is not set +CONFIG_INET_TABLE_PERTURB_ORDER=16 # CONFIG_INET_XFRM_TUNNEL is not set CONFIG_INET_TUNNEL=y CONFIG_INET_XFRM_MODE_TRANSPORT=y CONFIG_INET_XFRM_MODE_TUNNEL=y CONFIG_INET_XFRM_MODE_BEET=y -# CONFIG_INET_LRO is not set CONFIG_INET_DIAG=y CONFIG_INET_TCP_DIAG=y # CONFIG_INET_UDP_DIAG is not set +# CONFIG_INET_RAW_DIAG is not set +# CONFIG_INET_DIAG_DESTROY is not set # CONFIG_TCP_CONG_ADVANCED is not set CONFIG_TCP_CONG_CUBIC=y CONFIG_DEFAULT_TCP_CONG="cubic" @@ -644,7 +716,6 @@ CONFIG_IPV6=y # CONFIG_INET6_ESP is not set # CONFIG_INET6_IPCOMP is not set # CONFIG_IPV6_MIP6 is not set -# CONFIG_IPV6_ILA is not set # CONFIG_INET6_XFRM_TUNNEL is not set # CONFIG_INET6_TUNNEL is not set CONFIG_INET6_XFRM_MODE_TRANSPORT=y @@ -656,9 +727,12 @@ CONFIG_IPV6_SIT=y # CONFIG_IPV6_SIT_6RD is not set CONFIG_IPV6_NDISC_NODETYPE=y # CONFIG_IPV6_TUNNEL is not set -# CONFIG_IPV6_GRE is not set +# CONFIG_IPV6_FOU is not set +# CONFIG_IPV6_FOU_TUNNEL is not set # CONFIG_IPV6_MULTIPLE_TABLES is not set # CONFIG_IPV6_MROUTE is not set +# CONFIG_IPV6_SEG6_LWTUNNEL is not set +# CONFIG_IPV6_SEG6_HMAC is not set # CONFIG_NETWORK_SECMARK is not set # CONFIG_NET_PTP_CLASSIFY is not set # CONFIG_NETWORK_PHY_TIMESTAMPING is not set @@ -673,7 +747,6 @@ CONFIG_IPV6_NDISC_NODETYPE=y CONFIG_HAVE_NET_DSA=y # CONFIG_NET_DSA is not set # CONFIG_VLAN_8021Q is not set -# CONFIG_DECNET is not set # CONFIG_LLC2 is not set # CONFIG_IPX is not set # CONFIG_ATALK is not set @@ -689,9 +762,11 @@ CONFIG_HAVE_NET_DSA=y # CONFIG_VSOCKETS is not set # CONFIG_NETLINK_DIAG is not set # CONFIG_MPLS is not set +# CONFIG_NET_NSH is not set # CONFIG_HSR is not set # CONFIG_NET_SWITCHDEV is not set # CONFIG_NET_L3_MASTER_DEV is not set +# CONFIG_NET_NCSI is not set CONFIG_RPS=y CONFIG_RFS_ACCEL=y CONFIG_XPS=y @@ -706,30 +781,35 @@ CONFIG_NET_FLOW_LIMIT=y # Network testing # # CONFIG_NET_PKTGEN is not set +# CONFIG_NET_DROP_MONITOR is not set # CONFIG_HAMRADIO is not set # CONFIG_CAN is not set -# CONFIG_IRDA is not set # CONFIG_BT is not set # CONFIG_AF_RXRPC is not set +# CONFIG_AF_KCM is not set +# CONFIG_STREAM_PARSER is not set # CONFIG_WIRELESS is not set # CONFIG_WIMAX is not set # CONFIG_RFKILL is not set -# CONFIG_RFKILL_REGULATOR is not set CONFIG_NET_9P=y CONFIG_NET_9P_VIRTIO=y # CONFIG_NET_9P_DEBUG is not set # CONFIG_CAIF is not set # CONFIG_CEPH_LIB is not set # CONFIG_NFC is not set +# CONFIG_PSAMPLE is not set +# CONFIG_NET_IFE is not set # CONFIG_LWTUNNEL is not set CONFIG_DST_CACHE=y -CONFIG_HAVE_BPF_JIT=y +CONFIG_GRO_CELLS=y +# CONFIG_NET_DEVLINK is not set +CONFIG_MAY_USE_DEVLINK=y +CONFIG_HAVE_EBPF_JIT=y # # Device Drivers # CONFIG_ARM_AMBA=y -# CONFIG_TEGRA_AHB is not set # # Generic Driver Options @@ -747,12 +827,18 @@ CONFIG_EXTRA_FIRMWARE="" CONFIG_ALLOW_DEV_COREDUMP=y # CONFIG_DEBUG_DRIVER is not set # CONFIG_DEBUG_DEVRES is not set +# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set +# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set # CONFIG_SYS_HYPERVISOR is not set # CONFIG_GENERIC_CPU_DEVICES is not set +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_CPU_VULNERABILITIES=y CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y CONFIG_REGMAP_MMIO=y # CONFIG_DMA_SHARED_BUFFER is not set # CONFIG_DMA_CMA is not set +CONFIG_GENERIC_ARCH_TOPOLOGY=y # # Bus devices @@ -761,9 +847,10 @@ CONFIG_ARM_CCI=y CONFIG_ARM_CCI400_COMMON=y # CONFIG_ARM_CCI400_PMU is not set CONFIG_ARM_CCI400_PORT_CTRL=y -# CONFIG_ARM_CCI500_PMU is not set +# CONFIG_ARM_CCI5xx_PMU is not set # CONFIG_ARM_CCN is not set # CONFIG_BRCMSTB_GISB_ARB is not set +# CONFIG_SIMPLE_PM_BUS is not set CONFIG_VEXPRESS_CONFIG=y # CONFIG_CONNECTOR is not set CONFIG_MTD=y @@ -774,6 +861,10 @@ CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_OF_PARTS=y # CONFIG_MTD_AR7_PARTS is not set +# +# Partition parsers +# + # # User Modules And Translation Layers # @@ -821,6 +912,8 @@ CONFIG_MTD_RAM=y CONFIG_MTD_PHYSMAP=y # CONFIG_MTD_PHYSMAP_COMPAT is not set CONFIG_MTD_PHYSMAP_OF=y +# CONFIG_MTD_PHYSMAP_OF_VERSATILE is not set +# CONFIG_MTD_PHYSMAP_OF_GEMINI is not set CONFIG_MTD_PLATRAM=y # @@ -859,7 +952,6 @@ CONFIG_OF_ADDRESS=y CONFIG_OF_IRQ=y CONFIG_OF_NET=y CONFIG_OF_MDIO=y -CONFIG_OF_MTD=y CONFIG_OF_RESERVED_MEM=y # CONFIG_OF_OVERLAY is not set CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y @@ -873,9 +965,10 @@ CONFIG_BLK_DEV=y # CONFIG_BLK_DEV_RAM is not set # CONFIG_CDROM_PKTCDVD is not set # CONFIG_ATA_OVER_ETH is not set -# CONFIG_MG_DISK is not set CONFIG_VIRTIO_BLK=y +# CONFIG_VIRTIO_BLK_SCSI is not set # CONFIG_BLK_DEV_RBD is not set +# CONFIG_NVME_FC is not set # # Misc devices @@ -889,13 +982,10 @@ CONFIG_VIRTIO_BLK=y # CONFIG_ISL29003 is not set # CONFIG_ISL29020 is not set # CONFIG_SENSORS_TSL2550 is not set -# CONFIG_SENSORS_BH1780 is not set # CONFIG_SENSORS_BH1770 is not set # CONFIG_SENSORS_APDS990X is not set # CONFIG_HMC6352 is not set # CONFIG_DS1682 is not set -# CONFIG_ARM_CHARLCD is not set -# CONFIG_BMP085_I2C is not set # CONFIG_USB_SWITCH_FSA9480 is not set # CONFIG_SRAM is not set CONFIG_VEXPRESS_SYSCFG=y @@ -908,6 +998,7 @@ CONFIG_VEXPRESS_SYSCFG=y # CONFIG_EEPROM_LEGACY is not set # CONFIG_EEPROM_MAX6875 is not set # CONFIG_EEPROM_93CX6 is not set +# CONFIG_EEPROM_IDT_89HPESX is not set # # Texas Instruments shared transport line discipline @@ -928,6 +1019,10 @@ CONFIG_VEXPRESS_SYSCFG=y # SCIF Bus Driver # +# +# VOP Bus Driver +# + # # Intel MIC Host Driver # @@ -943,10 +1038,14 @@ CONFIG_VEXPRESS_SYSCFG=y # # Intel MIC Coprocessor State Management (COSM) Drivers # + +# +# VOP Driver +# # CONFIG_ECHO is not set # CONFIG_CXL_BASE is not set -# CONFIG_CXL_KERNEL_API is not set -# CONFIG_CXL_EEH is not set +# CONFIG_CXL_AFU_DRIVER_OPS is not set +# CONFIG_CXL_LIB is not set # # SCSI device support @@ -1034,8 +1133,9 @@ CONFIG_NET_CORE=y # CONFIG_EQUALIZER is not set # CONFIG_NET_TEAM is not set # CONFIG_MACVLAN is not set -# CONFIG_IPVLAN is not set # CONFIG_VXLAN is not set +# CONFIG_GTP is not set +# CONFIG_MACSEC is not set # CONFIG_NETCONSOLE is not set # CONFIG_NETPOLL is not set # CONFIG_NET_POLL_CONTROLLER is not set @@ -1052,13 +1152,12 @@ CONFIG_VIRTIO_NET=y # # Distributed Switch Architecture drivers # -# CONFIG_NET_DSA_MV88E6XXX is not set -# CONFIG_NET_DSA_MV88E6XXX_NEED_PPU is not set CONFIG_ETHERNET=y +CONFIG_NET_VENDOR_ALACRITECH=y # CONFIG_ALTERA_TSE is not set +CONFIG_NET_VENDOR_AMAZON=y +CONFIG_NET_VENDOR_AQUANTIA=y CONFIG_NET_VENDOR_ARC=y -# CONFIG_ARC_EMAC is not set -# CONFIG_EMAC_ROCKCHIP is not set # CONFIG_NET_VENDOR_AURORA is not set CONFIG_NET_CADENCE=y # CONFIG_MACB is not set @@ -1077,26 +1176,36 @@ CONFIG_NET_VENDOR_FARADAY=y # CONFIG_FTGMAC100 is not set CONFIG_NET_VENDOR_HISILICON=y # CONFIG_HIX5HD2_GMAC is not set +# CONFIG_HISI_FEMAC is not set # CONFIG_HIP04_ETH is not set # CONFIG_HNS is not set # CONFIG_HNS_DSAF is not set # CONFIG_HNS_ENET is not set +CONFIG_NET_VENDOR_HUAWEI=y CONFIG_NET_VENDOR_INTEL=y CONFIG_NET_VENDOR_I825XX=y CONFIG_NET_VENDOR_MARVELL=y # CONFIG_MVMDIO is not set +# CONFIG_MVNETA_BM is not set +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MLXSW_CORE is not set +# CONFIG_MLXFW is not set CONFIG_NET_VENDOR_MICREL=y # CONFIG_KS8851_MLL is not set CONFIG_NET_VENDOR_NATSEMI=y +CONFIG_NET_VENDOR_NETRONOME=y CONFIG_NET_VENDOR_8390=y # CONFIG_AX88796 is not set # CONFIG_ETHOC is not set CONFIG_NET_VENDOR_QUALCOMM=y +# CONFIG_QCOM_EMAC is not set +# CONFIG_RMNET is not set CONFIG_NET_VENDOR_RENESAS=y CONFIG_NET_VENDOR_ROCKER=y CONFIG_NET_VENDOR_SAMSUNG=y # CONFIG_SXGBE_ETH is not set CONFIG_NET_VENDOR_SEEQ=y +CONFIG_NET_VENDOR_SOLARFLARE=y CONFIG_NET_VENDOR_SMSC=y CONFIG_SMC91X=y # CONFIG_SMC911X is not set @@ -1104,47 +1213,58 @@ CONFIG_SMSC911X=y # CONFIG_SMSC911X_ARCH_HOOKS is not set CONFIG_NET_VENDOR_STMICRO=y # CONFIG_STMMAC_ETH is not set -CONFIG_NET_VENDOR_SYNOPSYS=y -# CONFIG_SYNOPSYS_DWC_ETH_QOS is not set CONFIG_NET_VENDOR_VIA=y # CONFIG_VIA_RHINE is not set # CONFIG_VIA_VELOCITY is not set CONFIG_NET_VENDOR_WIZNET=y # CONFIG_WIZNET_W5100 is not set # CONFIG_WIZNET_W5300 is not set +CONFIG_NET_VENDOR_SYNOPSYS=y +# CONFIG_DWC_XLGMAC is not set +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_BUS=y +# CONFIG_MDIO_BCM_UNIMAC is not set +# CONFIG_MDIO_BITBANG is not set +# CONFIG_MDIO_BUS_MUX_GPIO is not set +# CONFIG_MDIO_BUS_MUX_MMIOREG is not set +# CONFIG_MDIO_HISI_FEMAC is not set CONFIG_PHYLIB=y +CONFIG_SWPHY=y +# CONFIG_LED_TRIGGER_PHY is not set # # MII PHY device drivers # +# CONFIG_AMD_PHY is not set # CONFIG_AQUANTIA_PHY is not set # CONFIG_AT803X_PHY is not set -# CONFIG_AMD_PHY is not set -# CONFIG_MARVELL_PHY is not set -# CONFIG_DAVICOM_PHY is not set -# CONFIG_QSEMI_PHY is not set -# CONFIG_LXT_PHY is not set -# CONFIG_CICADA_PHY is not set -# CONFIG_VITESSE_PHY is not set -# CONFIG_TERANETICS_PHY is not set -# CONFIG_SMSC_PHY is not set -# CONFIG_BROADCOM_PHY is not set # CONFIG_BCM7XXX_PHY is not set # CONFIG_BCM87XX_PHY is not set -# CONFIG_ICPLUS_PHY is not set -# CONFIG_REALTEK_PHY is not set -# CONFIG_NATIONAL_PHY is not set -# CONFIG_STE10XP is not set -# CONFIG_LSI_ET1011C_PHY is not set -# CONFIG_MICREL_PHY is not set +# CONFIG_BROADCOM_PHY is not set +# CONFIG_CICADA_PHY is not set +# CONFIG_CORTINA_PHY is not set +# CONFIG_DAVICOM_PHY is not set # CONFIG_DP83848_PHY is not set # CONFIG_DP83867_PHY is not set +CONFIG_FIXED_PHY=y +# CONFIG_ICPLUS_PHY is not set +# CONFIG_INTEL_XWAY_PHY is not set +# CONFIG_LSI_ET1011C_PHY is not set +# CONFIG_LXT_PHY is not set +# CONFIG_MARVELL_PHY is not set +# CONFIG_MARVELL_10G_PHY is not set +# CONFIG_MICREL_PHY is not set # CONFIG_MICROCHIP_PHY is not set -# CONFIG_FIXED_PHY is not set -# CONFIG_MDIO_BITBANG is not set -# CONFIG_MDIO_BUS_MUX_GPIO is not set -# CONFIG_MDIO_BUS_MUX_MMIOREG is not set -# CONFIG_MDIO_BCM_UNIMAC is not set +# CONFIG_MICROSEMI_PHY is not set +# CONFIG_NATIONAL_PHY is not set +# CONFIG_QSEMI_PHY is not set +# CONFIG_REALTEK_PHY is not set +# CONFIG_ROCKCHIP_PHY is not set +# CONFIG_SMSC_PHY is not set +# CONFIG_STE10XP is not set +# CONFIG_TERANETICS_PHY is not set +# CONFIG_VITESSE_PHY is not set +# CONFIG_XILINX_GMII2RGMII is not set # CONFIG_PPP is not set # CONFIG_SLIP is not set CONFIG_USB_NET_DRIVERS=y @@ -1163,7 +1283,6 @@ CONFIG_USB_NET_DRIVERS=y # # CONFIG_WAN is not set # CONFIG_ISDN is not set -# CONFIG_NVM is not set # # Input device support @@ -1178,10 +1297,7 @@ CONFIG_INPUT_LEDS=y # # Userland interfaces # -CONFIG_INPUT_MOUSEDEV=y -CONFIG_INPUT_MOUSEDEV_PSAUX=y -CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 -CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_MOUSEDEV is not set # CONFIG_INPUT_JOYDEV is not set CONFIG_INPUT_EVDEV=y # CONFIG_INPUT_EVBUG is not set @@ -1195,6 +1311,7 @@ CONFIG_INPUT_KEYBOARD=y CONFIG_KEYBOARD_ATKBD=y # CONFIG_KEYBOARD_QT1070 is not set # CONFIG_KEYBOARD_QT2160 is not set +# CONFIG_KEYBOARD_DLINK_DIR685 is not set # CONFIG_KEYBOARD_LKKBD is not set # CONFIG_KEYBOARD_GPIO is not set # CONFIG_KEYBOARD_GPIO_POLLED is not set @@ -1212,20 +1329,24 @@ CONFIG_KEYBOARD_ATKBD=y # CONFIG_KEYBOARD_STOWAWAY is not set # CONFIG_KEYBOARD_SUNKBD is not set # CONFIG_KEYBOARD_OMAP4 is not set +# CONFIG_KEYBOARD_TM2_TOUCHKEY is not set # CONFIG_KEYBOARD_XTKBD is not set # CONFIG_KEYBOARD_CAP11XX is not set # CONFIG_KEYBOARD_BCM is not set CONFIG_INPUT_MOUSE=y CONFIG_MOUSE_PS2=y CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_BYD=y CONFIG_MOUSE_PS2_LOGIPS2PP=y CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS=y CONFIG_MOUSE_PS2_CYPRESS=y CONFIG_MOUSE_PS2_TRACKPOINT=y # CONFIG_MOUSE_PS2_ELANTECH is not set # CONFIG_MOUSE_PS2_SENTELIC is not set # CONFIG_MOUSE_PS2_TOUCHKIT is not set CONFIG_MOUSE_PS2_FOCALTECH=y +CONFIG_MOUSE_PS2_SMBUS=y # CONFIG_MOUSE_SERIAL is not set # CONFIG_MOUSE_APPLETOUCH is not set # CONFIG_MOUSE_BCM5974 is not set @@ -1239,6 +1360,7 @@ CONFIG_MOUSE_PS2_FOCALTECH=y # CONFIG_INPUT_TABLET is not set # CONFIG_INPUT_TOUCHSCREEN is not set # CONFIG_INPUT_MISC is not set +# CONFIG_RMI4_CORE is not set # # Hardware I/O ports @@ -1252,6 +1374,7 @@ CONFIG_SERIO_LIBPS2=y # CONFIG_SERIO_PS2MULT is not set # CONFIG_SERIO_ARC_PS2 is not set # CONFIG_SERIO_APBPS2 is not set +# CONFIG_SERIO_GPIO_PS2 is not set # CONFIG_USERIO is not set # CONFIG_GAMEPORT is not set @@ -1266,7 +1389,6 @@ CONFIG_VT_CONSOLE_SLEEP=y CONFIG_HW_CONSOLE=y CONFIG_VT_HW_CONSOLE_BINDING=y CONFIG_UNIX98_PTYS=y -# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set CONFIG_LEGACY_PTYS=y CONFIG_LEGACY_PTY_COUNT=16 # CONFIG_SERIAL_NONSTANDARD is not set @@ -1274,7 +1396,7 @@ CONFIG_LEGACY_PTY_COUNT=16 # CONFIG_TRACE_SINK is not set CONFIG_LDISC_AUTOLOAD=y CONFIG_DEVMEM=y -CONFIG_DEVKMEM=y +# CONFIG_DEVKMEM is not set # # Serial drivers @@ -1302,7 +1424,7 @@ CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_SERIAL_FSL_LPUART is not set # CONFIG_SERIAL_CONEXANT_DIGICOLOR is not set # CONFIG_SERIAL_ST_ASC is not set -# CONFIG_SERIAL_STM32 is not set +# CONFIG_SERIAL_DEV_BUS is not set CONFIG_HVC_DRIVER=y # CONFIG_HVC_DCC is not set CONFIG_VIRTIO_CONSOLE=y @@ -1313,6 +1435,7 @@ CONFIG_HW_RANDOM_VIRTIO=y # CONFIG_RAW_DRIVER is not set # CONFIG_TCG_TPM is not set # CONFIG_XILLYBUS is not set +CONFIG_RANDOM_TRUST_BOOTLOADER=y # # I2C support @@ -1365,16 +1488,8 @@ CONFIG_I2C_VERSATILE=y # CONFIG_SPI is not set # CONFIG_SPMI is not set # CONFIG_HSI is not set - -# -# PPS support -# # CONFIG_PPS is not set -# -# PPS generators support -# - # # PTP clock support # @@ -1384,10 +1499,7 @@ CONFIG_I2C_VERSATILE=y # Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. # CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y -CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y -CONFIG_ARCH_REQUIRE_GPIOLIB=y CONFIG_GPIOLIB=y -CONFIG_GPIO_DEVRES=y CONFIG_OF_GPIO=y # CONFIG_DEBUG_GPIO is not set # CONFIG_GPIO_SYSFS is not set @@ -1399,14 +1511,15 @@ CONFIG_GPIO_GENERIC=y # CONFIG_GPIO_74XX_MMIO is not set # CONFIG_GPIO_ALTERA is not set # CONFIG_GPIO_DWAPB is not set -# CONFIG_GPIO_EM is not set +# CONFIG_GPIO_FTGPIO010 is not set CONFIG_GPIO_GENERIC_PLATFORM=y # CONFIG_GPIO_GRGPIO is not set +# CONFIG_GPIO_MOCKUP is not set +# CONFIG_GPIO_MPC8XXX is not set # CONFIG_GPIO_PL061 is not set # CONFIG_GPIO_SYSCON is not set # CONFIG_GPIO_XILINX is not set # CONFIG_GPIO_ZEVIO is not set -# CONFIG_GPIO_ZX is not set # # I2C GPIO expanders @@ -1417,44 +1530,20 @@ CONFIG_GPIO_GENERIC_PLATFORM=y # CONFIG_GPIO_MAX732X is not set # CONFIG_GPIO_PCA953X is not set # CONFIG_GPIO_PCF857X is not set -# CONFIG_GPIO_SX150X is not set +# CONFIG_GPIO_TPIC2810 is not set # # MFD GPIO expanders # - -# -# SPI or I2C GPIO expanders -# -# CONFIG_GPIO_MCP23S08 is not set +# CONFIG_HTC_EGPIO is not set # # USB GPIO expanders # # CONFIG_W1 is not set -CONFIG_POWER_SUPPLY=y -# CONFIG_POWER_SUPPLY_DEBUG is not set -# CONFIG_PDA_POWER is not set -# CONFIG_TEST_POWER is not set -# CONFIG_BATTERY_DS2780 is not set -# CONFIG_BATTERY_DS2781 is not set -# CONFIG_BATTERY_DS2782 is not set -# CONFIG_BATTERY_SBS is not set -# CONFIG_BATTERY_BQ27XXX is not set -# CONFIG_BATTERY_MAX17040 is not set -# CONFIG_BATTERY_MAX17042 is not set -# CONFIG_CHARGER_MAX8903 is not set -# CONFIG_CHARGER_LP8727 is not set -# CONFIG_CHARGER_GPIO is not set -# CONFIG_CHARGER_MANAGER is not set -# CONFIG_CHARGER_BQ2415X is not set -# CONFIG_CHARGER_BQ24190 is not set -# CONFIG_CHARGER_BQ24735 is not set -# CONFIG_CHARGER_BQ25890 is not set -# CONFIG_CHARGER_SMB347 is not set -# CONFIG_BATTERY_GAUGE_LTC2941 is not set -# CONFIG_CHARGER_RT9455 is not set +# CONFIG_POWER_AVS is not set CONFIG_POWER_RESET=y +# CONFIG_POWER_RESET_BRCMKONA is not set # CONFIG_POWER_RESET_BRCMSTB is not set # CONFIG_POWER_RESET_GPIO is not set # CONFIG_POWER_RESET_GPIO_RESTART is not set @@ -1464,7 +1553,33 @@ CONFIG_POWER_RESET=y CONFIG_POWER_RESET_VEXPRESS=y # CONFIG_POWER_RESET_SYSCON is not set # CONFIG_POWER_RESET_SYSCON_POWEROFF is not set -# CONFIG_POWER_AVS is not set +# CONFIG_SYSCON_REBOOT_MODE is not set +CONFIG_POWER_SUPPLY=y +# CONFIG_POWER_SUPPLY_DEBUG is not set +# CONFIG_PDA_POWER is not set +# CONFIG_TEST_POWER is not set +# CONFIG_BATTERY_DS2780 is not set +# CONFIG_BATTERY_DS2781 is not set +# CONFIG_BATTERY_DS2782 is not set +# CONFIG_BATTERY_SBS is not set +# CONFIG_CHARGER_SBS is not set +# CONFIG_BATTERY_BQ27XXX is not set +# CONFIG_BATTERY_MAX17040 is not set +# CONFIG_BATTERY_MAX17042 is not set +# CONFIG_CHARGER_MAX8903 is not set +# CONFIG_CHARGER_LP8727 is not set +# CONFIG_CHARGER_GPIO is not set +# CONFIG_CHARGER_MANAGER is not set +# CONFIG_CHARGER_LTC3651 is not set +# CONFIG_CHARGER_DETECTOR_MAX14656 is not set +# CONFIG_CHARGER_BQ2415X is not set +# CONFIG_CHARGER_BQ24257 is not set +# CONFIG_CHARGER_BQ24735 is not set +# CONFIG_CHARGER_BQ25890 is not set +# CONFIG_CHARGER_SMB347 is not set +# CONFIG_BATTERY_GAUGE_LTC2941 is not set +# CONFIG_BATTERY_RT5033 is not set +# CONFIG_CHARGER_RT9455 is not set CONFIG_HWMON=y # CONFIG_HWMON_VID is not set # CONFIG_HWMON_DEBUG_CHIP is not set @@ -1486,6 +1601,7 @@ CONFIG_HWMON=y # CONFIG_SENSORS_ADT7470 is not set # CONFIG_SENSORS_ADT7475 is not set # CONFIG_SENSORS_ASC7621 is not set +# CONFIG_SENSORS_ASPEED is not set # CONFIG_SENSORS_ATXP1 is not set # CONFIG_SENSORS_DS620 is not set # CONFIG_SENSORS_DS1621 is not set @@ -1503,6 +1619,7 @@ CONFIG_HWMON=y # CONFIG_SENSORS_POWR1220 is not set # CONFIG_SENSORS_LINEAGE is not set # CONFIG_SENSORS_LTC2945 is not set +# CONFIG_SENSORS_LTC2990 is not set # CONFIG_SENSORS_LTC4151 is not set # CONFIG_SENSORS_LTC4215 is not set # CONFIG_SENSORS_LTC4222 is not set @@ -1518,8 +1635,8 @@ CONFIG_HWMON=y # CONFIG_SENSORS_MAX6650 is not set # CONFIG_SENSORS_MAX6697 is not set # CONFIG_SENSORS_MAX31790 is not set -# CONFIG_SENSORS_HTU21 is not set # CONFIG_SENSORS_MCP3021 is not set +# CONFIG_SENSORS_TC654 is not set # CONFIG_SENSORS_LM63 is not set # CONFIG_SENSORS_LM73 is not set # CONFIG_SENSORS_LM75 is not set @@ -1546,6 +1663,7 @@ CONFIG_HWMON=y # CONFIG_PMBUS is not set # CONFIG_SENSORS_SHT15 is not set # CONFIG_SENSORS_SHT21 is not set +# CONFIG_SENSORS_SHT3x is not set # CONFIG_SENSORS_SHTC1 is not set # CONFIG_SENSORS_DME1737 is not set # CONFIG_SENSORS_EMC1403 is not set @@ -1555,6 +1673,7 @@ CONFIG_HWMON=y # CONFIG_SENSORS_SMSC47M192 is not set # CONFIG_SENSORS_SMSC47B397 is not set # CONFIG_SENSORS_SCH56XX_COMMON is not set +# CONFIG_SENSORS_STTS751 is not set # CONFIG_SENSORS_SMM665 is not set # CONFIG_SENSORS_ADC128D818 is not set # CONFIG_SENSORS_ADS1015 is not set @@ -1562,10 +1681,12 @@ CONFIG_HWMON=y # CONFIG_SENSORS_AMC6821 is not set # CONFIG_SENSORS_INA209 is not set # CONFIG_SENSORS_INA2XX is not set +# CONFIG_SENSORS_INA3221 is not set # CONFIG_SENSORS_TC74 is not set # CONFIG_SENSORS_THMC50 is not set # CONFIG_SENSORS_TMP102 is not set # CONFIG_SENSORS_TMP103 is not set +# CONFIG_SENSORS_TMP108 is not set # CONFIG_SENSORS_TMP401 is not set # CONFIG_SENSORS_TMP421 is not set CONFIG_SENSORS_VEXPRESS=y @@ -1588,16 +1709,13 @@ CONFIG_SSB_POSSIBLE=y # # CONFIG_SSB is not set CONFIG_BCMA_POSSIBLE=y - -# -# Broadcom specific AMBA -# # CONFIG_BCMA is not set # # Multifunction device drivers # CONFIG_MFD_CORE=y +# CONFIG_MFD_ACT8945A is not set # CONFIG_MFD_AS3711 is not set # CONFIG_MFD_AS3722 is not set # CONFIG_PMIC_ADP5520 is not set @@ -1605,7 +1723,8 @@ CONFIG_MFD_CORE=y # CONFIG_MFD_ATMEL_FLEXCOM is not set # CONFIG_MFD_ATMEL_HLCDC is not set # CONFIG_MFD_BCM590XX is not set -# CONFIG_MFD_AXP20X is not set +# CONFIG_MFD_BD9571MWV is not set +# CONFIG_MFD_AXP20X_I2C is not set # CONFIG_MFD_CROS_EC is not set # CONFIG_MFD_ASIC3 is not set # CONFIG_PMIC_DA903X is not set @@ -1617,15 +1736,14 @@ CONFIG_MFD_CORE=y # CONFIG_MFD_DLN2 is not set # CONFIG_MFD_MC13XXX_I2C is not set # CONFIG_MFD_HI6421_PMIC is not set -# CONFIG_HTC_EGPIO is not set # CONFIG_HTC_PASIC3 is not set # CONFIG_HTC_I2CPLD is not set -# CONFIG_INTEL_SOC_PMIC is not set # CONFIG_MFD_KEMPLD is not set # CONFIG_MFD_88PM800 is not set # CONFIG_MFD_88PM805 is not set # CONFIG_MFD_88PM860X is not set # CONFIG_MFD_MAX14577 is not set +# CONFIG_MFD_MAX77620 is not set # CONFIG_MFD_MAX77686 is not set # CONFIG_MFD_MAX77693 is not set # CONFIG_MFD_MAX77843 is not set @@ -1639,7 +1757,7 @@ CONFIG_MFD_CORE=y # CONFIG_MFD_RETU is not set # CONFIG_MFD_PCF50633 is not set # CONFIG_UCB1400_CORE is not set -# CONFIG_MFD_PM8921_CORE is not set +# CONFIG_MFD_PM8XXX is not set # CONFIG_MFD_RT5033 is not set # CONFIG_MFD_RTSX_USB is not set # CONFIG_MFD_RC5T583 is not set @@ -1656,16 +1774,19 @@ CONFIG_MFD_SYSCON=y # CONFIG_MFD_TI_AM335X_TSCADC is not set # CONFIG_MFD_LP3943 is not set # CONFIG_MFD_LP8788 is not set +# CONFIG_MFD_TI_LMU is not set # CONFIG_MFD_PALMAS is not set # CONFIG_TPS6105X is not set # CONFIG_TPS65010 is not set # CONFIG_TPS6507X is not set +# CONFIG_MFD_TPS65086 is not set # CONFIG_MFD_TPS65090 is not set # CONFIG_MFD_TPS65217 is not set +# CONFIG_MFD_TI_LP873X is not set +# CONFIG_MFD_TI_LP87565 is not set # CONFIG_MFD_TPS65218 is not set # CONFIG_MFD_TPS6586X is not set # CONFIG_MFD_TPS65910 is not set -# CONFIG_MFD_TPS65912 is not set # CONFIG_MFD_TPS65912_I2C is not set # CONFIG_MFD_TPS80031 is not set # CONFIG_TWL4030_CORE is not set @@ -1702,31 +1823,57 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y # CONFIG_REGULATOR_LP872X is not set # CONFIG_REGULATOR_LP8755 is not set # CONFIG_REGULATOR_LTC3589 is not set +# CONFIG_REGULATOR_LTC3676 is not set # CONFIG_REGULATOR_MAX1586 is not set # CONFIG_REGULATOR_MAX8649 is not set # CONFIG_REGULATOR_MAX8660 is not set # CONFIG_REGULATOR_MAX8952 is not set -# CONFIG_REGULATOR_MAX8973 is not set # CONFIG_REGULATOR_MT6311 is not set # CONFIG_REGULATOR_PFUZE100 is not set +# CONFIG_REGULATOR_PV88060 is not set +# CONFIG_REGULATOR_PV88080 is not set +# CONFIG_REGULATOR_PV88090 is not set # CONFIG_REGULATOR_TPS51632 is not set # CONFIG_REGULATOR_TPS62360 is not set # CONFIG_REGULATOR_TPS65023 is not set # CONFIG_REGULATOR_TPS6507X is not set +# CONFIG_REGULATOR_TPS65132 is not set +# CONFIG_REGULATOR_VCTRL is not set CONFIG_REGULATOR_VEXPRESS=y +CONFIG_RC_CORE=y +CONFIG_RC_MAP=y +CONFIG_RC_DECODERS=y +# CONFIG_LIRC is not set +CONFIG_IR_NEC_DECODER=y +CONFIG_IR_RC5_DECODER=y +CONFIG_IR_RC6_DECODER=y +CONFIG_IR_JVC_DECODER=y +CONFIG_IR_SONY_DECODER=y +CONFIG_IR_SANYO_DECODER=y +CONFIG_IR_SHARP_DECODER=y +CONFIG_IR_MCE_KBD_DECODER=y +CONFIG_IR_XMP_DECODER=y +# CONFIG_RC_DEVICES is not set # CONFIG_MEDIA_SUPPORT is not set # # Graphics support # +# CONFIG_IMX_IPUV3_CORE is not set # CONFIG_DRM is not set +# +# ACP (Audio CoProcessor) Configuration +# +# CONFIG_DRM_LIB_RANDOM is not set + # # Frame buffer Devices # CONFIG_FB=y # CONFIG_FIRMWARE_EDID is not set CONFIG_FB_CMDLINE=y +CONFIG_FB_NOTIFY=y # CONFIG_FB_DDC is not set # CONFIG_FB_BOOT_VESA_SUPPORT is not set CONFIG_FB_CFB_FILLRECT=y @@ -1736,6 +1883,7 @@ CONFIG_FB_CFB_IMAGEBLIT=y # CONFIG_FB_SYS_FILLRECT is not set # CONFIG_FB_SYS_COPYAREA is not set # CONFIG_FB_SYS_IMAGEBLIT is not set +# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set # CONFIG_FB_FOREIGN_ENDIAN is not set # CONFIG_FB_SYS_FOPS is not set # CONFIG_FB_SVGALIB is not set @@ -1760,7 +1908,19 @@ CONFIG_PLAT_VERSATILE_CLCD=y # CONFIG_FB_AUO_K190X is not set # CONFIG_FB_SIMPLE is not set # CONFIG_FB_SSD1307 is not set -# CONFIG_BACKLIGHT_LCD_SUPPORT is not set +CONFIG_BACKLIGHT_LCD_SUPPORT=y +CONFIG_LCD_CLASS_DEVICE=m +# CONFIG_LCD_PLATFORM is not set +CONFIG_BACKLIGHT_CLASS_DEVICE=y +CONFIG_BACKLIGHT_GENERIC=y +# CONFIG_BACKLIGHT_PM8941_WLED is not set +# CONFIG_BACKLIGHT_ADP8860 is not set +# CONFIG_BACKLIGHT_ADP8870 is not set +# CONFIG_BACKLIGHT_LM3639 is not set +# CONFIG_BACKLIGHT_GPIO is not set +# CONFIG_BACKLIGHT_LV5207LP is not set +# CONFIG_BACKLIGHT_BD6107 is not set +# CONFIG_BACKLIGHT_ARCXCNN is not set # CONFIG_VGASTATE is not set CONFIG_VIDEOMODE_HELPERS=y @@ -1776,16 +1936,11 @@ CONFIG_LOGO=y # CONFIG_LOGO_LINUX_VGA16 is not set CONFIG_LOGO_LINUX_CLUT224=y CONFIG_SOUND=y -CONFIG_SOUND_OSS_CORE=y -CONFIG_SOUND_OSS_CORE_PRECLAIM=y +# CONFIG_SOUND_OSS_CORE is not set CONFIG_SND=y CONFIG_SND_TIMER=y CONFIG_SND_PCM=y -# CONFIG_SND_SEQUENCER is not set -CONFIG_SND_OSSEMUL=y -CONFIG_SND_MIXER_OSS=y -CONFIG_SND_PCM_OSS=y -CONFIG_SND_PCM_OSS_PLUGINS=y +# CONFIG_SND_OSSEMUL is not set CONFIG_SND_PCM_TIMER=y # CONFIG_SND_DYNAMIC_MINORS is not set CONFIG_SND_SUPPORT_OLD_API=y @@ -1794,11 +1949,9 @@ CONFIG_SND_VERBOSE_PROCFS=y # CONFIG_SND_VERBOSE_PRINTK is not set # CONFIG_SND_DEBUG is not set CONFIG_SND_VMASTER=y -# CONFIG_SND_RAWMIDI_SEQ is not set +# CONFIG_SND_SEQUENCER is not set # CONFIG_SND_OPL3_LIB_SEQ is not set # CONFIG_SND_OPL4_LIB_SEQ is not set -# CONFIG_SND_SBAWE_SEQ is not set -# CONFIG_SND_EMU10K1_SEQ is not set CONFIG_SND_AC97_CODEC=y # CONFIG_SND_DRIVERS is not set @@ -1820,7 +1973,6 @@ CONFIG_SND_USB=y # CONFIG_SND_USB_TONEPORT is not set # CONFIG_SND_USB_VARIAX is not set # CONFIG_SND_SOC is not set -# CONFIG_SOUND_PRIME is not set CONFIG_AC97_BUS=y # @@ -1836,9 +1988,11 @@ CONFIG_HID_GENERIC=y # Special HID drivers # CONFIG_HID_A4TECH=y +# CONFIG_HID_ACCUTOUCH is not set # CONFIG_HID_ACRUX is not set CONFIG_HID_APPLE=y # CONFIG_HID_APPLEIR is not set +# CONFIG_HID_ASUS is not set # CONFIG_HID_AUREAL is not set CONFIG_HID_BELKIN=y # CONFIG_HID_BETOP_FF is not set @@ -1846,7 +2000,7 @@ CONFIG_HID_CHERRY=y CONFIG_HID_CHICONY=y # CONFIG_HID_CORSAIR is not set # CONFIG_HID_PRODIKEYS is not set -# CONFIG_HID_CP2112 is not set +# CONFIG_HID_CMEDIA is not set CONFIG_HID_CYPRESS=y CONFIG_HID_DRAGONRISE=y # CONFIG_DRAGONRISE_FF is not set @@ -1864,9 +2018,11 @@ CONFIG_HID_EZKEY=y # CONFIG_HID_WALTOP is not set CONFIG_HID_GYRATION=y # CONFIG_HID_ICADE is not set +CONFIG_HID_ITE=y CONFIG_HID_TWINHAN=y CONFIG_HID_KENSINGTON=y # CONFIG_HID_LCPOWER is not set +# CONFIG_HID_LED is not set # CONFIG_HID_LENOVO is not set CONFIG_HID_LOGITECH=y # CONFIG_HID_LOGITECH_HIDPP is not set @@ -1875,9 +2031,11 @@ CONFIG_HID_LOGITECH=y # CONFIG_LOGIG940_FF is not set # CONFIG_LOGIWHEELS_FF is not set # CONFIG_HID_MAGICMOUSE is not set +# CONFIG_HID_MAYFLASH is not set CONFIG_HID_MICROSOFT=y CONFIG_HID_MONTEREY=y # CONFIG_HID_MULTITOUCH is not set +# CONFIG_HID_NTI is not set CONFIG_HID_NTRIG=y # CONFIG_HID_ORTEK is not set CONFIG_HID_PANTHERLORD=y @@ -1887,6 +2045,7 @@ CONFIG_HID_PETALYNX=y # CONFIG_HID_PICOLCD is not set # CONFIG_HID_PLANTRONICS is not set # CONFIG_HID_PRIMAX is not set +# CONFIG_HID_RETRODE is not set # CONFIG_HID_ROCCAT is not set # CONFIG_HID_SAITEK is not set CONFIG_HID_SAMSUNG=y @@ -1905,6 +2064,7 @@ CONFIG_HID_TOPSEED=y # CONFIG_HID_THINGM is not set CONFIG_HID_THRUSTMASTER=y # CONFIG_THRUSTMASTER_FF is not set +# CONFIG_HID_UDRAW_PS3 is not set # CONFIG_HID_WACOM is not set # CONFIG_HID_WIIMOTE is not set # CONFIG_HID_XINMO is not set @@ -1912,6 +2072,7 @@ CONFIG_HID_ZEROPLUS=y # CONFIG_ZEROPLUS_FF is not set # CONFIG_HID_ZYDACRON is not set # CONFIG_HID_SENSOR_HUB is not set +# CONFIG_HID_ALPS is not set # # USB HID support @@ -1938,7 +2099,7 @@ CONFIG_USB_DEFAULT_PERSIST=y # CONFIG_USB_DYNAMIC_MINORS is not set # CONFIG_USB_OTG is not set # CONFIG_USB_OTG_WHITELIST is not set -# CONFIG_USB_ULPI_BUS is not set +# CONFIG_USB_LEDS_TRIGGER_USBPORT is not set CONFIG_USB_MON=y # CONFIG_USB_WUSB_CBAF is not set @@ -2016,7 +2177,6 @@ CONFIG_USB_ISP1760_HOST_ROLE=y # CONFIG_USB_SEVSEG is not set # CONFIG_USB_LEGOTOWER is not set # CONFIG_USB_LCD is not set -# CONFIG_USB_LED is not set # CONFIG_USB_CYPRESS_CY7C63 is not set # CONFIG_USB_CYTHERM is not set # CONFIG_USB_IDMOUSE is not set @@ -2030,7 +2190,9 @@ CONFIG_USB_ISP1760_HOST_ROLE=y # CONFIG_USB_ISIGHTFW is not set # CONFIG_USB_YUREX is not set # CONFIG_USB_EZUSB_FX2 is not set +# CONFIG_USB_HUB_USB251XB is not set # CONFIG_USB_HSIC_USB3503 is not set +# CONFIG_USB_HSIC_USB4604 is not set # CONFIG_USB_LINK_LAYER_TEST is not set # CONFIG_USB_CHAOSKEY is not set @@ -2039,28 +2201,30 @@ CONFIG_USB_ISP1760_HOST_ROLE=y # # CONFIG_USB_PHY is not set # CONFIG_NOP_USB_XCEIV is not set -# CONFIG_AM335X_PHY_USB is not set # CONFIG_USB_GPIO_VBUS is not set # CONFIG_USB_ISP1301 is not set # CONFIG_USB_ULPI is not set # CONFIG_USB_GADGET is not set -# CONFIG_USB_LED_TRIG is not set -# CONFIG_UWB is not set -CONFIG_MMC=y -# CONFIG_MMC_DEBUG is not set # -# MMC/SD/SDIO Card Drivers +# USB Power Delivery and Type-C drivers # +# CONFIG_TYPEC_UCSI is not set +# CONFIG_USB_LED_TRIG is not set +# CONFIG_USB_ULPI_BUS is not set +# CONFIG_UWB is not set +CONFIG_MMC=y +CONFIG_PWRSEQ_EMMC=y +CONFIG_PWRSEQ_SIMPLE=y CONFIG_MMC_BLOCK=y CONFIG_MMC_BLOCK_MINORS=8 -CONFIG_MMC_BLOCK_BOUNCE=y # CONFIG_SDIO_UART is not set # CONFIG_MMC_TEST is not set # # MMC/SD/SDIO Host Controller Drivers # +# CONFIG_MMC_DEBUG is not set CONFIG_MMC_ARMMMCI=y # CONFIG_MMC_SDHCI is not set # CONFIG_MMC_DW is not set @@ -2072,6 +2236,7 @@ CONFIG_MMC_ARMMMCI=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y # CONFIG_LEDS_CLASS_FLASH is not set +# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set # # LED drivers @@ -2083,6 +2248,7 @@ CONFIG_LEDS_CLASS=y # CONFIG_LEDS_PCA9532 is not set CONFIG_LEDS_GPIO=y # CONFIG_LEDS_LP3944 is not set +# CONFIG_LEDS_LP3952 is not set # CONFIG_LEDS_LP5521 is not set # CONFIG_LEDS_LP5523 is not set # CONFIG_LEDS_LP5562 is not set @@ -2096,12 +2262,15 @@ CONFIG_LEDS_GPIO=y # CONFIG_LEDS_TCA6507 is not set # CONFIG_LEDS_TLC591XX is not set # CONFIG_LEDS_LM355x is not set +# CONFIG_LEDS_IS31FL319X is not set +# CONFIG_LEDS_IS31FL32XX is not set # # LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM) # # CONFIG_LEDS_BLINKM is not set # CONFIG_LEDS_SYSCON is not set +# CONFIG_LEDS_USER is not set # # LED Triggers @@ -2109,6 +2278,8 @@ CONFIG_LEDS_GPIO=y CONFIG_LEDS_TRIGGERS=y # CONFIG_LEDS_TRIGGER_TIMER is not set # CONFIG_LEDS_TRIGGER_ONESHOT is not set +# CONFIG_LEDS_TRIGGER_DISK is not set +# CONFIG_LEDS_TRIGGER_MTD is not set CONFIG_LEDS_TRIGGER_HEARTBEAT=y # CONFIG_LEDS_TRIGGER_BACKLIGHT is not set CONFIG_LEDS_TRIGGER_CPU=y @@ -2120,10 +2291,10 @@ CONFIG_LEDS_TRIGGER_CPU=y # # CONFIG_LEDS_TRIGGER_TRANSIENT is not set # CONFIG_LEDS_TRIGGER_CAMERA is not set +# CONFIG_LEDS_TRIGGER_PANIC is not set # CONFIG_ACCESSIBILITY is not set CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y -# CONFIG_EDAC is not set CONFIG_RTC_LIB=y CONFIG_RTC_CLASS=y CONFIG_RTC_HCTOSYS=y @@ -2131,6 +2302,7 @@ CONFIG_RTC_HCTOSYS_DEVICE="rtc0" CONFIG_RTC_SYSTOHC=y CONFIG_RTC_SYSTOHC_DEVICE="rtc0" # CONFIG_RTC_DEBUG is not set +CONFIG_RTC_NVMEM=y # # RTC interfaces @@ -2149,32 +2321,37 @@ CONFIG_RTC_INTF_DEV=y # CONFIG_RTC_DRV_DS1307 is not set # CONFIG_RTC_DRV_DS1374 is not set # CONFIG_RTC_DRV_DS1672 is not set -# CONFIG_RTC_DRV_DS3232 is not set # CONFIG_RTC_DRV_HYM8563 is not set # CONFIG_RTC_DRV_MAX6900 is not set # CONFIG_RTC_DRV_RS5C372 is not set # CONFIG_RTC_DRV_ISL1208 is not set # CONFIG_RTC_DRV_ISL12022 is not set -# CONFIG_RTC_DRV_ISL12057 is not set # CONFIG_RTC_DRV_X1205 is not set -# CONFIG_RTC_DRV_PCF2127 is not set # CONFIG_RTC_DRV_PCF8523 is not set -# CONFIG_RTC_DRV_PCF8563 is not set # CONFIG_RTC_DRV_PCF85063 is not set +# CONFIG_RTC_DRV_PCF8563 is not set # CONFIG_RTC_DRV_PCF8583 is not set # CONFIG_RTC_DRV_M41T80 is not set # CONFIG_RTC_DRV_BQ32K is not set # CONFIG_RTC_DRV_S35390A is not set # CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8010 is not set # CONFIG_RTC_DRV_RX8581 is not set # CONFIG_RTC_DRV_RX8025 is not set # CONFIG_RTC_DRV_EM3027 is not set -# CONFIG_RTC_DRV_RV3029C2 is not set # CONFIG_RTC_DRV_RV8803 is not set # # SPI RTC drivers # +CONFIG_RTC_I2C_AND_SPI=y + +# +# SPI and I2C RTC drivers +# +# CONFIG_RTC_DRV_DS3232 is not set +# CONFIG_RTC_DRV_PCF2127 is not set +# CONFIG_RTC_DRV_RV3029C2 is not set # # Platform RTC drivers @@ -2201,13 +2378,20 @@ CONFIG_RTC_INTF_DEV=y # # CONFIG_RTC_DRV_PL030 is not set CONFIG_RTC_DRV_PL031=y +# CONFIG_RTC_DRV_FTRTC010 is not set # CONFIG_RTC_DRV_SNVS is not set +# CONFIG_RTC_DRV_R7301 is not set # # HID Sensor RTC drivers # # CONFIG_RTC_DRV_HID_SENSOR_TIME is not set # CONFIG_DMADEVICES is not set + +# +# DMABUF options +# +# CONFIG_SYNC_FILE is not set # CONFIG_AUXDISPLAY is not set # CONFIG_UIO is not set # CONFIG_VIRT_DRIVERS is not set @@ -2224,7 +2408,9 @@ CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y # # Microsoft Hyper-V guest support # +# CONFIG_HYPERV_TSCPAGE is not set # CONFIG_STAGING is not set +# CONFIG_GOLDFISH is not set # CONFIG_CHROME_PLATFORMS is not set CONFIG_CLKDEV_LOOKUP=y CONFIG_HAVE_CLK_PREPARE=y @@ -2233,26 +2419,29 @@ CONFIG_COMMON_CLK=y # # Common Clock Framework # +CONFIG_ICST=y CONFIG_COMMON_CLK_VERSATILE=y CONFIG_CLK_SP810=y CONFIG_CLK_VEXPRESS_OSC=y +# CONFIG_CLK_HSDK is not set # CONFIG_COMMON_CLK_SI5351 is not set # CONFIG_COMMON_CLK_SI514 is not set # CONFIG_COMMON_CLK_SI570 is not set -# CONFIG_COMMON_CLK_CDCE925 is not set -# CONFIG_CLK_QORIQ is not set -# CONFIG_COMMON_CLK_PXA is not set # CONFIG_COMMON_CLK_CDCE706 is not set - -# -# Hardware Spinlock drivers -# +# CONFIG_COMMON_CLK_CDCE925 is not set +# CONFIG_COMMON_CLK_CS2000_CP is not set +# CONFIG_CLK_QORIQ is not set +# CONFIG_COMMON_CLK_NXP is not set +# CONFIG_COMMON_CLK_PXA is not set +# CONFIG_COMMON_CLK_PIC32 is not set +# CONFIG_COMMON_CLK_VC5 is not set +# CONFIG_HWSPINLOCK is not set # # Clock Source drivers # -CONFIG_CLKSRC_OF=y -CONFIG_CLKSRC_PROBE=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y CONFIG_CLKSRC_MMIO=y CONFIG_ARM_ARCH_TIMER=y CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y @@ -2272,12 +2461,13 @@ CONFIG_IOMMU_SUPPORT=y # Generic IOMMU Pagetable Support # # CONFIG_IOMMU_IO_PGTABLE_LPAE is not set +# CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set # CONFIG_ARM_SMMU is not set # # Remoteproc drivers # -# CONFIG_STE_MODEM_RPROC is not set +# CONFIG_REMOTEPROC is not set # # Rpmsg drivers @@ -2286,7 +2476,23 @@ CONFIG_IOMMU_SUPPORT=y # # SOC (System On Chip) specific Drivers # + +# +# Amlogic SoC drivers +# + +# +# Broadcom SoC drivers +# # CONFIG_SOC_BRCMSTB is not set + +# +# i.MX SoC drivers +# + +# +# Qualcomm SoC drivers +# # CONFIG_SUNXI_SRAM is not set # CONFIG_SOC_TI is not set # CONFIG_PM_DEVFREQ is not set @@ -2296,6 +2502,7 @@ CONFIG_IOMMU_SUPPORT=y # CONFIG_PWM is not set CONFIG_IRQCHIP=y CONFIG_ARM_GIC=y +CONFIG_ARM_GIC_MAX_NR=1 # CONFIG_IPACK_BUS is not set # CONFIG_RESET_CONTROLLER is not set # CONFIG_FMC is not set @@ -2304,9 +2511,9 @@ CONFIG_ARM_GIC=y # PHY Subsystem # # CONFIG_GENERIC_PHY is not set +# CONFIG_BCM_KONA_USB2_PHY is not set # CONFIG_PHY_PXA_28NM_HSIC is not set # CONFIG_PHY_PXA_28NM_USB2 is not set -# CONFIG_BCM_KONA_USB2_PHY is not set # CONFIG_POWERCAP is not set # CONFIG_MCB is not set @@ -2320,21 +2527,30 @@ CONFIG_ARM_PMU=y # Android # # CONFIG_ANDROID is not set -# CONFIG_NVMEM is not set +# CONFIG_DAX is not set +CONFIG_NVMEM=y # CONFIG_STM is not set # CONFIG_INTEL_TH is not set +# CONFIG_FPGA is not set # -# FPGA Configuration Support +# FSI support # -# CONFIG_FPGA is not set +# CONFIG_FSI is not set +# CONFIG_TEE is not set # # Firmware Drivers # CONFIG_ARM_PSCI_FW=y +# CONFIG_ARM_PSCI_CHECKER is not set # CONFIG_FIRMWARE_MEMMAP is not set CONFIG_HAVE_ARM_SMCCC=y +# CONFIG_GOOGLE_FIRMWARE is not set + +# +# Tegra firmware driver +# # # File systems @@ -2359,7 +2575,11 @@ CONFIG_FS_MBCACHE=y # CONFIG_NILFS2_FS is not set # CONFIG_F2FS_FS is not set # CONFIG_FS_POSIX_ACL is not set +CONFIG_EXPORTFS=y +# CONFIG_EXPORTFS_BLOCK_OPS is not set CONFIG_FILE_LOCKING=y +CONFIG_MANDATORY_FILE_LOCKING=y +# CONFIG_FS_ENCRYPTION is not set CONFIG_FSNOTIFY=y CONFIG_DNOTIFY=y CONFIG_INOTIFY_USER=y @@ -2389,6 +2609,7 @@ CONFIG_FAT_FS=y CONFIG_VFAT_FS=y CONFIG_FAT_DEFAULT_CODEPAGE=437 CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +# CONFIG_FAT_DEFAULT_UTF8 is not set # CONFIG_NTFS_FS is not set # @@ -2406,6 +2627,7 @@ CONFIG_TMPFS=y # CONFIG_HUGETLB_PAGE is not set # CONFIG_CONFIGFS_FS is not set CONFIG_MISC_FILESYSTEMS=y +# CONFIG_ORANGEFS_FS is not set # CONFIG_ADFS_FS is not set # CONFIG_AFFS_FS is not set # CONFIG_HFS_FS is not set @@ -2429,7 +2651,8 @@ CONFIG_UBIFS_FS=y CONFIG_UBIFS_FS_LZO=y CONFIG_UBIFS_FS_ZLIB=y # CONFIG_UBIFS_ATIME_SUPPORT is not set -# CONFIG_LOGFS is not set +# CONFIG_UBIFS_FS_ENCRYPTION is not set +CONFIG_UBIFS_FS_SECURITY=y CONFIG_CRAMFS=y CONFIG_SQUASHFS=y CONFIG_SQUASHFS_FILE_CACHE=y @@ -2442,6 +2665,7 @@ CONFIG_SQUASHFS_ZLIB=y # CONFIG_SQUASHFS_LZ4 is not set CONFIG_SQUASHFS_LZO=y # CONFIG_SQUASHFS_XZ is not set +# CONFIG_SQUASHFS_ZSTD is not set # CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set # CONFIG_SQUASHFS_EMBEDDED is not set CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 @@ -2538,6 +2762,7 @@ CONFIG_NLS_ISO8859_1=y # printk and dmesg options # # CONFIG_PRINTK_TIME is not set +CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7 CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 # CONFIG_BOOT_PRINTK_DELAY is not set # CONFIG_DYNAMIC_DEBUG is not set @@ -2564,6 +2789,7 @@ CONFIG_SECTION_MISMATCH_WARN_ONLY=y # CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set CONFIG_MAGIC_SYSRQ=y CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1 +CONFIG_MAGIC_SYSRQ_SERIAL=y CONFIG_DEBUG_KERNEL=y # @@ -2571,6 +2797,9 @@ CONFIG_DEBUG_KERNEL=y # # CONFIG_PAGE_EXTENSION is not set # CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_PAGE_POISONING is not set +# CONFIG_DEBUG_PAGE_REF is not set +# CONFIG_DEBUG_RODATA_TEST is not set # CONFIG_DEBUG_OBJECTS is not set # CONFIG_SLUB_DEBUG_ON is not set # CONFIG_SLUB_STATS is not set @@ -2578,6 +2807,8 @@ CONFIG_HAVE_DEBUG_KMEMLEAK=y # CONFIG_DEBUG_KMEMLEAK is not set # CONFIG_DEBUG_STACK_USAGE is not set # CONFIG_DEBUG_VM is not set +CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y +# CONFIG_DEBUG_VIRTUAL is not set CONFIG_DEBUG_MEMORY_INIT=y # CONFIG_DEBUG_PER_CPU_MAPS is not set # CONFIG_DEBUG_SHIRQ is not set @@ -2585,11 +2816,12 @@ CONFIG_DEBUG_MEMORY_INIT=y # # Debug Lockups and Hangs # -# CONFIG_LOCKUP_DETECTOR is not set +# CONFIG_SOFTLOCKUP_DETECTOR is not set CONFIG_DETECT_HUNG_TASK=y CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 # CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0 +# CONFIG_WQ_WATCHDOG is not set # CONFIG_PANIC_ON_OOPS is not set CONFIG_PANIC_ON_OOPS_VALUE=0 CONFIG_PANIC_TIMEOUT=0 @@ -2598,7 +2830,6 @@ CONFIG_PANIC_TIMEOUT=0 # CONFIG_SCHEDSTATS is not set # CONFIG_SCHED_STACK_END_CHECK is not set # CONFIG_DEBUG_TIMEKEEPING is not set -# CONFIG_TIMER_STATS is not set # # Lock Debugging (spinlocks, mutexes, etc...) @@ -2613,7 +2844,9 @@ CONFIG_PANIC_TIMEOUT=0 # CONFIG_DEBUG_ATOMIC_SLEEP is not set # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set # CONFIG_LOCK_TORTURE_TEST is not set -# CONFIG_STACKTRACE is not set +# CONFIG_WW_MUTEX_SELFTEST is not set +CONFIG_STACKTRACE=y +# CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set # CONFIG_DEBUG_KOBJECT is not set CONFIG_DEBUG_BUGVERBOSE=y # CONFIG_DEBUG_LIST is not set @@ -2626,29 +2859,38 @@ CONFIG_DEBUG_BUGVERBOSE=y # RCU Debugging # # CONFIG_PROVE_RCU is not set -# CONFIG_SPARSE_RCU_POINTER is not set # CONFIG_TORTURE_TEST is not set +# CONFIG_RCU_PERF_TEST is not set # CONFIG_RCU_TORTURE_TEST is not set CONFIG_RCU_CPU_STALL_TIMEOUT=21 -# CONFIG_RCU_TRACE is not set +CONFIG_RCU_TRACE=y # CONFIG_RCU_EQS_DEBUG is not set +# CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set # CONFIG_DEBUG_BLOCK_EXT_DEVT is not set +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set # CONFIG_NOTIFIER_ERROR_INJECTION is not set # CONFIG_FAULT_INJECTION is not set +# CONFIG_LATENCYTOP is not set +CONFIG_NOP_TRACER=y CONFIG_HAVE_FUNCTION_TRACER=y CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y CONFIG_HAVE_SYSCALL_TRACEPOINTS=y CONFIG_HAVE_C_RECORDMCOUNT=y CONFIG_TRACE_CLOCK=y CONFIG_RING_BUFFER=y +CONFIG_EVENT_TRACING=y +CONFIG_CONTEXT_SWITCH_TRACER=y CONFIG_RING_BUFFER_ALLOW_SWAP=y +CONFIG_TRACING=y CONFIG_TRACING_SUPPORT=y CONFIG_FTRACE=y # CONFIG_FUNCTION_TRACER is not set # CONFIG_IRQSOFF_TRACER is not set # CONFIG_SCHED_TRACER is not set +# CONFIG_HWLAT_TRACER is not set # CONFIG_ENABLE_DEFAULT_TRACERS is not set # CONFIG_FTRACE_SYSCALLS is not set # CONFIG_TRACER_SNAPSHOT is not set @@ -2657,18 +2899,21 @@ CONFIG_BRANCH_PROFILE_NONE=y # CONFIG_PROFILE_ALL_BRANCHES is not set # CONFIG_STACK_TRACER is not set # CONFIG_BLK_DEV_IO_TRACE is not set -# CONFIG_UPROBE_EVENT is not set -# CONFIG_PROBE_EVENTS is not set +CONFIG_UPROBE_EVENTS=y +CONFIG_PROBE_EVENTS=y # CONFIG_TRACEPOINT_BENCHMARK is not set # CONFIG_RING_BUFFER_BENCHMARK is not set # CONFIG_RING_BUFFER_STARTUP_TEST is not set +# CONFIG_TRACE_EVAL_MAP_FILE is not set CONFIG_TRACING_EVENTS_GPIO=y +# CONFIG_DMA_API_DEBUG is not set # # Runtime Testing # # CONFIG_LKDTM is not set # CONFIG_TEST_LIST_SORT is not set +# CONFIG_TEST_SORT is not set # CONFIG_BACKTRACE_SELF_TEST is not set # CONFIG_RBTREE_TEST is not set # CONFIG_INTERVAL_TREE_TEST is not set @@ -2678,21 +2923,29 @@ CONFIG_TRACING_EVENTS_GPIO=y # CONFIG_TEST_STRING_HELPERS is not set # CONFIG_TEST_KSTRTOX is not set # CONFIG_TEST_PRINTF is not set +# CONFIG_TEST_BITMAP is not set +# CONFIG_TEST_UUID is not set # CONFIG_TEST_RHASHTABLE is not set # CONFIG_TEST_HASH is not set -# CONFIG_DMA_API_DEBUG is not set # CONFIG_TEST_LKM is not set # CONFIG_TEST_USER_COPY is not set # CONFIG_TEST_BPF is not set # CONFIG_TEST_FIRMWARE is not set +# CONFIG_TEST_SYSCTL is not set # CONFIG_TEST_UDELAY is not set -# CONFIG_MEMTEST is not set # CONFIG_TEST_STATIC_KEYS is not set +# CONFIG_MEMTEST is not set +# CONFIG_BUG_ON_DATA_CORRUPTION is not set # CONFIG_SAMPLES is not set CONFIG_HAVE_ARCH_KGDB=y # CONFIG_KGDB is not set -# CONFIG_ARM_PTDUMP is not set +# CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set +# CONFIG_UBSAN is not set +CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y # CONFIG_STRICT_DEVMEM is not set +# CONFIG_ARM_PTDUMP is not set +# CONFIG_UNWINDER_FRAME_POINTER is not set +CONFIG_UNWINDER_ARM=y CONFIG_ARM_UNWIND=y CONFIG_DEBUG_USER=y # CONFIG_DEBUG_LL is not set @@ -2700,7 +2953,6 @@ CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" # CONFIG_DEBUG_UART_8250 is not set CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" # CONFIG_PID_IN_CONTEXTIDR is not set -# CONFIG_DEBUG_SET_MODULE_RONX is not set # CONFIG_CORESIGHT is not set # @@ -2710,6 +2962,9 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" # CONFIG_SECURITY_DMESG_RESTRICT is not set # CONFIG_SECURITY is not set # CONFIG_SECURITYFS is not set +CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR=y +# CONFIG_HARDENED_USERCOPY is not set +# CONFIG_STATIC_USERMODEHELPER is not set CONFIG_DEFAULT_SECURITY_DAC=y CONFIG_DEFAULT_SECURITY="" CONFIG_CRYPTO=y @@ -2727,9 +2982,12 @@ CONFIG_CRYPTO_HASH2=y CONFIG_CRYPTO_RNG=m CONFIG_CRYPTO_RNG2=y CONFIG_CRYPTO_RNG_DEFAULT=m -CONFIG_CRYPTO_PCOMP2=y CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_KPP2=y +CONFIG_CRYPTO_ACOMP2=y # CONFIG_CRYPTO_RSA is not set +# CONFIG_CRYPTO_DH is not set +# CONFIG_CRYPTO_ECDH is not set CONFIG_CRYPTO_MANAGER=m CONFIG_CRYPTO_MANAGER2=y # CONFIG_CRYPTO_USER is not set @@ -2791,6 +3049,7 @@ CONFIG_CRYPTO_CRC32C=y # CONFIG_CRYPTO_SHA1 is not set CONFIG_CRYPTO_SHA256=m # CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_SHA3 is not set # CONFIG_CRYPTO_TGR192 is not set # CONFIG_CRYPTO_WP512 is not set @@ -2798,6 +3057,7 @@ CONFIG_CRYPTO_SHA256=m # Ciphers # CONFIG_CRYPTO_AES=y +# CONFIG_CRYPTO_AES_TI is not set # CONFIG_CRYPTO_ANUBIS is not set # CONFIG_CRYPTO_ARC4 is not set # CONFIG_CRYPTO_BLOWFISH is not set @@ -2818,7 +3078,6 @@ CONFIG_CRYPTO_AES=y # Compression # CONFIG_CRYPTO_DEFLATE=y -# CONFIG_CRYPTO_ZLIB is not set CONFIG_CRYPTO_LZO=y # CONFIG_CRYPTO_842 is not set # CONFIG_CRYPTO_LZ4 is not set @@ -2831,7 +3090,6 @@ CONFIG_CRYPTO_LZO=y CONFIG_CRYPTO_DRBG_MENU=m CONFIG_CRYPTO_DRBG_HMAC=y # CONFIG_CRYPTO_DRBG_HASH is not set -# CONFIG_CRYPTO_DRBG_CTR is not set CONFIG_CRYPTO_DRBG=m CONFIG_CRYPTO_JITTERENTROPY=m # CONFIG_CRYPTO_USER_API_HASH is not set @@ -2844,7 +3102,7 @@ CONFIG_CRYPTO_JITTERENTROPY=m # Certificates for signature checking # # CONFIG_ARM_CRYPTO is not set -# CONFIG_BINARY_PRINTF is not set +CONFIG_BINARY_PRINTF=y # # Library routines @@ -2868,6 +3126,7 @@ CONFIG_CRC32_SLICEBY8=y # CONFIG_CRC32_SLICEBY4 is not set # CONFIG_CRC32_SARWATE is not set # CONFIG_CRC32_BIT is not set +# CONFIG_CRC4 is not set # CONFIG_CRC7 is not set # CONFIG_LIBCRC32C is not set # CONFIG_CRC8 is not set @@ -2896,19 +3155,25 @@ CONFIG_DECOMPRESS_LZ4=y CONFIG_GENERIC_ALLOCATOR=y CONFIG_HAS_IOMEM=y CONFIG_HAS_DMA=y +# CONFIG_SGL_ALLOC is not set +# CONFIG_DMA_NOOP_OPS is not set +# CONFIG_DMA_VIRT_OPS is not set CONFIG_CPU_RMAP=y CONFIG_DQL=y CONFIG_GLOB=y # CONFIG_GLOB_SELFTEST is not set CONFIG_NLATTR=y -CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y # CONFIG_CORDIC is not set # CONFIG_DDR is not set +# CONFIG_IRQ_POLL is not set CONFIG_LIBFDT=y CONFIG_FONT_SUPPORT=y # CONFIG_FONTS is not set CONFIG_FONT_8x8=y CONFIG_FONT_8x16=y # CONFIG_SG_SPLIT is not set +CONFIG_SG_POOL=y CONFIG_ARCH_HAS_SG_CHAIN=y +CONFIG_SBITMAP=y +# CONFIG_STRING_SELFTEST is not set # CONFIG_VIRTUALIZATION is not set From 35b87d02068406d2fd34ef31adafd49b0f1f7552 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 18 Jul 2023 21:04:44 -0700 Subject: [PATCH 025/150] ci: Update dist-powerpc64le-linux to ubuntu:22.04 --- .../docker/host-x86_64/dist-powerpc64le-linux/Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile index 2b2871c2ec06..5dc282403be9 100644 --- a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile @@ -1,22 +1,16 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh COPY scripts/rustbuild-setup.sh /scripts/ RUN sh /scripts/rustbuild-setup.sh -USER rustbuild WORKDIR /tmp -USER root - RUN apt-get install -y --no-install-recommends rpm2cpio cpio COPY host-x86_64/dist-powerpc64le-linux/shared.sh host-x86_64/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh /tmp/ RUN ./build-powerpc64le-toolchain.sh -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From 5dff575c56acdfe1f0dacffbc99dab9e15e2a048 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 19 Jul 2023 15:57:57 -0700 Subject: [PATCH 026/150] ci: Update dist-various-1 to ubuntu:22.04 --- .../docker/host-x86_64/dist-various-1/Dockerfile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile index c2abe9f19a31..99cb1d70147b 100644 --- a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ automake \ bison \ @@ -73,8 +74,8 @@ RUN env \ CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm -mfpu=vfp" \ bash musl.sh armhf && \ env \ - CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \ - CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a" \ + CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a -mfpu=vfp3" \ + CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a -mfpu=vfp3" \ bash musl.sh armv7hf && \ env \ CC=mips-openwrt-linux-gcc \ @@ -147,7 +148,7 @@ ENV TARGETS=$TARGETS,armv7a-none-eabi ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" \ CFLAGS_arm_unknown_linux_musleabi="-march=armv6 -marm" \ CFLAGS_arm_unknown_linux_musleabihf="-march=armv6 -marm -mfpu=vfp" \ - CFLAGS_armv7_unknown_linux_musleabihf="-march=armv7-a" \ + CFLAGS_armv7_unknown_linux_musleabihf="-march=armv7-a -mfpu=vfp3" \ CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ CC_mips64el_unknown_linux_muslabi64=mips64el-linux-gnuabi64-gcc \ @@ -186,9 +187,6 @@ ENV SCRIPT \ python3 ../x.py --stage 2 test --host='' --target $RUN_MAKE_TARGETS tests/run-make && \ python3 ../x.py dist --host='' --target $TARGETS -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - # sccache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From 69d56abfbdbbf00e9c7bc0992b1b8de7d8aaf330 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 19 Jul 2023 18:01:24 -0700 Subject: [PATCH 027/150] ci: Update dist-various-2 to ubuntu:22.04 --- .../host-x86_64/dist-various-2/Dockerfile | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index 6367aacfdde8..dd1c5fced0e8 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh @@ -9,7 +9,7 @@ RUN sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no-install-recommends \ build-essential \ # gcc-multilib can not be installed together with gcc-arm-linux-gnueabi - g++-8-multilib \ + g++-9-multilib \ libedit-dev \ libgmp-dev \ libisl-dev \ @@ -24,7 +24,7 @@ RUN apt-get update && apt-get build-dep -y clang llvm && apt-get install -y --no # Needed for apt-key to work: dirmngr \ gpg-agent \ - g++-8-arm-linux-gnueabi + g++-9-arm-linux-gnueabi RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486 RUN add-apt-repository -y 'deb https://apt.dilos.org/dilos dilos2 main' @@ -51,8 +51,8 @@ ENV \ AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar \ CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \ CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ \ - CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-8 \ - CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-8 \ + CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-9 \ + CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-9 \ AR_x86_64_fortanix_unknown_sgx=ar \ CC_x86_64_fortanix_unknown_sgx=clang-11 \ CFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening" \ @@ -67,14 +67,14 @@ ENV \ CXX_i686_unknown_uefi=clang++-11 \ CC_x86_64_unknown_uefi=clang-11 \ CXX_x86_64_unknown_uefi=clang++-11 \ - CC=gcc-8 \ - CXX=g++-8 + CC=gcc-9 \ + CXX=g++-9 WORKDIR /build COPY scripts/musl.sh /build RUN env \ - CC=arm-linux-gnueabi-gcc-8 CFLAGS="-march=armv7-a" \ - CXX=arm-linux-gnueabi-g++-8 CXXFLAGS="-march=armv7-a" \ + CC=arm-linux-gnueabi-gcc-9 CFLAGS="-march=armv7-a" \ + CXX=arm-linux-gnueabi-g++-9 CXXFLAGS="-march=armv7-a" \ bash musl.sh armv7 && \ rm -rf /build/* @@ -96,9 +96,6 @@ RUN /tmp/build-wasi-toolchain.sh COPY scripts/freebsd-toolchain.sh /tmp/ RUN /tmp/freebsd-toolchain.sh i686 -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh @@ -132,7 +129,7 @@ ENV TARGETS=$TARGETS,i686-unknown-uefi ENV TARGETS=$TARGETS,x86_64-unknown-uefi # As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211 -# we need asm in the search path for gcc-8 (for gnux32) but not in the search path of the +# we need asm in the search path for gcc-9 (for gnux32) but not in the search path of the # cross compilers. # Luckily one of the folders is /usr/local/include so symlink /usr/include/asm-generic there RUN ln -s /usr/include/asm-generic /usr/local/include/asm From a82fa0d1c719a3ec42aaa76d0a5aba3703014322 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 20 Jul 2023 16:08:41 -0700 Subject: [PATCH 028/150] ci: Update dist-x86_64-musl to ubuntu:22.04 --- src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile index 6f04dcad9a54..c9a6a2dd069e 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ make \ ninja-build \ @@ -11,6 +12,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins python3 \ git \ cmake \ + bzip2 \ xz-utils \ sudo \ gdb \ @@ -21,10 +23,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins WORKDIR /build/ -# Build cmake before musl toolchain, as we replace the compiler during that step. -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/musl-toolchain.sh /build/ # We need to mitigate rust-lang/rust#34978 when compiling musl itself as well RUN CFLAGS="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \ From ecb84f65ea07c2b2b922034b18c998cf3591d1db Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 20 Jul 2023 17:15:02 -0700 Subject: [PATCH 029/150] ci: Update dist-x86_64-netbsd to ubuntu:22.04 --- .../docker/host-x86_64/dist-x86_64-netbsd/Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-netbsd/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-netbsd/Dockerfile index 041bacf33975..effdc99d9a65 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-netbsd/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-netbsd/Dockerfile @@ -1,14 +1,14 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 +ARG DEBIAN_FRONTEND=noninteractive COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y zlib1g-dev +RUN apt-get install -y zlib1g-dev COPY host-x86_64/dist-x86_64-netbsd/build-netbsd-toolchain.sh /tmp/ -RUN /tmp/build-netbsd-toolchain.sh - -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh +# GCC 10 changed the default to -fno-common, which causes errors with the NetBSD-9.0 sources like: +# /usr/bin/ld: buf.o:(.bss+0x0): multiple definition of `debug_file'; arch.o:(.bss+0x0): first defined here +RUN env HOST_CFLAGS="-O -fcommon" /tmp/build-netbsd-toolchain.sh COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From 294b2145e006cd5621bedc8b719dd7869e9c66e7 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 20 Jul 2023 18:05:00 -0700 Subject: [PATCH 030/150] ci: Update test-various to ubuntu:22.04 --- src/ci/docker/host-x86_64/test-various/Dockerfile | 15 +++++---------- .../test-various/uefi_qemu_test/run.py | 7 +------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index 002f221b1f3c..4fe66014c17c 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ clang-11 \ g++ \ make \ @@ -15,10 +16,12 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins gdb \ libssl-dev \ pkg-config \ + bzip2 \ xz-utils \ wget \ patch \ ovmf \ + ovmf-ia32 \ qemu-efi-aarch64 \ qemu-system-arm \ qemu-system-x86 \ @@ -27,19 +30,11 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins RUN curl -sL https://nodejs.org/dist/v18.12.0/node-v18.12.0-linux-x64.tar.xz | \ tar -xJ -# Install 32-bit OVMF files for the i686-unknown-uefi test. This package -# is not available in ubuntu 20.04, so download a 22.04 package. -RUN curl -sL --output ovmf-ia32.deb http://mirrors.kernel.org/ubuntu/pool/universe/e/edk2/ovmf-ia32_2022.02-3_all.deb -RUN dpkg -i ovmf-ia32.deb && rm ovmf-ia32.deb - WORKDIR /build/ COPY scripts/musl-toolchain.sh /build/ RUN bash musl-toolchain.sh x86_64 && rm -rf build WORKDIR / -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh diff --git a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py index ffae7b0d4ac2..3577643ca550 100755 --- a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py +++ b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py @@ -109,12 +109,7 @@ def build_and_run(tmp_dir, target): '-drive', f'format=raw,file=fat:rw:{esp}', capture=True, - # Ubuntu 20.04 (which is what the Dockerfile currently - # uses) provides QEMU 4.2.1, which segfaults on - # shutdown under some circumstances. That has been - # fixed in newer versions of QEMU, but for now just - # don't check the exit status. - check=False, + check=True, # Set a timeout to kill the VM in case something goes wrong. timeout=60).stdout From 137de9365eb390d2b197ec05fb7b377aef2739ae Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 21 Jul 2023 09:04:49 -0700 Subject: [PATCH 031/150] ci: Update wasm32 to ubuntu:22.04 --- src/ci/docker/host-x86_64/wasm32/Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ci/docker/host-x86_64/wasm32/Dockerfile b/src/ci/docker/host-x86_64/wasm32/Dockerfile index 0e8989e10f28..24a1ccb7fc2c 100644 --- a/src/ci/docker/host-x86_64/wasm32/Dockerfile +++ b/src/ci/docker/host-x86_64/wasm32/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ make \ ninja-build \ @@ -20,9 +21,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins COPY scripts/emscripten.sh /scripts/ RUN bash /scripts/emscripten.sh -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh @@ -57,6 +55,7 @@ COPY static/gitconfig /etc/gitconfig # Emscripten installation is user-specific ENV NO_CHANGE_USER=1 +RUN chown 10719 -R /emsdk-portable/ # Exclude library/alloc due to OOM in benches. ENV SCRIPT python3 ../x.py test --stage 2 --host='' --target $TARGETS \ From e9e424854973b8cc8cf58911067231a6de7fd1be Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 21 Jul 2023 10:01:34 -0700 Subject: [PATCH 032/150] ci: Update x86_64-gnu-debug to ubuntu:22.04 --- src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile index b404e3b982ba..e4534d0f8408 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-debug/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -26,9 +26,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ clang \ && rm -rf /var/lib/apt/lists/* -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From d34a2b18704242a2527ee84ad46f0aed9f466fbe Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 21 Jul 2023 10:41:57 -0700 Subject: [PATCH 033/150] ci: Update x86_64-gnu-nopt to ubuntu:22.04 --- src/ci/docker/host-x86_64/x86_64-gnu-nopt/Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-nopt/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-nopt/Dockerfile index 1452c00a5d8e..d8113e067237 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-nopt/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-nopt/Dockerfile @@ -1,7 +1,8 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 # Avoid interactive prompts while installing `tzdata` dependency with `DEBIAN_FRONTEND`. -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ make \ ninja-build \ @@ -18,9 +19,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins xz-utils \ && rm -rf /var/lib/apt/lists/* -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From 3585562be676b1159e7922ffa4d39ec42d5c0b05 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 21 Jul 2023 11:04:59 -0700 Subject: [PATCH 034/150] ci: Update x86_64-gnu to ubuntu:22.04 --- src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile index 576487821dc6..9025e9bb0a3a 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -19,9 +19,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ mingw-w64 \ && rm -rf /var/lib/apt/lists/* -COPY scripts/cmake.sh /scripts/ -RUN /scripts/cmake.sh - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh From 33ec4e4bb0e332072b5dbd31f8f024dff4e3f44e Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 24 May 2023 16:05:42 +0000 Subject: [PATCH 035/150] make `noop_method_call` warn by default --- compiler/rustc_lint/src/noop_method_call.rs | 3 +-- tests/ui/issues/issue-11820.rs | 2 ++ tests/ui/lint/noop-method-call.rs | 1 - tests/ui/lint/noop-method-call.stderr | 22 +++++++++------------ tests/ui/underscore-imports/cycle.rs | 2 ++ tests/ui/underscore-imports/hygiene.rs | 1 + 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_lint/src/noop_method_call.rs b/compiler/rustc_lint/src/noop_method_call.rs index 13f650c20082..2817a665bb0a 100644 --- a/compiler/rustc_lint/src/noop_method_call.rs +++ b/compiler/rustc_lint/src/noop_method_call.rs @@ -18,7 +18,6 @@ declare_lint! { /// /// ```rust /// # #![allow(unused)] - /// #![warn(noop_method_call)] /// struct Foo; /// let foo = &Foo; /// let clone: &Foo = foo.clone(); @@ -34,7 +33,7 @@ declare_lint! { /// calling `clone` on a `&T` where `T` does not implement clone, actually doesn't do anything /// as references are copy. This lint detects these calls and warns the user about them. pub NOOP_METHOD_CALL, - Allow, + Warn, "detects the use of well-known noop methods" } diff --git a/tests/ui/issues/issue-11820.rs b/tests/ui/issues/issue-11820.rs index 7ffe9652797c..dc6349b10ee5 100644 --- a/tests/ui/issues/issue-11820.rs +++ b/tests/ui/issues/issue-11820.rs @@ -1,6 +1,8 @@ // run-pass // pretty-expanded FIXME #23616 +#![allow(noop_method_call)] + struct NoClone; fn main() { diff --git a/tests/ui/lint/noop-method-call.rs b/tests/ui/lint/noop-method-call.rs index dbcf2a5131b5..8ce6c859b248 100644 --- a/tests/ui/lint/noop-method-call.rs +++ b/tests/ui/lint/noop-method-call.rs @@ -1,7 +1,6 @@ // check-pass #![allow(unused)] -#![warn(noop_method_call)] use std::borrow::Borrow; use std::ops::Deref; diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr index 37cd1a0fc18e..ae61913f9938 100644 --- a/tests/ui/lint/noop-method-call.stderr +++ b/tests/ui/lint/noop-method-call.stderr @@ -1,18 +1,14 @@ warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:16:71 + --> $DIR/noop-method-call.rs:15:71 | LL | let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); | ^^^^^^^^ unnecessary method call | = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed -note: the lint level is defined here - --> $DIR/noop-method-call.rs:4:9 - | -LL | #![warn(noop_method_call)] - | ^^^^^^^^^^^^^^^^ + = note: `#[warn(noop_method_call)]` on by default warning: using `.clone()` on a double reference, which returns `&CloneType` instead of cloning the inner type - --> $DIR/noop-method-call.rs:23:63 + --> $DIR/noop-method-call.rs:22:63 | LL | let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); | ^^^^^^^^ @@ -20,7 +16,7 @@ LL | let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); = note: `#[warn(suspicious_double_ref_op)]` on by default warning: call to `.deref()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:27:63 + --> $DIR/noop-method-call.rs:26:63 | LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); | ^^^^^^^^ unnecessary method call @@ -28,13 +24,13 @@ LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); = note: the type `&PlainType` which `deref` is being called on is the same as the type returned from `deref`, so the method call does not do anything and can be removed warning: using `.deref()` on a double reference, which returns `&PlainType` instead of dereferencing the inner type - --> $DIR/noop-method-call.rs:31:63 + --> $DIR/noop-method-call.rs:30:63 | LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); | ^^^^^^^^ warning: call to `.borrow()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:35:66 + --> $DIR/noop-method-call.rs:34:66 | LL | let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); | ^^^^^^^^^ unnecessary method call @@ -42,13 +38,13 @@ LL | let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); = note: the type `&PlainType` which `borrow` is being called on is the same as the type returned from `borrow`, so the method call does not do anything and can be removed warning: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type - --> $DIR/noop-method-call.rs:43:44 + --> $DIR/noop-method-call.rs:42:44 | LL | let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead | ^^^^^^^^ warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:48:19 + --> $DIR/noop-method-call.rs:47:19 | LL | non_clone_type.clone(); | ^^^^^^^^ unnecessary method call @@ -56,7 +52,7 @@ LL | non_clone_type.clone(); = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:53:19 + --> $DIR/noop-method-call.rs:52:19 | LL | non_clone_type.clone(); | ^^^^^^^^ unnecessary method call diff --git a/tests/ui/underscore-imports/cycle.rs b/tests/ui/underscore-imports/cycle.rs index bacf9b2d5a96..c8a293687878 100644 --- a/tests/ui/underscore-imports/cycle.rs +++ b/tests/ui/underscore-imports/cycle.rs @@ -2,6 +2,8 @@ // check-pass +#![allow(noop_method_call)] + mod x { pub use crate::y::*; pub use std::ops::Deref as _; diff --git a/tests/ui/underscore-imports/hygiene.rs b/tests/ui/underscore-imports/hygiene.rs index c4db65245386..7795ccb79719 100644 --- a/tests/ui/underscore-imports/hygiene.rs +++ b/tests/ui/underscore-imports/hygiene.rs @@ -3,6 +3,7 @@ // check-pass #![feature(decl_macro)] +#![allow(noop_method_call)] mod x { pub use std::ops::Deref as _; From 626efab67f184658eb966d3a69c31d7f1deb47e4 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 25 May 2023 05:21:44 +0000 Subject: [PATCH 036/150] fix --- compiler/rustc_lint/messages.ftl | 2 +- compiler/rustc_lint/src/lints.rs | 3 ++- compiler/rustc_lint/src/noop_method_call.rs | 11 +++++---- .../src/traits/error_reporting/suggestions.rs | 3 +-- library/core/benches/iter.rs | 1 + .../tests/ui/explicit_deref_methods.fixed | 1 + .../clippy/tests/ui/explicit_deref_methods.rs | 1 + .../tests/ui/explicit_deref_methods.stderr | 24 +++++++++---------- src/tools/compiletest/src/lib.rs | 2 +- tests/ui/lint/noop-method-call.stderr | 10 ++++---- tests/ui/lint/suspicious-double-ref-op.stderr | 4 ++-- 11 files changed, 33 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 2c92277b50d2..598373a8301e 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -413,7 +413,7 @@ lint_non_upper_case_global = {$sort} `{$name}` should have an upper case name lint_noop_method_call = call to `.{$method}()` on a reference in this situation does nothing .label = unnecessary method call - .note = the type `{$receiver_ty}` which `{$method}` is being called on is the same as the type returned from `{$method}`, so the method call does not do anything and can be removed + .note = the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed lint_only_cast_u8_to_char = only `u8` can be cast into `char` .suggestion = use a `char` literal instead diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1dea758bb294..322a3b6583dd 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1231,7 +1231,8 @@ pub enum NonUpperCaseGlobalSub { #[note] pub struct NoopMethodCallDiag<'a> { pub method: Symbol, - pub receiver_ty: Ty<'a>, + pub orig_ty: Ty<'a>, + pub trait_: Symbol, #[label] pub label: Span, } diff --git a/compiler/rustc_lint/src/noop_method_call.rs b/compiler/rustc_lint/src/noop_method_call.rs index 2817a665bb0a..bc0b9d6d8187 100644 --- a/compiler/rustc_lint/src/noop_method_call.rs +++ b/compiler/rustc_lint/src/noop_method_call.rs @@ -85,10 +85,9 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall { let Some(trait_id) = cx.tcx.trait_of_item(did) else { return }; - if !matches!( - cx.tcx.get_diagnostic_name(trait_id), - Some(sym::Borrow | sym::Clone | sym::Deref) - ) { + let Some(trait_) = cx.tcx.get_diagnostic_name(trait_id) else { return }; + + if !matches!(trait_, sym::Borrow | sym::Clone | sym::Deref) { return; }; @@ -113,11 +112,13 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall { let expr_span = expr.span; let span = expr_span.with_lo(receiver.span.hi()); + let orig_ty = expr_ty.peel_refs(); + if receiver_ty == expr_ty { cx.emit_spanned_lint( NOOP_METHOD_CALL, span, - NoopMethodCallDiag { method: call.ident.name, receiver_ty, label: span }, + NoopMethodCallDiag { method: call.ident.name, orig_ty, trait_, label: span }, ); } else { match name { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 05d2934d4c53..52484413f76b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -41,7 +41,6 @@ use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span, DUMMY_SP}; use rustc_target::spec::abi; use std::borrow::Cow; use std::iter; -use std::ops::Deref; use super::InferCtxtPrivExt; use crate::infer::InferCtxtExt as _; @@ -3580,7 +3579,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // to an associated type (as seen from `trait_pred`) in the predicate. Like in // trait_pred `S: Sum<::Item>` and predicate `i32: Sum<&()>` let mut type_diffs = vec![]; - if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref() + if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code && let Some(node_args) = typeck_results.node_args_opt(call_hir_id) && let where_clauses = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_args) && let Some(where_pred) = where_clauses.predicates.get(*idx) diff --git a/library/core/benches/iter.rs b/library/core/benches/iter.rs index 5ec22e5147b1..05fec0c4b9d2 100644 --- a/library/core/benches/iter.rs +++ b/library/core/benches/iter.rs @@ -473,6 +473,7 @@ fn bench_next_chunk_copied(b: &mut Bencher) { /// Exercises the TrustedRandomAccess specialization in ArrayChunks #[bench] +#[allow(noop_method_call)] fn bench_next_chunk_trusted_random_access(b: &mut Bencher) { let v = vec![1u8; 1024]; diff --git a/src/tools/clippy/tests/ui/explicit_deref_methods.fixed b/src/tools/clippy/tests/ui/explicit_deref_methods.fixed index 4d72b58cdf86..4c0b0d8f275e 100644 --- a/src/tools/clippy/tests/ui/explicit_deref_methods.fixed +++ b/src/tools/clippy/tests/ui/explicit_deref_methods.fixed @@ -4,6 +4,7 @@ #![allow( clippy::borrow_deref_ref, suspicious_double_ref_op, + noop_method_call, clippy::explicit_auto_deref, clippy::needless_borrow, clippy::no_effect, diff --git a/src/tools/clippy/tests/ui/explicit_deref_methods.rs b/src/tools/clippy/tests/ui/explicit_deref_methods.rs index fcd945de3386..bc5da35e52e3 100644 --- a/src/tools/clippy/tests/ui/explicit_deref_methods.rs +++ b/src/tools/clippy/tests/ui/explicit_deref_methods.rs @@ -4,6 +4,7 @@ #![allow( clippy::borrow_deref_ref, suspicious_double_ref_op, + noop_method_call, clippy::explicit_auto_deref, clippy::needless_borrow, clippy::no_effect, diff --git a/src/tools/clippy/tests/ui/explicit_deref_methods.stderr b/src/tools/clippy/tests/ui/explicit_deref_methods.stderr index 362e559b21a5..e4d2fe3a1c3d 100644 --- a/src/tools/clippy/tests/ui/explicit_deref_methods.stderr +++ b/src/tools/clippy/tests/ui/explicit_deref_methods.stderr @@ -1,5 +1,5 @@ error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:54:19 + --> $DIR/explicit_deref_methods.rs:55:19 | LL | let b: &str = a.deref(); | ^^^^^^^^^ help: try: `&*a` @@ -7,67 +7,67 @@ LL | let b: &str = a.deref(); = note: `-D clippy::explicit-deref-methods` implied by `-D warnings` error: explicit `deref_mut` method call - --> $DIR/explicit_deref_methods.rs:56:23 + --> $DIR/explicit_deref_methods.rs:57:23 | LL | let b: &mut str = a.deref_mut(); | ^^^^^^^^^^^^^ help: try: `&mut **a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:59:39 + --> $DIR/explicit_deref_methods.rs:60:39 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:59:50 + --> $DIR/explicit_deref_methods.rs:60:50 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:61:20 + --> $DIR/explicit_deref_methods.rs:62:20 | LL | println!("{}", a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:64:11 + --> $DIR/explicit_deref_methods.rs:65:11 | LL | match a.deref() { | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:68:28 + --> $DIR/explicit_deref_methods.rs:69:28 | LL | let b: String = concat(a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:70:13 + --> $DIR/explicit_deref_methods.rs:71:13 | LL | let b = just_return(a).deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:72:28 + --> $DIR/explicit_deref_methods.rs:73:28 | LL | let b: String = concat(just_return(a).deref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:74:19 + --> $DIR/explicit_deref_methods.rs:75:19 | LL | let b: &str = a.deref().deref(); | ^^^^^^^^^^^^^^^^^ help: try: `&**a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:77:13 + --> $DIR/explicit_deref_methods.rs:78:13 | LL | let b = opt_a.unwrap().deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*opt_a.unwrap()` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:114:31 + --> $DIR/explicit_deref_methods.rs:115:31 | LL | let b: &str = expr_deref!(a.deref()); | ^^^^^^^^^ help: try: `&*a` diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index fc48d0159905..1a765477fe50 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -1119,7 +1119,7 @@ fn check_overlapping_tests(found_paths: &BTreeSet) { for path in found_paths { for ancestor in path.ancestors().skip(1) { if found_paths.contains(ancestor) { - collisions.push((path, ancestor.clone())); + collisions.push((path, ancestor)); } } } diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr index ae61913f9938..fb02c6f361e0 100644 --- a/tests/ui/lint/noop-method-call.stderr +++ b/tests/ui/lint/noop-method-call.stderr @@ -4,7 +4,7 @@ warning: call to `.clone()` on a reference in this situation does nothing LL | let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); | ^^^^^^^^ unnecessary method call | - = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed = note: `#[warn(noop_method_call)]` on by default warning: using `.clone()` on a double reference, which returns `&CloneType` instead of cloning the inner type @@ -21,7 +21,7 @@ warning: call to `.deref()` on a reference in this situation does nothing LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); | ^^^^^^^^ unnecessary method call | - = note: the type `&PlainType` which `deref` is being called on is the same as the type returned from `deref`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Deref`, so calling `deref` on `&PlainType` copies the reference, which does not do anything and can be removed warning: using `.deref()` on a double reference, which returns `&PlainType` instead of dereferencing the inner type --> $DIR/noop-method-call.rs:30:63 @@ -35,7 +35,7 @@ warning: call to `.borrow()` on a reference in this situation does nothing LL | let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); | ^^^^^^^^^ unnecessary method call | - = note: the type `&PlainType` which `borrow` is being called on is the same as the type returned from `borrow`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Borrow`, so calling `borrow` on `&PlainType` copies the reference, which does not do anything and can be removed warning: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type --> $DIR/noop-method-call.rs:42:44 @@ -49,7 +49,7 @@ warning: call to `.clone()` on a reference in this situation does nothing LL | non_clone_type.clone(); | ^^^^^^^^ unnecessary method call | - = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing --> $DIR/noop-method-call.rs:52:19 @@ -57,7 +57,7 @@ warning: call to `.clone()` on a reference in this situation does nothing LL | non_clone_type.clone(); | ^^^^^^^^ unnecessary method call | - = note: the type `&PlainType` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed warning: 8 warnings emitted diff --git a/tests/ui/lint/suspicious-double-ref-op.stderr b/tests/ui/lint/suspicious-double-ref-op.stderr index d15487ca2386..f2128f2a0eda 100644 --- a/tests/ui/lint/suspicious-double-ref-op.stderr +++ b/tests/ui/lint/suspicious-double-ref-op.stderr @@ -16,7 +16,7 @@ error: call to `.clone()` on a reference in this situation does nothing LL | let _ = &mut encoded.clone(); | ^^^^^^^^ unnecessary method call | - = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed note: the lint level is defined here --> $DIR/suspicious-double-ref-op.rs:2:35 | @@ -29,7 +29,7 @@ error: call to `.clone()` on a reference in this situation does nothing LL | let _ = &encoded.clone(); | ^^^^^^^^ unnecessary method call | - = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed error: aborting due to 3 previous errors From 2a76c570d6115230af9df0888a721de9fb2c88bc Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Sun, 23 Jul 2023 09:56:56 +0000 Subject: [PATCH 037/150] add suggestion --- compiler/rustc_lint/messages.ftl | 2 +- compiler/rustc_lint/src/lints.rs | 2 +- tests/ui/lint/noop-method-call.fixed | 51 +++++++++++++++++ tests/ui/lint/noop-method-call.rs | 29 +++++----- tests/ui/lint/noop-method-call.stderr | 56 +++++++++---------- tests/ui/lint/suspicious-double-ref-op.rs | 27 ++++++--- tests/ui/lint/suspicious-double-ref-op.stderr | 33 +++++------ 7 files changed, 127 insertions(+), 73 deletions(-) create mode 100644 tests/ui/lint/noop-method-call.fixed diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 598373a8301e..797504c0e8e4 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -412,7 +412,7 @@ lint_non_upper_case_global = {$sort} `{$name}` should have an upper case name .label = should have an UPPER_CASE name lint_noop_method_call = call to `.{$method}()` on a reference in this situation does nothing - .label = unnecessary method call + .suggestion = remove this redundant call .note = the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed lint_only_cast_u8_to_char = only `u8` can be cast into `char` diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 322a3b6583dd..981b39ba1c8f 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1233,7 +1233,7 @@ pub struct NoopMethodCallDiag<'a> { pub method: Symbol, pub orig_ty: Ty<'a>, pub trait_: Symbol, - #[label] + #[suggestion(code = "", applicability = "machine-applicable")] pub label: Span, } diff --git a/tests/ui/lint/noop-method-call.fixed b/tests/ui/lint/noop-method-call.fixed new file mode 100644 index 000000000000..eeb80279fd81 --- /dev/null +++ b/tests/ui/lint/noop-method-call.fixed @@ -0,0 +1,51 @@ +// check-pass +// run-rustfix + +#![allow(unused)] + +use std::borrow::Borrow; +use std::ops::Deref; + +struct PlainType(T); + +#[derive(Clone)] +struct CloneType(T); + +fn check(mut encoded: &[u8]) { + let _ = &mut encoded; + //~^ WARN call to `.clone()` on a reference in this situation does nothing + let _ = &encoded; + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} + +fn main() { + let non_clone_type_ref = &PlainType(1u32); + let non_clone_type_ref_clone: &PlainType = non_clone_type_ref; + //~^ WARN call to `.clone()` on a reference in this situation does nothing + + let clone_type_ref = &CloneType(1u32); + let clone_type_ref_clone: CloneType = clone_type_ref.clone(); + + + let non_deref_type = &PlainType(1u32); + let non_deref_type_deref: &PlainType = non_deref_type; + //~^ WARN call to `.deref()` on a reference in this situation does nothing + + let non_borrow_type = &PlainType(1u32); + let non_borrow_type_borrow: &PlainType = non_borrow_type; + //~^ WARN call to `.borrow()` on a reference in this situation does nothing + + // Borrowing a &&T does not warn since it has collapsed the double reference + let non_borrow_type = &&PlainType(1u32); + let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); +} + +fn generic(non_clone_type: &PlainType) { + non_clone_type; + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} + +fn non_generic(non_clone_type: &PlainType) { + non_clone_type; + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} diff --git a/tests/ui/lint/noop-method-call.rs b/tests/ui/lint/noop-method-call.rs index 8ce6c859b248..9569a0dfc617 100644 --- a/tests/ui/lint/noop-method-call.rs +++ b/tests/ui/lint/noop-method-call.rs @@ -1,4 +1,5 @@ // check-pass +// run-rustfix #![allow(unused)] @@ -10,45 +11,41 @@ struct PlainType(T); #[derive(Clone)] struct CloneType(T); +fn check(mut encoded: &[u8]) { + let _ = &mut encoded.clone(); + //~^ WARN call to `.clone()` on a reference in this situation does nothing + let _ = &encoded.clone(); + //~^ WARN call to `.clone()` on a reference in this situation does nothing +} + fn main() { let non_clone_type_ref = &PlainType(1u32); let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); - //~^ WARNING call to `.clone()` on a reference in this situation does nothing + //~^ WARN call to `.clone()` on a reference in this situation does nothing let clone_type_ref = &CloneType(1u32); let clone_type_ref_clone: CloneType = clone_type_ref.clone(); - let clone_type_ref = &&CloneType(1u32); - let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); - //~^ WARNING using `.clone()` on a double reference, which returns `&CloneType` let non_deref_type = &PlainType(1u32); let non_deref_type_deref: &PlainType = non_deref_type.deref(); - //~^ WARNING call to `.deref()` on a reference in this situation does nothing - - let non_deref_type = &&PlainType(1u32); - let non_deref_type_deref: &PlainType = non_deref_type.deref(); - //~^ WARNING using `.deref()` on a double reference, which returns `&PlainType` + //~^ WARN call to `.deref()` on a reference in this situation does nothing let non_borrow_type = &PlainType(1u32); let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); - //~^ WARNING call to `.borrow()` on a reference in this situation does nothing + //~^ WARN call to `.borrow()` on a reference in this situation does nothing // Borrowing a &&T does not warn since it has collapsed the double reference let non_borrow_type = &&PlainType(1u32); let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); - - let xs = ["a", "b", "c"]; - let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead - //~^ WARNING using `.clone()` on a double reference, which returns `&str` } fn generic(non_clone_type: &PlainType) { non_clone_type.clone(); - //~^ WARNING call to `.clone()` on a reference in this situation does nothing + //~^ WARN call to `.clone()` on a reference in this situation does nothing } fn non_generic(non_clone_type: &PlainType) { non_clone_type.clone(); - //~^ WARNING call to `.clone()` on a reference in this situation does nothing + //~^ WARN call to `.clone()` on a reference in this situation does nothing } diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr index fb02c6f361e0..aefc2706fd52 100644 --- a/tests/ui/lint/noop-method-call.stderr +++ b/tests/ui/lint/noop-method-call.stderr @@ -1,63 +1,59 @@ warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:15:71 + --> $DIR/noop-method-call.rs:15:25 | -LL | let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); - | ^^^^^^^^ unnecessary method call +LL | let _ = &mut encoded.clone(); + | ^^^^^^^^ help: remove this redundant call | - = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed + = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed = note: `#[warn(noop_method_call)]` on by default -warning: using `.clone()` on a double reference, which returns `&CloneType` instead of cloning the inner type - --> $DIR/noop-method-call.rs:22:63 +warning: call to `.clone()` on a reference in this situation does nothing + --> $DIR/noop-method-call.rs:17:21 | -LL | let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); - | ^^^^^^^^ +LL | let _ = &encoded.clone(); + | ^^^^^^^^ help: remove this redundant call | - = note: `#[warn(suspicious_double_ref_op)]` on by default + = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed + +warning: call to `.clone()` on a reference in this situation does nothing + --> $DIR/noop-method-call.rs:23:71 + | +LL | let non_clone_type_ref_clone: &PlainType = non_clone_type_ref.clone(); + | ^^^^^^^^ help: remove this redundant call + | + = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed warning: call to `.deref()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:26:63 + --> $DIR/noop-method-call.rs:31:63 | LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); - | ^^^^^^^^ unnecessary method call + | ^^^^^^^^ help: remove this redundant call | = note: the type `PlainType` does not implement `Deref`, so calling `deref` on `&PlainType` copies the reference, which does not do anything and can be removed -warning: using `.deref()` on a double reference, which returns `&PlainType` instead of dereferencing the inner type - --> $DIR/noop-method-call.rs:30:63 - | -LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); - | ^^^^^^^^ - warning: call to `.borrow()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:34:66 + --> $DIR/noop-method-call.rs:35:66 | LL | let non_borrow_type_borrow: &PlainType = non_borrow_type.borrow(); - | ^^^^^^^^^ unnecessary method call + | ^^^^^^^^^ help: remove this redundant call | = note: the type `PlainType` does not implement `Borrow`, so calling `borrow` on `&PlainType` copies the reference, which does not do anything and can be removed -warning: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type - --> $DIR/noop-method-call.rs:42:44 - | -LL | let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead - | ^^^^^^^^ - warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:47:19 + --> $DIR/noop-method-call.rs:44:19 | LL | non_clone_type.clone(); - | ^^^^^^^^ unnecessary method call + | ^^^^^^^^ help: remove this redundant call | = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:52:19 + --> $DIR/noop-method-call.rs:49:19 | LL | non_clone_type.clone(); - | ^^^^^^^^ unnecessary method call + | ^^^^^^^^ help: remove this redundant call | = note: the type `PlainType` does not implement `Clone`, so calling `clone` on `&PlainType` copies the reference, which does not do anything and can be removed -warning: 8 warnings emitted +warning: 7 warnings emitted diff --git a/tests/ui/lint/suspicious-double-ref-op.rs b/tests/ui/lint/suspicious-double-ref-op.rs index b9bcd31c2a8b..bc8c23c7b895 100644 --- a/tests/ui/lint/suspicious-double-ref-op.rs +++ b/tests/ui/lint/suspicious-double-ref-op.rs @@ -1,6 +1,14 @@ #![feature(lazy_cell)] #![deny(suspicious_double_ref_op, noop_method_call)] +use std::borrow::Borrow; +use std::ops::Deref; + +struct PlainType(T); + +#[derive(Clone)] +struct CloneType(T); + pub fn clone_on_double_ref() { let x = vec![1]; let y = &&x; @@ -20,11 +28,16 @@ fn rust_clippy_issue_9272() { println!("{str}") } -fn check(mut encoded: &[u8]) { - let _ = &mut encoded.clone(); - //~^ ERROR call to `.clone()` on a reference in this situation does nothing - let _ = &encoded.clone(); - //~^ ERROR call to `.clone()` on a reference in this situation does nothing -} +fn main() { + let clone_type_ref = &&CloneType(1u32); + let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); + //~^ ERROR using `.clone()` on a double reference, which returns `&CloneType` -fn main() {} + let non_deref_type = &&PlainType(1u32); + let non_deref_type_deref: &PlainType = non_deref_type.deref(); + //~^ ERROR using `.deref()` on a double reference, which returns `&PlainType` + + let xs = ["a", "b", "c"]; + let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead + //~^ ERROR using `.clone()` on a double reference, which returns `&str` +} diff --git a/tests/ui/lint/suspicious-double-ref-op.stderr b/tests/ui/lint/suspicious-double-ref-op.stderr index f2128f2a0eda..f5a71d40fc13 100644 --- a/tests/ui/lint/suspicious-double-ref-op.stderr +++ b/tests/ui/lint/suspicious-double-ref-op.stderr @@ -1,5 +1,5 @@ error: using `.clone()` on a double reference, which returns `&Vec` instead of cloning the inner type - --> $DIR/suspicious-double-ref-op.rs:7:23 + --> $DIR/suspicious-double-ref-op.rs:15:23 | LL | let z: &Vec<_> = y.clone(); | ^^^^^^^^ @@ -10,26 +10,23 @@ note: the lint level is defined here LL | #![deny(suspicious_double_ref_op, noop_method_call)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: call to `.clone()` on a reference in this situation does nothing - --> $DIR/suspicious-double-ref-op.rs:24:25 +error: using `.clone()` on a double reference, which returns `&CloneType` instead of cloning the inner type + --> $DIR/suspicious-double-ref-op.rs:33:63 | -LL | let _ = &mut encoded.clone(); - | ^^^^^^^^ unnecessary method call - | - = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed -note: the lint level is defined here - --> $DIR/suspicious-double-ref-op.rs:2:35 - | -LL | #![deny(suspicious_double_ref_op, noop_method_call)] - | ^^^^^^^^^^^^^^^^ +LL | let clone_type_ref_clone: &CloneType = clone_type_ref.clone(); + | ^^^^^^^^ -error: call to `.clone()` on a reference in this situation does nothing - --> $DIR/suspicious-double-ref-op.rs:26:21 +error: using `.deref()` on a double reference, which returns `&PlainType` instead of dereferencing the inner type + --> $DIR/suspicious-double-ref-op.rs:37:63 | -LL | let _ = &encoded.clone(); - | ^^^^^^^^ unnecessary method call +LL | let non_deref_type_deref: &PlainType = non_deref_type.deref(); + | ^^^^^^^^ + +error: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type + --> $DIR/suspicious-double-ref-op.rs:41:44 | - = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed +LL | let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead + | ^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors From ee7dba4db8964b3db2aca0eb8b8fec81178792b8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 5 Jul 2023 18:36:10 +0200 Subject: [PATCH 038/150] If re-export is private, get the next item until a public one is found or expose the private item directly --- src/librustdoc/clean/mod.rs | 96 +++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d14953f1bb78..fb232c4aac8b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1496,8 +1496,93 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( Item::from_def_id_and_parts(assoc_item.def_id, Some(assoc_item.name), kind, cx) } +/// The goal of this function is to return the first `Path` which is not private (ie not private +/// or `doc(hidden)`). If it's not possible, it'll return the "end type". +/// +/// If the path is not a re-export or is public, it'll return `None`. +fn first_not_private( + cx: &mut DocContext<'_>, + hir_id: hir::HirId, + path: &hir::Path<'_>, +) -> Option { + if path.segments.is_empty() { + return None; + } + let parent_def_id = if path.segments.len() == 1 { + // Then it's available in the same scope as the owner. + hir_id.owner.def_id + } else { + // It's not available in the same scope, so we start from the parent of the item. + path.segments[path.segments.len() - 2].res.opt_def_id()?.as_local()? + }; + let target_def_id = path.res.opt_def_id()?; + let mut ident = path.segments.last().unwrap().ident; + // First we try to get the `DefId` of the item. + for child in cx + .tcx + .module_children_local(cx.tcx.local_parent(parent_def_id)) + .iter() + .filter(move |c| c.ident == ident) + { + if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = child.res { + continue; + } + + if let Some(def_id) = child.res.opt_def_id() && target_def_id == def_id { + let mut last_path_res = None; + 'reexps: for reexp in child.reexport_chain.iter() { + if let Some(use_def_id) = reexp.id() && + let Some(local_use_def_id) = use_def_id.as_local() + { + let hir = cx.tcx.hir(); + // let parent_mod = hir.local_def_id_to_hir_id(); + for item_id in hir.module_items(cx.tcx.local_parent(local_use_def_id)) { + let item = hir.item(item_id); + if item.ident == ident { + match item.kind { + hir::ItemKind::Use(path, _) => { + for res in &path.res { + if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res { + continue; + } + if !cx.tcx.is_doc_hidden(use_def_id) && + cx.tcx.local_visibility(local_use_def_id).is_public() { + break 'reexps; + } + ident = path.segments.last().unwrap().ident; + last_path_res = Some((path, res)); + continue 'reexps; + } + } + _ => {} + } + } + } + } + } + if !child.reexport_chain.is_empty() { + // So in here, we use the data we gathered from iterating the reexports. If + // `last_path_res` is set, it can mean two things: + // + // 1. We found a public reexport. + // 2. We didn't find a public reexport so it's the "end type" path. + if let Some((path, res)) = last_path_res { + let path = hir::Path { segments: path.segments, res: *res, span: path.span }; + return Some(clean_path(&path, cx)); + } + // If `last_path_res` is `None`, it can mean two things: + // + // 1. The re-export is public, no need to change anything, just use the path as is. + // 2. Nothing was found, so let's just return the original path. + return None; + } + } + } + None +} + fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type { - let hir::Ty { hir_id: _, span, ref kind } = *hir_ty; + let hir::Ty { hir_id, span, ref kind } = *hir_ty; let hir::TyKind::Path(qpath) = kind else { unreachable!() }; match qpath { @@ -1514,7 +1599,12 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type if let Some(expanded) = maybe_expand_private_type_alias(cx, path) { expanded } else { - let path = clean_path(path, cx); + // First we check if it's a private re-export. + let path = if let Some(path) = first_not_private(cx, hir_id, &path) { + path + } else { + clean_path(path, cx) + }; resolve_type(cx, path) } } @@ -1665,7 +1755,7 @@ fn maybe_expand_private_type_alias<'tcx>( } } - Some(cx.enter_alias(args, def_id.to_def_id(), |cx| clean_ty(ty, cx))) + Some(cx.enter_alias(args, def_id.to_def_id(), |cx| clean_ty(&ty, cx))) } pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type { From d67a31f0581f95752a16061668b2700bd78e0eca Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 5 Jul 2023 18:45:42 +0200 Subject: [PATCH 039/150] Add regression test for #81141 --- ...ue-81141-private-reexport-in-public-api.rs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api.rs diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs new file mode 100644 index 000000000000..d6ef84354295 --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs @@ -0,0 +1,34 @@ +// This test ensures that if a private re-export is present in a public API, it'll be +// replaced by the first public item in the re-export chain or by the private item. + +#![crate_name = "foo"] + +use crate::bar::Bar as Alias; + +pub use crate::bar::Bar as Whatever; +use crate::Whatever as Whatever2; +use crate::Whatever2 as Whatever3; +pub use crate::bar::Inner as Whatever4; + +mod bar { + pub struct Bar; + pub use self::Bar as Inner; +} + +// @has 'foo/fn.bar.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' +pub fn bar() -> Alias { + Alias +} + +// @has 'foo/fn.bar2.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Whatever' +pub fn bar2() -> Whatever3 { + Whatever +} + +// @has 'foo/fn.bar3.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Whatever4' +pub fn bar3() -> Whatever4 { + Whatever +} From 078e9029526f1ea97a86c013142c0ce6a8b9ec0d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 7 Jul 2023 13:55:31 +0200 Subject: [PATCH 040/150] Improve code readability --- src/librustdoc/clean/mod.rs | 59 +++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index fb232c4aac8b..17da8bd2d443 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1505,24 +1505,25 @@ fn first_not_private( hir_id: hir::HirId, path: &hir::Path<'_>, ) -> Option { - if path.segments.is_empty() { - return None; - } - let parent_def_id = if path.segments.len() == 1 { - // Then it's available in the same scope as the owner. - hir_id.owner.def_id - } else { - // It's not available in the same scope, so we start from the parent of the item. - path.segments[path.segments.len() - 2].res.opt_def_id()?.as_local()? + let (parent_def_id, mut ident) = match &path.segments[..] { + [] => return None, + // Relative paths are available in the same scope as the owner. + [leaf] => (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident), + // So are self paths. + [parent, leaf] if parent.ident.name == kw::SelfLower => { + (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident) + } + // Crate paths are not. We start from the crate root. + [parent, leaf] if parent.ident.name == kw::Crate => { + (LOCAL_CRATE.as_def_id().as_local()?, leaf.ident) + } + // Absolute paths are not. We start from the parent of the item. + [.., parent, leaf] => (parent.res.opt_def_id()?.as_local()?, leaf.ident), }; let target_def_id = path.res.opt_def_id()?; - let mut ident = path.segments.last().unwrap().ident; // First we try to get the `DefId` of the item. - for child in cx - .tcx - .module_children_local(cx.tcx.local_parent(parent_def_id)) - .iter() - .filter(move |c| c.ident == ident) + for child in + cx.tcx.module_children_local(parent_def_id).iter().filter(move |c| c.ident == ident) { if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = child.res { continue; @@ -1535,26 +1536,20 @@ fn first_not_private( let Some(local_use_def_id) = use_def_id.as_local() { let hir = cx.tcx.hir(); - // let parent_mod = hir.local_def_id_to_hir_id(); for item_id in hir.module_items(cx.tcx.local_parent(local_use_def_id)) { let item = hir.item(item_id); - if item.ident == ident { - match item.kind { - hir::ItemKind::Use(path, _) => { - for res in &path.res { - if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res { - continue; - } - if !cx.tcx.is_doc_hidden(use_def_id) && - cx.tcx.local_visibility(local_use_def_id).is_public() { - break 'reexps; - } - ident = path.segments.last().unwrap().ident; - last_path_res = Some((path, res)); - continue 'reexps; - } + if item.ident == ident && let hir::ItemKind::Use(path, _) = item.kind { + for res in &path.res { + if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res { + continue; } - _ => {} + if !cx.tcx.is_doc_hidden(use_def_id) && + cx.tcx.local_visibility(local_use_def_id).is_public() { + break 'reexps; + } + ident = path.segments.last().unwrap().ident; + last_path_res = Some((path, res)); + continue 'reexps; } } } From 278d15c254b14199e531b34b209dac9030000d5b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 7 Jul 2023 13:55:47 +0200 Subject: [PATCH 041/150] Extend issue-81141-private-reexport-in-public-api test to cover more cases --- ...ue-81141-private-reexport-in-public-api.rs | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs index d6ef84354295..312146e79576 100644 --- a/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs @@ -32,3 +32,83 @@ pub fn bar2() -> Whatever3 { pub fn bar3() -> Whatever4 { Whatever } + +// @has 'foo/fn.bar4.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar4() -> Bar' +pub fn bar4() -> crate::Alias { + Alias +} + +// @has 'foo/fn.bar5.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar5() -> Whatever' +pub fn bar5() -> crate::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar6.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar6() -> Whatever4' +pub fn bar6() -> crate::Whatever4 { + Whatever +} + + +// @has 'foo/fn.bar7.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar7() -> Bar' +pub fn bar7() -> self::Alias { + Alias +} + +// @has 'foo/fn.bar8.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar8() -> Whatever' +pub fn bar8() -> self::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar9.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar9() -> Whatever4' +pub fn bar9() -> self::Whatever4 { + Whatever +} + +mod nested { + pub(crate) use crate::Alias; + pub(crate) use crate::Whatever3; + pub(crate) use crate::Whatever4; + pub(crate) use crate::nested as nested2; +} + +// @has 'foo/fn.bar10.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar10() -> Bar' +pub fn bar10() -> nested::Alias { + Alias +} + +// @has 'foo/fn.bar11.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar11() -> Whatever' +pub fn bar11() -> nested::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar12.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar12() -> Whatever4' +pub fn bar12() -> nested::Whatever4 { + Whatever +} + +// @has 'foo/fn.bar13.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar13() -> Bar' +pub fn bar13() -> nested::nested2::Alias { + Alias +} + +// @has 'foo/fn.bar14.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar14() -> Whatever' +pub fn bar14() -> nested::nested2::Whatever3 { + Whatever +} + +// @has 'foo/fn.bar15.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar15() -> Whatever4' +pub fn bar15() -> nested::nested2::Whatever4 { + Whatever +} From 6b56e8e1cfedadd25c8c0cb6ecd8a4a8640158ff Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 7 Jul 2023 16:56:21 +0200 Subject: [PATCH 042/150] Rename `first_not_private` into `first_non_private` --- src/librustdoc/clean/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 17da8bd2d443..ac569130cb20 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1500,7 +1500,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( /// or `doc(hidden)`). If it's not possible, it'll return the "end type". /// /// If the path is not a re-export or is public, it'll return `None`. -fn first_not_private( +fn first_non_private( cx: &mut DocContext<'_>, hir_id: hir::HirId, path: &hir::Path<'_>, @@ -1595,7 +1595,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type expanded } else { // First we check if it's a private re-export. - let path = if let Some(path) = first_not_private(cx, hir_id, &path) { + let path = if let Some(path) = first_non_private(cx, hir_id, &path) { path } else { clean_path(path, cx) From 9fb65489057ca6f4e240c6f0c373127d06da316d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 7 Jul 2023 17:55:33 +0200 Subject: [PATCH 043/150] Correctly handle `super` and `::` --- src/librustdoc/clean/mod.rs | 11 ++++++++++- .../issue-81141-private-reexport-in-public-api-2.rs | 13 +++++++++++++ .../issue-81141-private-reexport-in-public-api.rs | 10 ++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ac569130cb20..0be93d9b0570 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1514,9 +1514,18 @@ fn first_non_private( (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident) } // Crate paths are not. We start from the crate root. - [parent, leaf] if parent.ident.name == kw::Crate => { + [parent, leaf] if matches!(parent.ident.name, kw::Crate | kw::PathRoot) => { (LOCAL_CRATE.as_def_id().as_local()?, leaf.ident) } + [parent, leaf] if parent.ident.name == kw::Super => { + let parent_mod = cx.tcx.parent_module(hir_id); + if let Some(super_parent) = cx.tcx.opt_local_parent(parent_mod) { + (super_parent, leaf.ident) + } else { + // If we can't find the parent of the parent, then the parent is already the crate. + (LOCAL_CRATE.as_def_id().as_local()?, leaf.ident) + } + } // Absolute paths are not. We start from the parent of the item. [.., parent, leaf] => (parent.res.opt_def_id()?.as_local()?, leaf.ident), }; diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs new file mode 100644 index 000000000000..4e9d188bbf8d --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-2.rs @@ -0,0 +1,13 @@ +// edition:2015 + +#![crate_name = "foo"] + +use external::Public as Private; + +pub mod external { + pub struct Public; + + // @has 'foo/external/fn.make.html' + // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' + pub fn make() -> ::Private { super::Private } +} diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs index 312146e79576..bd54d02c6ec8 100644 --- a/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api.rs @@ -112,3 +112,13 @@ pub fn bar14() -> nested::nested2::Whatever3 { pub fn bar15() -> nested::nested2::Whatever4 { Whatever } + +use external::Public as Private; + +pub mod external { + pub struct Public; + + // @has 'foo/external/fn.make.html' + // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' + pub fn make() -> super::Private { super::Private } +} From 298cd366d510bbcdf3fd061debd6bb011e681ad1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 10 Jul 2023 14:10:26 +0200 Subject: [PATCH 044/150] Add test for private items --- src/librustdoc/clean/mod.rs | 3 ++ ...-private-reexport-in-public-api-private.rs | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0be93d9b0570..b1fdb4125a38 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1553,6 +1553,9 @@ fn first_non_private( continue; } if !cx.tcx.is_doc_hidden(use_def_id) && + // We never check for "cx.render_options.document_private" + // because if a re-export is not fully public, it's never + // documented. cx.tcx.local_visibility(local_use_def_id).is_public() { break 'reexps; } diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs new file mode 100644 index 000000000000..15749674a3db --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-private.rs @@ -0,0 +1,32 @@ +// compile-flags: --document-private-items + +#![crate_name = "foo"] + +use crate::bar::Bar as Alias; +pub(crate) use crate::bar::Bar as CrateAlias; + +mod bar { + pub struct Bar; + pub use self::Bar as Inner; +} + +// It's a fully private re-export so it should not be displayed. +// @has 'foo/fn.bar.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' +pub fn bar() -> Alias { + Alias +} + +// It's public re-export inside a private module so it should be visible. +// @has 'foo/fn.bar2.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Inner' +pub fn bar2() -> crate::bar::Inner { + Alias +} + +// It's a non-public, so it doesn't appear in documentation so it should not be visible. +// @has 'foo/fn.bar3.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Bar' +pub fn bar3() -> CrateAlias { + Alias +} From d29afe2e145ae2d337a559484efd9098805d0dd6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 10 Jul 2023 14:21:02 +0200 Subject: [PATCH 045/150] Add support for `--document-hidden-items` in `first_non_private` --- src/librustdoc/clean/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index b1fdb4125a38..702b58b1362c 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1552,7 +1552,8 @@ fn first_non_private( if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res { continue; } - if !cx.tcx.is_doc_hidden(use_def_id) && + if (cx.render_options.document_hidden || + !cx.tcx.is_doc_hidden(use_def_id)) && // We never check for "cx.render_options.document_private" // because if a re-export is not fully public, it's never // documented. From 5859b44e97d10b9e30d37b0f87d0fac68dfbc1fd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 10 Jul 2023 14:21:25 +0200 Subject: [PATCH 046/150] Add test for `--document-hidden-items` --- ...1141-private-reexport-in-public-api-hidden.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs new file mode 100644 index 000000000000..5053a328bad8 --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-hidden.rs @@ -0,0 +1,16 @@ +// compile-flags: -Z unstable-options --document-hidden-items + +#![crate_name = "foo"] + +#[doc(hidden)] +pub use crate::bar::Bar as Alias; + +mod bar { + pub struct Bar; +} + +// @has 'foo/fn.bar.html' +// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Alias' +pub fn bar() -> Alias { + Alias +} From 49ccde0054f4b6c9be6987a28211b0101613529e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 10 Jul 2023 17:00:55 +0200 Subject: [PATCH 047/150] Re-add missing generics in `first_non_private` --- src/librustdoc/clean/mod.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 702b58b1362c..b5c257d8d3de 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1505,6 +1505,8 @@ fn first_non_private( hir_id: hir::HirId, path: &hir::Path<'_>, ) -> Option { + use std::mem::transmute; + let (parent_def_id, mut ident) = match &path.segments[..] { [] => return None, // Relative paths are available in the same scope as the owner. @@ -1574,9 +1576,27 @@ fn first_non_private( // // 1. We found a public reexport. // 2. We didn't find a public reexport so it's the "end type" path. - if let Some((path, res)) = last_path_res { - let path = hir::Path { segments: path.segments, res: *res, span: path.span }; - return Some(clean_path(&path, cx)); + if let Some((new_path, _)) = last_path_res { + // In here we need to play with the path data one last time to provide it the + // missing `args` and `res` of the final `Path` we get, which, since it comes + // from a re-export, doesn't have the generics that were originally there, so + // we add them by hand. + let mut segments = new_path.segments.to_vec(); + if let Some(last) = segments.last_mut() { + // `transmute` is needed because we are using a wrong lifetime. Since + // `segments` will be dropped at the end of this block, it's fine. + last.args = unsafe { + transmute( + path.segments.last().as_ref().unwrap().args.clone(), + ) + }; + last.res = path.res; + } + // `transmute` is needed because we are using a wrong lifetime. Since + // `segments` will be dropped at the end of this block, it's fine. + let segments = unsafe { transmute(segments.as_slice()) }; + let new_path = hir::Path { segments, res: path.res, span: new_path.span }; + return Some(clean_path(&new_path, cx)); } // If `last_path_res` is `None`, it can mean two things: // From 95cea621cdf701a4dfaa668af78a4e80f4e94f98 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 10 Jul 2023 17:01:20 +0200 Subject: [PATCH 048/150] Add regression test for generics reexport of private import --- ...81141-private-reexport-in-public-api-generics.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs diff --git a/tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs b/tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs new file mode 100644 index 000000000000..7e289508628f --- /dev/null +++ b/tests/rustdoc/issue-81141-private-reexport-in-public-api-generics.rs @@ -0,0 +1,13 @@ +#![crate_name = "foo"] + +use crate::bar::Foo as Alias; + +pub mod bar { + pub struct Foo<'a, T>(&'a T); +} + +// @has "foo/fn.foo.html" +// @has - '//*[@class="rust item-decl"]/code' "pub fn foo<'a, T>(f: Foo<'a, T>) -> Foo<'a, usize>" +pub fn foo<'a, T>(f: Alias<'a, T>) -> Alias<'a, usize> { + Alias(&0) +} From bc7d958ab2768d022a3ed6af96a222543b13e1a3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 11 Jul 2023 11:38:31 +0200 Subject: [PATCH 049/150] Remove needs for transmute --- src/librustdoc/clean/mod.rs | 37 ++++++++++++++++------------------- src/librustdoc/clean/types.rs | 11 +++++++++++ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index b5c257d8d3de..9aaef40aa6b7 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1500,13 +1500,11 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( /// or `doc(hidden)`). If it's not possible, it'll return the "end type". /// /// If the path is not a re-export or is public, it'll return `None`. -fn first_non_private( - cx: &mut DocContext<'_>, +fn first_non_private<'tcx>( + cx: &mut DocContext<'tcx>, hir_id: hir::HirId, - path: &hir::Path<'_>, + path: &hir::Path<'tcx>, ) -> Option { - use std::mem::transmute; - let (parent_def_id, mut ident) = match &path.segments[..] { [] => return None, // Relative paths are available in the same scope as the owner. @@ -1577,26 +1575,25 @@ fn first_non_private( // 1. We found a public reexport. // 2. We didn't find a public reexport so it's the "end type" path. if let Some((new_path, _)) = last_path_res { + let new_hir_path = hir::Path { + segments: new_path.segments, + res: path.res, + span: new_path.span, + }; + let mut new_clean_path = clean_path(&new_hir_path, cx); // In here we need to play with the path data one last time to provide it the // missing `args` and `res` of the final `Path` we get, which, since it comes // from a re-export, doesn't have the generics that were originally there, so // we add them by hand. - let mut segments = new_path.segments.to_vec(); - if let Some(last) = segments.last_mut() { - // `transmute` is needed because we are using a wrong lifetime. Since - // `segments` will be dropped at the end of this block, it's fine. - last.args = unsafe { - transmute( - path.segments.last().as_ref().unwrap().args.clone(), - ) - }; - last.res = path.res; + if let Some(path_last) = path.segments.last().as_ref() + && let Some(new_path_last) = new_clean_path.segments[..].last_mut() + && let Some(path_last_args) = path_last.args.as_ref() + && path_last.args.is_some() + { + assert!(new_path_last.args.is_empty()); + new_path_last.args = clean_generic_args(path_last_args, cx); } - // `transmute` is needed because we are using a wrong lifetime. Since - // `segments` will be dropped at the end of this block, it's fine. - let segments = unsafe { transmute(segments.as_slice()) }; - let new_path = hir::Path { segments, res: path.res, span: new_path.span }; - return Some(clean_path(&new_path, cx)); + return Some(new_clean_path); } // If `last_path_res` is `None`, it can mean two things: // diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index ddef165a0547..60e316decf91 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2203,6 +2203,17 @@ pub(crate) enum GenericArgs { Parenthesized { inputs: Box<[Type]>, output: Option> }, } +impl GenericArgs { + pub(crate) fn is_empty(&self) -> bool { + match self { + GenericArgs::AngleBracketed { args, bindings } => { + args.is_empty() && bindings.is_empty() + } + GenericArgs::Parenthesized { inputs, output } => inputs.is_empty() && output.is_none(), + } + } +} + #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub(crate) struct PathSegment { pub(crate) name: Symbol, From 662c16771184a26ca0a69f6bf66b13467627d59d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 13 Jul 2023 13:54:23 +0200 Subject: [PATCH 050/150] Revert "Remove needs for transmute" This reverts commit ea9a17b9995b7a076283777b7d462a360fece2d6. --- src/librustdoc/clean/mod.rs | 37 +++++++++++++++++++---------------- src/librustdoc/clean/types.rs | 11 ----------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 9aaef40aa6b7..b5c257d8d3de 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1500,11 +1500,13 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( /// or `doc(hidden)`). If it's not possible, it'll return the "end type". /// /// If the path is not a re-export or is public, it'll return `None`. -fn first_non_private<'tcx>( - cx: &mut DocContext<'tcx>, +fn first_non_private( + cx: &mut DocContext<'_>, hir_id: hir::HirId, - path: &hir::Path<'tcx>, + path: &hir::Path<'_>, ) -> Option { + use std::mem::transmute; + let (parent_def_id, mut ident) = match &path.segments[..] { [] => return None, // Relative paths are available in the same scope as the owner. @@ -1575,25 +1577,26 @@ fn first_non_private<'tcx>( // 1. We found a public reexport. // 2. We didn't find a public reexport so it's the "end type" path. if let Some((new_path, _)) = last_path_res { - let new_hir_path = hir::Path { - segments: new_path.segments, - res: path.res, - span: new_path.span, - }; - let mut new_clean_path = clean_path(&new_hir_path, cx); // In here we need to play with the path data one last time to provide it the // missing `args` and `res` of the final `Path` we get, which, since it comes // from a re-export, doesn't have the generics that were originally there, so // we add them by hand. - if let Some(path_last) = path.segments.last().as_ref() - && let Some(new_path_last) = new_clean_path.segments[..].last_mut() - && let Some(path_last_args) = path_last.args.as_ref() - && path_last.args.is_some() - { - assert!(new_path_last.args.is_empty()); - new_path_last.args = clean_generic_args(path_last_args, cx); + let mut segments = new_path.segments.to_vec(); + if let Some(last) = segments.last_mut() { + // `transmute` is needed because we are using a wrong lifetime. Since + // `segments` will be dropped at the end of this block, it's fine. + last.args = unsafe { + transmute( + path.segments.last().as_ref().unwrap().args.clone(), + ) + }; + last.res = path.res; } - return Some(new_clean_path); + // `transmute` is needed because we are using a wrong lifetime. Since + // `segments` will be dropped at the end of this block, it's fine. + let segments = unsafe { transmute(segments.as_slice()) }; + let new_path = hir::Path { segments, res: path.res, span: new_path.span }; + return Some(clean_path(&new_path, cx)); } // If `last_path_res` is `None`, it can mean two things: // diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 60e316decf91..ddef165a0547 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2203,17 +2203,6 @@ pub(crate) enum GenericArgs { Parenthesized { inputs: Box<[Type]>, output: Option> }, } -impl GenericArgs { - pub(crate) fn is_empty(&self) -> bool { - match self { - GenericArgs::AngleBracketed { args, bindings } => { - args.is_empty() && bindings.is_empty() - } - GenericArgs::Parenthesized { inputs, output } => inputs.is_empty() && output.is_none(), - } - } -} - #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub(crate) struct PathSegment { pub(crate) name: Symbol, From 988729d842be9fddeecdf8bd9c8cf018b511ed8b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Jul 2023 15:09:22 +0200 Subject: [PATCH 051/150] Cache qpath first public result --- src/librustdoc/clean/mod.rs | 72 +++++++++++++++++++++++-------------- src/librustdoc/core.rs | 5 ++- 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index b5c257d8d3de..2ffe38c24030 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1496,17 +1496,55 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( Item::from_def_id_and_parts(assoc_item.def_id, Some(assoc_item.name), kind, cx) } +fn first_non_private_clean_path<'tcx>( + cx: &mut DocContext<'tcx>, + path: &hir::Path<'tcx>, + mut new_path_segments: Vec>, + new_path_span: rustc_span::Span, +) -> Path { + use std::mem::transmute; + + // In here we need to play with the path data one last time to provide it the + // missing `args` and `res` of the final `Path` we get, which, since it comes + // from a re-export, doesn't have the generics that were originally there, so + // we add them by hand. + if let Some(last) = new_path_segments.last_mut() { + // `transmute` is needed because we are using a wrong lifetime. Since + // `segments` will be dropped at the end of this block, it's fine. + last.args = unsafe { transmute(path.segments.last().as_ref().unwrap().args.clone()) }; + last.res = path.res; + } + // `transmute` is needed because we are using a wrong lifetime. Since + // `segments` will be dropped at the end of this block, it's fine. + let path = unsafe { + hir::Path { + segments: transmute(new_path_segments.as_slice()), + res: path.res, + span: new_path_span, + } + }; + clean_path(&path, cx) +} + /// The goal of this function is to return the first `Path` which is not private (ie not private /// or `doc(hidden)`). If it's not possible, it'll return the "end type". /// /// If the path is not a re-export or is public, it'll return `None`. -fn first_non_private( - cx: &mut DocContext<'_>, +fn first_non_private<'tcx>( + cx: &mut DocContext<'tcx>, hir_id: hir::HirId, - path: &hir::Path<'_>, + path: &hir::Path<'tcx>, ) -> Option { - use std::mem::transmute; - + let use_id = path.segments.last().map(|seg| seg.hir_id)?; + let target_def_id = path.res.opt_def_id()?; + let saved_path = cx + .updated_qpath + .borrow() + .get(&use_id) + .map(|saved_path| (saved_path.segments.to_vec(), saved_path.span)); + if let Some((segments, span)) = saved_path { + return Some(first_non_private_clean_path(cx, path, segments, span)); + } let (parent_def_id, mut ident) = match &path.segments[..] { [] => return None, // Relative paths are available in the same scope as the owner. @@ -1531,7 +1569,6 @@ fn first_non_private( // Absolute paths are not. We start from the parent of the item. [.., parent, leaf] => (parent.res.opt_def_id()?.as_local()?, leaf.ident), }; - let target_def_id = path.res.opt_def_id()?; // First we try to get the `DefId` of the item. for child in cx.tcx.module_children_local(parent_def_id).iter().filter(move |c| c.ident == ident) @@ -1577,26 +1614,9 @@ fn first_non_private( // 1. We found a public reexport. // 2. We didn't find a public reexport so it's the "end type" path. if let Some((new_path, _)) = last_path_res { - // In here we need to play with the path data one last time to provide it the - // missing `args` and `res` of the final `Path` we get, which, since it comes - // from a re-export, doesn't have the generics that were originally there, so - // we add them by hand. - let mut segments = new_path.segments.to_vec(); - if let Some(last) = segments.last_mut() { - // `transmute` is needed because we are using a wrong lifetime. Since - // `segments` will be dropped at the end of this block, it's fine. - last.args = unsafe { - transmute( - path.segments.last().as_ref().unwrap().args.clone(), - ) - }; - last.res = path.res; - } - // `transmute` is needed because we are using a wrong lifetime. Since - // `segments` will be dropped at the end of this block, it's fine. - let segments = unsafe { transmute(segments.as_slice()) }; - let new_path = hir::Path { segments, res: path.res, span: new_path.span }; - return Some(clean_path(&new_path, cx)); + cx.updated_qpath.borrow_mut().insert(use_id, new_path.clone()); + let new_path_segments = new_path.segments.to_vec(); + return Some(first_non_private_clean_path(cx, path, new_path_segments, new_path.span)); } // If `last_path_res` is `None`, it can mean two things: // diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7fb069d6e707..6cccb403491c 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -8,7 +8,7 @@ use rustc_feature::UnstableFeatures; use rustc_hir::def::Res; use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId}; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{HirId, Path}; +use rustc_hir::{HirId, Path, UsePath}; use rustc_interface::interface; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; @@ -63,6 +63,8 @@ pub(crate) struct DocContext<'tcx> { pub(crate) output_format: OutputFormat, /// Used by `strip_private`. pub(crate) show_coverage: bool, + /// Used by `first_non_private` to prevent computing the same path more than once. + pub(crate) updated_qpath: RefCell>>, } impl<'tcx> DocContext<'tcx> { @@ -352,6 +354,7 @@ pub(crate) fn run_global_ctxt( output_format, render_options, show_coverage, + updated_qpath: Default::default(), }; for cnum in tcx.crates(()) { From da4f62ebf7c487700c21a713c0cc3974bef11fc8 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 24 Jul 2023 08:15:53 -0700 Subject: [PATCH 052/150] Fix span for punnycode --- src/doc/rustc/src/symbol-mangling/v0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 13f7be315c95..61f747fac837 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -493,7 +493,7 @@ would be mangled as: ```text _RNvNtNtCsgOH4LzxkuMq_7mycrateu8gdel_5qa6escher4bach - ││└───┬───┘ + ││└───┬──┘ ││ │ ││ └── gdel_5qa translates to gödel │└─────── 8 is the length From 9f8c2495baee84a026f701c2279bff0459a69af7 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 24 Jul 2023 21:49:25 +0200 Subject: [PATCH 053/150] typos --- src/tools/compiletest/src/header/cfg.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/header/cfg.rs b/src/tools/compiletest/src/header/cfg.rs index 86a749b935d8..77c2866b366a 100644 --- a/src/tools/compiletest/src/header/cfg.rs +++ b/src/tools/compiletest/src/header/cfg.rs @@ -112,7 +112,7 @@ pub(super) fn parse_cfg_name_directive<'a>( (config.target == "wasm32-unknown-unknown").then_some("emscripten"), ], allowed_names: &target_cfgs.all_oses, - message: "when the operative system is {name}" + message: "when the operating system is {name}" } condition! { name: &target_cfg.env, @@ -122,7 +122,7 @@ pub(super) fn parse_cfg_name_directive<'a>( condition! { name: &target_cfg.os_and_env(), allowed_names: &target_cfgs.all_oses_and_envs, - message: "when the operative system and target environment are {name}" + message: "when the operating system and target environment are {name}" } condition! { name: &target_cfg.abi, From 1f828f01552b54abb8e33610484d9269067fcc28 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 25 Jul 2023 15:39:45 +0200 Subject: [PATCH 054/150] Improve performance of `first_non_private` --- src/librustdoc/clean/mod.rs | 40 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 2ffe38c24030..743ba6835db3 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1545,7 +1545,7 @@ fn first_non_private<'tcx>( if let Some((segments, span)) = saved_path { return Some(first_non_private_clean_path(cx, path, segments, span)); } - let (parent_def_id, mut ident) = match &path.segments[..] { + let (parent_def_id, ident) = match &path.segments[..] { [] => return None, // Relative paths are available in the same scope as the owner. [leaf] => (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident), @@ -1569,6 +1569,7 @@ fn first_non_private<'tcx>( // Absolute paths are not. We start from the parent of the item. [.., parent, leaf] => (parent.res.opt_def_id()?.as_local()?, leaf.ident), }; + let hir = cx.tcx.hir(); // First we try to get the `DefId` of the item. for child in cx.tcx.module_children_local(parent_def_id).iter().filter(move |c| c.ident == ident) @@ -1581,29 +1582,24 @@ fn first_non_private<'tcx>( let mut last_path_res = None; 'reexps: for reexp in child.reexport_chain.iter() { if let Some(use_def_id) = reexp.id() && - let Some(local_use_def_id) = use_def_id.as_local() + let Some(local_use_def_id) = use_def_id.as_local() && + let Some(hir::Node::Item(item)) = hir.find_by_def_id(local_use_def_id) && + let hir::ItemKind::Use(path, _) = item.kind { - let hir = cx.tcx.hir(); - for item_id in hir.module_items(cx.tcx.local_parent(local_use_def_id)) { - let item = hir.item(item_id); - if item.ident == ident && let hir::ItemKind::Use(path, _) = item.kind { - for res in &path.res { - if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res { - continue; - } - if (cx.render_options.document_hidden || - !cx.tcx.is_doc_hidden(use_def_id)) && - // We never check for "cx.render_options.document_private" - // because if a re-export is not fully public, it's never - // documented. - cx.tcx.local_visibility(local_use_def_id).is_public() { - break 'reexps; - } - ident = path.segments.last().unwrap().ident; - last_path_res = Some((path, res)); - continue 'reexps; - } + for res in &path.res { + if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res { + continue; } + if (cx.render_options.document_hidden || + !cx.tcx.is_doc_hidden(use_def_id)) && + // We never check for "cx.render_options.document_private" + // because if a re-export is not fully public, it's never + // documented. + cx.tcx.local_visibility(local_use_def_id).is_public() { + break 'reexps; + } + last_path_res = Some((path, res)); + continue 'reexps; } } } From 6c4437e3d25485e657322c7963f79e3b610a7785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 25 Jul 2023 13:32:44 +0200 Subject: [PATCH 055/150] CI: fix CMake installation for 32 and 64bit `dist` Linux --- src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile | 3 +-- src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile index 59e98689c2c3..f5274104d60a 100644 --- a/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-i686-linux/Dockerfile @@ -12,7 +12,6 @@ RUN yum upgrade -y && \ automake \ bzip2 \ file \ - cmake3 \ gcc \ gcc-c++ \ git \ @@ -35,7 +34,7 @@ RUN yum upgrade -y && \ zlib-devel.x86_64 \ && yum clean all -RUN mkdir -p /rustroot/bin && ln -s /usr/bin/cmake3 /rustroot/bin/cmake +RUN mkdir -p /rustroot/bin ENV PATH=/rustroot/bin:$PATH ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib32:/rustroot/lib diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index afd536a6602a..319989df3346 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -12,7 +12,6 @@ RUN yum upgrade -y && \ automake \ bzip2 \ file \ - cmake3 \ gcc \ gcc-c++ \ git \ @@ -35,7 +34,7 @@ RUN yum upgrade -y && \ zlib-devel.x86_64 \ && yum clean all -RUN mkdir -p /rustroot/bin && ln -s /usr/bin/cmake3 /rustroot/bin/cmake +RUN mkdir -p /rustroot/bin ENV PATH=/rustroot/bin:$PATH ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib32:/rustroot/lib From 16481807f5b106a6dcc627075fbdcd14add9495d Mon Sep 17 00:00:00 2001 From: Catherine Flores Date: Tue, 25 Jul 2023 18:27:24 +0000 Subject: [PATCH 056/150] Gracefully handle missing ternary operator --- compiler/rustc_parse/messages.ftl | 4 + compiler/rustc_parse/src/errors.rs | 8 ++ .../rustc_parse/src/parser/diagnostics.rs | 46 ++++++- compiler/rustc_parse/src/parser/mod.rs | 9 +- compiler/rustc_parse/src/parser/stmt.rs | 4 +- tests/ui/parser/ternary_operator.rs | 40 +++++++ tests/ui/parser/ternary_operator.stderr | 113 ++++++++++++++++++ 7 files changed, 220 insertions(+), 4 deletions(-) create mode 100644 tests/ui/parser/ternary_operator.rs create mode 100644 tests/ui/parser/ternary_operator.stderr diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 9787d98c1a49..86e41253b29f 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -722,6 +722,10 @@ parse_sugg_wrap_pattern_in_parens = wrap the pattern in parentheses parse_switch_mut_let_order = switch the order of `mut` and `let` + +parse_ternary_operator = Rust has no ternary operator + .help = use an `if-else` expression instead + parse_tilde_const_lifetime = `~const` may only modify trait bounds, not lifetime bounds parse_tilde_is_not_unary_operator = `~` cannot be used as a unary operator diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 96e1c0e3c6d9..903b0e078768 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -365,6 +365,14 @@ pub(crate) enum IfExpressionMissingThenBlockSub { AddThenBlock(#[primary_span] Span), } +#[derive(Diagnostic)] +#[diag(parse_ternary_operator)] +#[help] +pub struct TernaryOperator { + #[primary_span] + pub span: Span, +} + #[derive(Subdiagnostic)] #[suggestion(parse_extra_if_in_let_else, applicability = "maybe-incorrect", code = "")] pub(crate) struct IfExpressionLetSomeSub { diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index c3cf6437afa0..8f422d901753 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -14,7 +14,7 @@ use crate::errors::{ PatternMethodParamWithoutBody, QuestionMarkInType, QuestionMarkInTypeSugg, SelfParamNotFirst, StructLiteralBodyWithoutPath, StructLiteralBodyWithoutPathSugg, StructLiteralNeedingParens, StructLiteralNeedingParensSugg, SuggAddMissingLetStmt, SuggEscapeIdentifier, SuggRemoveComma, - UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration, + TernaryOperator, UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration, UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, }; @@ -500,6 +500,13 @@ impl<'a> Parser<'a> { // Special-case "expected `;`" errors if expected.contains(&TokenType::Token(token::Semi)) { + if self.prev_token.kind == token::Question { + self.maybe_ternary_lo = Some(self.prev_token.span.lo()); + let result = self.maybe_recover_from_ternary_operator().map(|_| true); + self.maybe_ternary_lo = None; + return result; + } + if self.token.span == DUMMY_SP || self.prev_token.span == DUMMY_SP { // Likely inside a macro, can't provide meaningful suggestions. } else if !sm.is_multiline(self.prev_token.span.until(self.token.span)) { @@ -1330,6 +1337,41 @@ impl<'a> Parser<'a> { } } + /// Rust has no ternary operator (`cond ? then : else`). Parse it and try + /// to recover from it if `then` and `else` are valid expressions. + pub(super) fn maybe_recover_from_ternary_operator(&mut self) -> PResult<'a, ()> { + let snapshot = self.create_snapshot_for_diagnostic(); + let lo = self.prev_token.span.lo(); + + if self.prev_token == token::Question + && match self.parse_expr() { + Ok(_) => true, + Err(err) => { + err.cancel(); + // The colon can sometimes be mistaken for type + // ascription. Catch when this happens and continue. + self.token == token::Colon + } + } + { + if self.eat_noexpect(&token::Colon) { + match self.parse_expr() { + Ok(_) => { + self.sess.emit_err(TernaryOperator { span: self.token.span.with_lo(lo) }); + } + Err(err) => { + err.cancel(); + self.restore_snapshot(snapshot); + } + }; + } + } else { + self.restore_snapshot(snapshot); + }; + + Ok(()) + } + pub(super) fn maybe_recover_from_bad_type_plus(&mut self, ty: &Ty) -> PResult<'a, ()> { // Do not add `+` to expected tokens. if !self.token.is_like_plus() { @@ -2111,7 +2153,7 @@ impl<'a> Parser<'a> { } _ => ( self.token.span, - format!("expected expression, found {}", super::token_descr(&self.token),), + format!("expected expression, found {}", super::token_descr(&self.token)), ), }; let mut err = self.struct_span_err(span, msg); diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 2e1a61e634e6..20515b36fa10 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -37,6 +37,7 @@ use rustc_errors::{ use rustc_session::parse::ParseSess; use rustc_span::source_map::{Span, DUMMY_SP}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; +use rustc_span::BytePos; use std::ops::Range; use std::{cmp, mem, slice}; use thin_vec::ThinVec; @@ -157,12 +158,17 @@ pub struct Parser<'a> { /// Whether the parser is allowed to do recovery. /// This is disabled when parsing macro arguments, see #103534 pub recovery: Recovery, + /// The low part of a ternary operator (`cond ? then : else`). + /// FIXME(Centri3): This is currently only used so that type ascription is + /// not mentioned in the error. Once the error in `stmt.rs` is removed, this + /// can be removed. + maybe_ternary_lo: Option, } // This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure // it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(Parser<'_>, 272); +rustc_data_structures::static_assert_size!(Parser<'_>, 280); /// Stores span information about a closure. #[derive(Clone)] @@ -475,6 +481,7 @@ impl<'a> Parser<'a> { }, current_closure: None, recovery: Recovery::Allowed, + maybe_ternary_lo: None, }; // Make parser point to the first token. diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 9fcf51a04ec0..5a7f3aa53dcb 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -576,7 +576,9 @@ impl<'a> Parser<'a> { Applicability::MaybeIncorrect, ); } - if self.sess.unstable_features.is_nightly_build() { + if self.sess.unstable_features.is_nightly_build() + && self.maybe_ternary_lo.is_none() + { // FIXME(Nilstrieb): Remove this again after a few months. err.note("type ascription syntax has been removed, see issue #101728 "); } diff --git a/tests/ui/parser/ternary_operator.rs b/tests/ui/parser/ternary_operator.rs new file mode 100644 index 000000000000..c41a20f481f8 --- /dev/null +++ b/tests/ui/parser/ternary_operator.rs @@ -0,0 +1,40 @@ +fn a() { + let x = 5 > 2 ? true : false; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` +} + +fn b() { + let x = 5 > 2 ? { true } : { false }; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` +} + +fn c() { + let x = 5 > 2 ? f32::MAX : f32::MIN; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` +} + +fn main() { + let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + //~^ ERROR Rust has no ternary operator + //~| HELP use an `if-else` expression instead + //~| expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| HELP the trait `Try` is not implemented for `{integer}` + //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] + //~| HELP the trait `FromResidual<_>` is not implemented for `()` +} diff --git a/tests/ui/parser/ternary_operator.stderr b/tests/ui/parser/ternary_operator.stderr new file mode 100644 index 000000000000..bf08666c8a43 --- /dev/null +++ b/tests/ui/parser/ternary_operator.stderr @@ -0,0 +1,113 @@ +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:2:19 + | +LL | let x = 5 > 2 ? true : false; + | ^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:12:19 + | +LL | let x = 5 > 2 ? { true } : { false }; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:22:19 + | +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/ternary_operator.rs:32:37 + | +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^ expected one of `.`, `;`, `?`, `else`, or an operator + +error: Rust has no ternary operator + --> $DIR/ternary_operator.rs:32:19 + | +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use an `if-else` expression instead + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:2:17 + | +LL | let x = 5 > 2 ? true : false; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:2:19 + | +LL | fn a() { + | ------ this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? true : false; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:12:17 + | +LL | let x = 5 > 2 ? { true } : { false }; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:12:19 + | +LL | fn b() { + | ------ this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? { true } : { false }; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:22:17 + | +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:22:19 + | +LL | fn c() { + | ------ this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/ternary_operator.rs:32:17 + | +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/ternary_operator.rs:32:19 + | +LL | fn main() { + | --------- this function should return `Result` or `Option` to accept `?` +LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error: aborting due to 13 previous errors + +For more information about this error, try `rustc --explain E0277`. From faa73953c07530bc02c9a89e4d719beb3f4a376e Mon Sep 17 00:00:00 2001 From: Catherine Flores Date: Tue, 25 Jul 2023 18:37:56 +0000 Subject: [PATCH 057/150] Remove unnecessary `maybe_ternary_lo` field --- .../rustc_parse/src/parser/diagnostics.rs | 10 ++--- compiler/rustc_parse/src/parser/mod.rs | 9 +--- compiler/rustc_parse/src/parser/stmt.rs | 4 +- tests/ui/parser/ternary_operator.rs | 41 ++++++++++++++++--- tests/ui/parser/ternary_operator.stderr | 28 +++++++------ 5 files changed, 55 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 8f422d901753..ef5581e1efe2 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -501,10 +501,8 @@ impl<'a> Parser<'a> { // Special-case "expected `;`" errors if expected.contains(&TokenType::Token(token::Semi)) { if self.prev_token.kind == token::Question { - self.maybe_ternary_lo = Some(self.prev_token.span.lo()); - let result = self.maybe_recover_from_ternary_operator().map(|_| true); - self.maybe_ternary_lo = None; - return result; + self.maybe_recover_from_ternary_operator(); + return Ok(true); } if self.token.span == DUMMY_SP || self.prev_token.span == DUMMY_SP { @@ -1339,7 +1337,7 @@ impl<'a> Parser<'a> { /// Rust has no ternary operator (`cond ? then : else`). Parse it and try /// to recover from it if `then` and `else` are valid expressions. - pub(super) fn maybe_recover_from_ternary_operator(&mut self) -> PResult<'a, ()> { + pub(super) fn maybe_recover_from_ternary_operator(&mut self) { let snapshot = self.create_snapshot_for_diagnostic(); let lo = self.prev_token.span.lo(); @@ -1368,8 +1366,6 @@ impl<'a> Parser<'a> { } else { self.restore_snapshot(snapshot); }; - - Ok(()) } pub(super) fn maybe_recover_from_bad_type_plus(&mut self, ty: &Ty) -> PResult<'a, ()> { diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 20515b36fa10..2e1a61e634e6 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -37,7 +37,6 @@ use rustc_errors::{ use rustc_session::parse::ParseSess; use rustc_span::source_map::{Span, DUMMY_SP}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::BytePos; use std::ops::Range; use std::{cmp, mem, slice}; use thin_vec::ThinVec; @@ -158,17 +157,12 @@ pub struct Parser<'a> { /// Whether the parser is allowed to do recovery. /// This is disabled when parsing macro arguments, see #103534 pub recovery: Recovery, - /// The low part of a ternary operator (`cond ? then : else`). - /// FIXME(Centri3): This is currently only used so that type ascription is - /// not mentioned in the error. Once the error in `stmt.rs` is removed, this - /// can be removed. - maybe_ternary_lo: Option, } // This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure // it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(Parser<'_>, 280); +rustc_data_structures::static_assert_size!(Parser<'_>, 272); /// Stores span information about a closure. #[derive(Clone)] @@ -481,7 +475,6 @@ impl<'a> Parser<'a> { }, current_closure: None, recovery: Recovery::Allowed, - maybe_ternary_lo: None, }; // Make parser point to the first token. diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 5a7f3aa53dcb..9fcf51a04ec0 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -576,9 +576,7 @@ impl<'a> Parser<'a> { Applicability::MaybeIncorrect, ); } - if self.sess.unstable_features.is_nightly_build() - && self.maybe_ternary_lo.is_none() - { + if self.sess.unstable_features.is_nightly_build() { // FIXME(Nilstrieb): Remove this again after a few months. err.note("type ascription syntax has been removed, see issue #101728 "); } diff --git a/tests/ui/parser/ternary_operator.rs b/tests/ui/parser/ternary_operator.rs index c41a20f481f8..23d537e77f79 100644 --- a/tests/ui/parser/ternary_operator.rs +++ b/tests/ui/parser/ternary_operator.rs @@ -1,4 +1,7 @@ -fn a() { +// A good chunk of these errors aren't shown to the user, but are still +// required in the test for it to pass. + +fn a() { //~ NOTE this function should return `Result` or `Option` to accept `?` let x = 5 > 2 ? true : false; //~^ ERROR Rust has no ternary operator //~| HELP use an `if-else` expression instead @@ -6,9 +9,15 @@ fn a() { //~| HELP the trait `Try` is not implemented for `{integer}` //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` } -fn b() { +fn b() { //~ NOTE this function should return `Result` or `Option` to accept `?` let x = 5 > 2 ? { true } : { false }; //~^ ERROR Rust has no ternary operator //~| HELP use an `if-else` expression instead @@ -16,9 +25,15 @@ fn b() { //~| HELP the trait `Try` is not implemented for `{integer}` //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` } -fn c() { +fn c() { //~ NOTE this function should return `Result` or `Option` to accept `?` let x = 5 > 2 ? f32::MAX : f32::MIN; //~^ ERROR Rust has no ternary operator //~| HELP use an `if-else` expression instead @@ -26,15 +41,29 @@ fn c() { //~| HELP the trait `Try` is not implemented for `{integer}` //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` } -fn main() { +fn main() { //~ NOTE this function should return `Result` or `Option` to accept `?` let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; //~^ ERROR Rust has no ternary operator //~| HELP use an `if-else` expression instead - //~| expected one of `.`, `;`, `?`, `else`, or an operator, found `:` - //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] + //~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + //~| NOTE expected one of `.`, `;`, `?`, `else`, or an operator + //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277] //~| HELP the trait `Try` is not implemented for `{integer}` //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277] //~| HELP the trait `FromResidual<_>` is not implemented for `()` + //~| NOTE type ascription syntax has been removed, see issue #101728 + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE the `?` operator cannot be applied to type `{integer}` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE cannot use the `?` operator in a function that returns `()` + //~| NOTE in this expansion of desugaring of operator `?` } diff --git a/tests/ui/parser/ternary_operator.stderr b/tests/ui/parser/ternary_operator.stderr index bf08666c8a43..af9565bbead1 100644 --- a/tests/ui/parser/ternary_operator.stderr +++ b/tests/ui/parser/ternary_operator.stderr @@ -1,5 +1,5 @@ error: Rust has no ternary operator - --> $DIR/ternary_operator.rs:2:19 + --> $DIR/ternary_operator.rs:5:19 | LL | let x = 5 > 2 ? true : false; | ^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let x = 5 > 2 ? true : false; = help: use an `if-else` expression instead error: Rust has no ternary operator - --> $DIR/ternary_operator.rs:12:19 + --> $DIR/ternary_operator.rs:21:19 | LL | let x = 5 > 2 ? { true } : { false }; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | let x = 5 > 2 ? { true } : { false }; = help: use an `if-else` expression instead error: Rust has no ternary operator - --> $DIR/ternary_operator.rs:22:19 + --> $DIR/ternary_operator.rs:37:19 | LL | let x = 5 > 2 ? f32::MAX : f32::MIN; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -23,13 +23,15 @@ LL | let x = 5 > 2 ? f32::MAX : f32::MIN; = help: use an `if-else` expression instead error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` - --> $DIR/ternary_operator.rs:32:37 + --> $DIR/ternary_operator.rs:53:37 | LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; | ^ expected one of `.`, `;`, `?`, `else`, or an operator + | + = note: type ascription syntax has been removed, see issue #101728 error: Rust has no ternary operator - --> $DIR/ternary_operator.rs:32:19 + --> $DIR/ternary_operator.rs:53:19 | LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +39,7 @@ LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; = help: use an `if-else` expression instead error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/ternary_operator.rs:2:17 + --> $DIR/ternary_operator.rs:5:17 | LL | let x = 5 > 2 ? true : false; | ^^^ the `?` operator cannot be applied to type `{integer}` @@ -45,7 +47,7 @@ LL | let x = 5 > 2 ? true : false; = help: the trait `Try` is not implemented for `{integer}` error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) - --> $DIR/ternary_operator.rs:2:19 + --> $DIR/ternary_operator.rs:5:19 | LL | fn a() { | ------ this function should return `Result` or `Option` to accept `?` @@ -55,7 +57,7 @@ LL | let x = 5 > 2 ? true : false; = help: the trait `FromResidual<_>` is not implemented for `()` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/ternary_operator.rs:12:17 + --> $DIR/ternary_operator.rs:21:17 | LL | let x = 5 > 2 ? { true } : { false }; | ^^^ the `?` operator cannot be applied to type `{integer}` @@ -63,7 +65,7 @@ LL | let x = 5 > 2 ? { true } : { false }; = help: the trait `Try` is not implemented for `{integer}` error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) - --> $DIR/ternary_operator.rs:12:19 + --> $DIR/ternary_operator.rs:21:19 | LL | fn b() { | ------ this function should return `Result` or `Option` to accept `?` @@ -73,7 +75,7 @@ LL | let x = 5 > 2 ? { true } : { false }; = help: the trait `FromResidual<_>` is not implemented for `()` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/ternary_operator.rs:22:17 + --> $DIR/ternary_operator.rs:37:17 | LL | let x = 5 > 2 ? f32::MAX : f32::MIN; | ^^^ the `?` operator cannot be applied to type `{integer}` @@ -81,7 +83,7 @@ LL | let x = 5 > 2 ? f32::MAX : f32::MIN; = help: the trait `Try` is not implemented for `{integer}` error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) - --> $DIR/ternary_operator.rs:22:19 + --> $DIR/ternary_operator.rs:37:19 | LL | fn c() { | ------ this function should return `Result` or `Option` to accept `?` @@ -91,7 +93,7 @@ LL | let x = 5 > 2 ? f32::MAX : f32::MIN; = help: the trait `FromResidual<_>` is not implemented for `()` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/ternary_operator.rs:32:17 + --> $DIR/ternary_operator.rs:53:17 | LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; | ^^^ the `?` operator cannot be applied to type `{integer}` @@ -99,7 +101,7 @@ LL | let x = 5 > 2 ? { let x = vec![]: Vec; x } : { false }; = help: the trait `Try` is not implemented for `{integer}` error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) - --> $DIR/ternary_operator.rs:32:19 + --> $DIR/ternary_operator.rs:53:19 | LL | fn main() { | --------- this function should return `Result` or `Option` to accept `?` From 79b6ed0e0860dc4a75af50a975d47efabdd95cbc Mon Sep 17 00:00:00 2001 From: Catherine Flores Date: Tue, 25 Jul 2023 19:15:19 +0000 Subject: [PATCH 058/150] Only early return if recovered --- .../rustc_parse/src/parser/diagnostics.rs | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index ef5581e1efe2..7d04a335c9e0 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -500,8 +500,7 @@ impl<'a> Parser<'a> { // Special-case "expected `;`" errors if expected.contains(&TokenType::Token(token::Semi)) { - if self.prev_token.kind == token::Question { - self.maybe_recover_from_ternary_operator(); + if self.prev_token == token::Question && self.maybe_recover_from_ternary_operator() { return Ok(true); } @@ -1336,26 +1335,30 @@ impl<'a> Parser<'a> { } /// Rust has no ternary operator (`cond ? then : else`). Parse it and try - /// to recover from it if `then` and `else` are valid expressions. - pub(super) fn maybe_recover_from_ternary_operator(&mut self) { - let snapshot = self.create_snapshot_for_diagnostic(); - let lo = self.prev_token.span.lo(); + /// to recover from it if `then` and `else` are valid expressions. Returns + /// whether it was a ternary operator. + pub(super) fn maybe_recover_from_ternary_operator(&mut self) -> bool { + if self.prev_token != token::Question { + return false; + } - if self.prev_token == token::Question - && match self.parse_expr() { - Ok(_) => true, - Err(err) => { - err.cancel(); - // The colon can sometimes be mistaken for type - // ascription. Catch when this happens and continue. - self.token == token::Colon - } + let lo = self.prev_token.span.lo(); + let snapshot = self.create_snapshot_for_diagnostic(); + + if match self.parse_expr() { + Ok(_) => true, + Err(err) => { + err.cancel(); + // The colon can sometimes be mistaken for type + // ascription. Catch when this happens and continue. + self.token == token::Colon } - { + } { if self.eat_noexpect(&token::Colon) { match self.parse_expr() { Ok(_) => { self.sess.emit_err(TernaryOperator { span: self.token.span.with_lo(lo) }); + return true; } Err(err) => { err.cancel(); @@ -1366,6 +1369,8 @@ impl<'a> Parser<'a> { } else { self.restore_snapshot(snapshot); }; + + false } pub(super) fn maybe_recover_from_bad_type_plus(&mut self, ty: &Ty) -> PResult<'a, ()> { From c64ef5e070ee7ae7fb73de2bec06fb7498a9af83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 25 Jul 2023 23:17:39 +0200 Subject: [PATCH 059/150] inline format!() args from rustc_codegen_llvm to the end (4) r? @WaffleLapkin --- .../rustc_borrowck/src/borrowck_errors.rs | 46 +++++------ compiler/rustc_borrowck/src/dataflow.rs | 2 +- .../src/diagnostics/conflict_errors.rs | 76 +++++++------------ compiler/rustc_borrowck/src/facts.rs | 2 +- compiler/rustc_borrowck/src/lib.rs | 6 +- compiler/rustc_borrowck/src/nll.rs | 6 +- .../src/region_infer/dump_mir.rs | 11 +-- .../src/region_infer/graphviz.rs | 4 +- .../rustc_borrowck/src/region_infer/mod.rs | 2 +- .../src/region_infer/opaque_types.rs | 2 +- .../rustc_borrowck/src/region_infer/values.rs | 6 +- .../src/const_eval/eval_queries.rs | 2 +- .../src/const_eval/valtrees.rs | 2 +- .../src/interpret/eval_context.rs | 10 +-- .../src/interpret/intrinsics.rs | 17 ++--- .../rustc_const_eval/src/interpret/memory.rs | 4 +- .../src/interpret/operator.rs | 5 +- .../rustc_const_eval/src/interpret/step.rs | 2 +- .../src/interpret/validity.rs | 10 +-- .../src/transform/check_consts/ops.rs | 8 +- .../src/transform/validate.rs | 61 +++++++-------- .../rustc_hir_analysis/src/astconv/errors.rs | 6 +- .../src/astconv/generics.rs | 8 +- .../rustc_hir_analysis/src/astconv/lint.rs | 4 +- .../rustc_hir_analysis/src/astconv/mod.rs | 10 +-- .../rustc_hir_analysis/src/check/check.rs | 6 +- .../src/check/compare_impl_item.rs | 2 +- .../rustc_hir_analysis/src/check/intrinsic.rs | 4 +- .../src/check/intrinsicck.rs | 2 +- compiler/rustc_hir_analysis/src/check/mod.rs | 2 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 8 +- .../rustc_hir_analysis/src/check_unused.rs | 2 +- .../src/coherence/builtin.rs | 3 +- .../src/coherence/inherent_impls.rs | 3 +- .../src/coherence/inherent_impls_overlap.rs | 8 +- .../src/coherence/orphan.rs | 15 ++-- compiler/rustc_hir_analysis/src/collect.rs | 16 ++-- .../src/collect/resolve_bound_vars.rs | 3 +- .../rustc_hir_analysis/src/collect/type_of.rs | 8 +- compiler/rustc_hir_analysis/src/errors.rs | 2 +- .../rustc_hir_analysis/src/impl_wf_check.rs | 5 +- .../src/impl_wf_check/min_specialization.rs | 4 +- .../wrong_number_of_generic_args.rs | 12 +-- .../rustc_hir_analysis/src/variance/terms.rs | 4 +- compiler/rustc_hir_typeck/src/callee.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 6 +- compiler/rustc_hir_typeck/src/coercion.rs | 3 +- compiler/rustc_hir_typeck/src/expr.rs | 14 ++-- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 8 +- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 42 +++++----- .../src/fn_ctxt/suggestions.rs | 10 +-- .../src/generator_interior/drop_ranges/mod.rs | 4 +- .../src/generator_interior/mod.rs | 2 +- compiler/rustc_hir_typeck/src/intrinsicck.rs | 2 +- .../rustc_hir_typeck/src/method/confirm.rs | 5 +- .../src/method/prelude2021.rs | 20 ++--- .../rustc_hir_typeck/src/method/suggest.rs | 68 ++++++++--------- compiler/rustc_hir_typeck/src/pat.rs | 27 +++---- compiler/rustc_hir_typeck/src/upvar.rs | 15 ++-- compiler/rustc_hir_typeck/src/writeback.rs | 10 +-- compiler/rustc_lint/src/builtin.rs | 2 +- compiler/rustc_lint/src/context.rs | 34 ++++----- compiler/rustc_lint/src/levels.rs | 2 +- compiler/rustc_lint/src/lints.rs | 6 +- compiler/rustc_lint/src/unused.rs | 10 +-- .../rustc_mir_build/src/build/custom/parse.rs | 2 +- .../src/build/expr/as_rvalue.rs | 3 +- .../rustc_mir_build/src/build/matches/mod.rs | 4 +- .../rustc_mir_build/src/build/matches/test.rs | 6 +- compiler/rustc_mir_build/src/build/mod.rs | 15 ++-- compiler/rustc_mir_build/src/errors.rs | 8 +- compiler/rustc_mir_build/src/thir/cx/expr.rs | 4 +- .../src/thir/pattern/check_match.rs | 25 +++--- .../src/thir/pattern/deconstruct_pat.rs | 18 ++--- .../src/thir/pattern/usefulness.rs | 4 +- .../src/coverage/counters.rs | 8 +- .../rustc_mir_transform/src/coverage/debug.rs | 4 +- .../rustc_mir_transform/src/coverage/graph.rs | 15 ++-- .../src/elaborate_drops.rs | 5 +- .../src/function_item_references.rs | 6 +- compiler/rustc_mir_transform/src/generator.rs | 2 +- .../rustc_mir_transform/src/instsimplify.rs | 2 +- compiler/rustc_mir_transform/src/lib.rs | 2 +- .../rustc_mir_transform/src/match_branches.rs | 2 +- .../src/multiple_return_terminators.rs | 2 +- compiler/rustc_mir_transform/src/nrvo.rs | 2 +- .../rustc_mir_transform/src/pass_manager.rs | 4 +- .../src/remove_unneeded_drops.rs | 2 +- .../rustc_mir_transform/src/remove_zsts.rs | 2 +- compiler/rustc_passes/src/check_const.rs | 6 +- compiler/rustc_passes/src/hir_id_validator.rs | 5 +- compiler/rustc_passes/src/hir_stats.rs | 8 +- compiler/rustc_passes/src/liveness.rs | 2 +- compiler/rustc_ty_utils/src/needs_drop.rs | 2 +- 94 files changed, 385 insertions(+), 498 deletions(-) diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs index a4e0e773a81a..a2c7e767b4cc 100644 --- a/compiler/rustc_borrowck/src/borrowck_errors.rs +++ b/compiler/rustc_borrowck/src/borrowck_errors.rs @@ -37,8 +37,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { desc, ); - err.span_label(borrow_span, format!("{} is borrowed here", borrow_desc)); - err.span_label(span, format!("use of borrowed {}", borrow_desc)); + err.span_label(borrow_span, format!("{borrow_desc} is borrowed here")); + err.span_label(span, format!("use of borrowed {borrow_desc}")); err } @@ -51,8 +51,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { old_opt_via: &str, old_load_end_span: Option, ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { - let via = - |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) }; + let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") }; let mut err = struct_span_err!( self, new_loan_span, @@ -143,9 +142,9 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { ); err.span_label( new_loan_span, - format!("{} construction occurs here{}", container_name, opt_via), + format!("{container_name} construction occurs here{opt_via}"), ); - err.span_label(old_loan_span, format!("borrow occurs here{}", old_opt_via)); + err.span_label(old_loan_span, format!("borrow occurs here{old_opt_via}")); if let Some(previous_end_span) = previous_end_span { err.span_label(previous_end_span, "borrow ends here"); } @@ -173,13 +172,10 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { opt_via, kind_new, ); - err.span_label( - new_loan_span, - format!("{}borrow occurs here{}", second_borrow_desc, opt_via), - ); + err.span_label(new_loan_span, format!("{second_borrow_desc}borrow occurs here{opt_via}")); err.span_label( old_loan_span, - format!("{} construction occurs here{}", container_name, old_opt_via), + format!("{container_name} construction occurs here{old_opt_via}"), ); if let Some(previous_end_span) = previous_end_span { err.span_label(previous_end_span, "borrow from closure ends here"); @@ -199,8 +195,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { msg_old: &str, old_load_end_span: Option, ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> { - let via = - |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) }; + let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") }; let mut err = struct_span_err!( self, span, @@ -216,22 +211,21 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { if msg_new == "" { // If `msg_new` is empty, then this isn't a borrow of a union field. - err.span_label(span, format!("{} borrow occurs here", kind_new)); - err.span_label(old_span, format!("{} borrow occurs here", kind_old)); + err.span_label(span, format!("{kind_new} borrow occurs here")); + err.span_label(old_span, format!("{kind_old} borrow occurs here")); } else { // If `msg_new` isn't empty, then this a borrow of a union field. err.span_label( span, format!( - "{} borrow of {} -- which overlaps with {} -- occurs here", - kind_new, msg_new, msg_old, + "{kind_new} borrow of {msg_new} -- which overlaps with {msg_old} -- occurs here", ), ); err.span_label(old_span, format!("{} borrow occurs here{}", kind_old, via(msg_old))); } if let Some(old_load_end_span) = old_load_end_span { - err.span_label(old_load_end_span, format!("{} borrow ends here", kind_old)); + err.span_label(old_load_end_span, format!("{kind_old} borrow ends here")); } err } @@ -250,8 +244,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { desc, ); - err.span_label(borrow_span, format!("{} is borrowed here", desc)); - err.span_label(span, format!("{} is assigned to here but it was already borrowed", desc)); + err.span_label(borrow_span, format!("{desc} is borrowed here")); + err.span_label(span, format!("{desc} is assigned to here but it was already borrowed")); err } @@ -330,7 +324,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { optional_adverb_for_moved: &str, moved_path: Option, ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { - let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default(); + let moved_path = moved_path.map(|mp| format!(": `{mp}`")).unwrap_or_default(); struct_span_err!( self, @@ -369,8 +363,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { immutable_place, immutable_section, ); - err.span_label(mutate_span, format!("cannot {}", action)); - err.span_label(immutable_span, format!("value is immutable in {}", immutable_section)); + err.span_label(mutate_span, format!("cannot {action}")); + err.span_label(immutable_span, format!("value is immutable in {immutable_section}")); err } @@ -428,7 +422,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { err.span_label( span, - format!("{}s a {} data owned by the current function", return_kind, reference_desc), + format!("{return_kind}s a {reference_desc} data owned by the current function"), ); err @@ -449,8 +443,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { "{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \ which is owned by the current {scope}", ); - err.span_label(capture_span, format!("{} is borrowed here", borrowed_path)) - .span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path)); + err.span_label(capture_span, format!("{borrowed_path} is borrowed here")) + .span_label(closure_span, format!("may outlive borrowed value {borrowed_path}")); err } diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index 1064b44d2cd7..1e89a9f51445 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -360,7 +360,7 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> { return; } let index = self.borrow_set.get_index_of(&location).unwrap_or_else(|| { - panic!("could not find BorrowIndex for location {:?}", location); + panic!("could not find BorrowIndex for location {location:?}"); }); trans.gen(index); diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 97c3e0b879a6..03b90f4ab184 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -653,7 +653,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.span_suggestion_verbose( sugg_span.shrink_to_hi(), "consider assigning a value", - format!(" = {}", assign_value), + format!(" = {assign_value}"), Applicability::MaybeIncorrect, ); } @@ -738,7 +738,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Try to find predicates on *generic params* that would allow copying `ty` let suggestion = if let Some(symbol) = tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { - format!(": {}.clone()", symbol) + format!(": {symbol}.clone()") } else { ".clone()".to_owned() }; @@ -1162,8 +1162,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if union_type_name != "" { err.note(format!( - "{} is a field of the union `{}`, so it overlaps the field {}", - msg_place, union_type_name, msg_borrow, + "{msg_place} is a field of the union `{union_type_name}`, so it overlaps the field {msg_borrow}", )); } @@ -1353,8 +1352,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let Some(trait_did) = tcx.trait_of_item(def_id) && tcx.is_diagnostic_item(sym::Iterator, trait_did) { err.note(format!( - "a for loop advances the iterator for you, the result is stored in `{}`.", - loop_bind + "a for loop advances the iterator for you, the result is stored in `{loop_bind}`." )); err.help("if you want to call `next` on a iterator within the loop, consider using `while let`."); } @@ -1825,7 +1823,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }, ConstraintCategory::CallArgument(None), var_or_use_span, - &format!("`{}`", name), + &format!("`{name}`"), "block", ), ( @@ -1847,7 +1845,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { region_name, category, span, - &format!("`{}`", name), + &format!("`{name}`"), "function", ), ( @@ -1921,14 +1919,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - let mut err = self.path_does_not_live_long_enough(borrow_span, &format!("`{}`", name)); + let mut err = self.path_does_not_live_long_enough(borrow_span, &format!("`{name}`")); if let Some(annotation) = self.annotate_argument_and_return_for_borrow(borrow) { let region_name = annotation.emit(self, &mut err); err.span_label( borrow_span, - format!("`{}` would have to be valid for `{}`...", name, region_name), + format!("`{name}` would have to be valid for `{region_name}`..."), ); err.span_label( @@ -1939,7 +1937,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.infcx .tcx .opt_item_name(self.mir_def_id().to_def_id()) - .map(|name| format!("function `{}`", name)) + .map(|name| format!("function `{name}`")) .unwrap_or_else(|| { match &self.infcx.tcx.def_kind(self.mir_def_id()) { DefKind::Closure => "enclosing closure", @@ -1974,7 +1972,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } else { err.span_label(borrow_span, "borrowed value does not live long enough"); - err.span_label(drop_span, format!("`{}` dropped here while still borrowed", name)); + err.span_label(drop_span, format!("`{name}` dropped here while still borrowed")); borrow_spans.args_subdiag(&mut err, |args_span| { crate::session_diagnostics::CaptureArgLabel::Capture { @@ -2018,22 +2016,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let mut err = self.cannot_borrow_across_destructor(borrow_span); let what_was_dropped = match self.describe_place(place.as_ref()) { - Some(name) => format!("`{}`", name), + Some(name) => format!("`{name}`"), None => String::from("temporary value"), }; let label = match self.describe_place(borrow.borrowed_place.as_ref()) { Some(borrowed) => format!( - "here, drop of {D} needs exclusive access to `{B}`, \ - because the type `{T}` implements the `Drop` trait", - D = what_was_dropped, - T = dropped_ty, - B = borrowed + "here, drop of {what_was_dropped} needs exclusive access to `{borrowed}`, \ + because the type `{dropped_ty}` implements the `Drop` trait" ), None => format!( - "here is drop of {D}; whose type `{T}` implements the `Drop` trait", - D = what_was_dropped, - T = dropped_ty + "here is drop of {what_was_dropped}; whose type `{dropped_ty}` implements the `Drop` trait" ), }; err.span_label(drop_span, label); @@ -2245,10 +2238,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } else { "local data " }; - ( - format!("{}`{}`", local_kind, place_desc), - format!("`{}` is borrowed here", place_desc), - ) + (format!("{local_kind}`{place_desc}`"), format!("`{place_desc}` is borrowed here")) } else { let root_place = self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All).last().unwrap(); @@ -2350,9 +2340,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.span_suggestion_verbose( sugg_span, format!( - "to force the {} to take ownership of {} (and any \ - other referenced variables), use the `move` keyword", - kind, captured_var + "to force the {kind} to take ownership of {captured_var} (and any \ + other referenced variables), use the `move` keyword" ), suggestion, Applicability::MachineApplicable, @@ -2360,7 +2349,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { match category { ConstraintCategory::Return(_) | ConstraintCategory::OpaqueType => { - let msg = format!("{} is returned here", kind); + let msg = format!("{kind} is returned here"); err.span_note(constraint_span, msg); } ConstraintCategory::CallArgument(_) => { @@ -2402,21 +2391,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.span_label( upvar_span, - format!("`{}` declared here, outside of the {} body", upvar_name, escapes_from), + format!("`{upvar_name}` declared here, outside of the {escapes_from} body"), ); - err.span_label(borrow_span, format!("borrow is only valid in the {} body", escapes_from)); + err.span_label(borrow_span, format!("borrow is only valid in the {escapes_from} body")); if let Some(name) = name { err.span_label( escape_span, - format!("reference to `{}` escapes the {} body here", name, escapes_from), + format!("reference to `{name}` escapes the {escapes_from} body here"), ); } else { - err.span_label( - escape_span, - format!("reference escapes the {} body here", escapes_from), - ); + err.span_label(escape_span, format!("reference escapes the {escapes_from} body here")); } err @@ -2697,10 +2683,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }); if let Some(Ok(instance)) = deref_target { let deref_target_ty = instance.ty(tcx, self.param_env); - err.note(format!( - "borrow occurs due to deref coercion to `{}`", - deref_target_ty - )); + err.note(format!("borrow occurs due to deref coercion to `{deref_target_ty}`")); err.span_note(tcx.def_span(instance.def_id()), "deref defined here"); } } @@ -2756,7 +2739,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { "cannot assign twice to immutable variable" }; if span != assigned_span && !from_arg { - err.span_label(assigned_span, format!("first assignment to {}", place_description)); + err.span_label(assigned_span, format!("first assignment to {place_description}")); } if let Some(decl) = local_decl && let Some(name) = local_name @@ -2765,7 +2748,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.span_suggestion( decl.source_info.span, "consider making this binding mutable", - format!("mut {}", name), + format!("mut {name}"), Applicability::MachineApplicable, ); } @@ -3226,7 +3209,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { return_span, } => { let argument_ty_name = cx.get_name_for_ty(argument_ty, 0); - diag.span_label(argument_span, format!("has type `{}`", argument_ty_name)); + diag.span_label(argument_span, format!("has type `{argument_ty_name}`")); let return_ty_name = cx.get_name_for_ty(return_ty, 0); let types_equal = return_ty_name == argument_ty_name; @@ -3253,15 +3236,14 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { // Region of return type and arguments checked to be the same earlier. let region_name = cx.get_region_name_for_ty(*return_ty, 0); for (_, argument_span) in arguments { - diag.span_label(*argument_span, format!("has lifetime `{}`", region_name)); + diag.span_label(*argument_span, format!("has lifetime `{region_name}`")); } - diag.span_label(*return_span, format!("also has lifetime `{}`", region_name,)); + diag.span_label(*return_span, format!("also has lifetime `{region_name}`",)); diag.help(format!( - "use data from the highlighted arguments which match the `{}` lifetime of \ + "use data from the highlighted arguments which match the `{region_name}` lifetime of \ the return type", - region_name, )); region_name diff --git a/compiler/rustc_borrowck/src/facts.rs b/compiler/rustc_borrowck/src/facts.rs index 87fad9a355d3..9916ebca32fa 100644 --- a/compiler/rustc_borrowck/src/facts.rs +++ b/compiler/rustc_borrowck/src/facts.rs @@ -202,7 +202,7 @@ trait FactCell { impl FactCell for A { default fn to_string(&self, _location_table: &LocationTable) -> String { - format!("{:?}", self) + format!("{self:?}") } } diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index ea32506fc898..32368f35fc99 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1817,8 +1817,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } ProjectionElem::Subslice { .. } => { - panic!("we don't allow assignments to subslices, location: {:?}", - location); + panic!("we don't allow assignments to subslices, location: {location:?}"); } ProjectionElem::Field(..) => { @@ -2017,8 +2016,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.infcx.tcx.sess.delay_span_bug( span, format!( - "Accessing `{:?}` with the kind `{:?}` shouldn't be possible", - place, kind, + "Accessing `{place:?}` with the kind `{kind:?}` shouldn't be possible", ), ); } diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index b5014a3f479c..679a19710a7f 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -347,7 +347,7 @@ pub(super) fn dump_mir_results<'tcx>( for_each_region_constraint( infcx.tcx, closure_region_requirements, - &mut |msg| writeln!(out, "| {}", msg), + &mut |msg| writeln!(out, "| {msg}"), )?; writeln!(out, "|")?; } @@ -426,7 +426,7 @@ pub(super) fn dump_annotation<'tcx>( }; if !opaque_type_values.is_empty() { - err.note(format!("Inferred opaque type values:\n{:#?}", opaque_type_values)); + err.note(format!("Inferred opaque type values:\n{opaque_type_values:#?}")); } errors.buffer_non_error_diag(err); @@ -439,7 +439,7 @@ fn for_each_region_constraint<'tcx>( ) -> io::Result<()> { for req in &closure_region_requirements.outlives_requirements { let subject = match req.subject { - ClosureOutlivesSubject::Region(subject) => format!("{:?}", subject), + ClosureOutlivesSubject::Region(subject) => format!("{subject:?}"), ClosureOutlivesSubject::Ty(ty) => { format!("{:?}", ty.instantiate(tcx, |vid| ty::Region::new_var(tcx, vid))) } diff --git a/compiler/rustc_borrowck/src/region_infer/dump_mir.rs b/compiler/rustc_borrowck/src/region_infer/dump_mir.rs index 6524b594e44d..4d620ac9de61 100644 --- a/compiler/rustc_borrowck/src/region_infer/dump_mir.rs +++ b/compiler/rustc_borrowck/src/region_infer/dump_mir.rs @@ -52,7 +52,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { writeln!(out, "|")?; writeln!(out, "| Inference Constraints")?; - self.for_each_constraint(tcx, &mut |msg| writeln!(out, "| {}", msg))?; + self.for_each_constraint(tcx, &mut |msg| writeln!(out, "| {msg}"))?; Ok(()) } @@ -69,7 +69,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { for region in self.definitions.indices() { let value = self.liveness_constraints.region_value_str(region); if value != "{}" { - with_msg(&format!("{:?} live at {}", region, value))?; + with_msg(&format!("{region:?} live at {value}"))?; } } @@ -81,12 +81,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { Locations::All(span) => { ("All", tcx.sess.source_map().span_to_embeddable_string(*span)) } - Locations::Single(loc) => ("Single", format!("{:?}", loc)), + Locations::Single(loc) => ("Single", format!("{loc:?}")), }; - with_msg(&format!( - "{:?}: {:?} due to {:?} at {}({}) ({:?}", - sup, sub, category, name, arg, span - ))?; + with_msg(&format!("{sup:?}: {sub:?} due to {category:?} at {name}({arg}) ({span:?}"))?; } Ok(()) diff --git a/compiler/rustc_borrowck/src/region_infer/graphviz.rs b/compiler/rustc_borrowck/src/region_infer/graphviz.rs index 2e15586e03b3..a0cf22e935a9 100644 --- a/compiler/rustc_borrowck/src/region_infer/graphviz.rs +++ b/compiler/rustc_borrowck/src/region_infer/graphviz.rs @@ -49,7 +49,7 @@ impl<'a, 'this, 'tcx> dot::Labeller<'this> for RawConstraints<'a, 'tcx> { Some(dot::LabelText::LabelStr(Cow::Borrowed("box"))) } fn node_label(&'this self, n: &RegionVid) -> dot::LabelText<'this> { - dot::LabelText::LabelStr(format!("{:?}", n).into()) + dot::LabelText::LabelStr(format!("{n:?}").into()) } fn edge_label(&'this self, e: &OutlivesConstraint<'tcx>) -> dot::LabelText<'this> { dot::LabelText::LabelStr(format!("{:?}", e.locations).into()) @@ -100,7 +100,7 @@ impl<'a, 'this, 'tcx> dot::Labeller<'this> for SccConstraints<'a, 'tcx> { } fn node_label(&'this self, n: &ConstraintSccIndex) -> dot::LabelText<'this> { let nodes = &self.nodes_per_scc[*n]; - dot::LabelText::LabelStr(format!("{:?} = {:?}", n, nodes).into()) + dot::LabelText::LabelStr(format!("{n:?} = {nodes:?}").into()) } } diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index fbbccc58ad66..30dfb2d919a3 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -259,7 +259,7 @@ fn sccs_info<'cx, 'tcx>( let mut reg_vars_to_origins_str = "region variables to origins:\n".to_string(); for (reg_var, origin) in var_to_origin_sorted.into_iter() { - reg_vars_to_origins_str.push_str(&format!("{:?}: {:?}\n", reg_var, origin)); + reg_vars_to_origins_str.push_str(&format!("{reg_var:?}: {origin:?}\n")); } debug!("{}", reg_vars_to_origins_str); diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index d8e81827a3be..f5da848d1c0d 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -419,7 +419,7 @@ fn check_opaque_type_parameter_valid( return Err(tcx .sess .struct_span_err(span, "non-defining opaque type use in defining scope") - .span_note(spans, format!("{} used multiple times", descr)) + .span_note(spans, format!("{descr} used multiple times")) .emit()); } } diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index 9290e7479144..d205862cd3fe 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -470,7 +470,7 @@ fn region_value_str(elements: impl IntoIterator) -> String } push_sep(&mut result); - result.push_str(&format!("{:?}", fr)); + result.push_str(&format!("{fr:?}")); } RegionElement::PlaceholderRegion(placeholder) => { @@ -481,7 +481,7 @@ fn region_value_str(elements: impl IntoIterator) -> String } push_sep(&mut result); - result.push_str(&format!("{:?}", placeholder)); + result.push_str(&format!("{placeholder:?}")); } } } @@ -497,7 +497,7 @@ fn region_value_str(elements: impl IntoIterator) -> String fn push_location_range(str: &mut String, location1: Location, location2: Location) { if location1 == location2 { - str.push_str(&format!("{:?}", location1)); + str.push_str(&format!("{location1:?}")); } else { assert_eq!(location1.block, location2.block); str.push_str(&format!( diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index b21cb984de67..e31c68d33d2f 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -52,7 +52,7 @@ fn eval_body_using_ecx<'mir, 'tcx>( trace!( "eval_body_using_ecx: pushing stack frame for global: {}{}", with_no_trimmed_paths!(ecx.tcx.def_path_str(cid.instance.def_id())), - cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p)) + cid.promoted.map_or_else(String::new, |p| format!("::promoted[{p:?}]")) ); ecx.push_stack_frame( diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index b519bcdf4a33..693b2d5f2838 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -55,7 +55,7 @@ fn slice_branches<'tcx>( place: &MPlaceTy<'tcx>, num_nodes: &mut usize, ) -> ValTreeCreationResult<'tcx> { - let n = place.len(ecx).unwrap_or_else(|_| panic!("expected to use len of place {:?}", place)); + let n = place.len(ecx).unwrap_or_else(|_| panic!("expected to use len of place {place:?}")); let mut elems = Vec::with_capacity(n as usize); for i in 0..n { diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 0e6125388a60..f014037f2781 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -1016,7 +1016,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug match self.place { Place::Local { frame, local, offset } => { let mut allocs = Vec::new(); - write!(fmt, "{:?}", local)?; + write!(fmt, "{local:?}")?; if let Some(offset) = offset { write!(fmt, "+{:#x}", offset.bytes())?; } @@ -1035,7 +1035,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug fmt, " by {} ref {:?}:", match mplace.meta { - MemPlaceMeta::Meta(meta) => format!(" meta({:?})", meta), + MemPlaceMeta::Meta(meta) => format!(" meta({meta:?})"), MemPlaceMeta::None => String::new(), }, mplace.ptr, @@ -1043,13 +1043,13 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug allocs.extend(mplace.ptr.provenance.map(Provenance::get_alloc_id)); } LocalValue::Live(Operand::Immediate(Immediate::Scalar(val))) => { - write!(fmt, " {:?}", val)?; + write!(fmt, " {val:?}")?; if let Scalar::Ptr(ptr, _size) = val { allocs.push(ptr.provenance.get_alloc_id()); } } LocalValue::Live(Operand::Immediate(Immediate::ScalarPair(val1, val2))) => { - write!(fmt, " ({:?}, {:?})", val1, val2)?; + write!(fmt, " ({val1:?}, {val2:?})")?; if let Scalar::Ptr(ptr, _size) = val1 { allocs.push(ptr.provenance.get_alloc_id()); } @@ -1065,7 +1065,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug Some(alloc_id) => { write!(fmt, "by ref {:?}: {:?}", mplace.ptr, self.ecx.dump_alloc(alloc_id)) } - ptr => write!(fmt, " integral by ref: {:?}", ptr), + ptr => write!(fmt, " integral by ref: {ptr:?}"), }, } } diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 3f6971682805..91da7ea68bc5 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -394,17 +394,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // For *all* intrinsics we first check `is_uninhabited` to give a more specific // error message. _ if layout.abi.is_uninhabited() => format!( - "aborted execution: attempted to instantiate uninhabited type `{}`", - ty + "aborted execution: attempted to instantiate uninhabited type `{ty}`" ), ValidityRequirement::Inhabited => bug!("handled earlier"), ValidityRequirement::Zero => format!( - "aborted execution: attempted to zero-initialize type `{}`, which is invalid", - ty + "aborted execution: attempted to zero-initialize type `{ty}`, which is invalid" ), ValidityRequirement::UninitMitigated0x01Fill => format!( - "aborted execution: attempted to leave type `{}` uninitialized, which is invalid", - ty + "aborted execution: attempted to leave type `{ty}` uninitialized, which is invalid" ), ValidityRequirement::Uninit => bug!("assert_uninit_valid doesn't exist"), }; @@ -420,9 +417,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { assert_eq!(input_len, dest_len, "Return vector length must match input length"); assert!( index < dest_len, - "Index `{}` must be in bounds of vector with length {}", - index, - dest_len + "Index `{index}` must be in bounds of vector with length {dest_len}" ); for i in 0..dest_len { @@ -440,9 +435,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let (input, input_len) = self.operand_to_simd(&args[0])?; assert!( index < input_len, - "index `{}` must be in bounds of vector with length {}", - index, - input_len + "index `{index}` must be in bounds of vector with length {input_len}" ); self.copy_op( &self.project_index(&input, index)?.into(), diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 7b44a20ef03d..02d022a2252a 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -53,7 +53,7 @@ impl fmt::Display for MemoryKind { match self { MemoryKind::Stack => write!(f, "stack variable"), MemoryKind::CallerLocation => write!(f, "caller location"), - MemoryKind::Machine(m) => write!(f, "{}", m), + MemoryKind::Machine(m) => write!(f, "{m}"), } } } @@ -907,7 +907,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a, match self.ecx.memory.alloc_map.get(id) { Some((kind, alloc)) => { // normal alloc - write!(fmt, " ({}, ", kind)?; + write!(fmt, " ({kind}, ")?; write_allocation_track_relocs( &mut *fmt, *self.ecx.tcx, diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs index 49c3b152e1d7..eb0645780673 100644 --- a/compiler/rustc_const_eval/src/interpret/operator.rs +++ b/compiler/rustc_const_eval/src/interpret/operator.rs @@ -24,8 +24,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { debug_assert_eq!( Ty::new_tup(self.tcx.tcx, &[ty, self.tcx.types.bool]), dest.layout.ty, - "type mismatch for result of {:?}", - op, + "type mismatch for result of {op:?}", ); // Write the result to `dest`. if let Abi::ScalarPair(..) = dest.layout.abi { @@ -56,7 +55,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { dest: &PlaceTy<'tcx, M::Provenance>, ) -> InterpResult<'tcx> { let (val, _overflowed, ty) = self.overflowing_binary_op(op, left, right)?; - assert_eq!(ty, dest.layout.ty, "type mismatch for result of {:?}", op); + assert_eq!(ty, dest.layout.ty, "type mismatch for result of {op:?}"); self.write_scalar(val, dest) } } diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 9182d23128fe..af6ca47708b6 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -178,7 +178,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // The operand always has the same type as the result. let val = self.read_immediate(&self.eval_operand(operand, Some(dest.layout))?)?; let val = self.unary_op(un_op, &val)?; - assert_eq!(val.layout, dest.layout, "layout mismatch for result of {:?}", un_op); + assert_eq!(val.layout, dest.layout, "layout mismatch for result of {un_op:?}"); self.write_immediate(*val, &dest)?; } diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index a82c98e72057..2141243cb0e7 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -164,14 +164,14 @@ fn write_path(out: &mut String, path: &[PathElem]) { for elem in path.iter() { match elem { - Field(name) => write!(out, ".{}", name), + Field(name) => write!(out, ".{name}"), EnumTag => write!(out, "."), - Variant(name) => write!(out, ".", name), + Variant(name) => write!(out, "."), GeneratorTag => write!(out, "."), GeneratorState(idx) => write!(out, ".", idx.index()), - CapturedVar(name) => write!(out, ".", name), - TupleElem(idx) => write!(out, ".{}", idx), - ArrayElem(idx) => write!(out, "[{}]", idx), + CapturedVar(name) => write!(out, "."), + TupleElem(idx) => write!(out, ".{idx}"), + ArrayElem(idx) => write!(out, "[{idx}]"), // `.` does not match Rust syntax, but it is more readable for long paths -- and // some of the other items here also are not Rust syntax. Actually we can't // even use the usual syntax because we are just showing the projections, diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 81337079af23..e785196c744c 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -310,8 +310,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { if let Some(feature) = feature && ccx.tcx.sess.is_nightly_build() { err.help(format!( - "add `#![feature({})]` to the crate attributes to enable", - feature, + "add `#![feature({feature})]` to the crate attributes to enable", )); } @@ -346,10 +345,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable { err.help("const-stable functions can only call other const-stable functions"); } else if ccx.tcx.sess.is_nightly_build() { if let Some(feature) = feature { - err.help(format!( - "add `#![feature({})]` to the crate attributes to enable", - feature - )); + err.help(format!("add `#![feature({feature})]` to the crate attributes to enable")); } } diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 7b2bed302db6..31effadd2c26 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -149,7 +149,7 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> { } } } else { - self.fail(location, format!("encountered jump to invalid basic block {:?}", bb)) + self.fail(location, format!("encountered jump to invalid basic block {bb:?}")) } } @@ -222,8 +222,7 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> { self.fail( Location { block: bb, statement_index: 0 }, format!( - "Cleanup control flow violation: Cycle involving edge {:?} -> {:?}", - bb, parent, + "Cleanup control flow violation: Cycle involving edge {bb:?} -> {parent:?}", ), ); break; @@ -257,7 +256,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { if self.body.local_decls.get(local).is_none() { self.fail( location, - format!("local {:?} has no corresponding declaration in `body.local_decls`", local), + format!("local {local:?} has no corresponding declaration in `body.local_decls`"), ); } @@ -272,7 +271,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { self.storage_liveness.seek_after_primary_effect(location); let locals_with_storage = self.storage_liveness.get(); if !locals_with_storage.contains(local) { - self.fail(location, format!("use of local {:?}, which has no storage here", local)); + self.fail(location, format!("use of local {local:?}, which has no storage here")); } } } @@ -323,7 +322,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { // DropsLowered`. However, this causes ICEs with generation of drop shims, which // seem to fail to set their `MirPhase` correctly. if matches!(kind, RetagKind::Raw | RetagKind::TwoPhase) { - self.fail(location, format!("explicit `{:?}` is forbidden", kind)); + self.fail(location, format!("explicit `{kind:?}` is forbidden")); } } StatementKind::StorageLive(local) => { @@ -556,7 +555,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { let ty = place.ty(&self.body.local_decls, self.tcx).ty; if !ty.is_copy_modulo_regions(self.tcx, self.param_env) { - self.fail(location, format!("`Operand::Copy` with non-`Copy` type {}", ty)); + self.fail(location, format!("`Operand::Copy` with non-`Copy` type {ty}")); } } } @@ -575,7 +574,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ProjectionElem::Index(index) => { let index_ty = self.body.local_decls[index].ty; if index_ty != self.tcx.types.usize { - self.fail(location, format!("bad index ({:?} != usize)", index_ty)) + self.fail(location, format!("bad index ({index_ty:?} != usize)")) } } ProjectionElem::Deref @@ -586,22 +585,21 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { if base_ty.is_box() { self.fail( location, - format!("{:?} dereferenced after ElaborateBoxDerefs", base_ty), + format!("{base_ty:?} dereferenced after ElaborateBoxDerefs"), ) } } ProjectionElem::Field(f, ty) => { let parent_ty = place_ref.ty(&self.body.local_decls, self.tcx); let fail_out_of_bounds = |this: &mut Self, location| { - this.fail(location, format!("Out of bounds field {:?} for {:?}", f, parent_ty)); + this.fail(location, format!("Out of bounds field {f:?} for {parent_ty:?}")); }; let check_equal = |this: &mut Self, location, f_ty| { if !this.mir_assign_valid_types(ty, f_ty) { this.fail( location, format!( - "Field projection `{:?}.{:?}` specified type `{:?}`, but actual type is `{:?}`", - place_ref, f, ty, f_ty + "Field projection `{place_ref:?}.{f:?}` specified type `{ty:?}`, but actual type is `{f_ty:?}`" ) ) } @@ -649,7 +647,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { let Some(layout) = gen_body.generator_layout() else { self.fail( location, - format!("No generator layout for {:?}", parent_ty), + format!("No generator layout for {parent_ty:?}"), ); return; }; @@ -662,7 +660,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { let Some(f_ty) = layout.field_tys.get(local) else { self.fail( location, - format!("Out of bounds local {:?} for {:?}", local, parent_ty), + format!("Out of bounds local {local:?} for {parent_ty:?}"), ); return; }; @@ -705,7 +703,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { if debuginfo.references != 0 && place.projection.last() == Some(&PlaceElem::Deref) { self.fail( START_BLOCK.start_location(), - format!("debuginfo {:?}, has both ref and deref", debuginfo), + format!("debuginfo {debuginfo:?}, has both ref and deref"), ); } } @@ -715,7 +713,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { if ty.is_union() || ty.is_enum() { self.fail( START_BLOCK.start_location(), - format!("invalid type {:?} for composite debuginfo", ty), + format!("invalid type {ty:?} for composite debuginfo"), ); } if f.projection.iter().any(|p| !matches!(p, PlaceElem::Field(..))) { @@ -742,7 +740,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { && cntxt != PlaceContext::NonUse(NonUseContext::VarDebugInfo) && place.projection[1..].contains(&ProjectionElem::Deref) { - self.fail(location, format!("{:?}, has deref at the wrong place", place)); + self.fail(location, format!("{place:?}, has deref at the wrong place")); } self.super_place(place, cntxt, location); @@ -802,7 +800,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { Offset => { check_kinds!(a, "Cannot offset non-pointer type {:?}", ty::RawPtr(..)); if b != self.tcx.types.isize && b != self.tcx.types.usize { - self.fail(location, format!("Cannot offset by non-isize type {:?}", b)); + self.fail(location, format!("Cannot offset by non-isize type {b:?}")); } } Eq | Lt | Le | Ne | Ge | Gt => { @@ -867,13 +865,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { self.fail( location, format!( - "Cannot perform checked arithmetic on unequal types {:?} and {:?}", - a, b + "Cannot perform checked arithmetic on unequal types {a:?} and {b:?}" ), ); } } - _ => self.fail(location, format!("There is no checked version of {:?}", op)), + _ => self.fail(location, format!("There is no checked version of {op:?}")), } } Rvalue::UnaryOp(op, operand) => { @@ -1078,7 +1075,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { if !ty.is_bool() { self.fail( location, - format!("`assume` argument must be `bool`, but got: `{}`", ty), + format!("`assume` argument must be `bool`, but got: `{ty}`"), ); } } @@ -1091,7 +1088,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } else { self.fail( location, - format!("Expected src to be ptr in copy_nonoverlapping, got: {}", src_ty), + format!("Expected src to be ptr in copy_nonoverlapping, got: {src_ty}"), ); return; }; @@ -1101,19 +1098,19 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } else { self.fail( location, - format!("Expected dst to be ptr in copy_nonoverlapping, got: {}", dst_ty), + format!("Expected dst to be ptr in copy_nonoverlapping, got: {dst_ty}"), ); return; }; // since CopyNonOverlapping is parametrized by 1 type, // we only need to check that they are equal and not keep an extra parameter. if !self.mir_assign_valid_types(op_src_ty, op_dst_ty) { - self.fail(location, format!("bad arg ({:?} != {:?})", op_src_ty, op_dst_ty)); + self.fail(location, format!("bad arg ({op_src_ty:?} != {op_dst_ty:?})")); } let op_cnt_ty = count.ty(&self.body.local_decls, self.tcx); if op_cnt_ty != self.tcx.types.usize { - self.fail(location, format!("bad arg ({:?} != usize)", op_cnt_ty)) + self.fail(location, format!("bad arg ({op_cnt_ty:?} != usize)")) } } StatementKind::SetDiscriminant { place, .. } => { @@ -1125,8 +1122,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { self.fail( location, format!( - "`SetDiscriminant` is only allowed on ADTs and generators, not {:?}", - pty + "`SetDiscriminant` is only allowed on ADTs and generators, not {pty:?}" ), ); } @@ -1141,7 +1137,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { // DropsLowered`. However, this causes ICEs with generation of drop shims, which // seem to fail to set their `MirPhase` correctly. if matches!(kind, RetagKind::Raw | RetagKind::TwoPhase) { - self.fail(location, format!("explicit `{:?}` is forbidden", kind)); + self.fail(location, format!("explicit `{kind:?}` is forbidden")); } } StatementKind::StorageLive(_) @@ -1174,7 +1170,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { if Scalar::<()>::try_from_uint(value, size).is_none() { self.fail( location, - format!("the value {:#x} is not a proper {:?}", value, switch_ty), + format!("the value {value:#x} is not a proper {switch_ty:?}"), ) } } @@ -1185,7 +1181,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ty::FnPtr(..) | ty::FnDef(..) => {} _ => self.fail( location, - format!("encountered non-callable type {} in `Call` terminator", func_ty), + format!("encountered non-callable type {func_ty} in `Call` terminator"), ), } } @@ -1195,8 +1191,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { self.fail( location, format!( - "encountered non-boolean condition of type {} in `Assert` terminator", - cond_ty + "encountered non-boolean condition of type {cond_ty} in `Assert` terminator" ), ); } diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs index 7f4927bbb98f..bd311c98facf 100644 --- a/compiler/rustc_hir_analysis/src/astconv/errors.rs +++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs @@ -197,7 +197,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } } - err.span_label(span, format!("associated type `{}` not found", assoc_name)); + err.span_label(span, format!("associated type `{assoc_name}` not found")); err.emit() } @@ -393,7 +393,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .into_iter() .map(|error| error.root_obligation.predicate) .filter_map(format_pred) - .map(|(p, _)| format!("`{}`", p)) + .map(|(p, _)| format!("`{p}`")) .collect(); bounds.sort(); bounds.dedup(); @@ -652,7 +652,7 @@ pub(crate) fn fn_trait_to_string( } .map(|s| { // `s.empty()` checks to see if the type is the unit tuple, if so we don't want a comma - if parenthesized || s.is_empty() { format!("({})", s) } else { format!("({},)", s) } + if parenthesized || s.is_empty() { format!("({s})") } else { format!("({s},)") } }) .ok(), _ => None, diff --git a/compiler/rustc_hir_analysis/src/astconv/generics.rs b/compiler/rustc_hir_analysis/src/astconv/generics.rs index e81c61d80edd..1372cc896be3 100644 --- a/compiler/rustc_hir_analysis/src/astconv/generics.rs +++ b/compiler/rustc_hir_analysis/src/astconv/generics.rs @@ -81,7 +81,7 @@ fn generic_arg_mismatch_err( err.span_suggestion( tcx.def_span(src_def_id), "consider changing this type parameter to a const parameter", - format!("const {}: {}", param_name, param_type), + format!("const {param_name}: {param_type}"), Applicability::MaybeIncorrect, ); }; @@ -102,7 +102,7 @@ fn generic_arg_mismatch_err( err.span_suggestion( arg.span(), "array type provided where a `usize` was expected, try", - format!("{{ {} }}", snippet), + format!("{{ {snippet} }}"), Applicability::MaybeIncorrect, ); } @@ -130,7 +130,7 @@ fn generic_arg_mismatch_err( } else { (arg.descr(), param.kind.descr()) }; - err.note(format!("{} arguments must be provided before {} arguments", first, last)); + err.note(format!("{first} arguments must be provided before {last} arguments")); if let Some(help) = help { err.help(help); } @@ -304,7 +304,7 @@ pub fn create_args_for_parent_generic_args<'tcx, 'a>( "reorder the arguments: {}: `<{}>`", param_types_present .into_iter() - .map(|ord| format!("{}s", ord)) + .map(|ord| format!("{ord}s")) .collect::>() .join(", then "), ordered_params diff --git a/compiler/rustc_hir_analysis/src/astconv/lint.rs b/compiler/rustc_hir_analysis/src/astconv/lint.rs index ff55174f97a7..1bd1270beaf8 100644 --- a/compiler/rustc_hir_analysis/src/astconv/lint.rs +++ b/compiler/rustc_hir_analysis/src/astconv/lint.rs @@ -34,9 +34,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let param_name = generics.params.next_type_param_name(None); let add_generic_sugg = if let Some(span) = generics.span_for_param_suggestion() { - (span, format!(", {}: {}", param_name, impl_trait_name)) + (span, format!(", {param_name}: {impl_trait_name}")) } else { - (generics.span, format!("<{}: {}>", param_name, impl_trait_name)) + (generics.span, format!("<{param_name}: {impl_trait_name}>")) }; diag.multipart_suggestion( format!("alternatively use a blanket \ diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index ecbbfd925390..3235a9ceba1f 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -1128,7 +1128,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ty_param_name ) }; - err.span_label(span, format!("ambiguous associated type `{}`", assoc_name)); + err.span_label(span, format!("ambiguous associated type `{assoc_name}`")); let mut where_bounds = vec![]; for bound in bounds { @@ -1407,7 +1407,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { _ => { let reported = if variant_resolution.is_some() { // Variant in type position - let msg = format!("expected type, found variant `{}`", assoc_ident); + let msg = format!("expected type, found variant `{assoc_ident}`"); tcx.sess.span_err(span, msg) } else if qself_ty.is_enum() { let mut err = struct_span_err!( @@ -1438,12 +1438,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } else { err.span_label( assoc_ident.span, - format!("variant not found in `{}`", qself_ty), + format!("variant not found in `{qself_ty}`"), ); } if let Some(sp) = tcx.hir().span_if_local(adt_def.did()) { - err.span_label(sp, format!("variant `{}` not found here", assoc_ident)); + err.span_label(sp, format!("variant `{assoc_ident}` not found here")); } err.emit() @@ -2750,7 +2750,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon(..) | ty::BrEnv => { "an anonymous lifetime".to_string() } - ty::BrNamed(_, name) => format!("lifetime `{}`", name), + ty::BrNamed(_, name) => format!("lifetime `{name}`"), }; let mut err = generate_err(&br_name); diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index e0698a72335f..f3beaf06d08a 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -342,7 +342,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes( err.span_suggestion( span, "consider spelling out the type instead", - name.unwrap_or_else(|| format!("{:?}", ty)), + name.unwrap_or_else(|| format!("{ty:?}")), Applicability::MaybeIncorrect, ); } @@ -626,7 +626,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) { "replace the {} parameters with concrete {}{}", kinds, kinds_pl, - egs.map(|egs| format!(" like `{}`", egs)).unwrap_or_default(), + egs.map(|egs| format!(" like `{egs}`")).unwrap_or_default(), ), ) .emit(); @@ -711,7 +711,7 @@ pub(super) fn check_specialization_validity<'tcx>( } else { tcx.sess.delay_span_bug( DUMMY_SP, - format!("parent item: {:?} not marked as default", parent_impl), + format!("parent item: {parent_impl:?} not marked as default"), ); } } diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 89877280a739..0a6e2e644eb2 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1744,7 +1744,7 @@ fn compare_generic_param_kinds<'tcx>( tcx.type_of(param.def_id).instantiate_identity() ) } - Type { .. } => format!("{} type parameter", prefix), + Type { .. } => format!("{prefix} type parameter"), Lifetime { .. } => unreachable!(), }; diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index d5c9840887a6..e076b1fc68cc 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -134,7 +134,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: DefId) -> hir /// Remember to add all intrinsics here, in `compiler/rustc_codegen_llvm/src/intrinsic.rs`, /// and in `library/core/src/intrinsics.rs`. pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { - let param = |n| Ty::new_param(tcx, n, Symbol::intern(&format!("P{}", n))); + let param = |n| Ty::new_param(tcx, n, Symbol::intern(&format!("P{n}"))); let intrinsic_id = it.owner_id.to_def_id(); let intrinsic_name = tcx.item_name(intrinsic_id); let name_str = intrinsic_name.as_str(); @@ -494,7 +494,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { /// Type-check `extern "platform-intrinsic" { ... }` functions. pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { let param = |n| { - let name = Symbol::intern(&format!("P{}", n)); + let name = Symbol::intern(&format!("P{n}")); Ty::new_param(tcx, n, name) }; diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index 8423a9550bac..b0dd5e5787dc 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -211,7 +211,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { // register class is usable at all. if let Some(feature) = feature { if !target_features.contains(feature) { - let msg = format!("`{}` target feature is not enabled", feature); + let msg = format!("`{feature}` target feature is not enabled"); let mut err = self.tcx.sess.struct_span_err(expr.span, msg); err.note(format!( "this is required to use type `{}` with register class `{}`", diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index def7a3a9d885..4cf3587327d2 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -214,7 +214,7 @@ fn missing_items_err( trait_item, tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity(), ); - let code = format!("{}{}\n{}", padding, snippet, padding); + let code = format!("{padding}{snippet}\n{padding}"); if let Some(span) = tcx.hir().span_if_local(trait_item.def_id) { missing_trait_item_label .push(errors::MissingTraitItemLabel { span, item: trait_item.name }); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 4e194f1c381c..cb41040cbaae 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -472,8 +472,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe let bound = if unsatisfied_bounds.len() > 1 { "these bounds are" } else { "this bound is" }; err.note(format!( - "{} currently required to ensure that impls have maximum flexibility", - bound + "{bound} currently required to ensure that impls have maximum flexibility" )); err.note( "we are soliciting feedback, see issue #87479 \ @@ -989,7 +988,7 @@ fn check_type_defn<'tcx>(tcx: TyCtxt<'tcx>, item: &hir::Item<'tcx>, all_sized: b let ty = tcx.erase_regions(ty); if ty.has_infer() { tcx.sess - .delay_span_bug(item.span, format!("inference variables in {:?}", ty)); + .delay_span_bug(item.span, format!("inference variables in {ty:?}")); // Just treat unresolved type expression as if it needs drop. true } else { @@ -1863,8 +1862,7 @@ fn report_bivariance( if matches!(param.kind, hir::GenericParamKind::Type { .. }) && !has_explicit_bounds { err.help(format!( - "if you intended `{0}` to be a const parameter, use `const {0}: usize` instead", - param_name + "if you intended `{param_name}` to be a const parameter, use `const {param_name}: usize` instead" )); } err.emit() diff --git a/compiler/rustc_hir_analysis/src/check_unused.rs b/compiler/rustc_hir_analysis/src/check_unused.rs index d10bc5b34ea9..9ad73eeffc6a 100644 --- a/compiler/rustc_hir_analysis/src/check_unused.rs +++ b/compiler/rustc_hir_analysis/src/check_unused.rs @@ -36,7 +36,7 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) { } let (path, _) = item.expect_use(); let msg = if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(path.span) { - format!("unused import: `{}`", snippet) + format!("unused import: `{snippet}`") } else { "unused import".to_owned() }; diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 3f65adcd36eb..c930537d4aee 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -171,8 +171,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef create_err(&format!( "the trait `DispatchFromDyn` may only be implemented \ for a coercion between structures with the same \ - definition; expected `{}`, found `{}`", - source_path, target_path, + definition; expected `{source_path}`, found `{target_path}`", )) .emit(); diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs index f5326e50614f..a94c75f918a9 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs @@ -148,8 +148,7 @@ impl<'tcx> InherentCollect<'tcx> { if let ty::Ref(_, subty, _) = ty.kind() { err.note(format!( "you could also try moving the reference to \ - uses of `{}` (such as `self`) within the implementation", - subty + uses of `{subty}` (such as `self`) within the implementation" )); } err.emit(); diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs index 3bd2931265c7..7205b7a21a82 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs @@ -77,8 +77,8 @@ impl<'tcx> InherentOverlapChecker<'tcx> { "duplicate definitions with name `{}`", ident, ); - err.span_label(span, format!("duplicate definitions for `{}`", ident)); - err.span_label(*former, format!("other definition for `{}`", ident)); + err.span_label(span, format!("duplicate definitions for `{ident}`")); + err.span_label(*former, format!("other definition for `{ident}`")); err.emit(); } @@ -114,11 +114,11 @@ impl<'tcx> InherentOverlapChecker<'tcx> { ); err.span_label( self.tcx.def_span(item1.def_id), - format!("duplicate definitions for `{}`", name), + format!("duplicate definitions for `{name}`"), ); err.span_label( self.tcx.def_span(item2.def_id), - format!("other definition for `{}`", name), + format!("other definition for `{name}`"), ); for cause in &overlap.intercrate_ambiguity_causes { diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 8d9a6f4d4461..bbdb108c59b6 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -412,9 +412,8 @@ fn emit_orphan_check_error<'tcx>( .span_label( sp, format!( - "type parameter `{}` must be covered by another type \ - when it appears before the first local type (`{}`)", - param_ty, local_type + "type parameter `{param_ty}` must be covered by another type \ + when it appears before the first local type (`{local_type}`)" ), ) .note( @@ -441,9 +440,8 @@ fn emit_orphan_check_error<'tcx>( .span_label( sp, format!( - "type parameter `{}` must be used as the type parameter for some \ + "type parameter `{param_ty}` must be used as the type parameter for some \ local type", - param_ty, ), ) .note( @@ -541,17 +539,16 @@ fn lint_auto_trait_impl<'tcx>( let self_descr = tcx.def_descr(self_type_did); match arg { ty::util::NotUniqueParam::DuplicateParam(arg) => { - lint.note(format!("`{}` is mentioned multiple times", arg)); + lint.note(format!("`{arg}` is mentioned multiple times")); } ty::util::NotUniqueParam::NotParam(arg) => { - lint.note(format!("`{}` is not a generic parameter", arg)); + lint.note(format!("`{arg}` is not a generic parameter")); } } lint.span_note( item_span, format!( - "try using the same sequence of generic parameters as the {} definition", - self_descr, + "try using the same sequence of generic parameters as the {self_descr} definition", ), ) }, diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index c160cf2df6e5..f568b7519519 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -195,9 +195,9 @@ pub(crate) fn placeholder_type_error_diag<'tcx>( sugg.push((arg.span, (*type_name).to_string())); } else if let Some(span) = generics.span_for_param_suggestion() { // Account for bounds, we want `fn foo(_: K)` not `fn foo(_: K)`. - sugg.push((span, format!(", {}", type_name))); + sugg.push((span, format!(", {type_name}"))); } else { - sugg.push((generics.span, format!("<{}>", type_name))); + sugg.push((generics.span, format!("<{type_name}>"))); } } @@ -329,7 +329,7 @@ fn bad_placeholder<'tcx>( mut spans: Vec, kind: &'static str, ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { - let kind = if kind.ends_with('s') { format!("{}es", kind) } else { format!("{}s", kind) }; + let kind = if kind.ends_with('s') { format!("{kind}es") } else { format!("{kind}s") }; spans.sort(); tcx.sess.create_err(errors::PlaceholderNotAllowedItemSignatures { spans, kind }) @@ -425,10 +425,8 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> { | hir::ItemKind::Union(_, generics) => { let lt_name = get_new_lifetime_name(self.tcx, poly_trait_ref, generics); let (lt_sp, sugg) = match generics.params { - [] => (generics.span, format!("<{}>", lt_name)), - [bound, ..] => { - (bound.span.shrink_to_lo(), format!("{}, ", lt_name)) - } + [] => (generics.span, format!("<{lt_name}>")), + [bound, ..] => (bound.span.shrink_to_lo(), format!("{lt_name}, ")), }; mpart_sugg = Some(errors::AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion { fspan: lt_sp, @@ -1027,7 +1025,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef { } else { tcx.sess.span_err( meta.span(), - format!("unknown meta item passed to `rustc_deny_explicit_impl` {:?}", meta), + format!("unknown meta item passed to `rustc_deny_explicit_impl` {meta:?}"), ); } } @@ -1505,7 +1503,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( .sess .source_map() .span_to_snippet(ast_ty.span) - .map_or_else(|_| String::new(), |s| format!(" `{}`", s)); + .map_or_else(|_| String::new(), |s| format!(" `{s}`")); tcx.sess.emit_err(errors::SIMDFFIHighlyExperimental { span: ast_ty.span, snip }); } }; diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 5e261f803872..eb93817e823a 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -2040,8 +2040,7 @@ fn is_late_bound_map( tcx.sess.delay_span_bug( *span, format!( - "Incorrect generic arg count for alias {:?}", - alias_def + "Incorrect generic arg count for alias {alias_def:?}" ), ); None diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index c39edaa15778..a9ef791077ee 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -156,7 +156,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { let Some(type_dependent_def) = tables.type_dependent_def_id(parent_node_id) else { return Ty::new_error_with_message(tcx, tcx.def_span(def_id), - format!("unable to find type-dependent def for {:?}", parent_node_id), + format!("unable to find type-dependent def for {parent_node_id:?}"), ); }; let idx = segment @@ -197,14 +197,14 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { } else { return Ty::new_error_with_message(tcx, tcx.def_span(def_id), - format!("unable to find const parent for {} in pat {:?}", hir_id, pat), + format!("unable to find const parent for {hir_id} in pat {pat:?}"), ); } } _ => { return Ty::new_error_with_message(tcx, tcx.def_span(def_id), - format!("unexpected const parent path {:?}", parent_node), + format!("unexpected const parent path {parent_node:?}"), ); } }; @@ -544,7 +544,7 @@ fn infer_placeholder_type<'a>( if let Some(ty) = ty.make_suggestable(tcx, false) { err.span_suggestion( span, - format!("provide a type for the {item}", item = kind), + format!("provide a type for the {kind}"), format!("{colon} {ty}"), Applicability::MachineApplicable, ); diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index c2d2e5f7e50f..0babdf7e5b3e 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -216,7 +216,7 @@ impl<'a> IntoDiagnostic<'a> for MissingTypeParams { "parameters", self.missing_type_params .iter() - .map(|n| format!("`{}`", n)) + .map(|n| format!("`{n}`")) .collect::>() .join(", "), ); diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index 62f22bda9f90..4f705eaf10aa 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -77,8 +77,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) tcx.sess.delay_span_bug( tcx.def_span(impl_def_id), format!( - "potentially unconstrained type parameters weren't evaluated: {:?}", - impl_self_ty, + "potentially unconstrained type parameters weren't evaluated: {impl_self_ty:?}", ), ); return; @@ -180,7 +179,7 @@ fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol kind, name ); - err.span_label(span, format!("unconstrained {} parameter", kind)); + err.span_label(span, format!("unconstrained {kind} parameter")); if kind == "const" { err.note( "expressions using a const parameter must map each value to a distinct output value", diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index 81993789bcf6..8b2c93d8fd31 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -294,7 +294,7 @@ fn check_duplicate_params<'tcx>( if let (_, [duplicate, ..]) = base_params.partition_dedup() { let param = impl1_args[duplicate.0 as usize]; tcx.sess - .struct_span_err(span, format!("specializing impl repeats parameter `{}`", param)) + .struct_span_err(span, format!("specializing impl repeats parameter `{param}`")) .emit(); } } @@ -523,7 +523,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc } _ => { tcx.sess - .struct_span_err(span, format!("cannot specialize on predicate `{}`", predicate)) + .struct_span_err(span, format!("cannot specialize on predicate `{predicate}`")) .emit(); } } diff --git a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs index 0828fe9e0f23..6be8d72aed20 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs @@ -474,7 +474,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { verb ) } else { - format!("missing generics for {} `{}`", def_kind, def_path) + format!("missing generics for {def_kind} `{def_path}`") } } @@ -599,7 +599,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let span = self.path_segment.ident.span; // insert a suggestion of the form "Y<'a, 'b>" - let sugg = format!("<{}>", suggested_args); + let sugg = format!("<{suggested_args}>"); debug!("sugg: {:?}", sugg); err.span_suggestion_verbose( @@ -624,7 +624,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let sugg_suffix = if is_first && (has_non_lt_args || has_bindings) { ", " } else { "" }; - let sugg = format!("{}{}{}", sugg_prefix, suggested_args, sugg_suffix); + let sugg = format!("{sugg_prefix}{suggested_args}{sugg_suffix}"); debug!("sugg: {:?}", sugg); err.span_suggestion_verbose(sugg_span, msg, sugg, Applicability::HasPlaceholders); @@ -649,7 +649,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let span = self.path_segment.ident.span; // insert a suggestion of the form "Y" - let sugg = format!("<{}>", suggested_args); + let sugg = format!("<{suggested_args}>"); debug!("sugg: {:?}", sugg); err.span_suggestion_verbose( @@ -682,7 +682,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let sugg_suffix = if is_first && !self.gen_args.bindings.is_empty() { ", " } else { "" }; - let sugg = format!("{}{}{}", sugg_prefix, suggested_args, sugg_suffix); + let sugg = format!("{sugg_prefix}{suggested_args}{sugg_suffix}"); debug!("sugg: {:?}", sugg); err.span_suggestion_verbose(sugg_span, msg, sugg, Applicability::HasPlaceholders); @@ -1024,7 +1024,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { .collect::>() .join(", "); - format!(": {}", params) + format!(": {params}") }; format!( diff --git a/compiler/rustc_hir_analysis/src/variance/terms.rs b/compiler/rustc_hir_analysis/src/variance/terms.rs index 3b286bb9c93c..ed03c5da26f0 100644 --- a/compiler/rustc_hir_analysis/src/variance/terms.rs +++ b/compiler/rustc_hir_analysis/src/variance/terms.rs @@ -32,8 +32,8 @@ pub enum VarianceTerm<'a> { impl<'a> fmt::Debug for VarianceTerm<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - ConstantTerm(c1) => write!(f, "{:?}", c1), - TransformTerm(v1, v2) => write!(f, "({:?} \u{00D7} {:?})", v1, v2), + ConstantTerm(c1) => write!(f, "{c1:?}"), + TransformTerm(v1, v2) => write!(f, "({v1:?} \u{00D7} {v2:?})"), InferredTerm(id) => write!(f, "[{}]", { let InferredIndex(i) = id; i diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index a24d1ff077f3..f1affaca3dfe 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -402,7 +402,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .sess .struct_span_err( callee_expr.span, - format!("evaluate({:?}) = {:?}", predicate, result), + format!("evaluate({predicate:?}) = {result:?}"), ) .span_label(predicate_span, "predicate") .emit(); diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index af8afcc0f0b9..5bc0e2ee86c8 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -144,7 +144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let reported = self .tcx .sess - .delay_span_bug(span, format!("`{:?}` should be sized but is not?", t)); + .delay_span_bug(span, format!("`{t:?}` should be sized but is not?")); return Err(reported); } }) @@ -644,12 +644,12 @@ impl<'a, 'tcx> CastCheck<'tcx> { err.span_suggestion( self.cast_span, "try casting to a reference instead", - format!("&{}{}", mtstr, s), + format!("&{mtstr}{s}"), Applicability::MachineApplicable, ); } Err(_) => { - let msg = format!("did you mean `&{}{}`?", mtstr, tstr); + let msg = format!("did you mean `&{mtstr}{tstr}`?"); err.span_help(self.cast_span, msg); } } diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 56e485a4a3c1..4fdfc51bc86c 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1797,8 +1797,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { err.span_note( sp, format!( - "return type inferred to be `{}` here", - expected + "return type inferred to be `{expected}` here" ), ); } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 29488c9011a1..4ae8020fc42f 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -1890,7 +1890,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut truncated_fields_error = String::new(); let remaining_fields_names = match &displayable_field_names[..] { - [field1] => format!("`{}`", field1), + [field1] => format!("`{field1}`"), [field1, field2] => format!("`{field1}` and `{field2}`"), [field1, field2, field3] => format!("`{field1}`, `{field2}` and `{field3}`"), _ => { @@ -2117,16 +2117,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } _ => { - err.span_label(variant_ident_span, format!("`{adt}` defined here", adt = ty)); + err.span_label(variant_ident_span, format!("`{ty}` defined here")); err.span_label(field.ident.span, "field does not exist"); err.span_suggestion_verbose( expr_span, - format!( - "`{adt}` is a tuple {kind_name}, use the appropriate syntax", - adt = ty, - kind_name = kind_name, - ), - format!("{adt}(/* fields */)", adt = ty), + format!("`{ty}` is a tuple {kind_name}, use the appropriate syntax",), + format!("{ty}(/* fields */)"), Applicability::HasPlaceholders, ); } @@ -2243,7 +2239,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // dynamic limit, to never omit just one field let limit = if names.len() == 6 { 6 } else { 5 }; let mut display = - names.iter().take(limit).map(|n| format!("`{}`", n)).collect::>().join(", "); + names.iter().take(limit).map(|n| format!("`{n}`")).collect::>().join(", "); if names.len() > limit { display = format!("{} ... and {} others", display, names.len() - limit); } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index fa1056e724a1..ecafb50f4209 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -61,7 +61,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind); - let msg = format!("unreachable {}", kind); + let msg = format!("unreachable {kind}"); self.tcx().struct_span_lint_hir( lint::builtin::UNREACHABLE_CODE, id, @@ -134,7 +134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub fn tag(&self) -> String { - format!("{:p}", self) + format!("{self:p}") } pub fn local_ty(&self, span: Span, nid: hir::HirId) -> Ty<'tcx> { @@ -1412,9 +1412,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx.sess.delay_span_bug( span, format!( - "instantiate_value_path: (UFCS) {:?} was a subtype of {:?} but now is not?", - self_ty, - impl_ty, + "instantiate_value_path: (UFCS) {self_ty:?} was a subtype of {impl_ty:?} but now is not?", ), ); } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index a9610009db1e..0311251f5c3a 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -689,7 +689,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); err.span_label( full_call_span, - format!("arguments to this {} are incorrect", call_name), + format!("arguments to this {call_name} are incorrect"), ); } else { err = tcx.sess.struct_span_err_with_code( @@ -796,10 +796,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None, None, ); - err.span_label( - full_call_span, - format!("arguments to this {} are incorrect", call_name), - ); + err.span_label(full_call_span, format!("arguments to this {call_name} are incorrect")); if let hir::ExprKind::MethodCall(_, rcvr, _, _) = call_expr.kind && provided_idx.as_usize() == expected_idx.as_usize() @@ -874,7 +871,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if ty.is_unit() { "()".to_string() } else if ty.is_suggestable(tcx, false) { - format!("/* {} */", ty) + format!("/* {ty} */") } else if let Some(fn_def_id) = fn_def_id && self.tcx.def_kind(fn_def_id).is_fn_like() && let self_implicit = @@ -931,12 +928,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (provided_ty, provided_span) = provided_arg_tys[arg_idx]; let provided_ty_name = if !has_error_or_infer([provided_ty]) { // FIXME: not suggestable, use something else - format!(" of type `{}`", provided_ty) + format!(" of type `{provided_ty}`") } else { "".to_string() }; - labels - .push((provided_span, format!("unexpected argument{}", provided_ty_name))); + labels.push((provided_span, format!("unexpected argument{provided_ty_name}"))); let mut span = provided_span; if span.can_be_used_for_suggestions() { if arg_idx.index() > 0 @@ -1009,11 +1005,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { args_span }; let rendered = if !has_error_or_infer([input_ty]) { - format!(" of type `{}`", input_ty) + format!(" of type `{input_ty}`") } else { "".to_string() }; - labels.push((span, format!("an argument{} is missing", rendered))); + labels.push((span, format!("an argument{rendered} is missing"))); suggestion_text = match suggestion_text { SuggestionText::None => SuggestionText::Provide(false), SuggestionText::Provide(_) => SuggestionText::Provide(true), @@ -1034,13 +1030,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let rendered = if !has_error_or_infer([first_expected_ty, second_expected_ty]) { format!( - " of type `{}` and `{}`", - first_expected_ty, second_expected_ty + " of type `{first_expected_ty}` and `{second_expected_ty}`" ) } else { "".to_string() }; - labels.push((span, format!("two arguments{} are missing", rendered))); + labels.push((span, format!("two arguments{rendered} are missing"))); suggestion_text = match suggestion_text { SuggestionText::None | SuggestionText::Provide(_) => { SuggestionText::Provide(true) @@ -1066,13 +1061,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { third_expected_ty, ]) { format!( - " of type `{}`, `{}`, and `{}`", - first_expected_ty, second_expected_ty, third_expected_ty + " of type `{first_expected_ty}`, `{second_expected_ty}`, and `{third_expected_ty}`" ) } else { "".to_string() }; - labels.push((span, format!("three arguments{} are missing", rendered))); + labels.push((span, format!("three arguments{rendered} are missing"))); suggestion_text = match suggestion_text { SuggestionText::None | SuggestionText::Provide(_) => { SuggestionText::Provide(true) @@ -1113,25 +1107,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (first_provided_ty, first_span) = provided_arg_tys[first_provided_idx]; let (_, first_expected_ty) = formal_and_expected_inputs[first_expected_idx]; let first_provided_ty_name = if !has_error_or_infer([first_provided_ty]) { - format!(", found `{}`", first_provided_ty) + format!(", found `{first_provided_ty}`") } else { String::new() }; labels.push(( first_span, - format!("expected `{}`{}", first_expected_ty, first_provided_ty_name), + format!("expected `{first_expected_ty}`{first_provided_ty_name}"), )); let (second_provided_ty, second_span) = provided_arg_tys[second_provided_idx]; let (_, second_expected_ty) = formal_and_expected_inputs[second_expected_idx]; let second_provided_ty_name = if !has_error_or_infer([second_provided_ty]) { - format!(", found `{}`", second_provided_ty) + format!(", found `{second_provided_ty}`") } else { String::new() }; labels.push(( second_span, - format!("expected `{}`{}", second_expected_ty, second_provided_ty_name), + format!("expected `{second_expected_ty}`{second_provided_ty_name}"), )); suggestion_text = match suggestion_text { @@ -1144,13 +1138,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (_, expected_ty) = formal_and_expected_inputs[dst_arg]; let (provided_ty, provided_span) = provided_arg_tys[dest_input]; let provided_ty_name = if !has_error_or_infer([provided_ty]) { - format!(", found `{}`", provided_ty) + format!(", found `{provided_ty}`") } else { String::new() }; labels.push(( provided_span, - format!("expected `{}`{}", expected_ty, provided_ty_name), + format!("expected `{expected_ty}`{provided_ty_name}"), )); } @@ -2031,7 +2025,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { ("closure", self.tcx.def_span(def_id)) }; - err.span_note(span, format!("{} defined here", kind)); + err.span_note(span, format!("{kind} defined here")); } else { err.span_note( self.tcx.def_span(def_id), diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index ec19d017c259..8bbb714541e4 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -397,7 +397,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let struct_pat_shorthand_field = self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr); if let Some(name) = struct_pat_shorthand_field { - sugg.insert(0, (expr.span.shrink_to_lo(), format!("{}: ", name))); + sugg.insert(0, (expr.span.shrink_to_lo(), format!("{name}: "))); } Some(sugg) }) @@ -558,7 +558,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .take(4) .map(|(var_hir_id, upvar)| { let var_name = self.tcx.hir().name(*var_hir_id).to_string(); - let msg = format!("`{}` captured here", var_name); + let msg = format!("`{var_name}` captured here"); (upvar.span, msg) }) .collect::>(); @@ -931,7 +931,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_suggestion( fn_return.span(), "consider using an impl return type", - format!("impl {}", all_bounds_str), + format!("impl {all_bounds_str}"), Applicability::MaybeIncorrect, ); } @@ -1070,7 +1070,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .must_apply_modulo_regions() { let suggestion = match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { - Some(ident) => format!(": {}.clone()", ident), + Some(ident) => format!(": {ident}.clone()"), None => ".clone()".to_string() }; @@ -1248,7 +1248,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let suggestion = match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { - Some(ident) => format!(": {}.is_some()", ident), + Some(ident) => format!(": {ident}.is_some()"), None => ".is_some()".to_string(), }; diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs index e01dcf83a380..e563bd40b654 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/mod.rs @@ -125,8 +125,8 @@ impl Debug for TrackedValue { write!(f, "{}", tcx.hir().node_to_string(self.hir_id())) } else { match self { - Self::Variable(hir_id) => write!(f, "Variable({:?})", hir_id), - Self::Temporary(hir_id) => write!(f, "Temporary({:?})", hir_id), + Self::Variable(hir_id) => write!(f, "Variable({hir_id:?})"), + Self::Temporary(hir_id) => write!(f, "Temporary({hir_id:?})"), } } }) diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs index 86ea092bc407..6a8171224913 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs @@ -112,7 +112,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { self.fcx .tcx .sess - .delay_span_bug(span, format!("Encountered var {:?}", unresolved_term)); + .delay_span_bug(span, format!("Encountered var {unresolved_term:?}")); } else { let note = format!( "the type is part of the {} because of this {}", diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index 2d85451c9e18..2cd18c4c3fcb 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -85,7 +85,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Ok(SizeSkeleton::Pointer { tail, .. }) => format!("pointer to `{tail}`"), Ok(SizeSkeleton::Known(size)) => { if let Some(v) = u128::from(size.bytes()).checked_mul(8) { - format!("{} bits", v) + format!("{v} bits") } else { // `u128` should definitely be able to hold the size of different architectures // larger sizes should be reported as error `are too big for the current architecture` diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 6835782b5bd8..7c73f6a89cdb 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -225,7 +225,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { assert!(mutbl.is_mut()); Ty::new_ptr(self.tcx, ty::TypeAndMut { mutbl: hir::Mutability::Not, ty }) } - other => panic!("Cannot adjust receiver type {:?} to const ptr", other), + other => panic!("Cannot adjust receiver type {other:?} to const ptr"), }; adjustments.push(Adjustment { @@ -262,8 +262,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let impl_def_id = pick.item.container_id(self.tcx); assert!( self.tcx.impl_trait_ref(impl_def_id).is_none(), - "impl {:?} is not an inherent impl", - impl_def_id + "impl {impl_def_id:?} is not an inherent impl" ); self.fresh_args_for_item(self.span, impl_def_id) } diff --git a/compiler/rustc_hir_typeck/src/method/prelude2021.rs b/compiler/rustc_hir_typeck/src/method/prelude2021.rs index 4efe95c4dc56..5b19a4c525f8 100644 --- a/compiler/rustc_hir_typeck/src/method/prelude2021.rs +++ b/compiler/rustc_hir_typeck/src/method/prelude2021.rs @@ -97,28 +97,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let self_adjusted = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) = pick.autoref_or_ptr_adjustment { - format!("{}{} as *const _", derefs, self_expr) + format!("{derefs}{self_expr} as *const _") } else { - format!("{}{}{}", autoref, derefs, self_expr) + format!("{autoref}{derefs}{self_expr}") }; lint.span_suggestion( sp, "disambiguate the method call", - format!("({})", self_adjusted), + format!("({self_adjusted})"), Applicability::MachineApplicable, ); } else { let self_adjusted = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) = pick.autoref_or_ptr_adjustment { - format!("{}(...) as *const _", derefs) + format!("{derefs}(...) as *const _") } else { - format!("{}{}...", autoref, derefs) + format!("{autoref}{derefs}...") }; lint.span_help( sp, - format!("disambiguate the method call with `({})`", self_adjusted,), + format!("disambiguate the method call with `({self_adjusted})`",), ); } @@ -168,7 +168,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .ok()) { // Keep turbofish. - format!("::{}", args) + format!("::{args}") } else { String::new() }, @@ -347,7 +347,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Glob import, so just use its name. return None; } else { - return Some(format!("{}", any_id)); + return Some(format!("{any_id}")); } } @@ -396,9 +396,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let adjusted_text = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) = pick.autoref_or_ptr_adjustment { - format!("{}{} as *const _", derefs, expr_text) + format!("{derefs}{expr_text} as *const _") } else { - format!("{}{}{}", autoref, derefs, expr_text) + format!("{autoref}{derefs}{expr_text}") }; (adjusted_text, precise) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 3d7187cb16f3..f6c07931023e 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -153,7 +153,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { E0034, "multiple applicable items in scope" ); - err.span_label(item_name.span, format!("multiple `{}` found", item_name)); + err.span_label(item_name.span, format!("multiple `{item_name}` found")); self.note_candidates_on_method_error( rcvr_ty, @@ -177,13 +177,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { kind, item_name ); - err.span_label(item_name.span, format!("private {}", kind)); + err.span_label(item_name.span, format!("private {kind}")); let sp = self .tcx .hir() .span_if_local(def_id) .unwrap_or_else(|| self.tcx.def_span(def_id)); - err.span_label(sp, format!("private {} defined here", kind)); + err.span_label(sp, format!("private {kind} defined here")); self.suggest_valid_traits(&mut err, out_of_scope_traits); err.emit(); } @@ -218,7 +218,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { *region, ty::TypeAndMut { ty: *t_type, mutbl: mutability.invert() }, ); - let msg = format!("you need `{}` instead of `{}`", trait_type, rcvr_ty); + let msg = format!("you need `{trait_type}` instead of `{rcvr_ty}`"); let mut kind = &self_expr.kind; while let hir::ExprKind::AddrOf(_, _, expr) | hir::ExprKind::Unary(hir::UnOp::Deref, expr) = kind @@ -637,7 +637,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // Point at the closure that couldn't satisfy the bound. ty::Closure(def_id, _) => bound_spans - .push((tcx.def_span(*def_id), format!("doesn't satisfy `{}`", quiet))), + .push((tcx.def_span(*def_id), format!("doesn't satisfy `{quiet}`"))), _ => {} } }; @@ -659,7 +659,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let term = pred.skip_binder().term; - let obligation = format!("{} = {}", projection_ty, term); + let obligation = format!("{projection_ty} = {term}"); let quiet = with_forced_trimmed_paths!(format!( "{} = {}", quiet_projection_ty, term @@ -672,7 +672,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let p = poly_trait_ref.trait_ref; let self_ty = p.self_ty(); let path = p.print_only_trait_path(); - let obligation = format!("{}: {}", self_ty, path); + let obligation = format!("{self_ty}: {path}"); let quiet = with_forced_trimmed_paths!(format!("_: {}", path)); bound_span_label(self_ty, &obligation, &quiet); Some((obligation, self_ty)) @@ -825,12 +825,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut preds: Vec<_> = predicates .iter() .filter_map(|pred| format_pred(**pred)) - .map(|(p, _)| format!("`{}`", p)) + .map(|(p, _)| format!("`{p}`")) .collect(); preds.sort(); preds.dedup(); let msg = if let [pred] = &preds[..] { - format!("trait bound {} was not satisfied", pred) + format!("trait bound {pred} was not satisfied") } else { format!("the following trait bounds were not satisfied:\n{}", preds.join("\n"),) }; @@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { suggested_bounds.insert(pred); } } - format!("`{}`\nwhich is required by `{}`", p, parent_p) + format!("`{p}`\nwhich is required by `{parent_p}`") } }, }, @@ -1034,8 +1034,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "".to_string() }; err.note(format!( - "the {item_kind} was found for\n{}{}", - type_candidates, additional_types + "the {item_kind} was found for\n{type_candidates}{additional_types}" )); } else { 'outer: for inherent_impl_did in self.tcx.inherent_impls(adt.did()) { @@ -1249,8 +1248,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { ( format!( - "the candidate is defined in an impl{} for the type `{}`", - insertion, impl_ty, + "the candidate is defined in an impl{insertion} for the type `{impl_ty}`", ), None, ) @@ -1452,11 +1450,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_suggestion( sugg_span, "use associated function syntax instead", - format!("{}::{}{}", ty_str, item_name, args), + format!("{ty_str}::{item_name}{args}"), applicability, ); } else { - err.help(format!("try with `{}::{}`", ty_str, item_name,)); + err.help(format!("try with `{ty_str}::{item_name}`",)); } } @@ -1491,9 +1489,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let expr_span = expr.span.to(item_name.span); err.multipart_suggestion( format!( - "to call the function stored in `{}`, \ + "to call the function stored in `{item_name}`, \ surround the field access with parentheses", - item_name, ), vec![ (expr_span.shrink_to_lo(), '('.to_string()), @@ -1516,7 +1513,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let field_kind = if is_accessible { "field" } else { "private field" }; - err.span_label(item_name.span, format!("{}, not a method", field_kind)); + err.span_label(item_name.span, format!("{field_kind}, not a method")); return true; } false @@ -1669,8 +1666,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { lit.span, format!( "you must specify a concrete type for this numeric value, \ - like `{}`", - concrete_type + like `{concrete_type}`" ), format!("{snippet}_{concrete_type}"), Applicability::MaybeIncorrect, @@ -1685,8 +1681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let parent_node = self.tcx.hir().get_parent(hir_id); let msg = format!( - "you must specify a type for this binding, like `{}`", - concrete_type, + "you must specify a type for this binding, like `{concrete_type}`", ); match (filename, parent_node) { @@ -2194,7 +2189,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some((last_self_name, _, ref mut last_trait_names)) = derives_grouped.last_mut() { if last_self_name == &self_name { - last_trait_names.push_str(format!(", {}", trait_name).as_str()); + last_trait_names.push_str(format!(", {trait_name}").as_str()); continue; } } @@ -2226,8 +2221,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for (self_name, self_span, traits) in &derives_grouped { err.span_suggestion_verbose( self_span.shrink_to_lo(), - format!("consider annotating `{}` with `#[derive({})]`", self_name, traits), - format!("#[derive({})]\n", traits), + format!("consider annotating `{self_name}` with `#[derive({traits})]`"), + format!("#[derive({traits})]\n"), Applicability::MaybeIncorrect, ); } @@ -2475,7 +2470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if pick.autoderefs == 0 && !skip { err.span_label( pick.item.ident(self.tcx).span, - format!("the method is available for `{}` here", rcvr_ty), + format!("the method is available for `{rcvr_ty}` here"), ); } break; @@ -2521,13 +2516,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if pick.autoderefs == 0 && !skip { err.span_label( pick.item.ident(self.tcx).span, - format!("the method is available for `{}` here", new_rcvr_t), + format!("the method is available for `{new_rcvr_t}` here"), ); err.multipart_suggestion( "consider wrapping the receiver expression with the \ appropriate type", vec![ - (rcvr.span.shrink_to_lo(), format!("{}({}", pre, post)), + (rcvr.span.shrink_to_lo(), format!("{pre}({post}")), (rcvr.span.shrink_to_hi(), ")".to_string()), ], Applicability::MaybeIncorrect, @@ -2767,7 +2762,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; err.span_suggestions( sp, - message(format!("add {} supertrait for", article)), + message(format!("add {article} supertrait for")), candidates.iter().map(|t| { format!("{} {}", sep, self.tcx.def_path_str(t.def_id),) }), @@ -2836,7 +2831,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { trait_infos => { let mut msg = message(param_type.map_or_else( || "implement".to_string(), // FIXME: it might only need to be imported into scope, not implemented. - |param| format!("restrict type parameter `{}` with", param), + |param| format!("restrict type parameter `{param}` with"), )); for (i, trait_info) in trait_infos.iter().enumerate() { msg.push_str(&format!( @@ -2860,8 +2855,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } trait_infos => { let mut msg = format!( - "the following traits define an item `{}`, but are explicitly unimplemented:", - item_name + "the following traits define an item `{item_name}`, but are explicitly unimplemented:" ); for trait_info in trait_infos { msg.push_str(&format!("\n{}", self.tcx.def_path_str(trait_info.def_id))); @@ -3027,13 +3021,13 @@ fn print_disambiguation_help<'tcx>( .join(", "), ); let trait_name = if !fn_has_self_parameter { - format!("<{} as {}>", rcvr_ty, trait_name) + format!("<{rcvr_ty} as {trait_name}>") } else { trait_name }; - (span, format!("{}::{}{}", trait_name, item_name, args)) + (span, format!("{trait_name}::{item_name}{args}")) } else { - (span.with_hi(item_name.span.lo()), format!("<{} as {}>::", rcvr_ty, trait_name)) + (span.with_hi(item_name.span.lo()), format!("<{rcvr_ty} as {trait_name}>::")) }; err.span_suggestion_verbose( span, @@ -3041,7 +3035,7 @@ fn print_disambiguation_help<'tcx>( "disambiguate the {} for {}", def_kind_descr, if let Some(candidate) = candidate { - format!("candidate #{}", candidate) + format!("candidate #{candidate}") } else { "the candidate".to_string() }, diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 8bf95d4bf9a6..6ffa3b0a0b34 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -516,7 +516,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn endpoint_has_type(&self, err: &mut Diagnostic, span: Span, ty: Ty<'_>) { if !ty.references_error() { - err.span_label(span, format!("this is of type `{}`", ty)); + err.span_label(span, format!("this is of type `{ty}`")); } } @@ -540,7 +540,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let msg = |ty| { let ty = self.resolve_vars_if_possible(ty); - format!("this is of type `{}` but it should be `char` or numeric", ty) + format!("this is of type `{ty}` but it should be `char` or numeric") }; let mut one_side_err = |first_span, first_ty, second: Option<(bool, Ty<'tcx>, Span)>| { err.span_label(first_span, msg(first_ty)); @@ -653,7 +653,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) }); let pre = if in_match { "in the same arm, " } else { "" }; - err.note(format!("{}a binding must have the same type in all alternatives", pre)); + err.note(format!("{pre}a binding must have the same type in all alternatives")); self.suggest_adding_missing_ref_or_removing_ref( &mut err, span, @@ -1710,7 +1710,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_suggestion_verbose( qpath.span().shrink_to_hi().to(pat.span.shrink_to_hi()), "use the tuple variant pattern syntax instead", - format!("({})", sugg), + format!("({sugg})"), appl, ); return Some(err); @@ -1812,7 +1812,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { const LIMIT: usize = 3; match witnesses { [] => bug!(), - [witness] => format!("`{}`", witness), + [witness] => format!("`{witness}`"), [head @ .., tail] if head.len() < LIMIT => { let head: Vec<_> = head.iter().map(<_>::to_string).collect(); format!("`{}` and `{}`", head.join("`, `"), tail) @@ -1834,8 +1834,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "ensure that all fields are mentioned explicitly by adding the suggested fields", ); lint.note(format!( - "the pattern is of type `{}` and the `non_exhaustive_omitted_patterns` attribute was found", - ty, + "the pattern is of type `{ty}` and the `non_exhaustive_omitted_patterns` attribute was found", )); lint @@ -1864,10 +1863,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { let fields = unmentioned_fields .iter() - .map(|(_, name)| format!("`{}`", name)) + .map(|(_, name)| format!("`{name}`")) .collect::>() .join(", "); - format!("fields {}{}", fields, inaccessible) + format!("fields {fields}{inaccessible}") }; let mut err = struct_span_err!( self.tcx.sess, @@ -1876,7 +1875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "pattern does not mention {}", field_names ); - err.span_label(pat.span, format!("missing {}", field_names)); + err.span_label(pat.span, format!("missing {field_names}")); let len = unmentioned_fields.len(); let (prefix, postfix, sp) = match fields { [] => match &pat.kind { @@ -1909,11 +1908,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .iter() .map(|(_, name)| { let field_name = name.to_string(); - if is_number(&field_name) { - format!("{}: _", field_name) - } else { - field_name - } + if is_number(&field_name) { format!("{field_name}: _") } else { field_name } }) .collect::>() .join(", "), @@ -1930,7 +1925,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { s = pluralize!(len), them = if len == 1 { "it" } else { "them" }, ), - format!("{}..{}", prefix, postfix), + format!("{prefix}..{postfix}"), Applicability::MachineApplicable, ); err diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 22fe823acb76..be939560c459 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -109,11 +109,11 @@ impl MigrationWarningReason { fn migration_message(&self) -> String { let base = "changes to closure capture in Rust 2021 will affect"; if !self.auto_traits.is_empty() && self.drop_order { - format!("{} drop order and which traits the closure implements", base) + format!("{base} drop order and which traits the closure implements") } else if self.drop_order { - format!("{} drop order", base) + format!("{base} drop order") } else { - format!("{} which traits the closure implements", base) + format!("{base} which traits the closure implements") } } } @@ -824,8 +824,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { lint.note("for more information, see "); let diagnostic_msg = format!( - "add a dummy let to cause {} to be fully captured", - migrated_variables_concat + "add a dummy let to cause {migrated_variables_concat} to be fully captured" ); let closure_span = self.tcx.hir().span_with_body(closure_hir_id); @@ -1943,7 +1942,7 @@ fn construct_place_string<'tcx>(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String let mut projections_str = String::new(); for (i, item) in place.projections.iter().enumerate() { let proj = match item.kind { - ProjectionKind::Field(a, b) => format!("({:?}, {:?})", a, b), + ProjectionKind::Field(a, b) => format!("({a:?}, {b:?})"), ProjectionKind::Deref => String::from("Deref"), ProjectionKind::Index => String::from("Index"), ProjectionKind::Subslice => String::from("Subslice"), @@ -1966,7 +1965,7 @@ fn construct_capture_kind_reason_string<'tcx>( let capture_kind_str = match capture_info.capture_kind { ty::UpvarCapture::ByValue => "ByValue".into(), - ty::UpvarCapture::ByRef(kind) => format!("{:?}", kind), + ty::UpvarCapture::ByRef(kind) => format!("{kind:?}"), }; format!("{place_str} captured as {capture_kind_str} here") @@ -1987,7 +1986,7 @@ fn construct_capture_info_string<'tcx>( let capture_kind_str = match capture_info.capture_kind { ty::UpvarCapture::ByValue => "ByValue".into(), - ty::UpvarCapture::ByRef(kind) => format!("{:?}", kind), + ty::UpvarCapture::ByRef(kind) => format!("{kind:?}"), }; format!("{place_str} -> {capture_kind_str}") } diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 2329a1f63cec..6f47623ec43d 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -217,7 +217,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // When encountering `return [0][0]` outside of a `fn` body we can encounter a base // that isn't in the type table. We assume more relevant errors have already been // emitted, so we delay an ICE if none have. (#64638) - self.tcx().sess.delay_span_bug(e.span, format!("bad base: `{:?}`", base)); + self.tcx().sess.delay_span_bug(e.span, format!("bad base: `{base:?}`")); } if let Some(base_ty) = base_ty && let ty::Ref(_, base_ty_inner, _) = *base_ty.kind() @@ -231,7 +231,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { Ty::new_error_with_message( self.fcx.tcx, e.span, - format!("bad index {:?} for base: `{:?}`", index, base), + format!("bad index {index:?} for base: `{base:?}`"), ) }); if self.is_builtin_index(e, base_ty_inner, index_ty) { @@ -488,10 +488,8 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { let span = self.tcx().hir().span(hir_id); // We need to buffer the errors in order to guarantee a consistent // order when emitting them. - let err = self - .tcx() - .sess - .struct_span_err(span, format!("user args: {:?}", user_args)); + let err = + self.tcx().sess.struct_span_err(span, format!("user args: {user_args:?}")); err.buffer(&mut errors_buffer); } } diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 84aca80b0dec..cf6e7f16f071 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1716,7 +1716,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { let end = expr_to_string(&end); let replace = match start { Some(start) => format!("&({}..={})", expr_to_string(&start), end), - None => format!("&(..={})", end), + None => format!("&(..={end})"), }; if join.edition() >= Edition::Edition2021 { cx.sess().emit_err(BuiltinEllipsisInclusiveRangePatterns { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 7c701fd4fe16..65c56bff8410 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -411,7 +411,7 @@ impl LintStore { } let complete_name = if let Some(tool_name) = tool_name { - format!("{}::{}", tool_name, lint_name) + format!("{tool_name}::{lint_name}") } else { lint_name.to_string() }; @@ -424,7 +424,7 @@ impl LintStore { // 1. The tool is currently running, so this lint really doesn't exist. // FIXME: should this handle tools that never register a lint, like rustfmt? debug!("lints={:?}", self.by_name.keys().collect::>()); - let tool_prefix = format!("{}::", tool_name); + let tool_prefix = format!("{tool_name}::"); return if self.by_name.keys().any(|lint| lint.starts_with(&tool_prefix)) { self.no_lint_suggestion(&complete_name) } else { @@ -445,11 +445,11 @@ impl LintStore { } match self.by_name.get(&complete_name) { Some(Renamed(new_name, _)) => CheckLintNameResult::Warning( - format!("lint `{}` has been renamed to `{}`", complete_name, new_name), + format!("lint `{complete_name}` has been renamed to `{new_name}`"), Some(new_name.to_owned()), ), Some(Removed(reason)) => CheckLintNameResult::Warning( - format!("lint `{}` has been removed: {}", complete_name, reason), + format!("lint `{complete_name}` has been removed: {reason}"), None, ), None => match self.lint_groups.get(&*complete_name) { @@ -503,7 +503,7 @@ impl LintStore { lint_name: &str, tool_name: &str, ) -> CheckLintNameResult<'_> { - let complete_name = format!("{}::{}", tool_name, lint_name); + let complete_name = format!("{tool_name}::{lint_name}"); match self.by_name.get(&complete_name) { None => match self.lint_groups.get(&*complete_name) { // Now we are sure, that this lint exists nowhere @@ -618,12 +618,10 @@ pub trait LintContext: Sized { _ => ("", "s"), }; db.span_label(span, format!( - "this comment contains {}invisible unicode text flow control codepoint{}", - an, - s, + "this comment contains {an}invisible unicode text flow control codepoint{s}", )); for (c, span) in &spans { - db.span_label(*span, format!("{:?}", c)); + db.span_label(*span, format!("{c:?}")); } db.note( "these kind of unicode codepoints change the way text flows on \ @@ -648,7 +646,7 @@ pub trait LintContext: Sized { let opt_colon = if s.trim_start().starts_with("::") { "" } else { "::" }; - (format!("crate{}{}", opt_colon, s), Applicability::MachineApplicable) + (format!("crate{opt_colon}{s}"), Applicability::MachineApplicable) } Err(_) => ("crate::".to_string(), Applicability::HasPlaceholders), }; @@ -704,7 +702,7 @@ pub trait LintContext: Sized { let introduced = if is_imported { "imported" } else { "defined" }; db.span_label( span, - format!("the item `{}` is already {} here", ident, introduced), + format!("the item `{ident}` is already {introduced} here"), ); } } @@ -908,7 +906,7 @@ pub trait LintContext: Sized { BuiltinLintDiagnostics::NamedArgumentUsedPositionally{ position_sp_to_replace, position_sp_for_msg, named_arg_sp, named_arg_name, is_formatting_arg} => { db.span_label(named_arg_sp, "this named argument is referred to by position in formatting string"); if let Some(positional_arg_for_msg) = position_sp_for_msg { - let msg = format!("this formatting argument uses named argument `{}` by position", named_arg_name); + let msg = format!("this formatting argument uses named argument `{named_arg_name}` by position"); db.span_label(positional_arg_for_msg, msg); } @@ -949,11 +947,11 @@ pub trait LintContext: Sized { ); } BuiltinLintDiagnostics::AmbiguousGlobReexports { name, namespace, first_reexport_span, duplicate_reexport_span } => { - db.span_label(first_reexport_span, format!("the name `{}` in the {} namespace is first re-exported here", name, namespace)); - db.span_label(duplicate_reexport_span, format!("but the name `{}` in the {} namespace is also re-exported here", name, namespace)); + db.span_label(first_reexport_span, format!("the name `{name}` in the {namespace} namespace is first re-exported here")); + db.span_label(duplicate_reexport_span, format!("but the name `{name}` in the {namespace} namespace is also re-exported here")); } BuiltinLintDiagnostics::HiddenGlobReexports { name, namespace, glob_reexport_span, private_item_span } => { - db.span_note(glob_reexport_span, format!("the name `{}` in the {} namespace is supposed to be publicly re-exported here", name, namespace)); + db.span_note(glob_reexport_span, format!("the name `{name}` in the {namespace} namespace is supposed to be publicly re-exported here")); db.span_note(private_item_span, "but the private item here shadows it".to_owned()); } BuiltinLintDiagnostics::UnusedQualifications { removal_span } => { @@ -1281,8 +1279,8 @@ impl<'tcx> LateContext<'tcx> { // This shouldn't ever be needed, but just in case: with_no_trimmed_paths!({ Ok(vec![match trait_ref { - Some(trait_ref) => Symbol::intern(&format!("{:?}", trait_ref)), - None => Symbol::intern(&format!("<{}>", self_ty)), + Some(trait_ref) => Symbol::intern(&format!("{trait_ref:?}")), + None => Symbol::intern(&format!("<{self_ty}>")), }]) }) } @@ -1306,7 +1304,7 @@ impl<'tcx> LateContext<'tcx> { ))) } None => { - with_no_trimmed_paths!(Symbol::intern(&format!("", self_ty))) + with_no_trimmed_paths!(Symbol::intern(&format!(""))) } }); diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 0c80141a756d..fb407be1f02a 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -945,7 +945,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { ); } } else { - panic!("renamed lint does not exist: {}", new_name); + panic!("renamed lint does not exist: {new_name}"); } } } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1dea758bb294..2f2a5a933471 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -776,7 +776,7 @@ impl AddToDiagnostic for HiddenUnicodeCodepointsDiagLabels { ) -> rustc_errors::SubdiagnosticMessage, { for (c, span) in self.spans { - diag.span_label(span, format!("{:?}", c)); + diag.span_label(span, format!("{c:?}")); } } } @@ -808,7 +808,7 @@ impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub { spans .into_iter() .map(|(c, span)| { - let c = format!("{:?}", c); + let c = format!("{c:?}"); (span, c[1..c.len() - 1].to_string()) }) .collect(), @@ -823,7 +823,7 @@ impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub { "escaped", spans .into_iter() - .map(|(c, _)| format!("{:?}", c)) + .map(|(c, _)| format!("{c:?}")) .collect::>() .join(", "), ); diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index f78da284a3a1..a3c5ca4cda19 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -414,7 +414,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { match path { MustUsePath::Suppressed => {} MustUsePath::Boxed(path) => { - let descr_pre = &format!("{}boxed ", descr_pre); + let descr_pre = &format!("{descr_pre}boxed "); emit_must_use_untranslated( cx, path, @@ -426,7 +426,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { ); } MustUsePath::Opaque(path) => { - let descr_pre = &format!("{}implementer{} of ", descr_pre, plural_suffix); + let descr_pre = &format!("{descr_pre}implementer{plural_suffix} of "); emit_must_use_untranslated( cx, path, @@ -438,7 +438,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { ); } MustUsePath::TraitObject(path) => { - let descr_post = &format!(" trait object{}{}", plural_suffix, descr_post); + let descr_post = &format!(" trait object{plural_suffix}{descr_post}"); emit_must_use_untranslated( cx, path, @@ -451,7 +451,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { } MustUsePath::TupleElement(elems) => { for (index, path) in elems { - let descr_post = &format!(" in tuple element {}", index); + let descr_post = &format!(" in tuple element {index}"); emit_must_use_untranslated( cx, path, @@ -464,7 +464,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { } } MustUsePath::Array(path, len) => { - let descr_pre = &format!("{}array{} of ", descr_pre, plural_suffix); + let descr_pre = &format!("{descr_pre}array{plural_suffix} of "); emit_must_use_untranslated( cx, path, diff --git a/compiler/rustc_mir_build/src/build/custom/parse.rs b/compiler/rustc_mir_build/src/build/custom/parse.rs index c494929cbff5..60c4a041696b 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse.rs @@ -74,7 +74,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { kind @ StmtKind::Let { pattern, .. } => { return Err(ParseError { span: pattern.span, - item_description: format!("{:?}", kind), + item_description: format!("{kind:?}"), expected: "expression".to_string(), }); } diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 7817c3d0d809..3220a184d49b 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -774,8 +774,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Not in a closure debug_assert!( local == ty::CAPTURE_STRUCT_LOCAL, - "Expected local to be Local(1), found {:?}", - local + "Expected local to be Local(1), found {local:?}" ); // Not in a closure debug_assert!( diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 6f14891cb786..ed3ac7cb3ec7 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -1627,9 +1627,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // at least the first candidate ought to be tested assert!( total_candidate_count > candidates.len(), - "{}, {:#?}", - total_candidate_count, - candidates + "{total_candidate_count}, {candidates:#?}" ); debug!("tested_candidates: {}", total_candidate_count - candidates.len()); debug!("untested_candidates: {}", candidates.len()); diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index 275878a39195..484e8490919d 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -175,16 +175,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug_assert_ne!( target_blocks[idx.index()], otherwise_block, - "no candidates for tested discriminant: {:?}", - discr, + "no candidates for tested discriminant: {discr:?}", ); Some((discr.val, target_blocks[idx.index()])) } else { debug_assert_eq!( target_blocks[idx.index()], otherwise_block, - "found candidates for untested discriminant: {:?}", - discr, + "found candidates for untested discriminant: {discr:?}", ); None } diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 17295fe1d344..1ae8031ef3c5 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -94,8 +94,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { || body.basic_blocks.has_free_regions() || body.var_debug_info.has_free_regions() || body.yield_ty().has_free_regions()), - "Unexpected free regions in MIR: {:?}", - body, + "Unexpected free regions in MIR: {body:?}", ); body @@ -977,9 +976,9 @@ pub(crate) fn parse_float_into_scalar( match float_ty { ty::FloatTy::F32 => { let Ok(rust_f) = num.parse::() else { return None }; - let mut f = num.parse::().unwrap_or_else(|e| { - panic!("apfloat::ieee::Single failed to parse `{}`: {:?}", num, e) - }); + let mut f = num + .parse::() + .unwrap_or_else(|e| panic!("apfloat::ieee::Single failed to parse `{num}`: {e:?}")); assert!( u128::from(rust_f.to_bits()) == f.to_bits(), @@ -1000,9 +999,9 @@ pub(crate) fn parse_float_into_scalar( } ty::FloatTy::F64 => { let Ok(rust_f) = num.parse::() else { return None }; - let mut f = num.parse::().unwrap_or_else(|e| { - panic!("apfloat::ieee::Double failed to parse `{}`: {:?}", num, e) - }); + let mut f = num + .parse::() + .unwrap_or_else(|e| panic!("apfloat::ieee::Double failed to parse `{num}`: {e:?}")); assert!( u128::from(rust_f.to_bits()) == f.to_bits(), diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 820ab93851e7..3ff3387a7811 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -454,17 +454,13 @@ impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> { if self.span.eq_ctxt(self.expr_span) { // Get the span for the empty match body `{}`. let (indentation, more) = if let Some(snippet) = sm.indentation_before(self.span) { - (format!("\n{}", snippet), " ") + (format!("\n{snippet}"), " ") } else { (" ".to_string(), "") }; suggestion = Some(( self.span.shrink_to_hi().with_hi(self.expr_span.hi()), - format!( - " {{{indentation}{more}_ => todo!(),{indentation}}}", - indentation = indentation, - more = more, - ), + format!(" {{{indentation}{more}_ => todo!(),{indentation}}}",), )); } diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 711a9126c04a..ff4620948fa1 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -229,9 +229,7 @@ impl<'tcx> Cx<'tcx> { let param_env_ty = self.param_env.and(discr_ty); let size = tcx .layout_of(param_env_ty) - .unwrap_or_else(|e| { - panic!("could not compute layout for {:?}: {:?}", param_env_ty, e) - }) + .unwrap_or_else(|e| panic!("could not compute layout for {param_env_ty:?}: {e:?}")) .size; let lit = ScalarInt::try_from_uint(discr_offset as u128, size).unwrap(); diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 38c866c50a2f..a786e6596642 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -691,7 +691,7 @@ fn non_exhaustive_match<'p, 'tcx>( err = create_e0004( cx.tcx.sess, sp, - format!("non-exhaustive patterns: {} not covered", joined_patterns), + format!("non-exhaustive patterns: {joined_patterns} not covered"), ); err.span_label(sp, pattern_not_covered_label(&witnesses, &joined_patterns)); patterns_len = witnesses.len(); @@ -721,15 +721,13 @@ fn non_exhaustive_match<'p, 'tcx>( && matches!(witnesses[0].ctor(), Constructor::NonExhaustive) { err.note(format!( - "`{}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \ + "`{scrut_ty}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \ exhaustively", - scrut_ty, )); if cx.tcx.sess.is_nightly_build() { err.help(format!( "add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \ - enable precise `{}` matching", - scrut_ty, + enable precise `{scrut_ty}` matching", )); } } @@ -745,18 +743,13 @@ fn non_exhaustive_match<'p, 'tcx>( [] if sp.eq_ctxt(expr_span) => { // Get the span for the empty match body `{}`. let (indentation, more) = if let Some(snippet) = sm.indentation_before(sp) { - (format!("\n{}", snippet), " ") + (format!("\n{snippet}"), " ") } else { (" ".to_string(), "") }; suggestion = Some(( sp.shrink_to_hi().with_hi(expr_span.hi()), - format!( - " {{{indentation}{more}{pattern} => todo!(),{indentation}}}", - indentation = indentation, - more = more, - pattern = pattern, - ), + format!(" {{{indentation}{more}{pattern} => todo!(),{indentation}}}",), )); } [only] => { @@ -765,7 +758,7 @@ fn non_exhaustive_match<'p, 'tcx>( && let Ok(with_trailing) = sm.span_extend_while(only.span, |c| c.is_whitespace() || c == ',') && sm.is_multiline(with_trailing) { - (format!("\n{}", snippet), true) + (format!("\n{snippet}"), true) } else { (" ".to_string(), false) }; @@ -780,7 +773,7 @@ fn non_exhaustive_match<'p, 'tcx>( }; suggestion = Some(( only.span.shrink_to_hi(), - format!("{}{}{} => todo!()", comma, pre_indentation, pattern), + format!("{comma}{pre_indentation}{pattern} => todo!()"), )); } [.., prev, last] => { @@ -803,7 +796,7 @@ fn non_exhaustive_match<'p, 'tcx>( if let Some(spacing) = spacing { suggestion = Some(( last.span.shrink_to_hi(), - format!("{}{}{} => todo!()", comma, spacing, pattern), + format!("{comma}{spacing}{pattern} => todo!()"), )); } } @@ -900,7 +893,7 @@ fn adt_defined_here<'p, 'tcx>( for pat in spans { span.push_span_label(pat, "not covered"); } - err.span_note(span, format!("`{}` defined here", ty)); + err.span_note(span, format!("`{ty}` defined here")); } } diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 4228597cdc95..bee1c4e4614f 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -306,9 +306,9 @@ impl fmt::Debug for IntRange { let (lo, hi) = self.boundaries(); let bias = self.bias; let (lo, hi) = (lo ^ bias, hi ^ bias); - write!(f, "{}", lo)?; + write!(f, "{lo}")?; write!(f, "{}", RangeEnd::Included)?; - write!(f, "{}", hi) + write!(f, "{hi}") } } @@ -1619,7 +1619,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> { // of `std`). So this branch is only reachable when the feature is enabled and // the pattern is a box pattern. let subpattern = self.iter_fields().next().unwrap(); - write!(f, "box {:?}", subpattern) + write!(f, "box {subpattern:?}") } ty::Adt(..) | ty::Tuple(..) => { let variant = match self.ty.kind() { @@ -1638,7 +1638,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> { write!(f, "(")?; for p in self.iter_fields() { write!(f, "{}", start_or_comma())?; - write!(f, "{:?}", p)?; + write!(f, "{p:?}")?; } write!(f, ")") } @@ -1674,11 +1674,11 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> { write!(f, "]") } &FloatRange(lo, hi, end) => { - write!(f, "{}", lo)?; - write!(f, "{}", end)?; - write!(f, "{}", hi) + write!(f, "{lo}")?; + write!(f, "{end}")?; + write!(f, "{hi}") } - IntRange(range) => write!(f, "{:?}", range), // Best-effort, will render e.g. `false` as `0..=0` + IntRange(range) => write!(f, "{range:?}"), // Best-effort, will render e.g. `false` as `0..=0` Wildcard | Missing { .. } | NonExhaustive => write!(f, "_ : {:?}", self.ty), Or => { for pat in self.iter_fields() { @@ -1686,7 +1686,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> { } Ok(()) } - Str(value) => write!(f, "{}", value), + Str(value) => write!(f, "{value}"), Opaque => write!(f, ""), } } diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index e5b635069060..08cfe98bb68b 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -459,7 +459,7 @@ impl<'p, 'tcx> fmt::Debug for PatStack<'p, 'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "+")?; for pat in self.iter() { - write!(f, " {:?} +", pat)?; + write!(f, " {pat:?} +")?; } Ok(()) } @@ -530,7 +530,7 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { let Matrix { patterns: m, .. } = self; let pretty_printed_matrix: Vec> = - m.iter().map(|row| row.iter().map(|pat| format!("{:?}", pat)).collect()).collect(); + m.iter().map(|row| row.iter().map(|pat| format!("{pat:?}")).collect()).collect(); let column_count = m.iter().map(|row| row.len()).next().unwrap_or(0); assert!(m.iter().all(|row| row.len() == column_count)); diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 658e01d93103..e9c5f856d35f 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -282,7 +282,7 @@ impl<'a> BcbCounters<'a> { branching_counter_operand, Op::Subtract, sumup_counter_operand, - || Some(format!("{:?}", expression_branch)), + || Some(format!("{expression_branch:?}")), ); debug!("{:?} gets an expression: {}", expression_branch, self.format_counter(&expression)); let bcb = expression_branch.target_bcb; @@ -324,7 +324,7 @@ impl<'a> BcbCounters<'a> { // program results in a tight infinite loop, but it should still compile. let one_path_to_target = self.bcb_has_one_path_to_target(bcb); if one_path_to_target || self.bcb_predecessors(bcb).contains(&bcb) { - let counter_kind = self.coverage_counters.make_counter(|| Some(format!("{:?}", bcb))); + let counter_kind = self.coverage_counters.make_counter(|| Some(format!("{bcb:?}"))); if one_path_to_target { debug!( "{}{:?} gets a new counter: {}", @@ -392,7 +392,7 @@ impl<'a> BcbCounters<'a> { first_edge_counter_operand, Op::Add, some_sumup_edge_counter_operand.unwrap(), - || Some(format!("{:?}", bcb)), + || Some(format!("{bcb:?}")), ); debug!( "{}{:?} gets a new counter (sum of predecessor counters): {}", @@ -449,7 +449,7 @@ impl<'a> BcbCounters<'a> { // Make a new counter to count this edge. let counter_kind = - self.coverage_counters.make_counter(|| Some(format!("{:?}->{:?}", from_bcb, to_bcb))); + self.coverage_counters.make_counter(|| Some(format!("{from_bcb:?}->{to_bcb:?}"))); debug!( "{}Edge {:?}->{:?} gets a new counter: {}", NESTED_INDENT.repeat(debug_indent_level), diff --git a/compiler/rustc_mir_transform/src/coverage/debug.rs b/compiler/rustc_mir_transform/src/coverage/debug.rs index 7ad981441592..c9914eb9f820 100644 --- a/compiler/rustc_mir_transform/src/coverage/debug.rs +++ b/compiler/rustc_mir_transform/src/coverage/debug.rs @@ -630,7 +630,7 @@ pub(super) fn dump_coverage_spanview<'tcx>( .expect("Unexpected error creating MIR spanview HTML file"); let crate_name = tcx.crate_name(def_id.krate); let item_name = tcx.def_path(def_id).to_filename_friendly_no_crate(); - let title = format!("{}.{} - Coverage Spans", crate_name, item_name); + let title = format!("{crate_name}.{item_name} - Coverage Spans"); spanview::write_document(tcx, body_span, span_viewables, &title, &mut file) .expect("Unexpected IO error dumping coverage spans as HTML"); } @@ -779,7 +779,7 @@ fn bcb_to_string_sections<'tcx>( )); } if let Some(counter_kind) = &bcb_data.counter_kind { - sections.push(format!("{:?}", counter_kind)); + sections.push(format!("{counter_kind:?}")); } let non_term_blocks = bcb_data.basic_blocks[0..len - 1] .iter() diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index d2a854b26756..5d843f4ade09 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -360,8 +360,7 @@ impl BasicCoverageBlockData { if let Some(replaced) = self.counter_kind.replace(counter_kind) { Error::from_string(format!( "attempt to set a BasicCoverageBlock coverage counter more than once; \ - {:?} already had counter {:?}", - self, replaced, + {self:?} already had counter {replaced:?}", )) } else { Ok(operand) @@ -389,9 +388,8 @@ impl BasicCoverageBlockData { // `BasicCoverageBlock`). if self.counter_kind.as_ref().is_some_and(|c| !c.is_expression()) { return Error::from_string(format!( - "attempt to add an incoming edge counter from {:?} when the target BCB already \ - has a `Counter`", - from_bcb + "attempt to add an incoming edge counter from {from_bcb:?} when the target BCB already \ + has a `Counter`" )); } } @@ -401,8 +399,7 @@ impl BasicCoverageBlockData { { Error::from_string(format!( "attempt to set an edge counter more than once; from_bcb: \ - {:?} already had counter {:?}", - from_bcb, replaced, + {from_bcb:?} already had counter {replaced:?}", )) } else { Ok(operand) @@ -612,7 +609,7 @@ impl TraverseCoverageGraphWithLoops { the {}", successor_to_add, if let Some(loop_header) = some_loop_header { - format!("worklist for the loop headed by {:?}", loop_header) + format!("worklist for the loop headed by {loop_header:?}") } else { String::from("non-loop worklist") }, @@ -623,7 +620,7 @@ impl TraverseCoverageGraphWithLoops { "{:?} successor is non-branching. Defer it to the end of the {}", successor_to_add, if let Some(loop_header) = some_loop_header { - format!("worklist for the loop headed by {:?}", loop_header) + format!("worklist for the loop headed by {loop_header:?}") } else { String::from("non-loop worklist") }, diff --git a/compiler/rustc_mir_transform/src/elaborate_drops.rs b/compiler/rustc_mir_transform/src/elaborate_drops.rs index d5664e2b40a6..43757a9ea353 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drops.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drops.rs @@ -358,8 +358,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { self.tcx.sess.delay_span_bug( terminator.source_info.span, format!( - "drop of untracked, uninitialized value {:?}, place {:?} ({:?})", - bb, place, path + "drop of untracked, uninitialized value {bb:?}, place {place:?} ({path:?})" ), ); } @@ -424,7 +423,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { if !replace { self.tcx.sess.delay_span_bug( terminator.source_info.span, - format!("drop of untracked value {:?}", bb), + format!("drop of untracked value {bb:?}"), ); } // A drop and replace behind a pointer/array/whatever. diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index fdf6ab33c82f..a42eacbf22b4 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -168,15 +168,15 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { } }; let ident = self.tcx.item_name(fn_id).to_ident_string(); - let ty_params = fn_args.types().map(|ty| format!("{}", ty)); - let const_params = fn_args.consts().map(|c| format!("{}", c)); + let ty_params = fn_args.types().map(|ty| format!("{ty}")); + let const_params = fn_args.consts().map(|c| format!("{c}")); let params = ty_params.chain(const_params).join(", "); let num_args = fn_sig.inputs().map_bound(|inputs| inputs.len()).skip_binder(); let variadic = if fn_sig.c_variadic() { ", ..." } else { "" }; let ret = if fn_sig.output().skip_binder().is_unit() { "" } else { " -> _" }; let sugg = format!( "{} as {}{}fn({}{}){}", - if params.is_empty() { ident.clone() } else { format!("{}::<{}>", ident, params) }, + if params.is_empty() { ident.clone() } else { format!("{ident}::<{params}>") }, unsafety, abi, vec!["_"; num_args].join(", "), diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index eaeaff69cf39..669135f80bc5 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -1477,7 +1477,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform { ) } _ => { - tcx.sess.delay_span_bug(body.span, format!("unexpected generator type {}", gen_ty)); + tcx.sess.delay_span_bug(body.span, format!("unexpected generator type {gen_ty}")); return; } }; diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index a430f8da35cf..8b0a0903d189 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -57,7 +57,7 @@ struct InstSimplifyContext<'tcx, 'a> { impl<'tcx> InstSimplifyContext<'tcx, '_> { fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool { self.tcx.consider_optimizing(|| { - format!("InstSimplify - Rvalue: {:?} SourceInfo: {:?}", rvalue, source_info) + format!("InstSimplify - Rvalue: {rvalue:?} SourceInfo: {source_info:?}") }) } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index d419329f2d6b..734321e97d89 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -615,7 +615,7 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { // computes and caches its result. Some(hir::ConstContext::ConstFn) => tcx.ensure_with_value().mir_for_ctfe(did), None => {} - Some(other) => panic!("do not use `optimized_mir` for constants: {:?}", other), + Some(other) => panic!("do not use `optimized_mir` for constants: {other:?}"), } debug!("about to call mir_drops_elaborated..."); let body = tcx.mir_drops_elaborated_and_const_checked(did).steal(); diff --git a/compiler/rustc_mir_transform/src/match_branches.rs b/compiler/rustc_mir_transform/src/match_branches.rs index 6eb484982744..bc29fb8ded16 100644 --- a/compiler/rustc_mir_transform/src/match_branches.rs +++ b/compiler/rustc_mir_transform/src/match_branches.rs @@ -51,7 +51,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification { let bbs = body.basic_blocks.as_mut(); let mut should_cleanup = false; 'outer: for bb_idx in bbs.indices() { - if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {:?} ", def_id)) { + if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {def_id:?} ")) { continue; } diff --git a/compiler/rustc_mir_transform/src/multiple_return_terminators.rs b/compiler/rustc_mir_transform/src/multiple_return_terminators.rs index 3957cd92c4e3..c97d034544a8 100644 --- a/compiler/rustc_mir_transform/src/multiple_return_terminators.rs +++ b/compiler/rustc_mir_transform/src/multiple_return_terminators.rs @@ -27,7 +27,7 @@ impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators { } for bb in bbs { - if !tcx.consider_optimizing(|| format!("MultipleReturnTerminators {:?} ", def_id)) { + if !tcx.consider_optimizing(|| format!("MultipleReturnTerminators {def_id:?} ")) { break; } diff --git a/compiler/rustc_mir_transform/src/nrvo.rs b/compiler/rustc_mir_transform/src/nrvo.rs index 5ce96012b908..e1298b0654f2 100644 --- a/compiler/rustc_mir_transform/src/nrvo.rs +++ b/compiler/rustc_mir_transform/src/nrvo.rs @@ -45,7 +45,7 @@ impl<'tcx> MirPass<'tcx> for RenameReturnPlace { return; }; - if !tcx.consider_optimizing(|| format!("RenameReturnPlace {:?}", def_id)) { + if !tcx.consider_optimizing(|| format!("RenameReturnPlace {def_id:?}")) { return; } diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index 710eed3ed380..057f5fe82931 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -118,7 +118,7 @@ fn run_passes_inner<'tcx>( dump_mir_for_pass(tcx, body, &name, false); } if validate { - validate_body(tcx, body, format!("before pass {}", name)); + validate_body(tcx, body, format!("before pass {name}")); } tcx.sess.time(name, || pass.run_pass(tcx, body)); @@ -127,7 +127,7 @@ fn run_passes_inner<'tcx>( dump_mir_for_pass(tcx, body, &name, true); } if validate { - validate_body(tcx, body, format!("after pass {}", name)); + validate_body(tcx, body, format!("after pass {name}")); } body.pass_count += 1; diff --git a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs index 84ccf6e1f61d..08b2a6537e93 100644 --- a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs +++ b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs @@ -27,7 +27,7 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops { if ty.ty.needs_drop(tcx, param_env) { continue; } - if !tcx.consider_optimizing(|| format!("RemoveUnneededDrops {:?} ", did)) { + if !tcx.consider_optimizing(|| format!("RemoveUnneededDrops {did:?} ")) { continue; } debug!("SUCCESS: replacing `drop` with goto({:?})", target); diff --git a/compiler/rustc_mir_transform/src/remove_zsts.rs b/compiler/rustc_mir_transform/src/remove_zsts.rs index 1ba9ad875375..9c6c55b0811f 100644 --- a/compiler/rustc_mir_transform/src/remove_zsts.rs +++ b/compiler/rustc_mir_transform/src/remove_zsts.rs @@ -102,7 +102,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { let op_ty = operand.ty(self.local_decls, self.tcx); if self.known_to_be_zst(op_ty) && self.tcx.consider_optimizing(|| { - format!("RemoveZsts - Operand: {:?} Location: {:?}", operand, loc) + format!("RemoveZsts - Operand: {operand:?} Location: {loc:?}") }) { *operand = Operand::Constant(Box::new(self.make_zst(op_ty))) diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index fc437c429fbe..e70817d7b7c5 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -157,10 +157,8 @@ impl<'tcx> CheckConstVisitor<'tcx> { // is a pretty narrow case, however. if tcx.sess.is_nightly_build() { for gate in missing_secondary { - let note = format!( - "add `#![feature({})]` to the crate attributes to enable", - gate, - ); + let note = + format!("add `#![feature({gate})]` to the crate attributes to enable",); err.help(note); } } diff --git a/compiler/rustc_passes/src/hir_id_validator.rs b/compiler/rustc_passes/src/hir_id_validator.rs index 363e1743677a..f825363ae39a 100644 --- a/compiler/rustc_passes/src/hir_id_validator.rs +++ b/compiler/rustc_passes/src/hir_id_validator.rs @@ -89,9 +89,8 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> { self.error(|| { format!( - "ItemLocalIds not assigned densely in {}. \ - Max ItemLocalId = {}, missing IDs = {:#?}; seen IDs = {:#?}", - pretty_owner, max, missing_items, seen_items + "ItemLocalIds not assigned densely in {pretty_owner}. \ + Max ItemLocalId = {max}, missing IDs = {missing_items:#?}; seen IDs = {seen_items:#?}" ) }); } diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 6c748147abe0..5aa8aef6a859 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -126,12 +126,12 @@ impl<'k> StatCollector<'k> { let total_size = nodes.iter().map(|(_, node)| node.stats.count * node.stats.size).sum(); - eprintln!("{} {}", prefix, title); + eprintln!("{prefix} {title}"); eprintln!( "{} {:<18}{:>18}{:>14}{:>14}", prefix, "Name", "Accumulated Size", "Count", "Item Size" ); - eprintln!("{} ----------------------------------------------------------------", prefix); + eprintln!("{prefix} ----------------------------------------------------------------"); let percent = |m, n| (m * 100) as f64 / n as f64; @@ -163,9 +163,9 @@ impl<'k> StatCollector<'k> { } } } - eprintln!("{} ----------------------------------------------------------------", prefix); + eprintln!("{prefix} ----------------------------------------------------------------"); eprintln!("{} {:<18}{:>10}", prefix, "Total", to_readable_str(total_size)); - eprintln!("{}", prefix); + eprintln!("{prefix}"); } } diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 89c6704e4169..15757a0f1ada 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -605,7 +605,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { for var_idx in 0..self.ir.var_kinds.len() { let var = Variable::from(var_idx); if test(var) { - write!(wr, " {:?}", var)?; + write!(wr, " {var:?}")?; } } Ok(()) diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index e173bba49be0..f89558a45999 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -133,7 +133,7 @@ where _ => { tcx.sess.delay_span_bug( tcx.hir().span_if_local(def_id).unwrap_or(DUMMY_SP), - format!("unexpected generator witness type {:?}", witness), + format!("unexpected generator witness type {witness:?}"), ); return Some(Err(AlwaysRequiresDrop)); } From 39d51bd51c941021567e6adae1f80c3cbcc31d47 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 26 Jul 2023 09:11:18 +1000 Subject: [PATCH 060/150] Remove `Parser::desugar_doc_comments`. It's currently stored twice: once in `Parser`, once in the `TokenStream` within `Parser`. We only need the latter. --- compiler/rustc_parse/src/parser/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 2e1a61e634e6..843e1e4d1576 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -138,7 +138,6 @@ pub struct Parser<'a> { // Important: This must only be advanced from `bump` to ensure that // `token_cursor.num_next_calls` is updated properly. token_cursor: TokenCursor, - desugar_doc_comments: bool, /// This field is used to keep track of how many left angle brackets we have seen. This is /// required in order to detect extra leading left angle brackets (`<` characters) and error /// appropriately. @@ -463,7 +462,6 @@ impl<'a> Parser<'a> { desugar_doc_comments, break_last_token: false, }, - desugar_doc_comments, unmatched_angle_bracket_count: 0, max_angle_bracket_count: 0, last_unexpected_token_span: None, @@ -1107,7 +1105,7 @@ impl<'a> Parser<'a> { pub fn bump(&mut self) { // Note: destructuring here would give nicer code, but it was found in #96210 to be slower // than `.0`/`.1` access. - let mut next = self.token_cursor.inlined_next(self.desugar_doc_comments); + let mut next = self.token_cursor.inlined_next(self.token_cursor.desugar_doc_comments); self.token_cursor.num_next_calls += 1; // We've retrieved an token from the underlying // cursor, so we no longer need to worry about From f68f37d00691f5b7c5de7b401c213fe54c2e695e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 26 Jul 2023 02:10:17 +0200 Subject: [PATCH 061/150] rustdoc: stylistic changes --- src/librustdoc/clean/mod.rs | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d14953f1bb78..ce6bcf357b4e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -798,10 +798,10 @@ fn clean_ty_generics<'tcx>( let where_predicates = preds .predicates .iter() - .flat_map(|(p, _)| { + .flat_map(|(pred, _)| { let mut projection = None; let param_idx = (|| { - let bound_p = p.kind(); + let bound_p = pred.kind(); match bound_p.skip_binder() { ty::ClauseKind::Trait(pred) => { if let ty::Param(param) = pred.self_ty().kind() { @@ -826,33 +826,27 @@ fn clean_ty_generics<'tcx>( })(); if let Some(param_idx) = param_idx - && let Some(b) = impl_trait.get_mut(¶m_idx.into()) + && let Some(bounds) = impl_trait.get_mut(¶m_idx.into()) { - let p: WherePredicate = clean_predicate(*p, cx)?; + let pred = clean_predicate(*pred, cx)?; - b.extend( - p.get_bounds() + bounds.extend( + pred.get_bounds() .into_iter() .flatten() .cloned() .filter(|b| !b.is_sized_bound(cx)), ); - let proj = projection.map(|p| { - ( - clean_projection(p.map_bound(|p| p.projection_ty), cx, None), - p.map_bound(|p| p.term), - ) - }); - if let Some(((_, trait_did, name), rhs)) = proj - .as_ref() - .and_then(|(lhs, rhs): &(Type, _)| Some((lhs.projection()?, rhs))) + if let Some(proj) = projection + && let lhs = clean_projection(proj.map_bound(|p| p.projection_ty), cx, None) + && let Some((_, trait_did, name)) = lhs.projection() { impl_trait_proj.entry(param_idx).or_default().push(( trait_did, name, - *rhs, - p.get_bound_params() + proj.map_bound(|p| p.term), + pred.get_bound_params() .into_iter() .flatten() .cloned() @@ -863,7 +857,7 @@ fn clean_ty_generics<'tcx>( return None; } - Some(p) + Some(pred) }) .collect::>(); @@ -891,7 +885,7 @@ fn clean_ty_generics<'tcx>( // implicit `Sized` bound unless removed with `?Sized`. // However, in the list of where-predicates below, `Sized` appears like a // normal bound: It's either present (the type is sized) or - // absent (the type is unsized) but never *maybe* (i.e. `?Sized`). + // absent (the type might be unsized) but never *maybe* (i.e. `?Sized`). // // This is unsuitable for rendering. // Thus, as a first step remove all `Sized` bounds that should be implicit. @@ -902,8 +896,8 @@ fn clean_ty_generics<'tcx>( let mut sized_params = FxHashSet::default(); where_predicates.retain(|pred| { if let WherePredicate::BoundPredicate { ty: Generic(g), bounds, .. } = pred - && *g != kw::SelfUpper - && bounds.iter().any(|b| b.is_sized_bound(cx)) + && *g != kw::SelfUpper + && bounds.iter().any(|b| b.is_sized_bound(cx)) { sized_params.insert(*g); false From 28d40f195967ee008fd47b7ad88463ac56e98253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 26 Jul 2023 02:11:35 +0200 Subject: [PATCH 062/150] rustdoc: fix cross-crate impl-Sized --- src/librustdoc/clean/mod.rs | 44 ++++++++++++++----- src/librustdoc/clean/types.rs | 17 +++++-- src/librustdoc/html/format.rs | 35 ++++++++++----- tests/rustdoc/extern-impl-trait.rs | 2 +- tests/rustdoc/impl-everywhere.rs | 2 +- .../inline_cross/auxiliary/impl-sized.rs | 21 +++++++++ tests/rustdoc/inline_cross/impl-sized.rs | 27 ++++++++++++ 7 files changed, 121 insertions(+), 27 deletions(-) create mode 100644 tests/rustdoc/inline_cross/auxiliary/impl-sized.rs create mode 100644 tests/rustdoc/inline_cross/impl-sized.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ce6bcf357b4e..40a1e214a3b8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -835,7 +835,6 @@ fn clean_ty_generics<'tcx>( .into_iter() .flatten() .cloned() - .filter(|b| !b.is_sized_bound(cx)), ); if let Some(proj) = projection @@ -862,8 +861,27 @@ fn clean_ty_generics<'tcx>( .collect::>(); for (param, mut bounds) in impl_trait { + let mut has_sized = false; + bounds.retain(|b| { + if b.is_sized_bound(cx) { + has_sized = true; + false + } else { + true + } + }); + if !has_sized { + bounds.push(GenericBound::maybe_sized(cx)); + } + // Move trait bounds to the front. - bounds.sort_by_key(|b| !matches!(b, GenericBound::TraitBound(..))); + bounds.sort_by_key(|b| !b.is_trait_bound()); + + // Add back a `Sized` bound if there are no *trait* bounds remaining (incl. `?Sized`). + // Since all potential trait bounds are at the front we can just check the first bound. + if bounds.first().map_or(true, |b| !b.is_trait_bound()) { + bounds.insert(0, GenericBound::sized(cx)); + } let crate::core::ImplTraitParam::ParamIndex(idx) = param else { unreachable!() }; if let Some(proj) = impl_trait_proj.remove(&idx) { @@ -2107,7 +2125,6 @@ fn clean_middle_opaque_bounds<'tcx>( cx: &mut DocContext<'tcx>, bounds: Vec>, ) -> Type { - let mut regions = vec![]; let mut has_sized = false; let mut bounds = bounds .iter() @@ -2116,10 +2133,7 @@ fn clean_middle_opaque_bounds<'tcx>( let trait_ref = match bound_predicate.skip_binder() { ty::ClauseKind::Trait(tr) => bound_predicate.rebind(tr.trait_ref), ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => { - if let Some(r) = clean_middle_region(reg) { - regions.push(GenericBound::Outlives(r)); - } - return None; + return clean_middle_region(reg).map(GenericBound::Outlives); } _ => return None, }; @@ -2155,10 +2169,20 @@ fn clean_middle_opaque_bounds<'tcx>( Some(clean_poly_trait_ref_with_bindings(cx, trait_ref, bindings)) }) .collect::>(); - bounds.extend(regions); - if !has_sized && !bounds.is_empty() { - bounds.insert(0, GenericBound::maybe_sized(cx)); + + if !has_sized { + bounds.push(GenericBound::maybe_sized(cx)); } + + // Move trait bounds to the front. + bounds.sort_by_key(|b| !b.is_trait_bound()); + + // Add back a `Sized` bound if there are no *trait* bounds remaining (incl. `?Sized`). + // Since all potential trait bounds are at the front we can just check the first bound. + if bounds.first().map_or(true, |b| !b.is_trait_bound()) { + bounds.insert(0, GenericBound::sized(cx)); + } + ImplTrait(bounds) } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index ddef165a0547..647fbcdc3d77 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1219,15 +1219,24 @@ pub(crate) enum GenericBound { } impl GenericBound { + pub(crate) fn sized(cx: &mut DocContext<'_>) -> GenericBound { + Self::sized_with(cx, hir::TraitBoundModifier::None) + } + pub(crate) fn maybe_sized(cx: &mut DocContext<'_>) -> GenericBound { + Self::sized_with(cx, hir::TraitBoundModifier::Maybe) + } + + fn sized_with(cx: &mut DocContext<'_>, modifier: hir::TraitBoundModifier) -> GenericBound { let did = cx.tcx.require_lang_item(LangItem::Sized, None); let empty = ty::Binder::dummy(ty::GenericArgs::empty()); let path = external_path(cx, did, false, ThinVec::new(), empty); inline::record_extern_fqn(cx, did, ItemType::Trait); - GenericBound::TraitBound( - PolyTrait { trait_: path, generic_params: Vec::new() }, - hir::TraitBoundModifier::Maybe, - ) + GenericBound::TraitBound(PolyTrait { trait_: path, generic_params: Vec::new() }, modifier) + } + + pub(crate) fn is_trait_bound(&self) -> bool { + matches!(self, Self::TraitBound(..)) } pub(crate) fn is_sized_bound(&self, cx: &DocContext<'_>) -> bool { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 1099c68b004c..eba77157b240 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1094,22 +1094,35 @@ fn fmt_type<'cx>( }; let m = mutability.print_with_space(); let amp = if f.alternate() { "&" } else { "&" }; - match **ty { + + if let clean::Generic(name) = **ty { + return primitive_link( + f, + PrimitiveType::Reference, + &format!("{amp}{lt}{m}{name}"), + cx, + ); + } + + write!(f, "{amp}{lt}{m}")?; + + let needs_parens = match **ty { clean::DynTrait(ref bounds, ref trait_lt) if bounds.len() > 1 || trait_lt.is_some() => { - write!(f, "{}{}{}(", amp, lt, m)?; - fmt_type(ty, f, use_absolute, cx)?; - write!(f, ")") - } - clean::Generic(name) => { - primitive_link(f, PrimitiveType::Reference, &format!("{amp}{lt}{m}{name}"), cx) - } - _ => { - write!(f, "{}{}{}", amp, lt, m)?; - fmt_type(ty, f, use_absolute, cx) + true } + clean::ImplTrait(ref bounds) if bounds.len() > 1 => true, + _ => false, + }; + if needs_parens { + f.write_str("(")?; } + fmt_type(ty, f, use_absolute, cx)?; + if needs_parens { + f.write_str(")")?; + } + Ok(()) } clean::ImplTrait(ref bounds) => { if f.alternate() { diff --git a/tests/rustdoc/extern-impl-trait.rs b/tests/rustdoc/extern-impl-trait.rs index 8ab026afd1b8..4d8672305a75 100644 --- a/tests/rustdoc/extern-impl-trait.rs +++ b/tests/rustdoc/extern-impl-trait.rs @@ -7,5 +7,5 @@ extern crate extern_impl_trait; // @has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo + 'a" pub use extern_impl_trait::X; -// @has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl ?Sized + Foo + 'a" +// @has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo + ?Sized + 'a" pub use extern_impl_trait::Y; diff --git a/tests/rustdoc/impl-everywhere.rs b/tests/rustdoc/impl-everywhere.rs index 44885d4301ff..2311c806c18a 100644 --- a/tests/rustdoc/impl-everywhere.rs +++ b/tests/rustdoc/impl-everywhere.rs @@ -25,6 +25,6 @@ pub fn foo_foo() -> impl Foo + Foo2 { Bar } -// @has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo + Foo2" +// @has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) { } diff --git a/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs b/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs new file mode 100644 index 000000000000..65f72a3b9ac3 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/impl-sized.rs @@ -0,0 +1,21 @@ +use std::fmt::Debug; + +pub fn sized(x: impl Sized) -> impl Sized { + x +} + +pub fn sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a { + x +} + +pub fn maybe_sized(x: &impl ?Sized) -> &impl ?Sized { + x +} + +pub fn debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized) { + x +} + +pub fn maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't) { + x +} diff --git a/tests/rustdoc/inline_cross/impl-sized.rs b/tests/rustdoc/inline_cross/impl-sized.rs new file mode 100644 index 000000000000..82bdce474784 --- /dev/null +++ b/tests/rustdoc/inline_cross/impl-sized.rs @@ -0,0 +1,27 @@ +#![crate_name = "user"] + +// aux-crate:impl_sized=impl-sized.rs +// edition:2021 + +// @has user/fn.sized.html +// @has - '//pre[@class="rust item-decl"]' "sized(x: impl Sized) -> impl Sized" +pub use impl_sized::sized; + +// @has user/fn.sized_outlives.html +// @has - '//pre[@class="rust item-decl"]' \ +// "sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a" +pub use impl_sized::sized_outlives; + +// @has user/fn.maybe_sized.html +// @has - '//pre[@class="rust item-decl"]' "maybe_sized(x: &impl ?Sized) -> &impl ?Sized" +pub use impl_sized::maybe_sized; + +// @has user/fn.debug_maybe_sized.html +// @has - '//pre[@class="rust item-decl"]' \ +// "debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized)" +pub use impl_sized::debug_maybe_sized; + +// @has user/fn.maybe_sized_outlives.html +// @has - '//pre[@class="rust item-decl"]' \ +// "maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't)" +pub use impl_sized::maybe_sized_outlives; From 808e174dfc8e6921fa9aac71ae6e568e940687af Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 26 Jul 2023 01:35:51 +0000 Subject: [PATCH 063/150] Don't treat negative trait predicates as always knowable --- compiler/rustc_trait_selection/src/traits/select/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index e086489b1bcb..ca289ab6fe3f 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1487,7 +1487,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { fn is_knowable<'o>(&mut self, stack: &TraitObligationStack<'o, 'tcx>) -> Result<(), Conflict> { debug!("is_knowable(intercrate={:?})", self.is_intercrate()); - if !self.is_intercrate() || stack.obligation.polarity() == ty::ImplPolarity::Negative { + if !self.is_intercrate() { return Ok(()); } From 395e95c4900367930af2f18c9a53ce18ed55d5d5 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 26 Jul 2023 09:17:16 +1000 Subject: [PATCH 064/150] Tweak `Parser::look_ahead`. It doesn't really matter what the `desugar_doc_comments` argument is here, because in practice we never look ahead through doc comments. Changing it to `cursor.desugar_doc_comments` will allow some follow-up simplifications. --- compiler/rustc_parse/src/parser/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 843e1e4d1576..1bf48d509a16 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1155,7 +1155,7 @@ impl<'a> Parser<'a> { let mut i = 0; let mut token = Token::dummy(); while i < dist { - token = cursor.next(/* desugar_doc_comments */ false).0; + token = cursor.next(cursor.desugar_doc_comments).0; if matches!( token.kind, token::OpenDelim(Delimiter::Invisible) | token::CloseDelim(Delimiter::Invisible) From 8bfc69285146bdfa97ea38bb9bcd5c8a92c1de47 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 26 Jul 2023 09:17:32 +1000 Subject: [PATCH 065/150] Remove `desugar_doc_comments` arguments from `TokenCursor::{inlined_,}next`. Because it's now always `self.desugar_doc_comments`. --- .../rustc_parse/src/parser/attr_wrapper.rs | 2 +- compiler/rustc_parse/src/parser/mod.rs | 41 +++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index b579da098d8a..4cc03664b47c 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -107,7 +107,7 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl { let tokens = std::iter::once((FlatToken::Token(self.start_token.0.clone()), self.start_token.1)) .chain((0..self.num_calls).map(|_| { - let token = cursor_snapshot.next(cursor_snapshot.desugar_doc_comments); + let token = cursor_snapshot.next(); (FlatToken::Token(token.0), token.1) })) .take(self.num_calls); diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 1bf48d509a16..1715d9f6cc43 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -254,33 +254,38 @@ struct TokenCursor { } impl TokenCursor { - fn next(&mut self, desugar_doc_comments: bool) -> (Token, Spacing) { - self.inlined_next(desugar_doc_comments) + fn next(&mut self) -> (Token, Spacing) { + self.inlined_next() } /// This always-inlined version should only be used on hot code paths. #[inline(always)] - fn inlined_next(&mut self, desugar_doc_comments: bool) -> (Token, Spacing) { + fn inlined_next(&mut self) -> (Token, Spacing) { loop { // FIXME: we currently don't return `Delimiter` open/close delims. To fix #67062 we will // need to, whereupon the `delim != Delimiter::Invisible` conditions below can be // removed. if let Some(tree) = self.tree_cursor.next_ref() { match tree { - &TokenTree::Token(ref token, spacing) => match (desugar_doc_comments, token) { - (true, &Token { kind: token::DocComment(_, attr_style, data), span }) => { - let desugared = self.desugar(attr_style, data, span); - self.tree_cursor.replace_prev_and_rewind(desugared); - // Continue to get the first token of the desugared doc comment. + &TokenTree::Token(ref token, spacing) => { + match (self.desugar_doc_comments, token) { + ( + true, + &Token { kind: token::DocComment(_, attr_style, data), span }, + ) => { + let desugared = self.desugar(attr_style, data, span); + self.tree_cursor.replace_prev_and_rewind(desugared); + // Continue to get the first token of the desugared doc comment. + } + _ => { + debug_assert!(!matches!( + token.kind, + token::OpenDelim(_) | token::CloseDelim(_) + )); + return (token.clone(), spacing); + } } - _ => { - debug_assert!(!matches!( - token.kind, - token::OpenDelim(_) | token::CloseDelim(_) - )); - return (token.clone(), spacing); - } - }, + } &TokenTree::Delimited(sp, delim, ref tts) => { let trees = tts.clone().into_trees(); self.stack.push((mem::replace(&mut self.tree_cursor, trees), delim, sp)); @@ -1105,7 +1110,7 @@ impl<'a> Parser<'a> { pub fn bump(&mut self) { // Note: destructuring here would give nicer code, but it was found in #96210 to be slower // than `.0`/`.1` access. - let mut next = self.token_cursor.inlined_next(self.token_cursor.desugar_doc_comments); + let mut next = self.token_cursor.inlined_next(); self.token_cursor.num_next_calls += 1; // We've retrieved an token from the underlying // cursor, so we no longer need to worry about @@ -1155,7 +1160,7 @@ impl<'a> Parser<'a> { let mut i = 0; let mut token = Token::dummy(); while i < dist { - token = cursor.next(cursor.desugar_doc_comments).0; + token = cursor.next().0; if matches!( token.kind, token::OpenDelim(Delimiter::Invisible) | token::CloseDelim(Delimiter::Invisible) From 34b218e4548f9a989a4131979a61d15fd73289e9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 26 Jul 2023 09:22:59 +1000 Subject: [PATCH 066/150] Add a comment to `TokenCursor::desugar_doc_comments`. Useful information that took me some time to discern. --- compiler/rustc_parse/src/parser/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 1715d9f6cc43..37b4c371c94b 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -224,6 +224,9 @@ struct TokenCursor { // because it's the outermost token stream which never has delimiters. stack: Vec<(TokenTreeCursor, Delimiter, DelimSpan)>, + // We need to desugar doc comments from `/// foo` form into `#[doc = + // r"foo"]` form when parsing declarative macro inputs in `parse_tt`, + // because some declarative macros look for `doc` attributes. desugar_doc_comments: bool, // Counts the number of calls to `{,inlined_}next`. From 933fc180bd7a3a096e9412e8535cd254a92705be Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Wed, 26 Jul 2023 00:15:29 -0400 Subject: [PATCH 067/150] add stable NullaryOp --- compiler/rustc_smir/src/rustc_smir/mod.rs | 4 +++- compiler/rustc_smir/src/stable_mir/mir/body.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 044e2f8f3256..9bf3d031217d 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -156,7 +156,9 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> { ops.0.stable(tables), ops.1.stable(tables), ), - NullaryOp(_, _) => todo!(), + NullaryOp(null_op, ty) => { + stable_mir::mir::Rvalue::NullaryOp(null_op.stable(tables), tables.intern_ty(*ty)) + } UnaryOp(un_op, op) => { stable_mir::mir::Rvalue::UnaryOp(un_op.stable(tables), op.stable(tables)) } diff --git a/compiler/rustc_smir/src/stable_mir/mir/body.rs b/compiler/rustc_smir/src/stable_mir/mir/body.rs index 831eb6589e46..1b1871bcd2a7 100644 --- a/compiler/rustc_smir/src/stable_mir/mir/body.rs +++ b/compiler/rustc_smir/src/stable_mir/mir/body.rs @@ -218,6 +218,9 @@ pub enum Rvalue { /// nature of this operation? ThreadLocalRef(stable_mir::CrateItem), + /// Computes a value as described by the operation. + NullaryOp(NullOp, Ty), + /// Exactly like `BinaryOp`, but less operands. /// /// Also does two's-complement arithmetic. Negation requires a signed integer or a float; From cf325e8187f457b636973a31a83f279e455c25c2 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 25 Jul 2023 12:56:34 +0000 Subject: [PATCH 068/150] Bump syn now that it doesn't affect diagnostics anymore --- Cargo.lock | 38 +++--- compiler/rustc_macros/Cargo.toml | 3 +- .../diagnostic-derive.stderr | 52 +++---- .../subdiagnostic-derive.stderr | 127 +++++++++--------- 4 files changed, 109 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c2c3f5e628b..569010d08c5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -502,7 +502,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -527,7 +527,7 @@ dependencies = [ "regex", "rustc_tools_util", "serde", - "syn 2.0.8", + "syn 2.0.27", "tempfile", "termize", "tester", @@ -842,7 +842,7 @@ version = "0.1.73" dependencies = [ "itertools", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -943,7 +943,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -1309,7 +1309,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -2456,7 +2456,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -2643,7 +2643,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -3584,7 +3584,7 @@ dependencies = [ "fluent-syntax", "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", "unic-langid", ] @@ -3854,7 +3854,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", "synstructure 0.13.0", ] @@ -4462,7 +4462,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -4629,7 +4629,7 @@ checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -4910,9 +4910,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.8" +version = "2.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc02725fd69ab9f26eab07fad303e2497fad6fb9eba4f96c4d1687bdf704ad9" +checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" dependencies = [ "proc-macro2", "quote", @@ -4939,7 +4939,7 @@ checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", "unicode-xid", ] @@ -5089,7 +5089,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -5310,7 +5310,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", ] [[package]] @@ -5740,7 +5740,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", "wasm-bindgen-shared", ] @@ -5774,7 +5774,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.8", + "syn 2.0.27", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/compiler/rustc_macros/Cargo.toml b/compiler/rustc_macros/Cargo.toml index 16c4a850012b..17651ce95987 100644 --- a/compiler/rustc_macros/Cargo.toml +++ b/compiler/rustc_macros/Cargo.toml @@ -8,7 +8,6 @@ proc-macro = true [dependencies] synstructure = "0.13.0" -# FIXME(Nilstrieb): Updating this causes changes in the diagnostics output. -syn = { version = "=2.0.8", features = ["full"] } +syn = { version = "2.0.9", features = ["full"] } proc-macro2 = "1" quote = "1" diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 1398f9c96bf2..ca09f1f0153f 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -20,12 +20,6 @@ LL | Bar, | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: expected parentheses: #[diag(...)] - --> $DIR/diagnostic-derive.rs:55:8 - | -LL | #[diag = "E0123"] - | ^ - error: `#[nonsense(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:60:1 | @@ -476,6 +470,14 @@ LL | #[multipart_suggestion(no_crate_suggestion)] | = help: consider creating a `Subdiagnostic` instead +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:645:1 + | +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead + error: `#[multipart_suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:649:5 | @@ -484,12 +486,6 @@ LL | #[multipart_suggestion(no_crate_suggestion)] | = help: consider creating a `Subdiagnostic` instead -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/diagnostic-derive.rs:645:24 - | -LL | #[multipart_suggestion()] - | ^ - error: `#[suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:657:1 | @@ -550,18 +546,6 @@ error: `code(...)` must contain only string literals LL | #[suggestion(code(foo))] | ^^^ -error: unexpected token - --> $DIR/diagnostic-derive.rs:798:23 - | -LL | #[suggestion(code(foo))] - | ^^^ - -error: expected string literal - --> $DIR/diagnostic-derive.rs:807:25 - | -LL | #[suggestion(code = 3)] - | ^ - error: `#[suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:822:5 | @@ -572,6 +556,24 @@ LL | #[suggestion(no_crate_suggestion, code = "")] = help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]` = help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]` +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:55:8 + | +LL | #[diag = "E0123"] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:798:23 + | +LL | #[suggestion(code(foo))] + | ^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:807:25 + | +LL | #[suggestion(code = 3)] + | ^ maybe a missing crate `core`? + error: cannot find attribute `nonsense` in this scope --> $DIR/diagnostic-derive.rs:60:3 | @@ -656,5 +658,5 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` error: aborting due to 84 previous errors -Some errors have detailed explanations: E0277, E0425. +Some errors have detailed explanations: E0277, E0425, E0433. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 5ddc8edd745d..1dedd68914e3 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -38,12 +38,6 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute LL | #[label(bug = "...")] | ^^^^^^^^^^^^^^^^^^^^^ -error: unexpected literal in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:97:9 - | -LL | #[label("...")] - | ^^^^^ - error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:106:9 | @@ -68,11 +62,11 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute LL | #[label(slug("..."))] | ^^^^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:136:9 +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:136:1 | LL | #[label()] - | ^ + | ^^^^^^^^^^ error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:145:27 @@ -174,16 +168,6 @@ LL | #[bar("...")] | = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes -error: unexpected unsupported untagged union - --> $DIR/subdiagnostic-derive.rs:312:1 - | -LL | / union AC { -LL | | -LL | | span: u32, -LL | | b: u64, -LL | | } - | |_^ - error: a diagnostic slug must be the first argument to the attribute --> $DIR/subdiagnostic-derive.rs:327:44 | @@ -331,11 +315,11 @@ error: `#[suggestion_part(...)]` attribute without `code = "..."` LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:558:23 +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:558:5 | LL | #[suggestion_part()] - | ^ + | ^^^^^^^^^^^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:567:5 @@ -363,6 +347,12 @@ error: `#[suggestion_part(...)]` attribute without `code = "..."` LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:578:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + error: `code` is the only valid nested attribute --> $DIR/subdiagnostic-derive.rs:581:23 | @@ -381,18 +371,6 @@ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:578:23 - | -LL | #[suggestion_part()] - | ^ - -error: expected `,` - --> $DIR/subdiagnostic-derive.rs:581:27 - | -LL | #[suggestion_part(foo = "bar")] - | ^ - error: specified multiple times --> $DIR/subdiagnostic-derive.rs:596:37 | @@ -417,48 +395,24 @@ error: expected exactly one string literal for `code = ...` LL | #[suggestion_part(code("foo"))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:673:28 - | -LL | #[suggestion_part(code("foo"))] - | ^^^^^ - error: expected exactly one string literal for `code = ...` --> $DIR/subdiagnostic-derive.rs:683:41 | LL | #[suggestion_part(code("foo", "bar"))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:683:28 - | -LL | #[suggestion_part(code("foo", "bar"))] - | ^^^^^ - error: expected exactly one string literal for `code = ...` --> $DIR/subdiagnostic-derive.rs:693:30 | LL | #[suggestion_part(code(3))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:693:28 - | -LL | #[suggestion_part(code(3))] - | ^ - error: expected exactly one string literal for `code = ...` --> $DIR/subdiagnostic-derive.rs:703:29 | LL | #[suggestion_part(code())] | ^ -error: expected string literal - --> $DIR/subdiagnostic-derive.rs:715:30 - | -LL | #[suggestion_part(code = 3)] - | ^ - error: specified multiple times --> $DIR/subdiagnostic-derive.rs:757:1 | @@ -513,12 +467,6 @@ error: expected `= "xxx"` LL | #[suggestion(no_crate_example, code = "", style("foo"))] | ^ -error: expected `,` - --> $DIR/subdiagnostic-derive.rs:806:48 - | -LL | #[suggestion(no_crate_example, code = "", style("foo"))] - | ^ - error: `#[primary_span]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:818:5 | @@ -540,6 +488,54 @@ LL | | sub: Vec, LL | | } | |_^ +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:97:9 + | +LL | #[label("...")] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:312:1 + | +LL | union AC { + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:581:27 + | +LL | #[suggestion_part(foo = "bar")] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:673:28 + | +LL | #[suggestion_part(code("foo"))] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:683:28 + | +LL | #[suggestion_part(code("foo", "bar"))] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:693:28 + | +LL | #[suggestion_part(code(3))] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:715:30 + | +LL | #[suggestion_part(code = 3)] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:806:48 + | +LL | #[suggestion(no_crate_example, code = "", style("foo"))] + | ^ maybe a missing crate `core`? + error: cannot find attribute `foo` in this scope --> $DIR/subdiagnostic-derive.rs:68:3 | @@ -610,4 +606,5 @@ LL | #[derive(Subdiagnostic)] error: aborting due to 86 previous errors -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. From ad8303739f9f62827e2192eb991b951809369a54 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 26 Jul 2023 08:42:40 +0000 Subject: [PATCH 069/150] Bump syn dependency --- .../session-diagnostic/diagnostic-derive.rs | 8 +- .../subdiagnostic-derive.rs | 30 ++-- .../subdiagnostic-derive.stderr | 166 +++++++++--------- 3 files changed, 106 insertions(+), 98 deletions(-) diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index ffbefce48d3e..c30120e5cf3a 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -53,7 +53,7 @@ enum DiagnosticOnEnum { #[derive(Diagnostic)] #[diag(no_crate_example, code = "E0123")] #[diag = "E0123"] -//~^ ERROR expected parentheses: #[diag(...)] +//~^ ERROR failed to resolve: maybe a missing crate `core` struct WrongStructAttrStyle {} #[derive(Diagnostic)] @@ -644,7 +644,7 @@ struct MissingCodeInSuggestion { //~| ERROR cannot find attribute `multipart_suggestion` in this scope #[multipart_suggestion()] //~^ ERROR cannot find attribute `multipart_suggestion` in this scope -//~| ERROR unexpected end of input, unexpected token in nested attribute, expected ident +//~| ERROR `#[multipart_suggestion(...)]` is not a valid attribute struct MultipartSuggestion { #[multipart_suggestion(no_crate_suggestion)] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute @@ -797,7 +797,7 @@ struct SuggestionsNoItem { struct SuggestionsInvalidItem { #[suggestion(code(foo))] //~^ ERROR `code(...)` must contain only string literals - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core` sub: Span, } @@ -805,7 +805,7 @@ struct SuggestionsInvalidItem { #[diag(no_crate_example)] struct SuggestionsInvalidLiteral { #[suggestion(code = 3)] - //~^ ERROR expected string literal + //~^ ERROR failed to resolve: maybe a missing crate `core` sub: Span, } diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 38af5b0f9fb1..dd0f7a7efb71 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -95,7 +95,8 @@ struct G { #[derive(Subdiagnostic)] #[label("...")] -//~^ ERROR unexpected literal in nested attribute, expected ident +//~^ ERROR failed to resolve: maybe a missing crate `core`? +//~| NOTE maybe a missing crate `core`? struct H { #[primary_span] span: Span, @@ -134,7 +135,7 @@ struct L { #[derive(Subdiagnostic)] #[label()] -//~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident +//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute struct M { #[primary_span] span: Span, @@ -310,7 +311,8 @@ struct AB { #[derive(Subdiagnostic)] union AC { - //~^ ERROR unexpected unsupported untagged union + //~^ ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: u32, b: u64, } @@ -556,7 +558,7 @@ struct BBb { #[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] - //~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, } @@ -576,11 +578,12 @@ struct BD { //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, #[suggestion_part()] - //~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span2: Span, #[suggestion_part(foo = "bar")] //~^ ERROR `code` is the only valid nested attribute - //~| ERROR expected `,` + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span4: Span, #[suggestion_part(code = "...")] //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` @@ -672,7 +675,8 @@ enum BL { struct BM { #[suggestion_part(code("foo"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -682,7 +686,8 @@ struct BM { struct BN { #[suggestion_part(code("foo", "bar"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -692,7 +697,8 @@ struct BN { struct BO { #[suggestion_part(code(3))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -713,7 +719,8 @@ struct BP { #[multipart_suggestion(no_crate_example)] struct BQ { #[suggestion_part(code = 3)] - //~^ ERROR expected string literal + //~^ ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -805,7 +812,8 @@ struct SuggestionStyleInvalid3 { #[derive(Subdiagnostic)] #[suggestion(no_crate_example, code = "", style("foo"))] //~^ ERROR expected `= "xxx"` -//~| ERROr expected `,` +//~| ERROR failed to resolve: maybe a missing crate `core`? +//~| NOTE maybe a missing crate `core`? struct SuggestionStyleInvalid4 { #[primary_span] sub: Span, diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 1dedd68914e3..1f267aceb9ef 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -39,97 +39,97 @@ LL | #[label(bug = "...")] | ^^^^^^^^^^^^^^^^^^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:106:9 + --> $DIR/subdiagnostic-derive.rs:107:9 | LL | #[label(slug = 4)] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:106:1 + --> $DIR/subdiagnostic-derive.rs:107:1 | LL | #[label(slug = 4)] | ^^^^^^^^^^^^^^^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:116:9 + --> $DIR/subdiagnostic-derive.rs:117:9 | LL | #[label(slug("..."))] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:116:1 + --> $DIR/subdiagnostic-derive.rs:117:1 | LL | #[label(slug("..."))] | ^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:136:1 + --> $DIR/subdiagnostic-derive.rs:137:1 | LL | #[label()] | ^^^^^^^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:145:27 + --> $DIR/subdiagnostic-derive.rs:146:27 | LL | #[label(no_crate_example, code = "...")] | ^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:154:27 + --> $DIR/subdiagnostic-derive.rs:155:27 | LL | #[label(no_crate_example, applicability = "machine-applicable")] | ^^^^^^^^^^^^^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:163:1 + --> $DIR/subdiagnostic-derive.rs:164:1 | LL | #[foo] | ^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:177:5 + --> $DIR/subdiagnostic-derive.rs:178:5 | LL | #[bar] | ^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:189:5 + --> $DIR/subdiagnostic-derive.rs:190:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:201:5 + --> $DIR/subdiagnostic-derive.rs:202:5 | LL | #[bar = 4] | ^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:213:5 + --> $DIR/subdiagnostic-derive.rs:214:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ error: only `no_span` is a valid nested attribute - --> $DIR/subdiagnostic-derive.rs:225:13 + --> $DIR/subdiagnostic-derive.rs:226:13 | LL | #[label(code = "...")] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:225:5 + --> $DIR/subdiagnostic-derive.rs:226:5 | LL | #[label(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^ error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:254:5 + --> $DIR/subdiagnostic-derive.rs:255:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:251:1 + --> $DIR/subdiagnostic-derive.rs:252:1 | LL | / #[label(no_crate_example)] LL | | @@ -141,13 +141,13 @@ LL | | } | |_^ error: `#[applicability]` is only valid on suggestions - --> $DIR/subdiagnostic-derive.rs:264:5 + --> $DIR/subdiagnostic-derive.rs:265:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:274:5 + --> $DIR/subdiagnostic-derive.rs:275:5 | LL | #[bar] | ^^^^^^ @@ -155,13 +155,13 @@ LL | #[bar] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:285:5 + --> $DIR/subdiagnostic-derive.rs:286:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:296:5 + --> $DIR/subdiagnostic-derive.rs:297:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ @@ -169,73 +169,73 @@ LL | #[bar("...")] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:327:44 + --> $DIR/subdiagnostic-derive.rs:329:44 | LL | #[label(no_crate_example, no_crate::example)] | ^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:340:5 + --> $DIR/subdiagnostic-derive.rs:342:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:337:5 + --> $DIR/subdiagnostic-derive.rs:339:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:346:8 + --> $DIR/subdiagnostic-derive.rs:348:8 | LL | struct AG { | ^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:383:46 + --> $DIR/subdiagnostic-derive.rs:385:46 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:383:32 + --> $DIR/subdiagnostic-derive.rs:385:32 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:401:5 + --> $DIR/subdiagnostic-derive.rs:403:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:398:5 + --> $DIR/subdiagnostic-derive.rs:400:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` - --> $DIR/subdiagnostic-derive.rs:411:5 + --> $DIR/subdiagnostic-derive.rs:413:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:424:1 + --> $DIR/subdiagnostic-derive.rs:426:1 | LL | #[suggestion(no_crate_example)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:434:62 + --> $DIR/subdiagnostic-derive.rs:436:62 | LL | #[suggestion(no_crate_example, code = "...", applicability = "foo")] | ^^^^^ error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:452:1 + --> $DIR/subdiagnostic-derive.rs:454:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -245,25 +245,25 @@ LL | | } | |_^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:466:1 + --> $DIR/subdiagnostic-derive.rs:468:1 | LL | #[label] | ^^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:486:39 + --> $DIR/subdiagnostic-derive.rs:488:39 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:505:43 + --> $DIR/subdiagnostic-derive.rs:507:43 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `#[suggestion_part]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:528:5 + --> $DIR/subdiagnostic-derive.rs:530:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | #[suggestion_part] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead error: `#[suggestion_part(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:531:5 + --> $DIR/subdiagnostic-derive.rs:533:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -279,7 +279,7 @@ LL | #[suggestion_part(code = "...")] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:525:1 + --> $DIR/subdiagnostic-derive.rs:527:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -291,7 +291,7 @@ LL | | } | |_^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:540:42 + --> $DIR/subdiagnostic-derive.rs:542:42 | LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] | ^^^^ @@ -299,7 +299,7 @@ LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "mac = help: only `no_span`, `style` and `applicability` are valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:540:1 + --> $DIR/subdiagnostic-derive.rs:542:1 | LL | / #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] LL | | @@ -310,19 +310,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:550:5 + --> $DIR/subdiagnostic-derive.rs:552:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:558:5 + --> $DIR/subdiagnostic-derive.rs:560:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:567:5 + --> $DIR/subdiagnostic-derive.rs:569:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -330,7 +330,7 @@ LL | #[primary_span] = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:564:1 + --> $DIR/subdiagnostic-derive.rs:566:1 | LL | / #[multipart_suggestion(no_crate_example)] LL | | @@ -342,91 +342,91 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:575:5 + --> $DIR/subdiagnostic-derive.rs:577:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:578:5 + --> $DIR/subdiagnostic-derive.rs:580:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: `code` is the only valid nested attribute - --> $DIR/subdiagnostic-derive.rs:581:23 + --> $DIR/subdiagnostic-derive.rs:583:23 | LL | #[suggestion_part(foo = "bar")] | ^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:585:5 + --> $DIR/subdiagnostic-derive.rs:588:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:588:5 + --> $DIR/subdiagnostic-derive.rs:591:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:596:37 + --> $DIR/subdiagnostic-derive.rs:599:37 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:596:23 + --> $DIR/subdiagnostic-derive.rs:599:23 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` - --> $DIR/subdiagnostic-derive.rs:625:5 + --> $DIR/subdiagnostic-derive.rs:628:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:673:34 + --> $DIR/subdiagnostic-derive.rs:676:34 | LL | #[suggestion_part(code("foo"))] | ^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:683:41 + --> $DIR/subdiagnostic-derive.rs:687:41 | LL | #[suggestion_part(code("foo", "bar"))] | ^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:693:30 + --> $DIR/subdiagnostic-derive.rs:698:30 | LL | #[suggestion_part(code(3))] | ^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:703:29 + --> $DIR/subdiagnostic-derive.rs:709:29 | LL | #[suggestion_part(code())] | ^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:757:1 + --> $DIR/subdiagnostic-derive.rs:764:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:757:1 + --> $DIR/subdiagnostic-derive.rs:764:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:766:1 + --> $DIR/subdiagnostic-derive.rs:773:1 | LL | #[suggestion_hidden(no_crate_example, code = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -434,7 +434,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:774:1 + --> $DIR/subdiagnostic-derive.rs:781:1 | LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -442,7 +442,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: invalid suggestion style - --> $DIR/subdiagnostic-derive.rs:782:51 + --> $DIR/subdiagnostic-derive.rs:789:51 | LL | #[suggestion(no_crate_example, code = "", style = "foo")] | ^^^^^ @@ -450,25 +450,25 @@ LL | #[suggestion(no_crate_example, code = "", style = "foo")] = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:790:49 + --> $DIR/subdiagnostic-derive.rs:797:49 | LL | #[suggestion(no_crate_example, code = "", style = 42)] | ^ error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:798:48 + --> $DIR/subdiagnostic-derive.rs:805:48 | LL | #[suggestion(no_crate_example, code = "", style)] | ^ error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:806:48 + --> $DIR/subdiagnostic-derive.rs:813:48 | LL | #[suggestion(no_crate_example, code = "", style("foo"))] | ^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:818:5 + --> $DIR/subdiagnostic-derive.rs:826:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -477,7 +477,7 @@ LL | #[primary_span] = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:815:1 + --> $DIR/subdiagnostic-derive.rs:823:1 | LL | / #[suggestion(no_crate_example, code = "")] LL | | @@ -495,43 +495,43 @@ LL | #[label("...")] | ^^^^^ maybe a missing crate `core`? error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/subdiagnostic-derive.rs:312:1 + --> $DIR/subdiagnostic-derive.rs:313:1 | LL | union AC { | ^^^^^ maybe a missing crate `core`? error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/subdiagnostic-derive.rs:581:27 + --> $DIR/subdiagnostic-derive.rs:583:27 | LL | #[suggestion_part(foo = "bar")] | ^ maybe a missing crate `core`? error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/subdiagnostic-derive.rs:673:28 + --> $DIR/subdiagnostic-derive.rs:676:28 | LL | #[suggestion_part(code("foo"))] | ^^^^^ maybe a missing crate `core`? error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/subdiagnostic-derive.rs:683:28 + --> $DIR/subdiagnostic-derive.rs:687:28 | LL | #[suggestion_part(code("foo", "bar"))] | ^^^^^ maybe a missing crate `core`? error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/subdiagnostic-derive.rs:693:28 + --> $DIR/subdiagnostic-derive.rs:698:28 | LL | #[suggestion_part(code(3))] | ^ maybe a missing crate `core`? error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/subdiagnostic-derive.rs:715:30 + --> $DIR/subdiagnostic-derive.rs:721:30 | LL | #[suggestion_part(code = 3)] | ^ maybe a missing crate `core`? error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/subdiagnostic-derive.rs:806:48 + --> $DIR/subdiagnostic-derive.rs:813:48 | LL | #[suggestion(no_crate_example, code = "", style("foo"))] | ^ maybe a missing crate `core`? @@ -543,61 +543,61 @@ LL | #[foo] | ^^^ error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive.rs:163:3 + --> $DIR/subdiagnostic-derive.rs:164:3 | LL | #[foo] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:177:7 + --> $DIR/subdiagnostic-derive.rs:178:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:189:7 + --> $DIR/subdiagnostic-derive.rs:190:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:201:7 + --> $DIR/subdiagnostic-derive.rs:202:7 | LL | #[bar = 4] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:213:7 + --> $DIR/subdiagnostic-derive.rs:214:7 | LL | #[bar("...")] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:274:7 + --> $DIR/subdiagnostic-derive.rs:275:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:285:7 + --> $DIR/subdiagnostic-derive.rs:286:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:296:7 + --> $DIR/subdiagnostic-derive.rs:297:7 | LL | #[bar("...")] | ^^^ error[E0425]: cannot find value `slug` in module `crate::fluent_generated` - --> $DIR/subdiagnostic-derive.rs:126:9 + --> $DIR/subdiagnostic-derive.rs:127:9 | LL | #[label(slug)] | ^^^^ not found in `crate::fluent_generated` error[E0425]: cannot find value `__code_29` in this scope - --> $DIR/subdiagnostic-derive.rs:709:10 + --> $DIR/subdiagnostic-derive.rs:715:10 | LL | #[derive(Subdiagnostic)] | ^^^^^^^^^^^^^ not found in this scope From 075a6bbef960a7be4cebc6f6b9b7a3d6212f56a6 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 10 Mar 2023 12:50:02 +0100 Subject: [PATCH 070/150] Regression test `println!()` panic message on `ErrorKind::BrokenPipe` No existing test failed if the [`panic!()`][1] of the `println!()` family of functions was removed, or if its message was changed. So add such a test. [1] https://github.com/rust-lang/rust/blob/104f4300cfddbd956e32820ef202a732f06ec848/library/std/src/io/stdio.rs#L1007-L1009 --- tests/ui/process/println-with-broken-pipe.rs | 44 +++++++++++++++++++ .../println-with-broken-pipe.run.stderr | 2 + .../println-with-broken-pipe.run.stdout | 1 + 3 files changed, 47 insertions(+) create mode 100644 tests/ui/process/println-with-broken-pipe.rs create mode 100644 tests/ui/process/println-with-broken-pipe.run.stderr create mode 100644 tests/ui/process/println-with-broken-pipe.run.stdout diff --git a/tests/ui/process/println-with-broken-pipe.rs b/tests/ui/process/println-with-broken-pipe.rs new file mode 100644 index 000000000000..47c590ce2f01 --- /dev/null +++ b/tests/ui/process/println-with-broken-pipe.rs @@ -0,0 +1,44 @@ +// run-pass +// check-run-results +// ignore-windows +// ignore-emscripten +// ignore-fuchsia +// ignore-horizon +// ignore-android +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" + +// Test what the error message looks like when `println!()` panics because of +// `std::io::ErrorKind::BrokenPipe` + +#![feature(unix_sigpipe)] + +use std::env; +use std::process::{Command, Stdio}; + +#[unix_sigpipe = "sig_ign"] +fn main() { + let mut args = env::args(); + let me = args.next().unwrap(); + + if let Some(arg) = args.next() { + // More than enough iterations to fill any pipe buffer. Normally this + // loop will end with a panic more or less immediately. + for _ in 0..65536 * 64 { + println!("{arg}"); + } + unreachable!("should have panicked because of BrokenPipe"); + } + + // Set up a pipeline with a short-lived consumer and wait for it to finish. + // This will produce the `println!()` panic message on stderr. + let mut producer = Command::new(&me) + .arg("this line shall appear exactly once on stdout") + .env("RUST_BACKTRACE", "0") + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + let mut consumer = + Command::new("head").arg("-n1").stdin(producer.stdout.take().unwrap()).spawn().unwrap(); + consumer.wait().unwrap(); + producer.wait().unwrap(); +} diff --git a/tests/ui/process/println-with-broken-pipe.run.stderr b/tests/ui/process/println-with-broken-pipe.run.stderr new file mode 100644 index 000000000000..ebcd920d501f --- /dev/null +++ b/tests/ui/process/println-with-broken-pipe.run.stderr @@ -0,0 +1,2 @@ +thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/process/println-with-broken-pipe.run.stdout b/tests/ui/process/println-with-broken-pipe.run.stdout new file mode 100644 index 000000000000..f55c39578b10 --- /dev/null +++ b/tests/ui/process/println-with-broken-pipe.run.stdout @@ -0,0 +1 @@ +this line shall appear exactly once on stdout From 9f47ff84e34593662e70d825e42aae2321da9b05 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 26 Jul 2023 19:02:26 +0700 Subject: [PATCH 071/150] docs: fmt::Debug*: Fix comments for finish method. In the code sample for the `finish` method on `DebugList`, `DebugMap`, and `DebugSet`, refer to finishing the list, map, or set, rather than struct as it did. --- library/core/src/fmt/builders.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs index 36f49d51ca6d..d2c9f9800420 100644 --- a/library/core/src/fmt/builders.rs +++ b/library/core/src/fmt/builders.rs @@ -518,7 +518,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> { /// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { /// fmt.debug_set() /// .entries(self.0.iter()) - /// .finish() // Ends the struct formatting. + /// .finish() // Ends the set formatting. /// } /// } /// @@ -648,7 +648,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> { /// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { /// fmt.debug_list() /// .entries(self.0.iter()) - /// .finish() // Ends the struct formatting. + /// .finish() // Ends the list formatting. /// } /// } /// @@ -905,7 +905,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { /// fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { /// fmt.debug_map() /// .entries(self.0.iter().map(|&(ref k, ref v)| (k, v))) - /// .finish() // Ends the struct formatting. + /// .finish() // Ends the map formatting. /// } /// } /// From 48e7f3e313c19d8df1a05f0ccc17ac02e41dda6a Mon Sep 17 00:00:00 2001 From: MoskalykA <100430077+MoskalykA@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:07:57 +0200 Subject: [PATCH 072/150] Have a better file name than just the issue id --- library/std/tests/{issue-15149.rs => process_spawning.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename library/std/tests/{issue-15149.rs => process_spawning.rs} (100%) diff --git a/library/std/tests/issue-15149.rs b/library/std/tests/process_spawning.rs similarity index 100% rename from library/std/tests/issue-15149.rs rename to library/std/tests/process_spawning.rs From 51eb0c3b361093b880009b997dc69cddcd73e9dc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 25 Jul 2023 23:14:09 +0200 Subject: [PATCH 073/150] Fix regression for private in public --- src/librustdoc/clean/mod.rs | 1 + .../auxiliary/jump-to-def-res-err-handling-aux.rs | 1 + tests/rustdoc/private-use.rs | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs create mode 100644 tests/rustdoc/private-use.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 743ba6835db3..998380abfacf 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1584,6 +1584,7 @@ fn first_non_private<'tcx>( if let Some(use_def_id) = reexp.id() && let Some(local_use_def_id) = use_def_id.as_local() && let Some(hir::Node::Item(item)) = hir.find_by_def_id(local_use_def_id) && + !item.ident.name.is_empty() && let hir::ItemKind::Use(path, _) = item.kind { for res in &path.res { diff --git a/tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs b/tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs new file mode 100644 index 000000000000..eacec957a2aa --- /dev/null +++ b/tests/rustdoc/auxiliary/jump-to-def-res-err-handling-aux.rs @@ -0,0 +1 @@ +pub struct Ident; diff --git a/tests/rustdoc/private-use.rs b/tests/rustdoc/private-use.rs new file mode 100644 index 000000000000..689ed73140d9 --- /dev/null +++ b/tests/rustdoc/private-use.rs @@ -0,0 +1,13 @@ +// Regression test for to +// ensure it doesn't panic. + +mod generics { + pub enum WherePredicate { + EqPredicate, + } +} +pub mod visit { + use *; + pub fn visit_where_predicate(_visitor: &mut V, _i: &WherePredicate) {} +} +pub use generics::*; From 31630859cce142d1a31a92f188682dac3f87d8ac Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 26 Jul 2023 18:09:50 +0300 Subject: [PATCH 074/150] replace atty crate with std's isTerminal --- Cargo.lock | 2 -- compiler/rustc_interface/Cargo.toml | 1 - compiler/rustc_interface/src/util.rs | 3 ++- compiler/rustc_session/Cargo.toml | 1 - compiler/rustc_session/src/config.rs | 3 ++- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72f0236fd08a..7898bc549a08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3732,7 +3732,6 @@ dependencies = [ name = "rustc_interface" version = "0.0.0" dependencies = [ - "atty", "libloading", "rustc-rayon", "rustc-rayon-core", @@ -4196,7 +4195,6 @@ dependencies = [ name = "rustc_session" version = "0.0.0" dependencies = [ - "atty", "bitflags 1.3.2", "getopts", "libc", diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index 7826d42dcb2d..2c7438ed9db4 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [lib] [dependencies] -atty = "0.2.13" libloading = "0.7.1" tracing = "0.1" rustc-rayon-core = { version = "0.5.0", optional = true } diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 12d33f06309b..ad35dbbc8f96 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -519,7 +519,8 @@ fn multiple_output_types_to_stdout( output_types: &OutputTypes, single_output_file_is_stdout: bool, ) -> bool { - if atty::is(atty::Stream::Stdout) { + use std::io::IsTerminal; + if std::io::stdout().is_terminal() { // If stdout is a tty, check if multiple text output types are // specified by `--emit foo=- --emit bar=-` or `-o - --emit foo,bar` let named_text_types = output_types diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index 1291d1454a6e..e26d25d9a412 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -4,7 +4,6 @@ version = "0.0.0" edition = "2021" [dependencies] -atty = "0.2.13" bitflags = "1.2.1" getopts = "0.2" rustc_macros = { path = "../rustc_macros" } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 36b5c385ab19..f75cd2ae7765 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -834,9 +834,10 @@ impl OutFileName { } pub fn is_tty(&self) -> bool { + use std::io::IsTerminal; match *self { OutFileName::Real(_) => false, - OutFileName::Stdout => atty::is(atty::Stream::Stdout), + OutFileName::Stdout => std::io::stdout().is_terminal(), } } From 1794466c00379de37441ef605eff5e6a3d3a8b85 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 26 Jul 2023 18:43:40 +0000 Subject: [PATCH 075/150] Dont pass -Zwrite-long-types-to-disk=no for ui-fulldeps --stage=1 --- src/tools/compiletest/src/runtest.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ba068995d44a..45582ddcbafc 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2330,7 +2330,14 @@ impl<'test> TestCx<'test> { // Hide line numbers to reduce churn rustc.arg("-Zui-testing"); rustc.arg("-Zdeduplicate-diagnostics=no"); - rustc.arg("-Zwrite-long-types-to-disk=no"); + // #[cfg(not(bootstrap)] unconditionally pass flag after beta bump + // since `ui-fulldeps --stage=1` builds using the stage 0 compiler, + // which doesn't have this flag. + if !(self.config.stage_id.starts_with("stage1-") + && self.config.suite == "ui-fulldeps") + { + rustc.arg("-Zwrite-long-types-to-disk=no"); + } // FIXME: use this for other modes too, for perf? rustc.arg("-Cstrip=debuginfo"); } From 9439e02fb2332d6ffed6a61f95923204faa82655 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 3 Jul 2023 13:40:14 -0400 Subject: [PATCH 076/150] Unite bless environment variables under `RUSTC_BLESS` Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to indicate that output should be blessed, but they use different variable names. In order to improve consistency, this patch applies the following changes: - Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always available - Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS` - Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS` - Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS` - Adjust the blessable test in `rustc_errors` to use this same convention - Update documentation where applicable Any tools that uses `RUSTC_BLESS` should check that it is set to any value other than `"0"`. --- .../rustc_errors/src/markdown/tests/term.rs | 2 +- src/bootstrap/test.rs | 25 ++++++------------- src/tools/clippy/tests/compile-test.rs | 4 ++- src/tools/miri/README.md | 2 +- src/tools/miri/miri | 2 +- src/tools/miri/test-cargo-miri/run-test.py | 5 ++-- src/tools/miri/tests/compiletest.rs | 5 ++-- src/tools/rustfmt/src/test/mod.rs | 8 +++--- 8 files changed, 22 insertions(+), 31 deletions(-) diff --git a/compiler/rustc_errors/src/markdown/tests/term.rs b/compiler/rustc_errors/src/markdown/tests/term.rs index 3b31c6d6295a..6f68fb25a589 100644 --- a/compiler/rustc_errors/src/markdown/tests/term.rs +++ b/compiler/rustc_errors/src/markdown/tests/term.rs @@ -63,7 +63,7 @@ fn test_wrapping_write() { #[test] fn test_output() { // Capture `--bless` when run via ./x - let bless = std::env::var("RUSTC_BLESS").unwrap_or_default() == "1"; + let bless = std::env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0"); let ast = MdStream::parse_str(INPUT); let bufwtr = BufferWriter::stderr(ColorChoice::Always); let mut buffer = bufwtr.buffer(); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 1fe92098fd6a..820fe5e5294f 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -430,10 +430,6 @@ impl Step for Rustfmt { &[], ); - if builder.config.cmd.bless() { - cargo.env("BLESS", "1"); - } - let dir = testdir(builder, compiler.host); t!(fs::create_dir_all(&dir)); cargo.env("RUSTFMT_TEST_DIR", dir); @@ -633,10 +629,6 @@ impl Step for Miri { cargo.env("MIRI_SYSROOT", &miri_sysroot); cargo.env("MIRI_HOST_SYSROOT", sysroot); cargo.env("MIRI", &miri); - // propagate --bless - if builder.config.cmd.bless() { - cargo.env("MIRI_BLESS", "Gesundheit"); - } // Set the target. cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg()); @@ -654,8 +646,8 @@ impl Step for Miri { cargo.env("MIRIFLAGS", "-O -Zmir-opt-level=4 -Cdebug-assertions=yes"); // Optimizations can change backtraces cargo.env("MIRI_SKIP_UI_CHECKS", "1"); - // `MIRI_SKIP_UI_CHECKS` and `MIRI_BLESS` are incompatible - cargo.env_remove("MIRI_BLESS"); + // `MIRI_SKIP_UI_CHECKS` and `RUSTC_BLESS` are incompatible + cargo.env_remove("RUSTC_BLESS"); // Optimizations can change error locations and remove UB so don't run `fail` tests. cargo.args(&["tests/pass", "tests/panic"]); @@ -799,11 +791,6 @@ impl Step for Clippy { cargo.add_rustc_lib_path(builder, compiler); let mut cargo = prepare_cargo_test(cargo, &[], &[], "clippy", compiler, host, builder); - // propagate --bless - if builder.config.cmd.bless() { - cargo.env("BLESS", "Gesundheit"); - } - let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host); #[allow(deprecated)] // Clippy reports errors if it blessed the outputs @@ -2245,9 +2232,11 @@ fn prepare_cargo_test( ) -> Command { let mut cargo = cargo.into(); - // If bless is passed, give downstream crates a way to use it - if builder.config.cmd.bless() { - cargo.env("RUSTC_BLESS", "1"); + // Propegate `--bless` if it has not already been set/unset + // Any tools that want to use this should bless if `RUSTC_BLESS` is set to + // anything other than `0`. + if builder.config.cmd.bless() && !cargo.get_envs().any(|v| v.0 == "RUSTC_BLESS") { + cargo.env("RUSTC_BLESS", "Gesundheit"); } // Pass in some standard flags then iterate over the graph we've discovered diff --git a/src/tools/clippy/tests/compile-test.rs b/src/tools/clippy/tests/compile-test.rs index d70c4ea34cbc..f714b2962331 100644 --- a/src/tools/clippy/tests/compile-test.rs +++ b/src/tools/clippy/tests/compile-test.rs @@ -115,7 +115,9 @@ fn base_config(test_dir: &str) -> compiletest::Config { mode: TestMode::Yolo, stderr_filters: vec![], stdout_filters: vec![], - output_conflict_handling: if var_os("BLESS").is_some() || env::args().any(|arg| arg == "--bless") { + // FIXME(tgross35): deduplicate bless env once clippy can update + output_conflict_handling: if var_os("RUSTC_BLESS").is_some_and(|v| v != "0") + || env::args().any(|arg| arg == "--bless") { compiletest::OutputConflictHandling::Bless } else { compiletest::OutputConflictHandling::Error("cargo test -- -- --bless".into()) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index eaf58340d7b1..89d4b29ebb89 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -482,7 +482,7 @@ Moreover, Miri recognizes some environment variables: purpose. * `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's sysroot is built without libstd. This allows testing and running no_std programs. -* `MIRI_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all +* `RUSTC_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all `stderr` and `stdout` files instead of checking whether the output matches. * `MIRI_SKIP_UI_CHECKS` (recognized by the test suite): don't check whether the `stderr` or `stdout` files match the actual output. diff --git a/src/tools/miri/miri b/src/tools/miri/miri index 1bc4e254ad4a..bccf6d835ff8 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -303,7 +303,7 @@ test|bless) $CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml find_sysroot if [ "$COMMAND" = "bless" ]; then - export MIRI_BLESS="Gesundheit" + export RUSTC_BLESS="Gesundheit" fi # Then test, and let caller control flags. # Only in root project as `cargo-miri` has no tests. diff --git a/src/tools/miri/test-cargo-miri/run-test.py b/src/tools/miri/test-cargo-miri/run-test.py index f022c51e59fa..ca2f69fc8cfa 100755 --- a/src/tools/miri/test-cargo-miri/run-test.py +++ b/src/tools/miri/test-cargo-miri/run-test.py @@ -8,8 +8,8 @@ and the working directory to contain the cargo-miri-test project. import difflib import os import re -import sys import subprocess +import sys CGREEN = '\33[32m' CBOLD = '\33[1m' @@ -37,7 +37,8 @@ def normalize_stderr(str): return str def check_output(actual, path, name): - if 'MIRI_BLESS' in os.environ: + if os.environ.get("RUSTC_BLESS", "0") != "0": + # Write the output only if bless is set open(path, mode='w').write(actual) return True expected = open(path).read() diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index 59143550253d..c26954da2720 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -72,13 +72,14 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> program.args.push(flag); } + let bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v !="0"); let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some(); - let output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) { + let output_conflict_handling = match (bless, skip_ui_checks) { (false, false) => OutputConflictHandling::Error("./miri bless".into()), (true, false) => OutputConflictHandling::Bless, (false, true) => OutputConflictHandling::Ignore, - (true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"), + (true, true) => panic!("cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time"), }; let mut config = Config { diff --git a/src/tools/rustfmt/src/test/mod.rs b/src/tools/rustfmt/src/test/mod.rs index 364aa225f680..37854ead28bf 100644 --- a/src/tools/rustfmt/src/test/mod.rs +++ b/src/tools/rustfmt/src/test/mod.rs @@ -838,11 +838,9 @@ fn handle_result( // Ignore LF and CRLF difference for Windows. if !string_eq_ignore_newline_repr(&fmt_text, &text) { - if let Some(bless) = std::env::var_os("BLESS") { - if bless != "0" { - std::fs::write(file_name, fmt_text).unwrap(); - continue; - } + if std::env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0") { + std::fs::write(file_name, fmt_text).unwrap(); + continue; } let diff = make_diff(&text, &fmt_text, DIFF_CONTEXT_SIZE); assert!( From 6776265d1b217d245a8054a8d7ab902369c048c9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 26 Jul 2023 14:54:56 -0600 Subject: [PATCH 077/150] Update LLVM submodule This adds https://github.com/rust-lang/llvm-project/pull/148. --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 06248fa7f351..a7d11c453784 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 06248fa7f35136f66114b2f82c29abcefd5f1e9b +Subproject commit a7d11c453784a3f258c7269b5108c58592d27e1a From 37216f85a1c0f1647e518c638250222d111f78aa Mon Sep 17 00:00:00 2001 From: jyn Date: Wed, 26 Jul 2023 14:43:15 -0700 Subject: [PATCH 078/150] Prevent people from assigning me as a PR reviewer --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index cc26c3b3e7b9..bfc14b24d6eb 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -498,6 +498,7 @@ cc = ["@nnethercote"] [assign] warn_non_default_branch = true contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html" +users_on_vacation = ["jyn514"] [assign.adhoc_groups] compiler-team = [ From 0169ce968c6489cc9acf107b558fa05f6ab430d2 Mon Sep 17 00:00:00 2001 From: Veera Date: Wed, 26 Jul 2023 17:57:56 -0500 Subject: [PATCH 079/150] Fix URL for `rmatches` --- library/core/src/str/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 9a93bb72903f..07a5990e5957 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -1666,7 +1666,7 @@ impl str { /// If the pattern allows a reverse search but its results might differ /// from a forward search, the [`rmatches`] method can be used. /// - /// [`rmatches`]: str::matches + /// [`rmatches`]: str::rmatches /// /// # Examples /// From 3cd3a91dbc50c71a3d51a32ac35a10869847c035 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 26 Jul 2023 16:00:05 -0700 Subject: [PATCH 080/150] ci: use `armv7-a+fp` for `armv7-unknown-linux_musleabihf` This is consistent with what we had from `arm-linux-gnueabihf-gcc` in the `ubuntu:20.04` base. --- src/ci/docker/host-x86_64/dist-various-1/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile index 99cb1d70147b..8f4ad0f4e755 100644 --- a/src/ci/docker/host-x86_64/dist-various-1/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-1/Dockerfile @@ -74,8 +74,8 @@ RUN env \ CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm -mfpu=vfp" \ bash musl.sh armhf && \ env \ - CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a -mfpu=vfp3" \ - CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a -mfpu=vfp3" \ + CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a+fp" \ + CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a+fp" \ bash musl.sh armv7hf && \ env \ CC=mips-openwrt-linux-gcc \ @@ -148,7 +148,7 @@ ENV TARGETS=$TARGETS,armv7a-none-eabi ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" \ CFLAGS_arm_unknown_linux_musleabi="-march=armv6 -marm" \ CFLAGS_arm_unknown_linux_musleabihf="-march=armv6 -marm -mfpu=vfp" \ - CFLAGS_armv7_unknown_linux_musleabihf="-march=armv7-a -mfpu=vfp3" \ + CFLAGS_armv7_unknown_linux_musleabihf="-march=armv7-a+fp" \ CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ CC_mips64el_unknown_linux_muslabi64=mips64el-linux-gnuabi64-gcc \ From 53379a7b65055fc272db1178f68c9cef9b4aa3bc Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 09:39:28 +1000 Subject: [PATCH 081/150] Simplify the `ttdelim_span` test. The existing code is a very complex and inefficient way to the get the span of the last token. --- compiler/rustc_expand/src/parse/tests.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index 8b37728b60fe..f891850963ea 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -294,9 +294,7 @@ fn ttdelim_span() { .unwrap(); let ast::ExprKind::MacCall(mac) = &expr.kind else { panic!("not a macro") }; - let tts: Vec<_> = mac.args.tokens.clone().into_trees().collect(); - - let span = tts.iter().rev().next().unwrap().span(); + let span = mac.args.tokens.trees().last().unwrap().span(); match sess.source_map().span_to_snippet(span) { Ok(s) => assert_eq!(&s[..], "{ body }"), From a9d84592995c18b33f69e85735210c50438596e1 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 10:40:39 +1000 Subject: [PATCH 082/150] Replace `into_trees` with `trees` in a test. There's no need for token tree cloning here. --- compiler/rustc_expand/src/parse/tests.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index f891850963ea..541f26862358 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -63,9 +63,8 @@ fn bad_path_expr_1() { #[test] fn string_to_tts_macro() { create_default_session_globals_then(|| { - let tts: Vec<_> = - string_to_stream("macro_rules! zip (($a)=>($a))".to_string()).into_trees().collect(); - let tts: &[TokenTree] = &tts[..]; + let stream = string_to_stream("macro_rules! zip (($a)=>($a))".to_string()); + let tts = &stream.trees().collect::>()[..]; match tts { [ From 103bd4a8208d813a958f3d3653c687be577ec3c2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 10:00:04 +1000 Subject: [PATCH 083/150] Use `TokenStream::trees` instead of `into_trees` for attributes. This avoids cloning some token trees. A couple of `clone` calls were inserted, but only on some paths, and the next commit will remove them. --- compiler/rustc_ast/src/attr/mod.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 15fe29580c29..466765f2dbfd 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -285,12 +285,12 @@ impl MetaItem { self.kind.value_str() } - fn from_tokens(tokens: &mut iter::Peekable) -> Option + fn from_tokens<'a, I>(tokens: &mut iter::Peekable) -> Option where - I: Iterator, + I: Iterator, { // FIXME: Share code with `parse_path`. - let path = match tokens.next().map(TokenTree::uninterpolate) { + let path = match tokens.next().map(|tt| TokenTree::uninterpolate(tt.clone())) { Some(TokenTree::Token( Token { kind: kind @ (token::Ident(..) | token::ModSep), span }, _, @@ -309,7 +309,7 @@ impl MetaItem { }; loop { if let Some(TokenTree::Token(Token { kind: token::Ident(name, _), span }, _)) = - tokens.next().map(TokenTree::uninterpolate) + tokens.next().map(|tt| TokenTree::uninterpolate(tt.clone())) { segments.push(PathSegment::from_ident(Ident::new(name, span))); } else { @@ -354,7 +354,7 @@ impl MetaItemKind { } fn list_from_tokens(tokens: TokenStream) -> Option> { - let mut tokens = tokens.into_trees().peekable(); + let mut tokens = tokens.trees().peekable(); let mut result = ThinVec::new(); while tokens.peek().is_some() { let item = NestedMetaItem::from_tokens(&mut tokens)?; @@ -367,12 +367,12 @@ impl MetaItemKind { Some(result) } - fn name_value_from_tokens( - tokens: &mut impl Iterator, + fn name_value_from_tokens<'a>( + tokens: &mut impl Iterator, ) -> Option { match tokens.next() { Some(TokenTree::Delimited(_, Delimiter::Invisible, inner_tokens)) => { - MetaItemKind::name_value_from_tokens(&mut inner_tokens.into_trees()) + MetaItemKind::name_value_from_tokens(&mut inner_tokens.trees()) } Some(TokenTree::Token(token, _)) => { MetaItemLit::from_token(&token).map(MetaItemKind::NameValue) @@ -381,8 +381,8 @@ impl MetaItemKind { } } - fn from_tokens( - tokens: &mut iter::Peekable>, + fn from_tokens<'a>( + tokens: &mut iter::Peekable>, ) -> Option { match tokens.peek() { Some(TokenTree::Delimited(_, Delimiter::Parenthesis, inner_tokens)) => { @@ -501,9 +501,9 @@ impl NestedMetaItem { self.meta_item().is_some() } - fn from_tokens(tokens: &mut iter::Peekable) -> Option + fn from_tokens<'a, I>(tokens: &mut iter::Peekable) -> Option where - I: Iterator, + I: Iterator, { match tokens.peek() { Some(TokenTree::Token(token, _)) @@ -513,9 +513,8 @@ impl NestedMetaItem { return Some(NestedMetaItem::Lit(lit)); } Some(TokenTree::Delimited(_, Delimiter::Invisible, inner_tokens)) => { - let inner_tokens = inner_tokens.clone(); tokens.next(); - return NestedMetaItem::from_tokens(&mut inner_tokens.into_trees().peekable()); + return NestedMetaItem::from_tokens(&mut inner_tokens.trees().peekable()); } _ => {} } From 55a732461dcd104311b24cc048dcef2ed0c9d57c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 10:10:32 +1000 Subject: [PATCH 084/150] Make `TokenTree::uninterpolate` take `&self` and return a `Cow`. Making it similar to `Token::uninterpolate`. This avoids some more token tree cloning. --- compiler/rustc_ast/src/attr/mod.rs | 14 +++++++------- compiler/rustc_ast/src/tokenstream.rs | 12 +++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 466765f2dbfd..8b9bb1df5dc9 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -290,12 +290,12 @@ impl MetaItem { I: Iterator, { // FIXME: Share code with `parse_path`. - let path = match tokens.next().map(|tt| TokenTree::uninterpolate(tt.clone())) { - Some(TokenTree::Token( - Token { kind: kind @ (token::Ident(..) | token::ModSep), span }, + let path = match tokens.next().map(|tt| TokenTree::uninterpolate(tt)).as_deref() { + Some(&TokenTree::Token( + Token { kind: ref kind @ (token::Ident(..) | token::ModSep), span }, _, )) => 'arm: { - let mut segments = if let token::Ident(name, _) = kind { + let mut segments = if let &token::Ident(name, _) = kind { if let Some(TokenTree::Token(Token { kind: token::ModSep, .. }, _)) = tokens.peek() { @@ -308,8 +308,8 @@ impl MetaItem { thin_vec![PathSegment::path_root(span)] }; loop { - if let Some(TokenTree::Token(Token { kind: token::Ident(name, _), span }, _)) = - tokens.next().map(|tt| TokenTree::uninterpolate(tt.clone())) + if let Some(&TokenTree::Token(Token { kind: token::Ident(name, _), span }, _)) = + tokens.next().map(|tt| TokenTree::uninterpolate(tt)).as_deref() { segments.push(PathSegment::from_ident(Ident::new(name, span))); } else { @@ -326,7 +326,7 @@ impl MetaItem { let span = span.with_hi(segments.last().unwrap().ident.span.hi()); Path { span, segments, tokens: None } } - Some(TokenTree::Token(Token { kind: token::Interpolated(nt), .. }, _)) => match &*nt { + Some(TokenTree::Token(Token { kind: token::Interpolated(nt), .. }, _)) => match &**nt { token::Nonterminal::NtMeta(item) => return item.meta(item.path.span), token::Nonterminal::NtPath(path) => (**path).clone(), _ => return None, diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index ca4a739abd7a..c6f0643147d8 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -25,6 +25,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_span::{Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; +use std::borrow::Cow; use std::{fmt, iter, mem}; /// When the main Rust parser encounters a syntax-extension invocation, it @@ -98,12 +99,13 @@ impl TokenTree { TokenTree::Token(Token::new(kind, span), Spacing::Joint) } - pub fn uninterpolate(self) -> TokenTree { + pub fn uninterpolate(&self) -> Cow<'_, TokenTree> { match self { - TokenTree::Token(token, spacing) => { - TokenTree::Token(token.uninterpolate().into_owned(), spacing) - } - tt => tt, + TokenTree::Token(token, spacing) => match token.uninterpolate() { + Cow::Owned(token) => Cow::Owned(TokenTree::Token(token, *spacing)), + Cow::Borrowed(_) => Cow::Borrowed(self), + }, + _ => Cow::Borrowed(self), } } } From 853f453d576ab18e2282b2d8c64cd7e37dd30382 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 10:50:06 +1000 Subject: [PATCH 085/150] Avoid some token cloning in `filter_tokens_from_list`. Now the cloning only happens on some paths, instead of all paths. --- src/librustdoc/clean/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index d14953f1bb78..bf6b11846399 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2347,19 +2347,19 @@ fn get_all_import_attributes<'hir>( } fn filter_tokens_from_list( - args_tokens: TokenStream, + args_tokens: &TokenStream, should_retain: impl Fn(&TokenTree) -> bool, ) -> Vec { let mut tokens = Vec::with_capacity(args_tokens.len()); let mut skip_next_comma = false; - for token in args_tokens.into_trees() { + for token in args_tokens.trees() { match token { TokenTree::Token(Token { kind: TokenKind::Comma, .. }, _) if skip_next_comma => { skip_next_comma = false; } - token if should_retain(&token) => { + token if should_retain(token) => { skip_next_comma = false; - tokens.push(token); + tokens.push(token.clone()); } _ => { skip_next_comma = true; @@ -2417,7 +2417,7 @@ fn add_without_unwanted_attributes<'hir>( match normal.item.args { ast::AttrArgs::Delimited(ref mut args) => { let tokens = - filter_tokens_from_list(args.tokens.clone(), |token| { + filter_tokens_from_list(&args.tokens, |token| { !matches!( token, TokenTree::Token( From d2f7f67921ac718dcd0547e47f03630a30617743 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 11:04:26 +1000 Subject: [PATCH 086/150] Avoid some token tree cloning in decl macro parsing. By changing `into_trees` into `trees`. Some of the subsequent paths require explicit clones, but not all. --- compiler/rustc_expand/src/mbe/macro_rules.rs | 4 +- compiler/rustc_expand/src/mbe/quoted.rs | 42 ++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 102bae2a7449..7398a124fdb3 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -500,7 +500,7 @@ pub fn compile_declarative_macro( .map(|m| { if let MatchedTokenTree(tt) = m { let tt = mbe::quoted::parse( - TokenStream::new(vec![tt.clone()]), + &TokenStream::new(vec![tt.clone()]), true, &sess.parse_sess, def.id, @@ -524,7 +524,7 @@ pub fn compile_declarative_macro( .map(|m| { if let MatchedTokenTree(tt) = m { return mbe::quoted::parse( - TokenStream::new(vec![tt.clone()]), + &TokenStream::new(vec![tt.clone()]), false, &sess.parse_sess, def.id, diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 40bfa3715be7..ac862ae8c4f8 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -36,7 +36,7 @@ const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \ /// /// A collection of `self::TokenTree`. There may also be some errors emitted to `sess`. pub(super) fn parse( - input: tokenstream::TokenStream, + input: &tokenstream::TokenStream, parsing_patterns: bool, sess: &ParseSess, node_id: NodeId, @@ -48,7 +48,7 @@ pub(super) fn parse( // For each token tree in `input`, parse the token into a `self::TokenTree`, consuming // additional trees if need be. - let mut trees = input.into_trees(); + let mut trees = input.trees(); while let Some(tree) = trees.next() { // Given the parsed tree, if there is a metavar and we are expecting matchers, actually // parse out the matcher (i.e., in `$id:ident` this would parse the `:` and `ident`). @@ -56,7 +56,7 @@ pub(super) fn parse( match tree { TokenTree::MetaVar(start_sp, ident) if parsing_patterns => { let span = match trees.next() { - Some(tokenstream::TokenTree::Token(Token { kind: token::Colon, span }, _)) => { + Some(&tokenstream::TokenTree::Token(Token { kind: token::Colon, span }, _)) => { match trees.next() { Some(tokenstream::TokenTree::Token(token, _)) => match token.ident() { Some((frag, _)) => { @@ -96,10 +96,10 @@ pub(super) fn parse( } _ => token.span, }, - tree => tree.as_ref().map_or(span, tokenstream::TokenTree::span), + tree => tree.map_or(span, tokenstream::TokenTree::span), } } - tree => tree.as_ref().map_or(start_sp, tokenstream::TokenTree::span), + tree => tree.map_or(start_sp, tokenstream::TokenTree::span), }; result.push(TokenTree::MetaVarDecl(span, ident, None)); @@ -134,9 +134,9 @@ fn maybe_emit_macro_metavar_expr_feature(features: &Features, sess: &ParseSess, /// - `parsing_patterns`: same as [parse]. /// - `sess`: the parsing session. Any errors will be emitted to this session. /// - `features`: language features so we can do feature gating. -fn parse_tree( - tree: tokenstream::TokenTree, - outer_trees: &mut impl Iterator, +fn parse_tree<'a>( + tree: &'a tokenstream::TokenTree, + outer_trees: &mut impl Iterator, parsing_patterns: bool, sess: &ParseSess, node_id: NodeId, @@ -146,13 +146,13 @@ fn parse_tree( // Depending on what `tree` is, we could be parsing different parts of a macro match tree { // `tree` is a `$` token. Look at the next token in `trees` - tokenstream::TokenTree::Token(Token { kind: token::Dollar, span }, _) => { + &tokenstream::TokenTree::Token(Token { kind: token::Dollar, span }, _) => { // FIXME: Handle `Invisible`-delimited groups in a more systematic way // during parsing. let mut next = outer_trees.next(); - let mut trees: Box>; + let mut trees: Box>; if let Some(tokenstream::TokenTree::Delimited(_, Delimiter::Invisible, tts)) = next { - trees = Box::new(tts.into_trees()); + trees = Box::new(tts.trees()); next = trees.next(); } else { trees = Box::new(outer_trees); @@ -160,7 +160,7 @@ fn parse_tree( match next { // `tree` is followed by a delimited set of token trees. - Some(tokenstream::TokenTree::Delimited(delim_span, delim, tts)) => { + Some(&tokenstream::TokenTree::Delimited(delim_span, delim, ref tts)) => { if parsing_patterns { if delim != Delimiter::Parenthesis { span_dollar_dollar_or_metavar_in_the_lhs_err( @@ -228,7 +228,7 @@ fn parse_tree( } // `tree` is followed by another `$`. This is an escaped `$`. - Some(tokenstream::TokenTree::Token(Token { kind: token::Dollar, span }, _)) => { + Some(&tokenstream::TokenTree::Token(Token { kind: token::Dollar, span }, _)) => { if parsing_patterns { span_dollar_dollar_or_metavar_in_the_lhs_err( sess, @@ -256,11 +256,11 @@ fn parse_tree( } // `tree` is an arbitrary token. Keep it. - tokenstream::TokenTree::Token(token, _) => TokenTree::Token(token), + tokenstream::TokenTree::Token(token, _) => TokenTree::Token(token.clone()), // `tree` is the beginning of a delimited set of tokens (e.g., `(` or `{`). We need to // descend into the delimited set and further parse it. - tokenstream::TokenTree::Delimited(span, delim, tts) => TokenTree::Delimited( + &tokenstream::TokenTree::Delimited(span, delim, ref tts) => TokenTree::Delimited( span, Delimited { delim, @@ -286,16 +286,16 @@ fn kleene_op(token: &Token) -> Option { /// - Ok(Ok((op, span))) if the next token tree is a KleeneOp /// - Ok(Err(tok, span)) if the next token tree is a token but not a KleeneOp /// - Err(span) if the next token tree is not a token -fn parse_kleene_op( - input: &mut impl Iterator, +fn parse_kleene_op<'a>( + input: &mut impl Iterator, span: Span, ) -> Result, Span> { match input.next() { Some(tokenstream::TokenTree::Token(token, _)) => match kleene_op(&token) { Some(op) => Ok(Ok((op, token.span))), - None => Ok(Err(token)), + None => Ok(Err(token.clone())), }, - tree => Err(tree.as_ref().map_or(span, tokenstream::TokenTree::span)), + tree => Err(tree.map_or(span, tokenstream::TokenTree::span)), } } @@ -311,8 +311,8 @@ fn parse_kleene_op( /// session `sess`. If the next one (or possibly two) tokens in `input` correspond to a Kleene /// operator and separator, then a tuple with `(separator, KleeneOp)` is returned. Otherwise, an /// error with the appropriate span is emitted to `sess` and a dummy value is returned. -fn parse_sep_and_kleene_op( - input: &mut impl Iterator, +fn parse_sep_and_kleene_op<'a>( + input: &mut impl Iterator, span: Span, sess: &ParseSess, ) -> (Option, KleeneToken) { From ee6ed603733c5b61690a920c4eaa4806f1d0f213 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 11:40:36 +1000 Subject: [PATCH 087/150] Avoid `into_trees` usage in rustfmt. Token tree cloning is only needed in one place. --- src/tools/rustfmt/src/macros.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/tools/rustfmt/src/macros.rs b/src/tools/rustfmt/src/macros.rs index e9a298a27693..4f45d0c74028 100644 --- a/src/tools/rustfmt/src/macros.rs +++ b/src/tools/rustfmt/src/macros.rs @@ -13,7 +13,7 @@ use std::collections::HashMap; use std::panic::{catch_unwind, AssertUnwindSafe}; use rustc_ast::token::{BinOpToken, Delimiter, Token, TokenKind}; -use rustc_ast::tokenstream::{TokenStream, TokenTree, TokenTreeCursor}; +use rustc_ast::tokenstream::{RefTokenTreeCursor, TokenStream, TokenTree}; use rustc_ast::{ast, ptr}; use rustc_ast_pretty::pprust; use rustc_span::{ @@ -394,7 +394,7 @@ pub(crate) fn rewrite_macro_def( } let ts = def.body.tokens.clone(); - let mut parser = MacroParser::new(ts.into_trees()); + let mut parser = MacroParser::new(ts.trees()); let parsed_def = match parser.parse() { Some(def) => def, None => return snippet, @@ -736,9 +736,9 @@ impl MacroArgParser { self.buf.clear(); } - fn add_meta_variable(&mut self, iter: &mut TokenTreeCursor) -> Option<()> { + fn add_meta_variable(&mut self, iter: &mut RefTokenTreeCursor<'_>) -> Option<()> { match iter.next() { - Some(TokenTree::Token( + Some(&TokenTree::Token( Token { kind: TokenKind::Ident(name, _), .. @@ -768,7 +768,7 @@ impl MacroArgParser { &mut self, inner: Vec, delim: Delimiter, - iter: &mut TokenTreeCursor, + iter: &mut RefTokenTreeCursor<'_>, ) -> Option<()> { let mut buffer = String::new(); let mut first = true; @@ -868,11 +868,11 @@ impl MacroArgParser { /// Returns a collection of parsed macro def's arguments. fn parse(mut self, tokens: TokenStream) -> Option> { - let mut iter = tokens.into_trees(); + let mut iter = tokens.trees(); while let Some(tok) = iter.next() { match tok { - TokenTree::Token( + &TokenTree::Token( Token { kind: TokenKind::Dollar, span, @@ -901,7 +901,7 @@ impl MacroArgParser { self.add_meta_variable(&mut iter)?; } TokenTree::Token(ref t, _) => self.update_buffer(t), - TokenTree::Delimited(_delimited_span, delimited, ref tts) => { + &TokenTree::Delimited(_delimited_span, delimited, ref tts) => { if !self.buf.is_empty() { if next_space(&self.last_tok.kind) == SpaceState::Always { self.add_separator(); @@ -1119,12 +1119,12 @@ pub(crate) fn macro_style(mac: &ast::MacCall, context: &RewriteContext<'_>) -> D // A very simple parser that just parses a macros 2.0 definition into its branches. // Currently we do not attempt to parse any further than that. -struct MacroParser { - toks: TokenTreeCursor, +struct MacroParser<'a> { + toks: RefTokenTreeCursor<'a>, } -impl MacroParser { - const fn new(toks: TokenTreeCursor) -> Self { +impl<'a> MacroParser<'a> { + const fn new(toks: RefTokenTreeCursor<'a>) -> Self { Self { toks } } @@ -1143,9 +1143,9 @@ impl MacroParser { let tok = self.toks.next()?; let (lo, args_paren_kind) = match tok { TokenTree::Token(..) => return None, - TokenTree::Delimited(delimited_span, d, _) => (delimited_span.open.lo(), d), + &TokenTree::Delimited(delimited_span, d, _) => (delimited_span.open.lo(), d), }; - let args = TokenStream::new(vec![tok]); + let args = TokenStream::new(vec![tok.clone()]); match self.toks.next()? { TokenTree::Token( Token { From 4ebf2be8bb91e41fdf6c7c337482c72317508cef Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 11:48:55 +1000 Subject: [PATCH 088/150] Remove `Iterator` impl for `TokenTreeCursor`. This is surprising, but the new comment explains why. It's a logical conclusion in the drive to avoid `TokenTree` clones. `TokenTreeCursor` is now only used within `Parser`. It's still needed due to `replace_prev_and_rewind`. --- compiler/rustc_ast/src/tokenstream.rs | 21 +++++++------------ compiler/rustc_expand/src/config.rs | 6 +++--- .../rustc_expand/src/proc_macro_server.rs | 4 ++-- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index c6f0643147d8..348c37c480f7 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -597,26 +597,21 @@ impl<'t> Iterator for RefTokenTreeCursor<'t> { } } -/// Owning by-value iterator over a [`TokenStream`], that produces `TokenTree` +/// Owning by-value iterator over a [`TokenStream`], that produces `&TokenTree` /// items. -// FIXME: Many uses of this can be replaced with by-reference iterator to avoid clones. +/// +/// Doesn't impl `Iterator` because Rust doesn't permit an owning iterator to +/// return `&T` from `next`; the need for an explicit lifetime in the `Item` +/// associated type gets in the way. Instead, use `next_ref` (which doesn't +/// involve associated types) for getting individual elements, or +/// `RefTokenTreeCursor` if you really want an `Iterator`, e.g. in a `for` +/// loop. #[derive(Clone)] pub struct TokenTreeCursor { pub stream: TokenStream, index: usize, } -impl Iterator for TokenTreeCursor { - type Item = TokenTree; - - fn next(&mut self) -> Option { - self.stream.0.get(self.index).map(|tree| { - self.index += 1; - tree.clone() - }) - } -} - impl TokenTreeCursor { fn new(stream: TokenStream) -> Self { TokenTreeCursor { stream, index: 0 } diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index 4ec5ac22e907..aeb4f6e861b0 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -365,9 +365,9 @@ impl<'a> StripUnconfigured<'a> { // Use the `#` in `#[cfg_attr(pred, attr)]` as the `#` token // for `attr` when we expand it to `#[attr]` - let mut orig_trees = orig_tokens.into_trees(); + let mut orig_trees = orig_tokens.trees(); let TokenTree::Token(pound_token @ Token { kind: TokenKind::Pound, .. }, _) = - orig_trees.next().unwrap() + orig_trees.next().unwrap().clone() else { panic!("Bad tokens for attribute {:?}", attr); }; @@ -377,7 +377,7 @@ impl<'a> StripUnconfigured<'a> { if attr.style == AttrStyle::Inner { // For inner attributes, we do the same thing for the `!` in `#![some_attr]` let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) = - orig_trees.next().unwrap() + orig_trees.next().unwrap().clone() else { panic!("Bad tokens for attribute {:?}", attr); }; diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index ecd2315112a6..ac73b5d72b78 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -94,10 +94,10 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec { let delimiter = pm::Delimiter::from_internal(delim); trees.push(TokenTree::Group(Group { From 99f60ec41179fa648a827cc99b6d110541e88c0c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 03:16:34 +0000 Subject: [PATCH 089/150] Revert "don't uniquify regions when canonicalizing" This reverts commit 171f5414705194067557cd7b70bd680308b9cced. --- .../src/solve/canonicalize.rs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_trait_selection/src/solve/canonicalize.rs b/compiler/rustc_trait_selection/src/solve/canonicalize.rs index 255620489ff0..88771f90756d 100644 --- a/compiler/rustc_trait_selection/src/solve/canonicalize.rs +++ b/compiler/rustc_trait_selection/src/solve/canonicalize.rs @@ -125,9 +125,8 @@ impl<'a, 'tcx> Canonicalizer<'a, 'tcx> { // - var_infos: [E0, U1, E1, U1, E1, E6, U6], curr_compressed_uv: 1, next_orig_uv: 6 // - var_infos: [E0, U1, E1, U1, E1, E2, U2], curr_compressed_uv: 2, next_orig_uv: - // - // This algorithm runs in `O(nm)` where `n` is the number of different universe - // indices in the input and `m` is the number of canonical variables. - // This should be fine as both `n` and `m` are expected to be small. + // This algorithm runs in `O(n²)` where `n` is the number of different universe + // indices in the input. This should be fine as `n` is expected to be small. let mut curr_compressed_uv = ty::UniverseIndex::ROOT; let mut existential_in_new_uv = false; let mut next_orig_uv = Some(ty::UniverseIndex::ROOT); @@ -263,14 +262,18 @@ impl<'tcx> TypeFolder> for Canonicalizer<'_, 'tcx> { ty::ReError(_) => return r, }; - let var = ty::BoundVar::from( - self.variables.iter().position(|&v| v == r.into()).unwrap_or_else(|| { - let var = self.variables.len(); - self.variables.push(r.into()); - self.primitive_var_infos.push(CanonicalVarInfo { kind }); - var - }), - ); + let existing_bound_var = match self.canonicalize_mode { + CanonicalizeMode::Input => None, + CanonicalizeMode::Response { .. } => { + self.variables.iter().position(|&v| v == r.into()).map(ty::BoundVar::from) + } + }; + let var = existing_bound_var.unwrap_or_else(|| { + let var = ty::BoundVar::from(self.variables.len()); + self.variables.push(r.into()); + self.primitive_var_infos.push(CanonicalVarInfo { kind }); + var + }); let br = ty::BoundRegion { var, kind: BrAnon(None) }; ty::Region::new_late_bound(self.interner(), self.binder_index, br) } From 1ffc6ca9a513d1a3a928cc1d32b21d55d6326bb3 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 04:00:18 +0000 Subject: [PATCH 090/150] Consider a goal as NOT changed if its response is identity modulo regions --- .../src/solve/eval_ctxt.rs | 2 +- tests/ui/impl-trait/autoderef.rs | 2 +- ...dont-loop-fulfill-on-region-constraints.rs | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs index f48a992d3275..9e3b0bbc4fb2 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs @@ -344,7 +344,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { Ok(response) => response, }; - let has_changed = !canonical_response.value.var_values.is_identity() + let has_changed = !canonical_response.value.var_values.is_identity_modulo_regions() || !canonical_response.value.external_constraints.opaque_types.is_empty(); let (certainty, nested_goals) = match self.instantiate_and_apply_query_response( goal.param_env, diff --git a/tests/ui/impl-trait/autoderef.rs b/tests/ui/impl-trait/autoderef.rs index 0d07a549640f..cd2cdd9e3b3c 100644 --- a/tests/ui/impl-trait/autoderef.rs +++ b/tests/ui/impl-trait/autoderef.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flag: -Ztrait-solver=next +//[next] compile-flags: -Ztrait-solver=next // check-pass use std::path::Path; diff --git a/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs b/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs new file mode 100644 index 000000000000..b241e3bf8652 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs @@ -0,0 +1,32 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Eq<'a, 'b, T> {} + +trait Ambig {} +impl Ambig for () {} + +impl<'a, T> Eq<'a, 'a, T> for () where T: Ambig {} + +fn eq<'a, 'b, T>(t: T) +where + (): Eq<'a, 'b, T>, +{ +} + +fn test<'r>() { + let mut x = Default::default(); + + // When we evaluate `(): Eq<'r, 'r, ?0>` we uniquify the regions. + // That leads us to evaluate `(): Eq<'?0, '?1, ?0>`. The response of this + // will be ambiguous (because `?0: Ambig` is ambig) and also not an "identity" + // response, since the region constraints will contain `'?0 == '?1` (so + // `is_changed` will return true). Since it's both ambig and changed, + // fulfillment will both re-register the goal AND loop again. This hits the + // overflow limit. This should neither be considered overflow, nor ICE. + eq::<'r, 'r, _>(x); + + x = (); +} + +fn main() {} From ac747a848124c1797140aa6c10b69d00e7ffc226 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jul 2023 14:56:28 +1000 Subject: [PATCH 091/150] Optimize `TokenKind::clone`. `TokenKind` would impl `Copy` if it weren't for `TokenKind::Interpolated`. This commit makes `clone` reflect that. --- compiler/rustc_ast/src/token.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 303bdd3a3079..4c920e84f867 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -226,7 +226,9 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool { .contains(&name) } -#[derive(Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +// SAFETY: due to the `Clone` impl below, all fields of all variants other than +// `Interpolated` must impl `Copy`. +#[derive(PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub enum TokenKind { /* Expression-operator symbols. */ Eq, @@ -299,6 +301,19 @@ pub enum TokenKind { Eof, } +impl Clone for TokenKind { + fn clone(&self) -> Self { + // `TokenKind` would impl `Copy` if it weren't for `Interpolated`. So + // for all other variants, this implementation of `clone` is just like + // a copy. This is faster than the `derive(Clone)` version which has a + // separate path for every variant. + match self { + Interpolated(nt) => Interpolated(nt.clone()), + _ => unsafe { std::ptr::read(self) }, + } + } +} + #[derive(Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub struct Token { pub kind: TokenKind, From f4c4f96d16c7b9e20644a57b6096dfced07aa940 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Thu, 27 Jul 2023 10:14:34 +0200 Subject: [PATCH 092/150] tests/ui/hello_world/main.rs: Remove FIXME The purpose of the test is to make sure that compiling hello world produces no compiler output. To properly test that, we need to run the entire compiler pipeline. We don't want the test to pass if codegen accidentally starts writing to stdout. So keep it as build-pass. --- tests/ui/hello_world/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/hello_world/main.rs b/tests/ui/hello_world/main.rs index 22ce47414b28..39cb74b709b7 100644 --- a/tests/ui/hello_world/main.rs +++ b/tests/ui/hello_world/main.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// build-pass // Test that compiling hello world succeeds with no output of any kind. From 99a9a63ca6086338a3208b26b224f894d5a29d58 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 27 Jul 2023 08:23:06 +0000 Subject: [PATCH 093/150] Turns out opaque types can have hidden types registered during mir validation --- .../rustc_const_eval/src/util/compare_types.rs | 15 +++++++++------ tests/ui/type-alias-impl-trait/broken_mir.rs | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 tests/ui/type-alias-impl-trait/broken_mir.rs diff --git a/compiler/rustc_const_eval/src/util/compare_types.rs b/compiler/rustc_const_eval/src/util/compare_types.rs index 88d4f5e715c9..83376c8e9928 100644 --- a/compiler/rustc_const_eval/src/util/compare_types.rs +++ b/compiler/rustc_const_eval/src/util/compare_types.rs @@ -57,12 +57,15 @@ pub fn is_subtype<'tcx>( // we would get unification errors because we're unable to look into opaque types, // even if they're constrained in our current function. for (key, ty) in infcx.take_opaque_types() { - span_bug!( - ty.hidden_type.span, - "{}, {}", - tcx.type_of(key.def_id).instantiate(tcx, key.args), - ty.hidden_type.ty - ); + let hidden_ty = tcx.type_of(key.def_id).instantiate(tcx, key.args); + if hidden_ty != ty.hidden_type.ty { + span_bug!( + ty.hidden_type.span, + "{}, {}", + tcx.type_of(key.def_id).instantiate(tcx, key.args), + ty.hidden_type.ty + ); + } } errors.is_empty() } diff --git a/tests/ui/type-alias-impl-trait/broken_mir.rs b/tests/ui/type-alias-impl-trait/broken_mir.rs new file mode 100644 index 000000000000..b68e798fb7c9 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/broken_mir.rs @@ -0,0 +1,16 @@ +//! ICE: https://github.com/rust-lang/rust/issues/114121 +//! This test checks that MIR validation never constrains +//! new hidden types that *differ* from the actual hidden types. +//! This test used to ICE because oli-obk assumed mir validation +//! was only ever run after opaque types were revealed in MIR. + +// compile-flags: -Zvalidate-mir +// check-pass + +fn main() { + let _ = Some(()).into_iter().flat_map(|_| Some(()).into_iter().flat_map(func)); +} + +fn func(_: ()) -> impl Iterator { + Some(()).into_iter().flat_map(|_| vec![]) +} From 4315ba64b5437b380a53d6c36971ec1625d7dd62 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Thu, 27 Jul 2023 10:29:53 +0200 Subject: [PATCH 094/150] tests/ui/proc-macro/*: Migrate FIXMEs to check-pass proc-macros are processed early in the compiler pipeline. There is no need to involve codegen. So change to check-pass. I have also looked through each changed test and to me it is sufficiently clear that codegen is not needed for the purpose of the test. I skipped changing tests/ui/proc-macro/no-missing-docs.rs in this commit because it was not clear to me that it can be changed to check-pass. --- tests/ui/proc-macro/derive-helper-shadowed.rs | 2 +- tests/ui/proc-macro/derive-in-mod.rs | 2 +- tests/ui/proc-macro/edition-imports-2018.rs | 2 +- tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs | 2 +- tests/ui/proc-macro/helper-attr-blocked-by-import.rs | 2 +- tests/ui/proc-macro/issue-53481.rs | 2 +- tests/ui/proc-macro/macro-use-attr.rs | 2 +- tests/ui/proc-macro/macro-use-bang.rs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/ui/proc-macro/derive-helper-shadowed.rs b/tests/ui/proc-macro/derive-helper-shadowed.rs index e299454e0fc7..ac14ece69184 100644 --- a/tests/ui/proc-macro/derive-helper-shadowed.rs +++ b/tests/ui/proc-macro/derive-helper-shadowed.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs // aux-build:derive-helper-shadowed-2.rs diff --git a/tests/ui/proc-macro/derive-in-mod.rs b/tests/ui/proc-macro/derive-in-mod.rs index 8b5d4e9d09ce..96e9d93fe128 100644 --- a/tests/ui/proc-macro/derive-in-mod.rs +++ b/tests/ui/proc-macro/derive-in-mod.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs extern crate test_macros; diff --git a/tests/ui/proc-macro/edition-imports-2018.rs b/tests/ui/proc-macro/edition-imports-2018.rs index 5a77cd4ef4f5..765673531987 100644 --- a/tests/ui/proc-macro/edition-imports-2018.rs +++ b/tests/ui/proc-macro/edition-imports-2018.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // edition:2018 // aux-build:edition-imports-2015.rs diff --git a/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs b/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs index a6e64e1b1b1b..38f61c36c8c6 100644 --- a/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs +++ b/tests/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // edition:2018 extern crate proc_macro; diff --git a/tests/ui/proc-macro/helper-attr-blocked-by-import.rs b/tests/ui/proc-macro/helper-attr-blocked-by-import.rs index 2e20a3de6bf4..344323122dc2 100644 --- a/tests/ui/proc-macro/helper-attr-blocked-by-import.rs +++ b/tests/ui/proc-macro/helper-attr-blocked-by-import.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use(Empty)] diff --git a/tests/ui/proc-macro/issue-53481.rs b/tests/ui/proc-macro/issue-53481.rs index ae10a3baa3e3..922e60a4c4fa 100644 --- a/tests/ui/proc-macro/issue-53481.rs +++ b/tests/ui/proc-macro/issue-53481.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use] diff --git a/tests/ui/proc-macro/macro-use-attr.rs b/tests/ui/proc-macro/macro-use-attr.rs index b101c09ed542..d275fb6a804f 100644 --- a/tests/ui/proc-macro/macro-use-attr.rs +++ b/tests/ui/proc-macro/macro-use-attr.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use] diff --git a/tests/ui/proc-macro/macro-use-bang.rs b/tests/ui/proc-macro/macro-use-bang.rs index 4a0bf0b2f63b..e3174fd446a1 100644 --- a/tests/ui/proc-macro/macro-use-bang.rs +++ b/tests/ui/proc-macro/macro-use-bang.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // aux-build:test-macros.rs #[macro_use] From 2461d0cf9cca7e437e17cc251496963caeac051d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 27 Jul 2023 10:54:10 +0200 Subject: [PATCH 095/150] Remove transmute calls and caching for use paths --- src/librustdoc/clean/mod.rs | 43 +++++++++++------------------------ src/librustdoc/clean/types.rs | 11 +++++++++ src/librustdoc/core.rs | 5 +--- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 998380abfacf..fd38d1c045ec 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1499,31 +1499,25 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( fn first_non_private_clean_path<'tcx>( cx: &mut DocContext<'tcx>, path: &hir::Path<'tcx>, - mut new_path_segments: Vec>, + new_path_segments: &'tcx [hir::PathSegment<'tcx>], new_path_span: rustc_span::Span, ) -> Path { - use std::mem::transmute; - + let new_hir_path = + hir::Path { segments: new_path_segments, res: path.res, span: new_path_span }; + let mut new_clean_path = clean_path(&new_hir_path, cx); // In here we need to play with the path data one last time to provide it the // missing `args` and `res` of the final `Path` we get, which, since it comes // from a re-export, doesn't have the generics that were originally there, so // we add them by hand. - if let Some(last) = new_path_segments.last_mut() { - // `transmute` is needed because we are using a wrong lifetime. Since - // `segments` will be dropped at the end of this block, it's fine. - last.args = unsafe { transmute(path.segments.last().as_ref().unwrap().args.clone()) }; - last.res = path.res; + if let Some(path_last) = path.segments.last().as_ref() + && let Some(new_path_last) = new_clean_path.segments[..].last_mut() + && let Some(path_last_args) = path_last.args.as_ref() + && path_last.args.is_some() + { + assert!(new_path_last.args.is_empty()); + new_path_last.args = clean_generic_args(path_last_args, cx); } - // `transmute` is needed because we are using a wrong lifetime. Since - // `segments` will be dropped at the end of this block, it's fine. - let path = unsafe { - hir::Path { - segments: transmute(new_path_segments.as_slice()), - res: path.res, - span: new_path_span, - } - }; - clean_path(&path, cx) + new_clean_path } /// The goal of this function is to return the first `Path` which is not private (ie not private @@ -1535,16 +1529,7 @@ fn first_non_private<'tcx>( hir_id: hir::HirId, path: &hir::Path<'tcx>, ) -> Option { - let use_id = path.segments.last().map(|seg| seg.hir_id)?; let target_def_id = path.res.opt_def_id()?; - let saved_path = cx - .updated_qpath - .borrow() - .get(&use_id) - .map(|saved_path| (saved_path.segments.to_vec(), saved_path.span)); - if let Some((segments, span)) = saved_path { - return Some(first_non_private_clean_path(cx, path, segments, span)); - } let (parent_def_id, ident) = match &path.segments[..] { [] => return None, // Relative paths are available in the same scope as the owner. @@ -1611,9 +1596,7 @@ fn first_non_private<'tcx>( // 1. We found a public reexport. // 2. We didn't find a public reexport so it's the "end type" path. if let Some((new_path, _)) = last_path_res { - cx.updated_qpath.borrow_mut().insert(use_id, new_path.clone()); - let new_path_segments = new_path.segments.to_vec(); - return Some(first_non_private_clean_path(cx, path, new_path_segments, new_path.span)); + return Some(first_non_private_clean_path(cx, path, new_path.segments, new_path.span)); } // If `last_path_res` is `None`, it can mean two things: // diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index ddef165a0547..60e316decf91 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2203,6 +2203,17 @@ pub(crate) enum GenericArgs { Parenthesized { inputs: Box<[Type]>, output: Option> }, } +impl GenericArgs { + pub(crate) fn is_empty(&self) -> bool { + match self { + GenericArgs::AngleBracketed { args, bindings } => { + args.is_empty() && bindings.is_empty() + } + GenericArgs::Parenthesized { inputs, output } => inputs.is_empty() && output.is_none(), + } + } +} + #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub(crate) struct PathSegment { pub(crate) name: Symbol, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 6cccb403491c..7fb069d6e707 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -8,7 +8,7 @@ use rustc_feature::UnstableFeatures; use rustc_hir::def::Res; use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId}; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{HirId, Path, UsePath}; +use rustc_hir::{HirId, Path}; use rustc_interface::interface; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; @@ -63,8 +63,6 @@ pub(crate) struct DocContext<'tcx> { pub(crate) output_format: OutputFormat, /// Used by `strip_private`. pub(crate) show_coverage: bool, - /// Used by `first_non_private` to prevent computing the same path more than once. - pub(crate) updated_qpath: RefCell>>, } impl<'tcx> DocContext<'tcx> { @@ -354,7 +352,6 @@ pub(crate) fn run_global_ctxt( output_format, render_options, show_coverage, - updated_qpath: Default::default(), }; for cnum in tcx.crates(()) { From 656213cc83537c311d8bcfd0b8f2c68fe1594233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 27 Jul 2023 12:32:22 +0000 Subject: [PATCH 096/150] When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist Fix #113881. --- compiler/rustc_errors/src/lib.rs | 4 ++-- library/std/src/panicking.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 1da02e1bb012..9772c5b8c157 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1673,11 +1673,11 @@ impl HandlerInner { let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(true, |x| &x != "0"); for bug in bugs { if let Some(file) = self.ice_file.as_ref() - && let Ok(mut out) = std::fs::File::options().append(true).open(file) + && let Ok(mut out) = std::fs::File::options().create(true).append(true).open(file) { let _ = write!( &mut out, - "\n\ndelayed span bug: {}\n{}", + "delayed span bug: {}\n{}\n", bug.inner.styled_message().iter().filter_map(|(msg, _)| msg.as_str()).collect::(), &bug.note ); diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 0e90d618ad43..15285465c713 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -300,7 +300,7 @@ pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path }; if let Some(path) = path - && let Ok(mut out) = crate::fs::File::options().create(true).write(true).open(&path) + && let Ok(mut out) = crate::fs::File::options().create(true).append(true).open(&path) { write(&mut out, BacktraceStyle::full()); } From 686b3debfc19f124c9c2ec8a856c06892f6086a1 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Thu, 27 Jul 2023 08:39:59 -0700 Subject: [PATCH 097/150] Revert "add tidy check that forbids issue ui test filenames" This reverts commit 13e2abf6b388762af2e97ce065d6206961264a8f. Reverting because an MCP was requested and it turned out there was a lack of a consensus on what to do in this area. --- src/tools/tidy/src/issues.txt | 4282 -------------------------------- src/tools/tidy/src/ui_tests.rs | 53 +- 2 files changed, 6 insertions(+), 4329 deletions(-) delete mode 100644 src/tools/tidy/src/issues.txt diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt deleted file mode 100644 index 9f1e8d1b3f35..000000000000 --- a/src/tools/tidy/src/issues.txt +++ /dev/null @@ -1,4282 +0,0 @@ -/* -============================================================ - ⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️ -============================================================ -*/ -[ -"ui/abi/issues/issue-22565-rust-call.rs", -"ui/abi/issues/issue-62350-sysv-neg-reg-counts.rs", -"ui/abi/issues/issue-97463-broken-abi-leaked-uninit-data.rs", -"ui/abi/issue-28676.rs", -"ui/abi/issue-94223.rs", -"ui/argument-suggestions/issue-100154.rs", -"ui/argument-suggestions/issue-100478.rs", -"ui/argument-suggestions/issue-101097.rs", -"ui/argument-suggestions/issue-109831.rs", -"ui/argument-suggestions/issue-96638.rs", -"ui/argument-suggestions/issue-97197.rs", -"ui/argument-suggestions/issue-97484.rs", -"ui/argument-suggestions/issue-98894.rs", -"ui/argument-suggestions/issue-98897.rs", -"ui/argument-suggestions/issue-99482.rs", -"ui/argument-suggestions/issue-112507.rs", -"ui/argument-suggestions/issue-109425.rs", -"ui/array-slice-vec/issue-15730.rs", -"ui/array-slice-vec/issue-18425.rs", -"ui/array-slice-vec/issue-69103-extra-binding-subslice.rs", -"ui/asm/x86_64/issue-82869.rs", -"ui/asm/x86_64/issue-89875.rs", -"ui/asm/x86_64/issue-96797.rs", -"ui/asm/issue-72570.rs", -"ui/asm/issue-85247.rs", -"ui/asm/issue-87802.rs", -"ui/asm/issue-89305.rs", -"ui/asm/issue-92378.rs", -"ui/asm/issue-97490.rs", -"ui/asm/issue-99071.rs", -"ui/asm/issue-99122-2.rs", -"ui/asm/issue-99122.rs", -"ui/associated-consts/issue-102335-const.rs", -"ui/associated-consts/issue-105330.rs", -"ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.rs", -"ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.rs", -"ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.rs", -"ui/associated-consts/issue-47814.rs", -"ui/associated-consts/issue-58022.rs", -"ui/associated-consts/issue-63496.rs", -"ui/associated-consts/issue-93775.rs", -"ui/associated-consts/issue-93835.rs", -"ui/associated-consts/issue-69020-assoc-const-arith-overflow.rs", -"ui/associated-consts/issue-88599-ref-self.rs", -"ui/associated-consts/issue-110933.rs", -"ui/associated-inherent-types/issue-109299-1.rs", -"ui/associated-inherent-types/issue-109299.rs", -"ui/associated-inherent-types/issue-109768.rs", -"ui/associated-inherent-types/issue-109789.rs", -"ui/associated-inherent-types/issue-111879-0.rs", -"ui/associated-inherent-types/issue-111879-1.rs", -"ui/associated-inherent-types/issue-111404-1.rs", -"ui/associated-inherent-types/issue-104260.rs", -"ui/associated-inherent-types/issue-109790.rs", -"ui/associated-inherent-types/issue-111404-0.rs", -"ui/associated-inherent-types/issue-109071.rs", -"ui/associated-item/issue-48027.rs", -"ui/associated-item/issue-105449.rs", -"ui/associated-item/issue-87638.rs", -"ui/associated-type-bounds/issue-102335-ty.rs", -"ui/associated-type-bounds/issue-104916.rs", -"ui/associated-type-bounds/issue-71443-1.rs", -"ui/associated-type-bounds/issue-99828.rs", -"ui/associated-type-bounds/issue-61752.rs", -"ui/associated-type-bounds/issue-70292.rs", -"ui/associated-type-bounds/issue-71443-2.rs", -"ui/associated-type-bounds/issue-73818.rs", -"ui/associated-type-bounds/issue-79949.rs", -"ui/associated-type-bounds/issue-81193.rs", -"ui/associated-type-bounds/issue-83017.rs", -"ui/associated-types/issue-18655.rs", -"ui/associated-types/issue-19883.rs", -"ui/associated-types/issue-20005.rs", -"ui/associated-types/issue-20825.rs", -"ui/associated-types/issue-22037.rs", -"ui/associated-types/issue-22560.rs", -"ui/associated-types/issue-22828.rs", -"ui/associated-types/issue-23208.rs", -"ui/associated-types/issue-23595-1.rs", -"ui/associated-types/issue-23595-2.rs", -"ui/associated-types/issue-25339.rs", -"ui/associated-types/issue-25700-1.rs", -"ui/associated-types/issue-25700-2.rs", -"ui/associated-types/issue-25700.rs", -"ui/associated-types/issue-26681.rs", -"ui/associated-types/issue-27675-unchecked-bounds.rs", -"ui/associated-types/issue-27901.rs", -"ui/associated-types/issue-38821.rs", -"ui/associated-types/issue-43784-associated-type.rs", -"ui/associated-types/issue-43924.rs", -"ui/associated-types/issue-44153.rs", -"ui/associated-types/issue-47139-1.rs", -"ui/associated-types/issue-47139-2.rs", -"ui/associated-types/issue-47814.rs", -"ui/associated-types/issue-54108.rs", -"ui/associated-types/issue-54182-1.rs", -"ui/associated-types/issue-54467.rs", -"ui/associated-types/issue-55846.rs", -"ui/associated-types/issue-59324.rs", -"ui/associated-types/issue-62200.rs", -"ui/associated-types/issue-63593.rs", -"ui/associated-types/issue-64848.rs", -"ui/associated-types/issue-64855.rs", -"ui/associated-types/issue-65774-1.rs", -"ui/associated-types/issue-65774-2.rs", -"ui/associated-types/issue-72806.rs", -"ui/associated-types/issue-85103.rs", -"ui/associated-types/issue-87261.rs", -"ui/associated-types/issue-19081.rs", -"ui/associated-types/issue-20825-2.rs", -"ui/associated-types/issue-21363.rs", -"ui/associated-types/issue-21726.rs", -"ui/associated-types/issue-22066.rs", -"ui/associated-types/issue-24159.rs", -"ui/associated-types/issue-24204.rs", -"ui/associated-types/issue-24338.rs", -"ui/associated-types/issue-28871.rs", -"ui/associated-types/issue-31597.rs", -"ui/associated-types/issue-32350.rs", -"ui/associated-types/issue-36499.rs", -"ui/associated-types/issue-37808.rs", -"ui/associated-types/issue-37883.rs", -"ui/associated-types/issue-38917.rs", -"ui/associated-types/issue-39532.rs", -"ui/associated-types/issue-40093.rs", -"ui/associated-types/issue-41868.rs", -"ui/associated-types/issue-43475.rs", -"ui/associated-types/issue-47385.rs", -"ui/associated-types/issue-48010.rs", -"ui/associated-types/issue-48551.rs", -"ui/associated-types/issue-50301.rs", -"ui/associated-types/issue-54182-2.rs", -"ui/associated-types/issue-63591.rs", -"ui/associated-types/issue-64855-2.rs", -"ui/associated-types/issue-65934.rs", -"ui/associated-types/issue-67684.rs", -"ui/associated-types/issue-69398.rs", -"ui/associated-types/issue-71113.rs", -"ui/associated-types/issue-76179.rs", -"ui/associated-types/issue-82079.rs", -"ui/associated-types/issue-88856.rs", -"ui/associated-types/issue-91069.rs", -"ui/associated-types/issue-91231.rs", -"ui/associated-types/issue-91234.rs", -"ui/async-await/auxiliary/issue-107036.rs", -"ui/async-await/auxiliary/issue-72470-lib.rs", -"ui/async-await/in-trait/issue-102138.rs", -"ui/async-await/in-trait/issue-102219.rs", -"ui/async-await/in-trait/issue-102310.rs", -"ui/async-await/in-trait/issue-104678.rs", -"ui/async-await/issues/auxiliary/issue-60674.rs", -"ui/async-await/issues/auxiliary/issue_67893.rs", -"ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs", -"ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs", -"ui/async-await/issues/issue-65419/issue-65419-generator-resume-after-completion.rs", -"ui/async-await/issues/issue-102206.rs", -"ui/async-await/issues/issue-107280.rs", -"ui/async-await/issues/issue-112225-1.rs", -"ui/async-await/issues/issue-112225-2.rs", -"ui/async-await/issues/issue-51719.rs", -"ui/async-await/issues/issue-51751.rs", -"ui/async-await/issues/issue-53249.rs", -"ui/async-await/issues/issue-54752-async-block.rs", -"ui/async-await/issues/issue-54974.rs", -"ui/async-await/issues/issue-55324.rs", -"ui/async-await/issues/issue-55809.rs", -"ui/async-await/issues/issue-58885.rs", -"ui/async-await/issues/issue-59001.rs", -"ui/async-await/issues/issue-59972.rs", -"ui/async-await/issues/issue-60518.rs", -"ui/async-await/issues/issue-60655-latebound-regions.rs", -"ui/async-await/issues/issue-60674.rs", -"ui/async-await/issues/issue-61187.rs", -"ui/async-await/issues/issue-61986.rs", -"ui/async-await/issues/issue-62009-1.rs", -"ui/async-await/issues/issue-62009-2.rs", -"ui/async-await/issues/issue-62097.rs", -"ui/async-await/issues/issue-62517-1.rs", -"ui/async-await/issues/issue-62517-2.rs", -"ui/async-await/issues/issue-63388-1.rs", -"ui/async-await/issues/issue-63388-2.rs", -"ui/async-await/issues/issue-63388-3.rs", -"ui/async-await/issues/issue-63388-4.rs", -"ui/async-await/issues/issue-64391-2.rs", -"ui/async-await/issues/issue-64433.rs", -"ui/async-await/issues/issue-64477-2.rs", -"ui/async-await/issues/issue-64477.rs", -"ui/async-await/issues/issue-64964.rs", -"ui/async-await/issues/issue-65159.rs", -"ui/async-await/issues/issue-65436-raw-ptr-not-send.rs", -"ui/async-await/issues/issue-66695-static-refs.rs", -"ui/async-await/issues/issue-66958-non-copy-infered-type-arg.rs", -"ui/async-await/issues/issue-67611-static-mut-refs.rs", -"ui/async-await/issues/issue-67893.rs", -"ui/async-await/issues/issue-69307-nested.rs", -"ui/async-await/issues/issue-69307.rs", -"ui/async-await/issues/issue-72312.rs", -"ui/async-await/issues/issue-78600.rs", -"ui/async-await/issues/issue-78654.rs", -"ui/async-await/issues/issue-78938-async-block.rs", -"ui/async-await/issues/issue-95307.rs", -"ui/async-await/return-type-notation/issue-110963-early.rs", -"ui/async-await/return-type-notation/issue-110963-late.rs", -"ui/async-await/track-caller/issue-105134.rs", -"ui/async-await/issue-73541-3.rs", -"ui/async-await/issue-73541.rs", -"ui/async-await/issue-101715.rs", -"ui/async-await/issue-105501.rs", -"ui/async-await/issue-107036.rs", -"ui/async-await/issue-108572.rs", -"ui/async-await/issue-54239-private-type-triggers-lint.rs", -"ui/async-await/issue-60709.rs", -"ui/async-await/issue-61076.rs", -"ui/async-await/issue-61452.rs", -"ui/async-await/issue-61793.rs", -"ui/async-await/issue-61949-self-return-type.rs", -"ui/async-await/issue-62658.rs", -"ui/async-await/issue-63832-await-short-temporary-lifetime-1.rs", -"ui/async-await/issue-63832-await-short-temporary-lifetime.rs", -"ui/async-await/issue-64130-1-sync.rs", -"ui/async-await/issue-64130-2-send.rs", -"ui/async-await/issue-64130-3-other.rs", -"ui/async-await/issue-64130-4-async-move.rs", -"ui/async-await/issue-64130-non-send-future-diags.rs", -"ui/async-await/issue-64391.rs", -"ui/async-await/issue-66312.rs", -"ui/async-await/issue-66387-if-without-else.rs", -"ui/async-await/issue-67252-unnamed-future.rs", -"ui/async-await/issue-67651.rs", -"ui/async-await/issue-67765-async-diagnostic.rs", -"ui/async-await/issue-68112.rs", -"ui/async-await/issue-68523-start.rs", -"ui/async-await/issue-68523.rs", -"ui/async-await/issue-69446-fnmut-capture.rs", -"ui/async-await/issue-70594.rs", -"ui/async-await/issue-70818.rs", -"ui/async-await/issue-71137.rs", -"ui/async-await/issue-72442.rs", -"ui/async-await/issue-72470-llvm-dominate.rs", -"ui/async-await/issue-72590-type-error-sized.rs", -"ui/async-await/issue-73050.rs", -"ui/async-await/issue-73137.rs", -"ui/async-await/issue-73541-1.rs", -"ui/async-await/issue-73541-2.rs", -"ui/async-await/issue-73741-type-err-drop-tracking.rs", -"ui/async-await/issue-73741-type-err.rs", -"ui/async-await/issue-74047.rs", -"ui/async-await/issue-74072-lifetime-name-annotations.rs", -"ui/async-await/issue-74497-lifetime-in-opaque.rs", -"ui/async-await/issue-75785-confusing-named-region.rs", -"ui/async-await/issue-76547.rs", -"ui/async-await/issue-77993-2.rs", -"ui/async-await/issue-78115.rs", -"ui/async-await/issue-84841.rs", -"ui/async-await/issue-86507.rs", -"ui/async-await/issue-93197.rs", -"ui/async-await/issue-93648.rs", -"ui/async-await/issue-98634.rs", -"ui/async-await/issue-70935-complex-spans.rs", -"ui/attributes/issue-100631.rs", -"ui/attributes/issue-105594-invalid-attr-validation.rs", -"ui/attributes/issue-90873.rs", -"ui/attributes/issue-40962.rs", -"ui/auto-traits/issue-23080.rs", -"ui/auto-traits/issue-84075.rs", -"ui/auto-traits/issue-23080-2.rs", -"ui/auxiliary/issue-13560-1.rs", -"ui/auxiliary/issue-13560-2.rs", -"ui/auxiliary/issue-13560-3.rs", -"ui/auxiliary/issue-16822.rs", -"ui/auxiliary/issue-18502.rs", -"ui/auxiliary/issue-24106.rs", -"ui/auxiliary/issue-76387.rs", -"ui/bench/issue-32062.rs", -"ui/binding/issue-53114-borrow-checks.rs", -"ui/binding/issue-53114-safety-checks.rs", -"ui/binop/issue-25916.rs", -"ui/binop/issue-28837.rs", -"ui/binop/issue-3820.rs", -"ui/binop/issue-77910-1.rs", -"ui/binop/issue-77910-2.rs", -"ui/binop/issue-93927.rs", -"ui/block-result/issue-11714.rs", -"ui/block-result/issue-13428.rs", -"ui/block-result/issue-13624.rs", -"ui/block-result/issue-20862.rs", -"ui/block-result/issue-22645.rs", -"ui/block-result/issue-3563.rs", -"ui/block-result/issue-5500.rs", -"ui/borrowck/issue-85765-closure.rs", -"ui/borrowck/issue-101119.rs", -"ui/borrowck/issue-102209.rs", -"ui/borrowck/issue-17545.rs", -"ui/borrowck/issue-17718-static-move.rs", -"ui/borrowck/issue-20801.rs", -"ui/borrowck/issue-23338-params-outlive-temps-of-body.rs", -"ui/borrowck/issue-24267-flow-exit.rs", -"ui/borrowck/issue-25793.rs", -"ui/borrowck/issue-29166.rs", -"ui/borrowck/issue-31287-drop-in-guard.rs", -"ui/borrowck/issue-33819.rs", -"ui/borrowck/issue-41962.rs", -"ui/borrowck/issue-42344.rs", -"ui/borrowck/issue-45983.rs", -"ui/borrowck/issue-46095.rs", -"ui/borrowck/issue-46471.rs", -"ui/borrowck/issue-47215-ice-from-drop-elab.rs", -"ui/borrowck/issue-47646.rs", -"ui/borrowck/issue-51117.rs", -"ui/borrowck/issue-51301.rs", -"ui/borrowck/issue-51348-multi-ref-mut-in-guard.rs", -"ui/borrowck/issue-52713-bug.rs", -"ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.rs", -"ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs", -"ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs", -"ui/borrowck/issue-54499-field-mutation-of-moved-out.rs", -"ui/borrowck/issue-54499-field-mutation-of-never-init.rs", -"ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs", -"ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs", -"ui/borrowck/issue-58776-borrowck-scans-children.rs", -"ui/borrowck/issue-62007-assign-box.rs", -"ui/borrowck/issue-62007-assign-field.rs", -"ui/borrowck/issue-62107-match-arm-scopes.rs", -"ui/borrowck/issue-64453.rs", -"ui/borrowck/issue-69789-iterator-mut-suggestion.rs", -"ui/borrowck/issue-7573.rs", -"ui/borrowck/issue-81365-1.rs", -"ui/borrowck/issue-81365-10.rs", -"ui/borrowck/issue-81365-11.rs", -"ui/borrowck/issue-81365-2.rs", -"ui/borrowck/issue-81365-3.rs", -"ui/borrowck/issue-81365-4.rs", -"ui/borrowck/issue-81365-5.rs", -"ui/borrowck/issue-81365-6.rs", -"ui/borrowck/issue-81365-7.rs", -"ui/borrowck/issue-81365-8.rs", -"ui/borrowck/issue-81365-9.rs", -"ui/borrowck/issue-81899.rs", -"ui/borrowck/issue-82032.rs", -"ui/borrowck/issue-82462.rs", -"ui/borrowck/issue-83309-ice-immut-in-for-loop.rs", -"ui/borrowck/issue-83760.rs", -"ui/borrowck/issue-85581.rs", -"ui/borrowck/issue-85765.rs", -"ui/borrowck/issue-87456-point-to-closure.rs", -"ui/borrowck/issue-88434-minimal-example.rs", -"ui/borrowck/issue-88434-removal-index-should-be-less.rs", -"ui/borrowck/issue-91206.rs", -"ui/borrowck/issue-92015.rs", -"ui/borrowck/issue-92157.rs", -"ui/borrowck/issue-93078.rs", -"ui/borrowck/issue-111554.rs", -"ui/borrowck/issue-45199.rs", -"ui/borrowck/issue-103095.rs", -"ui/borrowck/issue-103250.rs", -"ui/borrowck/issue-103624.rs", -"ui/borrowck/issue-104639-lifetime-order.rs", -"ui/borrowck/issue-10876.rs", -"ui/borrowck/issue-109271-pass-self-into-closure.rs", -"ui/borrowck/issue-11493.rs", -"ui/borrowck/issue-17263.rs", -"ui/borrowck/issue-28934.rs", -"ui/borrowck/issue-36082.rs", -"ui/borrowck/issue-51415.rs", -"ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs", -"ui/borrowck/issue-55552-ascribe-wildcard-to-structured-pattern.rs", -"ui/borrowck/issue-70919-drop-in-loop.rs", -"ui/borrowck/issue-71546.rs", -"ui/borrowck/issue-80772.rs", -"ui/borrowck/issue-82126-mismatched-subst-and-hir.rs", -"ui/borrowck/issue-83924.rs", -"ui/borrowck/issue-93093.rs", -"ui/borrowck/issue-95079-missing-move-in-nested-closure.rs", -"ui/box/issue-82446.rs", -"ui/box/issue-95036.rs", -"ui/c-variadic/issue-32201.rs", -"ui/c-variadic/issue-86053-2.rs", -"ui/c-variadic/issue-86053-1.rs", -"ui/cast/issue-106883-is-empty.rs", -"ui/cast/issue-10991.rs", -"ui/cast/issue-17444.rs", -"ui/cast/issue-85586.rs", -"ui/cast/issue-88621.rs", -"ui/cast/issue-84213.rs", -"ui/cast/issue-89497.rs", -"ui/closure-expected-type/issue-24421.rs", -"ui/closure_context/issue-26046-fn-mut.rs", -"ui/closure_context/issue-26046-fn-once.rs", -"ui/closure_context/issue-42065.rs", -"ui/closures/2229_closure_analysis/match/issue-87097.rs", -"ui/closures/2229_closure_analysis/match/issue-87426.rs", -"ui/closures/2229_closure_analysis/match/issue-87988.rs", -"ui/closures/2229_closure_analysis/match/issue-88331.rs", -"ui/closures/2229_closure_analysis/migrations/issue-78720.rs", -"ui/closures/2229_closure_analysis/migrations/issue-86753.rs", -"ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs", -"ui/closures/2229_closure_analysis/run_pass/issue-87378.rs", -"ui/closures/2229_closure_analysis/run_pass/issue-88372.rs", -"ui/closures/2229_closure_analysis/run_pass/issue-88431.rs", -"ui/closures/2229_closure_analysis/run_pass/issue-88476.rs", -"ui/closures/2229_closure_analysis/issue-87378.rs", -"ui/closures/2229_closure_analysis/issue-87987.rs", -"ui/closures/2229_closure_analysis/issue-88118-2.rs", -"ui/closures/2229_closure_analysis/issue-88476.rs", -"ui/closures/2229_closure_analysis/issue-89606.rs", -"ui/closures/2229_closure_analysis/issue-90465.rs", -"ui/closures/2229_closure_analysis/issue-92724-needsdrop-query-cycle.rs", -"ui/closures/2229_closure_analysis/issue_88118.rs", -"ui/closures/issue-10398.rs", -"ui/closures/issue-109188.rs", -"ui/closures/issue-42463.rs", -"ui/closures/issue-52437.rs", -"ui/closures/issue-67123.rs", -"ui/closures/issue-6801.rs", -"ui/closures/issue-78720.rs", -"ui/closures/issue-80313-mutable-borrow-in-closure.rs", -"ui/closures/issue-80313-mutable-borrow-in-move-closure.rs", -"ui/closures/issue-80313-mutation-in-closure.rs", -"ui/closures/issue-80313-mutation-in-move-closure.rs", -"ui/closures/issue-81700-mut-borrow.rs", -"ui/closures/issue-82438-mut-without-upvar.rs", -"ui/closures/issue-84044-drop-non-mut.rs", -"ui/closures/issue-84128.rs", -"ui/closures/issue-868.rs", -"ui/closures/issue-90871.rs", -"ui/closures/issue-99565.rs", -"ui/closures/issue-111932.rs", -"ui/closures/issue-72408-nested-closures-exponential.rs", -"ui/closures/issue-101696.rs", -"ui/closures/issue-102089-multiple-opaque-cast.rs", -"ui/closures/issue-23012-supertrait-signature-inference.rs", -"ui/closures/issue-41366.rs", -"ui/closures/issue-46742.rs", -"ui/closures/issue-48109.rs", -"ui/closures/issue-68025.rs", -"ui/closures/issue-87461.rs", -"ui/closures/issue-87814-1.rs", -"ui/closures/issue-87814-2.rs", -"ui/closures/issue-97607.rs", -"ui/closures/issue-113087.rs", -"ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs", -"ui/codegen/auxiliary/issue-97708-aux.rs", -"ui/codegen/issue-101585-128bit-repeat.rs", -"ui/codegen/issue-16602-1.rs", -"ui/codegen/issue-16602-2.rs", -"ui/codegen/issue-16602-3.rs", -"ui/codegen/issue-55976.rs", -"ui/codegen/issue-64401.rs", -"ui/codegen/issue-97708.rs", -"ui/codegen/issue-99551.rs", -"ui/codegen/issue-28950.rs", -"ui/codegen/issue-63787.rs", -"ui/codegen/issue-82859-slice-miscompile.rs", -"ui/codegen/issue-88043-bb-does-not-have-terminator.rs", -"ui/codemap_tests/issue-11715.rs", -"ui/codemap_tests/issue-28308.rs", -"ui/coercion/auxiliary/issue-39823.rs", -"ui/coercion/issue-14589.rs", -"ui/coercion/issue-39823.rs", -"ui/coercion/issue-53475.rs", -"ui/coercion/issue-73886.rs", -"ui/coercion/issue-3794.rs", -"ui/coercion/issue-101066.rs", -"ui/coercion/issue-36007.rs", -"ui/coercion/issue-37655.rs", -"ui/coercion/issue-88097.rs", -"ui/coherence/issue-85026.rs", -"ui/coherence/issue-99663-2.rs", -"ui/coherence/issue-99663.rs", -"ui/command/issue-10626.rs", -"ui/compare-method/issue-90444.rs", -"ui/conditional-compilation/issue-34028.rs", -"ui/confuse-field-and-method/issue-18343.rs", -"ui/confuse-field-and-method/issue-2392.rs", -"ui/confuse-field-and-method/issue-32128.rs", -"ui/confuse-field-and-method/issue-33784.rs", -"ui/const-generics/generic_arg_infer/issue-91614.rs", -"ui/const-generics/generic_const_exprs/auxiliary/issue-94287-aux.rs", -"ui/const-generics/generic_const_exprs/issue-100217.rs", -"ui/const-generics/generic_const_exprs/issue-102768.rs", -"ui/const-generics/generic_const_exprs/issue-105257.rs", -"ui/const-generics/generic_const_exprs/issue-105608.rs", -"ui/const-generics/generic_const_exprs/issue-69654.rs", -"ui/const-generics/generic_const_exprs/issue-73298.rs", -"ui/const-generics/generic_const_exprs/issue-73899.rs", -"ui/const-generics/generic_const_exprs/issue-74713.rs", -"ui/const-generics/generic_const_exprs/issue-76595.rs", -"ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.rs", -"ui/const-generics/generic_const_exprs/issue-80742.rs", -"ui/const-generics/generic_const_exprs/issue-82268.rs", -"ui/const-generics/generic_const_exprs/issue-83765.rs", -"ui/const-generics/generic_const_exprs/issue-83972.rs", -"ui/const-generics/generic_const_exprs/issue-84669.rs", -"ui/const-generics/generic_const_exprs/issue-85848.rs", -"ui/const-generics/generic_const_exprs/issue-94287.rs", -"ui/const-generics/generic_const_exprs/issue-86710.rs", -"ui/const-generics/generic_const_exprs/issue-100360.rs", -"ui/const-generics/generic_const_exprs/issue-102074.rs", -"ui/const-generics/generic_const_exprs/issue-62504.rs", -"ui/const-generics/generic_const_exprs/issue-72787.rs", -"ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.rs", -"ui/const-generics/generic_const_exprs/issue-74634.rs", -"ui/const-generics/generic_const_exprs/issue-80561-incorrect-param-env.rs", -"ui/const-generics/generic_const_exprs/issue-84408.rs", -"ui/const-generics/generic_const_exprs/issue-89851.rs", -"ui/const-generics/generic_const_exprs/issue-90847.rs", -"ui/const-generics/generic_const_exprs/issue-94293.rs", -"ui/const-generics/generic_const_exprs/issue-97047-ice-1.rs", -"ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs", -"ui/const-generics/generic_const_exprs/issue-99647.rs", -"ui/const-generics/generic_const_exprs/issue-99705.rs", -"ui/const-generics/generic_const_exprs/issue-109141.rs", -"ui/const-generics/generic_const_exprs/issue-96699.rs", -"ui/const-generics/infer/issue-77092.rs", -"ui/const-generics/issues/issue-105037.rs", -"ui/const-generics/issues/issue-56445-2.rs", -"ui/const-generics/issues/issue-56445-3.rs", -"ui/const-generics/issues/issue-61336-1.rs", -"ui/const-generics/issues/issue-61336-2.rs", -"ui/const-generics/issues/issue-61336.rs", -"ui/const-generics/issues/issue-61432.rs", -"ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs", -"ui/const-generics/issues/issue-67185-2.rs", -"ui/const-generics/issues/issue-68104-print-stack-overflow.rs", -"ui/const-generics/issues/issue-69654-run-pass.rs", -"ui/const-generics/issues/issue-70125-1.rs", -"ui/const-generics/issues/issue-70125-2.rs", -"ui/const-generics/issues/issue-70180-1-stalled_on.rs", -"ui/const-generics/issues/issue-70180-2-stalled_on.rs", -"ui/const-generics/issues/issue-71202.rs", -"ui/const-generics/issues/issue-72845.rs", -"ui/const-generics/issues/issue-73260.rs", -"ui/const-generics/issues/issue-76701-ty-param-in-const.rs", -"ui/const-generics/issues/issue-79674.rs", -"ui/const-generics/issues/issue-80062.rs", -"ui/const-generics/issues/issue-80375.rs", -"ui/const-generics/issues/issue-82956.rs", -"ui/const-generics/issues/issue-83249.rs", -"ui/const-generics/issues/issue-83288.rs", -"ui/const-generics/issues/issue-83466.rs", -"ui/const-generics/issues/issue-83765.rs", -"ui/const-generics/issues/issue-84659.rs", -"ui/const-generics/issues/issue-86530.rs", -"ui/const-generics/issues/issue-86535-2.rs", -"ui/const-generics/issues/issue-86535.rs", -"ui/const-generics/issues/issue-86820.rs", -"ui/const-generics/issues/issue-87470.rs", -"ui/const-generics/issues/issue-87493.rs", -"ui/const-generics/issues/issue-87964.rs", -"ui/const-generics/issues/issue-88997.rs", -"ui/const-generics/issues/issue-89146.rs", -"ui/const-generics/issues/issue-89320.rs", -"ui/const-generics/issues/issue-89334.rs", -"ui/const-generics/issues/issue-90318.rs", -"ui/const-generics/issues/issue-90364.rs", -"ui/const-generics/issues/issue-90455.rs", -"ui/const-generics/issues/issue-97634.rs", -"ui/const-generics/issues/issue-98629.rs", -"ui/const-generics/issues/issue-100313.rs", -"ui/const-generics/issues/issue-87076.rs", -"ui/const-generics/issues/issue-97278.rs", -"ui/const-generics/issues/issue-99641.rs", -"ui/const-generics/issues/issue-105821.rs", -"ui/const-generics/issues/issue-56445-1.rs", -"ui/const-generics/issues/issue-60818-struct-constructors.rs", -"ui/const-generics/issues/issue-61422.rs", -"ui/const-generics/issues/issue-62878.rs", -"ui/const-generics/issues/issue-63322-forbid-dyn.rs", -"ui/const-generics/issues/issue-64519.rs", -"ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs", -"ui/const-generics/issues/issue-66906.rs", -"ui/const-generics/issues/issue-67185-1.rs", -"ui/const-generics/issues/issue-67375.rs", -"ui/const-generics/issues/issue-67739.rs", -"ui/const-generics/issues/issue-67945-1.rs", -"ui/const-generics/issues/issue-67945-2.rs", -"ui/const-generics/issues/issue-67945-3.rs", -"ui/const-generics/issues/issue-67945-4.rs", -"ui/const-generics/issues/issue-68366.rs", -"ui/const-generics/issues/issue-68596.rs", -"ui/const-generics/issues/issue-68615-adt.rs", -"ui/const-generics/issues/issue-68615-array.rs", -"ui/const-generics/issues/issue-70167.rs", -"ui/const-generics/issues/issue-70225.rs", -"ui/const-generics/issues/issue-70273-assoc-fn.rs", -"ui/const-generics/issues/issue-71169.rs", -"ui/const-generics/issues/issue-71381.rs", -"ui/const-generics/issues/issue-71382.rs", -"ui/const-generics/issues/issue-71547.rs", -"ui/const-generics/issues/issue-71611.rs", -"ui/const-generics/issues/issue-71986.rs", -"ui/const-generics/issues/issue-72352.rs", -"ui/const-generics/issues/issue-73120.rs", -"ui/const-generics/issues/issue-73491.rs", -"ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs", -"ui/const-generics/issues/issue-74101.rs", -"ui/const-generics/issues/issue-74255.rs", -"ui/const-generics/issues/issue-74906.rs", -"ui/const-generics/issues/issue-74950.rs", -"ui/const-generics/issues/issue-75047.rs", -"ui/const-generics/issues/issue-75299.rs", -"ui/const-generics/issues/issue-85031-2.rs", -"ui/const-generics/issues/issue-86033.rs", -"ui/const-generics/issues/issue-88119.rs", -"ui/const-generics/issues/issue-88468.rs", -"ui/const-generics/issues/issue-89304.rs", -"ui/const-generics/issues/issue-92186.rs", -"ui/const-generics/issues/issue-96654.rs", -"ui/const-generics/parser-error-recovery/issue-89013-no-assoc.rs", -"ui/const-generics/parser-error-recovery/issue-89013-no-kw.rs", -"ui/const-generics/parser-error-recovery/issue-89013-type.rs", -"ui/const-generics/parser-error-recovery/issue-89013.rs", -"ui/const-generics/type-dependent/issue-61936.rs", -"ui/const-generics/type-dependent/issue-63695.rs", -"ui/const-generics/type-dependent/issue-69816.rs", -"ui/const-generics/type-dependent/issue-70507.rs", -"ui/const-generics/type-dependent/issue-71382.rs", -"ui/const-generics/type-dependent/issue-71805.rs", -"ui/const-generics/type-dependent/issue-67144-1.rs", -"ui/const-generics/type-dependent/issue-67144-2.rs", -"ui/const-generics/type-dependent/issue-70217.rs", -"ui/const-generics/type-dependent/issue-70586.rs", -"ui/const-generics/type-dependent/issue-71348.rs", -"ui/const-generics/type-dependent/issue-73730.rs", -"ui/const-generics/issue-46511.rs", -"ui/const-generics/issue-70408.rs", -"ui/const-generics/issue-93647.rs", -"ui/const-generics/issue-112505-overflow.rs", -"ui/const-generics/issue-66451.rs", -"ui/const-generics/issue-80471.rs", -"ui/const-generics/issue-102124.rs", -"ui/const-generics/issue-105689.rs", -"ui/const-generics/issue-106419-struct-with-multiple-const-params.rs", -"ui/const-generics/issue-97007.rs", -"ui/const_prop/issue-102553.rs", -"ui/const_prop/issue-86351.rs", -"ui/consts/auxiliary/issue-17718-aux.rs", -"ui/consts/auxiliary/issue-63226.rs", -"ui/consts/const-eval/issue-100878.rs", -"ui/consts/const-eval/issue-104390.rs", -"ui/consts/const-eval/issue-43197.rs", -"ui/consts/const-eval/issue-44578.rs", -"ui/consts/const-eval/issue-49296.rs", -"ui/consts/const-eval/issue-50814-2.rs", -"ui/consts/const-eval/issue-50814.rs", -"ui/consts/const-eval/issue-64908.rs", -"ui/consts/const-eval/issue-64970.rs", -"ui/consts/const-eval/issue-65394.rs", -"ui/consts/const-eval/issue-84957-const-str-as-bytes.rs", -"ui/consts/const-eval/issue-85155.rs", -"ui/consts/const-eval/issue-85907.rs", -"ui/consts/const-eval/issue-91827-extern-types.rs", -"ui/consts/const-eval/issue-52475.rs", -"ui/consts/const-eval/issue-70723.rs", -"ui/consts/const-eval/issue-47971.rs", -"ui/consts/const-eval/issue-50706.rs", -"ui/consts/const-eval/issue-51300.rs", -"ui/consts/const-eval/issue-53157.rs", -"ui/consts/const-eval/issue-53401.rs", -"ui/consts/const-eval/issue-55541.rs", -"ui/consts/const-eval/issue-70804-fn-subtyping.rs", -"ui/consts/const-extern-fn/issue-68062-const-extern-fns-dont-need-fn-specifier-2.rs", -"ui/consts/const-extern-fn/issue-68062-const-extern-fns-dont-need-fn-specifier.rs", -"ui/consts/const-mut-refs/issue-76510.rs", -"ui/consts/const_in_pattern/issue-44333.rs", -"ui/consts/const_in_pattern/issue-62614.rs", -"ui/consts/const_in_pattern/issue-78057.rs", -"ui/consts/const_in_pattern/issue-53708.rs", -"ui/consts/const_in_pattern/issue-65466.rs", -"ui/consts/const_in_pattern/issue-73431.rs", -"ui/consts/control-flow/issue-46843.rs", -"ui/consts/control-flow/issue-50577.rs", -"ui/consts/extra-const-ub/issue-100771.rs", -"ui/consts/extra-const-ub/issue-101034.rs", -"ui/consts/issue-102117.rs", -"ui/consts/issue-103790.rs", -"ui/consts/issue-104609.rs", -"ui/consts/issue-104768.rs", -"ui/consts/issue-13902.rs", -"ui/consts/issue-17458.rs", -"ui/consts/issue-17718-borrow-interior.rs", -"ui/consts/issue-17718-const-bad-values.rs", -"ui/consts/issue-17718-const-borrow.rs", -"ui/consts/issue-17718-constants-not-static.rs", -"ui/consts/issue-17718-references.rs", -"ui/consts/issue-17718.rs", -"ui/consts/issue-17756.rs", -"ui/consts/issue-18294.rs", -"ui/consts/issue-19244.rs", -"ui/consts/issue-21562.rs", -"ui/consts/issue-21721.rs", -"ui/consts/issue-23833.rs", -"ui/consts/issue-23968-const-not-overflow.rs", -"ui/consts/issue-25826.rs", -"ui/consts/issue-27890.rs", -"ui/consts/issue-28113.rs", -"ui/consts/issue-29914-2.rs", -"ui/consts/issue-29914-3.rs", -"ui/consts/issue-29914.rs", -"ui/consts/issue-29927-1.rs", -"ui/consts/issue-29927.rs", -"ui/consts/issue-32829-2.rs", -"ui/consts/issue-32829.rs", -"ui/consts/issue-33537.rs", -"ui/consts/issue-34784.rs", -"ui/consts/issue-36163.rs", -"ui/consts/issue-37222.rs", -"ui/consts/issue-37550.rs", -"ui/consts/issue-37991.rs", -"ui/consts/issue-39974.rs", -"ui/consts/issue-43105.rs", -"ui/consts/issue-44415.rs", -"ui/consts/issue-46553.rs", -"ui/consts/issue-50439.rs", -"ui/consts/issue-52023-array-size-pointer-cast.rs", -"ui/consts/issue-52060.rs", -"ui/consts/issue-54224.rs", -"ui/consts/issue-54348.rs", -"ui/consts/issue-54582.rs", -"ui/consts/issue-54954.rs", -"ui/consts/issue-56164.rs", -"ui/consts/issue-58435-ice-with-assoc-const.rs", -"ui/consts/issue-64506.rs", -"ui/consts/issue-64662.rs", -"ui/consts/issue-66693-panic-in-array-len.rs", -"ui/consts/issue-66693.rs", -"ui/consts/issue-68542-closure-in-array-len.rs", -"ui/consts/issue-69191-ice-on-uninhabited-enum-field.rs", -"ui/consts/issue-69310-array-size-lit-wrong-ty.rs", -"ui/consts/issue-69312.rs", -"ui/consts/issue-69488.rs", -"ui/consts/issue-69532.rs", -"ui/consts/issue-70773-mir-typeck-lt-norm.rs", -"ui/consts/issue-70942-trait-vs-impl-mismatch.rs", -"ui/consts/issue-73976-monomorphic.rs", -"ui/consts/issue-73976-polymorphic.rs", -"ui/consts/issue-76064.rs", -"ui/consts/issue-77062-large-zst-array.rs", -"ui/consts/issue-78655.rs", -"ui/consts/issue-79137-toogeneric.rs", -"ui/consts/issue-83182.rs", -"ui/consts/issue-87046.rs", -"ui/consts/issue-90762.rs", -"ui/consts/issue-90878-2.rs", -"ui/consts/issue-90878-3.rs", -"ui/consts/issue-90878.rs", -"ui/consts/issue-91434.rs", -"ui/consts/issue-94675.rs", -"ui/consts/issue-104155.rs", -"ui/consts/issue-104396.rs", -"ui/consts/issue-13837.rs", -"ui/consts/issue-16538.rs", -"ui/consts/issue-28822.rs", -"ui/consts/issue-29798.rs", -"ui/consts/issue-33903.rs", -"ui/consts/issue-3521.rs", -"ui/consts/issue-37550-1.rs", -"ui/consts/issue-39161-bogus-error.rs", -"ui/consts/issue-47789.rs", -"ui/consts/issue-54387.rs", -"ui/consts/issue-62045.rs", -"ui/consts/issue-63226.rs", -"ui/consts/issue-63952.rs", -"ui/consts/issue-64059.rs", -"ui/consts/issue-65348.rs", -"ui/consts/issue-66342.rs", -"ui/consts/issue-66345.rs", -"ui/consts/issue-66397.rs", -"ui/consts/issue-66787.rs", -"ui/consts/issue-67529.rs", -"ui/consts/issue-67640.rs", -"ui/consts/issue-67641.rs", -"ui/consts/issue-67696-const-prop-ice.rs", -"ui/consts/issue-67862.rs", -"ui/consts/issue-68264-overflow.rs", -"ui/consts/issue-68684.rs", -"ui/consts/issue-6991.rs", -"ui/consts/issue-79137-monomorphic.rs", -"ui/consts/issue-79152-const-array-index.rs", -"ui/consts/issue-79690.rs", -"ui/consts/issue-88071.rs", -"ui/consts/issue-88649.rs", -"ui/consts/issue-89088.rs", -"ui/consts/issue-90870.rs", -"ui/consts/issue-91560.rs", -"ui/consts/issue-94371.rs", -"ui/consts/issue-96169.rs", -"ui/consts/issue-17074.rs", -"ui/cross-crate/issue-64872/issue-64872.rs", -"ui/cycle-trait/issue-12511.rs", -"ui/debuginfo/issue-105386-debuginfo-ub.rs", -"ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs", -"ui/deprecation/issue-84637-deprecated-associated-function.rs", -"ui/derived-errors/issue-30580.rs", -"ui/derived-errors/issue-31997-1.rs", -"ui/derived-errors/issue-31997.rs", -"ui/derives/issue-36617.rs", -"ui/derives/issue-43023.rs", -"ui/derives/issue-91492.rs", -"ui/derives/issue-91550.rs", -"ui/derives/issue-97343.rs", -"ui/deriving/issue-103157.rs", -"ui/deriving/issue-15689-1.rs", -"ui/deriving/issue-19358.rs", -"ui/deriving/issue-3935.rs", -"ui/deriving/issue-58319.rs", -"ui/deriving/issue-105101.rs", -"ui/deriving/issue-15689-2.rs", -"ui/deriving/issue-6341.rs", -"ui/deriving/issue-89188-gat-hrtb.rs", -"ui/did_you_mean/issue-103909.rs", -"ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.rs", -"ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.rs", -"ui/did_you_mean/issue-31424.rs", -"ui/did_you_mean/issue-34126.rs", -"ui/did_you_mean/issue-34337.rs", -"ui/did_you_mean/issue-35937.rs", -"ui/did_you_mean/issue-36798.rs", -"ui/did_you_mean/issue-36798_unknown_field.rs", -"ui/did_you_mean/issue-37139.rs", -"ui/did_you_mean/issue-38054-do-not-show-unresolved-names.rs", -"ui/did_you_mean/issue-38147-1.rs", -"ui/did_you_mean/issue-38147-2.rs", -"ui/did_you_mean/issue-38147-3.rs", -"ui/did_you_mean/issue-38147-4.rs", -"ui/did_you_mean/issue-39544.rs", -"ui/did_you_mean/issue-39802-show-5-trait-impls.rs", -"ui/did_you_mean/issue-40006.rs", -"ui/did_you_mean/issue-40396.rs", -"ui/did_you_mean/issue-40823.rs", -"ui/did_you_mean/issue-42599_available_fields_note.rs", -"ui/did_you_mean/issue-42764.rs", -"ui/did_you_mean/issue-43871-enum-instead-of-variant.rs", -"ui/did_you_mean/issue-46718-struct-pattern-dotdotdot.rs", -"ui/did_you_mean/issue-46836-identifier-not-instead-of-negation.rs", -"ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs", -"ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.rs", -"ui/did_you_mean/issue-53280-expected-float-found-integer-literal.rs", -"ui/did_you_mean/issue-54109-and_instead_of_ampersands.rs", -"ui/did_you_mean/issue-56028-there-is-an-enum-variant.rs", -"ui/did_you_mean/issue-87830-try-brackets-for-arrays.rs", -"ui/did_you_mean/issue-93210-ignore-doc-hidden.rs", -"ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs", -"ui/did_you_mean/issue-54109-without-witness.rs", -"ui/drop/auxiliary/issue-10028.rs", -"ui/drop/issue-10028.rs", -"ui/drop/issue-21486.rs", -"ui/drop/issue-23338-ensure-param-drop-order.rs", -"ui/drop/issue-2734.rs", -"ui/drop/issue-2735-2.rs", -"ui/drop/issue-2735-3.rs", -"ui/drop/issue-2735.rs", -"ui/drop/issue-30018-nopanic.rs", -"ui/drop/issue-35546.rs", -"ui/drop/issue-48962.rs", -"ui/drop/issue-90752-raw-ptr-shenanigans.rs", -"ui/drop/issue-90752.rs", -"ui/drop/issue-979.rs", -"ui/drop/issue-100276.rs", -"ui/drop/issue-103107.rs", -"ui/drop/issue-110682.rs", -"ui/drop/issue-17718-const-destructors.rs", -"ui/dropck/issue-24805-dropck-itemless.rs", -"ui/dropck/issue-28498-ugeh-with-lifetime-param.rs", -"ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs", -"ui/dropck/issue-28498-ugeh-with-trait-bound.rs", -"ui/dropck/issue-29844.rs", -"ui/dropck/issue-34053.rs", -"ui/dropck/issue-38868.rs", -"ui/dropck/issue-54943-1.rs", -"ui/dropck/issue-54943-2.rs", -"ui/dst/issue-90528-unsizing-suggestion-1.rs", -"ui/dst/issue-90528-unsizing-suggestion-2.rs", -"ui/dst/issue-90528-unsizing-suggestion-3.rs", -"ui/dst/issue-90528-unsizing-suggestion-4.rs", -"ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs", -"ui/dyn-star/issue-102430.rs", -"ui/empty/issue-37026.rs", -"ui/enum-discriminant/auxiliary/issue-41394.rs", -"ui/enum-discriminant/issue-104519.rs", -"ui/enum-discriminant/issue-41394-rpass.rs", -"ui/enum-discriminant/issue-41394.rs", -"ui/enum-discriminant/issue-43398.rs", -"ui/enum-discriminant/issue-51582.rs", -"ui/enum-discriminant/issue-61696.rs", -"ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs", -"ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs", -"ui/enum-discriminant/issue-70453-polymorphic-ctfe.rs", -"ui/enum-discriminant/issue-70509-partial_eq.rs", -"ui/enum-discriminant/issue-72554.rs", -"ui/enum-discriminant/issue-90038.rs", -"ui/enum-discriminant/issue-50689.rs", -"ui/enum-discriminant/issue-46519.rs", -"ui/enum/issue-42747.rs", -"ui/enum/issue-67945-1.rs", -"ui/enum/issue-67945-2.rs", -"ui/enum/issue-1821.rs", -"ui/error-codes/e0119/auxiliary/issue-23563-a.rs", -"ui/error-codes/e0119/issue-23563.rs", -"ui/error-codes/e0119/issue-27403.rs", -"ui/error-codes/e0119/issue-28981.rs", -"ui/errors/issue-99572-impl-trait-on-pointer.rs", -"ui/errors/issue-104621-extern-bad-file.rs", -"ui/errors/issue-104621-extern-not-file.rs", -"ui/errors/issue-89280-emitter-overflow-splice-lines.rs", -"ui/expr/if/issue-4201.rs", -"ui/extenv/issue-55897.rs", -"ui/extenv/issue-110547.rs", -"ui/extern/auxiliary/issue-80074-macro.rs", -"ui/extern/issue-10025.rs", -"ui/extern/issue-10763.rs", -"ui/extern/issue-10764-rpass.rs", -"ui/extern/issue-13655.rs", -"ui/extern/issue-36122-accessing-externed-dst.rs", -"ui/extern/issue-112363-extern-item-where-clauses-debug-ice.rs", -"ui/extern/issue-1251.rs", -"ui/extern/issue-28324.rs", -"ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs", -"ui/extern/issue-64655-extern-rust-must-allow-unwind.rs", -"ui/extern/issue-80074.rs", -"ui/extern/issue-95829.rs", -"ui/feature-gates/issue-43106-gating-of-bench.rs", -"ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs", -"ui/feature-gates/issue-43106-gating-of-derive-2.rs", -"ui/feature-gates/issue-43106-gating-of-derive.rs", -"ui/feature-gates/issue-43106-gating-of-macro_use.rs", -"ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs", -"ui/feature-gates/issue-43106-gating-of-stable.rs", -"ui/feature-gates/issue-43106-gating-of-test.rs", -"ui/feature-gates/issue-43106-gating-of-unstable.rs", -"ui/feature-gates/issue-49983-see-issue-0.rs", -"ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs", -"ui/feature-gates/issue-43106-gating-of-deprecated.rs", -"ui/feature-gates/issue-43106-gating-of-macro_escape.rs", -"ui/fmt/issue-103826.rs", -"ui/fmt/issue-104142.rs", -"ui/fmt/issue-75307.rs", -"ui/fmt/issue-86085.rs", -"ui/fmt/issue-89173.rs", -"ui/fmt/issue-91556.rs", -"ui/fn/issue-3044.rs", -"ui/fn/issue-3099.rs", -"ui/fn/issue-3904.rs", -"ui/fn/issue-39259.rs", -"ui/fn/issue-80179.rs", -"ui/for-loop-while/issue-2216.rs", -"ui/for-loop-while/issue-51345.rs", -"ui/for-loop-while/issue-69841.rs", -"ui/for-loop-while/issue-1257.rs", -"ui/for/issue-20605.rs", -"ui/foreign/issue-91370-foreign-fn-block-impl.rs", -"ui/foreign/issue-74120-lowering-of-ffi-block-bodies.rs", -"ui/foreign/issue-99276-same-type-lifetimes.rs", -"ui/function-pointer/issue-102289.rs", -"ui/functions-closures/closure-expected-type/issue-38714.rs", -"ui/generator/issue-113279.rs", -"ui/generator/issue-44197.rs", -"ui/generator/issue-48048.rs", -"ui/generator/issue-52398.rs", -"ui/generator/issue-64620-yield-array-element.rs", -"ui/generator/issue-69039.rs", -"ui/generator/issue-88653.rs", -"ui/generator/issue-91477.rs", -"ui/generator/issue-102645.rs", -"ui/generator/issue-105084.rs", -"ui/generator/issue-110929-generator-conflict-error-ice.rs", -"ui/generator/issue-45729-unsafe-in-generator.rs", -"ui/generator/issue-52304.rs", -"ui/generator/issue-53548-1.rs", -"ui/generator/issue-53548.rs", -"ui/generator/issue-57017.rs", -"ui/generator/issue-57084.rs", -"ui/generator/issue-57478.rs", -"ui/generator/issue-58888.rs", -"ui/generator/issue-61442-stmt-expr-with-drop.rs", -"ui/generator/issue-62506-two_awaits.rs", -"ui/generator/issue-68112.rs", -"ui/generator/issue-69017.rs", -"ui/generator/issue-87142.rs", -"ui/generator/issue-93161.rs", -"ui/generic-associated-types/bugs/issue-87735.rs", -"ui/generic-associated-types/bugs/issue-87755.rs", -"ui/generic-associated-types/bugs/issue-87803.rs", -"ui/generic-associated-types/bugs/issue-88382.rs", -"ui/generic-associated-types/bugs/issue-88460.rs", -"ui/generic-associated-types/bugs/issue-88526.rs", -"ui/generic-associated-types/bugs/issue-91762.rs", -"ui/generic-associated-types/bugs/issue-100013.rs", -"ui/generic-associated-types/bugs/issue-80626.rs", -"ui/generic-associated-types/issue-101020.rs", -"ui/generic-associated-types/issue-102114.rs", -"ui/generic-associated-types/issue-102335-gat.rs", -"ui/generic-associated-types/issue-47206-where-clause.rs", -"ui/generic-associated-types/issue-67510.rs", -"ui/generic-associated-types/issue-68641-check-gat-bounds.rs", -"ui/generic-associated-types/issue-68642-broken-llvm-ir.rs", -"ui/generic-associated-types/issue-68643-broken-mir.rs", -"ui/generic-associated-types/issue-68644-codegen-selection.rs", -"ui/generic-associated-types/issue-68645-codegen-fulfillment.rs", -"ui/generic-associated-types/issue-68648-2.rs", -"ui/generic-associated-types/issue-68656-unsized-values.rs", -"ui/generic-associated-types/issue-70304.rs", -"ui/generic-associated-types/issue-71176.rs", -"ui/generic-associated-types/issue-74684-1.rs", -"ui/generic-associated-types/issue-74684-2.rs", -"ui/generic-associated-types/issue-74816.rs", -"ui/generic-associated-types/issue-74824.rs", -"ui/generic-associated-types/issue-76826.rs", -"ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs", -"ui/generic-associated-types/issue-79636-1.rs", -"ui/generic-associated-types/issue-79636-2.rs", -"ui/generic-associated-types/issue-80433.rs", -"ui/generic-associated-types/issue-81487.rs", -"ui/generic-associated-types/issue-81712-cyclic-traits.rs", -"ui/generic-associated-types/issue-81862.rs", -"ui/generic-associated-types/issue-84931.rs", -"ui/generic-associated-types/issue-86787.rs", -"ui/generic-associated-types/issue-87258_a.rs", -"ui/generic-associated-types/issue-87258_b.rs", -"ui/generic-associated-types/issue-87429-associated-type-default.rs", -"ui/generic-associated-types/issue-87429-specialization.rs", -"ui/generic-associated-types/issue-91139.rs", -"ui/generic-associated-types/issue-91883.rs", -"ui/generic-associated-types/issue-92033.rs", -"ui/generic-associated-types/issue-95305.rs", -"ui/generic-associated-types/issue-102333.rs", -"ui/generic-associated-types/issue-58694-parameter-out-of-range.rs", -"ui/generic-associated-types/issue-62326-parameter-out-of-range.rs", -"ui/generic-associated-types/issue-67424.rs", -"ui/generic-associated-types/issue-67510-pass.rs", -"ui/generic-associated-types/issue-68648-1.rs", -"ui/generic-associated-types/issue-68649-pass.rs", -"ui/generic-associated-types/issue-68653.rs", -"ui/generic-associated-types/issue-70303.rs", -"ui/generic-associated-types/issue-76407.rs", -"ui/generic-associated-types/issue-76535.rs", -"ui/generic-associated-types/issue-78671.rs", -"ui/generic-associated-types/issue-79422.rs", -"ui/generic-associated-types/issue-80433-reduced.rs", -"ui/generic-associated-types/issue-85921.rs", -"ui/generic-associated-types/issue-86218-2.rs", -"ui/generic-associated-types/issue-86218.rs", -"ui/generic-associated-types/issue-86483.rs", -"ui/generic-associated-types/issue-87429-2.rs", -"ui/generic-associated-types/issue-87429.rs", -"ui/generic-associated-types/issue-87748.rs", -"ui/generic-associated-types/issue-87750.rs", -"ui/generic-associated-types/issue-88287.rs", -"ui/generic-associated-types/issue-88360.rs", -"ui/generic-associated-types/issue-88405.rs", -"ui/generic-associated-types/issue-88459.rs", -"ui/generic-associated-types/issue-89008.rs", -"ui/generic-associated-types/issue-89352.rs", -"ui/generic-associated-types/issue-90014.rs", -"ui/generic-associated-types/issue-90729.rs", -"ui/generic-associated-types/issue-92096.rs", -"ui/generic-associated-types/issue-92280.rs", -"ui/generic-associated-types/issue-92954.rs", -"ui/generic-associated-types/issue-93141.rs", -"ui/generic-associated-types/issue-93262.rs", -"ui/generic-associated-types/issue-93340.rs", -"ui/generic-associated-types/issue-93341.rs", -"ui/generic-associated-types/issue-93342.rs", -"ui/generic-associated-types/issue-93874.rs", -"ui/generic-associated-types/issue-88595.rs", -"ui/generic-associated-types/issue-90014-tait.rs", -"ui/generic-associated-types/issue-90014-tait2.rs", -"ui/generics/issue-106694.rs", -"ui/generics/issue-1112.rs", -"ui/generics/issue-2936.rs", -"ui/generics/issue-32498.rs", -"ui/generics/issue-333.rs", -"ui/generics/issue-59508-1.rs", -"ui/generics/issue-61631-default-type-param-can-reference-self-in-trait.rs", -"ui/generics/issue-61631-default-type-param-cannot-reference-self.rs", -"ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs", -"ui/generics/issue-79605.rs", -"ui/generics/issue-80512-param-reordering-with-defaults.rs", -"ui/generics/issue-94432-garbage-ice.rs", -"ui/generics/issue-98432.rs", -"ui/generics/issue-59508.rs", -"ui/generics/issue-94923.rs", -"ui/generics/issue-95208-ignore-qself.rs", -"ui/generics/issue-95208.rs", -"ui/hygiene/issue-15221.rs", -"ui/hygiene/issue-40847.rs", -"ui/hygiene/issue-77523-def-site-async-await.rs", -"ui/hygiene/issue-32922.rs", -"ui/hygiene/issue-44128.rs", -"ui/hygiene/issue-47311.rs", -"ui/hygiene/issue-47312.rs", -"ui/hygiene/issue-61574-const-parameters.rs", -"ui/impl-trait/explicit-generic-args-with-impl-trait/issue-87718.rs", -"ui/impl-trait/in-trait/issue-102140.rs", -"ui/impl-trait/in-trait/issue-102301.rs", -"ui/impl-trait/in-trait/issue-102571.rs", -"ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.rs", -"ui/impl-trait/issues/issue-54600.rs", -"ui/impl-trait/issues/issue-54840.rs", -"ui/impl-trait/issues/issue-54895.rs", -"ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs", -"ui/impl-trait/issues/issue-57979-impl-trait-in-path.rs", -"ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.rs", -"ui/impl-trait/issues/issue-58504.rs", -"ui/impl-trait/issues/issue-58956.rs", -"ui/impl-trait/issues/issue-62742.rs", -"ui/impl-trait/issues/issue-67830.rs", -"ui/impl-trait/issues/issue-70971.rs", -"ui/impl-trait/issues/issue-79099.rs", -"ui/impl-trait/issues/issue-82139.rs", -"ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs", -"ui/impl-trait/issues/issue-84073.rs", -"ui/impl-trait/issues/issue-84919.rs", -"ui/impl-trait/issues/issue-86642.rs", -"ui/impl-trait/issues/issue-86719.rs", -"ui/impl-trait/issues/issue-87295.rs", -"ui/impl-trait/issues/issue-87340.rs", -"ui/impl-trait/issues/issue-88236-2.rs", -"ui/impl-trait/issues/issue-88236.rs", -"ui/impl-trait/issues/issue-99348-impl-compatibility.rs", -"ui/impl-trait/issues/issue-104815.rs", -"ui/impl-trait/issues/issue-105826.rs", -"ui/impl-trait/issues/issue-42479.rs", -"ui/impl-trait/issues/issue-49376.rs", -"ui/impl-trait/issues/issue-52128.rs", -"ui/impl-trait/issues/issue-53457.rs", -"ui/impl-trait/issues/issue-55608-captures-empty-region.rs", -"ui/impl-trait/issues/issue-57464-unexpected-regions.rs", -"ui/impl-trait/issues/issue-77987.rs", -"ui/impl-trait/issues/issue-83919.rs", -"ui/impl-trait/issues/issue-86201.rs", -"ui/impl-trait/issues/issue-86800.rs", -"ui/impl-trait/issues/issue-89312.rs", -"ui/impl-trait/issues/issue-92305.rs", -"ui/impl-trait/issues/issue-93788.rs", -"ui/impl-trait/issues/issue-65581.rs", -"ui/impl-trait/issues/issue-70877.rs", -"ui/impl-trait/issues/issue-74282.rs", -"ui/impl-trait/issues/issue-78722-2.rs", -"ui/impl-trait/issues/issue-78722.rs", -"ui/impl-trait/issue-100075-2.rs", -"ui/impl-trait/issue-100075.rs", -"ui/impl-trait/issue-35668.rs", -"ui/impl-trait/issue-36792.rs", -"ui/impl-trait/issue-49685.rs", -"ui/impl-trait/issue-51185.rs", -"ui/impl-trait/issue-54966.rs", -"ui/impl-trait/issue-55872-1.rs", -"ui/impl-trait/issue-55872.rs", -"ui/impl-trait/issue-72911.rs", -"ui/impl-trait/issue-86465.rs", -"ui/impl-trait/issue-87450.rs", -"ui/impl-trait/issue-99073-2.rs", -"ui/impl-trait/issue-99073.rs", -"ui/impl-trait/issue-100187.rs", -"ui/impl-trait/issue-102605.rs", -"ui/impl-trait/issue-103181-1.rs", -"ui/impl-trait/issue-103599.rs", -"ui/impl-trait/issue-108591.rs", -"ui/impl-trait/issue-108592.rs", -"ui/impl-trait/issue-46959.rs", -"ui/impl-trait/issue-49556.rs", -"ui/impl-trait/issue-49579.rs", -"ui/impl-trait/issue-55872-2.rs", -"ui/impl-trait/issue-56445.rs", -"ui/impl-trait/issue-68532.rs", -"ui/impl-trait/issue-99642-2.rs", -"ui/impl-trait/issue-99642.rs", -"ui/impl-trait/issue-99914.rs", -"ui/impl-trait/issue-103181-2.rs", -"ui/impl-trait/issue-55872-3.rs", -"ui/implied-bounds/issue-100690.rs", -"ui/implied-bounds/issue-101951.rs", -"ui/implied-bounds/issue-110161.rs", -"ui/imports/auxiliary/issue-36881-aux.rs", -"ui/imports/auxiliary/issue-52891.rs", -"ui/imports/auxiliary/issue-55811.rs", -"ui/imports/auxiliary/issue-56125.rs", -"ui/imports/auxiliary/issue-59764.rs", -"ui/imports/auxiliary/issue-85992-extern-1.rs", -"ui/imports/auxiliary/issue-85992-extern-2.rs", -"ui/imports/issue-26873-multifile/issue-26873-multifile.rs", -"ui/imports/issue-26873-multifile/issue-26873-onefile.rs", -"ui/imports/issue-45829/auxiliary/issue-45829-a.rs", -"ui/imports/issue-45829/auxiliary/issue-45829-b.rs", -"ui/imports/issue-45829/issue-45829.rs", -"ui/imports/issue-113953.rs", -"ui/imports/issue-109343.rs", -"ui/imports/issue-13404.rs", -"ui/imports/issue-1697.rs", -"ui/imports/issue-19498.rs", -"ui/imports/issue-24081.rs", -"ui/imports/issue-25396.rs", -"ui/imports/issue-26886.rs", -"ui/imports/issue-28388-1.rs", -"ui/imports/issue-28388-2.rs", -"ui/imports/issue-2937.rs", -"ui/imports/issue-30560.rs", -"ui/imports/issue-31212.rs", -"ui/imports/issue-32833.rs", -"ui/imports/issue-33464.rs", -"ui/imports/issue-36881.rs", -"ui/imports/issue-37887.rs", -"ui/imports/issue-38293.rs", -"ui/imports/issue-4366-2.rs", -"ui/imports/issue-4366.rs", -"ui/imports/issue-47623.rs", -"ui/imports/issue-4865-1.rs", -"ui/imports/issue-4865-2.rs", -"ui/imports/issue-4865-3.rs", -"ui/imports/issue-53269.rs", -"ui/imports/issue-53512.rs", -"ui/imports/issue-53565.rs", -"ui/imports/issue-55457.rs", -"ui/imports/issue-55884-1.rs", -"ui/imports/issue-57015.rs", -"ui/imports/issue-8208.rs", -"ui/imports/issue-8640.rs", -"ui/imports/issue-55884-2.rs", -"ui/imports/issue-109148.rs", -"ui/imports/issue-18083.rs", -"ui/imports/issue-24883.rs", -"ui/imports/issue-26930.rs", -"ui/imports/issue-28134.rs", -"ui/imports/issue-32119.rs", -"ui/imports/issue-32222.rs", -"ui/imports/issue-32354-suggest-import-rename.rs", -"ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs", -"ui/imports/issue-52891.rs", -"ui/imports/issue-53140.rs", -"ui/imports/issue-55811.rs", -"ui/imports/issue-56125.rs", -"ui/imports/issue-56263.rs", -"ui/imports/issue-57539.rs", -"ui/imports/issue-59764.rs", -"ui/imports/issue-62767.rs", -"ui/imports/issue-68103.rs", -"ui/imports/issue-99695-b.rs", -"ui/imports/issue-99695.rs", -"ui/imports/issue-85992.rs", -"ui/inference/need_type_info/issue-103053.rs", -"ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.rs", -"ui/inference/need_type_info/issue-109905.rs", -"ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs", -"ui/inference/issue-103587.rs", -"ui/inference/issue-104649.rs", -"ui/inference/issue-107090.rs", -"ui/inference/issue-36053.rs", -"ui/inference/issue-70082.rs", -"ui/inference/issue-71309.rs", -"ui/inference/issue-71584.rs", -"ui/inference/issue-71732.rs", -"ui/inference/issue-72616.rs", -"ui/inference/issue-72690.rs", -"ui/inference/issue-80816.rs", -"ui/inference/issue-81522.rs", -"ui/inference/issue-83606.rs", -"ui/inference/issue-86162-1.rs", -"ui/inference/issue-86162-2.rs", -"ui/inference/issue-28935.rs", -"ui/inference/issue-70703.rs", -"ui/inference/issue-80409.rs", -"ui/inference/issue-113354.rs", -"ui/infinite/issue-41731-infinite-macro-print.rs", -"ui/infinite/issue-41731-infinite-macro-println.rs", -"ui/intrinsics/issue-28575.rs", -"ui/intrinsics/issue-84297-reifying-copy.rs", -"ui/issues/auxiliary/issue-11224.rs", -"ui/issues/auxiliary/issue-11508.rs", -"ui/issues/auxiliary/issue-11529.rs", -"ui/issues/auxiliary/issue-11680.rs", -"ui/issues/auxiliary/issue-12133-dylib.rs", -"ui/issues/auxiliary/issue-12133-dylib2.rs", -"ui/issues/auxiliary/issue-12133-rlib.rs", -"ui/issues/auxiliary/issue-12612-1.rs", -"ui/issues/auxiliary/issue-12612-2.rs", -"ui/issues/auxiliary/issue-12660-aux.rs", -"ui/issues/auxiliary/issue-13507.rs", -"ui/issues/auxiliary/issue-13620-1.rs", -"ui/issues/auxiliary/issue-13620-2.rs", -"ui/issues/auxiliary/issue-13872-1.rs", -"ui/issues/auxiliary/issue-13872-2.rs", -"ui/issues/auxiliary/issue-13872-3.rs", -"ui/issues/auxiliary/issue-14344-1.rs", -"ui/issues/auxiliary/issue-14344-2.rs", -"ui/issues/auxiliary/issue-14421.rs", -"ui/issues/auxiliary/issue-14422.rs", -"ui/issues/auxiliary/issue-15562.rs", -"ui/issues/auxiliary/issue-16643.rs", -"ui/issues/auxiliary/issue-16725.rs", -"ui/issues/auxiliary/issue-17662.rs", -"ui/issues/auxiliary/issue-18501.rs", -"ui/issues/auxiliary/issue-18514.rs", -"ui/issues/auxiliary/issue-18711.rs", -"ui/issues/auxiliary/issue-18913-1.rs", -"ui/issues/auxiliary/issue-18913-2.rs", -"ui/issues/auxiliary/issue-1920.rs", -"ui/issues/auxiliary/issue-19293.rs", -"ui/issues/auxiliary/issue-19340-1.rs", -"ui/issues/auxiliary/issue-20389.rs", -"ui/issues/auxiliary/issue-21202.rs", -"ui/issues/auxiliary/issue-2170-lib.rs", -"ui/issues/auxiliary/issue-2316-a.rs", -"ui/issues/auxiliary/issue-2316-b.rs", -"ui/issues/auxiliary/issue-2380.rs", -"ui/issues/auxiliary/issue-2414-a.rs", -"ui/issues/auxiliary/issue-2414-b.rs", -"ui/issues/auxiliary/issue-2472-b.rs", -"ui/issues/auxiliary/issue-25185-1.rs", -"ui/issues/auxiliary/issue-25185-2.rs", -"ui/issues/auxiliary/issue-2526.rs", -"ui/issues/auxiliary/issue-25467.rs", -"ui/issues/auxiliary/issue-2631-a.rs", -"ui/issues/auxiliary/issue-2723-a.rs", -"ui/issues/auxiliary/issue-29181.rs", -"ui/issues/auxiliary/issue-29265.rs", -"ui/issues/auxiliary/issue-29485.rs", -"ui/issues/auxiliary/issue-3012-1.rs", -"ui/issues/auxiliary/issue-30123-aux.rs", -"ui/issues/auxiliary/issue-3136-a.rs", -"ui/issues/auxiliary/issue-31702-1.rs", -"ui/issues/auxiliary/issue-34796-aux.rs", -"ui/issues/auxiliary/issue-36954.rs", -"ui/issues/auxiliary/issue-38190.rs", -"ui/issues/auxiliary/issue-38226-aux.rs", -"ui/issues/auxiliary/issue-3979-traits.rs", -"ui/issues/auxiliary/issue-41053.rs", -"ui/issues/auxiliary/issue-41549.rs", -"ui/issues/auxiliary/issue-42007-s.rs", -"ui/issues/auxiliary/issue-4208-cc.rs", -"ui/issues/auxiliary/issue-4545.rs", -"ui/issues/auxiliary/issue-48984-aux.rs", -"ui/issues/auxiliary/issue-49544.rs", -"ui/issues/auxiliary/issue-51798.rs", -"ui/issues/auxiliary/issue-52489.rs", -"ui/issues/auxiliary/issue-5518.rs", -"ui/issues/auxiliary/issue-5521.rs", -"ui/issues/auxiliary/issue-56943.rs", -"ui/issues/auxiliary/issue-57271-lib.rs", -"ui/issues/auxiliary/issue-5844-aux.rs", -"ui/issues/auxiliary/issue-7178.rs", -"ui/issues/auxiliary/issue-73112.rs", -"ui/issues/auxiliary/issue-7899.rs", -"ui/issues/auxiliary/issue-8044.rs", -"ui/issues/auxiliary/issue-8259.rs", -"ui/issues/auxiliary/issue-8401.rs", -"ui/issues/auxiliary/issue-9123.rs", -"ui/issues/auxiliary/issue-9155.rs", -"ui/issues/auxiliary/issue-9188.rs", -"ui/issues/auxiliary/issue-9906.rs", -"ui/issues/auxiliary/issue-9968.rs", -"ui/issues/auxiliary/issue-111011.rs", -"ui/issues/auxiliary/issue-31702-2.rs", -"ui/issues/issue-24687-embed-debuginfo/auxiliary/issue-24687-lib.rs", -"ui/issues/issue-24687-embed-debuginfo/auxiliary/issue-24687-mbcs-in-comments.rs", -"ui/issues/issue-37311-type-length-limit/issue-37311.rs", -"ui/issues/issue-38875/auxiliary/issue-38875-b.rs", -"ui/issues/issue-38875/issue-38875.rs", -"ui/issues/issue-40402-ref-hints/issue-40402-1.rs", -"ui/issues/issue-40402-ref-hints/issue-40402-2.rs", -"ui/issues/issue-41652/auxiliary/issue-41652-b.rs", -"ui/issues/issue-41652/issue-41652.rs", -"ui/issues/issue-70093/issue-70093-link-directives.rs", -"ui/issues/issue-70093/issue-70093.rs", -"ui/issues/issue-77218/issue-77218-2.rs", -"ui/issues/issue-77218/issue-77218.rs", -"ui/issues/issue-100605.rs", -"ui/issues/issue-10228.rs", -"ui/issues/issue-10291.rs", -"ui/issues/issue-102964.rs", -"ui/issues/issue-10412.rs", -"ui/issues/issue-10436.rs", -"ui/issues/issue-10465.rs", -"ui/issues/issue-10545.rs", -"ui/issues/issue-10638.rs", -"ui/issues/issue-10656.rs", -"ui/issues/issue-10682.rs", -"ui/issues/issue-10683.rs", -"ui/issues/issue-10718.rs", -"ui/issues/issue-10734.rs", -"ui/issues/issue-10764.rs", -"ui/issues/issue-10767.rs", -"ui/issues/issue-10802.rs", -"ui/issues/issue-10806.rs", -"ui/issues/issue-10877.rs", -"ui/issues/issue-11004.rs", -"ui/issues/issue-11192.rs", -"ui/issues/issue-11205.rs", -"ui/issues/issue-11224.rs", -"ui/issues/issue-11267.rs", -"ui/issues/issue-11374.rs", -"ui/issues/issue-11382.rs", -"ui/issues/issue-11508.rs", -"ui/issues/issue-11529.rs", -"ui/issues/issue-11552.rs", -"ui/issues/issue-11593.rs", -"ui/issues/issue-11677.rs", -"ui/issues/issue-11680.rs", -"ui/issues/issue-11681.rs", -"ui/issues/issue-11692-1.rs", -"ui/issues/issue-11692-2.rs", -"ui/issues/issue-11771.rs", -"ui/issues/issue-11820.rs", -"ui/issues/issue-11844.rs", -"ui/issues/issue-11873.rs", -"ui/issues/issue-11958.rs", -"ui/issues/issue-12028.rs", -"ui/issues/issue-12033.rs", -"ui/issues/issue-12041.rs", -"ui/issues/issue-12127.rs", -"ui/issues/issue-12133-1.rs", -"ui/issues/issue-12133-2.rs", -"ui/issues/issue-12187-1.rs", -"ui/issues/issue-12187-2.rs", -"ui/issues/issue-12285.rs", -"ui/issues/issue-12567.rs", -"ui/issues/issue-12612.rs", -"ui/issues/issue-12660.rs", -"ui/issues/issue-12677.rs", -"ui/issues/issue-12699.rs", -"ui/issues/issue-12744.rs", -"ui/issues/issue-12860.rs", -"ui/issues/issue-12863.rs", -"ui/issues/issue-12909.rs", -"ui/issues/issue-13027.rs", -"ui/issues/issue-13033.rs", -"ui/issues/issue-13058.rs", -"ui/issues/issue-13204.rs", -"ui/issues/issue-13214.rs", -"ui/issues/issue-13259-windows-tcb-trash.rs", -"ui/issues/issue-13264.rs", -"ui/issues/issue-13323.rs", -"ui/issues/issue-13359.rs", -"ui/issues/issue-13407.rs", -"ui/issues/issue-13434.rs", -"ui/issues/issue-13446.rs", -"ui/issues/issue-13466.rs", -"ui/issues/issue-13482.rs", -"ui/issues/issue-13497-2.rs", -"ui/issues/issue-13497.rs", -"ui/issues/issue-13507-2.rs", -"ui/issues/issue-1362.rs", -"ui/issues/issue-13620.rs", -"ui/issues/issue-13665.rs", -"ui/issues/issue-13763.rs", -"ui/issues/issue-13808.rs", -"ui/issues/issue-13847.rs", -"ui/issues/issue-13867.rs", -"ui/issues/issue-13872.rs", -"ui/issues/issue-14091-2.rs", -"ui/issues/issue-14091.rs", -"ui/issues/issue-14092.rs", -"ui/issues/issue-14229.rs", -"ui/issues/issue-14285.rs", -"ui/issues/issue-14308.rs", -"ui/issues/issue-14344.rs", -"ui/issues/issue-14366.rs", -"ui/issues/issue-14382.rs", -"ui/issues/issue-14393.rs", -"ui/issues/issue-14399.rs", -"ui/issues/issue-14421.rs", -"ui/issues/issue-14422.rs", -"ui/issues/issue-1448-2.rs", -"ui/issues/issue-1451.rs", -"ui/issues/issue-14541.rs", -"ui/issues/issue-1460.rs", -"ui/issues/issue-14721.rs", -"ui/issues/issue-1476.rs", -"ui/issues/issue-14821.rs", -"ui/issues/issue-14845.rs", -"ui/issues/issue-14853.rs", -"ui/issues/issue-14865.rs", -"ui/issues/issue-14875.rs", -"ui/issues/issue-14915.rs", -"ui/issues/issue-14919.rs", -"ui/issues/issue-15034.rs", -"ui/issues/issue-15043.rs", -"ui/issues/issue-15063.rs", -"ui/issues/issue-15094.rs", -"ui/issues/issue-15104.rs", -"ui/issues/issue-15129-rpass.rs", -"ui/issues/issue-15155.rs", -"ui/issues/issue-15167.rs", -"ui/issues/issue-15189.rs", -"ui/issues/issue-15207.rs", -"ui/issues/issue-15260.rs", -"ui/issues/issue-15381.rs", -"ui/issues/issue-15444.rs", -"ui/issues/issue-15523-big.rs", -"ui/issues/issue-15523.rs", -"ui/issues/issue-15562.rs", -"ui/issues/issue-15571.rs", -"ui/issues/issue-15673.rs", -"ui/issues/issue-15756.rs", -"ui/issues/issue-15763.rs", -"ui/issues/issue-15774.rs", -"ui/issues/issue-15783.rs", -"ui/issues/issue-15793.rs", -"ui/issues/issue-15858.rs", -"ui/issues/issue-15896.rs", -"ui/issues/issue-15965.rs", -"ui/issues/issue-16048.rs", -"ui/issues/issue-16149.rs", -"ui/issues/issue-16151.rs", -"ui/issues/issue-16250.rs", -"ui/issues/issue-16256.rs", -"ui/issues/issue-16278.rs", -"ui/issues/issue-16338.rs", -"ui/issues/issue-16401.rs", -"ui/issues/issue-16441.rs", -"ui/issues/issue-16452.rs", -"ui/issues/issue-16492.rs", -"ui/issues/issue-16530.rs", -"ui/issues/issue-16560.rs", -"ui/issues/issue-16562.rs", -"ui/issues/issue-1660.rs", -"ui/issues/issue-16643.rs", -"ui/issues/issue-16648.rs", -"ui/issues/issue-16671.rs", -"ui/issues/issue-16683.rs", -"ui/issues/issue-16725.rs", -"ui/issues/issue-16739.rs", -"ui/issues/issue-16745.rs", -"ui/issues/issue-16774.rs", -"ui/issues/issue-16783.rs", -"ui/issues/issue-16819.rs", -"ui/issues/issue-16922-rpass.rs", -"ui/issues/issue-16922.rs", -"ui/issues/issue-16939.rs", -"ui/issues/issue-1696.rs", -"ui/issues/issue-16966.rs", -"ui/issues/issue-17001.rs", -"ui/issues/issue-17033.rs", -"ui/issues/issue-17068.rs", -"ui/issues/issue-17216.rs", -"ui/issues/issue-17252.rs", -"ui/issues/issue-17302.rs", -"ui/issues/issue-17322.rs", -"ui/issues/issue-17336.rs", -"ui/issues/issue-17337.rs", -"ui/issues/issue-17351.rs", -"ui/issues/issue-17361.rs", -"ui/issues/issue-17373.rs", -"ui/issues/issue-17385.rs", -"ui/issues/issue-17405.rs", -"ui/issues/issue-17431-1.rs", -"ui/issues/issue-17431-2.rs", -"ui/issues/issue-17431-3.rs", -"ui/issues/issue-17431-4.rs", -"ui/issues/issue-17431-5.rs", -"ui/issues/issue-17431-6.rs", -"ui/issues/issue-17431-7.rs", -"ui/issues/issue-17441.rs", -"ui/issues/issue-17450.rs", -"ui/issues/issue-17503.rs", -"ui/issues/issue-17546.rs", -"ui/issues/issue-17551.rs", -"ui/issues/issue-17651.rs", -"ui/issues/issue-17662.rs", -"ui/issues/issue-17734.rs", -"ui/issues/issue-17740.rs", -"ui/issues/issue-17758.rs", -"ui/issues/issue-17771.rs", -"ui/issues/issue-17800.rs", -"ui/issues/issue-17816.rs", -"ui/issues/issue-17877.rs", -"ui/issues/issue-17897.rs", -"ui/issues/issue-17904-2.rs", -"ui/issues/issue-17905-2.rs", -"ui/issues/issue-17905.rs", -"ui/issues/issue-17933.rs", -"ui/issues/issue-17954.rs", -"ui/issues/issue-17959.rs", -"ui/issues/issue-17994.rs", -"ui/issues/issue-17999.rs", -"ui/issues/issue-18058.rs", -"ui/issues/issue-18107.rs", -"ui/issues/issue-18110.rs", -"ui/issues/issue-18119.rs", -"ui/issues/issue-18159.rs", -"ui/issues/issue-18173.rs", -"ui/issues/issue-18183.rs", -"ui/issues/issue-18232.rs", -"ui/issues/issue-18352.rs", -"ui/issues/issue-18353.rs", -"ui/issues/issue-18423.rs", -"ui/issues/issue-18446.rs", -"ui/issues/issue-18464.rs", -"ui/issues/issue-18501.rs", -"ui/issues/issue-18514.rs", -"ui/issues/issue-18532.rs", -"ui/issues/issue-18539.rs", -"ui/issues/issue-18566.rs", -"ui/issues/issue-18611.rs", -"ui/issues/issue-18685.rs", -"ui/issues/issue-18711.rs", -"ui/issues/issue-18767.rs", -"ui/issues/issue-18783.rs", -"ui/issues/issue-18819.rs", -"ui/issues/issue-18845.rs", -"ui/issues/issue-18859.rs", -"ui/issues/issue-18913.rs", -"ui/issues/issue-18919.rs", -"ui/issues/issue-18952.rs", -"ui/issues/issue-18959.rs", -"ui/issues/issue-1900.rs", -"ui/issues/issue-19001.rs", -"ui/issues/issue-19086.rs", -"ui/issues/issue-19127.rs", -"ui/issues/issue-19135.rs", -"ui/issues/issue-1920-1.rs", -"ui/issues/issue-1920-2.rs", -"ui/issues/issue-1920-3.rs", -"ui/issues/issue-19244-1.rs", -"ui/issues/issue-19244-2.rs", -"ui/issues/issue-19293.rs", -"ui/issues/issue-19340-1.rs", -"ui/issues/issue-19340-2.rs", -"ui/issues/issue-19367.rs", -"ui/issues/issue-19380.rs", -"ui/issues/issue-19404.rs", -"ui/issues/issue-19482.rs", -"ui/issues/issue-19499.rs", -"ui/issues/issue-19521.rs", -"ui/issues/issue-19692.rs", -"ui/issues/issue-19707.rs", -"ui/issues/issue-19734.rs", -"ui/issues/issue-1974.rs", -"ui/issues/issue-19811-escape-unicode.rs", -"ui/issues/issue-19922.rs", -"ui/issues/issue-19991.rs", -"ui/issues/issue-20055-box-trait.rs", -"ui/issues/issue-20055-box-unsized-array.rs", -"ui/issues/issue-20162.rs", -"ui/issues/issue-20174.rs", -"ui/issues/issue-20225.rs", -"ui/issues/issue-20261.rs", -"ui/issues/issue-20313-rpass.rs", -"ui/issues/issue-20313.rs", -"ui/issues/issue-20389.rs", -"ui/issues/issue-20413.rs", -"ui/issues/issue-20427.rs", -"ui/issues/issue-20433.rs", -"ui/issues/issue-20544.rs", -"ui/issues/issue-20575.rs", -"ui/issues/issue-20616.rs", -"ui/issues/issue-20676.rs", -"ui/issues/issue-20714.rs", -"ui/issues/issue-2074.rs", -"ui/issues/issue-20772.rs", -"ui/issues/issue-20797.rs", -"ui/issues/issue-20803.rs", -"ui/issues/issue-20831-debruijn.rs", -"ui/issues/issue-20847.rs", -"ui/issues/issue-20939.rs", -"ui/issues/issue-20953.rs", -"ui/issues/issue-21033.rs", -"ui/issues/issue-21160.rs", -"ui/issues/issue-21174.rs", -"ui/issues/issue-21177.rs", -"ui/issues/issue-21202.rs", -"ui/issues/issue-21291.rs", -"ui/issues/issue-21306.rs", -"ui/issues/issue-21332.rs", -"ui/issues/issue-21361.rs", -"ui/issues/issue-21384.rs", -"ui/issues/issue-21400.rs", -"ui/issues/issue-21449.rs", -"ui/issues/issue-2150.rs", -"ui/issues/issue-2151.rs", -"ui/issues/issue-21546.rs", -"ui/issues/issue-21554.rs", -"ui/issues/issue-21596.rs", -"ui/issues/issue-21600.rs", -"ui/issues/issue-21634.rs", -"ui/issues/issue-21655.rs", -"ui/issues/issue-2170-exe.rs", -"ui/issues/issue-21701.rs", -"ui/issues/issue-21763.rs", -"ui/issues/issue-21837.rs", -"ui/issues/issue-21891.rs", -"ui/issues/issue-2190-1.rs", -"ui/issues/issue-21909.rs", -"ui/issues/issue-21922.rs", -"ui/issues/issue-21946.rs", -"ui/issues/issue-21950.rs", -"ui/issues/issue-21974.rs", -"ui/issues/issue-22008.rs", -"ui/issues/issue-22034.rs", -"ui/issues/issue-22036.rs", -"ui/issues/issue-2214.rs", -"ui/issues/issue-22258.rs", -"ui/issues/issue-22289.rs", -"ui/issues/issue-22312.rs", -"ui/issues/issue-22346.rs", -"ui/issues/issue-22370.rs", -"ui/issues/issue-22403.rs", -"ui/issues/issue-22426.rs", -"ui/issues/issue-22434.rs", -"ui/issues/issue-22468.rs", -"ui/issues/issue-22577.rs", -"ui/issues/issue-22599.rs", -"ui/issues/issue-22629.rs", -"ui/issues/issue-22638.rs", -"ui/issues/issue-22644.rs", -"ui/issues/issue-22684.rs", -"ui/issues/issue-22706.rs", -"ui/issues/issue-2281-part1.rs", -"ui/issues/issue-2284.rs", -"ui/issues/issue-22864-1.rs", -"ui/issues/issue-22864-2.rs", -"ui/issues/issue-22872.rs", -"ui/issues/issue-22874.rs", -"ui/issues/issue-2288.rs", -"ui/issues/issue-22886.rs", -"ui/issues/issue-22894.rs", -"ui/issues/issue-22933-2.rs", -"ui/issues/issue-22992-2.rs", -"ui/issues/issue-22992.rs", -"ui/issues/issue-23024.rs", -"ui/issues/issue-23036.rs", -"ui/issues/issue-23041.rs", -"ui/issues/issue-23046.rs", -"ui/issues/issue-23073.rs", -"ui/issues/issue-23122-1.rs", -"ui/issues/issue-23122-2.rs", -"ui/issues/issue-2316-c.rs", -"ui/issues/issue-23173.rs", -"ui/issues/issue-23189.rs", -"ui/issues/issue-23217.rs", -"ui/issues/issue-23253.rs", -"ui/issues/issue-23261.rs", -"ui/issues/issue-23281.rs", -"ui/issues/issue-23302-1.rs", -"ui/issues/issue-23302-2.rs", -"ui/issues/issue-23302-3.rs", -"ui/issues/issue-23304-1.rs", -"ui/issues/issue-23304-2.rs", -"ui/issues/issue-23311.rs", -"ui/issues/issue-23336.rs", -"ui/issues/issue-23406.rs", -"ui/issues/issue-23433.rs", -"ui/issues/issue-23485.rs", -"ui/issues/issue-23491.rs", -"ui/issues/issue-23543.rs", -"ui/issues/issue-23544.rs", -"ui/issues/issue-23550.rs", -"ui/issues/issue-23589.rs", -"ui/issues/issue-23611-enum-swap-in-drop.rs", -"ui/issues/issue-23649-1.rs", -"ui/issues/issue-23649-2.rs", -"ui/issues/issue-23649-3.rs", -"ui/issues/issue-23699.rs", -"ui/issues/issue-23781.rs", -"ui/issues/issue-2380-b.rs", -"ui/issues/issue-2383.rs", -"ui/issues/issue-23891.rs", -"ui/issues/issue-23898.rs", -"ui/issues/issue-23958.rs", -"ui/issues/issue-23966.rs", -"ui/issues/issue-23992.rs", -"ui/issues/issue-24013.rs", -"ui/issues/issue-24036.rs", -"ui/issues/issue-24086.rs", -"ui/issues/issue-2414-c.rs", -"ui/issues/issue-2428.rs", -"ui/issues/issue-24308.rs", -"ui/issues/issue-24322.rs", -"ui/issues/issue-24352.rs", -"ui/issues/issue-24353.rs", -"ui/issues/issue-24357.rs", -"ui/issues/issue-24363.rs", -"ui/issues/issue-24365.rs", -"ui/issues/issue-24424.rs", -"ui/issues/issue-24446.rs", -"ui/issues/issue-2445-b.rs", -"ui/issues/issue-2445.rs", -"ui/issues/issue-24533.rs", -"ui/issues/issue-24589.rs", -"ui/issues/issue-2463.rs", -"ui/issues/issue-24682.rs", -"ui/issues/issue-2472.rs", -"ui/issues/issue-24779.rs", -"ui/issues/issue-24819.rs", -"ui/issues/issue-2487-a.rs", -"ui/issues/issue-24947.rs", -"ui/issues/issue-24954.rs", -"ui/issues/issue-25076.rs", -"ui/issues/issue-25089.rs", -"ui/issues/issue-25145.rs", -"ui/issues/issue-25185.rs", -"ui/issues/issue-2526-a.rs", -"ui/issues/issue-25279.rs", -"ui/issues/issue-25343.rs", -"ui/issues/issue-25368.rs", -"ui/issues/issue-25386.rs", -"ui/issues/issue-25439.rs", -"ui/issues/issue-25467.rs", -"ui/issues/issue-25497.rs", -"ui/issues/issue-2550.rs", -"ui/issues/issue-25515.rs", -"ui/issues/issue-25549-multiple-drop.rs", -"ui/issues/issue-25679.rs", -"ui/issues/issue-25693.rs", -"ui/issues/issue-25746-bool-transmute.rs", -"ui/issues/issue-25757.rs", -"ui/issues/issue-25810.rs", -"ui/issues/issue-2590.rs", -"ui/issues/issue-25901.rs", -"ui/issues/issue-26056.rs", -"ui/issues/issue-26093.rs", -"ui/issues/issue-26127.rs", -"ui/issues/issue-26217.rs", -"ui/issues/issue-26237.rs", -"ui/issues/issue-26262.rs", -"ui/issues/issue-2631-b.rs", -"ui/issues/issue-2642.rs", -"ui/issues/issue-26468.rs", -"ui/issues/issue-26472.rs", -"ui/issues/issue-26619.rs", -"ui/issues/issue-26641.rs", -"ui/issues/issue-26655.rs", -"ui/issues/issue-26709.rs", -"ui/issues/issue-26802.rs", -"ui/issues/issue-26805.rs", -"ui/issues/issue-26812.rs", -"ui/issues/issue-26905-rpass.rs", -"ui/issues/issue-26905.rs", -"ui/issues/issue-26948.rs", -"ui/issues/issue-27008.rs", -"ui/issues/issue-27033.rs", -"ui/issues/issue-27042.rs", -"ui/issues/issue-27054-primitive-binary-ops.rs", -"ui/issues/issue-27078.rs", -"ui/issues/issue-2708.rs", -"ui/issues/issue-2723-b.rs", -"ui/issues/issue-27240.rs", -"ui/issues/issue-27268.rs", -"ui/issues/issue-27340.rs", -"ui/issues/issue-27401-dropflag-reinit.rs", -"ui/issues/issue-27592.rs", -"ui/issues/issue-27639.rs", -"ui/issues/issue-27815.rs", -"ui/issues/issue-27842.rs", -"ui/issues/issue-27859.rs", -"ui/issues/issue-27942.rs", -"ui/issues/issue-27949.rs", -"ui/issues/issue-27997.rs", -"ui/issues/issue-28105.rs", -"ui/issues/issue-28109.rs", -"ui/issues/issue-28181.rs", -"ui/issues/issue-2823.rs", -"ui/issues/issue-28344.rs", -"ui/issues/issue-28433.rs", -"ui/issues/issue-28472.rs", -"ui/issues/issue-2848.rs", -"ui/issues/issue-2849.rs", -"ui/issues/issue-28498-must-work-ex1.rs", -"ui/issues/issue-28498-must-work-ex2.rs", -"ui/issues/issue-28498-ugeh-ex1.rs", -"ui/issues/issue-28550.rs", -"ui/issues/issue-28568.rs", -"ui/issues/issue-28586.rs", -"ui/issues/issue-28625.rs", -"ui/issues/issue-28777.rs", -"ui/issues/issue-28828.rs", -"ui/issues/issue-28839.rs", -"ui/issues/issue-2895.rs", -"ui/issues/issue-28971.rs", -"ui/issues/issue-28983.rs", -"ui/issues/issue-28992-empty.rs", -"ui/issues/issue-2904.rs", -"ui/issues/issue-29053.rs", -"ui/issues/issue-29071-2.rs", -"ui/issues/issue-29092.rs", -"ui/issues/issue-29147-rpass.rs", -"ui/issues/issue-29147.rs", -"ui/issues/issue-29181.rs", -"ui/issues/issue-2935.rs", -"ui/issues/issue-29466.rs", -"ui/issues/issue-29485.rs", -"ui/issues/issue-2951.rs", -"ui/issues/issue-29522.rs", -"ui/issues/issue-29540.rs", -"ui/issues/issue-29663.rs", -"ui/issues/issue-29668.rs", -"ui/issues/issue-29723.rs", -"ui/issues/issue-29746.rs", -"ui/issues/issue-29821.rs", -"ui/issues/issue-29861.rs", -"ui/issues/issue-2989.rs", -"ui/issues/issue-29948.rs", -"ui/issues/issue-2995.rs", -"ui/issues/issue-30007.rs", -"ui/issues/issue-30018-panic.rs", -"ui/issues/issue-30081.rs", -"ui/issues/issue-3012-2.rs", -"ui/issues/issue-30123.rs", -"ui/issues/issue-3021-b.rs", -"ui/issues/issue-3021-d.rs", -"ui/issues/issue-30236.rs", -"ui/issues/issue-30255.rs", -"ui/issues/issue-3026.rs", -"ui/issues/issue-3037.rs", -"ui/issues/issue-30371.rs", -"ui/issues/issue-3038.rs", -"ui/issues/issue-30490.rs", -"ui/issues/issue-3052.rs", -"ui/issues/issue-30530.rs", -"ui/issues/issue-30589.rs", -"ui/issues/issue-30615.rs", -"ui/issues/issue-30756.rs", -"ui/issues/issue-30891.rs", -"ui/issues/issue-3091.rs", -"ui/issues/issue-31011.rs", -"ui/issues/issue-3109.rs", -"ui/issues/issue-3121.rs", -"ui/issues/issue-31267-additional.rs", -"ui/issues/issue-31267.rs", -"ui/issues/issue-31299.rs", -"ui/issues/issue-3136-b.rs", -"ui/issues/issue-31511.rs", -"ui/issues/issue-3154.rs", -"ui/issues/issue-31702.rs", -"ui/issues/issue-31769.rs", -"ui/issues/issue-31776.rs", -"ui/issues/issue-31910.rs", -"ui/issues/issue-32004.rs", -"ui/issues/issue-32008.rs", -"ui/issues/issue-32086.rs", -"ui/issues/issue-3214.rs", -"ui/issues/issue-3220.rs", -"ui/issues/issue-32292.rs", -"ui/issues/issue-32323.rs", -"ui/issues/issue-32326.rs", -"ui/issues/issue-32377.rs", -"ui/issues/issue-32389.rs", -"ui/issues/issue-32518.rs", -"ui/issues/issue-32655.rs", -"ui/issues/issue-32709.rs", -"ui/issues/issue-32782.rs", -"ui/issues/issue-32805.rs", -"ui/issues/issue-3290.rs", -"ui/issues/issue-32950.rs", -"ui/issues/issue-32995-2.rs", -"ui/issues/issue-32995.rs", -"ui/issues/issue-33187.rs", -"ui/issues/issue-33202.rs", -"ui/issues/issue-33287.rs", -"ui/issues/issue-33293.rs", -"ui/issues/issue-33387.rs", -"ui/issues/issue-3344.rs", -"ui/issues/issue-33461.rs", -"ui/issues/issue-33504.rs", -"ui/issues/issue-33525.rs", -"ui/issues/issue-33571.rs", -"ui/issues/issue-33687.rs", -"ui/issues/issue-33770.rs", -"ui/issues/issue-3389.rs", -"ui/issues/issue-33992.rs", -"ui/issues/issue-34047.rs", -"ui/issues/issue-34074.rs", -"ui/issues/issue-34209.rs", -"ui/issues/issue-34229.rs", -"ui/issues/issue-3429.rs", -"ui/issues/issue-34334.rs", -"ui/issues/issue-34349.rs", -"ui/issues/issue-34373.rs", -"ui/issues/issue-34427.rs", -"ui/issues/issue-3447.rs", -"ui/issues/issue-34503.rs", -"ui/issues/issue-34571.rs", -"ui/issues/issue-3477.rs", -"ui/issues/issue-34796.rs", -"ui/issues/issue-3500.rs", -"ui/issues/issue-35139.rs", -"ui/issues/issue-35241.rs", -"ui/issues/issue-35423.rs", -"ui/issues/issue-3556.rs", -"ui/issues/issue-3559.rs", -"ui/issues/issue-35600.rs", -"ui/issues/issue-3563-3.rs", -"ui/issues/issue-3574.rs", -"ui/issues/issue-35815.rs", -"ui/issues/issue-35988.rs", -"ui/issues/issue-36023.rs", -"ui/issues/issue-36036-associated-type-layout.rs", -"ui/issues/issue-36260.rs", -"ui/issues/issue-36278-prefix-nesting.rs", -"ui/issues/issue-36299.rs", -"ui/issues/issue-36400.rs", -"ui/issues/issue-36401.rs", -"ui/issues/issue-36474.rs", -"ui/issues/issue-3668.rs", -"ui/issues/issue-36744-bitcast-args-if-needed.rs", -"ui/issues/issue-36786-resolve-call.rs", -"ui/issues/issue-3680.rs", -"ui/issues/issue-36816.rs", -"ui/issues/issue-36836.rs", -"ui/issues/issue-36936.rs", -"ui/issues/issue-36954.rs", -"ui/issues/issue-3702-2.rs", -"ui/issues/issue-3702.rs", -"ui/issues/issue-3707.rs", -"ui/issues/issue-37109.rs", -"ui/issues/issue-3743.rs", -"ui/issues/issue-3753.rs", -"ui/issues/issue-37534.rs", -"ui/issues/issue-37576.rs", -"ui/issues/issue-3763.rs", -"ui/issues/issue-37686.rs", -"ui/issues/issue-37725.rs", -"ui/issues/issue-37733.rs", -"ui/issues/issue-3779.rs", -"ui/issues/issue-37884.rs", -"ui/issues/issue-38190.rs", -"ui/issues/issue-38412.rs", -"ui/issues/issue-38437.rs", -"ui/issues/issue-38458.rs", -"ui/issues/issue-3847.rs", -"ui/issues/issue-38556.rs", -"ui/issues/issue-38727.rs", -"ui/issues/issue-3874.rs", -"ui/issues/issue-38763.rs", -"ui/issues/issue-3878.rs", -"ui/issues/issue-38857.rs", -"ui/issues/issue-38919.rs", -"ui/issues/issue-38942.rs", -"ui/issues/issue-3895.rs", -"ui/issues/issue-38954.rs", -"ui/issues/issue-38987.rs", -"ui/issues/issue-39175.rs", -"ui/issues/issue-39211.rs", -"ui/issues/issue-39548.rs", -"ui/issues/issue-39687.rs", -"ui/issues/issue-39709.rs", -"ui/issues/issue-3979-generics.rs", -"ui/issues/issue-3979-xcrate.rs", -"ui/issues/issue-3979.rs", -"ui/issues/issue-39808.rs", -"ui/issues/issue-39827.rs", -"ui/issues/issue-39848.rs", -"ui/issues/issue-3993.rs", -"ui/issues/issue-39970.rs", -"ui/issues/issue-40000.rs", -"ui/issues/issue-40085.rs", -"ui/issues/issue-40235.rs", -"ui/issues/issue-40288-2.rs", -"ui/issues/issue-40288.rs", -"ui/issues/issue-40408.rs", -"ui/issues/issue-40510-1.rs", -"ui/issues/issue-40510-3.rs", -"ui/issues/issue-40610.rs", -"ui/issues/issue-40749.rs", -"ui/issues/issue-40827.rs", -"ui/issues/issue-40845.rs", -"ui/issues/issue-40861.rs", -"ui/issues/issue-40883.rs", -"ui/issues/issue-40951.rs", -"ui/issues/issue-41053.rs", -"ui/issues/issue-41139.rs", -"ui/issues/issue-41213.rs", -"ui/issues/issue-41229-ref-str.rs", -"ui/issues/issue-41479.rs", -"ui/issues/issue-41498.rs", -"ui/issues/issue-41549.rs", -"ui/issues/issue-41604.rs", -"ui/issues/issue-41677.rs", -"ui/issues/issue-41696.rs", -"ui/issues/issue-41726.rs", -"ui/issues/issue-41742.rs", -"ui/issues/issue-41744.rs", -"ui/issues/issue-41849-variance-req.rs", -"ui/issues/issue-41880.rs", -"ui/issues/issue-41888.rs", -"ui/issues/issue-41974.rs", -"ui/issues/issue-42007.rs", -"ui/issues/issue-4208.rs", -"ui/issues/issue-42106.rs", -"ui/issues/issue-42148.rs", -"ui/issues/issue-4228.rs", -"ui/issues/issue-42312.rs", -"ui/issues/issue-42453.rs", -"ui/issues/issue-4252.rs", -"ui/issues/issue-42552.rs", -"ui/issues/issue-4265.rs", -"ui/issues/issue-42755.rs", -"ui/issues/issue-42796.rs", -"ui/issues/issue-42880.rs", -"ui/issues/issue-43162.rs", -"ui/issues/issue-43205.rs", -"ui/issues/issue-43250.rs", -"ui/issues/issue-43291.rs", -"ui/issues/issue-4333.rs", -"ui/issues/issue-4335.rs", -"ui/issues/issue-43355.rs", -"ui/issues/issue-43420-no-over-suggest.rs", -"ui/issues/issue-43424.rs", -"ui/issues/issue-43431.rs", -"ui/issues/issue-43692.rs", -"ui/issues/issue-43853.rs", -"ui/issues/issue-4387.rs", -"ui/issues/issue-43910.rs", -"ui/issues/issue-43923.rs", -"ui/issues/issue-43925.rs", -"ui/issues/issue-43926.rs", -"ui/issues/issue-43988.rs", -"ui/issues/issue-44023.rs", -"ui/issues/issue-44078.rs", -"ui/issues/issue-44255.rs", -"ui/issues/issue-44405.rs", -"ui/issues/issue-4517.rs", -"ui/issues/issue-4541.rs", -"ui/issues/issue-4542.rs", -"ui/issues/issue-4545.rs", -"ui/issues/issue-45510.rs", -"ui/issues/issue-45730.rs", -"ui/issues/issue-45801.rs", -"ui/issues/issue-45965.rs", -"ui/issues/issue-46069.rs", -"ui/issues/issue-46101.rs", -"ui/issues/issue-46302.rs", -"ui/issues/issue-46311.rs", -"ui/issues/issue-46332.rs", -"ui/issues/issue-46438.rs", -"ui/issues/issue-46471-1.rs", -"ui/issues/issue-46472.rs", -"ui/issues/issue-46604.rs", -"ui/issues/issue-46771.rs", -"ui/issues/issue-46983.rs", -"ui/issues/issue-47073-zero-padded-tuple-struct-indices.rs", -"ui/issues/issue-47094.rs", -"ui/issues/issue-47184.rs", -"ui/issues/issue-4734.rs", -"ui/issues/issue-4735.rs", -"ui/issues/issue-4736.rs", -"ui/issues/issue-47377.rs", -"ui/issues/issue-47380.rs", -"ui/issues/issue-47486.rs", -"ui/issues/issue-4759-1.rs", -"ui/issues/issue-4759.rs", -"ui/issues/issue-47638.rs", -"ui/issues/issue-47715.rs", -"ui/issues/issue-47725.rs", -"ui/issues/issue-48006.rs", -"ui/issues/issue-48132.rs", -"ui/issues/issue-48159.rs", -"ui/issues/issue-48276.rs", -"ui/issues/issue-48364.rs", -"ui/issues/issue-48728.rs", -"ui/issues/issue-4875.rs", -"ui/issues/issue-48838.rs", -"ui/issues/issue-48984.rs", -"ui/issues/issue-49298.rs", -"ui/issues/issue-4935.rs", -"ui/issues/issue-49632.rs", -"ui/issues/issue-4968.rs", -"ui/issues/issue-4972.rs", -"ui/issues/issue-49824.rs", -"ui/issues/issue-49854.rs", -"ui/issues/issue-49919.rs", -"ui/issues/issue-49934-errors.rs", -"ui/issues/issue-49934.rs", -"ui/issues/issue-49955.rs", -"ui/issues/issue-49973.rs", -"ui/issues/issue-5008-borrowed-traitobject-method-call.rs", -"ui/issues/issue-50403.rs", -"ui/issues/issue-50415.rs", -"ui/issues/issue-50442.rs", -"ui/issues/issue-50581.rs", -"ui/issues/issue-50582.rs", -"ui/issues/issue-50585.rs", -"ui/issues/issue-50600.rs", -"ui/issues/issue-50618.rs", -"ui/issues/issue-5062.rs", -"ui/issues/issue-50688.rs", -"ui/issues/issue-50714-1.rs", -"ui/issues/issue-50714.rs", -"ui/issues/issue-50761.rs", -"ui/issues/issue-50781.rs", -"ui/issues/issue-50802.rs", -"ui/issues/issue-5100.rs", -"ui/issues/issue-51022.rs", -"ui/issues/issue-51044.rs", -"ui/issues/issue-51102.rs", -"ui/issues/issue-51116.rs", -"ui/issues/issue-51154.rs", -"ui/issues/issue-51515.rs", -"ui/issues/issue-5153.rs", -"ui/issues/issue-51632-try-desugar-incompatible-types.rs", -"ui/issues/issue-51874.rs", -"ui/issues/issue-5192.rs", -"ui/issues/issue-51947.rs", -"ui/issues/issue-52049.rs", -"ui/issues/issue-52126-assign-op-invariance.rs", -"ui/issues/issue-52262.rs", -"ui/issues/issue-5239-1.rs", -"ui/issues/issue-5239-2.rs", -"ui/issues/issue-52533.rs", -"ui/issues/issue-52717.rs", -"ui/issues/issue-5280.rs", -"ui/issues/issue-5315.rs", -"ui/issues/issue-5321-immediates-with-bare-self.rs", -"ui/issues/issue-53251.rs", -"ui/issues/issue-53275.rs", -"ui/issues/issue-53300.rs", -"ui/issues/issue-53348.rs", -"ui/issues/issue-53498.rs", -"ui/issues/issue-5358-1.rs", -"ui/issues/issue-53728.rs", -"ui/issues/issue-53843.rs", -"ui/issues/issue-54044.rs", -"ui/issues/issue-54062.rs", -"ui/issues/issue-5439.rs", -"ui/issues/issue-54410.rs", -"ui/issues/issue-54477-reduced-2.rs", -"ui/issues/issue-54696.rs", -"ui/issues/issue-5518.rs", -"ui/issues/issue-5521.rs", -"ui/issues/issue-55376.rs", -"ui/issues/issue-55380.rs", -"ui/issues/issue-5550.rs", -"ui/issues/issue-5554.rs", -"ui/issues/issue-55587.rs", -"ui/issues/issue-55731.rs", -"ui/issues/issue-56199.rs", -"ui/issues/issue-56237.rs", -"ui/issues/issue-5666.rs", -"ui/issues/issue-56806.rs", -"ui/issues/issue-56835.rs", -"ui/issues/issue-56870.rs", -"ui/issues/issue-5688.rs", -"ui/issues/issue-56943.rs", -"ui/issues/issue-5708.rs", -"ui/issues/issue-5718.rs", -"ui/issues/issue-57198-pass.rs", -"ui/issues/issue-57271.rs", -"ui/issues/issue-57362-1.rs", -"ui/issues/issue-57362-2.rs", -"ui/issues/issue-5741.rs", -"ui/issues/issue-57741-1.rs", -"ui/issues/issue-57781.rs", -"ui/issues/issue-57924.rs", -"ui/issues/issue-58712.rs", -"ui/issues/issue-58734.rs", -"ui/issues/issue-5884.rs", -"ui/issues/issue-58857.rs", -"ui/issues/issue-5917.rs", -"ui/issues/issue-59488.rs", -"ui/issues/issue-59494.rs", -"ui/issues/issue-5988.rs", -"ui/issues/issue-5997-enum.rs", -"ui/issues/issue-5997-struct.rs", -"ui/issues/issue-5997.rs", -"ui/issues/issue-60218.rs", -"ui/issues/issue-60622.rs", -"ui/issues/issue-60989.rs", -"ui/issues/issue-61106.rs", -"ui/issues/issue-61108.rs", -"ui/issues/issue-6117.rs", -"ui/issues/issue-6130.rs", -"ui/issues/issue-61475.rs", -"ui/issues/issue-6153.rs", -"ui/issues/issue-61623.rs", -"ui/issues/issue-61894.rs", -"ui/issues/issue-62375.rs", -"ui/issues/issue-62480.rs", -"ui/issues/issue-6318.rs", -"ui/issues/issue-6344-let.rs", -"ui/issues/issue-6344-match.rs", -"ui/issues/issue-63983.rs", -"ui/issues/issue-64559.rs", -"ui/issues/issue-64792-bad-unicode-ctor.rs", -"ui/issues/issue-65131.rs", -"ui/issues/issue-65230.rs", -"ui/issues/issue-65462.rs", -"ui/issues/issue-6596-2.rs", -"ui/issues/issue-66353.rs", -"ui/issues/issue-6642.rs", -"ui/issues/issue-66667-function-cmp-cycle.rs", -"ui/issues/issue-66702-break-outside-loop-val.rs", -"ui/issues/issue-66706.rs", -"ui/issues/issue-66923-show-error-for-correct-call.rs", -"ui/issues/issue-67039-unsound-pin-partialeq.rs", -"ui/issues/issue-6738.rs", -"ui/issues/issue-67535.rs", -"ui/issues/issue-68010-large-zst-consts.rs", -"ui/issues/issue-68696-catch-during-unwind.rs", -"ui/issues/issue-6892.rs", -"ui/issues/issue-69130.rs", -"ui/issues/issue-6919.rs", -"ui/issues/issue-69306.rs", -"ui/issues/issue-6936.rs", -"ui/issues/issue-69455.rs", -"ui/issues/issue-69602-type-err-during-codegen-ice.rs", -"ui/issues/issue-69683.rs", -"ui/issues/issue-7012.rs", -"ui/issues/issue-70381.rs", -"ui/issues/issue-7044.rs", -"ui/issues/issue-7061.rs", -"ui/issues/issue-70673.rs", -"ui/issues/issue-70724-add_type_neq_err_label-unwrap.rs", -"ui/issues/issue-7092.rs", -"ui/issues/issue-71406.rs", -"ui/issues/issue-71676-2.rs", -"ui/issues/issue-7178.rs", -"ui/issues/issue-72076.rs", -"ui/issues/issue-72278.rs", -"ui/issues/issue-7246.rs", -"ui/issues/issue-72839-error-overflow.rs", -"ui/issues/issue-72933-match-stack-overflow.rs", -"ui/issues/issue-73112.rs", -"ui/issues/issue-7344.rs", -"ui/issues/issue-7364.rs", -"ui/issues/issue-74082.rs", -"ui/issues/issue-74564-if-expr-stack-overflow.rs", -"ui/issues/issue-7519-match-unit-in-arg.rs", -"ui/issues/issue-75283.rs", -"ui/issues/issue-7563.rs", -"ui/issues/issue-75704.rs", -"ui/issues/issue-7575.rs", -"ui/issues/issue-7607-1.rs", -"ui/issues/issue-76077.rs", -"ui/issues/issue-76191.rs", -"ui/issues/issue-7660.rs", -"ui/issues/issue-7663.rs", -"ui/issues/issue-7784.rs", -"ui/issues/issue-77919.rs", -"ui/issues/issue-78192.rs", -"ui/issues/issue-78622.rs", -"ui/issues/issue-7867.rs", -"ui/issues/issue-78957.rs", -"ui/issues/issue-7899.rs", -"ui/issues/issue-7911.rs", -"ui/issues/issue-7950.rs", -"ui/issues/issue-7970a.rs", -"ui/issues/issue-8044.rs", -"ui/issues/issue-80607.rs", -"ui/issues/issue-8248.rs", -"ui/issues/issue-8249.rs", -"ui/issues/issue-8259.rs", -"ui/issues/issue-8391.rs", -"ui/issues/issue-8401.rs", -"ui/issues/issue-8498.rs", -"ui/issues/issue-8506.rs", -"ui/issues/issue-86756.rs", -"ui/issues/issue-87199.rs", -"ui/issues/issue-8727.rs", -"ui/issues/issue-87490.rs", -"ui/issues/issue-8761.rs", -"ui/issues/issue-8767.rs", -"ui/issues/issue-8783.rs", -"ui/issues/issue-8860.rs", -"ui/issues/issue-8898.rs", -"ui/issues/issue-9047.rs", -"ui/issues/issue-9123.rs", -"ui/issues/issue-9129.rs", -"ui/issues/issue-9155.rs", -"ui/issues/issue-9188.rs", -"ui/issues/issue-9243.rs", -"ui/issues/issue-9259.rs", -"ui/issues/issue-9382.rs", -"ui/issues/issue-9446.rs", -"ui/issues/issue-9575.rs", -"ui/issues/issue-9719.rs", -"ui/issues/issue-9725.rs", -"ui/issues/issue-9737.rs", -"ui/issues/issue-9814.rs", -"ui/issues/issue-98299.rs", -"ui/issues/issue-9837.rs", -"ui/issues/issue-9906.rs", -"ui/issues/issue-9918.rs", -"ui/issues/issue-9942.rs", -"ui/issues/issue-9951.rs", -"ui/issues/issue-9968.rs", -"ui/issues/issue-99838.rs", -"ui/issues/issue-11047.rs", -"ui/issues/issue-11709.rs", -"ui/issues/issue-20644.rs", -"ui/issues/issue-23808.rs", -"ui/issues/issue-26997.rs", -"ui/issues/issue-28600.rs", -"ui/issues/issue-3656.rs", -"ui/issues/issue-50811.rs", -"ui/issues/issue-51907.rs", -"ui/issues/issue-5754.rs", -"ui/issues/issue-10396.rs", -"ui/issues/issue-10456.rs", -"ui/issues/issue-106755.rs", -"ui/issues/issue-10853.rs", -"ui/issues/issue-10902.rs", -"ui/issues/issue-11085.rs", -"ui/issues/issue-11384.rs", -"ui/issues/issue-11592.rs", -"ui/issues/issue-11740.rs", -"ui/issues/issue-11869.rs", -"ui/issues/issue-12729.rs", -"ui/issues/issue-12920.rs", -"ui/issues/issue-13105.rs", -"ui/issues/issue-13167.rs", -"ui/issues/issue-13202.rs", -"ui/issues/issue-13405.rs", -"ui/issues/issue-13482-2.rs", -"ui/issues/issue-13703.rs", -"ui/issues/issue-13775.rs", -"ui/issues/issue-14082.rs", -"ui/issues/issue-14254.rs", -"ui/issues/issue-14330.rs", -"ui/issues/issue-14901.rs", -"ui/issues/issue-14959.rs", -"ui/issues/issue-15734.rs", -"ui/issues/issue-15735.rs", -"ui/issues/issue-16596.rs", -"ui/issues/issue-16668.rs", -"ui/issues/issue-16994.rs", -"ui/issues/issue-17121.rs", -"ui/issues/issue-17732.rs", -"ui/issues/issue-17746.rs", -"ui/issues/issue-17904.rs", -"ui/issues/issue-18088.rs", -"ui/issues/issue-18188.rs", -"ui/issues/issue-18446-2.rs", -"ui/issues/issue-18576.rs", -"ui/issues/issue-18738.rs", -"ui/issues/issue-18809.rs", -"ui/issues/issue-18906.rs", -"ui/issues/issue-18988.rs", -"ui/issues/issue-19037.rs", -"ui/issues/issue-19097.rs", -"ui/issues/issue-19098.rs", -"ui/issues/issue-19100.rs", -"ui/issues/issue-19102.rs", -"ui/issues/issue-19129-1.rs", -"ui/issues/issue-19129-2.rs", -"ui/issues/issue-19398.rs", -"ui/issues/issue-19479.rs", -"ui/issues/issue-19601.rs", -"ui/issues/issue-1962.rs", -"ui/issues/issue-19631.rs", -"ui/issues/issue-19632.rs", -"ui/issues/issue-19850.rs", -"ui/issues/issue-19982.rs", -"ui/issues/issue-20009.rs", -"ui/issues/issue-20186.rs", -"ui/issues/issue-20396.rs", -"ui/issues/issue-20414.rs", -"ui/issues/issue-20454.rs", -"ui/issues/issue-20763-1.rs", -"ui/issues/issue-20763-2.rs", -"ui/issues/issue-20971.rs", -"ui/issues/issue-21140.rs", -"ui/issues/issue-21174-2.rs", -"ui/issues/issue-21245.rs", -"ui/issues/issue-21402.rs", -"ui/issues/issue-21622.rs", -"ui/issues/issue-22356.rs", -"ui/issues/issue-22471.rs", -"ui/issues/issue-22603.rs", -"ui/issues/issue-22673.rs", -"ui/issues/issue-22777.rs", -"ui/issues/issue-22781.rs", -"ui/issues/issue-22789.rs", -"ui/issues/issue-22814.rs", -"ui/issues/issue-22933-1.rs", -"ui/issues/issue-2311-2.rs", -"ui/issues/issue-2311.rs", -"ui/issues/issue-2312.rs", -"ui/issues/issue-23354-2.rs", -"ui/issues/issue-23354.rs", -"ui/issues/issue-23442.rs", -"ui/issues/issue-23477.rs", -"ui/issues/issue-24161.rs", -"ui/issues/issue-24227.rs", -"ui/issues/issue-24389.rs", -"ui/issues/issue-24434.rs", -"ui/issues/issue-2470-bounds-check-overflow.rs", -"ui/issues/issue-24945-repeat-dash-opts.rs", -"ui/issues/issue-2502.rs", -"ui/issues/issue-25180.rs", -"ui/issues/issue-25394.rs", -"ui/issues/issue-25579.rs", -"ui/issues/issue-26095.rs", -"ui/issues/issue-2611-3.rs", -"ui/issues/issue-26186.rs", -"ui/issues/issue-26205.rs", -"ui/issues/issue-26484.rs", -"ui/issues/issue-26614.rs", -"ui/issues/issue-26646.rs", -"ui/issues/issue-27105.rs", -"ui/issues/issue-27281.rs", -"ui/issues/issue-27433.rs", -"ui/issues/issue-2761.rs", -"ui/issues/issue-27697.rs", -"ui/issues/issue-27889.rs", -"ui/issues/issue-28279.rs", -"ui/issues/issue-28561.rs", -"ui/issues/issue-28776.rs", -"ui/issues/issue-28936.rs", -"ui/issues/issue-28999.rs", -"ui/issues/issue-29030.rs", -"ui/issues/issue-29037.rs", -"ui/issues/issue-29048.rs", -"ui/issues/issue-29071.rs", -"ui/issues/issue-29265.rs", -"ui/issues/issue-29276.rs", -"ui/issues/issue-29516.rs", -"ui/issues/issue-29710.rs", -"ui/issues/issue-29740.rs", -"ui/issues/issue-29743.rs", -"ui/issues/issue-29857.rs", -"ui/issues/issue-3029.rs", -"ui/issues/issue-30380.rs", -"ui/issues/issue-31260.rs", -"ui/issues/issue-3149.rs", -"ui/issues/issue-32122-1.rs", -"ui/issues/issue-32122-2.rs", -"ui/issues/issue-32324.rs", -"ui/issues/issue-32797.rs", -"ui/issues/issue-33096.rs", -"ui/issues/issue-33241.rs", -"ui/issues/issue-33941.rs", -"ui/issues/issue-3424.rs", -"ui/issues/issue-34418.rs", -"ui/issues/issue-34569.rs", -"ui/issues/issue-34721.rs", -"ui/issues/issue-34751.rs", -"ui/issues/issue-34780.rs", -"ui/issues/issue-34839.rs", -"ui/issues/issue-3521-2.rs", -"ui/issues/issue-35976.rs", -"ui/issues/issue-36075.rs", -"ui/issues/issue-3609.rs", -"ui/issues/issue-36116.rs", -"ui/issues/issue-36379.rs", -"ui/issues/issue-3668-2.rs", -"ui/issues/issue-36839.rs", -"ui/issues/issue-36856.rs", -"ui/issues/issue-37051.rs", -"ui/issues/issue-37131.rs", -"ui/issues/issue-37510.rs", -"ui/issues/issue-37598.rs", -"ui/issues/issue-37665.rs", -"ui/issues/issue-38160.rs", -"ui/issues/issue-38226.rs", -"ui/issues/issue-38381.rs", -"ui/issues/issue-3888-2.rs", -"ui/issues/issue-39089.rs", -"ui/issues/issue-39367.rs", -"ui/issues/issue-39467.rs", -"ui/issues/issue-3979-2.rs", -"ui/issues/issue-3991.rs", -"ui/issues/issue-39984.rs", -"ui/issues/issue-40136.rs", -"ui/issues/issue-4025.rs", -"ui/issues/issue-40350.rs", -"ui/issues/issue-40510-2.rs", -"ui/issues/issue-40510-4.rs", -"ui/issues/issue-40782.rs", -"ui/issues/issue-41272.rs", -"ui/issues/issue-41298.rs", -"ui/issues/issue-41628.rs", -"ui/issues/issue-41936-variance-coerce-unsized-cycle.rs", -"ui/issues/issue-41998.rs", -"ui/issues/issue-42210.rs", -"ui/issues/issue-42467.rs", -"ui/issues/issue-42956.rs", -"ui/issues/issue-43057.rs", -"ui/issues/issue-43357.rs", -"ui/issues/issue-43483.rs", -"ui/issues/issue-43806.rs", -"ui/issues/issue-44056.rs", -"ui/issues/issue-44216-add-instant.rs", -"ui/issues/issue-44216-add-system-time.rs", -"ui/issues/issue-44216-sub-instant.rs", -"ui/issues/issue-44216-sub-system-time.rs", -"ui/issues/issue-44239.rs", -"ui/issues/issue-44247.rs", -"ui/issues/issue-4464.rs", -"ui/issues/issue-44730.rs", -"ui/issues/issue-44851.rs", -"ui/issues/issue-45425.rs", -"ui/issues/issue-45562.rs", -"ui/issues/issue-45697-1.rs", -"ui/issues/issue-45697.rs", -"ui/issues/issue-45731.rs", -"ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.rs", -"ui/issues/issue-46855.rs", -"ui/issues/issue-46964.rs", -"ui/issues/issue-47309.rs", -"ui/issues/issue-47364.rs", -"ui/issues/issue-47673.rs", -"ui/issues/issue-47703-1.rs", -"ui/issues/issue-47703-tuple.rs", -"ui/issues/issue-47703.rs", -"ui/issues/issue-47722.rs", -"ui/issues/issue-48131.rs", -"ui/issues/issue-4830.rs", -"ui/issues/issue-49544.rs", -"ui/issues/issue-50187.rs", -"ui/issues/issue-50411.rs", -"ui/issues/issue-50471.rs", -"ui/issues/issue-50518.rs", -"ui/issues/issue-50571.rs", -"ui/issues/issue-5067.rs", -"ui/issues/issue-51655.rs", -"ui/issues/issue-51798.rs", -"ui/issues/issue-52489.rs", -"ui/issues/issue-53333.rs", -"ui/issues/issue-53419.rs", -"ui/issues/issue-53568.rs", -"ui/issues/issue-54094.rs", -"ui/issues/issue-54462-mutable-noalias-correctness.rs", -"ui/issues/issue-5572.rs", -"ui/issues/issue-56128.rs", -"ui/issues/issue-56175.rs", -"ui/issues/issue-56229.rs", -"ui/issues/issue-57156.rs", -"ui/issues/issue-57162.rs", -"ui/issues/issue-57399-self-return-impl-trait.rs", -"ui/issues/issue-57741.rs", -"ui/issues/issue-58212.rs", -"ui/issues/issue-58344.rs", -"ui/issues/issue-58375-monomorphize-default-impls.rs", -"ui/issues/issue-5844.rs", -"ui/issues/issue-58463.rs", -"ui/issues/issue-5900.rs", -"ui/issues/issue-59020.rs", -"ui/issues/issue-59326.rs", -"ui/issues/issue-5950.rs", -"ui/issues/issue-59756.rs", -"ui/issues/issue-64430.rs", -"ui/issues/issue-64593.rs", -"ui/issues/issue-6557.rs", -"ui/issues/issue-65634-raw-ident-suggestion.rs", -"ui/issues/issue-66308.rs", -"ui/issues/issue-66768.rs", -"ui/issues/issue-68951.rs", -"ui/issues/issue-6898.rs", -"ui/issues/issue-69225-SCEVAddExpr-wrap-flag.rs", -"ui/issues/issue-69225-layout-repeated-checked-add.rs", -"ui/issues/issue-70746.rs", -"ui/issues/issue-71676-1.rs", -"ui/issues/issue-72002.rs", -"ui/issues/issue-7268.rs", -"ui/issues/issue-73229.rs", -"ui/issues/issue-76042.rs", -"ui/issues/issue-7607-2.rs", -"ui/issues/issue-76077-1.rs", -"ui/issues/issue-7673-cast-generically-implemented-trait.rs", -"ui/issues/issue-81584.rs", -"ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs", -"ui/issues/issue-81918.rs", -"ui/issues/issue-82833-slice-miscompile.rs", -"ui/issues/issue-83048.rs", -"ui/issues/issue-8398.rs", -"ui/issues/issue-8521.rs", -"ui/issues/issue-8578.rs", -"ui/issues/issue-87707.rs", -"ui/issues/issue-88150.rs", -"ui/issues/issue-9110.rs", -"ui/issues/issue-91489.rs", -"ui/issues/issue-9249.rs", -"ui/issues/issue-92741.rs", -"ui/issues/issue-12133-3.rs", -"ui/issues/issue-18389.rs", -"ui/issues/issue-35570.rs", -"ui/issues/issue-51714.rs", -"ui/issues/issue-5883.rs", -"ui/issues/issue-67552.rs", -"ui/issues/issue-85461.rs", -"ui/iterators/issue-28098.rs", -"ui/iterators/issue-58952-filter-type-length.rs", -"ui/lang-items/issue-31076.rs", -"ui/lang-items/issue-83471.rs", -"ui/lang-items/issue-86238.rs", -"ui/lang-items/issue-87573.rs", -"ui/lang-items/issue-19660.rs", -"ui/late-bound-lifetimes/issue-36381.rs", -"ui/late-bound-lifetimes/issue-80618.rs", -"ui/late-bound-lifetimes/issue-47511.rs", -"ui/layout/issue-60431-unsized-tail-behind-projection.rs", -"ui/layout/issue-84108.rs", -"ui/layout/issue-113941.rs", -"ui/layout/issue-96158-scalarpair-payload-might-be-uninit.rs", -"ui/layout/issue-96185-overaligned-enum.rs", -"ui/layout/issue-112048-unsizing-field-order.rs", -"ui/layout/issue-112048-unsizing-niche.rs", -"ui/let-else/issue-94176.rs", -"ui/let-else/issue-100103.rs", -"ui/let-else/issue-102317.rs", -"ui/let-else/issue-99975.rs", -"ui/lifetimes/auxiliary/issue-91763-aux.rs", -"ui/lifetimes/lifetime-errors/issue_74400.rs", -"ui/lifetimes/issue-105675.rs", -"ui/lifetimes/issue-107492-default-value-for-lifetime.rs", -"ui/lifetimes/issue-107988.rs", -"ui/lifetimes/issue-17728.rs", -"ui/lifetimes/issue-26638.rs", -"ui/lifetimes/issue-34979.rs", -"ui/lifetimes/issue-36744-without-calls.rs", -"ui/lifetimes/issue-55796.rs", -"ui/lifetimes/issue-64173-unused-lifetimes.rs", -"ui/lifetimes/issue-79187-2.rs", -"ui/lifetimes/issue-79187.rs", -"ui/lifetimes/issue-83753-invalid-associated-type-supertrait-hrtb.rs", -"ui/lifetimes/issue-83907-invalid-fn-like-path.rs", -"ui/lifetimes/issue-90600-expected-return-static-indirect.rs", -"ui/lifetimes/issue-91763.rs", -"ui/lifetimes/issue-95023.rs", -"ui/lifetimes/issue-97193.rs", -"ui/lifetimes/issue-97194.rs", -"ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs", -"ui/lifetimes/issue-104432-unused-lifetimes-in-expansion.rs", -"ui/lifetimes/issue-105227.rs", -"ui/lifetimes/issue-105507.rs", -"ui/lifetimes/issue-54378.rs", -"ui/lifetimes/issue-67498.rs", -"ui/lifetimes/issue-69314.rs", -"ui/lifetimes/issue-70917-lifetimes-in-fn-def.rs", -"ui/lifetimes/issue-76168-hr-outlives-2.rs", -"ui/lifetimes/issue-76168-hr-outlives.rs", -"ui/lifetimes/issue-77175.rs", -"ui/lifetimes/issue-83737-binders-across-types.rs", -"ui/lifetimes/issue-83737-erasing-bound-vars.rs", -"ui/lifetimes/issue-84398.rs", -"ui/lifetimes/issue-84604.rs", -"ui/lifetimes/issue-90170-elision-mismatch.rs", -"ui/lifetimes/issue-93911.rs", -"ui/limits/issue-75158-64.rs", -"ui/limits/issue-55878.rs", -"ui/limits/issue-69485-var-size-diffs-too-large.rs", -"ui/limits/issue-15919-32.rs", -"ui/limits/issue-15919-64.rs", -"ui/limits/issue-17913.rs", -"ui/limits/issue-56762.rs", -"ui/linkage-attr/issue-109144.rs", -"ui/linkage-attr/issue-10755.rs", -"ui/lint/dead-code/issue-59003.rs", -"ui/lint/dead-code/issue-68408-false-positive.rs", -"ui/lint/dead-code/issue-85071-2.rs", -"ui/lint/dead-code/issue-85071.rs", -"ui/lint/dead-code/issue-85255.rs", -"ui/lint/must_not_suspend/issue-89562.rs", -"ui/lint/unused/issue-105061-array-lint.rs", -"ui/lint/unused/issue-105061-should-lint.rs", -"ui/lint/unused/issue-105061.rs", -"ui/lint/unused/issue-30730.rs", -"ui/lint/unused/issue-46576.rs", -"ui/lint/unused/issue-59896.rs", -"ui/lint/unused/issue-67691-unused-field-in-or-pattern.rs", -"ui/lint/unused/issue-74883-unused-paren-baren-yield.rs", -"ui/lint/unused/issue-85913.rs", -"ui/lint/unused/issue-90807-unused-paren-error.rs", -"ui/lint/unused/issue-92751.rs", -"ui/lint/unused/issue-96606.rs", -"ui/lint/unused/issue-103320-must-use-ops.rs", -"ui/lint/unused/issue-104397.rs", -"ui/lint/unused/issue-47390-unused-variable-in-struct-pattern.rs", -"ui/lint/unused/issue-54180-unused-ref-field.rs", -"ui/lint/unused/issue-54538-unused-parens-lint.rs", -"ui/lint/unused/issue-70041.rs", -"ui/lint/unused/issue-71290-unused-paren-binop.rs", -"ui/lint/unused/issue-81314-unused-span-ident.rs", -"ui/lint/unused/issue-88519-unused-paren.rs", -"ui/lint/unused/issue-90807-unused-paren.rs", -"ui/lint/use-redundant/issue-92904.rs", -"ui/lint/issue-104392.rs", -"ui/lint/issue-106991.rs", -"ui/lint/issue-109152.rs", -"ui/lint/issue-111359.rs", -"ui/lint/issue-14309.rs", -"ui/lint/issue-17718-const-naming.rs", -"ui/lint/issue-1866.rs", -"ui/lint/issue-20343.rs", -"ui/lint/issue-30302.rs", -"ui/lint/issue-34798.rs", -"ui/lint/issue-35075.rs", -"ui/lint/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs", -"ui/lint/issue-63364.rs", -"ui/lint/issue-66362-no-snake-case-warning-for-field-puns.rs", -"ui/lint/issue-79744.rs", -"ui/lint/issue-97094.rs", -"ui/lint/issue-101284.rs", -"ui/lint/issue-102705.rs", -"ui/lint/issue-103317.rs", -"ui/lint/issue-103435-extra-parentheses.rs", -"ui/lint/issue-104897.rs", -"ui/lint/issue-108155.rs", -"ui/lint/issue-109529.rs", -"ui/lint/issue-110573.rs", -"ui/lint/issue-112489.rs", -"ui/lint/issue-14837.rs", -"ui/lint/issue-31924-non-snake-ffi.rs", -"ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs", -"ui/lint/issue-54099-camel-case-underscore-types.rs", -"ui/lint/issue-57410-1.rs", -"ui/lint/issue-57410.rs", -"ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs", -"ui/lint/issue-79546-fuel-ice.rs", -"ui/lint/issue-80988.rs", -"ui/lint/issue-81218.rs", -"ui/lint/issue-83477.rs", -"ui/lint/issue-86600-lint-twice.rs", -"ui/lint/issue-87274-paren-parent.rs", -"ui/lint/issue-89469.rs", -"ui/lint/issue-90614-accept-allow-text-direction-codepoint-in-comment-lint.rs", -"ui/lint/issue-99387.rs", -"ui/loops/issue-50576.rs", -"ui/loops/issue-82916.rs", -"ui/lowering/issue-96847.rs", -"ui/lto/issue-105637.rs", -"ui/lto/issue-100772.rs", -"ui/lto/issue-11154.rs", -"ui/macros/auxiliary/issue-100199.rs", -"ui/macros/auxiliary/issue-19163.rs", -"ui/macros/auxiliary/issue-40469.rs", -"ui/macros/auxiliary/issue-75982.rs", -"ui/macros/issue-100199.rs", -"ui/macros/issue-102878.rs", -"ui/macros/issue-103529.rs", -"ui/macros/issue-104769-concat_bytes-invalid-literal.rs", -"ui/macros/issue-105011.rs", -"ui/macros/issue-10536.rs", -"ui/macros/issue-106837.rs", -"ui/macros/issue-109237.rs", -"ui/macros/issue-111749.rs", -"ui/macros/issue-16098.rs", -"ui/macros/issue-19163.rs", -"ui/macros/issue-21356.rs", -"ui/macros/issue-22463.rs", -"ui/macros/issue-25274.rs", -"ui/macros/issue-25385.rs", -"ui/macros/issue-26094.rs", -"ui/macros/issue-26322.rs", -"ui/macros/issue-29084.rs", -"ui/macros/issue-30143.rs", -"ui/macros/issue-33185.rs", -"ui/macros/issue-34421-mac-expr-bad-stmt-good-add-semi.rs", -"ui/macros/issue-35450.rs", -"ui/macros/issue-37175.rs", -"ui/macros/issue-38715.rs", -"ui/macros/issue-39388.rs", -"ui/macros/issue-39404.rs", -"ui/macros/issue-40469.rs", -"ui/macros/issue-40770.rs", -"ui/macros/issue-41776.rs", -"ui/macros/issue-41803.rs", -"ui/macros/issue-44127.rs", -"ui/macros/issue-5060.rs", -"ui/macros/issue-51848.rs", -"ui/macros/issue-52169.rs", -"ui/macros/issue-54441.rs", -"ui/macros/issue-58490.rs", -"ui/macros/issue-61033-1.rs", -"ui/macros/issue-61033-2.rs", -"ui/macros/issue-61053-different-kleene.rs", -"ui/macros/issue-61053-duplicate-binder.rs", -"ui/macros/issue-61053-missing-repetition.rs", -"ui/macros/issue-61053-unbound.rs", -"ui/macros/issue-6596-1.rs", -"ui/macros/issue-68060.rs", -"ui/macros/issue-69396-const-no-type-in-macro.rs", -"ui/macros/issue-78325-inconsistent-resolution.rs", -"ui/macros/issue-78333.rs", -"ui/macros/issue-81006.rs", -"ui/macros/issue-83340.rs", -"ui/macros/issue-83344.rs", -"ui/macros/issue-84195-lint-anon-const.rs", -"ui/macros/issue-84632-eager-expansion-recursion-limit.rs", -"ui/macros/issue-86865.rs", -"ui/macros/issue-8709.rs", -"ui/macros/issue-8851.rs", -"ui/macros/issue-92267.rs", -"ui/macros/issue-98790.rs", -"ui/macros/issue-112342-1.rs", -"ui/macros/issue-112342-2.rs", -"ui/macros/issue-2804-2.rs", -"ui/macros/issue-34171.rs", -"ui/macros/issue-42954.rs", -"ui/macros/issue-57597.rs", -"ui/macros/issue-63102.rs", -"ui/macros/issue-68058.rs", -"ui/macros/issue-69838-mods-relative-to-included-path.rs", -"ui/macros/issue-70446.rs", -"ui/macros/issue-75982-foreign-macro-weird-mod.rs", -"ui/macros/issue-77475.rs", -"ui/macros/issue-78892-substitution-in-statement-attr.rs", -"ui/macros/issue-84429-matches-edition.rs", -"ui/macros/issue-86082-option-env-invalid-char.rs", -"ui/macros/issue-87877.rs", -"ui/macros/issue-88206.rs", -"ui/macros/issue-88228.rs", -"ui/macros/issue-95267.rs", -"ui/macros/issue-95533.rs", -"ui/macros/issue-98466-allow.rs", -"ui/macros/issue-98466.rs", -"ui/macros/issue-99261.rs", -"ui/macros/issue-99265.rs", -"ui/macros/issue-99907.rs", -"ui/malformed/issue-69341-malformed-derive-inert.rs", -"ui/malformed/issue-107423-unused-delim-only-one-no-pair.rs", -"ui/marker_trait_attr/issue-61651-type-mismatch.rs", -"ui/match/issue-11319.rs", -"ui/match/issue-11940.rs", -"ui/match/issue-12552.rs", -"ui/match/issue-18060.rs", -"ui/match/issue-26251.rs", -"ui/match/issue-26996.rs", -"ui/match/issue-27021.rs", -"ui/match/issue-33498.rs", -"ui/match/issue-41255.rs", -"ui/match/issue-42679.rs", -"ui/match/issue-46920-byte-array-patterns.rs", -"ui/match/issue-5530.rs", -"ui/match/issue-56685.rs", -"ui/match/issue-72680.rs", -"ui/match/issue-72896.rs", -"ui/match/issue-74050-end-span.rs", -"ui/match/issue-82866.rs", -"ui/match/issue-91058.rs", -"ui/match/issue-92100.rs", -"ui/match/issue-112438.rs", -"ui/match/issue-70972-dyn-trait.rs", -"ui/match/issue-82392.rs", -"ui/match/issue-84434.rs", -"ui/match/issue-113012.rs", -"ui/methods/issues/issue-105732.rs", -"ui/methods/issues/issue-61525.rs", -"ui/methods/issues/issue-84495.rs", -"ui/methods/issues/issue-90315.rs", -"ui/methods/issues/issue-94581.rs", -"ui/mir/auxiliary/issue_76375_aux.rs", -"ui/mir/validate/issue-95978-validator-lifetime-comparison.rs", -"ui/mir/issue-102389.rs", -"ui/mir/issue-107678-projection-with-lifetime.rs", -"ui/mir/issue-29227.rs", -"ui/mir/issue-67947.rs", -"ui/mir/issue-75419-validation-impl-trait.rs", -"ui/mir/issue-76803-branches-not-same.rs", -"ui/mir/issue-77359-simplify-arm-identity.rs", -"ui/mir/issue-83499-input-output-iteration-ice.rs", -"ui/mir/issue-89485.rs", -"ui/mir/issue-92893.rs", -"ui/mir/issue-112269.rs", -"ui/mir/issue-80949.rs", -"ui/mir/issue-101844.rs", -"ui/mir/issue-105809.rs", -"ui/mir/issue-106062.rs", -"ui/mir/issue-107691.rs", -"ui/mir/issue-109004-drop-large-array.rs", -"ui/mir/issue-109743.rs", -"ui/mir/issue-46845.rs", -"ui/mir/issue-60390.rs", -"ui/mir/issue-66851.rs", -"ui/mir/issue-66930.rs", -"ui/mir/issue-67639-normalization-ice.rs", -"ui/mir/issue-67710-inline-projection.rs", -"ui/mir/issue-68841.rs", -"ui/mir/issue-71793-inline-args-storage.rs", -"ui/mir/issue-73914.rs", -"ui/mir/issue-74739.rs", -"ui/mir/issue-75053.rs", -"ui/mir/issue-76248.rs", -"ui/mir/issue-76375.rs", -"ui/mir/issue-76740-copy-propagation.rs", -"ui/mir/issue-77002.rs", -"ui/mir/issue-77911.rs", -"ui/mir/issue-78496.rs", -"ui/mir/issue-91745.rs", -"ui/mir/issue-99852.rs", -"ui/mir/issue-99866.rs", -"ui/mir/issue66339.rs", -"ui/mismatched_types/issue-19109.rs", -"ui/mismatched_types/issue-26480.rs", -"ui/mismatched_types/issue-35030.rs", -"ui/mismatched_types/issue-36053-2.rs", -"ui/mismatched_types/issue-38371-unfixable.rs", -"ui/mismatched_types/issue-47706-trait.rs", -"ui/mismatched_types/issue-47706.rs", -"ui/mismatched_types/issue-74918-missing-lifetime.rs", -"ui/mismatched_types/issue-75361-mismatched-impl.rs", -"ui/mismatched_types/issue-84976.rs", -"ui/mismatched_types/issue-112036.rs", -"ui/mismatched_types/issue-106182.rs", -"ui/mismatched_types/issue-38371.rs", -"ui/missing-trait-bounds/auxiliary/issue-69725.rs", -"ui/missing-trait-bounds/issue-35677.rs", -"ui/missing-trait-bounds/issue-69725.rs", -"ui/modules/issue-56411.rs", -"ui/modules/issue-107649.rs", -"ui/modules/issue-56411-aux.rs", -"ui/moves/issue-22536-copy-mustnt-zero.rs", -"ui/moves/issue-46099-move-in-macro.rs", -"ui/moves/issue-72649-uninit-in-loop.rs", -"ui/moves/issue-75904-move-closure-loop.rs", -"ui/moves/issue-99470-move-out-of-some.rs", -"ui/never_type/issue-10176.rs", -"ui/never_type/issue-13352.rs", -"ui/never_type/issue-2149.rs", -"ui/never_type/issue-51506.rs", -"ui/never_type/issue-52443.rs", -"ui/never_type/issue-96335.rs", -"ui/never_type/issue-44402.rs", -"ui/never_type/issue-5500-1.rs", -"ui/nll/closure-requirements/issue-58127-mutliple-requirements.rs", -"ui/nll/polonius/issue-46589.rs", -"ui/nll/relate_tys/issue-48071.rs", -"ui/nll/ty-outlives/issue-53789-1.rs", -"ui/nll/ty-outlives/issue-53789-2.rs", -"ui/nll/ty-outlives/issue-55756.rs", -"ui/nll/user-annotations/issue-54124.rs", -"ui/nll/user-annotations/issue-55241.rs", -"ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.rs", -"ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs", -"ui/nll/user-annotations/issue-54570-bootstrapping.rs", -"ui/nll/user-annotations/issue-55219.rs", -"ui/nll/issue-21232-partial-init-and-erroneous-use.rs", -"ui/nll/issue-21232-partial-init-and-use.rs", -"ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs", -"ui/nll/issue-27282-move-match-input-into-guard.rs", -"ui/nll/issue-27282-move-ref-mut-into-guard.rs", -"ui/nll/issue-27282-mutate-before-diverging-arm-1.rs", -"ui/nll/issue-27282-mutate-before-diverging-arm-2.rs", -"ui/nll/issue-27282-mutate-before-diverging-arm-3.rs", -"ui/nll/issue-27282-mutation-in-guard.rs", -"ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs", -"ui/nll/issue-27868.rs", -"ui/nll/issue-30438-a.rs", -"ui/nll/issue-30438-b.rs", -"ui/nll/issue-30438-c.rs", -"ui/nll/issue-31567.rs", -"ui/nll/issue-42574-diagnostic-in-nested-closure.rs", -"ui/nll/issue-45157.rs", -"ui/nll/issue-45696-long-live-borrows-in-boxes.rs", -"ui/nll/issue-45696-no-variant-box-recur.rs", -"ui/nll/issue-45696-scribble-on-boxed-borrow.rs", -"ui/nll/issue-46023.rs", -"ui/nll/issue-46036.rs", -"ui/nll/issue-46589.rs", -"ui/nll/issue-47153-generic-const.rs", -"ui/nll/issue-47388.rs", -"ui/nll/issue-47470.rs", -"ui/nll/issue-47589.rs", -"ui/nll/issue-48070.rs", -"ui/nll/issue-48238.rs", -"ui/nll/issue-48623-closure.rs", -"ui/nll/issue-48623-generator.rs", -"ui/nll/issue-48697.rs", -"ui/nll/issue-48803.rs", -"ui/nll/issue-50343.rs", -"ui/nll/issue-50461-used-mut-from-moves.rs", -"ui/nll/issue-50716.rs", -"ui/nll/issue-51191.rs", -"ui/nll/issue-51244.rs", -"ui/nll/issue-51268.rs", -"ui/nll/issue-51512.rs", -"ui/nll/issue-52057.rs", -"ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs", -"ui/nll/issue-52086.rs", -"ui/nll/issue-52113.rs", -"ui/nll/issue-52213.rs", -"ui/nll/issue-52533-1.rs", -"ui/nll/issue-52534-1.rs", -"ui/nll/issue-52534-2.rs", -"ui/nll/issue-52534.rs", -"ui/nll/issue-52663-span-decl-captured-variable.rs", -"ui/nll/issue-52663-trait-object.rs", -"ui/nll/issue-52669.rs", -"ui/nll/issue-52742.rs", -"ui/nll/issue-53040.rs", -"ui/nll/issue-53123-raw-pointer-cast.rs", -"ui/nll/issue-53773.rs", -"ui/nll/issue-53807.rs", -"ui/nll/issue-54189.rs", -"ui/nll/issue-54302-cases.rs", -"ui/nll/issue-54302.rs", -"ui/nll/issue-54382-use-span-of-tail-of-block.rs", -"ui/nll/issue-54556-niconii.rs", -"ui/nll/issue-54556-stephaneyfx.rs", -"ui/nll/issue-54556-temps-in-tail-diagnostic.rs", -"ui/nll/issue-54556-used-vs-unused-tails.rs", -"ui/nll/issue-54556-wrap-it-up.rs", -"ui/nll/issue-54779-anon-static-lifetime.rs", -"ui/nll/issue-54943.rs", -"ui/nll/issue-55394.rs", -"ui/nll/issue-55401.rs", -"ui/nll/issue-55511.rs", -"ui/nll/issue-55850.rs", -"ui/nll/issue-57100.rs", -"ui/nll/issue-57265-return-type-wf-check.rs", -"ui/nll/issue-57280-1-flipped.rs", -"ui/nll/issue-57642-higher-ranked-subtype.rs", -"ui/nll/issue-57843.rs", -"ui/nll/issue-57960.rs", -"ui/nll/issue-57989.rs", -"ui/nll/issue-58053.rs", -"ui/nll/issue-58299.rs", -"ui/nll/issue-62007-assign-const-index.rs", -"ui/nll/issue-62007-assign-differing-fields.rs", -"ui/nll/issue-67007-escaping-data.rs", -"ui/nll/issue-68550.rs", -"ui/nll/issue-69114-static-mut-ty.rs", -"ui/nll/issue-69114-static-ty.rs", -"ui/nll/issue-73159-rpit-static.rs", -"ui/nll/issue-75777.rs", -"ui/nll/issue-95272.rs", -"ui/nll/issue-97997.rs", -"ui/nll/issue-98170.rs", -"ui/nll/issue-98589-closures-relate-named-regions.rs", -"ui/nll/issue-98693.rs", -"ui/nll/issue-112604-closure-output-normalize.rs", -"ui/nll/issue-16223.rs", -"ui/nll/issue-21114-ebfull.rs", -"ui/nll/issue-21114-kixunil.rs", -"ui/nll/issue-22323-temp-destruction.rs", -"ui/nll/issue-27583.rs", -"ui/nll/issue-30104.rs", -"ui/nll/issue-32382-index-assoc-type-with-lifetime.rs", -"ui/nll/issue-43058.rs", -"ui/nll/issue-47022.rs", -"ui/nll/issue-48179.rs", -"ui/nll/issue-50716-1.rs", -"ui/nll/issue-51345-2.rs", -"ui/nll/issue-51351.rs", -"ui/nll/issue-51770.rs", -"ui/nll/issue-52078.rs", -"ui/nll/issue-52992.rs", -"ui/nll/issue-53119.rs", -"ui/nll/issue-53570.rs", -"ui/nll/issue-54943-3.rs", -"ui/nll/issue-55288.rs", -"ui/nll/issue-55344.rs", -"ui/nll/issue-55651.rs", -"ui/nll/issue-55825-const-fn.rs", -"ui/nll/issue-57280-1.rs", -"ui/nll/issue-57280.rs", -"ui/nll/issue-61311-normalize.rs", -"ui/nll/issue-61320-normalize.rs", -"ui/nll/issue-61424.rs", -"ui/nll/issue-63154-normalize.rs", -"ui/nll/issue-78561.rs", -"ui/numbers-arithmetic/issue-8460.rs", -"ui/numbers-arithmetic/issue-105626.rs", -"ui/numbers-arithmetic/issue-8460-const.rs", -"ui/object-safety/issue-19538.rs", -"ui/object-safety/issue-102762.rs", -"ui/object-safety/issue-102933.rs", -"ui/object-safety/issue-106247.rs", -"ui/on-unimplemented/issue-104140.rs", -"ui/or-patterns/issue-64879-trailing-before-guard.rs", -"ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs", -"ui/or-patterns/issue-67514-irrefutable-param.rs", -"ui/or-patterns/issue-68785-irrefutable-param-with-at.rs", -"ui/or-patterns/issue-69875-should-have-been-expanded-earlier.rs", -"ui/or-patterns/issue-70413-no-unreachable-pat-and-guard.rs", -"ui/overloaded/issue-14958.rs", -"ui/packed/issue-27060-2.rs", -"ui/packed/issue-27060.rs", -"ui/packed/issue-46152.rs", -"ui/panics/issue-47429-short-backtraces.rs", -"ui/parser/issues/auxiliary/issue-21146-inc.rs", -"ui/parser/issues/auxiliary/issue-89971-outer-attr-following-inner-attr-ice.rs", -"ui/parser/issues/auxiliary/issue-94340-inc.rs", -"ui/parser/issues/issue-101540.rs", -"ui/parser/issues/issue-102182-impl-trait-recover.rs", -"ui/parser/issues/issue-10392.rs", -"ui/parser/issues/issue-104088.rs", -"ui/parser/issues/issue-104367.rs", -"ui/parser/issues/issue-10636-1.rs", -"ui/parser/issues/issue-108242-semicolon-recovery.rs", -"ui/parser/issues/issue-110014.rs", -"ui/parser/issues/issue-111416.rs", -"ui/parser/issues/issue-13483.rs", -"ui/parser/issues/issue-14303.rs", -"ui/parser/issues/issue-15914.rs", -"ui/parser/issues/issue-15980.rs", -"ui/parser/issues/issue-1655.rs", -"ui/parser/issues/issue-17718-const-mut.rs", -"ui/parser/issues/issue-17904-2.rs", -"ui/parser/issues/issue-1802-1.rs", -"ui/parser/issues/issue-1802-2.rs", -"ui/parser/issues/issue-19096.rs", -"ui/parser/issues/issue-19398.rs", -"ui/parser/issues/issue-20616-1.rs", -"ui/parser/issues/issue-20616-2.rs", -"ui/parser/issues/issue-20616-3.rs", -"ui/parser/issues/issue-20616-4.rs", -"ui/parser/issues/issue-20616-5.rs", -"ui/parser/issues/issue-20616-6.rs", -"ui/parser/issues/issue-20616-7.rs", -"ui/parser/issues/issue-20616-8.rs", -"ui/parser/issues/issue-20616-9.rs", -"ui/parser/issues/issue-20711-2.rs", -"ui/parser/issues/issue-20711.rs", -"ui/parser/issues/issue-21153.rs", -"ui/parser/issues/issue-21475.rs", -"ui/parser/issues/issue-22647.rs", -"ui/parser/issues/issue-22712.rs", -"ui/parser/issues/issue-2354-1.rs", -"ui/parser/issues/issue-2354.rs", -"ui/parser/issues/issue-23620-invalid-escapes.rs", -"ui/parser/issues/issue-24197.rs", -"ui/parser/issues/issue-24375.rs", -"ui/parser/issues/issue-24780.rs", -"ui/parser/issues/issue-27255.rs", -"ui/parser/issues/issue-31804.rs", -"ui/parser/issues/issue-32214.rs", -"ui/parser/issues/issue-32446.rs", -"ui/parser/issues/issue-32501.rs", -"ui/parser/issues/issue-32505.rs", -"ui/parser/issues/issue-33262.rs", -"ui/parser/issues/issue-33413.rs", -"ui/parser/issues/issue-33418.rs", -"ui/parser/issues/issue-33455.rs", -"ui/parser/issues/issue-34222-1.rs", -"ui/parser/issues/issue-34255-1.rs", -"ui/parser/issues/issue-41155.rs", -"ui/parser/issues/issue-43196.rs", -"ui/parser/issues/issue-43692.rs", -"ui/parser/issues/issue-44021.rs", -"ui/parser/issues/issue-44406.rs", -"ui/parser/issues/issue-45296.rs", -"ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs", -"ui/parser/issues/issue-48508-aux.rs", -"ui/parser/issues/issue-49040.rs", -"ui/parser/issues/issue-51602.rs", -"ui/parser/issues/issue-52496.rs", -"ui/parser/issues/issue-5544-a.rs", -"ui/parser/issues/issue-5544-b.rs", -"ui/parser/issues/issue-56031.rs", -"ui/parser/issues/issue-57198.rs", -"ui/parser/issues/issue-5806.rs", -"ui/parser/issues/issue-58856-1.rs", -"ui/parser/issues/issue-58856-2.rs", -"ui/parser/issues/issue-59418.rs", -"ui/parser/issues/issue-60075.rs", -"ui/parser/issues/issue-62546.rs", -"ui/parser/issues/issue-62660.rs", -"ui/parser/issues/issue-62881.rs", -"ui/parser/issues/issue-62895.rs", -"ui/parser/issues/issue-62913.rs", -"ui/parser/issues/issue-64732.rs", -"ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.rs", -"ui/parser/issues/issue-65257-invalid-var-decl-recovery.rs", -"ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs", -"ui/parser/issues/issue-6610.rs", -"ui/parser/issues/issue-66357-unexpected-unreachable.rs", -"ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs", -"ui/parser/issues/issue-68000-unicode-ident-after-missing-comma.rs", -"ui/parser/issues/issue-68890-2.rs", -"ui/parser/issues/issue-68890.rs", -"ui/parser/issues/issue-69259.rs", -"ui/parser/issues/issue-70388-recover-dotdotdot-rest-pat.rs", -"ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs", -"ui/parser/issues/issue-70552-ascription-in-parens-after-call.rs", -"ui/parser/issues/issue-70583-block-is-empty-1.rs", -"ui/parser/issues/issue-70583-block-is-empty-2.rs", -"ui/parser/issues/issue-7222.rs", -"ui/parser/issues/issue-72253.rs", -"ui/parser/issues/issue-72373.rs", -"ui/parser/issues/issue-73568-lifetime-after-mut.rs", -"ui/parser/issues/issue-7970b.rs", -"ui/parser/issues/issue-81806.rs", -"ui/parser/issues/issue-83639.rs", -"ui/parser/issues/issue-84117.rs", -"ui/parser/issues/issue-84148-1.rs", -"ui/parser/issues/issue-8537.rs", -"ui/parser/issues/issue-86895.rs", -"ui/parser/issues/issue-87086-colon-path-sep.rs", -"ui/parser/issues/issue-87635.rs", -"ui/parser/issues/issue-87812-path.rs", -"ui/parser/issues/issue-87812.rs", -"ui/parser/issues/issue-88818.rs", -"ui/parser/issues/issue-89388.rs", -"ui/parser/issues/issue-89574.rs", -"ui/parser/issues/issue-89971-outer-attr-following-inner-attr-ice.rs", -"ui/parser/issues/issue-90993.rs", -"ui/parser/issues/issue-91461.rs", -"ui/parser/issues/issue-93282.rs", -"ui/parser/issues/issue-93867.rs", -"ui/parser/issues/issue-94340.rs", -"ui/parser/issues/issue-111148.rs", -"ui/parser/issues/issue-111692.rs", -"ui/parser/issues/issue-10392-2.rs", -"ui/parser/issues/issue-105209.rs", -"ui/parser/issues/issue-10636-2.rs", -"ui/parser/issues/issue-14303-fncall.rs", -"ui/parser/issues/issue-17904.rs", -"ui/parser/issues/issue-21146.rs", -"ui/parser/issues/issue-30318.rs", -"ui/parser/issues/issue-3036.rs", -"ui/parser/issues/issue-35813-postfix-after-cast.rs", -"ui/parser/issues/issue-46186.rs", -"ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items.rs", -"ui/parser/issues/issue-48508.rs", -"ui/parser/issues/issue-48636.rs", -"ui/parser/issues/issue-54521-1.rs", -"ui/parser/issues/issue-54521-2.rs", -"ui/parser/issues/issue-54521-3.rs", -"ui/parser/issues/issue-57684.rs", -"ui/parser/issues/issue-57819.rs", -"ui/parser/issues/issue-58094-missing-right-square-bracket.rs", -"ui/parser/issues/issue-62524.rs", -"ui/parser/issues/issue-62554.rs", -"ui/parser/issues/issue-62894.rs", -"ui/parser/issues/issue-62973.rs", -"ui/parser/issues/issue-63115-range-pat-interpolated.rs", -"ui/parser/issues/issue-63116.rs", -"ui/parser/issues/issue-63135.rs", -"ui/parser/issues/issue-65041-empty-vis-matcher-in-enum.rs", -"ui/parser/issues/issue-65041-empty-vis-matcher-in-trait.rs", -"ui/parser/issues/issue-66473.rs", -"ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs", -"ui/parser/issues/issue-68629.rs", -"ui/parser/issues/issue-68730.rs", -"ui/parser/issues/issue-68788-in-trait-item-propagation.rs", -"ui/parser/issues/issue-70050-ntliteral-accepts-negated-lit.rs", -"ui/parser/issues/issue-70388-without-witness.rs", -"ui/parser/issues/issue-75599.rs", -"ui/parser/issues/issue-76437-async.rs", -"ui/parser/issues/issue-76437-const-async-unsafe.rs", -"ui/parser/issues/issue-76437-const-async.rs", -"ui/parser/issues/issue-76437-const.rs", -"ui/parser/issues/issue-76437-pub-crate-unsafe.rs", -"ui/parser/issues/issue-76437-unsafe.rs", -"ui/parser/issues/issue-76597.rs", -"ui/parser/issues/issue-84104.rs", -"ui/parser/issues/issue-84148-2.rs", -"ui/parser/issues/issue-87197-missing-semicolon.rs", -"ui/parser/issues/issue-88276-unary-plus.rs", -"ui/parser/issues/issue-88583-union-as-ident.rs", -"ui/parser/issues/issue-88770.rs", -"ui/parser/issues/issue-89396.rs", -"ui/parser/issues/issue-112458.rs", -"ui/parser/macro/issue-33569.rs", -"ui/parser/macro/issue-37113.rs", -"ui/parser/macro/issue-37234.rs", -"ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs", -"ui/parser/shebang/issue-71471-ignore-tidy.rs", -"ui/parser/issue-102806.rs", -"ui/parser/issue-103143.rs", -"ui/parser/issue-103425.rs", -"ui/parser/issue-103748-ICE-wrong-braces.rs", -"ui/parser/issue-104620.rs", -"ui/parser/issue-104867-inc-dec-2.rs", -"ui/parser/issue-104867-inc-dec.rs", -"ui/parser/issue-108495-dec.rs", -"ui/parser/issue-17718-parse-const.rs", -"ui/parser/issue-39616.rs", -"ui/parser/issue-49257.rs", -"ui/parser/issue-61858.rs", -"ui/parser/issue-68091-unicode-ident-after-if.rs", -"ui/parser/issue-68092-unicode-ident-after-incomplete-expr.rs", -"ui/parser/issue-68987-unmatch-issue-1.rs", -"ui/parser/issue-68987-unmatch-issue-2.rs", -"ui/parser/issue-68987-unmatch-issue-3.rs", -"ui/parser/issue-68987-unmatch-issue.rs", -"ui/parser/issue-87694-duplicated-pub.rs", -"ui/parser/issue-87694-misplaced-pub.rs", -"ui/parser/issue-90728.rs", -"ui/parser/issue-91421.rs", -"ui/parser/issue-100197-mut-let.rs", -"ui/parser/issue-101477-enum.rs", -"ui/parser/issue-101477-let.rs", -"ui/parser/issue-103381.rs", -"ui/parser/issue-103451.rs", -"ui/parser/issue-105366.rs", -"ui/parser/issue-105634.rs", -"ui/parser/issue-107705.rs", -"ui/parser/issue-112188.rs", -"ui/parser/issue-81804.rs", -"ui/parser/issue-81827.rs", -"ui/parser/issue-99625-enum-struct-mutually-exclusive.rs", -"ui/parser/issue-99910-const-let-mutually-exclusive.rs", -"ui/parser/issue-113342.rs", -"ui/pattern/move-ref-patterns/issue-53840.rs", -"ui/pattern/usefulness/issue-12116.rs", -"ui/pattern/usefulness/issue-12369.rs", -"ui/pattern/usefulness/issue-13727.rs", -"ui/pattern/usefulness/issue-15129.rs", -"ui/pattern/usefulness/issue-2111.rs", -"ui/pattern/usefulness/issue-30240-b.rs", -"ui/pattern/usefulness/issue-30240-rpass.rs", -"ui/pattern/usefulness/issue-30240.rs", -"ui/pattern/usefulness/issue-3096-1.rs", -"ui/pattern/usefulness/issue-3096-2.rs", -"ui/pattern/usefulness/issue-31221.rs", -"ui/pattern/usefulness/issue-31561.rs", -"ui/pattern/usefulness/issue-35609.rs", -"ui/pattern/usefulness/issue-39362.rs", -"ui/pattern/usefulness/issue-40221.rs", -"ui/pattern/usefulness/issue-4321.rs", -"ui/pattern/usefulness/issue-50900.rs", -"ui/pattern/usefulness/issue-56379.rs", -"ui/pattern/usefulness/issue-57472.rs", -"ui/pattern/usefulness/issue-72377.rs", -"ui/pattern/usefulness/issue-78123-non-exhaustive-reference.rs", -"ui/pattern/usefulness/issue-82772-match-box-as-struct.rs", -"ui/pattern/usefulness/issue-53820-slice-pattern-large-array.rs", -"ui/pattern/usefulness/issue-65413-constants-and-slices-exhaustiveness.rs", -"ui/pattern/usefulness/issue-66501.rs", -"ui/pattern/usefulness/issue-71930-type-of-match-scrutinee.rs", -"ui/pattern/usefulness/issue-72476-and-89393-associated-type.rs", -"ui/pattern/usefulness/issue-78549-ref-pat-and-str.rs", -"ui/pattern/usefulness/issue-80501-or-pat-and-macro.rs", -"ui/pattern/usefulness/issue-88747.rs", -"ui/pattern/usefulness/issue-3601.rs", -"ui/pattern/issue-10392.rs", -"ui/pattern/issue-106552.rs", -"ui/pattern/issue-11577.rs", -"ui/pattern/issue-12582.rs", -"ui/pattern/issue-14221.rs", -"ui/pattern/issue-15080.rs", -"ui/pattern/issue-17718-patterns.rs", -"ui/pattern/issue-22546.rs", -"ui/pattern/issue-27320.rs", -"ui/pattern/issue-52240.rs", -"ui/pattern/issue-6449.rs", -"ui/pattern/issue-66270-pat-struct-parser-recovery.rs", -"ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs", -"ui/pattern/issue-67776-match-same-name-enum-variant-refs.rs", -"ui/pattern/issue-68393-let-pat-assoc-constant.rs", -"ui/pattern/issue-72574-1.rs", -"ui/pattern/issue-72574-2.rs", -"ui/pattern/issue-74539.rs", -"ui/pattern/issue-74702.rs", -"ui/pattern/issue-80186-mut-binding-help-suggestion.rs", -"ui/pattern/issue-8351-1.rs", -"ui/pattern/issue-8351-2.rs", -"ui/pattern/issue-88074-pat-range-type-inference-err.rs", -"ui/pattern/issue-92074-macro-ice.rs", -"ui/pattern/issue-95878.rs", -"ui/pattern/issue-72565.rs", -"ui/pattern/issue-94866.rs", -"ui/pattern/issue-106862.rs", -"ui/pattern/issue-74954.rs", -"ui/pattern/issue-88074-pat-range-type-inference.rs", -"ui/pattern/issue-110508.rs", -"ui/polymorphization/issue-74614.rs", -"ui/polymorphization/issue-74636.rs", -"ui/privacy/auxiliary/issue-17718-const-privacy.rs", -"ui/privacy/auxiliary/issue-57264-1.rs", -"ui/privacy/auxiliary/issue-57264-2.rs", -"ui/privacy/auxiliary/issue-75907.rs", -"ui/privacy/auxiliary/issue-92755.rs", -"ui/privacy/issue-13641.rs", -"ui/privacy/issue-17718-const-privacy.rs", -"ui/privacy/issue-29161.rs", -"ui/privacy/issue-30079.rs", -"ui/privacy/issue-46209-private-enum-variant-reexport.rs", -"ui/privacy/issue-75062-fieldless-tuple-struct.rs", -"ui/privacy/issue-75906.rs", -"ui/privacy/issue-75907.rs", -"ui/privacy/issue-75907_b.rs", -"ui/privacy/issue-79593.rs", -"ui/privacy/issue-92755.rs", -"ui/privacy/issue-111220-2-tuple-struct-fields-projection.rs", -"ui/privacy/issue-111220-tuple-struct-fields.rs", -"ui/privacy/issue-57264-1.rs", -"ui/privacy/issue-57264-2.rs", -"ui/proc-macro/auxiliary/issue-104884.rs", -"ui/proc-macro/auxiliary/issue-38586.rs", -"ui/proc-macro/auxiliary/issue-39889.rs", -"ui/proc-macro/auxiliary/issue-42708.rs", -"ui/proc-macro/auxiliary/issue-50061.rs", -"ui/proc-macro/auxiliary/issue-50493.rs", -"ui/proc-macro/auxiliary/issue-66286.rs", -"ui/proc-macro/auxiliary/issue-75801.rs", -"ui/proc-macro/auxiliary/issue-79242.rs", -"ui/proc-macro/auxiliary/issue-79825.rs", -"ui/proc-macro/auxiliary/issue-83510.rs", -"ui/proc-macro/auxiliary/issue-91800-macro.rs", -"ui/proc-macro/auxiliary/issue-59191.rs", -"ui/proc-macro/issue-104884-trait-impl-sugg-err.rs", -"ui/proc-macro/issue-36935.rs", -"ui/proc-macro/issue-37788.rs", -"ui/proc-macro/issue-38586.rs", -"ui/proc-macro/issue-39889.rs", -"ui/proc-macro/issue-42708.rs", -"ui/proc-macro/issue-50061.rs", -"ui/proc-macro/issue-50493.rs", -"ui/proc-macro/issue-53481.rs", -"ui/proc-macro/issue-66286.rs", -"ui/proc-macro/issue-75801.rs", -"ui/proc-macro/issue-81543-item-parse-err.rs", -"ui/proc-macro/issue-83469-global-alloc-invalid-stmt.rs", -"ui/proc-macro/issue-83510.rs", -"ui/proc-macro/issue-91800.rs", -"ui/proc-macro/issue-59191-replace-root-with-fn.rs", -"ui/proc-macro/issue-73933-procedural-masquerade.rs", -"ui/proc-macro/issue-75734-pp-paren.rs", -"ui/proc-macro/issue-75930-derive-cfg.rs", -"ui/proc-macro/issue-76182-leading-vert-pat.rs", -"ui/proc-macro/issue-76270-panic-in-libproc-macro.rs", -"ui/proc-macro/issue-78675-captured-inner-attrs.rs", -"ui/proc-macro/issue-79148.rs", -"ui/proc-macro/issue-79242-slow-retokenize-check.rs", -"ui/proc-macro/issue-79825.rs", -"ui/proc-macro/issue-80760-empty-stmt.rs", -"ui/proc-macro/issue-81007-item-attrs.rs", -"ui/proc-macro/issue-81555.rs", -"ui/proc-macro/issue-86781-bad-inner-doc.rs", -"ui/process/issue-13304.rs", -"ui/process/issue-14456.rs", -"ui/process/issue-14940.rs", -"ui/process/issue-16272.rs", -"ui/process/issue-20091.rs", -"ui/ptr_ops/issue-80309-safe.rs", -"ui/ptr_ops/issue-80309.rs", -"ui/pub/issue-33174-restricted-type-in-public-interface.rs", -"ui/query-system/issue-83479.rs", -"ui/range/issue-54505-no-std.rs", -"ui/range/issue-73553-misinterp-range-literal.rs", -"ui/range/issue-54505-no-literals.rs", -"ui/range/issue-54505.rs", -"ui/reachable/auxiliary/issue-11225-1.rs", -"ui/reachable/auxiliary/issue-11225-2.rs", -"ui/reachable/auxiliary/issue-11225-3.rs", -"ui/reachable/issue-11225-1.rs", -"ui/reachable/issue-11225-2.rs", -"ui/reachable/issue-11225-3.rs", -"ui/reachable/issue-948.rs", -"ui/recursion/issue-26548-recursion-via-normalize.rs", -"ui/recursion/issue-38591-non-regular-dropck-recursion.rs", -"ui/recursion/issue-86784.rs", -"ui/recursion/issue-83150.rs", -"ui/recursion/issue-95134.rs", -"ui/recursion_limit/issue-105700.rs", -"ui/recursion_limit/issue-40003.rs", -"ui/regions/issue-101280.rs", -"ui/regions/issue-102374.rs", -"ui/regions/issue-102392.rs", -"ui/regions/issue-12470.rs", -"ui/regions/issue-26448-1.rs", -"ui/regions/issue-28848.rs", -"ui/regions/issue-5243.rs", -"ui/regions/issue-6157.rs", -"ui/regions/issue-11612.rs", -"ui/regions/issue-21520.rs", -"ui/regions/issue-24085.rs", -"ui/regions/issue-26448-2.rs", -"ui/regions/issue-26448-3.rs", -"ui/regions/issue-56537-closure-uses-region-from-container.rs", -"ui/regions/issue-72051-member-region-hang.rs", -"ui/regions/issue-78262.rs", -"ui/repr/issue-83505-repr-simd.rs", -"ui/repr/issue-83921-ice.rs", -"ui/resolve/auxiliary/issue-19452-aux.rs", -"ui/resolve/auxiliary/issue-21221-3.rs", -"ui/resolve/auxiliary/issue-21221-4.rs", -"ui/resolve/auxiliary/issue-30535.rs", -"ui/resolve/auxiliary/issue-3907.rs", -"ui/resolve/auxiliary/issue-80079.rs", -"ui/resolve/auxiliary/issue-112831-aux.rs", -"ui/resolve/issue-113808-invalid-unused-qualifications-suggestion.rs", -"ui/resolve/issue-100365.rs", -"ui/resolve/issue-101749-2.rs", -"ui/resolve/issue-10200.rs", -"ui/resolve/issue-102946.rs", -"ui/resolve/issue-103202.rs", -"ui/resolve/issue-103474.rs", -"ui/resolve/issue-104700-inner_scope.rs", -"ui/resolve/issue-105069.rs", -"ui/resolve/issue-107563-ambiguous-glob-reexports.rs", -"ui/resolve/issue-108529.rs", -"ui/resolve/issue-109250.rs", -"ui/resolve/issue-12796.rs", -"ui/resolve/issue-14254.rs", -"ui/resolve/issue-16058.rs", -"ui/resolve/issue-17518.rs", -"ui/resolve/issue-18252.rs", -"ui/resolve/issue-19452.rs", -"ui/resolve/issue-21221-1.rs", -"ui/resolve/issue-21221-2.rs", -"ui/resolve/issue-21221-3.rs", -"ui/resolve/issue-21221-4.rs", -"ui/resolve/issue-22692.rs", -"ui/resolve/issue-2330.rs", -"ui/resolve/issue-23305.rs", -"ui/resolve/issue-2356.rs", -"ui/resolve/issue-23716.rs", -"ui/resolve/issue-24968.rs", -"ui/resolve/issue-26545.rs", -"ui/resolve/issue-3021-c.rs", -"ui/resolve/issue-3021.rs", -"ui/resolve/issue-30535.rs", -"ui/resolve/issue-3099-a.rs", -"ui/resolve/issue-3099-b.rs", -"ui/resolve/issue-31845.rs", -"ui/resolve/issue-33876.rs", -"ui/resolve/issue-35675.rs", -"ui/resolve/issue-3907-2.rs", -"ui/resolve/issue-3907.rs", -"ui/resolve/issue-39226.rs", -"ui/resolve/issue-39559-2.rs", -"ui/resolve/issue-39559.rs", -"ui/resolve/issue-42944.rs", -"ui/resolve/issue-49074.rs", -"ui/resolve/issue-5035-2.rs", -"ui/resolve/issue-5035.rs", -"ui/resolve/issue-50599.rs", -"ui/resolve/issue-5099.rs", -"ui/resolve/issue-54379.rs", -"ui/resolve/issue-55673.rs", -"ui/resolve/issue-5927.rs", -"ui/resolve/issue-60057.rs", -"ui/resolve/issue-65025-extern-static-parent-generics.rs", -"ui/resolve/issue-65035-static-with-parent-generics.rs", -"ui/resolve/issue-6702.rs", -"ui/resolve/issue-69401-trait-fn-no-body-ty-local.rs", -"ui/resolve/issue-73427.rs", -"ui/resolve/issue-80079.rs", -"ui/resolve/issue-81508.rs", -"ui/resolve/issue-82156.rs", -"ui/resolve/issue-82865.rs", -"ui/resolve/issue-85348.rs", -"ui/resolve/issue-88472.rs", -"ui/resolve/issue-90113.rs", -"ui/resolve/issue-109153.rs", -"ui/resolve/issue-101749.rs", -"ui/resolve/issue-111312.rs", -"ui/resolve/issue-111727.rs", -"ui/resolve/issue-112472-multi-generics-suggestion.rs", -"ui/resolve/issue-112831.rs", -"ui/resolve/issue-57523.rs", -"ui/resolve/issue-70736-async-fn-no-body-def-collector.rs", -"ui/resolve/issue-85671.rs", -"ui/return/issue-82612-return-mutable-reference.rs", -"ui/return/issue-64620.rs", -"ui/return/issue-86188-return-not-in-fn-body.rs", -"ui/rfcs/rfc-1937-termination-trait/issue-103052-1.rs", -"ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs", -"ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs", -"ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.rs", -"ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.rs", -"ui/rfcs/rfc-2396-target_feature-11/issue-99876.rs", -"ui/rfcs/rfc-2396-target_feature-11/issue-108655-inline-always-closure.rs", -"ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.rs", -"ui/rfcs/rfc-2528-type-changing-struct-update/issue-96878.rs", -"ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs", -"ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs", -"ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs", -"ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.rs", -"ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs", -"ui/rfcs/rfc-2093-infer-outlives/issue-54467.rs", -"ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs", -"ui/rfcs/rfc-2497-if-let-chains/issue-88498.rs", -"ui/rfcs/rfc-2497-if-let-chains/issue-90722.rs", -"ui/rfcs/rfc-2497-if-let-chains/issue-92145.rs", -"ui/rfcs/rfc-2497-if-let-chains/issue-99938.rs", -"ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-102156.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-90052.rs", -"ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs", -"ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-103677.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs", -"ui/rfcs/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs", -"ui/rust-2018/uniform-paths/auxiliary/issue-55779-extern-trait.rs", -"ui/rust-2018/uniform-paths/auxiliary/issue-56596-2.rs", -"ui/rust-2018/uniform-paths/auxiliary/issue-56596.rs", -"ui/rust-2018/uniform-paths/auxiliary/issue-87932-a.rs", -"ui/rust-2018/uniform-paths/issue-54253.rs", -"ui/rust-2018/uniform-paths/issue-55779.rs", -"ui/rust-2018/uniform-paths/issue-56596-2.rs", -"ui/rust-2018/uniform-paths/issue-56596.rs", -"ui/rust-2018/uniform-paths/issue-87932.rs", -"ui/rust-2018/issue-51008-1.rs", -"ui/rust-2018/issue-51008.rs", -"ui/rust-2018/issue-52202-use-suggestions.rs", -"ui/rust-2018/issue-54006.rs", -"ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs", -"ui/sanitize/issue-111184-generator-witness.rs", -"ui/sanitize/issue-72154-lifetime-markers.rs", -"ui/self/issue-61882-2.rs", -"ui/self/issue-61882.rs", -"ui/simd/intrinsic/issue-85855.rs", -"ui/simd/issue-17170.rs", -"ui/simd/issue-32947.rs", -"ui/simd/issue-39720.rs", -"ui/simd/issue-85915-simd-ptrs.rs", -"ui/simd/issue-89193.rs", -"ui/simd/issue-105439.rs", -"ui/single-use-lifetime/issue-104440.rs", -"ui/single-use-lifetime/issue-107998.rs", -"ui/span/issue28498-reject-ex1.rs", -"ui/span/issue28498-reject-lifetime-param.rs", -"ui/span/issue28498-reject-passed-to-fn.rs", -"ui/span/issue28498-reject-trait-bound.rs", -"ui/span/issue-11925.rs", -"ui/span/issue-23338-locals-die-before-temps-of-body.rs", -"ui/span/issue-23729.rs", -"ui/span/issue-23827.rs", -"ui/span/issue-24356.rs", -"ui/span/issue-24805-dropck-child-has-items-via-parent.rs", -"ui/span/issue-24805-dropck-trait-has-items.rs", -"ui/span/issue-24895-copy-clone-dropck.rs", -"ui/span/issue-25199.rs", -"ui/span/issue-26656.rs", -"ui/span/issue-27522.rs", -"ui/span/issue-29106.rs", -"ui/span/issue-29595.rs", -"ui/span/issue-33884.rs", -"ui/span/issue-34264.rs", -"ui/span/issue-35987.rs", -"ui/span/issue-36537.rs", -"ui/span/issue-37767.rs", -"ui/span/issue-39018.rs", -"ui/span/issue-39698.rs", -"ui/span/issue-40157.rs", -"ui/span/issue-43927-non-ADT-derive.rs", -"ui/span/issue-81800.rs", -"ui/span/issue-107353.rs", -"ui/span/issue-15480.rs", -"ui/span/issue-24690.rs", -"ui/span/issue-42234-unknown-receiver-type.rs", -"ui/span/issue-71363.rs", -"ui/specialization/min_specialization/issue-79224.rs", -"ui/specialization/issue-111232.rs", -"ui/specialization/issue-33017.rs", -"ui/specialization/issue-38091-2.rs", -"ui/specialization/issue-38091.rs", -"ui/specialization/issue-39448.rs", -"ui/specialization/issue-44861.rs", -"ui/specialization/issue-50452-fail.rs", -"ui/specialization/issue-50452.rs", -"ui/specialization/issue-51892.rs", -"ui/specialization/issue-52050.rs", -"ui/specialization/issue-59435.rs", -"ui/specialization/issue-68830-spurious-diagnostics.rs", -"ui/specialization/issue-35376.rs", -"ui/specialization/issue-36804.rs", -"ui/specialization/issue-39618.rs", -"ui/specialization/issue-40582.rs", -"ui/specialization/issue-43037.rs", -"ui/specialization/issue-45814.rs", -"ui/specialization/issue-63716-parse-async.rs", -"ui/specialization/issue-70442.rs", -"ui/stability-attribute/issue-106589.rs", -"ui/stability-attribute/issue-109177.rs", -"ui/stability-attribute/issue-28075.rs", -"ui/stability-attribute/issue-28388-3.rs", -"ui/stability-attribute/issue-99286-stable-intrinsics.rs", -"ui/static/auxiliary/issue_24843.rs", -"ui/static/issue-18118-2.rs", -"ui/static/issue-18118.rs", -"ui/static/issue-34194.rs", -"ui/static/issue-5216.rs", -"ui/static/issue-24843.rs", -"ui/statics/issue-15261.rs", -"ui/statics/issue-17233.rs", -"ui/statics/issue-17718-static-sync.rs", -"ui/statics/issue-17718-static-unsafe-interior.rs", -"ui/statics/issue-44373.rs", -"ui/statics/issue-14227.rs", -"ui/statics/issue-44373-2.rs", -"ui/statics/issue-91050-1.rs", -"ui/statics/issue-91050-2.rs", -"ui/std/issue-15149.rs", -"ui/std/issue-81357-unsound-file-methods.rs", -"ui/stdlib-unit-tests/issue-21058.rs", -"ui/structs-enums/struct-rec/issue-74224.rs", -"ui/structs-enums/struct-rec/issue-84611.rs", -"ui/structs-enums/issue-1701.rs", -"ui/structs-enums/issue-2718-a.rs", -"ui/structs-enums/issue-38002.rs", -"ui/structs-enums/issue-50731.rs", -"ui/structs-enums/issue-3008-1.rs", -"ui/structs-enums/issue-3008-2.rs", -"ui/structs-enums/issue-3008-3.rs", -"ui/structs-enums/issue-103869.rs", -"ui/structs/issue-80853.rs", -"ui/suggestions/auxiliary/issue-61963-1.rs", -"ui/suggestions/auxiliary/issue-61963.rs", -"ui/suggestions/auxiliary/issue-81839.rs", -"ui/suggestions/lifetimes/issue-105544.rs", -"ui/suggestions/issue-101421.rs", -"ui/suggestions/issue-101465.rs", -"ui/suggestions/issue-101623.rs", -"ui/suggestions/issue-101984.rs", -"ui/suggestions/issue-102354.rs", -"ui/suggestions/issue-102892.rs", -"ui/suggestions/issue-103112.rs", -"ui/suggestions/issue-104086-suggest-let.rs", -"ui/suggestions/issue-104287.rs", -"ui/suggestions/issue-104327.rs", -"ui/suggestions/issue-104328.rs", -"ui/suggestions/issue-105226.rs", -"ui/suggestions/issue-105494.rs", -"ui/suggestions/issue-105645.rs", -"ui/suggestions/issue-106443-sugg-clone-for-arg.rs", -"ui/suggestions/issue-106443-sugg-clone-for-bound.rs", -"ui/suggestions/issue-109291.rs", -"ui/suggestions/issue-109396.rs", -"ui/suggestions/issue-109436.rs", -"ui/suggestions/issue-109854.rs", -"ui/suggestions/issue-21673.rs", -"ui/suggestions/issue-51055-missing-semicolon-between-call-and-tuple.rs", -"ui/suggestions/issue-61963.rs", -"ui/suggestions/issue-62843.rs", -"ui/suggestions/issue-64252-self-type.rs", -"ui/suggestions/issue-66968-suggest-sorted-words.rs", -"ui/suggestions/issue-68049-1.rs", -"ui/suggestions/issue-68049-2.rs", -"ui/suggestions/issue-71394-no-from-impl.rs", -"ui/suggestions/issue-81098.rs", -"ui/suggestions/issue-82566-1.rs", -"ui/suggestions/issue-82566-2.rs", -"ui/suggestions/issue-84592.rs", -"ui/suggestions/issue-84700.rs", -"ui/suggestions/issue-84973-2.rs", -"ui/suggestions/issue-84973-blacklist.rs", -"ui/suggestions/issue-84973-negative.rs", -"ui/suggestions/issue-84973.rs", -"ui/suggestions/issue-85347.rs", -"ui/suggestions/issue-85943-no-suggest-unsized-indirection-in-where-clause.rs", -"ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.rs", -"ui/suggestions/issue-86100-tuple-paren-comma.rs", -"ui/suggestions/issue-88730.rs", -"ui/suggestions/issue-89064.rs", -"ui/suggestions/issue-89333.rs", -"ui/suggestions/issue-90974.rs", -"ui/suggestions/issue-94171.rs", -"ui/suggestions/issue-96223.rs", -"ui/suggestions/issue-97760.rs", -"ui/suggestions/issue-98500.rs", -"ui/suggestions/issue-99080.rs", -"ui/suggestions/issue-99240-2.rs", -"ui/suggestions/issue-99240.rs", -"ui/suggestions/issue-99597.rs", -"ui/suggestions/issue-103646.rs", -"ui/suggestions/issue-88696.rs", -"ui/suggestions/issue-101065.rs", -"ui/suggestions/issue-104961.rs", -"ui/suggestions/issue-105761-suggest-self-for-closure.rs", -"ui/suggestions/issue-107860.rs", -"ui/suggestions/issue-108470.rs", -"ui/suggestions/issue-52820.rs", -"ui/suggestions/issue-53692.rs", -"ui/suggestions/issue-57672.rs", -"ui/suggestions/issue-59819.rs", -"ui/suggestions/issue-61226.rs", -"ui/suggestions/issue-72766.rs", -"ui/suggestions/issue-79843-impl-trait-with-missing-bounds-on-async-fn.rs", -"ui/suggestions/issue-81839.rs", -"ui/suggestions/issue-82361.rs", -"ui/suggestions/issue-83892.rs", -"ui/suggestions/issue-83943.rs", -"ui/suggestions/issue-86667.rs", -"ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs", -"ui/suggestions/issue-96555.rs", -"ui/suggestions/issue-97677.rs", -"ui/suggestions/issue-97704.rs", -"ui/suggestions/issue-102972.rs", -"ui/suggestions/issue-109991.rs", -"ui/suggestions/issue-112590-suggest-import.rs", -"ui/suggestions/issue-89640.rs", -"ui/symbol-names/issue-53912.rs", -"ui/symbol-names/issue-60925.rs", -"ui/symbol-names/issue-75326.rs", -"ui/symbol-names/issue-76365.rs", -"ui/test-attrs/custom-test-frameworks/issue-107454.rs", -"ui/test-attrs/issue-109816.rs", -"ui/test-attrs/issue-12997-1.rs", -"ui/test-attrs/issue-12997-2.rs", -"ui/test-attrs/issue-16597-empty.rs", -"ui/test-attrs/issue-16597.rs", -"ui/test-attrs/issue-20823.rs", -"ui/test-attrs/issue-34932.rs", -"ui/test-attrs/issue-36768.rs", -"ui/test-attrs/issue-52557.rs", -"ui/test-attrs/issue-53675-a-test-called-panic.rs", -"ui/threads-sendsync/issue-24313.rs", -"ui/threads-sendsync/issue-29488.rs", -"ui/threads-sendsync/issue-43733-2.rs", -"ui/threads-sendsync/issue-4446.rs", -"ui/threads-sendsync/issue-4448.rs", -"ui/threads-sendsync/issue-8827.rs", -"ui/threads-sendsync/issue-9396.rs", -"ui/threads-sendsync/issue-43733.rs", -"ui/trait-bounds/issue-75961.rs", -"ui/trait-bounds/issue-93008.rs", -"ui/trait-bounds/issue-94680.rs", -"ui/trait-bounds/issue-94999.rs", -"ui/trait-bounds/issue-95640.rs", -"ui/traits/alias/issue-108072-unmet-trait-alias-bound.rs", -"ui/traits/alias/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs", -"ui/traits/alias/issue-83613.rs", -"ui/traits/alias/issue-107747-do-not-assemble-supertraits.rs", -"ui/traits/alias/issue-60021-assoc-method-resolve.rs", -"ui/traits/alias/issue-60755.rs", -"ui/traits/alias/issue-72415-assoc-const-resolve.rs", -"ui/traits/alias/issue-75983.rs", -"ui/traits/associated_type_bound/issue-51446.rs", -"ui/traits/auxiliary/issue_89119_intercrate_caching.rs", -"ui/traits/new-solver/coherence/issue-102048.rs", -"ui/traits/object/issue-44454-1.rs", -"ui/traits/object/issue-44454-2.rs", -"ui/traits/object/issue-44454-3.rs", -"ui/traits/object/issue-33140-traitobject-crate.rs", -"ui/traits/suggest-deferences/issue-39029.rs", -"ui/traits/suggest-deferences/issue-62530.rs", -"ui/traits/trait-upcasting/issue-11515.rs", -"ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs", -"ui/traits/vtable/issue-97381.rs", -"ui/traits/vtable/issue-91807.rs", -"ui/traits/issue-102989.rs", -"ui/traits/issue-103563.rs", -"ui/traits/issue-104322.rs", -"ui/traits/issue-106072.rs", -"ui/traits/issue-18400.rs", -"ui/traits/issue-18412.rs", -"ui/traits/issue-20692.rs", -"ui/traits/issue-22019.rs", -"ui/traits/issue-22110.rs", -"ui/traits/issue-22384.rs", -"ui/traits/issue-22655.rs", -"ui/traits/issue-23003.rs", -"ui/traits/issue-23825.rs", -"ui/traits/issue-24010.rs", -"ui/traits/issue-26339.rs", -"ui/traits/issue-28576.rs", -"ui/traits/issue-32963.rs", -"ui/traits/issue-33140-hack-boundaries.rs", -"ui/traits/issue-33140.rs", -"ui/traits/issue-35869.rs", -"ui/traits/issue-3683.rs", -"ui/traits/issue-38033.rs", -"ui/traits/issue-38404.rs", -"ui/traits/issue-38604.rs", -"ui/traits/issue-3973.rs", -"ui/traits/issue-4107.rs", -"ui/traits/issue-43132.rs", -"ui/traits/issue-43784-supertrait.rs", -"ui/traits/issue-50480.rs", -"ui/traits/issue-52893.rs", -"ui/traits/issue-56202.rs", -"ui/traits/issue-56488.rs", -"ui/traits/issue-59029-1.rs", -"ui/traits/issue-59029-2.rs", -"ui/traits/issue-6128.rs", -"ui/traits/issue-6334.rs", -"ui/traits/issue-65284-suggest-generic-trait-bound.rs", -"ui/traits/issue-65673.rs", -"ui/traits/issue-68295.rs", -"ui/traits/issue-7013.rs", -"ui/traits/issue-71036.rs", -"ui/traits/issue-71136.rs", -"ui/traits/issue-72410.rs", -"ui/traits/issue-75627.rs", -"ui/traits/issue-77982.rs", -"ui/traits/issue-78372.rs", -"ui/traits/issue-79458.rs", -"ui/traits/issue-8153.rs", -"ui/traits/issue-85735.rs", -"ui/traits/issue-87558.rs", -"ui/traits/issue-91594.rs", -"ui/traits/issue-9394-inherited-calls.rs", -"ui/traits/issue-97576.rs", -"ui/traits/issue-99875.rs", -"ui/traits/issue-105231.rs", -"ui/traits/issue-83538-tainted-cache-after-cycle.rs", -"ui/traits/issue-23003-overflow.rs", -"ui/traits/issue-70944.rs", -"ui/traits/issue-72455.rs", -"ui/traits/issue-78632.rs", -"ui/traits/issue-82830.rs", -"ui/traits/issue-84399-bad-fresh-caching.rs", -"ui/traits/issue-85360-eval-obligation-ice.rs", -"ui/traits/issue-89119.rs", -"ui/traits/issue-90195-2.rs", -"ui/traits/issue-90195.rs", -"ui/traits/issue-90662-projection-caching.rs", -"ui/traits/issue-91949-hangs-on-recursion.rs", -"ui/traits/issue-92292.rs", -"ui/traits/issue-95311.rs", -"ui/traits/issue-95898.rs", -"ui/traits/issue-96664.rs", -"ui/traits/issue-96665.rs", -"ui/traits/issue-97695-double-trivial-bound.rs", -"ui/transmutability/arrays/issue-103783-array-length.rs", -"ui/transmutability/issue-101739-1.rs", -"ui/transmutability/issue-101739-2.rs", -"ui/transmutability/issue-110467.rs", -"ui/transmutability/issue-110892.rs", -"ui/trivial-bounds/issue-73021-impossible-inline.rs", -"ui/try-block/issue-45124.rs", -"ui/type-alias-enum-variants/issue-57866.rs", -"ui/type-alias-enum-variants/issue-61801-path-pattern-can-infer.rs", -"ui/type-alias-enum-variants/issue-63151-dead-code-lint-fields-in-patterns.rs", -"ui/type-alias-impl-trait/issue-52843-closure-constrain.rs", -"ui/type-alias-impl-trait/issue-52843.rs", -"ui/type-alias-impl-trait/issue-53092-2.rs", -"ui/type-alias-impl-trait/issue-53092.rs", -"ui/type-alias-impl-trait/issue-53096.rs", -"ui/type-alias-impl-trait/issue-53598.rs", -"ui/type-alias-impl-trait/issue-57700.rs", -"ui/type-alias-impl-trait/issue-58887.rs", -"ui/type-alias-impl-trait/issue-60371.rs", -"ui/type-alias-impl-trait/issue-60407.rs", -"ui/type-alias-impl-trait/issue-63279.rs", -"ui/type-alias-impl-trait/issue-65384.rs", -"ui/type-alias-impl-trait/issue-65918.rs", -"ui/type-alias-impl-trait/issue-74244.rs", -"ui/type-alias-impl-trait/issue-74280.rs", -"ui/type-alias-impl-trait/issue-74761-2.rs", -"ui/type-alias-impl-trait/issue-74761.rs", -"ui/type-alias-impl-trait/issue-84660-unsoundness.rs", -"ui/type-alias-impl-trait/issue-90400-1.rs", -"ui/type-alias-impl-trait/issue-90400-2.rs", -"ui/type-alias-impl-trait/issue-94429.rs", -"ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs", -"ui/type-alias-impl-trait/issue-98608.rs", -"ui/type-alias-impl-trait/issue-101750.rs", -"ui/type-alias-impl-trait/issue-104817.rs", -"ui/type-alias-impl-trait/issue-53398-cyclic-types.rs", -"ui/type-alias-impl-trait/issue-55099-lifetime-inference.rs", -"ui/type-alias-impl-trait/issue-57188-associate-impl-capture.rs", -"ui/type-alias-impl-trait/issue-57611-trait-alias.rs", -"ui/type-alias-impl-trait/issue-57807-associated-type.rs", -"ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs", -"ui/type-alias-impl-trait/issue-58662-simplified.rs", -"ui/type-alias-impl-trait/issue-58951-2.rs", -"ui/type-alias-impl-trait/issue-58951.rs", -"ui/type-alias-impl-trait/issue-60564-working.rs", -"ui/type-alias-impl-trait/issue-60662.rs", -"ui/type-alias-impl-trait/issue-62000-associate-impl-trait-lifetimes.rs", -"ui/type-alias-impl-trait/issue-63355.rs", -"ui/type-alias-impl-trait/issue-63677-type-alias-coherence.rs", -"ui/type-alias-impl-trait/issue-66580-closure-coherence.rs", -"ui/type-alias-impl-trait/issue-67844-nested-opaque.rs", -"ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-ok.rs", -"ui/type-alias-impl-trait/issue-69323.rs", -"ui/type-alias-impl-trait/issue-72793.rs", -"ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs", -"ui/type-alias-impl-trait/issue-78450.rs", -"ui/type-alias-impl-trait/issue-84660-trait-impl-for-tait.rs", -"ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs", -"ui/type-alias-impl-trait/issue-89686.rs", -"ui/type-alias-impl-trait/issue-89952.rs", -"ui/type-alias-impl-trait/issue-93411.rs", -"ui/type-alias-impl-trait/issue-96572-unconstrained.rs", -"ui/type-alias-impl-trait/issue-98604.rs", -"ui/type-alias-impl-trait/issue-109054.rs", -"ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs", -"ui/type-alias-impl-trait/issue-57961.rs", -"ui/type-alias-impl-trait/issue-60564.rs", -"ui/type-alias-impl-trait/issue-63263-closure-return.rs", -"ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs", -"ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs", -"ui/type-alias-impl-trait/issue-68368-non-defining-use.rs", -"ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs", -"ui/type-alias-impl-trait/issue-70121.rs", -"ui/type-alias-impl-trait/issue-77179.rs", -"ui/type-alias/issue-62263-self-in-atb.rs", -"ui/type-alias/issue-62305-self-assoc-ty.rs", -"ui/type-alias/issue-62364-self-ty-arg.rs", -"ui/type-alias/issue-14933.rs", -"ui/type-alias/issue-37515.rs", -"ui/type-inference/issue-30225.rs", -"ui/type-inference/issue-113283-alllocator-trait-eq.rs", -"ui/type/ascription/issue-34255-1.rs", -"ui/type/ascription/issue-47666.rs", -"ui/type/ascription/issue-54516.rs", -"ui/type/ascription/issue-60933.rs", -"ui/type/type-check/issue-22897.rs", -"ui/type/type-check/issue-40294.rs", -"ui/type/type-check/issue-41314.rs", -"ui/type/type-check/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs", -"ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.rs", -"ui/type/issue-100584.rs", -"ui/type/issue-101866.rs", -"ui/type/issue-102598.rs", -"ui/type/issue-103271.rs", -"ui/type/issue-58355.rs", -"ui/type/issue-67690-type-alias-bound-diagnostic-crash.rs", -"ui/type/issue-91268.rs", -"ui/type/issue-94187-verbose-type-name.rs", -"ui/typeck/auxiliary/issue-36708.rs", -"ui/typeck/auxiliary/issue-81943-lib.rs", -"ui/typeck/issue-100246.rs", -"ui/typeck/issue-100285.rs", -"ui/typeck/issue-103899.rs", -"ui/typeck/issue-10401.rs", -"ui/typeck/issue-104513-ice.rs", -"ui/typeck/issue-104582.rs", -"ui/typeck/issue-105946.rs", -"ui/typeck/issue-107087.rs", -"ui/typeck/issue-10969.rs", -"ui/typeck/issue-110052.rs", -"ui/typeck/issue-13853-2.rs", -"ui/typeck/issue-13853-5.rs", -"ui/typeck/issue-13853.rs", -"ui/typeck/issue-18937-1.rs", -"ui/typeck/issue-18937.rs", -"ui/typeck/issue-29124.rs", -"ui/typeck/issue-31173.rs", -"ui/typeck/issue-33575.rs", -"ui/typeck/issue-36708.rs", -"ui/typeck/issue-43189.rs", -"ui/typeck/issue-46112.rs", -"ui/typeck/issue-50687-ice-on-borrow.rs", -"ui/typeck/issue-52082-type-param-shadows-existing-type.rs", -"ui/typeck/issue-53712.rs", -"ui/typeck/issue-57404.rs", -"ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.rs", -"ui/typeck/issue-65611.rs", -"ui/typeck/issue-67971.rs", -"ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.rs", -"ui/typeck/issue-74086.rs", -"ui/typeck/issue-75883.rs", -"ui/typeck/issue-75889.rs", -"ui/typeck/issue-7813.rs", -"ui/typeck/issue-79040.rs", -"ui/typeck/issue-80779.rs", -"ui/typeck/issue-81293.rs", -"ui/typeck/issue-81885.rs", -"ui/typeck/issue-81943.rs", -"ui/typeck/issue-83621-placeholder-static-in-extern.rs", -"ui/typeck/issue-83693.rs", -"ui/typeck/issue-84160.rs", -"ui/typeck/issue-84768.rs", -"ui/typeck/issue-84831.rs", -"ui/typeck/issue-87771-ice-assign-assign-to-bool.rs", -"ui/typeck/issue-87872-missing-inaccessible-field-literal.rs", -"ui/typeck/issue-87872-missing-inaccessible-field-pattern.rs", -"ui/typeck/issue-88609.rs", -"ui/typeck/issue-88643.rs", -"ui/typeck/issue-88844.rs", -"ui/typeck/issue-89275.rs", -"ui/typeck/issue-89806.rs", -"ui/typeck/issue-90101.rs", -"ui/typeck/issue-90164.rs", -"ui/typeck/issue-90319.rs", -"ui/typeck/issue-90804-incorrect-reference-suggestion.rs", -"ui/typeck/issue-91267.rs", -"ui/typeck/issue-91450-inner-ty-error.rs", -"ui/typeck/issue-92481.rs", -"ui/typeck/issue-93486.rs", -"ui/typeck/issue-96530.rs", -"ui/typeck/issue-96738.rs", -"ui/typeck/issue-98260.rs", -"ui/typeck/issue-98982.rs", -"ui/typeck/issue-106929.rs", -"ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs", -"ui/typeck/issue-1871.rs", -"ui/typeck/issue-2063.rs", -"ui/typeck/issue-100164.rs", -"ui/typeck/issue-104510-ice.rs", -"ui/typeck/issue-107775.rs", -"ui/typeck/issue-112252-ptr-arithmetics-help.rs", -"ui/typeck/issue-2063-resource.rs", -"ui/typeck/issue-22375.rs", -"ui/typeck/issue-55810-must-typeck-match-pats-before-guards.rs", -"ui/typeck/issue-61711-once-caused-rustc-inf-loop.rs", -"ui/typeck/issue-68590-reborrow-through-derefmut.rs", -"ui/typeck/issue-72225-call-fnmut-through-derefmut.rs", -"ui/typeck/issue-73592-borrow_mut-through-deref.rs", -"ui/typeck/issue-74933.rs", -"ui/typeck/issue-80207-unsized-return.rs", -"ui/typeck/issue-82772.rs", -"ui/typeck/issue-88803-call-expr-method.rs", -"ui/typeck/issue-89044-wrapped-expr-method.rs", -"ui/typeck/issue-89856.rs", -"ui/typeck/issue-89935.rs", -"ui/typeck/issue-90027-async-fn-return-suggestion.rs", -"ui/typeck/issue-90483-inaccessible-field-adjustment.rs", -"ui/typeck/issue-91210-ptr-method.rs", -"ui/typeck/issue-91328.rs", -"ui/typeck/issue-91334.rs", -"ui/typeck/issue-91633.rs", -"ui/typeck/issue-86721-return-expr-ice.rs", -"ui/typeof/issue-100183.rs", -"ui/typeof/issue-29184.rs", -"ui/typeof/issue-42060.rs", -"ui/unboxed-closures/issue-18652.rs", -"ui/unboxed-closures/issue-18661.rs", -"ui/unboxed-closures/issue-30906.rs", -"ui/unboxed-closures/issue-53448.rs", -"ui/underscore-imports/issue-110164.rs", -"ui/uniform-paths/auxiliary/issue-53691.rs", -"ui/uniform-paths/issue-53691.rs", -"ui/uninhabited/issue-107505.rs", -"ui/union/issue-41073.rs", -"ui/union/issue-81199.rs", -"ui/union/issue-99375.rs", -"ui/unsafe/auxiliary/issue-106126.rs", -"ui/unsafe/issue-106126-good-path-bug.rs", -"ui/unsafe/issue-3080.rs", -"ui/unsafe/issue-45087-unreachable-unsafe.rs", -"ui/unsafe/issue-45107-unnecessary-unsafe-in-closure.rs", -"ui/unsafe/issue-47412.rs", -"ui/unsafe/issue-85435-unsafe-op-in-let-under-unsafe-under-closure.rs", -"ui/unsafe/issue-87414-query-cycle.rs", -"ui/unsized-locals/issue-30276-feature-flagged.rs", -"ui/unsized-locals/issue-30276.rs", -"ui/unsized-locals/issue-50940-with-feature.rs", -"ui/unsized-locals/issue-50940.rs", -"ui/unsized-locals/issue-67981.rs", -"ui/unsized/issue-30355.rs", -"ui/unsized/issue-75707.rs", -"ui/unsized/issue-91801.rs", -"ui/unsized/issue-91803.rs", -"ui/unsized/issue-40231-1.rs", -"ui/unsized/issue-40231-2.rs", -"ui/unsized/issue-71659.rs", -"ui/unsized/issue-75899-but-gats.rs", -"ui/unsized/issue-75899.rs", -"ui/unsized/issue-97732.rs", -"ui/use/issue-18986.rs", -"ui/use/issue-60976-extern-use-primitive-type.rs", -"ui/wf/issue-103573.rs", -"ui/wf/issue-110157.rs", -"ui/wf/issue-87495.rs", -"ui/wf/issue-95665.rs", -"ui/wf/issue-96810.rs", -"ui/wf/issue-48638.rs", -"ui/where-clauses/issue-50825-1.rs", -"ui/where-clauses/issue-50825.rs", -"ui/issues-71798.rs", -"ui/issue-11881.rs", -"ui/issue-13560.rs", -"ui/issue-16822.rs", -"ui/issue-18502.rs", -"ui/issue-2804.rs", -"ui/higher-ranked/trait-bounds/issue-30786.rs", -"ui/higher-ranked/trait-bounds/issue-36139-normalize-closure-sig.rs", -"ui/higher-ranked/trait-bounds/issue-39292.rs", -"ui/higher-ranked/trait-bounds/issue-46989.rs", -"ui/higher-ranked/trait-bounds/issue-58451.rs", -"ui/higher-ranked/trait-bounds/issue-59311.rs", -"ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-44005.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-56556.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-2.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-4.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-5.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-70120.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-74261.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-76956.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80706.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80956.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-81809.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90612.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs", -"ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90875.rs", -"ui/higher-ranked/trait-bounds/issue-100689.rs", -"ui/higher-ranked/trait-bounds/issue-102899.rs", -"ui/higher-ranked/trait-bounds/issue-42114.rs", -"ui/higher-ranked/trait-bounds/issue-43623.rs", -"ui/higher-ranked/trait-bounds/issue-57639.rs", -"ui/higher-ranked/trait-bounds/issue-60283.rs", -"ui/higher-ranked/trait-bounds/issue-88446.rs", -"ui/higher-ranked/trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs", -"ui/higher-ranked/trait-bounds/issue-90177.rs", -"ui/higher-ranked/trait-bounds/issue-95034.rs", -"ui/higher-ranked/trait-bounds/issue-95230.rs", -"ui/issue-76387-llvm-miscompile.rs", -"ui/issue-15924.rs", -"ui/issue-24106.rs", -"ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs", -"ui-fulldeps/plugin/issue-40001.rs", -"ui-fulldeps/plugin/issue-15778-fail.rs", -] \ No newline at end of file diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index f9a90bf3a005..699559e4ba9c 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -3,9 +3,7 @@ //! - there are no stray `.stderr` files use ignore::Walk; -use lazy_static::lazy_static; -use regex::Regex; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::ffi::OsStr; use std::fs; use std::path::{Path, PathBuf}; @@ -90,12 +88,6 @@ fn check_entries(tests_path: &Path, bad: &mut bool) { pub fn check(path: &Path, bad: &mut bool) { check_entries(&path, bad); - - // the list of files in ui tests that are allowed to start with `issue-XXXX` - let mut allowed_issue_filenames: HashSet = HashSet::from( - include!("issues.txt").map(|path| path.replace("/", std::path::MAIN_SEPARATOR_STR)), - ); - let (ui, ui_fulldeps) = (path.join("ui"), path.join("ui-fulldeps")); let paths = [ui.as_path(), ui_fulldeps.as_path()]; crate::walk::walk_no_read(&paths, |_, _| false, &mut |entry| { @@ -108,11 +100,6 @@ pub fn check(path: &Path, bad: &mut bool) { { tidy_error!(bad, "file {} has unexpected extension {}", file_path.display(), ext); } - - // NB: We do not use file_stem() as some file names have multiple `.`s and we - // must strip all of them. - let testname = - file_path.file_name().unwrap().to_str().unwrap().split_once('.').unwrap().0; if ext == "stderr" || ext == "stdout" { // Test output filenames have one of the formats: // ``` @@ -124,7 +111,11 @@ pub fn check(path: &Path, bad: &mut bool) { // // For now, just make sure that there is a corresponding // `$testname.rs` file. - + // + // NB: We do not use file_stem() as some file names have multiple `.`s and we + // must strip all of them. + let testname = + file_path.file_name().unwrap().to_str().unwrap().split_once('.').unwrap().0; if !file_path.with_file_name(testname).with_extension("rs").exists() && !testname.contains("ignore-tidy") { @@ -137,38 +128,6 @@ pub fn check(path: &Path, bad: &mut bool) { } } } - - if ext == "rs" { - lazy_static! { - static ref ISSUE_NAME_REGEX: Regex = - Regex::new(r"^issues?[-_]?\d{3,}").unwrap(); - } - - if ISSUE_NAME_REGEX.is_match(testname) { - // these paths are always relative to the passed `path` and always UTF8 - let stripped_path = file_path.strip_prefix(path).unwrap().to_str().unwrap(); - if !allowed_issue_filenames.remove(stripped_path) { - tidy_error!( - bad, - "UI test `{}` should use a name that describes the test and link the issue in a comment instead.", - file_path.display(), - ); - } - } - } } }); - - // if an excluded file is renamed, it must be removed from this list - if allowed_issue_filenames.len() > 0 { - for file_name in allowed_issue_filenames { - let mut p = PathBuf::from(path); - p.push(file_name); - tidy_error!( - bad, - "file `{}` no longer exists and should be removed from the exclusions in `src/tools/tidy/src/issues.txt`", - p.display() - ); - } - } } From e6b423aebb7ef4b1f0b717243f435ac636aa79bc Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 27 Jul 2023 15:50:42 +0000 Subject: [PATCH 098/150] Remove `constness` from `ParamEnv` --- compiler/rustc_borrowck/src/type_check/mod.rs | 6 -- .../src/const_eval/eval_queries.rs | 2 - .../src/interpret/eval_context.rs | 1 - .../rustc_const_eval/src/interpret/operand.rs | 6 +- .../src/transform/check_consts/check.rs | 37 ++++---- .../check_consts/post_drop_elaboration.rs | 6 +- .../src/transform/check_consts/qualifs.rs | 3 +- .../src/check/compare_impl_item.rs | 14 +-- .../rustc_hir_analysis/src/check/dropck.rs | 5 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 8 +- compiler/rustc_hir_typeck/src/closure.rs | 2 +- compiler/rustc_hir_typeck/src/expr.rs | 4 +- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 5 -- compiler/rustc_hir_typeck/src/lib.rs | 12 +-- compiler/rustc_infer/src/traits/mod.rs | 9 -- .../rustc_middle/src/mir/interpret/queries.rs | 9 +- compiler/rustc_middle/src/ty/codec.rs | 4 +- compiler/rustc_middle/src/ty/mod.rs | 85 ++----------------- .../rustc_middle/src/ty/structural_impls.rs | 2 +- .../src/solve/trait_goals.rs | 13 ++- .../src/traits/auto_trait.rs | 2 - .../src/traits/error_reporting/mod.rs | 7 +- .../src/traits/error_reporting/suggestions.rs | 1 - .../rustc_trait_selection/src/traits/mod.rs | 19 +---- .../src/traits/object_safety.rs | 6 +- .../src/traits/query/evaluate_obligation.rs | 13 +-- .../traits/query/type_op/ascribe_user_type.rs | 1 - .../src/traits/select/candidate_assembly.rs | 3 +- .../src/traits/select/confirmation.rs | 20 ++--- .../src/traits/select/mod.rs | 60 ++----------- compiler/rustc_ty_utils/src/ty.rs | 78 +---------------- src/tools/clippy/clippy_lints/src/derive.rs | 3 +- .../clippy_lints/src/manual_float_methods.rs | 2 +- .../clippy_utils/src/qualify_min_const_fn.rs | 2 +- 34 files changed, 89 insertions(+), 361 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 78aa513033c9..fd4a3ec1a5e3 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -409,18 +409,12 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { } if let ty::FnDef(def_id, args) = *constant.literal.ty().kind() { - // const_trait_impl: use a non-const param env when checking that a FnDef type is well formed. - // this is because the well-formedness of the function does not need to be proved to have `const` - // impls for trait bounds. let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, args); - let prev = self.cx.param_env; - self.cx.param_env = prev.without_const(); self.cx.normalize_and_prove_instantiated_predicates( def_id, instantiated_predicates, locations, ); - self.cx.param_env = prev; } } } diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index c8e8a3711052..4c7e9194401a 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -228,7 +228,6 @@ pub fn eval_to_const_value_raw_provider<'tcx>( tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc_middle::mir::interpret::EvalToConstValueResult<'tcx> { - assert!(key.param_env.is_const()); // see comment in eval_to_allocation_raw_provider for what we're doing here if key.param_env.reveal() == Reveal::All { let mut key = key; @@ -269,7 +268,6 @@ pub fn eval_to_allocation_raw_provider<'tcx>( tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc_middle::mir::interpret::EvalToAllocationRawResult<'tcx> { - assert!(key.param_env.is_const()); // Because the constant is computed twice (once per value of `Reveal`), we are at risk of // reporting the same error twice here. To resolve this, we check whether we can evaluate the // constant in the more restrictive `Reveal::UserFacing`, which most likely already was diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index f014037f2781..3ac6f07e8b7b 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -958,7 +958,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } else { self.param_env }; - let param_env = param_env.with_const(); let val = self.ctfe_query(span, |tcx| tcx.eval_to_allocation_raw(param_env.and(gid)))?; self.raw_const_to_mplace(val) } diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index d1427b09632d..6e57a56b445a 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -698,10 +698,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ty::ConstKind::Unevaluated(uv) => { let instance = self.resolve(uv.def, uv.args)?; let cid = GlobalId { instance, promoted: None }; - self.ctfe_query(span, |tcx| { - tcx.eval_to_valtree(self.param_env.with_const().and(cid)) - })? - .unwrap_or_else(|| bug!("unable to create ValTree for {uv:?}")) + self.ctfe_query(span, |tcx| tcx.eval_to_valtree(self.param_env.and(cid)))? + .unwrap_or_else(|| bug!("unable to create ValTree for {uv:?}")) } ty::ConstKind::Bound(..) | ty::ConstKind::Infer(..) => { span_bug!(self.cur_span(), "unexpected ConstKind in ctfe: {val:?}") diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 15a7c0536cbb..ad5ffa6511f8 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -21,7 +21,7 @@ use std::mem; use std::ops::Deref; use super::ops::{self, NonConstOp, Status}; -use super::qualifs::{self, CustomEq, HasMutInterior, NeedsDrop, NeedsNonConstDrop}; +use super::qualifs::{self, CustomEq, HasMutInterior, NeedsDrop}; use super::resolver::FlowSensitiveAnalysis; use super::{ConstCx, Qualif}; use crate::const_eval::is_unstable_const_fn; @@ -34,7 +34,7 @@ type QualifResults<'mir, 'tcx, Q> = pub struct Qualifs<'mir, 'tcx> { has_mut_interior: Option>, needs_drop: Option>, - needs_non_const_drop: Option>, + // needs_non_const_drop: Option>, } impl<'mir, 'tcx> Qualifs<'mir, 'tcx> { @@ -77,15 +77,17 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> { local: Local, location: Location, ) -> bool { + // FIXME(effects) replace with `NeedsNonconstDrop` after const traits work again + /* let ty = ccx.body.local_decls[local].ty; - if !NeedsNonConstDrop::in_any_value_of_ty(ccx, ty) { + if !NeedsDrop::in_any_value_of_ty(ccx, ty) { return false; } let needs_non_const_drop = self.needs_non_const_drop.get_or_insert_with(|| { let ConstCx { tcx, body, .. } = *ccx; - FlowSensitiveAnalysis::new(NeedsNonConstDrop, ccx) + FlowSensitiveAnalysis::new(NeedsDrop, ccx) .into_engine(tcx, &body) .iterate_to_fixpoint() .into_results_cursor(&body) @@ -93,6 +95,9 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> { needs_non_const_drop.seek_before_primary_effect(location); needs_non_const_drop.get().contains(local) + */ + + self.needs_drop(ccx, local, location) } /// Returns `true` if `local` is `HasMutInterior` at the given `Location`. @@ -798,16 +803,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { } Ok(Some(ImplSource::UserDefined(data))) => { let callee_name = tcx.item_name(callee); - if let Some(&did) = tcx - .associated_item_def_ids(data.impl_def_id) - .iter() - .find(|did| tcx.item_name(**did) == callee_name) - { - // using internal args is ok here, since this is only - // used for the `resolve` call below - fn_args = GenericArgs::identity_for_item(tcx, did); - callee = did; - } if let hir::Constness::NotConst = tcx.constness(data.impl_def_id) { self.check_op(ops::FnCallNonConst { @@ -820,6 +815,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { }); return; } + + if let Some(&did) = tcx + .associated_item_def_ids(data.impl_def_id) + .iter() + .find(|did| tcx.item_name(**did) == callee_name) + { + // using internal args is ok here, since this is only + // used for the `resolve` call below + fn_args = GenericArgs::identity_for_item(tcx, did); + callee = did; + } } _ if !tcx.is_const_fn_raw(callee) => { // At this point, it is only legal when the caller is in a trait @@ -996,8 +1002,9 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { let mut err_span = self.span; let ty_of_dropped_place = dropped_place.ty(self.body, self.tcx).ty; + // FIXME(effects) replace with `NeedsNonConstDrop` once we fix const traits let ty_needs_non_const_drop = - qualifs::NeedsNonConstDrop::in_any_value_of_ty(self.ccx, ty_of_dropped_place); + qualifs::NeedsDrop::in_any_value_of_ty(self.ccx, ty_of_dropped_place); debug!(?ty_of_dropped_place, ?ty_needs_non_const_drop); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs index 1f1640fd80ae..e3377bd10c61 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs @@ -5,7 +5,7 @@ use rustc_span::{symbol::sym, Span}; use super::check::Qualifs; use super::ops::{self, NonConstOp}; -use super::qualifs::{NeedsNonConstDrop, Qualif}; +use super::qualifs::{NeedsDrop, Qualif}; use super::ConstCx; /// Returns `true` if we should use the more precise live drop checker that runs after drop @@ -82,7 +82,9 @@ impl<'tcx> Visitor<'tcx> for CheckLiveDrops<'_, 'tcx> { match &terminator.kind { mir::TerminatorKind::Drop { place: dropped_place, .. } => { let dropped_ty = dropped_place.ty(self.body, self.tcx).ty; - if !NeedsNonConstDrop::in_any_value_of_ty(self.ccx, dropped_ty) { + + // FIXME(effects) use `NeedsNonConstDrop` + if !NeedsDrop::in_any_value_of_ty(self.ccx, dropped_ty) { // Instead of throwing a bug, we just return here. This is because we have to // run custom `const Drop` impls. return; diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index b3730dd26487..b152644a551f 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -23,7 +23,8 @@ pub fn in_any_value_of_ty<'tcx>( ConstQualifs { has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty), needs_drop: NeedsDrop::in_any_value_of_ty(cx, ty), - needs_non_const_drop: NeedsNonConstDrop::in_any_value_of_ty(cx, ty), + // FIXME(effects) + needs_non_const_drop: NeedsDrop::in_any_value_of_ty(cx, ty), custom_eq: CustomEq::in_any_value_of_ty(cx, ty), tainted_by_errors, } diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 0a6e2e644eb2..919092ecb164 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -219,11 +219,7 @@ fn compare_method_predicate_entailment<'tcx>( // The key step here is to update the caller_bounds's predicates to be // the new hybrid bounds we computed. let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_def_id); - let param_env = ty::ParamEnv::new( - tcx.mk_clauses(&hybrid_preds.predicates), - Reveal::UserFacing, - hir::Constness::NotConst, - ); + let param_env = ty::ParamEnv::new(tcx.mk_clauses(&hybrid_preds.predicates), Reveal::UserFacing); let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause); let infcx = &tcx.infer_ctxt().build(); @@ -1923,11 +1919,7 @@ fn compare_type_predicate_entailment<'tcx>( let impl_ty_span = tcx.def_span(impl_ty_def_id); let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id); - let param_env = ty::ParamEnv::new( - tcx.mk_clauses(&hybrid_preds.predicates), - Reveal::UserFacing, - hir::Constness::NotConst, - ); + let param_env = ty::ParamEnv::new(tcx.mk_clauses(&hybrid_preds.predicates), Reveal::UserFacing); let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause); let infcx = tcx.infer_ctxt().build(); let ocx = ObligationCtxt::new(&infcx); @@ -2102,7 +2094,7 @@ pub(super) fn check_type_bounds<'tcx>( .to_predicate(tcx), ), }; - ty::ParamEnv::new(tcx.mk_clauses(&predicates), Reveal::UserFacing, param_env.constness()) + ty::ParamEnv::new(tcx.mk_clauses(&predicates), Reveal::UserFacing) }; debug!(?normalize_param_env); diff --git a/compiler/rustc_hir_analysis/src/check/dropck.rs b/compiler/rustc_hir_analysis/src/check/dropck.rs index 4ac3a7c23aef..dda3f7425697 100644 --- a/compiler/rustc_hir_analysis/src/check/dropck.rs +++ b/compiler/rustc_hir_analysis/src/check/dropck.rs @@ -129,9 +129,8 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( // We don't need to normalize this param-env or anything, since we're only // substituting it with free params, so no additional param-env normalization // can occur on top of what has been done in the param_env query itself. - let param_env = ty::EarlyBinder::bind(tcx.param_env(adt_def_id)) - .instantiate(tcx, adt_to_impl_args) - .with_constness(tcx.constness(drop_impl_def_id)); + let param_env = + ty::EarlyBinder::bind(tcx.param_env(adt_def_id)).instantiate(tcx, adt_to_impl_args); for (pred, span) in tcx.predicates_of(drop_impl_def_id).instantiate_identity(tcx) { let normalize_cause = traits::ObligationCause::misc(span, adt_def_id); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index cb41040cbaae..0e99df4f5813 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -75,12 +75,10 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { self.body_def_id, ObligationCauseCode::WellFormed(loc), ); - // for a type to be WF, we do not need to check if const trait predicates satisfy. - let param_env = self.param_env.without_const(); self.ocx.register_obligation(traits::Obligation::new( self.tcx(), cause, - param_env, + self.param_env, ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg))), )); } @@ -504,7 +502,7 @@ fn augment_param_env<'tcx>( ); // FIXME(compiler-errors): Perhaps there is a case where we need to normalize this // i.e. traits::normalize_param_env_or_error - ty::ParamEnv::new(bounds, param_env.reveal(), param_env.constness()) + ty::ParamEnv::new(bounds, param_env.reveal()) } /// We use the following trait as an example throughout this function. @@ -1415,7 +1413,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id let wf_obligations = predicates.into_iter().flat_map(|(p, sp)| { traits::wf::predicate_obligations( infcx, - wfcx.param_env.without_const(), + wfcx.param_env, wfcx.body_def_id, p.as_predicate(), sp, diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index affeee55e790..ca3b595d238e 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -81,7 +81,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!(?bound_sig, ?liberated_sig); - let mut fcx = FnCtxt::new(self, self.param_env.without_const(), closure.def_id); + let mut fcx = FnCtxt::new(self, self.param_env, closure.def_id); let generator_types = check_fn( &mut fcx, liberated_sig, diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 4ae8020fc42f..3f1f10f2f003 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -1334,7 +1334,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { t_cast, t.span, expr.span, - self.param_env.constness(), + hir::Constness::NotConst, ) { Ok(cast_check) => { debug!( @@ -1428,7 +1428,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Create a new function context. let def_id = block.def_id; - let fcx = FnCtxt::new(self, self.param_env.with_const(), def_id); + let fcx = FnCtxt::new(self, self.param_env, def_id); crate::GatherLocalsVisitor::new(&fcx).visit_body(body); let ty = fcx.check_expr_with_expectation(&body.value, expected); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 0311251f5c3a..e102c51c7eec 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -45,12 +45,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("FnCtxt::check_casts: {} deferred checks", deferred_cast_checks.len()); for cast in deferred_cast_checks.drain(..) { - let prev_env = self.param_env; - self.param_env = self.param_env.with_constness(cast.constness); - cast.check(self); - - self.param_env = prev_env; } *self.deferred_cast_checks.borrow_mut() = deferred_cast_checks; diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 28e7f2907378..864308267bba 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -71,7 +71,7 @@ use rustc_middle::traits; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::config; use rustc_span::def_id::{DefId, LocalDefId}; -use rustc_span::{sym, Span}; +use rustc_span::Span; fluent_messages! { "../messages.ftl" } @@ -182,11 +182,7 @@ fn typeck_with_fallback<'tcx>( let body = tcx.hir().body(body_id); let param_env = tcx.param_env(def_id); - let param_env = if tcx.has_attr(def_id, sym::rustc_do_not_const_check) { - param_env.without_const() - } else { - param_env - }; + let inh = Inherited::new(tcx, def_id); let mut fcx = FnCtxt::new(&inh, param_env, def_id); @@ -263,11 +259,7 @@ fn typeck_with_fallback<'tcx>( // Closure and generator analysis may run after fallback // because they don't constrain other type variables. - // Closure analysis only runs on closures. Therefore they only need to fulfill non-const predicates (as of now) - let prev_constness = fcx.param_env.constness(); - fcx.param_env = fcx.param_env.without_const(); fcx.closure_analyze(body); - fcx.param_env = fcx.param_env.with_constness(prev_constness); assert!(fcx.deferred_call_resolutions.borrow().is_empty()); // Before the generator analysis, temporary scopes shall be marked to provide more // precise information on types to be captured. diff --git a/compiler/rustc_infer/src/traits/mod.rs b/compiler/rustc_infer/src/traits/mod.rs index 626dd9359a19..a9da6104b383 100644 --- a/compiler/rustc_infer/src/traits/mod.rs +++ b/compiler/rustc_infer/src/traits/mod.rs @@ -79,7 +79,6 @@ impl<'tcx> PredicateObligation<'tcx> { } pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> PredicateObligation<'tcx> { - self.param_env = self.param_env.without_const(); if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) = self.predicate.kind().skip_binder() && trait_pred.is_const_if_const() { self.predicate = tcx.mk_predicate(self.predicate.kind().map_bound(|_| ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred.without_const())))); } @@ -88,14 +87,6 @@ impl<'tcx> PredicateObligation<'tcx> { } impl<'tcx> PolyTraitObligation<'tcx> { - /// Returns `true` if the trait predicate is considered `const` in its ParamEnv. - pub fn is_const(&self) -> bool { - matches!( - (self.predicate.skip_binder().constness, self.param_env.constness()), - (ty::BoundConstness::ConstIfConst, hir::Constness::Const) - ) - } - pub fn derived_cause( &self, variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>, diff --git a/compiler/rustc_middle/src/mir/interpret/queries.rs b/compiler/rustc_middle/src/mir/interpret/queries.rs index c9db0e7c11d2..fc659ce18a4d 100644 --- a/compiler/rustc_middle/src/mir/interpret/queries.rs +++ b/compiler/rustc_middle/src/mir/interpret/queries.rs @@ -139,7 +139,6 @@ impl<'tcx> TyCtxt<'tcx> { cid: GlobalId<'tcx>, span: Option, ) -> EvalToConstValueResult<'tcx> { - let param_env = param_env.with_const(); // Const-eval shouldn't depend on lifetimes at all, so we can erase them, which should // improve caching of queries. let inputs = self.erase_regions(param_env.and(cid)); @@ -158,8 +157,6 @@ impl<'tcx> TyCtxt<'tcx> { cid: GlobalId<'tcx>, span: Option, ) -> EvalToValTreeResult<'tcx> { - let param_env = param_env.with_const(); - debug!(?param_env); // Const-eval shouldn't depend on lifetimes at all, so we can erase them, which should // improve caching of queries. let inputs = self.erase_regions(param_env.and(cid)); @@ -204,7 +201,6 @@ impl<'tcx> TyCtxtAt<'tcx> { gid: GlobalId<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> Result, ErrorHandled> { - let param_env = param_env.with_const(); trace!("eval_to_allocation: Need to compute {:?}", gid); let raw_const = self.eval_to_allocation_raw(param_env.and(gid))?; Ok(self.global_alloc(raw_const.alloc_id).unwrap_memory()) @@ -224,8 +220,7 @@ impl<'tcx> TyCtxtEnsure<'tcx> { let args = GenericArgs::identity_for_item(self.tcx, def_id); let instance = ty::Instance::new(def_id, args); let cid = GlobalId { instance, promoted: None }; - let param_env = - self.tcx.param_env(def_id).with_reveal_all_normalized(self.tcx).with_const(); + let param_env = self.tcx.param_env(def_id).with_reveal_all_normalized(self.tcx); // Const-eval shouldn't depend on lifetimes at all, so we can erase them, which should // improve caching of queries. let inputs = self.tcx.erase_regions(param_env.and(cid)); @@ -238,7 +233,7 @@ impl<'tcx> TyCtxtEnsure<'tcx> { assert!(self.tcx.is_static(def_id)); let instance = ty::Instance::mono(self.tcx, def_id); let gid = GlobalId { instance, promoted: None }; - let param_env = ty::ParamEnv::reveal_all().with_const(); + let param_env = ty::ParamEnv::reveal_all(); trace!("eval_to_allocation: Need to compute {:?}", gid); self.eval_to_allocation_raw(param_env.and(gid)) } diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index b4f4f9bef8e8..7c05deae90a5 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -168,7 +168,6 @@ impl<'tcx, E: TyEncoder>> Encodable for ty::ParamEnv<'tcx> { fn encode(&self, e: &mut E) { self.caller_bounds().encode(e); self.reveal().encode(e); - self.constness().encode(e); } } @@ -306,8 +305,7 @@ impl<'tcx, D: TyDecoder>> Decodable for ty::ParamEnv<'tcx> { fn decode(d: &mut D) -> Self { let caller_bounds = Decodable::decode(d); let reveal = Decodable::decode(d); - let constness = Decodable::decode(d); - ty::ParamEnv::new(caller_bounds, reveal, constness) + ty::ParamEnv::new(caller_bounds, reveal) } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 0411890ab513..f9c0fbb23c35 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -867,20 +867,6 @@ pub struct TraitPredicate<'tcx> { pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>; impl<'tcx> TraitPredicate<'tcx> { - pub fn remap_constness(&mut self, param_env: &mut ParamEnv<'tcx>) { - *param_env = param_env.with_constness(self.constness.and(param_env.constness())) - } - - /// Remap the constness of this predicate before emitting it for diagnostics. - pub fn remap_constness_diag(&mut self, param_env: ParamEnv<'tcx>) { - // this is different to `remap_constness` that callees want to print this predicate - // in case of selection errors. `T: ~const Drop` bounds cannot end up here when the - // param_env is not const because it is always satisfied in non-const contexts. - if let hir::Constness::NotConst = param_env.constness() { - self.constness = ty::BoundConstness::NotConst; - } - } - pub fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self { Self { trait_ref: self.trait_ref.with_self_ty(tcx, self_ty), ..self } } @@ -922,14 +908,6 @@ impl<'tcx> PolyTraitPredicate<'tcx> { self.map_bound(|trait_ref| trait_ref.self_ty()) } - /// Remap the constness of this predicate before emitting it for diagnostics. - pub fn remap_constness_diag(&mut self, param_env: ParamEnv<'tcx>) { - *self = self.map_bound(|mut p| { - p.remap_constness_diag(param_env); - p - }); - } - #[inline] pub fn is_const_if_const(self) -> bool { self.skip_binder().is_const_if_const() @@ -1700,15 +1678,12 @@ pub struct ParamEnv<'tcx> { #[derive(Copy, Clone)] struct ParamTag { reveal: traits::Reveal, - constness: hir::Constness, } impl_tag! { impl Tag for ParamTag; - ParamTag { reveal: traits::Reveal::UserFacing, constness: hir::Constness::NotConst }, - ParamTag { reveal: traits::Reveal::All, constness: hir::Constness::NotConst }, - ParamTag { reveal: traits::Reveal::UserFacing, constness: hir::Constness::Const }, - ParamTag { reveal: traits::Reveal::All, constness: hir::Constness::Const }, + ParamTag { reveal: traits::Reveal::UserFacing }, + ParamTag { reveal: traits::Reveal::All }, } impl<'tcx> fmt::Debug for ParamEnv<'tcx> { @@ -1716,7 +1691,6 @@ impl<'tcx> fmt::Debug for ParamEnv<'tcx> { f.debug_struct("ParamEnv") .field("caller_bounds", &self.caller_bounds()) .field("reveal", &self.reveal()) - .field("constness", &self.constness()) .finish() } } @@ -1725,7 +1699,6 @@ impl<'a, 'tcx> HashStable> for ParamEnv<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { self.caller_bounds().hash_stable(hcx, hasher); self.reveal().hash_stable(hcx, hasher); - self.constness().hash_stable(hcx, hasher); } } @@ -1737,7 +1710,6 @@ impl<'tcx> TypeFoldable> for ParamEnv<'tcx> { Ok(ParamEnv::new( self.caller_bounds().try_fold_with(folder)?, self.reveal().try_fold_with(folder)?, - self.constness(), )) } } @@ -1756,7 +1728,7 @@ impl<'tcx> ParamEnv<'tcx> { /// type-checking. #[inline] pub fn empty() -> Self { - Self::new(List::empty(), Reveal::UserFacing, hir::Constness::NotConst) + Self::new(List::empty(), Reveal::UserFacing) } #[inline] @@ -1769,16 +1741,6 @@ impl<'tcx> ParamEnv<'tcx> { self.packed.tag().reveal } - #[inline] - pub fn constness(self) -> hir::Constness { - self.packed.tag().constness - } - - #[inline] - pub fn is_const(self) -> bool { - self.packed.tag().constness == hir::Constness::Const - } - /// Construct a trait environment with no where-clauses in scope /// where the values of all `impl Trait` and other hidden types /// are revealed. This is suitable for monomorphized, post-typeck @@ -1788,17 +1750,13 @@ impl<'tcx> ParamEnv<'tcx> { /// or invoke `param_env.with_reveal_all()`. #[inline] pub fn reveal_all() -> Self { - Self::new(List::empty(), Reveal::All, hir::Constness::NotConst) + Self::new(List::empty(), Reveal::All) } /// Construct a trait environment with the given set of predicates. #[inline] - pub fn new( - caller_bounds: &'tcx List>, - reveal: Reveal, - constness: hir::Constness, - ) -> Self { - ty::ParamEnv { packed: CopyTaggedPtr::new(caller_bounds, ParamTag { reveal, constness }) } + pub fn new(caller_bounds: &'tcx List>, reveal: Reveal) -> Self { + ty::ParamEnv { packed: CopyTaggedPtr::new(caller_bounds, ParamTag { reveal }) } } pub fn with_user_facing(mut self) -> Self { @@ -1806,29 +1764,6 @@ impl<'tcx> ParamEnv<'tcx> { self } - #[inline] - pub fn with_constness(mut self, constness: hir::Constness) -> Self { - self.packed.set_tag(ParamTag { constness, ..self.packed.tag() }); - self - } - - #[inline] - pub fn with_const(mut self) -> Self { - self.packed.set_tag(ParamTag { constness: hir::Constness::Const, ..self.packed.tag() }); - self - } - - #[inline] - pub fn without_const(mut self) -> Self { - self.packed.set_tag(ParamTag { constness: hir::Constness::NotConst, ..self.packed.tag() }); - self - } - - #[inline] - pub fn remap_constness_with(&mut self, mut constness: ty::BoundConstness) { - *self = self.with_constness(constness.and(self.constness())) - } - /// Returns a new parameter environment with the same clauses, but /// which "reveals" the true results of projections in all cases /// (even for associated types that are specializable). This is @@ -1843,17 +1778,13 @@ impl<'tcx> ParamEnv<'tcx> { return self; } - ParamEnv::new( - tcx.reveal_opaque_types_in_bounds(self.caller_bounds()), - Reveal::All, - self.constness(), - ) + ParamEnv::new(tcx.reveal_opaque_types_in_bounds(self.caller_bounds()), Reveal::All) } /// Returns this same environment but with no caller bounds. #[inline] pub fn without_caller_bounds(self) -> Self { - Self::new(List::empty(), self.reveal(), self.constness()) + Self::new(List::empty(), self.reveal()) } /// Creates a suitable environment in which to perform trait diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 9d380a58d9fa..50bf9afa531e 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -602,7 +602,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> { type Lifted = ty::ParamEnv<'tcx>; fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { tcx.lift(self.caller_bounds()) - .map(|caller_bounds| ty::ParamEnv::new(caller_bounds, self.reveal(), self.constness())) + .map(|caller_bounds| ty::ParamEnv::new(caller_bounds, self.reveal())) } } diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index 24ea9b5ea124..40ce4a3b3e40 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -449,14 +449,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> { return Err(NoSolution); } - if !goal.param_env.is_const() { - // `Destruct` is automatically implemented for every type in - // non-const environments. - ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) - } else { - // FIXME(-Ztrait-solver=next): Implement this when we get const working in the new solver - Err(NoSolution) - } + // FIXME(-Ztrait-solver=next): Implement this when we get const working in the new solver + + // `Destruct` is automatically implemented for every type in + // non-const environments. + ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } fn consider_builtin_transmute_candidate( diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 27cd0f99f34b..c26849d484e0 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -347,14 +347,12 @@ impl<'tcx> AutoTraitFinder<'tcx> { new_env = ty::ParamEnv::new( tcx.mk_clauses_from_iter(normalized_preds.filter_map(|p| p.as_clause())), param_env.reveal(), - param_env.constness(), ); } let final_user_env = ty::ParamEnv::new( tcx.mk_clauses_from_iter(user_computed_preds.into_iter().filter_map(|p| p.as_clause())), user_env.reveal(), - user_env.constness(), ); debug!( "evaluate_nested_obligations(ty={:?}, trait_did={:?}): succeeded with '{:?}' \ diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index c14839fe9be0..cbd81cae9890 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -687,9 +687,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { match bound_predicate.skip_binder() { ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_predicate)) => { let trait_predicate = bound_predicate.rebind(trait_predicate); - let mut trait_predicate = self.resolve_vars_if_possible(trait_predicate); + let trait_predicate = self.resolve_vars_if_possible(trait_predicate); - trait_predicate.remap_constness_diag(obligation.param_env); let predicate_is_const = ty::BoundConstness::ConstIfConst == trait_predicate.skip_binder().constness; @@ -3108,11 +3107,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { span: Span, ) -> UnsatisfiedConst { let mut unsatisfied_const = UnsatisfiedConst(false); - if trait_predicate.is_const_if_const() && obligation.param_env.is_const() { + if trait_predicate.is_const_if_const() { let non_const_predicate = trait_ref.without_const(); let non_const_obligation = Obligation { cause: obligation.cause.clone(), - param_env: obligation.param_env.without_const(), + param_env: obligation.param_env, predicate: non_const_predicate.to_predicate(self.tcx), recursion_depth: obligation.recursion_depth, }; diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 220b3576ddbd..ff7854d51d91 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -3136,7 +3136,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ObligationCauseCode::ImplDerivedObligation(ref data) => { let mut parent_trait_pred = self.resolve_vars_if_possible(data.derived.parent_trait_pred); - parent_trait_pred.remap_constness_diag(param_env); let parent_def_id = parent_trait_pred.def_id(); let (self_ty, file) = self.tcx.short_ty_string(parent_trait_pred.skip_binder().self_ty()); diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 6bab87e5de54..593f669e9bbb 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -328,11 +328,7 @@ pub fn normalize_param_env_or_error<'tcx>( debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates); - let elaborated_env = ty::ParamEnv::new( - tcx.mk_clauses(&predicates), - unnormalized_env.reveal(), - unnormalized_env.constness(), - ); + let elaborated_env = ty::ParamEnv::new(tcx.mk_clauses(&predicates), unnormalized_env.reveal()); // HACK: we are trying to normalize the param-env inside *itself*. The problem is that // normalization expects its param-env to be already normalized, which means we have @@ -376,11 +372,8 @@ pub fn normalize_param_env_or_error<'tcx>( // here. I believe they should not matter, because we are ignoring TypeOutlives param-env // predicates here anyway. Keeping them here anyway because it seems safer. let outlives_env = non_outlives_predicates.iter().chain(&outlives_predicates).cloned(); - let outlives_env = ty::ParamEnv::new( - tcx.mk_clauses_from_iter(outlives_env), - unnormalized_env.reveal(), - unnormalized_env.constness(), - ); + let outlives_env = + ty::ParamEnv::new(tcx.mk_clauses_from_iter(outlives_env), unnormalized_env.reveal()); let Ok(outlives_predicates) = do_normalize_predicates(tcx, cause, outlives_env, outlives_predicates) else { @@ -393,11 +386,7 @@ pub fn normalize_param_env_or_error<'tcx>( let mut predicates = non_outlives_predicates; predicates.extend(outlives_predicates); debug!("normalize_param_env_or_error: final predicates={:?}", predicates); - ty::ParamEnv::new( - tcx.mk_clauses(&predicates), - unnormalized_env.reveal(), - unnormalized_env.constness(), - ) + ty::ParamEnv::new(tcx.mk_clauses(&predicates), unnormalized_env.reveal()) } /// Normalize a type and process all resulting obligations, returning any errors. diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 143e8412967e..abb05be80e92 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -761,11 +761,7 @@ fn receiver_is_dispatchable<'tcx>( let caller_bounds = param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]); - ty::ParamEnv::new( - tcx.mk_clauses_from_iter(caller_bounds), - param_env.reveal(), - param_env.constness(), - ) + ty::ParamEnv::new(tcx.mk_clauses_from_iter(caller_bounds), param_env.reveal()) }; // Receiver: DispatchFromDyn U]> diff --git a/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs b/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs index a50644bb7092..65f32b1c48a4 100644 --- a/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs +++ b/compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs @@ -1,5 +1,4 @@ use rustc_infer::traits::{TraitEngine, TraitEngineExt}; -use rustc_middle::ty; use crate::infer::canonical::OriginalQueryValues; use crate::infer::InferCtxt; @@ -66,17 +65,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { ) -> Result { let mut _orig_values = OriginalQueryValues::default(); - let param_env = match obligation.predicate.kind().skip_binder() { - ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => { - // we ignore the value set to it. - let mut _constness = pred.constness; - obligation - .param_env - .with_constness(_constness.and(obligation.param_env.constness())) - } - // constness has no effect on the given predicate. - _ => obligation.param_env.without_const(), - }; + let param_env = obligation.param_env; if self.next_trait_solver() { self.probe(|snapshot| { diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs index 420d63265533..302b6016e5ea 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs @@ -82,7 +82,6 @@ fn relate_mir_and_user_args<'tcx>( def_id: DefId, user_args: UserArgs<'tcx>, ) -> Result<(), NoSolution> { - let param_env = param_env.without_const(); let UserArgs { user_self_ty, args } = user_args; let tcx = ocx.infcx.tcx; let cause = ObligationCause::dummy_with_span(span); diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index aa195d70a9f6..2aa8ee14c3cc 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -839,7 +839,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) { // If the predicate is `~const Destruct` in a non-const environment, we don't actually need // to check anything. We'll short-circuit checking any obligations in confirmation, too. - if !obligation.is_const() { + // FIXME(effects) + if true { candidates.vec.push(ConstDestructCandidate(None)); return; } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 92b9364adfa1..7140fedb74a3 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -13,8 +13,8 @@ use rustc_infer::infer::LateBoundRegionConversionTime::HigherRankedType; use rustc_infer::infer::{DefineOpaqueTypes, InferOk}; use rustc_middle::traits::{BuiltinImplSource, SelectionOutputTypeParameterMismatch}; use rustc_middle::ty::{ - self, Binder, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, ToPredicate, - TraitPredicate, TraitRef, Ty, TyCtxt, TypeVisitableExt, + self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, ToPredicate, + TraitPredicate, Ty, TyCtxt, TypeVisitableExt, }; use rustc_span::def_id::DefId; @@ -647,7 +647,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { fn confirm_fn_pointer_candidate( &mut self, obligation: &PolyTraitObligation<'tcx>, - is_const: bool, + // FIXME(effects) + _is_const: bool, ) -> Result>, SelectionError<'tcx>> { debug!(?obligation, "confirm_fn_pointer_candidate"); @@ -674,16 +675,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let mut nested = self.confirm_poly_trait_refs(obligation, trait_ref)?; let cause = obligation.derived_cause(BuiltinDerivedObligation); - if obligation.is_const() && !is_const { - // function is a trait method - if let ty::FnDef(def_id, args) = self_ty.kind() && let Some(trait_id) = tcx.trait_of_item(*def_id) { - let trait_ref = TraitRef::from_method(tcx, trait_id, *args); - let poly_trait_pred = Binder::dummy(trait_ref).with_constness(ty::BoundConstness::ConstIfConst); - let obligation = Obligation::new(tcx, cause.clone(), obligation.param_env, poly_trait_pred); - nested.push(obligation); - } - } - // Confirm the `type Output: Sized;` bound that is present on `FnOnce` let output_ty = self.infcx.instantiate_binder_with_placeholders(sig.output()); let output_ty = normalize_with_depth_to( @@ -1211,7 +1202,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { impl_def_id: Option, ) -> Result>, SelectionError<'tcx>> { // `~const Destruct` in a non-const environment is always trivially true, since our type is `Drop` - if !obligation.is_const() { + // FIXME(effects) + if true { return Ok(vec![]); } diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index e086489b1bcb..0e37e8da3930 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1000,13 +1000,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } let stack = self.push_stack(previous_stack, &obligation); - let mut fresh_trait_pred = stack.fresh_trait_pred; - let mut param_env = obligation.param_env; - - fresh_trait_pred = fresh_trait_pred.map_bound(|mut pred| { - pred.remap_constness(&mut param_env); - pred - }); + let fresh_trait_pred = stack.fresh_trait_pred; + let param_env = obligation.param_env; debug!(?fresh_trait_pred); @@ -1386,8 +1381,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { (result, dep_node) } - /// filter_impls filters constant trait obligations and candidates that have a positive impl - /// for a negative goal and a negative impl for a positive goal + /// filter_impls filters candidates that have a positive impl for a negative + /// goal and a negative impl for a positive goal #[instrument(level = "debug", skip(self, candidates))] fn filter_impls( &mut self, @@ -1399,42 +1394,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let mut result = Vec::with_capacity(candidates.len()); for candidate in candidates { - // Respect const trait obligations - if obligation.is_const() { - match candidate { - // const impl - ImplCandidate(def_id) if tcx.constness(def_id) == hir::Constness::Const => {} - // const param - ParamCandidate(trait_pred) if trait_pred.is_const_if_const() => {} - // const projection - ProjectionCandidate(_, ty::BoundConstness::ConstIfConst) - // auto trait impl - | AutoImplCandidate - // generator / future, this will raise error in other places - // or ignore error with const_async_blocks feature - | GeneratorCandidate - | FutureCandidate - // FnDef where the function is const - | FnPointerCandidate { is_const: true } - | ConstDestructCandidate(_) - | ClosureCandidate { is_const: true } => {} - - FnPointerCandidate { is_const: false } => { - if let ty::FnDef(def_id, _) = obligation.self_ty().skip_binder().kind() && tcx.trait_of_item(*def_id).is_some() { - // Trait methods are not seen as const unless the trait is implemented as const. - // We do not filter that out in here, but nested obligations will be needed to confirm this. - } else { - continue - } - } - - _ => { - // reject all other types of candidates - continue; - } - } - } - if let ImplCandidate(def_id) = candidate { if ty::ImplPolarity::Reservation == tcx.impl_polarity(def_id) || obligation.polarity() == tcx.impl_polarity(def_id) @@ -1528,7 +1487,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { fn check_candidate_cache( &mut self, - mut param_env: ty::ParamEnv<'tcx>, + param_env: ty::ParamEnv<'tcx>, cache_fresh_trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> Option>> { // Neither the global nor local cache is aware of intercrate @@ -1539,8 +1498,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { return None; } let tcx = self.tcx(); - let mut pred = cache_fresh_trait_pred.skip_binder(); - pred.remap_constness(&mut param_env); + let pred = cache_fresh_trait_pred.skip_binder(); if self.can_use_global_caches(param_env) { if let Some(res) = tcx.selection_cache.get(&(param_env, pred), tcx) { @@ -1586,15 +1544,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { #[instrument(skip(self, param_env, cache_fresh_trait_pred, dep_node), level = "debug")] fn insert_candidate_cache( &mut self, - mut param_env: ty::ParamEnv<'tcx>, + param_env: ty::ParamEnv<'tcx>, cache_fresh_trait_pred: ty::PolyTraitPredicate<'tcx>, dep_node: DepNodeIndex, candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>, ) { let tcx = self.tcx(); - let mut pred = cache_fresh_trait_pred.skip_binder(); - - pred.remap_constness(&mut param_env); + let pred = cache_fresh_trait_pred.skip_binder(); if !self.can_cache_candidate(&candidate) { debug!(?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable"); diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 505f78d0e5fe..2055852eda07 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -144,85 +144,9 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { } let local_did = def_id.as_local(); - // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): This isn't correct for - // RPITITs in const trait fn. - let hir_id = local_did.and_then(|def_id| tcx.opt_local_def_id_to_hir_id(def_id)); - - // FIXME(consts): This is not exactly in line with the constness query. - let constness = match hir_id { - Some(hir_id) => match tcx.hir().get(hir_id) { - hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. }) - if tcx.is_const_default_method(def_id) => - { - hir::Constness::Const - } - - hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(..), .. }) - | hir::Node::Item(hir::Item { kind: hir::ItemKind::Static(..), .. }) - | hir::Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Const(..), .. - }) - | hir::Node::AnonConst(_) - | hir::Node::ConstBlock(_) - | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. }) - | hir::Node::ImplItem(hir::ImplItem { - kind: - hir::ImplItemKind::Fn( - hir::FnSig { - header: hir::FnHeader { constness: hir::Constness::Const, .. }, - .. - }, - .., - ), - .. - }) => hir::Constness::Const, - - hir::Node::ImplItem(hir::ImplItem { - kind: hir::ImplItemKind::Type(..) | hir::ImplItemKind::Fn(..), - .. - }) => { - let parent_hir_id = tcx.hir().parent_id(hir_id); - match tcx.hir().get(parent_hir_id) { - hir::Node::Item(hir::Item { - kind: hir::ItemKind::Impl(hir::Impl { constness, .. }), - .. - }) => *constness, - _ => span_bug!( - tcx.def_span(parent_hir_id.owner), - "impl item's parent node is not an impl", - ), - } - } - - hir::Node::Item(hir::Item { - kind: - hir::ItemKind::Fn(hir::FnSig { header: hir::FnHeader { constness, .. }, .. }, ..), - .. - }) - | hir::Node::TraitItem(hir::TraitItem { - kind: - hir::TraitItemKind::Fn( - hir::FnSig { header: hir::FnHeader { constness, .. }, .. }, - .., - ), - .. - }) - | hir::Node::Item(hir::Item { - kind: hir::ItemKind::Impl(hir::Impl { constness, .. }), - .. - }) => *constness, - - _ => hir::Constness::NotConst, - }, - // FIXME(consts): It's suspicious that a param-env for a foreign item - // will always have NotConst param-env, though we don't typically use - // that param-env for anything meaningful right now, so it's likely - // not an issue. - None => hir::Constness::NotConst, - }; let unnormalized_env = - ty::ParamEnv::new(tcx.mk_clauses(&predicates), traits::Reveal::UserFacing, constness); + ty::ParamEnv::new(tcx.mk_clauses(&predicates), traits::Reveal::UserFacing); let body_id = local_did.unwrap_or(CRATE_DEF_ID); let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id); diff --git a/src/tools/clippy/clippy_lints/src/derive.rs b/src/tools/clippy/clippy_lints/src/derive.rs index c343f248d06d..91bc30ab5774 100644 --- a/src/tools/clippy/clippy_lints/src/derive.rs +++ b/src/tools/clippy/clippy_lints/src/derive.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, Visitor}; use rustc_hir::{ - self as hir, BlockCheckMode, BodyId, Constness, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, UnsafeSource, + self as hir, BlockCheckMode, BodyId, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, UnsafeSource, Unsafety, }; use rustc_lint::{LateContext, LateLintPass}; @@ -526,6 +526,5 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) -> }), )), Reveal::UserFacing, - Constness::NotConst, ) } diff --git a/src/tools/clippy/clippy_lints/src/manual_float_methods.rs b/src/tools/clippy/clippy_lints/src/manual_float_methods.rs index 085c73a5f9fb..ccd2f06aad27 100644 --- a/src/tools/clippy/clippy_lints/src/manual_float_methods.rs +++ b/src/tools/clippy/clippy_lints/src/manual_float_methods.rs @@ -83,7 +83,7 @@ impl Variant { impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { if !in_external_macro(cx.sess(), expr.span) - && (!cx.param_env.is_const() || cx.tcx.features().active(sym!(const_float_classify))) + && cx.tcx.features().active(sym!(const_float_classify)) && let ExprKind::Binary(kind, lhs, rhs) = expr.kind && let ExprKind::Binary(lhs_kind, lhs_lhs, lhs_rhs) = lhs.kind && let ExprKind::Binary(rhs_kind, rhs_lhs, rhs_rhs) = rhs.kind diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index e563e41ab2aa..aed3d601bcac 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -399,7 +399,7 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx> let obligation = Obligation::new( tcx, ObligationCause::dummy_with_span(body.span), - ConstCx::new(tcx, body).param_env.with_const(), + ConstCx::new(tcx, body).param_env, TraitRef::from_lang_item(tcx, LangItem::Destruct, body.span, [ty]).with_constness(BoundConstness::ConstIfConst), ); From 2d594512741ae8725a8e67e289365746511fa96d Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 27 Jul 2023 15:51:02 +0000 Subject: [PATCH 099/150] update tests, adding known-bug --- tests/ui/const-generics/issue-93647.rs | 1 - tests/ui/const-generics/issue-93647.stderr | 19 +----- tests/ui/consts/const-block-const-bound.rs | 4 +- .../ui/consts/const-block-const-bound.stderr | 20 +++--- tests/ui/consts/const_cmp_type_id.stderr | 44 +------------ .../invalid-inline-const-in-match-arm.rs | 1 - .../invalid-inline-const-in-match-arm.stderr | 19 +----- tests/ui/consts/issue-28113.rs | 1 - tests/ui/consts/issue-28113.stderr | 19 +----- tests/ui/consts/issue-56164.rs | 1 - tests/ui/consts/issue-56164.stderr | 21 +------ .../issue-68542-closure-in-array-len.rs | 1 - .../issue-68542-closure-in-array-len.stderr | 19 +----- .../ui/consts/issue-73976-monomorphic.stderr | 18 +----- tests/ui/consts/issue-94675.rs | 8 ++- tests/ui/consts/issue-94675.stderr | 22 ++----- tests/ui/consts/precise-drop-with-promoted.rs | 8 ++- .../consts/precise-drop-with-promoted.stderr | 6 ++ tests/ui/consts/promoted_const_call.rs | 14 +++-- tests/ui/consts/promoted_const_call.stderr | 25 +++++--- .../ui/impl-trait/normalize-tait-in-const.rs | 5 -- .../impl-trait/normalize-tait-in-const.stderr | 14 +++-- .../call-const-trait-method-fail.rs | 2 +- .../call-const-trait-method-fail.stderr | 12 ++-- .../call-generic-method-fail.stderr | 17 +---- .../call-generic-method-nonconst.rs | 5 +- .../call-generic-method-nonconst.stderr | 15 ----- .../const-closure-trait-method-fail.stderr | 19 +++--- .../const-default-method-bodies.rs | 2 +- .../const-default-method-bodies.stderr | 12 ++-- .../const-drop-bound.rs | 3 +- .../const-drop-bound.stderr | 9 +++ .../const-drop-fail-2.stderr | 55 +++------------- .../const-drop-fail.precise.stderr | 61 ++---------------- .../const-drop-fail.stock.stderr | 63 +++---------------- .../const-drop.precise.stderr | 19 ++++++ .../rfc-2632-const-trait-impl/const-drop.rs | 7 ++- .../const-drop.stock.stderr | 19 ++++++ .../cross-crate.gatednc.stderr | 12 ++-- .../rfc-2632-const-trait-impl/cross-crate.rs | 5 +- .../cross-crate.stocknc.stderr | 22 ++++--- ...ault-method-body-is-const-body-checking.rs | 5 +- ...-method-body-is-const-body-checking.stderr | 15 ----- ...ault-method-body-is-const-same-trait-ck.rs | 3 +- ...-method-body-is-const-same-trait-ck.stderr | 14 ++--- .../rfc-2632-const-trait-impl/issue-102985.rs | 7 ++- .../issue-102985.stderr | 36 +---------- .../rfc-2632-const-trait-impl/issue-88155.rs | 6 +- .../issue-88155.stderr | 19 +----- .../rfc-2632-const-trait-impl/issue-92111.rs | 3 +- .../issue-92111.stderr | 11 ++++ .../match-non-const-eq.gated.stderr | 22 ++----- .../match-non-const-eq.rs | 5 +- .../match-non-const-eq.stock.stderr | 4 +- ...fault-bound-non-const-specialized-bound.rs | 5 +- ...t-bound-non-const-specialized-bound.stderr | 18 +++--- .../specializing-constness-2.rs | 4 +- .../specializing-constness-2.stderr | 18 ++---- .../super-traits-fail-2.rs | 8 +-- .../super-traits-fail-2.yn.stderr | 16 ++--- .../super-traits-fail-2.yy.stderr | 16 ++--- .../super-traits-fail.rs | 5 +- .../super-traits-fail.stderr | 20 ------ .../trait-where-clause-const.rs | 6 +- .../trait-where-clause-const.stderr | 35 ----------- 65 files changed, 289 insertions(+), 661 deletions(-) create mode 100644 tests/ui/consts/precise-drop-with-promoted.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr diff --git a/tests/ui/const-generics/issue-93647.rs b/tests/ui/const-generics/issue-93647.rs index a0083a0c6291..806540e1775e 100644 --- a/tests/ui/const-generics/issue-93647.rs +++ b/tests/ui/const-generics/issue-93647.rs @@ -1,7 +1,6 @@ struct X; fn main() {} diff --git a/tests/ui/const-generics/issue-93647.stderr b/tests/ui/const-generics/issue-93647.stderr index 20a6af5c5494..18370eea5714 100644 --- a/tests/ui/const-generics/issue-93647.stderr +++ b/tests/ui/const-generics/issue-93647.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-93647.rs:2:6: 2:8]: Fn<()>` is not satisfied - --> $DIR/issue-93647.rs:2:5 - | -LL | (||1usize)() - | ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-93647.rs:2:6: 2:8]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-93647.rs:2:6: 2:8]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-93647.rs:2:6: 2:8]`, but that implementation is not `const` - --> $DIR/issue-93647.rs:2:5 - | -LL | (||1usize)() - | ^^^^^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-93647.rs:2:6: 2:8]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/issue-93647.rs:2:5 | @@ -22,7 +8,6 @@ LL | (||1usize)() = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-block-const-bound.rs b/tests/ui/consts/const-block-const-bound.rs index 3704a1a5a392..123e5cb1b3e6 100644 --- a/tests/ui/consts/const-block-const-bound.rs +++ b/tests/ui/consts/const-block-const-bound.rs @@ -1,3 +1,5 @@ +// known-bug: #103507 + #![allow(unused)] #![feature(const_trait_impl, inline_const, negative_impls)] @@ -14,6 +16,6 @@ impl Drop for UnconstDrop { fn main() { const { f(UnconstDrop); - //~^ ERROR can't drop + //FIXME ~^ ERROR can't drop } } diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index caf24e7afcf4..b402f0ea9154 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -1,17 +1,11 @@ -error[E0277]: can't drop `UnconstDrop` in const contexts - --> $DIR/const-block-const-bound.rs:16:9 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-block-const-bound.rs:8:32 | -LL | f(UnconstDrop); - | ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` - | - = note: the trait bound `UnconstDrop: ~const Destruct` is not satisfied -help: consider borrowing here - | -LL | &f(UnconstDrop); - | + -LL | &mut f(UnconstDrop); - | ++++ +LL | const fn f(x: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/const_cmp_type_id.stderr b/tests/ui/consts/const_cmp_type_id.stderr index dc2c702d885a..0d915cec07de 100644 --- a/tests/ui/consts/const_cmp_type_id.stderr +++ b/tests/ui/consts/const_cmp_type_id.stderr @@ -1,16 +1,3 @@ -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/const_cmp_type_id.rs:8:13 - | -LL | assert!(TypeId::of::() == TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` - | - = help: the trait `~const PartialEq` is not implemented for `TypeId` -note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/const_cmp_type_id.rs:8:13 - | -LL | assert!(TypeId::of::() == TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions --> $DIR/const_cmp_type_id.rs:8:13 | @@ -21,19 +8,6 @@ note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/any.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/const_cmp_type_id.rs:9:13 - | -LL | assert!(TypeId::of::<()>() != TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` - | - = help: the trait `~const PartialEq` is not implemented for `TypeId` -note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/const_cmp_type_id.rs:9:13 - | -LL | assert!(TypeId::of::<()>() != TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions --> $DIR/const_cmp_type_id.rs:9:13 | @@ -44,19 +18,6 @@ note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/any.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/const_cmp_type_id.rs:10:22 - | -LL | const _A: bool = TypeId::of::() < TypeId::of::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId < TypeId` and `TypeId > TypeId` - | - = help: the trait `~const PartialOrd` is not implemented for `TypeId` -note: the trait `PartialOrd` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/const_cmp_type_id.rs:10:22 - | -LL | const _A: bool = TypeId::of::() < TypeId::of::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constants --> $DIR/const_cmp_type_id.rs:10:22 | @@ -68,7 +29,6 @@ note: impl defined here, but it is not `const` = note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/invalid-inline-const-in-match-arm.rs b/tests/ui/consts/invalid-inline-const-in-match-arm.rs index 17acb2d9d17d..4d2d8fb1303c 100644 --- a/tests/ui/consts/invalid-inline-const-in-match-arm.rs +++ b/tests/ui/consts/invalid-inline-const-in-match-arm.rs @@ -5,6 +5,5 @@ fn main() { match () { const { (|| {})() } => {} //~^ ERROR cannot call non-const closure in constants - //~| ERROR the trait bound } } diff --git a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr index ac174849f06a..257ecd7f3cf7 100644 --- a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr +++ b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]: Fn<()>` is not satisfied - --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 - | -LL | const { (|| {})() } => {} - | ^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]`, but that implementation is not `const` - --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 - | -LL | const { (|| {})() } => {} - | ^^^^^^^^^ - = note: wrap the `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 | @@ -22,7 +8,6 @@ LL | const { (|| {})() } => {} = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-28113.rs b/tests/ui/consts/issue-28113.rs index e45c009d69f2..f8131c9f3b71 100644 --- a/tests/ui/consts/issue-28113.rs +++ b/tests/ui/consts/issue-28113.rs @@ -3,7 +3,6 @@ const X: u8 = || -> u8 { 5 }() //~^ ERROR cannot call non-const closure - //~| ERROR the trait bound ; fn main() {} diff --git a/tests/ui/consts/issue-28113.stderr b/tests/ui/consts/issue-28113.stderr index e177a3585c46..1294cc99bf73 100644 --- a/tests/ui/consts/issue-28113.stderr +++ b/tests/ui/consts/issue-28113.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-28113.rs:4:5: 4:13]: Fn<()>` is not satisfied - --> $DIR/issue-28113.rs:4:5 - | -LL | || -> u8 { 5 }() - | ^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-28113.rs:4:5: 4:13]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-28113.rs:4:5: 4:13]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-28113.rs:4:5: 4:13]`, but that implementation is not `const` - --> $DIR/issue-28113.rs:4:5 - | -LL | || -> u8 { 5 }() - | ^^^^^^^^^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-28113.rs:4:5: 4:13]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/issue-28113.rs:4:5 | @@ -22,7 +8,6 @@ LL | || -> u8 { 5 }() = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-56164.rs b/tests/ui/consts/issue-56164.rs index 00875c4b5823..22c257d0b08a 100644 --- a/tests/ui/consts/issue-56164.rs +++ b/tests/ui/consts/issue-56164.rs @@ -1,6 +1,5 @@ const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure -//~| ERROR the trait bound const fn bad(input: fn()) { input() diff --git a/tests/ui/consts/issue-56164.stderr b/tests/ui/consts/issue-56164.stderr index e46c649faf08..1b267214a022 100644 --- a/tests/ui/consts/issue-56164.stderr +++ b/tests/ui/consts/issue-56164.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-56164.rs:1:19: 1:21]: Fn<()>` is not satisfied - --> $DIR/issue-56164.rs:1:18 - | -LL | const fn foo() { (||{})() } - | ^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-56164.rs:1:19: 1:21]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-56164.rs:1:19: 1:21]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-56164.rs:1:19: 1:21]`, but that implementation is not `const` - --> $DIR/issue-56164.rs:1:18 - | -LL | const fn foo() { (||{})() } - | ^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-56164.rs:1:19: 1:21]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constant functions --> $DIR/issue-56164.rs:1:18 | @@ -23,12 +9,11 @@ LL | const fn foo() { (||{})() } = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable error: function pointer calls are not allowed in constant functions - --> $DIR/issue-56164.rs:6:5 + --> $DIR/issue-56164.rs:5:5 | LL | input() | ^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-68542-closure-in-array-len.rs b/tests/ui/consts/issue-68542-closure-in-array-len.rs index a88e0cc6017d..37958e7919d6 100644 --- a/tests/ui/consts/issue-68542-closure-in-array-len.rs +++ b/tests/ui/consts/issue-68542-closure-in-array-len.rs @@ -4,7 +4,6 @@ struct Bug { a: [(); (|| { 0 })()] //~ ERROR cannot call non-const closure - //~^ ERROR the trait bound } fn main() {} diff --git a/tests/ui/consts/issue-68542-closure-in-array-len.stderr b/tests/ui/consts/issue-68542-closure-in-array-len.stderr index ace62f09d050..d23513ed7ffb 100644 --- a/tests/ui/consts/issue-68542-closure-in-array-len.stderr +++ b/tests/ui/consts/issue-68542-closure-in-array-len.stderr @@ -1,17 +1,3 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]: Fn<()>` is not satisfied - --> $DIR/issue-68542-closure-in-array-len.rs:6:13 - | -LL | a: [(); (|| { 0 })()] - | ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]`, but that implementation is not `const` - --> $DIR/issue-68542-closure-in-array-len.rs:6:13 - | -LL | a: [(); (|| { 0 })()] - | ^^^^^^^^^^^^ - = note: wrap the `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants --> $DIR/issue-68542-closure-in-array-len.rs:6:13 | @@ -22,7 +8,6 @@ LL | a: [(); (|| { 0 })()] = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-73976-monomorphic.stderr b/tests/ui/consts/issue-73976-monomorphic.stderr index 09661d3f3440..b23796db4f11 100644 --- a/tests/ui/consts/issue-73976-monomorphic.stderr +++ b/tests/ui/consts/issue-73976-monomorphic.stderr @@ -1,16 +1,3 @@ -error[E0277]: can't compare `TypeId` with `TypeId` in const contexts - --> $DIR/issue-73976-monomorphic.rs:21:5 - | -LL | GetTypeId::::VALUE == GetTypeId::::VALUE - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` - | - = help: the trait `~const PartialEq` is not implemented for `TypeId` -note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` - --> $DIR/issue-73976-monomorphic.rs:21:5 - | -LL | GetTypeId::::VALUE == GetTypeId::::VALUE - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions --> $DIR/issue-73976-monomorphic.rs:21:5 | @@ -21,7 +8,6 @@ note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/any.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-94675.rs b/tests/ui/consts/issue-94675.rs index 38c8129b8cfd..2358175fe928 100644 --- a/tests/ui/consts/issue-94675.rs +++ b/tests/ui/consts/issue-94675.rs @@ -1,3 +1,5 @@ +// known-bug: #103507 + #![feature(const_trait_impl, const_mut_refs)] struct Foo<'a> { @@ -7,9 +9,9 @@ struct Foo<'a> { impl<'a> Foo<'a> { const fn spam(&mut self, baz: &mut Vec) { self.bar[0] = baz.len(); - //~^ ERROR: cannot call - //~| ERROR: cannot call - //~| ERROR: the trait bound + //FIXME ~^ ERROR: cannot call + //FIXME ~| ERROR: cannot call + //FIXME ~| ERROR: the trait bound } } diff --git a/tests/ui/consts/issue-94675.stderr b/tests/ui/consts/issue-94675.stderr index b4e5db44e710..cee4dfda2c99 100644 --- a/tests/ui/consts/issue-94675.stderr +++ b/tests/ui/consts/issue-94675.stderr @@ -1,26 +1,13 @@ error[E0015]: cannot call non-const fn `Vec::::len` in constant functions - --> $DIR/issue-94675.rs:9:27 + --> $DIR/issue-94675.rs:11:27 | LL | self.bar[0] = baz.len(); | ^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0277]: the trait bound `Vec: ~const IndexMut` is not satisfied - --> $DIR/issue-94675.rs:9:9 - | -LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` - | - = help: the trait `~const IndexMut` is not implemented for `Vec` -note: the trait `IndexMut` is implemented for `Vec`, but that implementation is not `const` - --> $DIR/issue-94675.rs:9:9 - | -LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-94675.rs:9:9 + --> $DIR/issue-94675.rs:11:9 | LL | self.bar[0] = baz.len(); | ^^^^^^^^^^^ @@ -29,7 +16,6 @@ note: impl defined here, but it is not `const` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/precise-drop-with-promoted.rs b/tests/ui/consts/precise-drop-with-promoted.rs index 6f2317a5a27a..5da325afb72b 100644 --- a/tests/ui/consts/precise-drop-with-promoted.rs +++ b/tests/ui/consts/precise-drop-with-promoted.rs @@ -1,6 +1,12 @@ // Regression test for issue #89938. -// check-pass // compile-flags: --crate-type=lib +// known-bug: #103507 +// failure-status: 101 +// normalize-stderr-test "note: .*\n\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +// rustc-env:RUST_BACKTRACE=0 + #![feature(const_precise_live_drops)] pub const fn f() { diff --git a/tests/ui/consts/precise-drop-with-promoted.stderr b/tests/ui/consts/precise-drop-with-promoted.stderr new file mode 100644 index 000000000000..a56672048eb7 --- /dev/null +++ b/tests/ui/consts/precise-drop-with-promoted.stderr @@ -0,0 +1,6 @@ +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `f` +#1 [analysis] running analysis passes on this crate +end of query stack diff --git a/tests/ui/consts/promoted_const_call.rs b/tests/ui/consts/promoted_const_call.rs index dae6cafaebb3..d6e48266fd30 100644 --- a/tests/ui/consts/promoted_const_call.rs +++ b/tests/ui/consts/promoted_const_call.rs @@ -1,3 +1,5 @@ +// known-bug: #103507 + #![feature(const_mut_refs)] #![feature(const_trait_impl)] @@ -7,15 +9,15 @@ impl const Drop for Panic { fn drop(&mut self) { panic!(); } } pub const fn id(x: T) -> T { x } pub const C: () = { let _: &'static _ = &id(&Panic); - //~^ ERROR: temporary value dropped while borrowed - //~| ERROR: temporary value dropped while borrowed + //FIXME ~^ ERROR: temporary value dropped while borrowed + //FIXME ~| ERROR: temporary value dropped while borrowed }; fn main() { let _: &'static _ = &id(&Panic); - //~^ ERROR: temporary value dropped while borrowed - //~| ERROR: temporary value dropped while borrowed + //FIXME ~^ ERROR: temporary value dropped while borrowed + //FIXME ~| ERROR: temporary value dropped while borrowed let _: &'static _ = &&(Panic, 0).1; - //~^ ERROR: temporary value dropped while borrowed - //~| ERROR: temporary value dropped while borrowed + //FIXME~^ ERROR: temporary value dropped while borrowed + //FIXME~| ERROR: temporary value dropped while borrowed } diff --git a/tests/ui/consts/promoted_const_call.stderr b/tests/ui/consts/promoted_const_call.stderr index 1cbd8cbe6999..1f6abc0ce7c8 100644 --- a/tests/ui/consts/promoted_const_call.stderr +++ b/tests/ui/consts/promoted_const_call.stderr @@ -1,5 +1,13 @@ +error[E0493]: destructor of `Panic` cannot be evaluated at compile-time + --> $DIR/promoted_const_call.rs:11:30 + | +LL | let _: &'static _ = &id(&Panic); + | ^^^^^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:9:26 + --> $DIR/promoted_const_call.rs:11:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -10,7 +18,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:9:30 + --> $DIR/promoted_const_call.rs:11:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -19,7 +27,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:15:26 + --> $DIR/promoted_const_call.rs:17:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -30,7 +38,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:15:30 + --> $DIR/promoted_const_call.rs:17:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -39,7 +47,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:18:26 + --> $DIR/promoted_const_call.rs:20:26 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -50,7 +58,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:18:27 + --> $DIR/promoted_const_call.rs:20:27 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -60,6 +68,7 @@ LL | let _: &'static _ = &&(Panic, 0).1; LL | } | - temporary value is freed at the end of this statement -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0716`. +Some errors have detailed explanations: E0493, E0716. +For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/impl-trait/normalize-tait-in-const.rs b/tests/ui/impl-trait/normalize-tait-in-const.rs index d2e34c00b642..dd03fd3f754d 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.rs +++ b/tests/ui/impl-trait/normalize-tait-in-const.rs @@ -1,9 +1,4 @@ // known-bug: #103507 -// failure-status: 101 -// normalize-stderr-test "note: .*\n\n" -> "" -// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" -// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -// rustc-env:RUST_BACKTRACE=0 #![feature(type_alias_impl_trait)] #![feature(const_trait_impl)] diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 84b00918724e..06247e2ea1e1 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -1,8 +1,12 @@ -error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:LL:CC: Failed to normalize fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead +error[E0493]: destructor of `F` cannot be evaluated at compile-time + --> $DIR/normalize-tait-in-const.rs:25:79 + | +LL | const fn with_positive Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { + | ^^^ the destructor for this type cannot be evaluated in constant functions +LL | fun(filter_positive()); +LL | } + | - value is dropped here -query stack during panic: -#0 [eval_to_allocation_raw] const-evaluating + checking `BAR` -#1 [eval_to_const_value_raw] simplifying constant for the type system `BAR` -end of query stack error: aborting due to previous error +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs index dd9933974207..646955fd867f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs @@ -23,7 +23,7 @@ pub const fn add_i32(a: i32, b: i32) -> i32 { pub const fn add_u32(a: u32, b: u32) -> u32 { a.plus(b) - //~^ ERROR the trait bound + //~^ ERROR cannot call } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr index 7350909ba8e1..0ee1b1a5cb25 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr @@ -1,15 +1,11 @@ -error[E0277]: the trait bound `u32: ~const Plus` is not satisfied +error[E0015]: cannot call non-const fn `::plus` in constant functions --> $DIR/call-const-trait-method-fail.rs:25:7 | LL | a.plus(b) - | ^^^^ the trait `~const Plus` is not implemented for `u32` + | ^^^^^^^ | -note: the trait `Plus` is implemented for `u32`, but that implementation is not `const` - --> $DIR/call-const-trait-method-fail.rs:25:7 - | -LL | a.plus(b) - | ^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr index 3963f64ad32b..d50100d033e5 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr @@ -1,15 +1,3 @@ -error[E0277]: can't compare `T` with `T` in const contexts - --> $DIR/call-generic-method-fail.rs:5:5 - | -LL | *t == *t - | ^^^^^^^^ no implementation for `T == T` - | -note: the trait `PartialEq` is implemented for `T`, but that implementation is not `const` - --> $DIR/call-generic-method-fail.rs:5:5 - | -LL | *t == *t - | ^^^^^^^^ - error[E0015]: cannot call non-const operator in constant functions --> $DIR/call-generic-method-fail.rs:5:5 | @@ -22,7 +10,6 @@ help: consider further restricting this bound LL | pub const fn equals_self(t: &T) -> bool { | ++++++++++++++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs index 414a8c87d2c4..eada4ceafe92 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs @@ -1,3 +1,6 @@ +// check-pass +// known-bug: #110395 + #![feature(const_trait_impl)] struct S; @@ -21,6 +24,6 @@ const fn equals_self(t: &T) -> bool { // it not using the impl. pub const EQ: bool = equals_self(&S); -//~^ ERROR +// FIXME(effects) ~^ ERROR fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr deleted file mode 100644 index a28d6ce05a7d..000000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `S: ~const Foo` is not satisfied - --> $DIR/call-generic-method-nonconst.rs:23:22 - | -LL | pub const EQ: bool = equals_self(&S); - | ^^^^^^^^^^^^^^^ the trait `~const Foo` is not implemented for `S` - | -note: the trait `Foo` is implemented for `S`, but that implementation is not `const` - --> $DIR/call-generic-method-nonconst.rs:23:22 - | -LL | pub const EQ: bool = equals_self(&S); - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr index 112416a35434..c350e3e40611 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr @@ -1,16 +1,21 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied in `fn(()) -> i32 {<() as Tr>::a}` - --> $DIR/const-closure-trait-method-fail.rs:18:23 +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ops/function.rs:LL:COL | -LL | const _: () = assert!(need_const_closure(Tr::a) == 42); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` + = note: calling non-const function `<() as Tr>::a` | -note: the trait `Tr` is implemented for `()`, but that implementation is not `const` +note: inside ` i32 {<() as Tr>::a} as FnOnce<((),)>>::call_once - shim(fn(()) -> i32 {<() as Tr>::a})` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL +note: inside `need_const_closure:: i32 {<() as Tr>::a}>` + --> $DIR/const-closure-trait-method-fail.rs:15:5 + | +LL | x(()) + | ^^^^^ +note: inside `_` --> $DIR/const-closure-trait-method-fail.rs:18:23 | LL | const _: () = assert!(need_const_closure(Tr::a) == 42); | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it appears within the type `fn(()) -> i32 {<() as Tr>::a}` error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs index 140a06a73ac6..3370f32061c2 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs @@ -22,7 +22,7 @@ impl const ConstDefaultFn for ConstImpl { const fn test() { NonConstImpl.a(); - //~^ ERROR the trait bound + //~^ ERROR cannot call ConstImpl.a(); } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr index f9d0d1f7875f..414688f71edf 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr @@ -1,15 +1,11 @@ -error[E0277]: the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied +error[E0015]: cannot call non-const fn `::a` in constant functions --> $DIR/const-default-method-bodies.rs:24:18 | LL | NonConstImpl.a(); - | ^ the trait `~const ConstDefaultFn` is not implemented for `NonConstImpl` + | ^^^ | -note: the trait `ConstDefaultFn` is implemented for `NonConstImpl`, but that implementation is not `const` - --> $DIR/const-default-method-bodies.rs:24:5 - | -LL | NonConstImpl.a(); - | ^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs index 948f0efbcfcb..7f89c12804b6 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs @@ -1,4 +1,5 @@ -// check-pass +// known-bug: #110395 +// FIXME check-pass #![feature(const_trait_impl)] #![feature(const_precise_live_drops)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr new file mode 100644 index 000000000000..f5147dc74b87 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr @@ -0,0 +1,9 @@ +error[E0493]: destructor of `E` cannot be evaluated at compile-time + --> $DIR/const-drop-bound.rs:12:13 + | +LL | Err(_e) => None, + | ^^ the destructor for this type cannot be evaluated in constant functions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr index 375f5d2c52d6..ce27e42f8c28 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr @@ -1,50 +1,11 @@ -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:31:23 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop-fail-2.rs:29:36 | -LL | const _: () = check::>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:31:23 - | -LL | const _: () = check::>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds(PhantomData); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` +LL | const fn check(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:32:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:32:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds(PhantomData); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` +error: aborting due to previous error -error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not - --> $DIR/const-drop-fail-2.rs:37:9 - | -LL | impl const Drop for ConstDropImplWithNonConstBounds { - | ^^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/const-drop-fail-2.rs:35:1 - | -LL | struct ConstDropImplWithNonConstBounds(PhantomData); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0277, E0367. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index e745cbd24429..dfa5ea8c4afa 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -1,58 +1,9 @@ -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop-fail.rs:24:36 | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | const fn check(_: T) {} + | ^ the destructor for this type cannot be evaluated in constant functions -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation -note: required because it appears within the type `ConstImplWithDropGlue` - --> $DIR/const-drop-fail.rs:18:8 - | -LL | struct ConstImplWithDropGlue(NonTrivialDrop); - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index e745cbd24429..8af38b792e66 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -1,58 +1,11 @@ -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop-fail.rs:24:36 | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | const fn check(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation - | -note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:28:23 - | -LL | const _: () = check($exp); - | ^^^^^^^^^^^ -... -LL | / check_all! { -LL | | NonTrivialDrop, -LL | | ConstImplWithDropGlue(NonTrivialDrop), -LL | | } - | |_- in this macro invocation -note: required because it appears within the type `ConstImplWithDropGlue` - --> $DIR/const-drop-fail.rs:18:8 - | -LL | struct ConstImplWithDropGlue(NonTrivialDrop); - | ^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr new file mode 100644 index 000000000000..23e368870258 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr @@ -0,0 +1,19 @@ +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:19:32 + | +LL | const fn a(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:24:13 + | +LL | let _ = S(&mut c); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs index b0fc3adf984a..0a9cf638a2d2 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs @@ -1,9 +1,10 @@ -// run-pass +// FIXME run-pass +// known-bug: #110395 // revisions: stock precise #![feature(const_trait_impl)] #![feature(const_mut_refs)] #![feature(never_type)] -#![cfg_attr(precise, feature(const_precise_live_drops))] +// #![cfg_attr(precise, feature(const_precise_live_drops))] use std::marker::Destruct; @@ -16,10 +17,12 @@ impl<'a> const Drop for S<'a> { } const fn a(_: T) {} +//FIXME ~^ ERROR destructor of const fn b() -> u8 { let mut c = 0; let _ = S(&mut c); + //FIXME ~^ ERROR destructor of a(S(&mut c)); c } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr new file mode 100644 index 000000000000..23e368870258 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr @@ -0,0 +1,19 @@ +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:19:32 + | +LL | const fn a(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:24:13 + | +LL | let _ = S(&mut c); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr index 633b7cc255a5..c936270de266 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr @@ -1,15 +1,11 @@ -error[E0277]: the trait bound `cross_crate::NonConst: ~const cross_crate::MyTrait` is not satisfied +error[E0015]: cannot call non-const fn `::func` in constant functions --> $DIR/cross-crate.rs:17:14 | LL | NonConst.func(); - | ^^^^ the trait `~const cross_crate::MyTrait` is not implemented for `cross_crate::NonConst` + | ^^^^^^ | -note: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst`, but that implementation is not `const` - --> $DIR/cross-crate.rs:17:5 - | -LL | NonConst.func(); - | ^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs index 6df47022cc94..1f78af794185 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs @@ -15,10 +15,11 @@ fn non_const_context() { const fn const_context() { #[cfg(any(stocknc, gatednc))] NonConst.func(); - //[stocknc]~^ ERROR: the trait bound - //[gatednc]~^^ ERROR: the trait bound + //[stocknc]~^ ERROR: cannot call + //[gatednc]~^^ ERROR: cannot call Const.func(); //[stock]~^ ERROR: cannot call + //[stocknc]~^^ ERROR: cannot call } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr index 9e97d3f11376..ebbe9aa2202f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr @@ -1,15 +1,21 @@ -error[E0277]: the trait bound `cross_crate::NonConst: cross_crate::MyTrait` is not satisfied +error[E0015]: cannot call non-const fn `::func` in constant functions --> $DIR/cross-crate.rs:17:14 | LL | NonConst.func(); - | ^^^^ the trait `~const cross_crate::MyTrait` is not implemented for `cross_crate::NonConst` + | ^^^^^^ | -note: the trait `cross_crate::MyTrait` is implemented for `cross_crate::NonConst`, but that implementation is not `const` - --> $DIR/cross-crate.rs:17:5 + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error[E0015]: cannot call non-const fn `::func` in constant functions + --> $DIR/cross-crate.rs:20:11 | -LL | NonConst.func(); - | ^^^^^^^^ +LL | Const.func(); + | ^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs index 96acdc300e0d..6ffdfa131329 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs @@ -1,3 +1,6 @@ +// known-bug: #110395 +// check-pass + #![feature(const_trait_impl)] #[const_trait] @@ -10,7 +13,7 @@ const fn foo() where T: ~const Tr {} pub trait Foo { fn foo() { foo::<()>(); - //~^ ERROR the trait bound `(): ~const Tr` is not satisfied + //FIXME ~^ ERROR the trait bound `(): ~const Tr` is not satisfied } } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr deleted file mode 100644 index 26644f72c4e5..000000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied - --> $DIR/default-method-body-is-const-body-checking.rs:12:9 - | -LL | foo::<()>(); - | ^^^^^^^^^^^ the trait `~const Tr` is not implemented for `()` - | -note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/default-method-body-is-const-body-checking.rs:12:9 - | -LL | foo::<()>(); - | ^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs index f70ecbc3746f..d3591e63a08e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs @@ -1,3 +1,4 @@ +// known-bug: #110395 #![feature(const_trait_impl)] #[const_trait] @@ -6,7 +7,7 @@ pub trait Tr { fn b(&self) { ().a() - //~^ ERROR the trait bound + //FIXME ~^ ERROR the trait bound } } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr index 21ecddaffbb6..9f9f17b09294 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr @@ -1,15 +1,11 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied - --> $DIR/default-method-body-is-const-same-trait-ck.rs:8:12 +error[E0015]: cannot call non-const fn `<() as Tr>::a` in constant functions + --> $DIR/default-method-body-is-const-same-trait-ck.rs:9:12 | LL | ().a() - | ^ the trait `~const Tr` is not implemented for `()` + | ^^^ | -note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/default-method-body-is-const-same-trait-ck.rs:8:9 - | -LL | ().a() - | ^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs index 07d3f51edce5..df242721bc31 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs @@ -1,11 +1,12 @@ +// known-bug: #110395 #![feature(const_trait_impl)] struct Bug { inner: [(); match || 1 { n => n(), - //~^ ERROR the trait bound - //~| ERROR the trait bound - //~| ERROR cannot call non-const closure in constants + //FIXME ~^ ERROR the trait bound + //FIXME ~| ERROR the trait bound + //FIXME ~| ERROR cannot call non-const closure in constants }], } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr index b98ccbe5d03e..f0c61cf9dd98 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr @@ -1,41 +1,11 @@ -error[E0277]: the trait bound `[closure@$DIR/issue-102985.rs:4:23: 4:25]: ~const Fn<()>` is not satisfied - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-102985.rs:4:23: 4:25]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-102985.rs:4:23: 4:25]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-102985.rs:4:23: 4:25]`, but that implementation is not `const` - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ - = note: wrap the `[closure@$DIR/issue-102985.rs:4:23: 4:25]` in a closure with no arguments: `|| { /* code */ }` - -error[E0277]: the trait bound `[closure@$DIR/issue-102985.rs:4:23: 4:25]: ~const Fn<()>` is not satisfied - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-102985.rs:4:23: 4:25]` - | - = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-102985.rs:4:23: 4:25]` -note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-102985.rs:4:23: 4:25]`, but that implementation is not `const` - --> $DIR/issue-102985.rs:5:14 - | -LL | n => n(), - | ^^^ - = note: wrap the `[closure@$DIR/issue-102985.rs:4:23: 4:25]` in a closure with no arguments: `|| { /* code */ }` - error[E0015]: cannot call non-const closure in constants - --> $DIR/issue-102985.rs:5:14 + --> $DIR/issue-102985.rs:6:14 | LL | n => n(), | ^^^ | - = note: closures need an RFC before allowed to be called in constants = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs index b132c395ac7b..5127ec069be9 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 + #![feature(const_trait_impl)] pub trait A { @@ -6,8 +8,8 @@ pub trait A { pub const fn foo() -> bool { T::assoc() - //~^ ERROR the trait bound - //~| ERROR cannot call non-const fn + //FIXME ~^ ERROR the trait bound + //FIXME ~| ERROR cannot call non-const fn } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr index 955923505200..d8cb10c65174 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr @@ -1,24 +1,11 @@ -error[E0277]: the trait bound `T: ~const A` is not satisfied - --> $DIR/issue-88155.rs:8:5 - | -LL | T::assoc() - | ^^^^^^^^^^ the trait `~const A` is not implemented for `T` - | -note: the trait `A` is implemented for `T`, but that implementation is not `const` - --> $DIR/issue-88155.rs:8:5 - | -LL | T::assoc() - | ^^^^^^^^^^ - error[E0015]: cannot call non-const fn `::assoc` in constant functions - --> $DIR/issue-88155.rs:8:5 + --> $DIR/issue-88155.rs:10:5 | LL | T::assoc() | ^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs index 96a3e386e6e9..fdb422201d20 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs @@ -1,6 +1,7 @@ // Regression test for #92111. // -// check-pass +// known-bug: #110395 +// FIXME check-pass #![feature(const_trait_impl)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr new file mode 100644 index 000000000000..b27f94f99ed7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr @@ -0,0 +1,11 @@ +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/issue-92111.rs:20:32 + | +LL | const fn a(t: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr index bd0dd126c5e6..4fe8a372e070 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr @@ -1,26 +1,12 @@ -error[E0277]: can't compare `str` with `str` in const contexts - --> $DIR/match-non-const-eq.rs:6:9 - | -LL | "a" => (), - | ^^^ no implementation for `str == str` - | - = help: the trait `~const PartialEq` is not implemented for `str` -note: the trait `PartialEq` is implemented for `str`, but that implementation is not `const` - --> $DIR/match-non-const-eq.rs:6:9 - | -LL | "a" => (), - | ^^^ - error[E0015]: cannot match on `str` in constant functions - --> $DIR/match-non-const-eq.rs:6:9 + --> $DIR/match-non-const-eq.rs:7:9 | -LL | "a" => (), +LL | "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in const contexts | ^^^ | = note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs index 0d04101a3830..d06d0d6dd108 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs @@ -1,10 +1,11 @@ +// known-bug: #110395 // revisions: stock gated #![cfg_attr(gated, feature(const_trait_impl))] const fn foo(input: &'static str) { match input { - "a" => (), //[gated]~ ERROR can't compare `str` with `str` in const contexts - //~^ ERROR cannot match on `str` in constant functions + "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in const contexts + //FIXME ~^ ERROR cannot match on `str` in constant functions _ => (), } } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr index dcb9b49ea04c..c36142dac928 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr @@ -1,7 +1,7 @@ error[E0015]: cannot match on `str` in constant functions - --> $DIR/match-non-const-eq.rs:6:9 + --> $DIR/match-non-const-eq.rs:7:9 | -LL | "a" => (), +LL | "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in const contexts | ^^^ | = note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs index f31123f16f14..0701cf93a02a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs @@ -1,5 +1,6 @@ // Tests that trait bounds on specializing trait impls must be `~const` if the // same bound is present on the default impl and is `~const` there. +// known-bug: #110395 #![feature(const_trait_impl)] #![feature(rustc_attrs)] @@ -29,7 +30,7 @@ where impl Bar for T where - T: Foo, //~ ERROR missing `~const` qualifier + T: Foo, //FIXME ~ ERROR missing `~const` qualifier T: Specialize, { fn bar() {} @@ -47,7 +48,7 @@ where default fn baz() {} } -impl const Baz for T //~ ERROR conflicting implementations of trait `Baz` +impl const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz` where T: Foo, T: Specialize, diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr index 057cf4aea8a0..8f5ca2189daa 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr @@ -1,18 +1,14 @@ error: missing `~const` qualifier for specialization - --> $DIR/const-default-bound-non-const-specialized-bound.rs:32:8 + --> $DIR/const-default-bound-non-const-specialized-bound.rs:33:8 + | +LL | T: Foo, //FIXME ~ ERROR missing `~const` qualifier + | ^^^ + +error: missing `~const` qualifier for specialization + --> $DIR/const-default-bound-non-const-specialized-bound.rs:53:8 | LL | T: Foo, | ^^^ -error[E0119]: conflicting implementations of trait `Baz` - --> $DIR/const-default-bound-non-const-specialized-bound.rs:50:1 - | -LL | impl const Baz for T - | ----------------------- first implementation here -... -LL | impl const Baz for T - | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs index 633543700d2e..ada475909a3d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs @@ -1,5 +1,5 @@ #![feature(const_trait_impl, min_specialization, rustc_attrs)] - +// known-bug: #110395 #[rustc_specialization_trait] #[const_trait] pub trait Sup {} @@ -25,7 +25,7 @@ impl const A for T { const fn generic() { ::a(); - //~^ ERROR: the trait bound `T: ~const Sup` is not satisfied + //FIXME ~^ ERROR: the trait bound `T: ~const Sup` is not satisfied } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr index 8923416f4c77..92bc9815e963 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr @@ -1,21 +1,11 @@ -error[E0277]: the trait bound `T: ~const Sup` is not satisfied +error[E0015]: cannot call non-const fn `::a` in constant functions --> $DIR/specializing-constness-2.rs:27:5 | LL | ::a(); - | ^^^^^^^^^^^^^ the trait `~const Sup` is not implemented for `T` + | ^^^^^^^^^^^^^ | -note: required for `T` to implement `~const A` - --> $DIR/specializing-constness-2.rs:20:37 - | -LL | impl const A for T { - | ---------- ^ ^ - | | - | unsatisfied trait bound introduced here -help: consider further restricting this bound - | -LL | const fn generic() { - | ++++++++++++ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs index ecb06271cd9b..93fd96f8f294 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs @@ -1,5 +1,5 @@ #![feature(const_trait_impl)] - +// known-bug: #110395 // revisions: yy yn ny nn #[cfg_attr(any(yy, yn), const_trait)] @@ -9,12 +9,12 @@ trait Foo { #[cfg_attr(any(yy, ny), const_trait)] trait Bar: ~const Foo {} -//[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` -//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` +// FIXME [ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` +// FIXME [ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` const fn foo(x: &T) { x.a(); - //[yn,yy]~^ ERROR the trait bound + // FIXME [yn,yy]~^ ERROR the trait bound } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr index c9fa1955498d..5d34156a5196 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr @@ -1,19 +1,11 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0015]: cannot call non-const fn `::a` in constant functions --> $DIR/super-traits-fail-2.rs:16:7 | LL | x.a(); - | ^ the trait `~const Foo` is not implemented for `T` + | ^^^ | -note: the trait `Foo` is implemented for `T`, but that implementation is not `const` - --> $DIR/super-traits-fail-2.rs:16:5 - | -LL | x.a(); - | ^ -help: consider further restricting this bound - | -LL | const fn foo(x: &T) { - | ++++++++++++ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr index c9fa1955498d..5d34156a5196 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr @@ -1,19 +1,11 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0015]: cannot call non-const fn `::a` in constant functions --> $DIR/super-traits-fail-2.rs:16:7 | LL | x.a(); - | ^ the trait `~const Foo` is not implemented for `T` + | ^^^ | -note: the trait `Foo` is implemented for `T`, but that implementation is not `const` - --> $DIR/super-traits-fail-2.rs:16:5 - | -LL | x.a(); - | ^ -help: consider further restricting this bound - | -LL | const fn foo(x: &T) { - | ++++++++++++ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs index 3e2b81368a5f..b3853def7213 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs @@ -1,3 +1,6 @@ +// check-pass +// known-bug: #110395 + #![feature(const_trait_impl)] #[const_trait] @@ -13,6 +16,6 @@ impl Foo for S { } impl const Bar for S {} -//~^ ERROR the trait bound +//FIXME ~^ ERROR the trait bound fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr deleted file mode 100644 index bf12ef1ca77d..000000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0277]: the trait bound `S: ~const Foo` is not satisfied - --> $DIR/super-traits-fail.rs:15:20 - | -LL | impl const Bar for S {} - | ^ the trait `~const Foo` is not implemented for `S` - | -note: the trait `Foo` is implemented for `S`, but that implementation is not `const` - --> $DIR/super-traits-fail.rs:15:20 - | -LL | impl const Bar for S {} - | ^ -note: required by a bound in `Bar` - --> $DIR/super-traits-fail.rs:8:12 - | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^ required by this bound in `Bar` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs index bfe98b98c742..90e9afd8e521 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs @@ -2,6 +2,8 @@ // Checking the validity of traits' where clauses happen at a later stage. // (`rustc_const_eval` instead of `rustc_hir_analysis`) Therefore one file as a // test is not enough. +// known-bug: #110395 +// check-pass #![feature(const_trait_impl)] #[const_trait] @@ -17,9 +19,9 @@ trait Foo { const fn test1() { T::a(); T::b(); - //~^ ERROR the trait bound + //FIXME ~^ ERROR the trait bound T::c::(); - //~^ ERROR the trait bound + //FIXME ~^ ERROR the trait bound } const fn test2() { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr deleted file mode 100644 index f2846b6a6626..000000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:19:5 - | -LL | T::b(); - | ^^^^^^ the trait `~const Bar` is not implemented for `T` - | -note: the trait `Bar` is implemented for `T`, but that implementation is not `const` - --> $DIR/trait-where-clause-const.rs:19:5 - | -LL | T::b(); - | ^^^^^^ -help: consider further restricting this bound - | -LL | const fn test1() { - | ++++++++++++ - -error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:21:5 - | -LL | T::c::(); - | ^^^^^^^^^^^ the trait `~const Bar` is not implemented for `T` - | -note: the trait `Bar` is implemented for `T`, but that implementation is not `const` - --> $DIR/trait-where-clause-const.rs:21:5 - | -LL | T::c::(); - | ^^^^^^^^^^^ -help: consider further restricting this bound - | -LL | const fn test1() { - | ++++++++++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. From b09091c69bb086e7ed4ecf7f6509654f1c776dde Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 16:50:28 +0000 Subject: [PATCH 100/150] Adjust spans correctly for fn -> method suggestion --- compiler/rustc_hir_typeck/src/callee.rs | 8 ++++++-- .../suggest-method-on-call-with-macro-rcvr.rs | 6 ++++++ .../suggest-method-on-call-with-macro-rcvr.stderr | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs create mode 100644 tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index a47597221996..c68f2d94f352 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -531,8 +531,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; } - let up_to_rcvr_span = segment.ident.span.until(callee_expr.span); - let rest_span = callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi()); + let Some(callee_expr_span) = callee_expr.span.find_ancestor_inside(call_expr.span) + else { + return; + }; + let up_to_rcvr_span = segment.ident.span.until(callee_expr_span); + let rest_span = callee_expr_span.shrink_to_hi().to(call_expr.span.shrink_to_hi()); let rest_snippet = if let Some(first) = rest.first() { self.tcx .sess diff --git a/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs new file mode 100644 index 000000000000..93b7ddf5e9e0 --- /dev/null +++ b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.rs @@ -0,0 +1,6 @@ +// issue: 114131 + +fn main() { + let hello = len(vec![]); + //~^ ERROR cannot find function `len` in this scope +} diff --git a/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr new file mode 100644 index 000000000000..9694f80ab6d0 --- /dev/null +++ b/tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr @@ -0,0 +1,15 @@ +error[E0425]: cannot find function `len` in this scope + --> $DIR/suggest-method-on-call-with-macro-rcvr.rs:4:17 + | +LL | let hello = len(vec![]); + | ^^^ not found in this scope + | +help: use the `.` operator to call the method `len` on `&Vec<_>` + | +LL - let hello = len(vec![]); +LL + let hello = vec![].len(); + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. From 9268a8b060f01ace9e925f27778d2768f4850cf8 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 27 Jul 2023 19:04:13 +0200 Subject: [PATCH 101/150] Make `--print KIND=PATH` unstable https://github.com/rust-lang/rust/pull/113780 should have gone through an MCP+FCP but wasn't, but instead of reverting the original PR, this PR just make that new option unstable. --- compiler/rustc_session/src/config.rs | 6 ++++++ src/doc/rustc/src/command-line-arguments.md | 4 ---- .../unstable-book/src/compiler-flags/path-options.md | 11 +++++++++++ tests/run-make/print-cfg/Makefile | 8 ++++---- tests/ui/feature-gates/print-with-path.cfg.stderr | 2 ++ tests/ui/feature-gates/print-with-path.rs | 7 +++++++ .../feature-gates/print-with-path.target-cpus.stderr | 2 ++ .../print-with-path.target-features.stderr | 2 ++ 8 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/doc/unstable-book/src/compiler-flags/path-options.md create mode 100644 tests/ui/feature-gates/print-with-path.cfg.stderr create mode 100644 tests/ui/feature-gates/print-with-path.rs create mode 100644 tests/ui/feature-gates/print-with-path.target-cpus.stderr create mode 100644 tests/ui/feature-gates/print-with-path.target-features.stderr diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 36b5c385ab19..0fadcf7899d6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2151,6 +2151,12 @@ fn collect_print_requests( prints.extend(matches.opt_strs("print").into_iter().map(|req| { let (req, out) = split_out_file_name(&req); + if out.is_some() && !unstable_opts.unstable_options { + handler.early_error( + "the `-Z unstable-options` flag must also be passed to \ + enable the path print option", + ); + } let kind = match PRINT_KINDS.iter().find(|&&(name, _)| name == req) { Some((_, PrintKind::TargetSpec)) => { if unstable_opts.unstable_options { diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index 4d32897cc14c..2c7c05c0c4b8 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -260,10 +260,6 @@ The valid types of print values are: This returns rustc's minimum supported deployment target if no `*_DEPLOYMENT_TARGET` variable is present in the environment, or otherwise returns the variable's parsed value. -A filepath may optionally be specified for each requested information kind, in -the format `--print KIND=PATH`, just like for `--emit`. When a path is -specified, information will be written there instead of to stdout. - [conditional compilation]: ../reference/conditional-compilation.html [deployment target]: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html diff --git a/src/doc/unstable-book/src/compiler-flags/path-options.md b/src/doc/unstable-book/src/compiler-flags/path-options.md new file mode 100644 index 000000000000..0f2437020dd9 --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/path-options.md @@ -0,0 +1,11 @@ +# `--print` Options + +The behavior of the `--print` flag can be modified by optionally be specifiying a filepath +for each requested information kind, in the format `--print KIND=PATH`, just like for +`--emit`. When a path is specified, information will be written there instead of to stdout. + +This is unstable feature, so you have to provide `-Zunstable-options` to enable it. + +## Examples + +`rustc main.rs -Z unstable-options --print cfg=cfgs.txt` diff --git a/tests/run-make/print-cfg/Makefile b/tests/run-make/print-cfg/Makefile index 6b153e5b54ed..654c303b3e26 100644 --- a/tests/run-make/print-cfg/Makefile +++ b/tests/run-make/print-cfg/Makefile @@ -13,19 +13,19 @@ all: default output_to_file output_to_file: # Backend-independent, printed by rustc_driver_impl/src/lib.rs - $(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt + $(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt -Z unstable-options $(CGREP) windows < $(TMPDIR)/cfg.txt # Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs - $(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt + $(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt -Z unstable-options $(CGREP) dynamic-no-pic < $(TMPDIR)/relocation-models.txt # Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs - $(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt + $(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt -Z unstable-options $(CGREP) reference-types < $(TMPDIR)/target-features.txt # Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp - $(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt + $(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt -Z unstable-options $(CGREP) generic < $(TMPDIR)/target-cpus.txt ifdef IS_WINDOWS diff --git a/tests/ui/feature-gates/print-with-path.cfg.stderr b/tests/ui/feature-gates/print-with-path.cfg.stderr new file mode 100644 index 000000000000..a6c51baa320a --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.cfg.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + diff --git a/tests/ui/feature-gates/print-with-path.rs b/tests/ui/feature-gates/print-with-path.rs new file mode 100644 index 000000000000..f929c14c2188 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.rs @@ -0,0 +1,7 @@ +// check-fail +// revisions: cfg target-features target-cpus +// [cfg]compile-flags: --print cfg=cfg.txt +// [target-cpus]compile-flags: --print target-cpu=target_cpu.txt +// [target-features]compile-flags: --print target-features=target_features.txt + +fn main() {} diff --git a/tests/ui/feature-gates/print-with-path.target-cpus.stderr b/tests/ui/feature-gates/print-with-path.target-cpus.stderr new file mode 100644 index 000000000000..a6c51baa320a --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.target-cpus.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + diff --git a/tests/ui/feature-gates/print-with-path.target-features.stderr b/tests/ui/feature-gates/print-with-path.target-features.stderr new file mode 100644 index 000000000000..a6c51baa320a --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.target-features.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + From b0fa2201d3e2d4c206e633bf47f562c660aad8b5 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 27 Jul 2023 17:56:25 +0000 Subject: [PATCH 102/150] bless clippy --- .../src/const_eval/fn_queries.rs | 13 +++-- .../clippy_lints/src/manual_float_methods.rs | 8 ++- .../clippy_utils/src/qualify_min_const_fn.rs | 58 ++++++++++--------- .../ui/missing_const_for_fn/could_be_const.rs | 1 + .../could_be_const.stderr | 8 +-- 5 files changed, 47 insertions(+), 41 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs index fa8253d5e496..cc39387c41fc 100644 --- a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs @@ -28,15 +28,18 @@ pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { && tcx.constness(parent_id) == hir::Constness::Const } -/// Checks whether an item is considered to be `const`. If it is a constructor, it is const. If -/// it is a trait impl/function, return if it has a `const` modifier. If it is an intrinsic, -/// report whether said intrinsic has a `rustc_const_{un,}stable` attribute. Otherwise, return -/// `Constness::NotConst`. +/// Checks whether an item is considered to be `const`. If it is a constructor, anonymous const, +/// const block, const item or associated const, it is const. If it is a trait impl/function, +/// return if it has a `const` modifier. If it is an intrinsic, report whether said intrinsic +/// has a `rustc_const_{un,}stable` attribute. Otherwise, return `Constness::NotConst`. fn constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness { let node = tcx.hir().get_by_def_id(def_id); match node { - hir::Node::Ctor(_) => hir::Constness::Const, + hir::Node::Ctor(_) + | hir::Node::AnonConst(_) + | hir::Node::ConstBlock(_) + | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. }) => hir::Constness::Const, hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.constness, hir::Node::ForeignItem(hir::ForeignItem { kind: hir::ForeignItemKind::Fn(..), .. }) => { // Intrinsics use `rustc_const_{un,}stable` attributes to indicate constness. All other diff --git a/src/tools/clippy/clippy_lints/src/manual_float_methods.rs b/src/tools/clippy/clippy_lints/src/manual_float_methods.rs index ccd2f06aad27..f48a5d9d2456 100644 --- a/src/tools/clippy/clippy_lints/src/manual_float_methods.rs +++ b/src/tools/clippy/clippy_lints/src/manual_float_methods.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use clippy_utils::{is_from_proc_macro, path_to_local}; use rustc_errors::Applicability; -use rustc_hir::{BinOpKind, Expr, ExprKind}; +use rustc_hir::{BinOpKind, Constness, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, Lint, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -83,8 +83,10 @@ impl Variant { impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { if !in_external_macro(cx.sess(), expr.span) - && cx.tcx.features().active(sym!(const_float_classify)) - && let ExprKind::Binary(kind, lhs, rhs) = expr.kind + && ( + matches!(cx.tcx.constness(cx.tcx.hir().enclosing_body_owner(expr.hir_id)), Constness::NotConst) + || cx.tcx.features().active(sym!(const_float_classify)) + ) && let ExprKind::Binary(kind, lhs, rhs) = expr.kind && let ExprKind::Binary(lhs_kind, lhs_lhs, lhs_rhs) = lhs.kind && let ExprKind::Binary(rhs_kind, rhs_lhs, rhs_rhs) = rhs.kind // Checking all possible scenarios using a function would be a hopeless task, as we have diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index aed3d601bcac..a98e2038d5f0 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -391,32 +391,38 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool { #[expect(clippy::similar_names)] // bit too pedantic fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool { - // Avoid selecting for simple cases, such as builtin types. - if ty::util::is_trivially_const_drop(ty) { - return true; + // FIXME(effects, fee1-dead) revert to const destruct once it works again + #[expect(unused)] + fn is_ty_const_destruct_unused<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool { + // Avoid selecting for simple cases, such as builtin types. + if ty::util::is_trivially_const_drop(ty) { + return true; + } + + let obligation = Obligation::new( + tcx, + ObligationCause::dummy_with_span(body.span), + ConstCx::new(tcx, body).param_env, + TraitRef::from_lang_item(tcx, LangItem::Destruct, body.span, [ty]).with_constness(BoundConstness::ConstIfConst), + ); + + let infcx = tcx.infer_ctxt().build(); + let mut selcx = SelectionContext::new(&infcx); + let Some(impl_src) = selcx.select(&obligation).ok().flatten() else { + return false; + }; + + if !matches!( + impl_src, + ImplSource::Builtin(BuiltinImplSource::Misc, _) | ImplSource::Param(ty::BoundConstness::ConstIfConst, _) + ) { + return false; + } + + let ocx = ObligationCtxt::new(&infcx); + ocx.register_obligations(impl_src.nested_obligations()); + ocx.select_all_or_error().is_empty() } - let obligation = Obligation::new( - tcx, - ObligationCause::dummy_with_span(body.span), - ConstCx::new(tcx, body).param_env, - TraitRef::from_lang_item(tcx, LangItem::Destruct, body.span, [ty]).with_constness(BoundConstness::ConstIfConst), - ); - - let infcx = tcx.infer_ctxt().build(); - let mut selcx = SelectionContext::new(&infcx); - let Some(impl_src) = selcx.select(&obligation).ok().flatten() else { - return false; - }; - - if !matches!( - impl_src, - ImplSource::Builtin(BuiltinImplSource::Misc, _) | ImplSource::Param(ty::BoundConstness::ConstIfConst, _) - ) { - return false; - } - - let ocx = ObligationCtxt::new(&infcx); - ocx.register_obligations(impl_src.nested_obligations()); - ocx.select_all_or_error().is_empty() + !ty.needs_drop(tcx, ConstCx::new(tcx, body).param_env) } diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs index b1980b1b523f..3aaee67e1d97 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs @@ -99,4 +99,5 @@ impl const Drop for D { } // Lint this, since it can be dropped in const contexts +// FIXME(effects) fn d(this: D) {} diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr index 7be2cc0ca930..66cf4e315293 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr @@ -89,11 +89,5 @@ LL | | 46 LL | | } | |_^ -error: this could be a `const fn` - --> $DIR/could_be_const.rs:102:1 - | -LL | fn d(this: D) {} - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 12 previous errors +error: aborting due to 11 previous errors From 37076c9b4ea70878027304af99cdaf9b75b79f57 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 16 Jul 2023 23:26:02 +0000 Subject: [PATCH 103/150] Don't attempt to compute layout of type referencing error --- compiler/rustc_hir_typeck/src/intrinsicck.rs | 11 +++-------- compiler/rustc_middle/messages.ftl | 3 +++ compiler/rustc_middle/src/error.rs | 3 +++ compiler/rustc_middle/src/ty/layout.rs | 9 +++++++-- compiler/rustc_transmute/src/layout/tree.rs | 2 +- compiler/rustc_ty_utils/src/layout.rs | 15 +++++++++++++-- .../ui/layout/malformed-unsized-type-in-union.rs | 8 ++++++++ .../layout/malformed-unsized-type-in-union.stderr | 9 +++++++++ 8 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 tests/ui/layout/malformed-unsized-type-in-union.rs create mode 100644 tests/ui/layout/malformed-unsized-type-in-union.stderr diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index 2cd18c4c3fcb..4e65182f1580 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -122,14 +122,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { err.note(format!("source type: `{}` ({})", from, skeleton_string(from, sk_from))) .note(format!("target type: `{}` ({})", to, skeleton_string(to, sk_to))); - let mut should_delay_as_bug = false; - if let Err(LayoutError::Unknown(bad_from)) = sk_from && bad_from.references_error() { - should_delay_as_bug = true; - } - if let Err(LayoutError::Unknown(bad_to)) = sk_to && bad_to.references_error() { - should_delay_as_bug = true; - } - if should_delay_as_bug { + if let Err(LayoutError::ReferencesError(_)) = sk_from { + err.delay_as_bug(); + } else if let Err(LayoutError::ReferencesError(_)) = sk_to { err.delay_as_bug(); } } diff --git a/compiler/rustc_middle/messages.ftl b/compiler/rustc_middle/messages.ftl index bb7147ac80fb..108a10b506be 100644 --- a/compiler/rustc_middle/messages.ftl +++ b/compiler/rustc_middle/messages.ftl @@ -52,6 +52,9 @@ middle_drop_check_overflow = overflow while adding drop-check rules for {$ty} .note = overflowed on {$overflow_ty} +middle_layout_references_error = + the type has an unknown layout + middle_limit_invalid = `limit` must be a non-negative integer .label = {$error_str} diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs index 57b2de84b47f..b346cd453914 100644 --- a/compiler/rustc_middle/src/error.rs +++ b/compiler/rustc_middle/src/error.rs @@ -132,6 +132,9 @@ pub enum LayoutError<'tcx> { #[diag(middle_cycle)] Cycle, + + #[diag(middle_layout_references_error)] + ReferencesError, } #[derive(Diagnostic)] diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 81e7dc3728ab..93dabb973e38 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -10,7 +10,7 @@ use rustc_hir::def_id::DefId; use rustc_index::IndexVec; use rustc_session::config::OptLevel; use rustc_span::symbol::{sym, Symbol}; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; use rustc_target::abi::call::FnAbi; use rustc_target::abi::*; use rustc_target::spec::{abi::Abi as SpecAbi, HasTargetSpec, PanicStrategy, Target}; @@ -212,6 +212,7 @@ pub enum LayoutError<'tcx> { Unknown(Ty<'tcx>), SizeOverflow(Ty<'tcx>), NormalizationFailure(Ty<'tcx>, NormalizationError<'tcx>), + ReferencesError(ErrorGuaranteed), Cycle, } @@ -224,6 +225,7 @@ impl<'tcx> LayoutError<'tcx> { SizeOverflow(_) => middle_values_too_big, NormalizationFailure(_, _) => middle_cannot_be_normalized, Cycle => middle_cycle, + ReferencesError(_) => middle_layout_references_error, } } @@ -237,6 +239,7 @@ impl<'tcx> LayoutError<'tcx> { E::NormalizationFailure { ty, failure_ty: e.get_type_for_failure() } } Cycle => E::Cycle, + ReferencesError(_) => E::ReferencesError, } } } @@ -257,6 +260,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> { e.get_type_for_failure() ), LayoutError::Cycle => write!(f, "a cycle occurred during layout computation"), + LayoutError::ReferencesError(_) => write!(f, "the type has an unknown layout"), } } } @@ -323,7 +327,8 @@ impl<'tcx> SizeSkeleton<'tcx> { Err( e @ LayoutError::Cycle | e @ LayoutError::SizeOverflow(_) - | e @ LayoutError::NormalizationFailure(..), + | e @ LayoutError::NormalizationFailure(..) + | e @ LayoutError::ReferencesError(_), ) => return Err(e), }; diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 8bd268182560..e8ddb0a43962 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -195,7 +195,7 @@ pub(crate) mod rustc { impl<'tcx> From<&LayoutError<'tcx>> for Err { fn from(err: &LayoutError<'tcx>) -> Self { match err { - LayoutError::Unknown(..) => Self::UnknownLayout, + LayoutError::Unknown(..) | LayoutError::ReferencesError(..) => Self::UnknownLayout, err => unimplemented!("{:?}", err), } } diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index b840ff184e0b..3500c2cc3700 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -96,6 +96,13 @@ fn layout_of_uncached<'tcx>( cx: &LayoutCx<'tcx, TyCtxt<'tcx>>, ty: Ty<'tcx>, ) -> Result, &'tcx LayoutError<'tcx>> { + // Types that reference `ty::Error` pessimistically don't have a meaningful layout. + // The only side-effect of this is possibly worse diagnostics in case the layout + // was actually computable (like if the `ty::Error` showed up only in a `PhantomData`). + if let Err(guar) = ty.error_reported() { + return Err(error(cx, LayoutError::ReferencesError(guar))); + } + let tcx = cx.tcx; let param_env = cx.param_env; let dl = cx.data_layout(); @@ -564,11 +571,15 @@ fn layout_of_uncached<'tcx>( return Err(error(cx, LayoutError::Unknown(ty))); } - ty::Bound(..) | ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) | ty::Infer(_) => { + ty::Bound(..) + | ty::GeneratorWitness(..) + | ty::GeneratorWitnessMIR(..) + | ty::Infer(_) + | ty::Error(_) => { bug!("Layout::compute: unexpected type `{}`", ty) } - ty::Placeholder(..) | ty::Param(_) | ty::Error(_) => { + ty::Placeholder(..) | ty::Param(_) => { return Err(error(cx, LayoutError::Unknown(ty))); } }) diff --git a/tests/ui/layout/malformed-unsized-type-in-union.rs b/tests/ui/layout/malformed-unsized-type-in-union.rs new file mode 100644 index 000000000000..5d8ec576cf01 --- /dev/null +++ b/tests/ui/layout/malformed-unsized-type-in-union.rs @@ -0,0 +1,8 @@ +// issue: 113760 + +union W { s: dyn Iterator } +//~^ ERROR cannot find type `Missing` in this scope + +static ONCE: W = todo!(); + +fn main() {} diff --git a/tests/ui/layout/malformed-unsized-type-in-union.stderr b/tests/ui/layout/malformed-unsized-type-in-union.stderr new file mode 100644 index 000000000000..cbb8d6af38ad --- /dev/null +++ b/tests/ui/layout/malformed-unsized-type-in-union.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/malformed-unsized-type-in-union.rs:3:34 + | +LL | union W { s: dyn Iterator } + | ^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. From 77fa702b639f941aab7462ca6e3562f793f54fef Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 17 Jul 2023 01:03:55 +0000 Subject: [PATCH 104/150] Fix aksama template --- src/librustdoc/html/templates/type_layout.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustdoc/html/templates/type_layout.html b/src/librustdoc/html/templates/type_layout.html index 20e09a548058..287cbab07d2b 100644 --- a/src/librustdoc/html/templates/type_layout.html +++ b/src/librustdoc/html/templates/type_layout.html @@ -44,6 +44,11 @@ Note: Encountered an error during type layout; {#+ #} the type was too big. {# #}

{# #} + {% when Err(LayoutError::ReferencesError(_)) %} +

{# #} + Note: Encountered an error during type layout; {#+ #} + the type references errors. {# #} +

{# #} {% when Err(LayoutError::NormalizationFailure(_, _)) %}

{# #} Note: Encountered an error during type layout; {#+ #} From d45eb41c500e35bd4ac155b1b49e0920c746abfc Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 18:51:44 +0000 Subject: [PATCH 105/150] Dont report CTFE errors that are due to references-error layouts --- compiler/rustc_const_eval/src/const_eval/error.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index ffeff8d079aa..d39a7e8a1925 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -138,7 +138,10 @@ where err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => { ErrorHandled::TooGeneric } - err_inval!(AlreadyReported(error_reported)) => ErrorHandled::Reported(error_reported), + err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar), + err_inval!(Layout(LayoutError::ReferencesError(guar))) => { + ErrorHandled::Reported(guar.into()) + } err_inval!(Layout(layout_error @ LayoutError::SizeOverflow(_))) => { // We must *always* hard error on these, even if the caller wants just a lint. // The `message` makes little sense here, this is a more serious error than the From 190ded84434f435b9626a07278b9ed0e7603bd11 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 27 Jul 2023 14:07:08 -0700 Subject: [PATCH 106/150] Update the minimum external LLVM to 15 --- .github/workflows/ci.yml | 6 +- compiler/rustc_codegen_llvm/src/attributes.rs | 62 +++++++++---------- compiler/rustc_codegen_llvm/src/llvm_util.rs | 2 - .../rustc_llvm/llvm-wrapper/LLVMWrapper.h | 2 - .../rustc_llvm/llvm-wrapper/PassWrapper.cpp | 3 - .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 41 ------------ src/bootstrap/llvm.rs | 4 +- .../host-x86_64/x86_64-gnu-llvm-14/Dockerfile | 54 ---------------- .../host-x86_64/x86_64-gnu-llvm-15/Dockerfile | 24 ++----- .../script.sh | 0 .../host-x86_64/x86_64-gnu-llvm-16/Dockerfile | 20 +----- src/ci/github-actions/ci.yml | 7 +-- tests/assembly/is_aligned.rs | 1 - tests/assembly/slice-is_ascii.rs | 1 - tests/assembly/strict_provenance.rs | 1 - tests/codegen/addr-of-mutate.rs | 1 - tests/codegen/align-offset.rs | 1 - tests/codegen/array-codegen.rs | 1 - tests/codegen/box-maybe-uninit.rs | 1 - tests/codegen/comparison-operators-2-tuple.rs | 1 - tests/codegen/comparison-operators-newtype.rs | 1 - tests/codegen/consts.rs | 1 - tests/codegen/intrinsics/offset.rs | 1 - tests/codegen/intrinsics/transmute-niched.rs | 1 - tests/codegen/intrinsics/transmute-x64.rs | 1 - tests/codegen/intrinsics/transmute.rs | 1 - .../issues/issue-105386-ub-in-debuginfo.rs | 5 +- .../issues/issue-85872-multiple-reverse.rs | 1 - tests/codegen/issues/issue-86106.rs | 1 - tests/codegen/issues/issue-96274.rs | 1 - .../issues/issue-96497-slice-size-nowrap.rs | 1 - ...issue-98294-get-mut-copy-from-slice-opt.rs | 1 - tests/codegen/mem-replace-simple-type.rs | 1 - tests/codegen/slice_as_from_ptr_range.rs | 1 - tests/codegen/transmute-optimized.rs | 1 - tests/codegen/transmute-scalar.rs | 1 - tests/codegen/try_question_mark_nop.rs | 1 - tests/codegen/unchecked_shifts.rs | 1 - tests/codegen/uninit-consts.rs | 1 - tests/codegen/vec-calloc.rs | 1 - tests/ui/asm/x86_64/issue-96797.rs | 1 - tests/ui/codegen/issue-55976.rs | 2 - tests/ui/dyn-star/llvm-old-style-ptrs.rs | 2 - tests/ui/generics/issue-94923.rs | 1 - 44 files changed, 42 insertions(+), 221 deletions(-) delete mode 100644 src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile rename src/ci/docker/host-x86_64/{x86_64-gnu-llvm-14 => x86_64-gnu-llvm-15}/script.sh (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0842b69c219c..bc66dcddc4b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: - name: mingw-check-tidy os: ubuntu-20.04-16core-64gb env: {} - - name: x86_64-gnu-llvm-14 + - name: x86_64-gnu-llvm-15 os: ubuntu-20.04-16core-64gb env: {} - name: x86_64-gnu-tools @@ -293,10 +293,6 @@ jobs: env: RUST_BACKTRACE: 1 os: ubuntu-20.04-8core-32gb - - name: x86_64-gnu-llvm-14 - env: - RUST_BACKTRACE: 1 - os: ubuntu-20.04-8core-32gb - name: x86_64-gnu-nopt os: ubuntu-20.04-4core-16gb env: {} diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 4c69b9503a2c..e4fce30e2325 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -363,50 +363,44 @@ pub fn from_fn_attrs<'ll, 'tcx>( if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR) || codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR_ZEROED) { - if llvm_util::get_version() >= (15, 0, 0) { - to_add.push(create_alloc_family_attr(cx.llcx)); - // apply to argument place instead of function - let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx); - attributes::apply_to_llfn(llfn, AttributePlace::Argument(1), &[alloc_align]); - to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 0)); - let mut flags = AllocKindFlags::Alloc | AllocKindFlags::Aligned; - if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR) { - flags |= AllocKindFlags::Uninitialized; - } else { - flags |= AllocKindFlags::Zeroed; - } - to_add.push(llvm::CreateAllocKindAttr(cx.llcx, flags)); + to_add.push(create_alloc_family_attr(cx.llcx)); + // apply to argument place instead of function + let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx); + attributes::apply_to_llfn(llfn, AttributePlace::Argument(1), &[alloc_align]); + to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 0)); + let mut flags = AllocKindFlags::Alloc | AllocKindFlags::Aligned; + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR) { + flags |= AllocKindFlags::Uninitialized; + } else { + flags |= AllocKindFlags::Zeroed; } + to_add.push(llvm::CreateAllocKindAttr(cx.llcx, flags)); // apply to return place instead of function (unlike all other attributes applied in this function) let no_alias = AttributeKind::NoAlias.create_attr(cx.llcx); attributes::apply_to_llfn(llfn, AttributePlace::ReturnValue, &[no_alias]); } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::REALLOCATOR) { - if llvm_util::get_version() >= (15, 0, 0) { - to_add.push(create_alloc_family_attr(cx.llcx)); - to_add.push(llvm::CreateAllocKindAttr( - cx.llcx, - AllocKindFlags::Realloc | AllocKindFlags::Aligned, - )); - // applies to argument place instead of function place - let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx); - attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]); - // apply to argument place instead of function - let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx); - attributes::apply_to_llfn(llfn, AttributePlace::Argument(2), &[alloc_align]); - to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 3)); - } + to_add.push(create_alloc_family_attr(cx.llcx)); + to_add.push(llvm::CreateAllocKindAttr( + cx.llcx, + AllocKindFlags::Realloc | AllocKindFlags::Aligned, + )); + // applies to argument place instead of function place + let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx); + attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]); + // apply to argument place instead of function + let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx); + attributes::apply_to_llfn(llfn, AttributePlace::Argument(2), &[alloc_align]); + to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 3)); let no_alias = AttributeKind::NoAlias.create_attr(cx.llcx); attributes::apply_to_llfn(llfn, AttributePlace::ReturnValue, &[no_alias]); } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::DEALLOCATOR) { - if llvm_util::get_version() >= (15, 0, 0) { - to_add.push(create_alloc_family_attr(cx.llcx)); - to_add.push(llvm::CreateAllocKindAttr(cx.llcx, AllocKindFlags::Free)); - // applies to argument place instead of function place - let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx); - attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]); - } + to_add.push(create_alloc_family_attr(cx.llcx)); + to_add.push(llvm::CreateAllocKindAttr(cx.llcx, AllocKindFlags::Free)); + // applies to argument place instead of function place + let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx); + attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]); } if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) { to_add.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry")); diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 4f20fbf2045a..6ae738174bff 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -507,8 +507,6 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec= (15, 0, 0)) .map(String::from), ); diff --git a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h index af6f4d5eaf99..ea0454628452 100644 --- a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h +++ b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h @@ -92,10 +92,8 @@ enum LLVMRustAttribute { NoCfCheck = 35, ShadowCallStack = 36, AllocSize = 37, -#if LLVM_VERSION_GE(15, 0) AllocatedPointer = 38, AllocAlign = 39, -#endif SanitizeSafeStack = 40, }; diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 71df17c9ce75..ebf8a50ae8b8 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -801,9 +801,6 @@ LLVMRustOptimize( OptimizerLastEPCallbacks.push_back( [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) { auto CompileKernel = SanitizerOptions->SanitizeKernelAddress; -#if LLVM_VERSION_LT(15, 0) - MPM.addPass(RequireAnalysisPass()); -#endif AddressSanitizerOptions opts = AddressSanitizerOptions{ CompileKernel, SanitizerOptions->SanitizeAddressRecover diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 870a2e02cbaa..f509e2911f31 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -277,12 +277,10 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) { return Attribute::ShadowCallStack; case AllocSize: return Attribute::AllocSize; -#if LLVM_VERSION_GE(15, 0) case AllocatedPointer: return Attribute::AllocatedPointer; case AllocAlign: return Attribute::AllocAlign; -#endif case SanitizeSafeStack: return Attribute::SafeStack; } @@ -340,20 +338,12 @@ extern "C" LLVMAttributeRef LLVMRustCreateStructRetAttr(LLVMContextRef C, LLVMTy } extern "C" LLVMAttributeRef LLVMRustCreateElementTypeAttr(LLVMContextRef C, LLVMTypeRef Ty) { -#if LLVM_VERSION_GE(15, 0) return wrap(Attribute::get(*unwrap(C), Attribute::ElementType, unwrap(Ty))); -#else - report_fatal_error("Should not be needed on LLVM < 15"); -#endif } extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Async) { -#if LLVM_VERSION_LT(15, 0) - return wrap(Attribute::get(*unwrap(C), Attribute::UWTable)); -#else return wrap(Attribute::getWithUWTableKind( *unwrap(C), Async ? UWTableKind::Async : UWTableKind::Sync)); -#endif } extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) { @@ -366,8 +356,6 @@ extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32 )); } -#if LLVM_VERSION_GE(15, 0) - // These values **must** match ffi::AllocKindFlags. // It _happens_ to match the LLVM values of llvm::AllocFnKind, // but that's happenstance and we do explicit conversions before @@ -411,16 +399,10 @@ static llvm::AllocFnKind allocKindFromRust(LLVMRustAllocKindFlags F) { } return AFK; } -#endif extern "C" LLVMAttributeRef LLVMRustCreateAllocKindAttr(LLVMContextRef C, uint64_t AllocKindArg) { -#if LLVM_VERSION_GE(15, 0) return wrap(Attribute::get(*unwrap(C), Attribute::AllocKind, static_cast(allocKindFromRust(static_cast(AllocKindArg))))); -#else - report_fatal_error( - "allockind attributes are new in LLVM 15 and should not be used on older LLVMs"); -#endif } // Simplified representation of `MemoryEffects` across the FFI boundary. @@ -517,14 +499,9 @@ LLVMRustInlineAsm(LLVMTypeRef Ty, char *AsmString, size_t AsmStringLen, extern "C" bool LLVMRustInlineAsmVerify(LLVMTypeRef Ty, char *Constraints, size_t ConstraintsLen) { -#if LLVM_VERSION_LT(15, 0) - return InlineAsm::Verify(unwrap(Ty), - StringRef(Constraints, ConstraintsLen)); -#else // llvm::Error converts to true if it is an error. return !llvm::errorToBool(InlineAsm::verify( unwrap(Ty), StringRef(Constraints, ConstraintsLen))); -#endif } typedef DIBuilder *LLVMRustDIBuilderRef; @@ -1649,19 +1626,11 @@ extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *hig auto C = unwrap(CV); if (C->getBitWidth() > 128) { return false; } APInt AP; -#if LLVM_VERSION_GE(15, 0) if (sext) { AP = C->getValue().sext(128); } else { AP = C->getValue().zext(128); } -#else - if (sext) { - AP = C->getValue().sextOrSelf(128); - } else { - AP = C->getValue().zextOrSelf(128); - } -#endif *low = AP.getLoBits(64).getZExtValue(); *high = AP.getHiBits(64).getZExtValue(); return true; @@ -2037,16 +2006,7 @@ extern "C" void LLVMRustGetMangledName(LLVMValueRef V, RustStringRef Str) { Mangler().getNameWithPrefix(OS, GV, true); } -// LLVMGetAggregateElement was added in LLVM 15. For earlier LLVM versions just -// use its implementation. -#if LLVM_VERSION_LT(15, 0) -extern "C" LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx) { - return wrap(unwrap(C)->getAggregateElement(Idx)); -} -#endif - extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) { -#if LLVM_VERSION_GE(15, 0) auto *CB = unwrap(CallSite); switch (CB->getIntrinsicID()) { case Intrinsic::arm_ldrex: @@ -2054,7 +2014,6 @@ extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) { case Intrinsic::arm_strex: return 1; } -#endif return -1; } diff --git a/src/bootstrap/llvm.rs b/src/bootstrap/llvm.rs index 02fef4b3e830..90007fc8ba14 100644 --- a/src/bootstrap/llvm.rs +++ b/src/bootstrap/llvm.rs @@ -525,11 +525,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) { let version = output(cmd.arg("--version")); let mut parts = version.split('.').take(2).filter_map(|s| s.parse::().ok()); if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) { - if major >= 14 { + if major >= 15 { return; } } - panic!("\n\nbad LLVM version: {}, need >=14.0\n\n", version) + panic!("\n\nbad LLVM version: {}, need >=15.0\n\n", version) } fn configure_cmake( diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile deleted file mode 100644 index 93d18bcf1b18..000000000000 --- a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile +++ /dev/null @@ -1,54 +0,0 @@ -FROM ubuntu:22.04 - -ARG DEBIAN_FRONTEND=noninteractive - -RUN apt-get update && apt-get install -y --no-install-recommends \ - g++ \ - gcc-multilib \ - make \ - ninja-build \ - file \ - curl \ - ca-certificates \ - python3.11 \ - git \ - cmake \ - sudo \ - gdb \ - llvm-14-tools \ - llvm-14-dev \ - libedit-dev \ - libssl-dev \ - pkg-config \ - zlib1g-dev \ - xz-utils \ - nodejs \ - mingw-w64 \ - && rm -rf /var/lib/apt/lists/* - -# Install powershell (universal package) so we can test x.ps1 on Linux -RUN curl -sL "https://github.com/PowerShell/PowerShell/releases/download/v7.3.1/powershell_7.3.1-1.deb_amd64.deb" > powershell.deb && \ - dpkg -i powershell.deb && \ - rm -f powershell.deb - -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh - -# We are disabling CI LLVM since this builder is intentionally using a host -# LLVM, rather than the typical src/llvm-project LLVM. -ENV NO_DOWNLOAD_CI_LLVM 1 - -# This is not the latest LLVM version, so some components required by tests may -# be missing. -ENV IS_NOT_LATEST_LLVM 1 - -# Using llvm-link-shared due to libffi issues -- see #34486 -ENV RUST_CONFIGURE_ARGS \ - --build=x86_64-unknown-linux-gnu \ - --llvm-root=/usr/lib/llvm-14 \ - --enable-llvm-link-shared \ - --set rust.thin-lto-import-instr-limit=10 - -COPY host-x86_64/x86_64-gnu-llvm-14/script.sh /tmp/ - -ENV SCRIPT /tmp/script.sh diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/Dockerfile index 960683b92bdd..444e0275d48f 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.10 +FROM ubuntu:22.04 ARG DEBIAN_FRONTEND=noninteractive @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ file \ curl \ ca-certificates \ - python3 \ + python3.11 \ git \ cmake \ sudo \ @@ -49,20 +49,6 @@ ENV RUST_CONFIGURE_ARGS \ --enable-llvm-link-shared \ --set rust.thin-lto-import-instr-limit=10 -# NOTE: intentionally uses all of `x.py`, `x`, and `x.ps1` to make sure they all work on Linux. -ENV SCRIPT ../x.py --stage 2 test --exclude src/tools/tidy && \ - # Run the `mir-opt` tests again but this time for a 32-bit target. - # This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have - # both 32-bit and 64-bit outputs updated by the PR author, before - # the PR is approved and tested for merging. - # It will also detect tests lacking `// EMIT_MIR_FOR_EACH_BIT_WIDTH`, - # despite having different output on 32-bit vs 64-bit targets. - ../x --stage 2 test tests/mir-opt \ - --host='' --target=i686-unknown-linux-gnu && \ - # Run the UI test suite again, but in `--pass=check` mode - # - # This is intended to make sure that both `--pass=check` continues to - # work. - # - ../x.ps1 --stage 2 test tests/ui --pass=check \ - --host='' --target=i686-unknown-linux-gnu +COPY host-x86_64/x86_64-gnu-llvm-15/script.sh /tmp/ + +ENV SCRIPT /tmp/script.sh diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/script.sh b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/script.sh similarity index 100% rename from src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/script.sh rename to src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/script.sh diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-16/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-16/Dockerfile index 7c75d0df5908..1e2b802e64e3 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-16/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-16/Dockerfile @@ -45,20 +45,6 @@ ENV RUST_CONFIGURE_ARGS \ --enable-llvm-link-shared \ --set rust.thin-lto-import-instr-limit=10 -# NOTE: intentionally uses all of `x.py`, `x`, and `x.ps1` to make sure they all work on Linux. -ENV SCRIPT ../x.py --stage 2 test --exclude src/tools/tidy && \ - # Run the `mir-opt` tests again but this time for a 32-bit target. - # This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have - # both 32-bit and 64-bit outputs updated by the PR author, before - # the PR is approved and tested for merging. - # It will also detect tests lacking `// EMIT_MIR_FOR_EACH_BIT_WIDTH`, - # despite having different output on 32-bit vs 64-bit targets. - ../x --stage 2 test tests/mir-opt \ - --host='' --target=i686-unknown-linux-gnu && \ - # Run the UI test suite again, but in `--pass=check` mode - # - # This is intended to make sure that both `--pass=check` continues to - # work. - # - ../x.ps1 --stage 2 test tests/ui --pass=check \ - --host='' --target=i686-unknown-linux-gnu +COPY host-x86_64/x86_64-gnu-llvm-15/script.sh /tmp/ + +ENV SCRIPT /tmp/script.sh diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 55fd6cca85a5..2f83729bbb62 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -323,7 +323,7 @@ jobs: - name: mingw-check-tidy <<: *job-linux-16c - - name: x86_64-gnu-llvm-14 + - name: x86_64-gnu-llvm-15 <<: *job-linux-16c - name: x86_64-gnu-tools @@ -469,11 +469,6 @@ jobs: RUST_BACKTRACE: 1 <<: *job-linux-8c - - name: x86_64-gnu-llvm-14 - env: - RUST_BACKTRACE: 1 - <<: *job-linux-8c - - name: x86_64-gnu-nopt <<: *job-linux-4c diff --git a/tests/assembly/is_aligned.rs b/tests/assembly/is_aligned.rs index 148d11ee4d68..d152d200adfd 100644 --- a/tests/assembly/is_aligned.rs +++ b/tests/assembly/is_aligned.rs @@ -1,5 +1,4 @@ // assembly-output: emit-asm -// min-llvm-version: 15.0 // only-x86_64 // ignore-sgx // revisions: opt-speed opt-size diff --git a/tests/assembly/slice-is_ascii.rs b/tests/assembly/slice-is_ascii.rs index b3e1fee15a71..124121164674 100644 --- a/tests/assembly/slice-is_ascii.rs +++ b/tests/assembly/slice-is_ascii.rs @@ -3,7 +3,6 @@ // [LIN] only-linux // assembly-output: emit-asm // compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel -// min-llvm-version: 14 // only-x86_64 // ignore-sgx // ignore-debug diff --git a/tests/assembly/strict_provenance.rs b/tests/assembly/strict_provenance.rs index 24a7c6b5bf10..ef8566a93e28 100644 --- a/tests/assembly/strict_provenance.rs +++ b/tests/assembly/strict_provenance.rs @@ -2,7 +2,6 @@ // compile-flags: -Copt-level=1 // only-x86_64 // ignore-sgx -// min-llvm-version: 15.0 #![crate_type = "rlib"] // CHECK-LABEL: old_style diff --git a/tests/codegen/addr-of-mutate.rs b/tests/codegen/addr-of-mutate.rs index 6dfc18250151..97af6181524e 100644 --- a/tests/codegen/addr-of-mutate.rs +++ b/tests/codegen/addr-of-mutate.rs @@ -1,5 +1,4 @@ // compile-flags: -C opt-level=3 -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) #![crate_type = "lib"] diff --git a/tests/codegen/align-offset.rs b/tests/codegen/align-offset.rs index 7c7660c5a55a..d4d8b18d35b7 100644 --- a/tests/codegen/align-offset.rs +++ b/tests/codegen/align-offset.rs @@ -1,5 +1,4 @@ // compile-flags: -O -// min-llvm-version: 15.0 (because we're using opaque pointers) // ignore-debug (debug assertions in `slice::from_raw_parts` block optimizations) #![crate_type = "lib"] diff --git a/tests/codegen/array-codegen.rs b/tests/codegen/array-codegen.rs index 71acd781549b..ba0d444f97e3 100644 --- a/tests/codegen/array-codegen.rs +++ b/tests/codegen/array-codegen.rs @@ -1,5 +1,4 @@ // compile-flags: -O -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) #![crate_type = "lib"] diff --git a/tests/codegen/box-maybe-uninit.rs b/tests/codegen/box-maybe-uninit.rs index 5c08b5832ad8..282af99b0673 100644 --- a/tests/codegen/box-maybe-uninit.rs +++ b/tests/codegen/box-maybe-uninit.rs @@ -1,5 +1,4 @@ // compile-flags: -O -// min-llvm-version: 15.0 #![crate_type = "lib"] use std::mem::MaybeUninit; diff --git a/tests/codegen/comparison-operators-2-tuple.rs b/tests/codegen/comparison-operators-2-tuple.rs index a9d25e3b53cf..7a2a3fc93f8a 100644 --- a/tests/codegen/comparison-operators-2-tuple.rs +++ b/tests/codegen/comparison-operators-2-tuple.rs @@ -1,5 +1,4 @@ // compile-flags: -C opt-level=1 -Z merge-functions=disabled -// min-llvm-version: 15.0 // only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/comparison-operators-newtype.rs b/tests/codegen/comparison-operators-newtype.rs index 683a2bd4fbb5..8fd8a81dfeb9 100644 --- a/tests/codegen/comparison-operators-newtype.rs +++ b/tests/codegen/comparison-operators-newtype.rs @@ -3,7 +3,6 @@ // in the operators for such a type all optimize away. // compile-flags: -C opt-level=1 -// min-llvm-version: 15.0 #![crate_type = "lib"] diff --git a/tests/codegen/consts.rs b/tests/codegen/consts.rs index 810da581ce9a..3797e1a99da7 100644 --- a/tests/codegen/consts.rs +++ b/tests/codegen/consts.rs @@ -1,5 +1,4 @@ // compile-flags: -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/offset.rs b/tests/codegen/intrinsics/offset.rs index 7fc4f4498d6d..542bacf99a80 100644 --- a/tests/codegen/intrinsics/offset.rs +++ b/tests/codegen/intrinsics/offset.rs @@ -1,5 +1,4 @@ // compile-flags: -O -C no-prepopulate-passes -// min-llvm-version: 15.0 (because we're using opaque pointers) #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/transmute-niched.rs b/tests/codegen/intrinsics/transmute-niched.rs index fffc24a11811..e9c8d803cb9e 100644 --- a/tests/codegen/intrinsics/transmute-niched.rs +++ b/tests/codegen/intrinsics/transmute-niched.rs @@ -2,7 +2,6 @@ // [OPT] compile-flags: -C opt-level=3 -C no-prepopulate-passes // [DBG] compile-flags: -C opt-level=0 -C no-prepopulate-passes // only-64bit (so I don't need to worry about usize) -// min-llvm-version: 15.0 # this test assumes `ptr`s #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/transmute-x64.rs b/tests/codegen/intrinsics/transmute-x64.rs index 168838ef4976..19020f6280a5 100644 --- a/tests/codegen/intrinsics/transmute-x64.rs +++ b/tests/codegen/intrinsics/transmute-x64.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C no-prepopulate-passes // only-x86_64 (it's using arch-specific types) -// min-llvm-version: 15.0 # this test assumes `ptr`s #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index f8c20960660d..e64af33ab6cc 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C no-prepopulate-passes // only-64bit (so I don't need to worry about usize) -// min-llvm-version: 15.0 # this test assumes `ptr`s #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs index 6e0eacfe4002..f345c96e6f76 100644 --- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs @@ -1,6 +1,5 @@ // compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates // MIR SROA will decompose the closure -// min-llvm-version: 15.0 # this test uses opaque pointer notation #![feature(stmt_expr_attributes)] pub struct S([usize; 8]); @@ -16,8 +15,8 @@ pub fn outer_function(x: S, y: S) -> usize { // Check that we do not attempt to load from the spilled arg before it is assigned to // when generating debuginfo. // CHECK-LABEL: @outer_function -// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:10:23: 10:25]" -// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:10:23: 10:25]", ptr [[spill]] +// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:9:23: 9:25]" +// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]] // CHECK-NOT: [[load:%.*]] = load ptr, ptr // CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) // CHECK: [[inner:%.*]] = getelementptr inbounds %"{{.*}}", ptr [[spill]] diff --git a/tests/codegen/issues/issue-85872-multiple-reverse.rs b/tests/codegen/issues/issue-85872-multiple-reverse.rs index 591a1aca7474..a4723a0e9460 100644 --- a/tests/codegen/issues/issue-85872-multiple-reverse.rs +++ b/tests/codegen/issues/issue-85872-multiple-reverse.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0.0 // compile-flags: -O #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-86106.rs b/tests/codegen/issues/issue-86106.rs index be5034dcfbd7..15aef344ac0c 100644 --- a/tests/codegen/issues/issue-86106.rs +++ b/tests/codegen/issues/issue-86106.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0 // only-64bit llvm appears to use stores instead of memset on 32bit // compile-flags: -C opt-level=3 -Z merge-functions=disabled diff --git a/tests/codegen/issues/issue-96274.rs b/tests/codegen/issues/issue-96274.rs index 28bfcce0d7be..a44789ce350a 100644 --- a/tests/codegen/issues/issue-96274.rs +++ b/tests/codegen/issues/issue-96274.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0 // compile-flags: -O #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs index 0413ed6b26f3..3ea6a5405e51 100644 --- a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs +++ b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs @@ -3,7 +3,6 @@ // in some situations, see https://github.com/rust-lang/rust/issues/96497#issuecomment-1112865218 // compile-flags: -O -// min-llvm-version: 15.0 #![crate_type="lib"] diff --git a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs index 7da29cd79529..b87e43c13b65 100644 --- a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs +++ b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0.0 // ignore-debug: The debug assertions get in the way // compile-flags: -O diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs index 5c4acf813ea4..174ac608e01b 100644 --- a/tests/codegen/mem-replace-simple-type.rs +++ b/tests/codegen/mem-replace-simple-type.rs @@ -1,5 +1,4 @@ // compile-flags: -O -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) // only-x86_64 (to not worry about usize differing) // ignore-debug (the debug assertions get in the way) diff --git a/tests/codegen/slice_as_from_ptr_range.rs b/tests/codegen/slice_as_from_ptr_range.rs index 0e3fefd9728d..3d8ab0a4b5f8 100644 --- a/tests/codegen/slice_as_from_ptr_range.rs +++ b/tests/codegen/slice_as_from_ptr_range.rs @@ -1,7 +1,6 @@ // compile-flags: -O // only-64bit (because we're using [ui]size) // ignore-debug (because the assertions get in the way) -// min-llvm-version: 15.0 (because this is a relatively new instcombine) #![crate_type = "lib"] #![feature(slice_from_ptr_range)] diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs index 461dd550cd7e..b8c51b08499f 100644 --- a/tests/codegen/transmute-optimized.rs +++ b/tests/codegen/transmute-optimized.rs @@ -1,5 +1,4 @@ // compile-flags: -O -Z merge-functions=disabled -// min-llvm-version: 15.0 # this test uses `ptr`s // ignore-debug #![crate_type = "lib"] diff --git a/tests/codegen/transmute-scalar.rs b/tests/codegen/transmute-scalar.rs index 293b0d664f62..39126b024a6e 100644 --- a/tests/codegen/transmute-scalar.rs +++ b/tests/codegen/transmute-scalar.rs @@ -1,5 +1,4 @@ // compile-flags: -C opt-level=0 -C no-prepopulate-passes -// min-llvm-version: 15.0 # this test assumes `ptr`s and thus no `pointercast`s #![crate_type = "lib"] diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index d239387768e6..9d34155bdd79 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -1,4 +1,3 @@ -// min-llvm-version: 15.0 // compile-flags: -O -Z merge-functions=disabled --edition=2021 // only-x86_64 diff --git a/tests/codegen/unchecked_shifts.rs b/tests/codegen/unchecked_shifts.rs index 0924dda08ee6..d5f53bedd543 100644 --- a/tests/codegen/unchecked_shifts.rs +++ b/tests/codegen/unchecked_shifts.rs @@ -1,5 +1,4 @@ // compile-flags: -O -// min-llvm-version: 15.0 (LLVM 13 in CI does this differently from submodule LLVM) // ignore-debug (because unchecked is checked in debug) #![crate_type = "lib"] diff --git a/tests/codegen/uninit-consts.rs b/tests/codegen/uninit-consts.rs index f169988e1f5a..1313e67634a3 100644 --- a/tests/codegen/uninit-consts.rs +++ b/tests/codegen/uninit-consts.rs @@ -1,5 +1,4 @@ // compile-flags: -C no-prepopulate-passes -// min-llvm-version: 15.0 (for opaque pointers) // Check that we use undef (and not zero) for uninitialized bytes in constants. diff --git a/tests/codegen/vec-calloc.rs b/tests/codegen/vec-calloc.rs index 4481a9d1e998..a5fda7b2449a 100644 --- a/tests/codegen/vec-calloc.rs +++ b/tests/codegen/vec-calloc.rs @@ -1,7 +1,6 @@ // compile-flags: -O -Z merge-functions=disabled // only-x86_64 // ignore-debug -// min-llvm-version: 15.0 #![crate_type = "lib"] diff --git a/tests/ui/asm/x86_64/issue-96797.rs b/tests/ui/asm/x86_64/issue-96797.rs index 954f8c5ccc33..951dd949b325 100644 --- a/tests/ui/asm/x86_64/issue-96797.rs +++ b/tests/ui/asm/x86_64/issue-96797.rs @@ -1,6 +1,5 @@ // build-pass // compile-flags: -O -// min-llvm-version: 14.0.5 // needs-asm-support // only-x86_64 // only-linux diff --git a/tests/ui/codegen/issue-55976.rs b/tests/ui/codegen/issue-55976.rs index 3142704b78cf..fee54fc6206d 100644 --- a/tests/ui/codegen/issue-55976.rs +++ b/tests/ui/codegen/issue-55976.rs @@ -1,7 +1,5 @@ // run-pass // ^-- The above is needed as this issue is related to LLVM/codegen. -// min-llvm-version:15.0.0 -// ^-- The above is needed as this issue is fixed by the opaque pointers. fn main() { type_error(|x| &x); diff --git a/tests/ui/dyn-star/llvm-old-style-ptrs.rs b/tests/ui/dyn-star/llvm-old-style-ptrs.rs index 4c042a539798..460af99f9c50 100644 --- a/tests/ui/dyn-star/llvm-old-style-ptrs.rs +++ b/tests/ui/dyn-star/llvm-old-style-ptrs.rs @@ -1,8 +1,6 @@ // run-pass // compile-flags: -Copt-level=0 -Cllvm-args=-opaque-pointers=0 -// (opaque-pointers flag is called force-opaque-pointers in LLVM 13...) -// min-llvm-version: 14.0 // (the ability to disable opaque pointers has been removed in LLVM 17) // ignore-llvm-version: 17 - 99 diff --git a/tests/ui/generics/issue-94923.rs b/tests/ui/generics/issue-94923.rs index d337a5dffc93..893bac0d5e8d 100644 --- a/tests/ui/generics/issue-94923.rs +++ b/tests/ui/generics/issue-94923.rs @@ -1,6 +1,5 @@ // run-pass // regression test for issue #94923 -// min-llvm-version: 15.0.0 // compile-flags: -C opt-level=3 fn f0(mut x: usize) -> usize { From da47736f42307e450a447889ebc563cddaf93ac2 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 27 Jul 2023 14:44:13 -0700 Subject: [PATCH 107/150] CHECK only for opaque ptr --- .../codegen/abi-main-signature-32bit-c-int.rs | 2 +- tests/codegen/adjustments.rs | 6 +- tests/codegen/align-enum.rs | 2 +- tests/codegen/align-struct.rs | 4 +- tests/codegen/array-equality.rs | 8 +-- tests/codegen/atomic-operations.rs | 60 ++++++++--------- tests/codegen/avr/avr-func-addrspace.rs | 6 +- tests/codegen/drop-in-place-noalias.rs | 4 +- tests/codegen/fastcall-inreg.rs | 2 +- tests/codegen/function-arguments-noopt.rs | 10 +-- tests/codegen/function-arguments.rs | 64 +++++++++---------- tests/codegen/intrinsics/mask.rs | 2 +- tests/codegen/intrinsics/nontemporal.rs | 2 +- tests/codegen/issues/issue-37945.rs | 8 +-- tests/codegen/issues/issue-56267-2.rs | 2 +- tests/codegen/issues/issue-56267.rs | 2 +- tests/codegen/issues/issue-56927.rs | 14 ++-- tests/codegen/issues/issue-58881.rs | 2 +- tests/codegen/lifetime_start_end.rs | 8 +-- tests/codegen/loads.rs | 34 +++++----- tests/codegen/match-optimized.rs | 6 +- tests/codegen/mem-replace-big-type.rs | 4 +- tests/codegen/move-operands.rs | 4 +- tests/codegen/option-nonzero-eq.rs | 2 +- tests/codegen/packed.rs | 40 ++++++------ tests/codegen/personality_lifetimes.rs | 2 +- tests/codegen/refs.rs | 6 +- tests/codegen/repeat-trusted-len.rs | 4 +- .../codegen/repr-transparent-aggregates-1.rs | 16 ++--- .../codegen/repr-transparent-aggregates-2.rs | 16 ++--- tests/codegen/repr-transparent.rs | 6 +- .../riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs | 10 +-- .../codegen/sanitizer-cfi-emit-type-checks.rs | 2 +- ...pe-metadata-itanium-cxx-abi-generalized.rs | 6 +- ...-itanium-cxx-abi-normalized-generalized.rs | 6 +- ...ype-metadata-itanium-cxx-abi-normalized.rs | 6 +- ...-cfi-emit-type-metadata-itanium-cxx-abi.rs | 6 +- ...er-cfi-emit-type-metadata-trait-objects.rs | 20 +++--- ...r-kcfi-emit-type-metadata-trait-objects.rs | 20 +++--- .../simd-intrinsic-generic-gather.rs | 4 +- .../simd-intrinsic-generic-scatter.rs | 4 +- .../simd-intrinsic-transmute-array.rs | 12 ++-- tests/codegen/simd_arith_offset.rs | 2 +- tests/codegen/slice-init.rs | 6 +- tests/codegen/slice-iter-len-eq-zero.rs | 2 +- tests/codegen/slice-ref-equality.rs | 12 ++-- tests/codegen/stores.rs | 8 +-- tests/codegen/swap-large-types.rs | 6 +- tests/codegen/union-abi.rs | 10 +-- tests/codegen/vec-as-ptr.rs | 4 +- .../coverage-llvmir/filecheck.testprog.txt | 4 +- .../filecheck-patterns.txt | 4 +- 52 files changed, 251 insertions(+), 251 deletions(-) diff --git a/tests/codegen/abi-main-signature-32bit-c-int.rs b/tests/codegen/abi-main-signature-32bit-c-int.rs index 7f22ddcfc12f..0258ad9534b1 100644 --- a/tests/codegen/abi-main-signature-32bit-c-int.rs +++ b/tests/codegen/abi-main-signature-32bit-c-int.rs @@ -7,4 +7,4 @@ fn main() { } -// CHECK: define{{( hidden)?}} i32 @main(i32{{( %0)?}}, {{i8\*\*|ptr}}{{( %1)?}}) +// CHECK: define{{( hidden)?}} i32 @main(i32{{( %0)?}}, ptr{{( %1)?}}) diff --git a/tests/codegen/adjustments.rs b/tests/codegen/adjustments.rs index b53a68a55880..0739c79ba8d6 100644 --- a/tests/codegen/adjustments.rs +++ b/tests/codegen/adjustments.rs @@ -13,9 +13,9 @@ pub fn helper(_: usize) { pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] { // We used to generate an extra alloca and memcpy for the block's trailing expression value, so // check that we copy directly to the return value slot -// CHECK: %0 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } poison, {{\[0 x i8\]\*|ptr}} %x.0, 0 -// CHECK: %1 = insertvalue { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %0, [[USIZE]] %x.1, 1 -// CHECK: ret { {{\[0 x i8\]\*|ptr}}, [[USIZE]] } %1 +// CHECK: %0 = insertvalue { ptr, [[USIZE]] } poison, ptr %x.0, 0 +// CHECK: %1 = insertvalue { ptr, [[USIZE]] } %0, [[USIZE]] %x.1, 1 +// CHECK: ret { ptr, [[USIZE]] } %1 { x } } diff --git a/tests/codegen/align-enum.rs b/tests/codegen/align-enum.rs index 70f09ace0062..5901f0113c3a 100644 --- a/tests/codegen/align-enum.rs +++ b/tests/codegen/align-enum.rs @@ -20,7 +20,7 @@ pub struct Nested64 { #[no_mangle] pub fn align64(a: u32) -> Align64 { // CHECK: %a64 = alloca %Align64, align 64 -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 64 %{{.*}}, {{i8\*|ptr}} align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) let a64 = Align64::A(a); a64 } diff --git a/tests/codegen/align-struct.rs b/tests/codegen/align-struct.rs index a2f47354b2b3..40bba6d52545 100644 --- a/tests/codegen/align-struct.rs +++ b/tests/codegen/align-struct.rs @@ -32,7 +32,7 @@ pub enum Enum64 { #[no_mangle] pub fn align64(i : i32) -> Align64 { // CHECK: %a64 = alloca %Align64, align 64 -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 64 %{{.*}}, {{i8\*|ptr}} align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 64 %{{.*}}, ptr align 64 %{{.*}}, i{{[0-9]+}} 64, i1 false) let a64 = Align64(i); a64 } @@ -42,7 +42,7 @@ pub fn align64(i : i32) -> Align64 { // CHECK-LABEL: @align64_load #[no_mangle] pub fn align64_load(a: Align64) -> i32 { -// CHECK: {{%.*}} = load i32, {{i32\*|ptr}} {{%.*}}, align 64 +// CHECK: {{%.*}} = load i32, ptr {{%.*}}, align 64 a.0 } diff --git a/tests/codegen/array-equality.rs b/tests/codegen/array-equality.rs index abfe295f8b67..1941452ea615 100644 --- a/tests/codegen/array-equality.rs +++ b/tests/codegen/array-equality.rs @@ -16,8 +16,8 @@ pub fn array_eq_value(a: [u16; 3], b: [u16; 3]) -> bool { #[no_mangle] pub fn array_eq_ref(a: &[u16; 3], b: &[u16; 3]) -> bool { // CHECK: start: - // CHECK: load i48, {{i48\*|ptr}} %{{.+}}, align 2 - // CHECK: load i48, {{i48\*|ptr}} %{{.+}}, align 2 + // CHECK: load i48, ptr %{{.+}}, align 2 + // CHECK: load i48, ptr %{{.+}}, align 2 // CHECK: icmp eq i48 // CHECK-NEXT: ret a == b @@ -27,7 +27,7 @@ pub fn array_eq_ref(a: &[u16; 3], b: &[u16; 3]) -> bool { #[no_mangle] pub fn array_eq_value_still_passed_by_pointer(a: [u16; 9], b: [u16; 9]) -> bool { // CHECK-NEXT: start: - // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{i8\*|ptr}} {{.*}} dereferenceable(18) %{{.+}}, {{i8\*|ptr}} {{.*}} dereferenceable(18) %{{.+}}, i64 18) + // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}(ptr {{.*}} dereferenceable(18) %{{.+}}, ptr {{.*}} dereferenceable(18) %{{.+}}, i64 18) // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[CMP]], 0 // CHECK-NEXT: ret i1 %[[EQ]] a == b @@ -37,7 +37,7 @@ pub fn array_eq_value_still_passed_by_pointer(a: [u16; 9], b: [u16; 9]) -> bool #[no_mangle] pub fn array_eq_long(a: &[u16; 1234], b: &[u16; 1234]) -> bool { // CHECK-NEXT: start: - // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{i8\*|ptr}} {{.*}} dereferenceable(2468) %{{.+}}, {{i8\*|ptr}} {{.*}} dereferenceable(2468) %{{.+}}, i64 2468) + // CHECK: %[[CMP:.+]] = tail call i32 @{{bcmp|memcmp}}(ptr {{.*}} dereferenceable(2468) %{{.+}}, ptr {{.*}} dereferenceable(2468) %{{.+}}, i64 2468) // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[CMP]], 0 // CHECK-NEXT: ret i1 %[[EQ]] a == b diff --git a/tests/codegen/atomic-operations.rs b/tests/codegen/atomic-operations.rs index d2bc618dfc52..20980c48960b 100644 --- a/tests/codegen/atomic-operations.rs +++ b/tests/codegen/atomic-operations.rs @@ -7,37 +7,37 @@ use std::sync::atomic::{AtomicI32, Ordering::*}; // CHECK-LABEL: @compare_exchange #[no_mangle] pub fn compare_exchange(a: &AtomicI32) { - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 10 monotonic monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 11 monotonic acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 12 monotonic seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 10 monotonic monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 11 monotonic acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 12 monotonic seq_cst let _ = a.compare_exchange(0, 10, Relaxed, Relaxed); let _ = a.compare_exchange(0, 11, Relaxed, Acquire); let _ = a.compare_exchange(0, 12, Relaxed, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 20 release monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 21 release acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 22 release seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 20 release monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 21 release acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 22 release seq_cst let _ = a.compare_exchange(0, 20, Release, Relaxed); let _ = a.compare_exchange(0, 21, Release, Acquire); let _ = a.compare_exchange(0, 22, Release, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 30 acquire monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 31 acquire acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 32 acquire seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 30 acquire monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 31 acquire acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 32 acquire seq_cst let _ = a.compare_exchange(0, 30, Acquire, Relaxed); let _ = a.compare_exchange(0, 31, Acquire, Acquire); let _ = a.compare_exchange(0, 32, Acquire, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 40 acq_rel monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 41 acq_rel acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 42 acq_rel seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 40 acq_rel monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 41 acq_rel acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 42 acq_rel seq_cst let _ = a.compare_exchange(0, 40, AcqRel, Relaxed); let _ = a.compare_exchange(0, 41, AcqRel, Acquire); let _ = a.compare_exchange(0, 42, AcqRel, SeqCst); - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 50 seq_cst monotonic - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 51 seq_cst acquire - // CHECK: cmpxchg {{i32\*|ptr}} %{{.*}}, i32 0, i32 52 seq_cst seq_cst + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 50 seq_cst monotonic + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 51 seq_cst acquire + // CHECK: cmpxchg ptr %{{.*}}, i32 0, i32 52 seq_cst seq_cst let _ = a.compare_exchange(0, 50, SeqCst, Relaxed); let _ = a.compare_exchange(0, 51, SeqCst, Acquire); let _ = a.compare_exchange(0, 52, SeqCst, SeqCst); @@ -46,37 +46,37 @@ pub fn compare_exchange(a: &AtomicI32) { // CHECK-LABEL: @compare_exchange_weak #[no_mangle] pub fn compare_exchange_weak(w: &AtomicI32) { - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 10 monotonic monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 11 monotonic acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 12 monotonic seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 10 monotonic monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 11 monotonic acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 12 monotonic seq_cst let _ = w.compare_exchange_weak(1, 10, Relaxed, Relaxed); let _ = w.compare_exchange_weak(1, 11, Relaxed, Acquire); let _ = w.compare_exchange_weak(1, 12, Relaxed, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 20 release monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 21 release acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 22 release seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 20 release monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 21 release acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 22 release seq_cst let _ = w.compare_exchange_weak(1, 20, Release, Relaxed); let _ = w.compare_exchange_weak(1, 21, Release, Acquire); let _ = w.compare_exchange_weak(1, 22, Release, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 30 acquire monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 31 acquire acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 32 acquire seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 30 acquire monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 31 acquire acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 32 acquire seq_cst let _ = w.compare_exchange_weak(1, 30, Acquire, Relaxed); let _ = w.compare_exchange_weak(1, 31, Acquire, Acquire); let _ = w.compare_exchange_weak(1, 32, Acquire, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 40 acq_rel monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 41 acq_rel acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 42 acq_rel seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 40 acq_rel monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 41 acq_rel acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 42 acq_rel seq_cst let _ = w.compare_exchange_weak(1, 40, AcqRel, Relaxed); let _ = w.compare_exchange_weak(1, 41, AcqRel, Acquire); let _ = w.compare_exchange_weak(1, 42, AcqRel, SeqCst); - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 50 seq_cst monotonic - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 51 seq_cst acquire - // CHECK: cmpxchg weak {{i32\*|ptr}} %{{.*}}, i32 1, i32 52 seq_cst seq_cst + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 50 seq_cst monotonic + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 51 seq_cst acquire + // CHECK: cmpxchg weak ptr %{{.*}}, i32 1, i32 52 seq_cst seq_cst let _ = w.compare_exchange_weak(1, 50, SeqCst, Relaxed); let _ = w.compare_exchange_weak(1, 51, SeqCst, Acquire); let _ = w.compare_exchange_weak(1, 52, SeqCst, SeqCst); diff --git a/tests/codegen/avr/avr-func-addrspace.rs b/tests/codegen/avr/avr-func-addrspace.rs index 83baae9e432d..dc36a9fac8c2 100644 --- a/tests/codegen/avr/avr-func-addrspace.rs +++ b/tests/codegen/avr/avr-func-addrspace.rs @@ -94,7 +94,7 @@ pub extern "C" fn test() { // Validate that we can codegen transmutes between data ptrs and fn ptrs. -// CHECK: define{{.+}}{{void \(\) addrspace\(1\)\*|ptr addrspace\(1\)}} @transmute_data_ptr_to_fn({{\{\}\*|ptr}}{{.*}} %x) +// CHECK: define{{.+}}ptr addrspace(1) @transmute_data_ptr_to_fn(ptr{{.*}} %x) #[no_mangle] pub unsafe fn transmute_data_ptr_to_fn(x: *const ()) -> fn() { // It doesn't matter precisely how this is codegenned (through memory or an addrspacecast), @@ -102,7 +102,7 @@ pub unsafe fn transmute_data_ptr_to_fn(x: *const ()) -> fn() { transmute(x) } -// CHECK: define{{.+}}{{\{\}\*|ptr}} @transmute_fn_ptr_to_data({{void \(\) addrspace\(1\)\*|ptr addrspace\(1\)}}{{.*}} %x) +// CHECK: define{{.+}}ptr @transmute_fn_ptr_to_data(ptr addrspace(1){{.*}} %x) #[no_mangle] pub unsafe fn transmute_fn_ptr_to_data(x: fn()) -> *const () { // It doesn't matter precisely how this is codegenned (through memory or an addrspacecast), @@ -116,7 +116,7 @@ pub enum Either { A(T), B(U) } // with the `ptr` field representing both `&i32` and `fn()` depending on the variant. // This is incorrect, because `fn()` should be `ptr addrspace(1)`, not `ptr`. -// CHECK: define{{.+}}void @should_not_combine_addrspace({{.+\*|ptr}}{{.+}}sret{{.+}}%_0, {{.+\*|ptr}}{{.+}}%x) +// CHECK: define{{.+}}void @should_not_combine_addrspace(ptr{{.+}}sret{{.+}}%_0, ptr{{.+}}%x) #[no_mangle] #[inline(never)] pub fn should_not_combine_addrspace(x: Either<&i32, fn()>) -> Either<&i32, fn()> { diff --git a/tests/codegen/drop-in-place-noalias.rs b/tests/codegen/drop-in-place-noalias.rs index 725e6fc048df..ece1e426c087 100644 --- a/tests/codegen/drop-in-place-noalias.rs +++ b/tests/codegen/drop-in-place-noalias.rs @@ -7,9 +7,9 @@ use std::marker::PhantomPinned; -// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}({{.*\*|ptr}} noalias noundef align 4 dereferenceable(12) %{{.+}}) +// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}(ptr noalias noundef align 4 dereferenceable(12) %{{.+}}) -// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}({{.*\*|ptr}} noundef nonnull align 4 %{{.+}}) +// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}(ptr noundef nonnull align 4 %{{.+}}) pub struct StructUnpin { a: i32, diff --git a/tests/codegen/fastcall-inreg.rs b/tests/codegen/fastcall-inreg.rs index 02f5d545910e..ab19efa45bf9 100644 --- a/tests/codegen/fastcall-inreg.rs +++ b/tests/codegen/fastcall-inreg.rs @@ -19,7 +19,7 @@ pub mod tests { #[no_mangle] pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {} - // CHECK: @f2({{i32\*|ptr}} inreg noundef %_1, {{i32\*|ptr}} inreg noundef %_2, {{i32\*|ptr}} noundef %_3) + // CHECK: @f2(ptr inreg noundef %_1, ptr inreg noundef %_2, ptr noundef %_3) #[no_mangle] pub extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {} diff --git a/tests/codegen/function-arguments-noopt.rs b/tests/codegen/function-arguments-noopt.rs index f99cc8fb4156..8fe6c790ddaf 100644 --- a/tests/codegen/function-arguments-noopt.rs +++ b/tests/codegen/function-arguments-noopt.rs @@ -23,13 +23,13 @@ pub fn boolean_call(x: bool, f: fn(bool) -> bool) -> bool { f(x) } -// CHECK: align 4 {{i32\*|ptr}} @borrow({{i32\*|ptr}} align 4 %x) +// CHECK: align 4 ptr @borrow(ptr align 4 %x) #[no_mangle] pub fn borrow(x: &i32) -> &i32 { x } -// CHECK: align 4 {{i32\*|ptr}} @borrow_mut({{i32\*|ptr}} align 4 %x) +// CHECK: align 4 ptr @borrow_mut(ptr align 4 %x) #[no_mangle] pub fn borrow_mut(x: &mut i32) -> &mut i32 { x @@ -38,11 +38,11 @@ pub fn borrow_mut(x: &mut i32) -> &mut i32 { // CHECK-LABEL: @borrow_call #[no_mangle] pub fn borrow_call(x: &i32, f: fn(&i32) -> &i32) -> &i32 { - // CHECK: call align 4 {{i32\*|ptr}} %f({{i32\*|ptr}} align 4 %x) + // CHECK: call align 4 ptr %f(ptr align 4 %x) f(x) } -// CHECK: void @struct_({{%S\*|ptr}} sret(%S) align 4{{( %_0)?}}, {{%S\*|ptr}} align 4 %x) +// CHECK: void @struct_(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %x) #[no_mangle] pub fn struct_(x: S) -> S { x @@ -51,7 +51,7 @@ pub fn struct_(x: S) -> S { // CHECK-LABEL: @struct_call #[no_mangle] pub fn struct_call(x: S, f: fn(S) -> S) -> S { - // CHECK: call void %f({{%S\*|ptr}} sret(%S) align 4{{( %_0)?}}, {{%S\*|ptr}} align 4 %{{.+}}) + // CHECK: call void %f(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %{{.+}}) f(x) } diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 2f047f103110..a218596da1d1 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -80,95 +80,95 @@ pub fn option_nonzero_int(x: Option) -> Option { x } -// CHECK: @readonly_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @readonly_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn readonly_borrow(_: &i32) { } -// CHECK: noundef align 4 dereferenceable(4) {{i32\*|ptr}} @readonly_borrow_ret() +// CHECK: noundef align 4 dereferenceable(4) ptr @readonly_borrow_ret() #[no_mangle] pub fn readonly_borrow_ret() -> &'static i32 { loop {} } -// CHECK: @static_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @static_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // static borrow may be captured #[no_mangle] pub fn static_borrow(_: &'static i32) { } -// CHECK: @named_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @named_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // borrow with named lifetime may be captured #[no_mangle] pub fn named_borrow<'r>(_: &'r i32) { } -// CHECK: @unsafe_borrow({{i16\*|ptr}} noundef nonnull align 2 %_1) +// CHECK: @unsafe_borrow(ptr noundef nonnull align 2 %_1) // unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_borrow(_: &UnsafeInner) { } -// CHECK: @mutable_unsafe_borrow({{i16\*|ptr}} noalias noundef align 2 dereferenceable(2) %_1) +// CHECK: @mutable_unsafe_borrow(ptr noalias noundef align 2 dereferenceable(2) %_1) // ... unless this is a mutable borrow, those never alias #[no_mangle] pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) { } -// CHECK: @mutable_borrow({{i32\*|ptr}} noalias noundef align 4 dereferenceable(4) %_1) +// CHECK: @mutable_borrow(ptr noalias noundef align 4 dereferenceable(4) %_1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_borrow(_: &mut i32) { } -// CHECK: noundef align 4 dereferenceable(4) {{i32\*|ptr}} @mutable_borrow_ret() +// CHECK: noundef align 4 dereferenceable(4) ptr @mutable_borrow_ret() #[no_mangle] pub fn mutable_borrow_ret() -> &'static mut i32 { loop {} } #[no_mangle] -// CHECK: @mutable_notunpin_borrow({{i32\*|ptr}} noundef nonnull align 4 %_1) +// CHECK: @mutable_notunpin_borrow(ptr noundef nonnull align 4 %_1) // This one is *not* `noalias` because it might be self-referential. // It is also not `dereferenceable` due to // . pub fn mutable_notunpin_borrow(_: &mut NotUnpin) { } -// CHECK: @notunpin_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable(4) %_1) +// CHECK: @notunpin_borrow(ptr noalias noundef readonly align 4 dereferenceable(4) %_1) // But `&NotUnpin` behaves perfectly normal. #[no_mangle] pub fn notunpin_borrow(_: &NotUnpin) { } -// CHECK: @indirect_struct({{%S\*|ptr}} noalias nocapture noundef readonly align 4 dereferenceable(32) %_1) +// CHECK: @indirect_struct(ptr noalias nocapture noundef readonly align 4 dereferenceable(32) %_1) #[no_mangle] pub fn indirect_struct(_: S) { } -// CHECK: @borrowed_struct({{%S\*|ptr}} noalias noundef readonly align 4 dereferenceable(32) %_1) +// CHECK: @borrowed_struct(ptr noalias noundef readonly align 4 dereferenceable(32) %_1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn borrowed_struct(_: &S) { } -// CHECK: @option_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable_or_null(4) %x) +// CHECK: @option_borrow(ptr noalias noundef readonly align 4 dereferenceable_or_null(4) %x) #[no_mangle] pub fn option_borrow(x: Option<&i32>) { } -// CHECK: @option_borrow_mut({{i32\*|ptr}} noalias noundef align 4 dereferenceable_or_null(4) %x) +// CHECK: @option_borrow_mut(ptr noalias noundef align 4 dereferenceable_or_null(4) %x) #[no_mangle] pub fn option_borrow_mut(x: Option<&mut i32>) { } -// CHECK: @raw_struct({{%S\*|ptr}} noundef %_1) +// CHECK: @raw_struct(ptr noundef %_1) #[no_mangle] pub fn raw_struct(_: *const S) { } -// CHECK: @raw_option_nonnull_struct({{i32\*|ptr}} noundef %_1) +// CHECK: @raw_option_nonnull_struct(ptr noundef %_1) #[no_mangle] pub fn raw_option_nonnull_struct(_: Option>) { } @@ -176,19 +176,19 @@ pub fn raw_option_nonnull_struct(_: Option>) { // `Box` can get deallocated during execution of the function, so it should // not get `dereferenceable`. -// CHECK: noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x) +// CHECK: noundef nonnull align 4 ptr @_box(ptr noalias noundef nonnull align 4 %x) #[no_mangle] pub fn _box(x: Box) -> Box { x } -// CHECK: noundef nonnull align 4 {{i32\*|ptr}} @notunpin_box({{i32\*|ptr}} noundef nonnull align 4 %x) +// CHECK: noundef nonnull align 4 ptr @notunpin_box(ptr noundef nonnull align 4 %x) #[no_mangle] pub fn notunpin_box(x: Box) -> Box { x } -// CHECK: @struct_return({{%S\*|ptr}} noalias nocapture noundef sret(%S) align 4 dereferenceable(32){{( %_0)?}}) +// CHECK: @struct_return(ptr noalias nocapture noundef sret(%S) align 4 dereferenceable(32){{( %_0)?}}) #[no_mangle] pub fn struct_return() -> S { S { @@ -202,68 +202,68 @@ pub fn struct_return() -> S { pub fn helper(_: usize) { } -// CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @slice(ptr noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn slice(_: &[u8]) { } -// CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @mutable_slice(ptr noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_slice(_: &mut [u8]) { } -// CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @unsafe_slice(ptr noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1) // unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_slice(_: &[UnsafeInner]) { } -// CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} noundef %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @raw_slice(ptr noundef %_1.0, [[USIZE]] noundef %_1.1) #[no_mangle] pub fn raw_slice(_: *const [u8]) { } -// CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) +// CHECK: @str(ptr noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn str(_: &[u8]) { } -// CHECK: @trait_borrow({{\{\}\*|ptr}} noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) +// CHECK: @trait_borrow(ptr noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn trait_borrow(_: &dyn Drop) { } -// CHECK: @option_trait_borrow({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +// CHECK: @option_trait_borrow(ptr noundef align 1 %x.0, ptr %x.1) #[no_mangle] pub fn option_trait_borrow(x: Option<&dyn Drop>) { } -// CHECK: @option_trait_borrow_mut({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +// CHECK: @option_trait_borrow_mut(ptr noundef align 1 %x.0, ptr %x.1) #[no_mangle] pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) { } -// CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) +// CHECK: @trait_raw(ptr noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) #[no_mangle] pub fn trait_raw(_: *const dyn Drop) { } -// CHECK: @trait_box({{\{\}\*|ptr}} noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) +// CHECK: @trait_box(ptr noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) #[no_mangle] pub fn trait_box(_: Box) { } -// CHECK: { {{i8\*|ptr}}, {{i8\*|ptr}} } @trait_option({{i8\*|ptr}} noalias noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +// CHECK: { ptr, ptr } @trait_option(ptr noalias noundef align 1 %x.0, ptr %x.1) #[no_mangle] pub fn trait_option(x: Option>) -> Option> { x } -// CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1) +// CHECK: { ptr, [[USIZE]] } @return_slice(ptr noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1) #[no_mangle] pub fn return_slice(x: &[u16]) -> &[u16] { x @@ -281,7 +281,7 @@ pub fn enum_id_2(x: Option) -> Option { x } -// CHECK: { {{\{\}\*|ptr}}, {{.+}} } @dyn_star({{\{\}\*|ptr}} noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1) +// CHECK: { ptr, {{.+}} } @dyn_star(ptr noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1) // Expect an ABI something like `{ {}*, [3 x i64]* }`, but that's hard to match on generically, // so do like the `trait_box` test and just match on `{{.+}}` for the vtable. #[no_mangle] diff --git a/tests/codegen/intrinsics/mask.rs b/tests/codegen/intrinsics/mask.rs index 8f93da2e5da4..82131c558472 100644 --- a/tests/codegen/intrinsics/mask.rs +++ b/tests/codegen/intrinsics/mask.rs @@ -7,6 +7,6 @@ #[no_mangle] pub fn mask_ptr(ptr: *const u16, mask: usize) -> *const u16 { // CHECK: call - // CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]]({{ptr|i8\*}} {{%ptr|%1}}, [[WORD]] %mask) + // CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]](ptr {{%ptr|%1}}, [[WORD]] %mask) core::intrinsics::ptr_mask(ptr, mask) } diff --git a/tests/codegen/intrinsics/nontemporal.rs b/tests/codegen/intrinsics/nontemporal.rs index d8ee29452662..dc020c121195 100644 --- a/tests/codegen/intrinsics/nontemporal.rs +++ b/tests/codegen/intrinsics/nontemporal.rs @@ -6,7 +6,7 @@ #[no_mangle] pub fn a(a: &mut u32, b: u32) { // CHECK-LABEL: define{{.*}}void @a - // CHECK: store i32 %b, {{i32\*|ptr}} %a, align 4, !nontemporal + // CHECK: store i32 %b, ptr %a, align 4, !nontemporal unsafe { std::intrinsics::nontemporal_store(a, b); } diff --git a/tests/codegen/issues/issue-37945.rs b/tests/codegen/issues/issue-37945.rs index 4f386d335c7d..329769940f9d 100644 --- a/tests/codegen/issues/issue-37945.rs +++ b/tests/codegen/issues/issue-37945.rs @@ -12,11 +12,11 @@ use std::slice::Iter; pub fn is_empty_1(xs: Iter) -> bool { // CHECK-LABEL: @is_empty_1( // CHECK-NEXT: start: -// CHECK-NEXT: [[A:%.*]] = icmp ne {{i32\*|ptr}} {{%xs.0|%xs.1}}, null +// CHECK-NEXT: [[A:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null // CHECK-NEXT: tail call void @llvm.assume(i1 [[A]]) // The order between %xs.0 and %xs.1 on the next line doesn't matter // and different LLVM versions produce different order. -// CHECK-NEXT: [[B:%.*]] = icmp eq {{i32\*|ptr}} {{%xs.0, %xs.1|%xs.1, %xs.0}} +// CHECK-NEXT: [[B:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}} // CHECK-NEXT: ret i1 [[B:%.*]] {xs}.next().is_none() } @@ -25,11 +25,11 @@ pub fn is_empty_1(xs: Iter) -> bool { pub fn is_empty_2(xs: Iter) -> bool { // CHECK-LABEL: @is_empty_2 // CHECK-NEXT: start: -// CHECK-NEXT: [[C:%.*]] = icmp ne {{i32\*|ptr}} {{%xs.0|%xs.1}}, null +// CHECK-NEXT: [[C:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null // CHECK-NEXT: tail call void @llvm.assume(i1 [[C]]) // The order between %xs.0 and %xs.1 on the next line doesn't matter // and different LLVM versions produce different order. -// CHECK-NEXT: [[D:%.*]] = icmp eq {{i32\*|ptr}} {{%xs.0, %xs.1|%xs.1, %xs.0}} +// CHECK-NEXT: [[D:%.*]] = icmp eq ptr {{%xs.0, %xs.1|%xs.1, %xs.0}} // CHECK-NEXT: ret i1 [[D:%.*]] xs.map(|&x| x).next().is_none() } diff --git a/tests/codegen/issues/issue-56267-2.rs b/tests/codegen/issues/issue-56267-2.rs index 4dc9ebfebbcd..1715e9f05ab5 100644 --- a/tests/codegen/issues/issue-56267-2.rs +++ b/tests/codegen/issues/issue-56267-2.rs @@ -11,7 +11,7 @@ pub struct Foo { // The load from bar.1 should have alignment 4. Not checking // other loads here, as the alignment will be platform-dependent. -// CHECK: %{{.+}} = load i32, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: %{{.+}} = load i32, ptr %{{.+}}, align 4 #[no_mangle] pub fn test(x: Foo<(i32, i32)>) -> (i32, i32) { x.bar diff --git a/tests/codegen/issues/issue-56267.rs b/tests/codegen/issues/issue-56267.rs index 7bdd25779983..90aa9f7ae899 100644 --- a/tests/codegen/issues/issue-56267.rs +++ b/tests/codegen/issues/issue-56267.rs @@ -11,7 +11,7 @@ pub struct Foo { // The store writing to bar.1 should have alignment 4. Not checking // other stores here, as the alignment will be platform-dependent. -// CHECK: store i32 [[TMP1:%.+]], {{i32\*|ptr}} [[TMP2:%.+]], align 4 +// CHECK: store i32 [[TMP1:%.+]], ptr [[TMP2:%.+]], align 4 #[no_mangle] pub fn test(x: (i32, i32)) -> Foo<(i32, i32)> { Foo { foo: 0, bar: x } diff --git a/tests/codegen/issues/issue-56927.rs b/tests/codegen/issues/issue-56927.rs index 044d721814bd..1b09ce565b37 100644 --- a/tests/codegen/issues/issue-56927.rs +++ b/tests/codegen/issues/issue-56927.rs @@ -8,10 +8,10 @@ pub struct S { } // CHECK-LABEL: @test1 -// CHECK: store i32 0, {{i32\*|ptr}} %{{.+}}, align 16 -// CHECK: store i32 1, {{i32\*|ptr}} %{{.+}}, align 4 -// CHECK: store i32 2, {{i32\*|ptr}} %{{.+}}, align 8 -// CHECK: store i32 3, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 0, ptr %{{.+}}, align 16 +// CHECK: store i32 1, ptr %{{.+}}, align 4 +// CHECK: store i32 2, ptr %{{.+}}, align 8 +// CHECK: store i32 3, ptr %{{.+}}, align 4 #[no_mangle] pub fn test1(s: &mut S) { s.arr[0] = 0; @@ -21,7 +21,7 @@ pub fn test1(s: &mut S) { } // CHECK-LABEL: @test2 -// CHECK: store i32 4, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 4, ptr %{{.+}}, align 4 #[allow(unconditional_panic)] #[no_mangle] pub fn test2(s: &mut S) { @@ -29,14 +29,14 @@ pub fn test2(s: &mut S) { } // CHECK-LABEL: @test3 -// CHECK: store i32 5, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 5, ptr %{{.+}}, align 4 #[no_mangle] pub fn test3(s: &mut S, i: usize) { s.arr[i] = 5; } // CHECK-LABEL: @test4 -// CHECK: store i32 6, {{i32\*|ptr}} %{{.+}}, align 4 +// CHECK: store i32 6, ptr %{{.+}}, align 4 #[no_mangle] pub fn test4(s: &mut S) { s.arr = [6; 4]; diff --git a/tests/codegen/issues/issue-58881.rs b/tests/codegen/issues/issue-58881.rs index 00f8953d9495..a1d0e8eb7e0c 100644 --- a/tests/codegen/issues/issue-58881.rs +++ b/tests/codegen/issues/issue-58881.rs @@ -16,6 +16,6 @@ struct Bar(u64, u64, u64); // Ensure that emit arguments of the correct type. pub unsafe fn test_call_variadic() { - // CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}}) + // CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, ptr {{.*}}) variadic_fn(0, Foo(0), Bar(0, 0, 0)) } diff --git a/tests/codegen/lifetime_start_end.rs b/tests/codegen/lifetime_start_end.rs index 471a0b8cedd7..16175dc18c20 100644 --- a/tests/codegen/lifetime_start_end.rs +++ b/tests/codegen/lifetime_start_end.rs @@ -8,7 +8,7 @@ pub fn test() { let a = 0u8; &a; // keep variable in an alloca -// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %a) +// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %a) { let b = &Some(a); @@ -26,9 +26,9 @@ pub fn test() { let c = 1u8; &c; // keep variable in an alloca -// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %c) +// CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %c) -// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %c) +// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %c) -// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{i8\*|ptr}} %a) +// CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %a) } diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs index f29a26596bfd..4a09a1dc0339 100644 --- a/tests/codegen/loads.rs +++ b/tests/codegen/loads.rs @@ -28,22 +28,22 @@ pub fn ptr_alignment_helper(x: &&()) {} // CHECK-LABEL: @load_ref #[no_mangle] pub fn load_ref<'a>(x: &&'a i32) -> &'a i32 { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_ref_higher_alignment #[no_mangle] pub fn load_ref_higher_alignment<'a>(x: &&'a Align16) -> &'a Align16 { - // CHECK: load {{%Align16\*|i128\*|ptr}}, {{%Align16\*\*|i128\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %x, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_scalar_pair #[no_mangle] pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16) { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} - // CHECK: load {{i64\*|ptr}}, {{i64\*\*|ptr}} %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %{{.+}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_16_META]], !noundef !{{[0-9]+}} *x } @@ -51,70 +51,70 @@ pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16 #[no_mangle] pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 { // loaded raw pointer should not have !nonnull or !align metadata - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef ![[NOUNDEF:[0-9]+]]{{$}} + // CHECK: load ptr, ptr %x, align [[PTR_ALIGNMENT]], !noundef ![[NOUNDEF:[0-9]+]]{{$}} *x } // CHECK-LABEL: @load_box #[no_mangle] pub fn load_box<'a>(x: Box>) -> Box { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} + // CHECK: load ptr, ptr %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_bool #[no_mangle] pub fn load_bool(x: &bool) -> bool { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1, !range ![[BOOL_RANGE:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load i8, ptr %x, align 1, !range ![[BOOL_RANGE:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_maybeuninit_bool #[no_mangle] pub fn load_maybeuninit_bool(x: &MaybeUninit) -> MaybeUninit { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1{{$}} + // CHECK: load i8, ptr %x, align 1{{$}} *x } // CHECK-LABEL: @load_enum_bool #[no_mangle] pub fn load_enum_bool(x: &MyBool) -> MyBool { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1, !range ![[BOOL_RANGE]], !noundef !{{[0-9]+}} + // CHECK: load i8, ptr %x, align 1, !range ![[BOOL_RANGE]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_maybeuninit_enum_bool #[no_mangle] pub fn load_maybeuninit_enum_bool(x: &MaybeUninit) -> MaybeUninit { - // CHECK: load i8, {{i8\*|ptr}} %x, align 1{{$}} + // CHECK: load i8, ptr %x, align 1{{$}} *x } // CHECK-LABEL: @load_int #[no_mangle] pub fn load_int(x: &u16) -> u16 { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef ![[NOUNDEF]]{{$}} + // CHECK: load i16, ptr %x, align 2, !noundef ![[NOUNDEF]]{{$}} *x } // CHECK-LABEL: @load_nonzero_int #[no_mangle] pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !range ![[NONZEROU16_RANGE:[0-9]+]], !noundef !{{[0-9]+}} + // CHECK: load i16, ptr %x, align 2, !range ![[NONZEROU16_RANGE:[0-9]+]], !noundef !{{[0-9]+}} *x } // CHECK-LABEL: @load_option_nonzero_int #[no_mangle] pub fn load_option_nonzero_int(x: &Option) -> Option { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef ![[NOUNDEF]]{{$}} + // CHECK: load i16, ptr %x, align 2, !noundef ![[NOUNDEF]]{{$}} *x } // CHECK-LABEL: @borrow #[no_mangle] pub fn borrow(x: &i32) -> &i32 { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x{{.*}}, !nonnull + // CHECK: load ptr, ptr %x{{.*}}, !nonnull &x; // keep variable in an alloca x } @@ -122,7 +122,7 @@ pub fn borrow(x: &i32) -> &i32 { // CHECK-LABEL: @_box #[no_mangle] pub fn _box(x: Box) -> i32 { - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x{{.*}}, align [[PTR_ALIGNMENT]] + // CHECK: load ptr, ptr %x{{.*}}, align [[PTR_ALIGNMENT]] *x } @@ -131,7 +131,7 @@ pub fn _box(x: Box) -> i32 { // dependent alignment #[no_mangle] pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] { - // CHECK: [[VAR:%[0-9]+]] = load i32, {{i32\*|ptr}} %{{.*}}, align 1 + // CHECK: [[VAR:%[0-9]+]] = load i32, ptr %{{.*}}, align 1 // CHECK: ret i32 [[VAR]] x } @@ -141,7 +141,7 @@ pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] { // dependent alignment #[no_mangle] pub fn small_struct_alignment(x: Bytes) -> Bytes { - // CHECK: [[VAR:%[0-9]+]] = load i32, {{i32\*|ptr}} %{{.*}}, align 1 + // CHECK: [[VAR:%[0-9]+]] = load i32, ptr %{{.*}}, align 1 // CHECK: ret i32 [[VAR]] x } diff --git a/tests/codegen/match-optimized.rs b/tests/codegen/match-optimized.rs index 59e6eeb7c5de..e32a5e545042 100644 --- a/tests/codegen/match-optimized.rs +++ b/tests/codegen/match-optimized.rs @@ -20,13 +20,13 @@ pub fn exhaustive_match(e: E) -> u8 { // CHECK-NEXT: unreachable // // CHECK: [[A]]: -// CHECK-NEXT: store i8 0, {{i8\*|ptr}} %_0, align 1 +// CHECK-NEXT: store i8 0, ptr %_0, align 1 // CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] // CHECK: [[B]]: -// CHECK-NEXT: store i8 1, {{i8\*|ptr}} %_0, align 1 +// CHECK-NEXT: store i8 1, ptr %_0, align 1 // CHECK-NEXT: br label %[[EXIT]] // CHECK: [[C]]: -// CHECK-NEXT: store i8 2, {{i8\*|ptr}} %_0, align 1 +// CHECK-NEXT: store i8 2, ptr %_0, align 1 // CHECK-NEXT: br label %[[EXIT]] match e { E::A => 0, diff --git a/tests/codegen/mem-replace-big-type.rs b/tests/codegen/mem-replace-big-type.rs index 55c2741faaf6..fc3e9d22bdf3 100644 --- a/tests/codegen/mem-replace-big-type.rs +++ b/tests/codegen/mem-replace-big-type.rs @@ -25,9 +25,9 @@ pub fn replace_big(dst: &mut Big, src: Big) -> Big { // For a large type, we expect exactly three `memcpy`s // CHECK-LABEL: define internal void @{{.+}}mem{{.+}}replace{{.+}}sret(%Big) // CHECK-NOT: call void @llvm.memcpy -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %result, {{i8\*|ptr}} align 8 %dest, i{{.*}} 56, i1 false) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr align 8 %result, ptr align 8 %dest, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %dest, {{i8\*|ptr}} align 8 %src, i{{.*}} 56, i1 false) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr align 8 %dest, ptr align 8 %src, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy // CHECK-NOT: call void @llvm.memcpy diff --git a/tests/codegen/move-operands.rs b/tests/codegen/move-operands.rs index df4fbe29ffdd..cd87e6d813ca 100644 --- a/tests/codegen/move-operands.rs +++ b/tests/codegen/move-operands.rs @@ -7,7 +7,7 @@ type T = [u8; 256]; #[no_mangle] pub fn f(a: T, b: fn(_: T, _: T)) { - // CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, {{.*}} 256, i1 false) - // CHECK-NOT: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, {{.*}} 256, i1 false) + // CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, {{.*}} 256, i1 false) + // CHECK-NOT: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, {{.*}} 256, i1 false) b(a, a) } diff --git a/tests/codegen/option-nonzero-eq.rs b/tests/codegen/option-nonzero-eq.rs index a394695f3bd6..ce5b6328af6c 100644 --- a/tests/codegen/option-nonzero-eq.rs +++ b/tests/codegen/option-nonzero-eq.rs @@ -32,7 +32,7 @@ pub fn non_zero_signed_eq(l: Option, r: Option) -> bool #[no_mangle] pub fn non_null_eq(l: Option>, r: Option>) -> bool { // CHECK: start: - // CHECK-NEXT: icmp eq {{(i8\*|ptr)}} + // CHECK-NEXT: icmp eq ptr // CHECK-NEXT: ret i1 l == r } diff --git a/tests/codegen/packed.rs b/tests/codegen/packed.rs index fd63b4f0acd5..96cd9a42e7dd 100644 --- a/tests/codegen/packed.rs +++ b/tests/codegen/packed.rs @@ -18,8 +18,8 @@ pub struct Packed2 { // CHECK-LABEL: @write_pkd1 #[no_mangle] pub fn write_pkd1(pkd: &mut Packed1) -> u32 { -// CHECK: %{{.*}} = load i32, {{i32\*|ptr}} %{{.*}}, align 1 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.*}}, align 1 +// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 1 +// CHECK: store i32 42, ptr %{{.*}}, align 1 let result = pkd.data; pkd.data = 42; result @@ -28,8 +28,8 @@ pub fn write_pkd1(pkd: &mut Packed1) -> u32 { // CHECK-LABEL: @write_pkd2 #[no_mangle] pub fn write_pkd2(pkd: &mut Packed2) -> u32 { -// CHECK: %{{.*}} = load i32, {{i32\*|ptr}} %{{.*}}, align 2 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.*}}, align 2 +// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 2 +// CHECK: store i32 42, ptr %{{.*}}, align 2 let result = pkd.data; pkd.data = 42; result @@ -52,8 +52,8 @@ pub struct BigPacked2 { #[no_mangle] pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 { // CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca %Array -// CHECK: call void %{{.*}}({{%Array\*|ptr}} noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) +// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) // check that calls whose destination is a field of a packed struct // go through an alloca rather than calling the function with an // unaligned destination. @@ -64,8 +64,8 @@ pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 { #[no_mangle] pub fn call_pkd2(f: fn() -> Array) -> BigPacked2 { // CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca %Array -// CHECK: call void %{{.*}}({{%Array\*|ptr}} noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 2 %{{.*}}, {{i8\*|ptr}} align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) +// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]]) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false) // check that calls whose destination is a field of a packed struct // go through an alloca rather than calling the function with an // unaligned destination. @@ -73,9 +73,9 @@ pub fn call_pkd2(f: fn() -> Array) -> BigPacked2 { } // CHECK-LABEL: @write_packed_array1 -// CHECK: store i32 0, {{i32\*|ptr}} %{{.+}}, align 1 -// CHECK: store i32 1, {{i32\*|ptr}} %{{.+}}, align 1 -// CHECK: store i32 2, {{i32\*|ptr}} %{{.+}}, align 1 +// CHECK: store i32 0, ptr %{{.+}}, align 1 +// CHECK: store i32 1, ptr %{{.+}}, align 1 +// CHECK: store i32 2, ptr %{{.+}}, align 1 #[no_mangle] pub fn write_packed_array1(p: &mut BigPacked1) { p.data.0[0] = 0; @@ -84,9 +84,9 @@ pub fn write_packed_array1(p: &mut BigPacked1) { } // CHECK-LABEL: @write_packed_array2 -// CHECK: store i32 0, {{i32\*|ptr}} %{{.+}}, align 2 -// CHECK: store i32 1, {{i32\*|ptr}} %{{.+}}, align 2 -// CHECK: store i32 2, {{i32\*|ptr}} %{{.+}}, align 2 +// CHECK: store i32 0, ptr %{{.+}}, align 2 +// CHECK: store i32 1, ptr %{{.+}}, align 2 +// CHECK: store i32 2, ptr %{{.+}}, align 2 #[no_mangle] pub fn write_packed_array2(p: &mut BigPacked2) { p.data.0[0] = 0; @@ -95,14 +95,14 @@ pub fn write_packed_array2(p: &mut BigPacked2) { } // CHECK-LABEL: @repeat_packed_array1 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.+}}, align 1 +// CHECK: store i32 42, ptr %{{.+}}, align 1 #[no_mangle] pub fn repeat_packed_array1(p: &mut BigPacked1) { p.data.0 = [42; 8]; } // CHECK-LABEL: @repeat_packed_array2 -// CHECK: store i32 42, {{i32\*|ptr}} %{{.+}}, align 2 +// CHECK: store i32 42, ptr %{{.+}}, align 2 #[no_mangle] pub fn repeat_packed_array2(p: &mut BigPacked2) { p.data.0 = [42; 8]; @@ -119,14 +119,14 @@ pub struct Packed2Pair(u8, u32); // CHECK-LABEL: @pkd1_pair #[no_mangle] pub fn pkd1_pair(pair1: &mut Packed1Pair, pair2: &mut Packed1Pair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{[0-9]+}} 5, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 5, i1 false) *pair2 = *pair1; } // CHECK-LABEL: @pkd2_pair #[no_mangle] pub fn pkd2_pair(pair1: &mut Packed2Pair, pair2: &mut Packed2Pair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 2 %{{.*}}, {{i8\*|ptr}} align 2 %{{.*}}, i{{[0-9]+}} 6, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 6, i1 false) *pair2 = *pair1; } @@ -141,13 +141,13 @@ pub struct Packed2NestedPair((u32, u32)); // CHECK-LABEL: @pkd1_nested_pair #[no_mangle] pub fn pkd1_nested_pair(pair1: &mut Packed1NestedPair, pair2: &mut Packed1NestedPair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{[0-9]+}} 8, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr align 1 %{{.*}}, i{{[0-9]+}} 8, i1 false) *pair2 = *pair1; } // CHECK-LABEL: @pkd2_nested_pair #[no_mangle] pub fn pkd2_nested_pair(pair1: &mut Packed2NestedPair, pair2: &mut Packed2NestedPair) { -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 2 %{{.*}}, {{i8\*|ptr}} align 2 %{{.*}}, i{{[0-9]+}} 8, i1 false) +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr align 2 %{{.*}}, i{{[0-9]+}} 8, i1 false) *pair2 = *pair1; } diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs index 9ff7a9b3e887..47243bece98f 100644 --- a/tests/codegen/personality_lifetimes.rs +++ b/tests/codegen/personality_lifetimes.rs @@ -22,7 +22,7 @@ pub fn test() { let _s = S; // Check that the personality slot alloca gets a lifetime start in each cleanup block, not just // in the first one. - // CHECK: [[SLOT:%[0-9]+]] = alloca { {{i8\*|ptr}}, i32 } + // CHECK: [[SLOT:%[0-9]+]] = alloca { ptr, i32 } // CHECK-LABEL: cleanup: // CHECK: call void @llvm.lifetime.start.{{.*}}({{.*}}) // CHECK-LABEL: cleanup1: diff --git a/tests/codegen/refs.rs b/tests/codegen/refs.rs index a52897667111..1c7746a3079b 100644 --- a/tests/codegen/refs.rs +++ b/tests/codegen/refs.rs @@ -13,9 +13,9 @@ pub fn helper(_: usize) { pub fn ref_dst(s: &[u8]) { // We used to generate an extra alloca and memcpy to ref the dst, so check that we copy // directly to the alloca for "x" -// CHECK: [[X0:%[0-9]+]] = getelementptr inbounds { {{\[0 x i8\]\*|ptr}}, [[USIZE]] }, {{.*}} %x, i32 0, i32 0 -// CHECK: store {{\[0 x i8\]\*|ptr}} %s.0, {{.*}} [[X0]] -// CHECK: [[X1:%[0-9]+]] = getelementptr inbounds { {{\[0 x i8\]\*|ptr}}, [[USIZE]] }, {{.*}} %x, i32 0, i32 1 +// CHECK: [[X0:%[0-9]+]] = getelementptr inbounds { ptr, [[USIZE]] }, {{.*}} %x, i32 0, i32 0 +// CHECK: store ptr %s.0, {{.*}} [[X0]] +// CHECK: [[X1:%[0-9]+]] = getelementptr inbounds { ptr, [[USIZE]] }, {{.*}} %x, i32 0, i32 1 // CHECK: store [[USIZE]] %s.1, {{.*}} [[X1]] let x = &*s; diff --git a/tests/codegen/repeat-trusted-len.rs b/tests/codegen/repeat-trusted-len.rs index d06978f24350..bd6ff977e1fe 100644 --- a/tests/codegen/repeat-trusted-len.rs +++ b/tests/codegen/repeat-trusted-len.rs @@ -8,13 +8,13 @@ use std::iter; // CHECK-LABEL: @repeat_take_collect #[no_mangle] pub fn repeat_take_collect() -> Vec { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}align 1{{.*}} %{{.*}}, i8 42, i{{[0-9]+}} 100000, i1 false) + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}align 1{{.*}} %{{.*}}, i8 42, i{{[0-9]+}} 100000, i1 false) iter::repeat(42).take(100000).collect() } // CHECK-LABEL: @repeat_with_take_collect #[no_mangle] pub fn repeat_with_take_collect() -> Vec { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}align 1{{.*}} %{{.*}}, i8 13, i{{[0-9]+}} 12345, i1 false) + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}align 1{{.*}} %{{.*}}, i8 13, i{{[0-9]+}} 12345, i1 false) iter::repeat_with(|| 13).take(12345).collect() } diff --git a/tests/codegen/repr-transparent-aggregates-1.rs b/tests/codegen/repr-transparent-aggregates-1.rs index ba3ba272efbb..c783a75a400a 100644 --- a/tests/codegen/repr-transparent-aggregates-1.rs +++ b/tests/codegen/repr-transparent-aggregates-1.rs @@ -36,19 +36,19 @@ pub enum TeBigS { Variant(BigS), } -// CHECK: define{{.*}}void @test_BigS({{%BigS\*|ptr}} [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], {{%BigS\*|ptr}} [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], ptr [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} } -// CHECK: define{{.*}}void @test_TsBigS({{%TsBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], {{%TsBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define{{.*}}void @test_TuBigS({{%TuBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], {{%TuBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define{{.*}}void @test_TeBigS({{%"TeBigS::Variant"\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], {{%"TeBigS::Variant"\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } @@ -72,18 +72,18 @@ pub enum TeBigU { Variant(BigU), } -// CHECK: define{{.*}}void @test_BigU({{%BigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], {{%BigU\*|ptr}} [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define{{.*}}void @test_TsBigU({{%TsBigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], {{%TsBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } -// CHECK: define{{.*}}void @test_TuBigU({{%TuBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], {{%TuBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } -// CHECK: define{{.*}}void @test_TeBigU({{%"TeBigU::Variant"\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], {{%"TeBigU::Variant"\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr-transparent-aggregates-2.rs b/tests/codegen/repr-transparent-aggregates-2.rs index a7bde2d05c3c..33f4f222b0af 100644 --- a/tests/codegen/repr-transparent-aggregates-2.rs +++ b/tests/codegen/repr-transparent-aggregates-2.rs @@ -37,19 +37,19 @@ pub enum TeBigS { Variant(BigS), } -// CHECK: define void @test_BigS({{%BigS\*|ptr}} [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [16 x i32] +// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [16 x i32] #[no_mangle] pub extern fn test_BigS(_: BigS) -> BigS { loop {} } -// CHECK: define void @test_TsBigS({{%TsBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define void @test_TuBigS({{%TuBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define void @test_TeBigS({{%"TeBigS::Variant"\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } @@ -73,18 +73,18 @@ pub enum TeBigU { Variant(BigU), } -// CHECK: define void @test_BigU({{%BigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [16 x i32] +// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [16 x i32] #[no_mangle] pub extern fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define void @test_TsBigU({{%TsBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } -// CHECK: define void @test_TuBigU({{%TuBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } -// CHECK: define void @test_TeBigU({{%"TeBigU::Variant"\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr-transparent.rs b/tests/codegen/repr-transparent.rs index 759ddea67a5b..64f3ce5a43ca 100644 --- a/tests/codegen/repr-transparent.rs +++ b/tests/codegen/repr-transparent.rs @@ -26,7 +26,7 @@ pub extern "C" fn test_F32(_: F32) -> F32 { loop {} } #[repr(transparent)] pub struct Ptr(*mut u8); -// CHECK: define{{.*}}{{i8\*|ptr}} @test_Ptr({{i8\*|ptr}} noundef %_1) +// CHECK: define{{.*}}ptr @test_Ptr(ptr noundef %_1) #[no_mangle] pub extern "C" fn test_Ptr(_: Ptr) -> Ptr { loop {} } @@ -41,7 +41,7 @@ pub extern "C" fn test_WithZst(_: WithZst) -> WithZst { loop {} } pub struct WithZeroSizedArray(*const f32, [i8; 0]); // Apparently we use i32* when newtype-unwrapping f32 pointers. Whatever. -// CHECK: define{{.*}}{{i32\*|ptr}} @test_WithZeroSizedArray({{i32\*|ptr}} noundef %_1) +// CHECK: define{{.*}}ptr @test_WithZeroSizedArray(ptr noundef %_1) #[no_mangle] pub extern "C" fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} } @@ -65,7 +65,7 @@ pub extern "C" fn test_Gpz(_: GenericPlusZst) -> GenericPlusZst { lo #[repr(transparent)] pub struct LifetimePhantom<'a, T: 'a>(*const T, PhantomData<&'a T>); -// CHECK: define{{.*}}{{i16\*|ptr}} @test_LifetimePhantom({{i16\*|ptr}} noundef %_1) +// CHECK: define{{.*}}ptr @test_LifetimePhantom(ptr noundef %_1) #[no_mangle] pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom) -> LifetimePhantom { loop {} } diff --git a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs index ec18fa9a328e..fdb9c6217de9 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs @@ -127,18 +127,18 @@ pub struct Large { d: i64, } -// CHECK: define void @f_agg_large({{%Large\*|ptr}} {{.*}}%x) +// CHECK: define void @f_agg_large(ptr {{.*}}%x) #[no_mangle] pub extern "C" fn f_agg_large(mut x: Large) { } -// CHECK: define void @f_agg_large_ret({{%Large\*|ptr}} {{.*}}sret{{.*}}, i32 noundef signext %i, i8 noundef signext %j) +// CHECK: define void @f_agg_large_ret(ptr {{.*}}sret{{.*}}, i32 noundef signext %i, i8 noundef signext %j) #[no_mangle] pub extern "C" fn f_agg_large_ret(i: i32, j: i8) -> Large { Large { a: 1, b: 2, c: 3, d: 4 } } -// CHECK: define void @f_scalar_stack_1(i64 %0, [2 x i64] %1, i128 %2, {{%Large\*|ptr}} {{.*}}%d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef %g, i8 noundef %h) +// CHECK: define void @f_scalar_stack_1(i64 %0, [2 x i64] %1, i128 %2, ptr {{.*}}%d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef %g, i8 noundef %h) #[no_mangle] pub extern "C" fn f_scalar_stack_1( a: Tiny, @@ -152,7 +152,7 @@ pub extern "C" fn f_scalar_stack_1( ) { } -// CHECK: define void @f_scalar_stack_2({{%Large\*|ptr}} {{.*}}sret{{.*}} %_0, i64 noundef %a, i128 %0, i128 %1, i64 noundef %d, i8 noundef zeroext %e, i8 noundef %f, i8 noundef %g) +// CHECK: define void @f_scalar_stack_2(ptr {{.*}}sret{{.*}} %_0, i64 noundef %a, i128 %0, i128 %1, i64 noundef %d, i8 noundef zeroext %e, i8 noundef %f, i8 noundef %g) #[no_mangle] pub extern "C" fn f_scalar_stack_2( a: u64, @@ -172,7 +172,7 @@ extern "C" { #[no_mangle] pub unsafe extern "C" fn f_va_caller() { - // CHECK: call noundef signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i64 noundef 3, double {{.*}}, double {{.*}}, i64 {{.*}}, [2 x i64] {{.*}}, i128 {{.*}}, {{%Large\*|ptr}} {{.*}}) + // CHECK: call noundef signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i64 noundef 3, double {{.*}}, double {{.*}}, i64 {{.*}}, [2 x i64] {{.*}}, i128 {{.*}}, ptr {{.*}}) f_va_callee( 1, 2i32, diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks.rs b/tests/codegen/sanitizer-cfi-emit-type-checks.rs index cea6aac8b8ba..f0fe5de9f66c 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-checks.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-checks.rs @@ -8,7 +8,7 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: start: - // CHECK: [[TT:%.+]] = call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"{{[[:print:]]+}}") + // CHECK: [[TT:%.+]] = call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"{{[[:print:]]+}}") // CHECK-NEXT: br i1 [[TT]], label %type_test.pass, label %type_test.fail // CHECK: type_test.pass: // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs index 78ef0c2c7d6b..d200ed9798a6 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs @@ -8,21 +8,21 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.generalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E.generalized") f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.generalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.generalized") f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.generalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.generalized") f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs index 3b72459c4b09..cdefec17a1c7 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs @@ -8,21 +8,21 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo // CHECK-SAME: {{.*}}![[TYPE1:[0-9]+]] - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized.generalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized.generalized") f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar // CHECK-SAME: {{.*}}![[TYPE2:[0-9]+]] - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized.generalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized.generalized") f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz // CHECK-SAME: {{.*}}![[TYPE3:[0-9]+]] - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized.generalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized.generalized") f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs index 9218e9947bfe..f360b33ddcf3 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs @@ -8,21 +8,21 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized") f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized") f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized") f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs index f9fd816dedb9..3cb817b212d1 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs @@ -8,21 +8,21 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_E") f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E") f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E") f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs index d24e416b67e9..b69e57261a8e 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs @@ -68,7 +68,7 @@ impl Trait5 for T { pub fn foo1(a: &dyn Trait1) { a.foo(); // CHECK-LABEL: define{{.*}}4foo1{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE1:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE1:[[:print:]]+]]") } pub fn bar1() { @@ -76,13 +76,13 @@ pub fn bar1() { let b = &a as &dyn Trait1; b.foo(); // CHECK-LABEL: define{{.*}}4bar1{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") } pub fn foo2(a: &dyn Trait2) { a.bar(); // CHECK-LABEL: define{{.*}}4foo2{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") } pub fn bar2() { @@ -91,14 +91,14 @@ pub fn bar2() { let b = &a as &dyn Trait2; b.bar(); // CHECK-LABEL: define{{.*}}4bar2{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") } pub fn foo3(a: &dyn Trait3) { let b = Type3; a.baz(&b); // CHECK-LABEL: define{{.*}}4foo3{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") } pub fn bar3() { @@ -107,14 +107,14 @@ pub fn bar3() { let b = &a as &dyn Trait3; b.baz(&a); // CHECK-LABEL: define{{.*}}4bar3{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") } pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { let b = Type4; a.qux(&b); // CHECK-LABEL: define{{.*}}4foo4{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") } pub fn bar4<'a>() { @@ -123,14 +123,14 @@ pub fn bar4<'a>() { let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; b.qux(&a); // CHECK-LABEL: define{{.*}}4bar4{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") } pub fn foo5(a: &dyn Trait5) { let b = &[Type5; 32]; a.quux(&b); // CHECK-LABEL: define{{.*}}4foo5{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE5:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE5:[[:print:]]+]]") } pub fn bar5() { @@ -139,7 +139,7 @@ pub fn bar5() { let b = &a as &dyn Trait5; b.quux(&a); // CHECK-LABEL: define{{.*}}4bar5{{.*}}!type !{{[0-9]+}} - // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE5:[[:print:]]+]]") + // CHECK: call i1 @llvm.type.test(ptr {{%f|%[0-9]}}, metadata !"[[TYPE5:[[:print:]]+]]") } // CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE1]]"} diff --git a/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs index 78ecc187b8e5..7aed137f215c 100644 --- a/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs @@ -93,7 +93,7 @@ impl Trait5 for T { pub fn foo1(a: &dyn Trait1) { a.foo(); // CHECK-LABEL: define{{.*}}4foo1{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] } pub fn bar1() { @@ -101,13 +101,13 @@ pub fn bar1() { let b = &a as &dyn Trait1; b.foo(); // CHECK-LABEL: define{{.*}}4bar1{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] } pub fn foo2(a: &dyn Trait2) { a.bar(); // CHECK-LABEL: define{{.*}}4foo2{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] } pub fn bar2() { @@ -116,14 +116,14 @@ pub fn bar2() { let b = &a as &dyn Trait2; b.bar(); // CHECK-LABEL: define{{.*}}4bar2{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] } pub fn foo3(a: &dyn Trait3) { let b = Type3; a.baz(&b); // CHECK-LABEL: define{{.*}}4foo3{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type3\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] } pub fn bar3() { @@ -132,14 +132,14 @@ pub fn bar3() { let b = &a as &dyn Trait3; b.baz(&a); // CHECK-LABEL: define{{.*}}4bar3{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type3\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] } pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { let b = Type4; a.qux(&b); // CHECK-LABEL: define{{.*}}4foo4{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call align 4 {{ptr|i32\*}} %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type4\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] + // CHECK: call align 4 ptr %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] } pub fn bar4<'a>() { @@ -148,14 +148,14 @@ pub fn bar4<'a>() { let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; b.qux(&a); // CHECK-LABEL: define{{.*}}4bar4{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call align 4 {{ptr|i32\*}} %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type4\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] + // CHECK: call align 4 ptr %{{[0-9]}}(ptr align 1 {{%[a-z]\.0|%_[0-9]}}, ptr align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] } pub fn foo5(a: &dyn Trait5) { let b = &[Type5; 32]; a.quux(&b); // CHECK-LABEL: define{{.*}}4foo5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, {{\{\}\*|ptr|\[32 x %Type5\]\*}} align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] } pub fn bar5() { @@ -164,7 +164,7 @@ pub fn bar5() { let b = &a as &dyn Trait5; b.quux(&a); // CHECK-LABEL: define{{.*}}4bar5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, {{\{\}\*|ptr|\[32 x %Type5\]\*}} align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] } // CHECK: !{{[0-9]+}} = !{i32 [[TYPE1]]} diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs index cacc32f2f1b6..7fe3ffd20860 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs @@ -23,7 +23,7 @@ extern "platform-intrinsic" { #[no_mangle] pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2, values: Vec2) -> Vec2 { - // CHECK: call <2 x float> @llvm.masked.gather.v2f32.{{.+}}(<2 x {{float\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float> {{.*}}) + // CHECK: call <2 x float> @llvm.masked.gather.v2f32.{{.+}}(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float> {{.*}}) simd_gather(values, pointers, mask) } @@ -31,6 +31,6 @@ pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2, #[no_mangle] pub unsafe fn gather_pf32x2(pointers: Vec2<*const *const f32>, mask: Vec2, values: Vec2<*const f32>) -> Vec2<*const f32> { - // CHECK: call <2 x {{float\*|ptr}}> @llvm.masked.gather.{{.+}}(<2 x {{float\*\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x {{float\*|ptr}}> {{.*}}) + // CHECK: call <2 x ptr> @llvm.masked.gather.{{.+}}(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x ptr> {{.*}}) simd_gather(values, pointers, mask) } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs index 94ecaf6096d5..5c917474e457 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs @@ -23,7 +23,7 @@ extern "platform-intrinsic" { #[no_mangle] pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2, values: Vec2) { - // CHECK: call void @llvm.masked.scatter.v2f32.v2p0{{.*}}(<2 x float> {{.*}}, <2 x {{float\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) + // CHECK: call void @llvm.masked.scatter.v2f32.v2p0{{.*}}(<2 x float> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) simd_scatter(values, pointers, mask) } @@ -32,6 +32,6 @@ pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2, #[no_mangle] pub unsafe fn scatter_pf32x2(pointers: Vec2<*mut *const f32>, mask: Vec2, values: Vec2<*const f32>) { - // CHECK: call void @llvm.masked.scatter.v2p0{{.*}}.v2p0{{.*}}(<2 x {{float\*|ptr}}> {{.*}}, <2 x {{float\*\*|ptr}}> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) + // CHECK: call void @llvm.masked.scatter.v2p0{{.*}}.v2p0{{.*}}(<2 x ptr> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) simd_scatter(values, pointers, mask) } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs index 3a0e37de2f3c..eb4ce307e70f 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs @@ -42,8 +42,8 @@ pub fn build_array_s(x: [f32; 4]) -> S<4> { // CHECK-LABEL: @build_array_transmute_s #[no_mangle] pub fn build_array_transmute_s(x: [f32; 4]) -> S<4> { - // CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], {{ptr %_0|.+>\* %.+}}, align [[VECTOR_ALIGN]] + // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } @@ -57,8 +57,8 @@ pub fn build_array_t(x: [f32; 4]) -> T { // CHECK-LABEL: @build_array_transmute_t #[no_mangle] pub fn build_array_transmute_t(x: [f32; 4]) -> T { - // CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], {{ptr %_0|.+>\* %.+}}, align [[VECTOR_ALIGN]] + // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } @@ -76,7 +76,7 @@ pub fn build_array_u(x: [f32; 4]) -> U { // CHECK-LABEL: @build_array_transmute_u #[no_mangle] pub fn build_array_transmute_u(x: [f32; 4]) -> U { - // CHECK: %[[VAL:.+]] = load <4 x float>, {{ptr %x|.+>\* %.+}}, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], {{ptr %_0|.+>\* %.+}}, align [[VECTOR_ALIGN]] + // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } diff --git a/tests/codegen/simd_arith_offset.rs b/tests/codegen/simd_arith_offset.rs index 74d7edc70d73..1ee73de1186f 100644 --- a/tests/codegen/simd_arith_offset.rs +++ b/tests/codegen/simd_arith_offset.rs @@ -21,6 +21,6 @@ pub struct Simd([T; LANES]); // CHECK-LABEL: smoke #[no_mangle] pub fn smoke(ptrs: SimdConstPtr, offsets: Simd) -> SimdConstPtr { - // CHECK: getelementptr i8, <8 x {{i8\*|ptr}}> %0, <8 x i64> %1 + // CHECK: getelementptr i8, <8 x ptr> %0, <8 x i64> %1 unsafe { simd_arith_offset(ptrs, offsets) } } diff --git a/tests/codegen/slice-init.rs b/tests/codegen/slice-init.rs index d80628cb1d46..c0bf1a04119b 100644 --- a/tests/codegen/slice-init.rs +++ b/tests/codegen/slice-init.rs @@ -23,7 +23,7 @@ pub fn zero_len_array() { // CHECK-LABEL: @byte_array #[no_mangle] pub fn byte_array() { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 7, i{{[0-9]+}} 4 + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}, i8 7, i{{[0-9]+}} 4 // CHECK-NOT: br label %repeat_loop_header{{.*}} let x = [7u8; 4]; opaque(&x); @@ -39,7 +39,7 @@ enum Init { // CHECK-LABEL: @byte_enum_array #[no_mangle] pub fn byte_enum_array() { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 {{.*}}, i{{[0-9]+}} 4 + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}, i8 {{.*}}, i{{[0-9]+}} 4 // CHECK-NOT: br label %repeat_loop_header{{.*}} let x = [Init::Memset; 4]; opaque(&x); @@ -48,7 +48,7 @@ pub fn byte_enum_array() { // CHECK-LABEL: @zeroed_integer_array #[no_mangle] pub fn zeroed_integer_array() { - // CHECK: call void @llvm.memset.{{.+}}({{i8\*|ptr}} {{.*}}, i8 0, i{{[0-9]+}} 16 + // CHECK: call void @llvm.memset.{{.+}}(ptr {{.*}}, i8 0, i{{[0-9]+}} 16 // CHECK-NOT: br label %repeat_loop_header{{.*}} let x = [0u32; 4]; opaque(&x); diff --git a/tests/codegen/slice-iter-len-eq-zero.rs b/tests/codegen/slice-iter-len-eq-zero.rs index efa7b6a9680a..c7515ce35a35 100644 --- a/tests/codegen/slice-iter-len-eq-zero.rs +++ b/tests/codegen/slice-iter-len-eq-zero.rs @@ -9,7 +9,7 @@ type Demo = [u8; 3]; #[no_mangle] pub fn slice_iter_len_eq_zero(y: std::slice::Iter<'_, Demo>) -> bool { // CHECK-NOT: sub - // CHECK: %[[RET:.+]] = icmp eq {{i8\*|ptr}} {{%1|%0}}, {{%1|%0}} + // CHECK: %[[RET:.+]] = icmp eq ptr {{%1|%0}}, {{%1|%0}} // CHECK: ret i1 %[[RET]] y.len() == 0 } diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index c91e5bc3cd0d..4d0dce7b0743 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -25,7 +25,7 @@ pub fn is_zero_slice_long(data: &[u8; 456]) -> bool { // CHECK-LABEL: @is_zero_slice_short #[no_mangle] pub fn is_zero_slice_short(data: &[u8; 4]) -> bool { - // CHECK: %[[LOAD:.+]] = load i32, {{i32\*|ptr}} %{{.+}}, align 1 + // CHECK: %[[LOAD:.+]] = load i32, ptr %{{.+}}, align 1 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[LOAD]], 0 // CHECK-NEXT: ret i1 %[[EQ]] &data[..] == [0; 4] @@ -34,7 +34,7 @@ pub fn is_zero_slice_short(data: &[u8; 4]) -> bool { // CHECK-LABEL: @is_zero_array #[no_mangle] pub fn is_zero_array(data: &[u8; 4]) -> bool { - // CHECK: %[[LOAD:.+]] = load i32, {{i32\*|ptr}} %{{.+}}, align 1 + // CHECK: %[[LOAD:.+]] = load i32, ptr %{{.+}}, align 1 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[LOAD]], 0 // CHECK-NEXT: ret i1 %[[EQ]] *data == [0; 4] @@ -50,7 +50,7 @@ pub fn is_zero_array(data: &[u8; 4]) -> bool { fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool { // CHECK: icmp eq [[USIZE]] %x.1, %y.1 // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %x.1, 3 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i8\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } @@ -62,7 +62,7 @@ fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool { fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { // CHECK: icmp eq [[USIZE]] %x.1, %y.1 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i32\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } @@ -74,7 +74,7 @@ fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { // CHECK: icmp eq [[USIZE]] %x.1, %y.1 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 2 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i32\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } @@ -86,7 +86,7 @@ fn eq_slice_of_nonzero(x: &[NonZeroU32], y: &[NonZeroU32]) -> bool { fn eq_slice_of_option_of_nonzero(x: &[Option], y: &[Option]) -> bool { // CHECK: icmp eq [[USIZE]] %x.1, %y.1 // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %x.1, 1 - // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}({{i16\*|ptr}} + // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } diff --git a/tests/codegen/stores.rs b/tests/codegen/stores.rs index 837256e53694..a8e155c4c8a4 100644 --- a/tests/codegen/stores.rs +++ b/tests/codegen/stores.rs @@ -17,8 +17,8 @@ pub struct Bytes { pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) { // CHECK: [[TMP:%.+]] = alloca i32 // CHECK: %y = alloca [4 x i8] -// CHECK: store i32 %0, {{i32\*|ptr}} [[TMP]] -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 {{.+}}, {{i8\*|ptr}} align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) +// CHECK: store i32 %0, ptr [[TMP]] +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) *x = y; } @@ -29,7 +29,7 @@ pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) { pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) { // CHECK: [[TMP:%.+]] = alloca i32 // CHECK: %y = alloca %Bytes -// CHECK: store i32 %0, {{i32\*|ptr}} [[TMP]] -// CHECK: call void @llvm.memcpy.{{.*}}({{i8\*|ptr}} align 1 {{.+}}, {{i8\*|ptr}} align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) +// CHECK: store i32 %0, ptr [[TMP]] +// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 {{.+}}, ptr align 4 {{.+}}, i{{[0-9]+}} 4, i1 false) *x = y; } diff --git a/tests/codegen/swap-large-types.rs b/tests/codegen/swap-large-types.rs index 4a68403578d1..7b6611f3da43 100644 --- a/tests/codegen/swap-large-types.rs +++ b/tests/codegen/swap-large-types.rs @@ -83,9 +83,9 @@ pub struct BigButHighlyAligned([u8; 64 * 3]); #[no_mangle] pub fn swap_big_aligned(x: &mut BigButHighlyAligned, y: &mut BigButHighlyAligned) { // CHECK-NOT: call void @llvm.memcpy -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} noundef nonnull align 64 dereferenceable(192) -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} noundef nonnull align 64 dereferenceable(192) -// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} noundef nonnull align 64 dereferenceable(192) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192) +// CHECK: call void @llvm.memcpy.{{.+}}(ptr noundef nonnull align 64 dereferenceable(192) // CHECK-NOT: call void @llvm.memcpy swap(x, y) } diff --git a/tests/codegen/union-abi.rs b/tests/codegen/union-abi.rs index 653c5837daf0..4878ae5c3b68 100644 --- a/tests/codegen/union-abi.rs +++ b/tests/codegen/union-abi.rs @@ -17,25 +17,25 @@ pub struct i64x4(i64, i64, i64, i64); #[derive(Copy, Clone)] pub union UnionI64x4{ a:(), b: i64x4 } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4({{<4 x i64>\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4(_: UnionI64x4) { loop {} } pub union UnionI64x4_{ a: i64x4, b: (), c:i64x4, d: Unhab, e: ((),()), f: UnionI64x4 } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_({{<4 x i64>\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4_(_: UnionI64x4_) { loop {} } pub union UnionI64x4I64{ a: i64x4, b: i64 } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64({{%UnionI64x4I64\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} } pub union UnionI64x4Tuple{ a: i64x4, b: (i64, i64, i64, i64) } -// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple({{%UnionI64x4Tuple\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple(ptr {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} } @@ -65,7 +65,7 @@ pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} } #[repr(C)] pub union CUnionU128{a:u128} -// CHECK: define {{(dso_local )?}}void @test_CUnionU128({{%CUnionU128\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_CUnionU128(ptr {{.*}} %_1) #[no_mangle] pub fn test_CUnionU128(_: CUnionU128) { loop {} } diff --git a/tests/codegen/vec-as-ptr.rs b/tests/codegen/vec-as-ptr.rs index 8ff7ba9cb64c..76098bc08a31 100644 --- a/tests/codegen/vec-as-ptr.rs +++ b/tests/codegen/vec-as-ptr.rs @@ -4,7 +4,7 @@ // Test that even though we return a *const u8 not a &[u8] or a NonNull, LLVM knows that this // pointer is nonnull. -// CHECK: nonnull {{i8\*|ptr}} @vec_as_ptr +// CHECK: nonnull ptr @vec_as_ptr #[no_mangle] pub fn vec_as_ptr(v: &Vec) -> *const u8 { v.as_ptr() @@ -12,7 +12,7 @@ pub fn vec_as_ptr(v: &Vec) -> *const u8 { // Test that even though we return a *const u8 not a &[u8] or a NonNull, LLVM knows that this // pointer is nonnull. -// CHECK: nonnull {{i8\*|ptr}} @vec_as_mut_ptr +// CHECK: nonnull ptr @vec_as_mut_ptr #[no_mangle] pub fn vec_as_mut_ptr(v: &mut Vec) -> *mut u8 { v.as_mut_ptr() diff --git a/tests/run-make/coverage-llvmir/filecheck.testprog.txt b/tests/run-make/coverage-llvmir/filecheck.testprog.txt index b3a8808df052..9d63fabd788b 100644 --- a/tests/run-make/coverage-llvmir/filecheck.testprog.txt +++ b/tests/run-make/coverage-llvmir/filecheck.testprog.txt @@ -39,10 +39,10 @@ CHECK-NOT: [[DEFINE_INTERNAL]] CHECK: atomicrmw add ptr CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, -CHECK: declare void @llvm.instrprof.increment({{i8\*|ptr}}, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] +CHECK: declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] WINDOWS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() #[[LLVM_PROFILE_RUNTIME_USER_ATTR:[0-9]+]] comdat { -WINDOWS-NEXT: %1 = load i32, {{i32\*|ptr}} @__llvm_profile_runtime +WINDOWS-NEXT: %1 = load i32, ptr @__llvm_profile_runtime WINDOWS-NEXT: ret i32 %1 WINDOWS-NEXT: } diff --git a/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt b/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt index e19c78350e9d..2b058faafcb9 100644 --- a/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt +++ b/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt @@ -2,7 +2,7 @@ CHECK: define void @call_a_bunch_of_functions({{.*}} { # Make sure that indirect call promotion inserted a check against the most # frequently called function. -CHECK: %{{.*}} = icmp eq {{void \(\)\*|ptr}} %{{.*}}, @function_called_always +CHECK: %{{.*}} = icmp eq ptr %{{.*}}, @function_called_always # Check that the call to `function_called_always` was inlined, so that we # directly call `opaque_f1` from the upstream crate. @@ -12,5 +12,5 @@ CHECK: call void @opaque_f1() # Same checks as above, repeated for the trait object case CHECK: define void @call_a_bunch_of_trait_methods({{.*}} -CHECK: %{{.*}} = icmp eq {{void \(\{\}\*\)\*|ptr}} %{{.*}}, {{.*}}@foo +CHECK: %{{.*}} = icmp eq ptr %{{.*}}, {{.*}}@foo CHECK: tail call void @opaque_f2() From 0ae0643a5353da7b79e53a11beca93ceeea067d5 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 22:04:19 +0000 Subject: [PATCH 108/150] Skip reporting item name when checking RPITIT GAT's associated type bounds hold --- .../src/infer/error_reporting/note.rs | 18 +++++++---- .../in-trait/bad-item-bound-within-rpitit.rs | 25 ++++++++++++++++ .../bad-item-bound-within-rpitit.stderr | 30 +++++++++++++++++++ 3 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index 7144084c78eb..8cd1b82130b0 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -243,12 +243,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } infer::CheckAssociatedTypeBounds { impl_item_def_id, trait_item_def_id, parent } => { let mut err = self.report_concrete_failure(*parent, sub, sup); - let trait_item_span = self.tcx.def_span(trait_item_def_id); - let item_name = self.tcx.item_name(impl_item_def_id.to_def_id()); - err.span_label( - trait_item_span, - format!("definition of `{}` from trait", item_name), - ); + + // Don't mention the item name if it's an RPITIT, since that'll just confuse + // folks. + if !self.tcx.is_impl_trait_in_trait(impl_item_def_id.to_def_id()) { + let trait_item_span = self.tcx.def_span(trait_item_def_id); + let item_name = self.tcx.item_name(impl_item_def_id.to_def_id()); + err.span_label( + trait_item_span, + format!("definition of `{}` from trait", item_name), + ); + } + self.suggest_copy_trait_method_bounds( trait_item_def_id, impl_item_def_id, diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs new file mode 100644 index 000000000000..8b97336fe0c6 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs @@ -0,0 +1,25 @@ +// issue: 114145 + +#![feature(return_position_impl_trait_in_trait)] + +trait Iterable { + type Item<'a> + where + Self: 'a; + + fn iter(&self) -> impl '_ + Iterator>; +} + +impl<'a, I: 'a + Iterable> Iterable for &'a I { + type Item<'b> = I::Item<'a> + where + 'b: 'a; + //~^ ERROR impl has stricter requirements than trait + + fn iter(&self) -> impl 'a + Iterator> { + //~^ ERROR the type `&'a I` does not fulfill the required lifetime + (*self).iter() + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr new file mode 100644 index 000000000000..1e3363268f06 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr @@ -0,0 +1,30 @@ +error[E0276]: impl has stricter requirements than trait + --> $DIR/bad-item-bound-within-rpitit.rs:16:13 + | +LL | type Item<'a> + | ------------- definition of `Item` from trait +... +LL | 'b: 'a; + | ^^ impl has extra requirement `'b: 'a` + | +help: copy the `where` clause predicates from the trait + | +LL | where Self: 'b; + | ~~~~~~~~~~~~~~ + +error[E0477]: the type `&'a I` does not fulfill the required lifetime + --> $DIR/bad-item-bound-within-rpitit.rs:19:5 + | +LL | fn iter(&self) -> impl 'a + Iterator> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must outlive the anonymous lifetime as defined here + --> $DIR/bad-item-bound-within-rpitit.rs:10:28 + | +LL | fn iter(&self) -> impl '_ + Iterator>; + | ^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0276, E0477. +For more information about an error, try `rustc --explain E0276`. From bf38111ac1ad499d592b9f9ef9ae28e947c1c587 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 22:20:32 +0000 Subject: [PATCH 109/150] tighten span slightly for synthetic item --- compiler/rustc_ty_utils/src/assoc.rs | 12 ++++++++++-- .../in-trait/bad-item-bound-within-rpitit.stderr | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 4a5442321742..780f7ea426f7 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -346,8 +346,16 @@ fn associated_type_for_impl_trait_in_impl( ) -> LocalDefId { let impl_local_def_id = tcx.local_parent(impl_fn_def_id); - // FIXME fix the span, we probably want the def_id of the return type of the function - let span = tcx.def_span(impl_fn_def_id); + let decl = tcx + .hir() + .find_by_def_id(impl_fn_def_id) + .expect("expected item") + .fn_decl() + .expect("expected decl"); + let span = match decl.output { + hir::FnRetTy::DefaultReturn(_) => tcx.def_span(impl_fn_def_id), + hir::FnRetTy::Return(ty) => ty.span, + }; let impl_assoc_ty = tcx.at(span).create_def(impl_local_def_id, DefPathData::ImplTraitAssocTy); let local_def_id = impl_assoc_ty.def_id(); diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr index 1e3363268f06..54a08c5b516c 100644 --- a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr @@ -13,10 +13,10 @@ LL | where Self: 'b; | ~~~~~~~~~~~~~~ error[E0477]: the type `&'a I` does not fulfill the required lifetime - --> $DIR/bad-item-bound-within-rpitit.rs:19:5 + --> $DIR/bad-item-bound-within-rpitit.rs:19:23 | LL | fn iter(&self) -> impl 'a + Iterator> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must outlive the anonymous lifetime as defined here --> $DIR/bad-item-bound-within-rpitit.rs:10:28 From a4ac773f62aa0992c4c525b9291302a93b352cc3 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 22:32:53 +0000 Subject: [PATCH 110/150] Insert RPITITs that were shadowed by missing ADTs that resolve to type error --- .../src/check/compare_impl_item.rs | 26 ++++++++++++++++--- .../rpitit-shadowed-by-missing-adt.rs | 18 +++++++++++++ .../rpitit-shadowed-by-missing-adt.stderr | 9 +++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs create mode 100644 tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 0a6e2e644eb2..3adbdcedbfb7 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -760,7 +760,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( ); ocx.resolve_regions_and_report_errors(impl_m_def_id, &outlives_env)?; - let mut collected_tys = FxHashMap::default(); + let mut remapped_types = FxHashMap::default(); for (def_id, (ty, args)) in collected_types { match infcx.fully_resolve((ty, args)) { Ok((ty, args)) => { @@ -810,19 +810,37 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( Ok(ty) => ty, Err(guar) => Ty::new_error(tcx, guar), }; - collected_tys.insert(def_id, ty::EarlyBinder::bind(ty)); + remapped_types.insert(def_id, ty::EarlyBinder::bind(ty)); } Err(err) => { let reported = tcx.sess.delay_span_bug( return_span, format!("could not fully resolve: {ty} => {err:?}"), ); - collected_tys.insert(def_id, ty::EarlyBinder::bind(Ty::new_error(tcx, reported))); + remapped_types.insert(def_id, ty::EarlyBinder::bind(Ty::new_error(tcx, reported))); } } } - Ok(&*tcx.arena.alloc(collected_tys)) + // We may not collect all RPITITs that we see in the HIR for a trait signature + // because an RPITIT was located within a missing item. Like if we have a sig + // returning `-> Missing`, that gets converted to `-> [type error]`, + // and when walking through the signature we end up never collecting the def id + // of the `impl Sized`. Insert that here, so we don't ICE later. + for assoc_item in tcx.associated_types_for_impl_traits_in_associated_fn(trait_m.def_id) { + if !remapped_types.contains_key(assoc_item) { + remapped_types.insert( + *assoc_item, + ty::EarlyBinder::bind(Ty::new_error_with_message( + tcx, + return_span, + "missing synthetic item for RPITIT", + )), + ); + } + } + + Ok(&*tcx.arena.alloc(remapped_types)) } struct ImplTraitInTraitCollector<'a, 'tcx> { diff --git a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs new file mode 100644 index 000000000000..7682884f8793 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs @@ -0,0 +1,18 @@ +// issue: 113903 + +#![feature(return_position_impl_trait_in_trait)] + +use std::ops::Deref; + +pub trait Tr { + fn w() -> impl Deref>; + //~^ ERROR cannot find type `Missing` in this scope +} + +impl Tr for () { + fn w() -> &'static () { + &() + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr new file mode 100644 index 000000000000..6e4a5bb5df36 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/rpitit-shadowed-by-missing-adt.rs:8:35 + | +LL | fn w() -> impl Deref>; + | ^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. From ea2f8b346b09c474d620ada38e4a0cb9f75e0b5f Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 22:50:40 +0000 Subject: [PATCH 111/150] Add additional test --- .../bad-item-bound-within-rpitit-2.rs | 11 +++++++ .../bad-item-bound-within-rpitit-2.stderr | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs create mode 100644 tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs new file mode 100644 index 000000000000..3a93dfee57f3 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs @@ -0,0 +1,11 @@ +// issue: 114146 + +#![feature(return_position_impl_trait_in_trait)] + +trait Foo { + fn bar<'other: 'a>() -> impl Sized + 'a {} + //~^ ERROR use of undeclared lifetime name `'a` + //~| ERROR use of undeclared lifetime name `'a` +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr new file mode 100644 index 000000000000..3a1f8f908374 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr @@ -0,0 +1,33 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/bad-item-bound-within-rpitit-2.rs:6:20 + | +LL | fn bar<'other: 'a>() -> impl Sized + 'a {} + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn bar<'a, 'other: 'a>() -> impl Sized + 'a {} + | +++ +help: consider introducing lifetime `'a` here + | +LL | trait Foo<'a> { + | ++++ + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/bad-item-bound-within-rpitit-2.rs:6:42 + | +LL | fn bar<'other: 'a>() -> impl Sized + 'a {} + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn bar<'a, 'other: 'a>() -> impl Sized + 'a {} + | +++ +help: consider introducing lifetime `'a` here + | +LL | trait Foo<'a> { + | ++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0261`. From 683b2656bfef8d6ef317427cd9eb027f120ecc30 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Wed, 26 Jul 2023 19:32:39 +0000 Subject: [PATCH 112/150] Refactor `suggest_copied_cloned_or_as_ref` --- compiler/rustc_hir_typeck/messages.ftl | 4 + compiler/rustc_hir_typeck/src/errors.rs | 39 ++++++ .../src/fn_ctxt/suggestions.rs | 114 +++++++----------- .../dont-suggest-cyclic-constraint.stderr | 2 +- tests/ui/suggestions/copied-and-cloned.fixed | 2 +- tests/ui/suggestions/copied-and-cloned.rs | 2 +- tests/ui/suggestions/copied-and-cloned.stderr | 2 +- 7 files changed, 93 insertions(+), 72 deletions(-) diff --git a/compiler/rustc_hir_typeck/messages.ftl b/compiler/rustc_hir_typeck/messages.ftl index 3d012a15a675..2281343e250b 100644 --- a/compiler/rustc_hir_typeck/messages.ftl +++ b/compiler/rustc_hir_typeck/messages.ftl @@ -77,6 +77,10 @@ hir_typeck_note_edition_guide = for more on editions, read https://doc.rust-lang hir_typeck_op_trait_generic_params = `{$method_name}` must not have any generic parameters +hir_typeck_option_result_asref = use `{$def_path}::as_ref` to convert `{$expected_ty}` to `{$expr_ty}` +hir_typeck_option_result_cloned = use `{$def_path}::cloned` to clone the value inside the `{$def_path}` +hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value inside the `{$def_path}` + hir_typeck_return_stmt_outside_of_fn_body = {$statement_kind} statement outside of function body .encl_body_label = the {$statement_kind} is part of this body... diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 05906a4b9f59..36096aa35d4c 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -252,6 +252,45 @@ impl HelpUseLatestEdition { } } +#[derive(Subdiagnostic)] +pub enum OptionResultRefMismatch<'tcx> { + #[suggestion( + hir_typeck_option_result_copied, + code = ".copied()", + style = "verbose", + applicability = "machine-applicable" + )] + Copied { + #[primary_span] + span: Span, + def_path: String, + }, + #[suggestion( + hir_typeck_option_result_cloned, + code = ".cloned()", + style = "verbose", + applicability = "machine-applicable" + )] + Cloned { + #[primary_span] + span: Span, + def_path: String, + }, + #[suggestion( + hir_typeck_option_result_asref, + code = ".as_ref()", + style = "verbose", + applicability = "machine-applicable" + )] + AsRef { + #[primary_span] + span: Span, + def_path: String, + expected_ty: Ty<'tcx>, + expr_ty: Ty<'tcx>, + }, +} + #[derive(Diagnostic)] #[diag(hir_typeck_const_select_must_be_const)] #[help] diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 4a1cbaceaf7e..ff715a1999de 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -1,8 +1,6 @@ use super::FnCtxt; -use crate::errors::{ - AddReturnTypeSuggestion, ExpectedReturnTypeLabel, SuggestBoxing, SuggestConvertViaMethod, -}; +use crate::errors; use crate::fluent_generated as fluent; use crate::method::probe::{IsSuggestion, Mode, ProbeScope}; use rustc_ast::util::parser::{ExprPrecedence, PREC_POSTFIX}; @@ -434,7 +432,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // FIXME: This could/should be extended to suggest `as_mut` and `as_deref_mut`, // but those checks need to be a bit more delicate and the benefit is diminishing. if self.can_eq(self.param_env, found_ty_inner, peeled) && error_tys_equate_as_ref { - err.subdiagnostic(SuggestConvertViaMethod { + err.subdiagnostic(errors::SuggestConvertViaMethod { span: expr.span.shrink_to_hi(), sugg: ".as_ref()", expected, @@ -447,7 +445,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && self.can_eq(self.param_env, deref_ty, peeled) && error_tys_equate_as_ref { - err.subdiagnostic(SuggestConvertViaMethod { + err.subdiagnostic(errors::SuggestConvertViaMethod { span: expr.span.shrink_to_hi(), sugg: ".as_deref()", expected, @@ -521,7 +519,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.can_coerce(Ty::new_box(self.tcx, found), expected) { let suggest_boxing = match found.kind() { ty::Tuple(tuple) if tuple.is_empty() => { - SuggestBoxing::Unit { start: span.shrink_to_lo(), end: span } + errors::SuggestBoxing::Unit { start: span.shrink_to_lo(), end: span } } ty::Generator(def_id, ..) if matches!( @@ -529,9 +527,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some(GeneratorKind::Async(AsyncGeneratorKind::Closure)) ) => { - SuggestBoxing::AsyncBody + errors::SuggestBoxing::AsyncBody } - _ => SuggestBoxing::Other { start: span.shrink_to_lo(), end: span.shrink_to_hi() }, + _ => errors::SuggestBoxing::Other { + start: span.shrink_to_lo(), + end: span.shrink_to_hi(), + }, }; err.subdiagnostic(suggest_boxing); @@ -756,23 +757,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match &fn_decl.output { &hir::FnRetTy::DefaultReturn(span) if expected.is_unit() && !can_suggest => { // `fn main()` must return `()`, do not suggest changing return type - err.subdiagnostic(ExpectedReturnTypeLabel::Unit { span }); + err.subdiagnostic(errors::ExpectedReturnTypeLabel::Unit { span }); return true; } &hir::FnRetTy::DefaultReturn(span) if expected.is_unit() => { if let Some(found) = found.make_suggestable(self.tcx, false) { - err.subdiagnostic(AddReturnTypeSuggestion::Add { span, found: found.to_string() }); + err.subdiagnostic(errors::AddReturnTypeSuggestion::Add { span, found: found.to_string() }); return true; } else if let ty::Closure(_, args) = found.kind() // FIXME(compiler-errors): Get better at printing binders... && let closure = args.as_closure() && closure.sig().is_suggestable(self.tcx, false) { - err.subdiagnostic(AddReturnTypeSuggestion::Add { span, found: closure.print_as_impl_trait().to_string() }); + err.subdiagnostic(errors::AddReturnTypeSuggestion::Add { span, found: closure.print_as_impl_trait().to_string() }); return true; } else { // FIXME: if `found` could be `impl Iterator` we should suggest that. - err.subdiagnostic(AddReturnTypeSuggestion::MissingHere { span }); + err.subdiagnostic(errors::AddReturnTypeSuggestion::MissingHere { span }); return true } } @@ -794,10 +795,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!(?found); if found.is_suggestable(self.tcx, false) { if term.span.is_empty() { - err.subdiagnostic(AddReturnTypeSuggestion::Add { span, found: found.to_string() }); + err.subdiagnostic(errors::AddReturnTypeSuggestion::Add { span, found: found.to_string() }); return true; } else { - err.subdiagnostic(ExpectedReturnTypeLabel::Other { span, expected }); + err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span, expected }); } } } @@ -813,7 +814,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ty = self.normalize(span, ty); let ty = self.tcx.erase_late_bound_regions(ty); if self.can_coerce(expected, ty) { - err.subdiagnostic(ExpectedReturnTypeLabel::Other { span, expected }); + err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span, expected }); self.try_suggest_return_impl_trait(err, expected, ty, fn_id); return true; } @@ -1103,65 +1104,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } - let mut suggest_copied_cloned_or_as_ref = || { + if Some(adt_def.did()) == self.tcx.get_diagnostic_item(sym::Result) + && self.can_eq(self.param_env, args.type_at(1), expected_args.type_at(1)) + || Some(adt_def.did()) == self.tcx.get_diagnostic_item(sym::Option) + { let expr_inner_ty = args.type_at(0); let expected_inner_ty = expected_args.type_at(0); if let &ty::Ref(_, ty, hir::Mutability::Not) = expr_inner_ty.kind() - && self.can_eq(self.param_env, ty, expected_inner_ty) - { - let def_path = self.tcx.def_path_str(adt_def.did()); - if self.type_is_copy_modulo_regions(self.param_env, ty) { - diag.span_suggestion_verbose( - expr.span.shrink_to_hi(), - format!( - "use `{def_path}::copied` to copy the value inside the `{def_path}`" - ), - ".copied()", - Applicability::MachineApplicable, - ); - return true; - } else if let Some(expected_ty_expr) = expected_ty_expr { - diag.span_suggestion_verbose( - expected_ty_expr.span.shrink_to_hi(), - format!( - "use `{def_path}::as_ref()` to convert `{expected_ty}` to `{expr_ty}`" - ), - ".as_ref()", - Applicability::MachineApplicable, - ); - return true; - } else if let Some(clone_did) = self.tcx.lang_items().clone_trait() - && rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions( - self, - self.param_env, - ty, - clone_did, - ) + && self.can_eq(self.param_env, ty, expected_inner_ty) { - diag.span_suggestion_verbose( - expr.span.shrink_to_hi(), - format!( - "use `{def_path}::cloned` to clone the value inside the `{def_path}`" - ), - ".cloned()", - Applicability::MachineApplicable, - ); + let def_path = self.tcx.def_path_str(adt_def.did()); + let span = expr.span.shrink_to_hi(); + let subdiag = if self.type_is_copy_modulo_regions(self.param_env, ty) { + errors::OptionResultRefMismatch::Copied { + span, def_path + } + } else if let Some(expected_ty_expr) = expected_ty_expr { + errors::OptionResultRefMismatch::AsRef { + span: expected_ty_expr.span.shrink_to_hi(), expected_ty, expr_ty, def_path + } + } else if let Some(clone_did) = self.tcx.lang_items().clone_trait() + && rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions( + self, + self.param_env, + ty, + clone_did, + ) + { + errors::OptionResultRefMismatch::Cloned { + span, def_path + } + } else { + return false; + }; + diag.subdiagnostic(subdiag); return true; } - } - false - }; - - if let Some(result_did) = self.tcx.get_diagnostic_item(sym::Result) - && adt_def.did() == result_did - // Check that the error types are equal - && self.can_eq(self.param_env, args.type_at(1), expected_args.type_at(1)) - { - return suggest_copied_cloned_or_as_ref(); - } else if let Some(option_did) = self.tcx.get_diagnostic_item(sym::Option) - && adt_def.did() == option_did - { - return suggest_copied_cloned_or_as_ref(); } false diff --git a/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr index c06c506a311a..65d18761b187 100644 --- a/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr +++ b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr @@ -6,7 +6,7 @@ LL | debug_assert_eq!(iter.next(), Some(value)); | = note: expected enum `Option<::Item>` found enum `Option<&::Item>` -help: use `Option::as_ref()` to convert `Option<::Item>` to `Option<&::Item>` +help: use `Option::as_ref` to convert `Option<::Item>` to `Option<&::Item>` | LL | debug_assert_eq!(iter.next().as_ref(), Some(value)); | +++++++++ diff --git a/tests/ui/suggestions/copied-and-cloned.fixed b/tests/ui/suggestions/copied-and-cloned.fixed index 13031f424cbe..dec89c603883 100644 --- a/tests/ui/suggestions/copied-and-cloned.fixed +++ b/tests/ui/suggestions/copied-and-cloned.fixed @@ -26,6 +26,6 @@ fn main() { let y = Some(&s); println!("{}", x.as_ref() == y); //~^ ERROR mismatched types - //~| HELP use `Option::as_ref()` to convert `Option` to `Option<&String>` + //~| HELP use `Option::as_ref` to convert `Option` to `Option<&String>` } diff --git a/tests/ui/suggestions/copied-and-cloned.rs b/tests/ui/suggestions/copied-and-cloned.rs index 2927d66dea94..99485a2b525d 100644 --- a/tests/ui/suggestions/copied-and-cloned.rs +++ b/tests/ui/suggestions/copied-and-cloned.rs @@ -26,6 +26,6 @@ fn main() { let y = Some(&s); println!("{}", x == y); //~^ ERROR mismatched types - //~| HELP use `Option::as_ref()` to convert `Option` to `Option<&String>` + //~| HELP use `Option::as_ref` to convert `Option` to `Option<&String>` } diff --git a/tests/ui/suggestions/copied-and-cloned.stderr b/tests/ui/suggestions/copied-and-cloned.stderr index 19aaf6e00b13..6384c9b55dab 100644 --- a/tests/ui/suggestions/copied-and-cloned.stderr +++ b/tests/ui/suggestions/copied-and-cloned.stderr @@ -86,7 +86,7 @@ LL | println!("{}", x == y); | = note: expected enum `Option` found enum `Option<&String>` -help: use `Option::as_ref()` to convert `Option` to `Option<&String>` +help: use `Option::as_ref` to convert `Option` to `Option<&String>` | LL | println!("{}", x.as_ref() == y); | +++++++++ From fafc3d2d0e3b9d3d1933459d93b9577819577e48 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Thu, 27 Jul 2023 23:10:53 +0000 Subject: [PATCH 113/150] Handle exclusive refs in suggestion to copy/clone --- .../src/fn_ctxt/suggestions.rs | 8 ++++-- tests/ui/suggestions/copied-and-cloned.fixed | 14 ++++++++++ tests/ui/suggestions/copied-and-cloned.rs | 14 ++++++++++ tests/ui/suggestions/copied-and-cloned.stderr | 28 ++++++++++++++++++- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index ff715a1999de..fe962f6c1c0c 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -1110,7 +1110,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { let expr_inner_ty = args.type_at(0); let expected_inner_ty = expected_args.type_at(0); - if let &ty::Ref(_, ty, hir::Mutability::Not) = expr_inner_ty.kind() + if let &ty::Ref(_, ty, mutability) = expr_inner_ty.kind() && self.can_eq(self.param_env, ty, expected_inner_ty) { let def_path = self.tcx.def_path_str(adt_def.did()); @@ -1119,7 +1119,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { errors::OptionResultRefMismatch::Copied { span, def_path } - } else if let Some(expected_ty_expr) = expected_ty_expr { + } else if let Some(expected_ty_expr) = expected_ty_expr + // FIXME: suggest changes to both expressions to convert both to + // Option/Result<&T> + && mutability.is_not() + { errors::OptionResultRefMismatch::AsRef { span: expected_ty_expr.span.shrink_to_hi(), expected_ty, expr_ty, def_path } diff --git a/tests/ui/suggestions/copied-and-cloned.fixed b/tests/ui/suggestions/copied-and-cloned.fixed index dec89c603883..77159d5075af 100644 --- a/tests/ui/suggestions/copied-and-cloned.fixed +++ b/tests/ui/suggestions/copied-and-cloned.fixed @@ -28,4 +28,18 @@ fn main() { //~^ ERROR mismatched types //~| HELP use `Option::as_ref` to convert `Option` to `Option<&String>` + + let mut s = (); + let x = Some(s); + let y = Some(&mut s); + println!("{}", x == y.copied()); + //~^ ERROR mismatched types + //~| HELP use `Option::copied` to copy the value inside the `Option` + + let mut s = String::new(); + let x = Some(s.clone()); + let y = Some(&mut s); + println!("{}", x == y.cloned()); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` } diff --git a/tests/ui/suggestions/copied-and-cloned.rs b/tests/ui/suggestions/copied-and-cloned.rs index 99485a2b525d..c506494ee141 100644 --- a/tests/ui/suggestions/copied-and-cloned.rs +++ b/tests/ui/suggestions/copied-and-cloned.rs @@ -28,4 +28,18 @@ fn main() { //~^ ERROR mismatched types //~| HELP use `Option::as_ref` to convert `Option` to `Option<&String>` + + let mut s = (); + let x = Some(s); + let y = Some(&mut s); + println!("{}", x == y); + //~^ ERROR mismatched types + //~| HELP use `Option::copied` to copy the value inside the `Option` + + let mut s = String::new(); + let x = Some(s.clone()); + let y = Some(&mut s); + println!("{}", x == y); + //~^ ERROR mismatched types + //~| HELP use `Option::cloned` to clone the value inside the `Option` } diff --git a/tests/ui/suggestions/copied-and-cloned.stderr b/tests/ui/suggestions/copied-and-cloned.stderr index 6384c9b55dab..f8712d0a39e1 100644 --- a/tests/ui/suggestions/copied-and-cloned.stderr +++ b/tests/ui/suggestions/copied-and-cloned.stderr @@ -91,6 +91,32 @@ help: use `Option::as_ref` to convert `Option` to `Option<&String>` LL | println!("{}", x.as_ref() == y); | +++++++++ -error: aborting due to 5 previous errors +error[E0308]: mismatched types + --> $DIR/copied-and-cloned.rs:35:25 + | +LL | println!("{}", x == y); + | ^ expected `Option<()>`, found `Option<&mut ()>` + | + = note: expected enum `Option<()>` + found enum `Option<&mut ()>` +help: use `Option::copied` to copy the value inside the `Option` + | +LL | println!("{}", x == y.copied()); + | +++++++++ + +error[E0308]: mismatched types + --> $DIR/copied-and-cloned.rs:42:25 + | +LL | println!("{}", x == y); + | ^ expected `Option`, found `Option<&mut String>` + | + = note: expected enum `Option` + found enum `Option<&mut String>` +help: use `Option::cloned` to clone the value inside the `Option` + | +LL | println!("{}", x == y.cloned()); + | +++++++++ + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0308`. From 45b2559e5e56157cb1d56f02e52caa33372b1832 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Thu, 27 Jul 2023 21:35:05 -0500 Subject: [PATCH 114/150] docs(style-guide): don't flatten match arms with macro call --- src/doc/style-guide/src/expressions.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index bf3fe87a0a46..f0c2a189f12e 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -663,7 +663,8 @@ never use a block (unless the block is empty). If the right-hand side consists of multiple statements, or has line comments, or the start of the line does not fit on the same line as the left-hand side, -use a block. +use a block. Do not flatten a right-hand side block containing a single macro call +because its expanded form could contain a trailing semicolon. Block-indent the body of a block arm. @@ -686,6 +687,10 @@ match foo { bar => {} // Trailing comma on last item. foo => bar, + baz => qux!(), + lorem => { + ipsum!() + } } ``` From 8745fdc4487d6200ec652abc05b7a1ac9bb16765 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Fri, 28 Jul 2023 12:55:13 +1000 Subject: [PATCH 115/150] Replace a lazy `RefCell>` with `OnceCell` --- compiler/rustc_mir_transform/src/coverage/spans.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 35cf9ea5f91c..deebf5345bac 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt; use rustc_span::source_map::original_sp; use rustc_span::{BytePos, ExpnKind, MacroKind, Span, Symbol}; -use std::cell::RefCell; +use std::cell::OnceCell; use std::cmp::Ordering; #[derive(Debug, Copy, Clone)] @@ -67,7 +67,7 @@ impl CoverageStatement { pub(super) struct CoverageSpan { pub span: Span, pub expn_span: Span, - pub current_macro_or_none: RefCell>>, + pub current_macro_or_none: OnceCell>, pub bcb: BasicCoverageBlock, pub coverage_statements: Vec, pub is_closure: bool, @@ -175,8 +175,7 @@ impl CoverageSpan { /// If the span is part of a macro, returns the macro name symbol. pub fn current_macro(&self) -> Option { self.current_macro_or_none - .borrow_mut() - .get_or_insert_with(|| { + .get_or_init(|| { if let ExpnKind::Macro(MacroKind::Bang, current_macro) = self.expn_span.ctxt().outer_expn_data().kind { From 3ea0e6e3fbdc0bdd84a5669efec7b38c21f84f8e Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Thu, 27 Jul 2023 23:04:14 -0400 Subject: [PATCH 116/150] Add simd_bswap intrinsic --- compiler/rustc_codegen_llvm/src/intrinsic.rs | 22 ++++++++++ .../rustc_hir_analysis/src/check/intrinsic.rs | 1 + compiler/rustc_span/src/symbol.rs | 1 + .../ui/simd/intrinsic/generic-arithmetic-2.rs | 7 +++ .../intrinsic/generic-arithmetic-2.stderr | 44 ++++++++++++------- .../simd/intrinsic/generic-arithmetic-pass.rs | 4 ++ 6 files changed, 63 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 6df1b708ccd4..c30cb6801da6 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -2074,6 +2074,28 @@ fn generic_simd_intrinsic<'ll, 'tcx>( simd_neg: Int => neg, Float => fneg; } + if name == sym::simd_bswap { + let vec_ty = bx.cx.type_vector( + match *in_elem.kind() { + ty::Int(i) => bx.cx.type_int_from_ty(i), + ty::Uint(i) => bx.cx.type_uint_from_ty(i), + _ => return_error!(InvalidMonomorphization::UnsupportedOperation { + span, + name, + in_ty, + in_elem + }), + }, + in_len as u64, + ); + let llvm_intrinsic = + &format!("llvm.bswap.v{}i{}", in_len, in_elem.int_size_and_signed(bx.tcx()).0.bits(),); + let fn_ty = bx.type_func(&[vec_ty], vec_ty); + let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty); + let v = bx.call(fn_ty, None, None, f, &[args[0].immediate()], None); + return Ok(v); + } + if name == sym::simd_arith_offset { // This also checks that the first operand is a ptr type. let pointee = in_elem.builtin_deref(true).unwrap_or_else(|| { diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index e076b1fc68cc..68c99c4f24ee 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -521,6 +521,7 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) | sym::simd_saturating_sub => (1, vec![param(0), param(0)], param(0)), sym::simd_arith_offset => (2, vec![param(0), param(1)], param(0)), sym::simd_neg + | sym::simd_bswap | sym::simd_fsqrt | sym::simd_fsin | sym::simd_fcos diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 54eb7bef5f20..445bcd58426c 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1369,6 +1369,7 @@ symbols! { simd_arith_offset, simd_as, simd_bitmask, + simd_bswap, simd_cast, simd_cast_ptr, simd_ceil, diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index 3576eed71ab5..310d5cab843b 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -27,6 +27,7 @@ extern "platform-intrinsic" { fn simd_xor(x: T, y: T) -> T; fn simd_neg(x: T) -> T; + fn simd_bswap(x: T) -> T; } fn main() { @@ -64,6 +65,8 @@ fn main() { simd_neg(x); simd_neg(z); + simd_bswap(x); + simd_bswap(y); simd_add(0, 0); @@ -87,6 +90,8 @@ fn main() { simd_neg(0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_bswap(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_shl(z, z); @@ -98,6 +103,8 @@ fn main() { simd_or(z, z); //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_xor(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_bswap(z); //~^ ERROR unsupported operation on `f32x4` with element `f32` } } diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index 0f0a7ea6652d..efc6f05d39d0 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,93 +1,105 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:69:9 + --> $DIR/generic-arithmetic-2.rs:72:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:71:9 + --> $DIR/generic-arithmetic-2.rs:74:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:73:9 + --> $DIR/generic-arithmetic-2.rs:76:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:75:9 + --> $DIR/generic-arithmetic-2.rs:78:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:77:9 + --> $DIR/generic-arithmetic-2.rs:80:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:79:9 + --> $DIR/generic-arithmetic-2.rs:82:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:81:9 + --> $DIR/generic-arithmetic-2.rs:84:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:83:9 + --> $DIR/generic-arithmetic-2.rs:86:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:85:9 + --> $DIR/generic-arithmetic-2.rs:88:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:88:9 + --> $DIR/generic-arithmetic-2.rs:91:9 | LL | simd_neg(0); | ^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:93:9 + | +LL | simd_bswap(0); + | ^^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:92:9 + --> $DIR/generic-arithmetic-2.rs:97:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:94:9 + --> $DIR/generic-arithmetic-2.rs:99:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:96:9 + --> $DIR/generic-arithmetic-2.rs:101:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:98:9 + --> $DIR/generic-arithmetic-2.rs:103:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:100:9 + --> $DIR/generic-arithmetic-2.rs:105:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ -error: aborting due to 15 previous errors +error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:107:9 + | +LL | simd_bswap(z); + | ^^^^^^^^^^^^^ + +error: aborting due to 17 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index c507b8d31ecb..ca3bae99fea4 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -47,6 +47,7 @@ extern "platform-intrinsic" { fn simd_xor(x: T, y: T) -> T; fn simd_neg(x: T) -> T; + fn simd_bswap(x: T) -> T; } fn main() { @@ -132,5 +133,8 @@ fn main() { all_eq!(simd_neg(z1), f32x4(-1.0, -2.0, -3.0, -4.0)); all_eq!(simd_neg(z2), f32x4(-2.0, -3.0, -4.0, -5.0)); + all_eq!(simd_bswap(x1), i32x4(0x01000000, 0x02000000, 0x03000000, 0x04000000)); + all_eq_!(simd_bswap(y1), U32::<4>([0x01000000, 0x02000000, 0x03000000, 0x04000000])); + } } From 4c02b4cf4cea24028a37d8e24c1376f7e5db808a Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Thu, 27 Jul 2023 23:53:45 -0400 Subject: [PATCH 117/150] Add SIMD bitreverse, ctlz, cttz intrinsics --- compiler/rustc_codegen_llvm/src/intrinsic.rs | 32 +++++++-- .../rustc_hir_analysis/src/check/intrinsic.rs | 3 + compiler/rustc_span/src/symbol.rs | 3 + .../ui/simd/intrinsic/generic-arithmetic-2.rs | 21 ++++++ .../intrinsic/generic-arithmetic-2.stderr | 72 ++++++++++++++----- .../simd/intrinsic/generic-arithmetic-pass.rs | 11 +++ 6 files changed, 117 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index c30cb6801da6..187214a93dd7 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -2074,7 +2074,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>( simd_neg: Int => neg, Float => fneg; } - if name == sym::simd_bswap { + // Unary integer intrinsics + if matches!(name, sym::simd_bswap | sym::simd_bitreverse | sym::simd_ctlz | sym::simd_cttz) { let vec_ty = bx.cx.type_vector( match *in_elem.kind() { ty::Int(i) => bx.cx.type_int_from_ty(i), @@ -2088,12 +2089,29 @@ fn generic_simd_intrinsic<'ll, 'tcx>( }, in_len as u64, ); - let llvm_intrinsic = - &format!("llvm.bswap.v{}i{}", in_len, in_elem.int_size_and_signed(bx.tcx()).0.bits(),); - let fn_ty = bx.type_func(&[vec_ty], vec_ty); - let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty); - let v = bx.call(fn_ty, None, None, f, &[args[0].immediate()], None); - return Ok(v); + let intrinsic_name = match name { + sym::simd_bswap => "bswap", + sym::simd_bitreverse => "bitreverse", + sym::simd_ctlz => "ctlz", + sym::simd_cttz => "cttz", + _ => unreachable!(), + }; + let llvm_intrinsic = &format!( + "llvm.{}.v{}i{}", + intrinsic_name, + in_len, + in_elem.int_size_and_signed(bx.tcx()).0.bits(), + ); + + return Ok(if matches!(name, sym::simd_ctlz | sym::simd_cttz) { + let fn_ty = bx.type_func(&[vec_ty, bx.type_bool()], vec_ty); + let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty); + bx.call(fn_ty, None, None, f, &[args[0].immediate(), bx.const_bool(false)], None) + } else { + let fn_ty = bx.type_func(&[vec_ty], vec_ty); + let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty); + bx.call(fn_ty, None, None, f, &[args[0].immediate()], None) + }); } if name == sym::simd_arith_offset { diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 68c99c4f24ee..064021b1ea42 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -522,6 +522,9 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) sym::simd_arith_offset => (2, vec![param(0), param(1)], param(0)), sym::simd_neg | sym::simd_bswap + | sym::simd_bitreverse + | sym::simd_ctlz + | sym::simd_cttz | sym::simd_fsqrt | sym::simd_fsin | sym::simd_fcos diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 445bcd58426c..35f8b99ffb27 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1369,10 +1369,13 @@ symbols! { simd_arith_offset, simd_as, simd_bitmask, + simd_bitreverse, simd_bswap, simd_cast, simd_cast_ptr, simd_ceil, + simd_ctlz, + simd_cttz, simd_div, simd_eq, simd_expose_addr, diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index 310d5cab843b..62fb5238bbd0 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -28,6 +28,9 @@ extern "platform-intrinsic" { fn simd_neg(x: T) -> T; fn simd_bswap(x: T) -> T; + fn simd_bitreverse(x: T) -> T; + fn simd_ctlz(x: T) -> T; + fn simd_cttz(x: T) -> T; } fn main() { @@ -67,6 +70,12 @@ fn main() { simd_neg(z); simd_bswap(x); simd_bswap(y); + simd_bitreverse(x); + simd_bitreverse(y); + simd_ctlz(x); + simd_ctlz(y); + simd_cttz(x); + simd_cttz(y); simd_add(0, 0); @@ -92,6 +101,12 @@ fn main() { //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_bswap(0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_bitreverse(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_ctlz(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_cttz(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_shl(z, z); @@ -105,6 +120,12 @@ fn main() { simd_xor(z, z); //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_bswap(z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_bitreverse(z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_ctlz(z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_cttz(z); //~^ ERROR unsupported operation on `f32x4` with element `f32` } } diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index efc6f05d39d0..db26f3417c95 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,105 +1,141 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:72:9 + --> $DIR/generic-arithmetic-2.rs:81:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:74:9 + --> $DIR/generic-arithmetic-2.rs:83:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:76:9 + --> $DIR/generic-arithmetic-2.rs:85:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:78:9 + --> $DIR/generic-arithmetic-2.rs:87:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:80:9 + --> $DIR/generic-arithmetic-2.rs:89:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:82:9 + --> $DIR/generic-arithmetic-2.rs:91:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:84:9 + --> $DIR/generic-arithmetic-2.rs:93:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:86:9 + --> $DIR/generic-arithmetic-2.rs:95:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:88:9 + --> $DIR/generic-arithmetic-2.rs:97:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:91:9 + --> $DIR/generic-arithmetic-2.rs:100:9 | LL | simd_neg(0); | ^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:93:9 + --> $DIR/generic-arithmetic-2.rs:102:9 | LL | simd_bswap(0); | ^^^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:104:9 + | +LL | simd_bitreverse(0); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:106:9 + | +LL | simd_ctlz(0); + | ^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:108:9 + | +LL | simd_cttz(0); + | ^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:97:9 + --> $DIR/generic-arithmetic-2.rs:112:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:99:9 + --> $DIR/generic-arithmetic-2.rs:114:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:101:9 + --> $DIR/generic-arithmetic-2.rs:116:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:103:9 + --> $DIR/generic-arithmetic-2.rs:118:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:105:9 + --> $DIR/generic-arithmetic-2.rs:120:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:107:9 + --> $DIR/generic-arithmetic-2.rs:122:9 | LL | simd_bswap(z); | ^^^^^^^^^^^^^ -error: aborting due to 17 previous errors +error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:124:9 + | +LL | simd_bitreverse(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:126:9 + | +LL | simd_ctlz(z); + | ^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:128:9 + | +LL | simd_cttz(z); + | ^^^^^^^^^^^^ + +error: aborting due to 23 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index ca3bae99fea4..1168e6aae0f2 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -48,6 +48,9 @@ extern "platform-intrinsic" { fn simd_neg(x: T) -> T; fn simd_bswap(x: T) -> T; + fn simd_bitreverse(x: T) -> T; + fn simd_ctlz(x: T) -> T; + fn simd_cttz(x: T) -> T; } fn main() { @@ -136,5 +139,13 @@ fn main() { all_eq!(simd_bswap(x1), i32x4(0x01000000, 0x02000000, 0x03000000, 0x04000000)); all_eq_!(simd_bswap(y1), U32::<4>([0x01000000, 0x02000000, 0x03000000, 0x04000000])); + all_eq!(simd_bitreverse(x1), i32x4(0x80000000u32 as i32, 0x40000000, 0xc0000000u32 as i32, 0x20000000)); + all_eq_!(simd_bitreverse(y1), U32::<4>([0x80000000, 0x40000000, 0xc0000000, 0x20000000])); + + all_eq!(simd_ctlz(x1), i32x4(31, 30, 30, 29)); + all_eq_!(simd_ctlz(y1), U32::<4>([31, 30, 30, 29])); + + all_eq!(simd_cttz(x1), i32x4(0, 1, 0, 2)); + all_eq_!(simd_cttz(y1), U32::<4>([0, 1, 0, 2])); } } From 4709ca2bed491523c06e5b674822a965e3649fea Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Fri, 28 Jul 2023 00:09:04 -0400 Subject: [PATCH 118/150] Format test --- .../simd/intrinsic/generic-arithmetic-pass.rs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index 1168e6aae0f2..f021ee4710a9 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -1,8 +1,6 @@ // run-pass #![allow(non_camel_case_types)] - // ignore-emscripten FIXME(#45351) hits an LLVM assert - #![feature(repr_simd, platform_intrinsics)] #[repr(simd)] @@ -22,7 +20,7 @@ macro_rules! all_eq { let a = $a; let b = $b; assert!(a.0 == b.0 && a.1 == b.1 && a.2 == b.2 && a.3 == b.3); - }} + }}; } macro_rules! all_eq_ { @@ -30,10 +28,9 @@ macro_rules! all_eq_ { let a = $a; let b = $b; assert!(a.0 == b.0); - }} + }}; } - extern "platform-intrinsic" { fn simd_add(x: T, y: T) -> T; fn simd_sub(x: T, y: T) -> T; @@ -88,8 +85,8 @@ fn main() { all_eq_!(simd_div(y1, y1), U32::<4>([1, 1, 1, 1])); all_eq_!(simd_div(U32::<4>([2, 4, 6, 8]), U32::<4>([2, 2, 2, 2])), y1); all_eq!(simd_div(z1, z1), f32x4(1.0, 1.0, 1.0, 1.0)); - all_eq!(simd_div(z1, z2), f32x4(1.0/2.0, 2.0/3.0, 3.0/4.0, 4.0/5.0)); - all_eq!(simd_div(z2, z1), f32x4(2.0/1.0, 3.0/2.0, 4.0/3.0, 5.0/4.0)); + all_eq!(simd_div(z1, z2), f32x4(1.0 / 2.0, 2.0 / 3.0, 3.0 / 4.0, 4.0 / 5.0)); + all_eq!(simd_div(z2, z1), f32x4(2.0 / 1.0, 3.0 / 2.0, 4.0 / 3.0, 5.0 / 4.0)); all_eq!(simd_rem(x1, x1), i32x4(0, 0, 0, 0)); all_eq!(simd_rem(x2, x1), i32x4(0, 1, 1, 1)); @@ -113,8 +110,10 @@ fn main() { // ensure we get logical vs. arithmetic shifts correct let (a, b, c, d) = (-12, -123, -1234, -12345); all_eq!(simd_shr(i32x4(a, b, c, d), x1), i32x4(a >> 1, b >> 2, c >> 3, d >> 4)); - all_eq_!(simd_shr(U32::<4>([a as u32, b as u32, c as u32, d as u32]), y1), - U32::<4>([(a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4])); + all_eq_!( + simd_shr(U32::<4>([a as u32, b as u32, c as u32, d as u32]), y1), + U32::<4>([(a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4]) + ); all_eq!(simd_and(x1, x2), i32x4(0, 2, 0, 4)); all_eq!(simd_and(x2, x1), i32x4(0, 2, 0, 4)); @@ -139,7 +138,10 @@ fn main() { all_eq!(simd_bswap(x1), i32x4(0x01000000, 0x02000000, 0x03000000, 0x04000000)); all_eq_!(simd_bswap(y1), U32::<4>([0x01000000, 0x02000000, 0x03000000, 0x04000000])); - all_eq!(simd_bitreverse(x1), i32x4(0x80000000u32 as i32, 0x40000000, 0xc0000000u32 as i32, 0x20000000)); + all_eq!( + simd_bitreverse(x1), + i32x4(0x80000000u32 as i32, 0x40000000, 0xc0000000u32 as i32, 0x20000000) + ); all_eq_!(simd_bitreverse(y1), U32::<4>([0x80000000, 0x40000000, 0xc0000000, 0x20000000])); all_eq!(simd_ctlz(x1), i32x4(31, 30, 30, 29)); From 38e0d58d7d67a4347b85ac26aa35df573df86621 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 28 Jul 2023 11:01:53 +0200 Subject: [PATCH 119/150] Add regression test for `--cap-lints allow` and trait bounds warning I have verified that the test fails if stderr begins to contain output by making sure the test fails when I add eprintln!("some output on stderr"); to the compiler (I added it to `fn build_session()`). --- tests/ui/lint/lint-cap-trait-bounds.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/ui/lint/lint-cap-trait-bounds.rs diff --git a/tests/ui/lint/lint-cap-trait-bounds.rs b/tests/ui/lint/lint-cap-trait-bounds.rs new file mode 100644 index 000000000000..d9c28dd0aa6e --- /dev/null +++ b/tests/ui/lint/lint-cap-trait-bounds.rs @@ -0,0 +1,8 @@ +// Regression test for https://github.com/rust-lang/rust/issues/43134 + +// check-pass +// compile-flags: --cap-lints allow + +type Foo = Option; + +fn main() {} From 37159345a74797316deb0b6f911d48b7243bba77 Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Fri, 28 Jul 2023 11:50:10 +0200 Subject: [PATCH 120/150] Change the description of `SUSPICIOUS_AUTO_TRAIT_IMPLS` --- compiler/rustc_lint_defs/src/builtin.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 87c542dc2e26..081ec7b65622 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4052,12 +4052,12 @@ declare_lint! { /// /// The compiler disables the automatic implementation if an explicit one /// exists for given type constructor. The exact rules governing this - /// are currently unsound, quite subtle, and will be modified in the future. - /// This change will cause the automatic implementation to be disabled in more + /// were previously unsound, quite subtle, and have been recently modified. + /// This change caused the automatic implementation to be disabled in more /// cases, potentially breaking some code. pub SUSPICIOUS_AUTO_TRAIT_IMPLS, Warn, - "the rules governing auto traits will change in the future", + "the rules governing auto traits have recently changed resulting in potential breakage", @future_incompatible = FutureIncompatibleInfo { reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange, reference: "issue #93367 ", From 5b576665e50752b89e96e5d3043b99a9558e881c Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 28 Apr 2023 13:04:35 +0200 Subject: [PATCH 121/150] Introduce the `#[diagnostic]` attribute namespace Co-authored-by: est31 Co-authored-by: Esteban Kuber Co-authored-by: Vadim Petrochenkov --- compiler/rustc_ast_passes/src/feature_gate.rs | 13 +++++++ compiler/rustc_feature/src/active.rs | 2 ++ compiler/rustc_lint_defs/src/builtin.rs | 25 +++++++++++++ compiler/rustc_resolve/src/macros.rs | 20 +++++++++-- compiler/rustc_span/src/symbol.rs | 1 + src/tools/tidy/src/ui_tests.rs | 2 +- .../auxiliary/proc-macro-helper.rs | 12 +++++++ ...use_the_diagnostic_name_in_other_places.rs | 13 +++++++ .../existing_proc_macros.rs | 24 +++++++++++++ .../feature-gate-diagnostic_namespace.rs | 13 +++++++ .../feature-gate-diagnostic_namespace.stderr | 35 +++++++++++++++++++ .../non_existing_attributes_accepted.rs | 13 +++++++ .../non_existing_attributes_accepted.stderr | 16 +++++++++ .../ui/diagnostic_namespace/requires_path.rs | 9 +++++ .../diagnostic_namespace/requires_path.stderr | 8 +++++ 15 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs create mode 100644 tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs create mode 100644 tests/ui/diagnostic_namespace/existing_proc_macros.rs create mode 100644 tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs create mode 100644 tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr create mode 100644 tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs create mode 100644 tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr create mode 100644 tests/ui/diagnostic_namespace/requires_path.rs create mode 100644 tests/ui/diagnostic_namespace/requires_path.stderr diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index b0dbc2c23403..c0d2e76f310a 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -218,6 +218,19 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } } + if !attr.is_doc_comment() + && attr.get_normal_item().path.segments.len() == 2 + && attr.get_normal_item().path.segments[0].ident.name == sym::diagnostic + && !self.features.diagnostic_namespace + { + let msg = "`#[diagnostic]` attribute name space is experimental"; + gate_feature_post!( + self, + diagnostic_namespace, + attr.get_normal_item().path.segments[0].ident.span, + msg + ); + } // Emit errors for non-staged-api crates. if !self.features.staged_api { diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 56a2c5eff3d0..c03789f500a7 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -379,6 +379,8 @@ declare_features! ( (active, deprecated_safe, "1.61.0", Some(94978), None), /// Allows having using `suggestion` in the `#[deprecated]` attribute. (active, deprecated_suggestion, "1.61.0", Some(94785), None), + /// Allows using the `#[diagnostic]` attribute tool namespace + (active, diagnostic_namespace, "CURRENT_RUSTC_VERSION", Some(94785), None), /// Controls errors in trait implementations. (active, do_not_recommend, "1.67.0", Some(51992), None), /// Tells rustdoc to automatically generate `#[doc(cfg(...))]`. diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a0f2e9aed811..cfb40a3b65c4 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3400,6 +3400,7 @@ declare_lint_pass! { UNFULFILLED_LINT_EXPECTATIONS, UNINHABITED_STATIC, UNKNOWN_CRATE_TYPES, + UNKNOWN_DIAGNOSTIC_ATTRIBUTES, UNKNOWN_LINTS, UNNAMEABLE_TYPES, UNREACHABLE_CODE, @@ -4380,3 +4381,27 @@ declare_lint! { "effective visibility of a type is larger than the area in which it can be named", @feature_gate = sym::type_privacy_lints; } + +declare_lint! { + /// The `unknown_diagnostic_attributes` lint detects unrecognized diagnostic attributes. + /// + /// ### Example + /// + /// ```rust + /// #![feature(diagnostic_namespace)] + /// #[diagnostic::does_not_exist] + /// struct Foo; + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check + /// the spelling, and check the diagnostic attribute listing for the correct name. Also + /// consider if you are using an old version of the compiler, and the attribute + /// is only available in a newer version. + pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES, + Warn, + "unrecognized diagnostic attribute" +} diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 266e37e4cef9..d456cc9a9a0b 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -24,7 +24,9 @@ use rustc_hir::def_id::{CrateNum, LocalDefId}; use rustc_middle::middle::stability; use rustc_middle::ty::RegisteredTools; use rustc_middle::ty::TyCtxt; -use rustc_session::lint::builtin::{LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE}; +use rustc_session::lint::builtin::{ + LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE, UNKNOWN_DIAGNOSTIC_ATTRIBUTES, +}; use rustc_session::lint::builtin::{UNUSED_MACROS, UNUSED_MACRO_RULES}; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::parse::feature_err; @@ -140,9 +142,9 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools { } } } - // We implicitly add `rustfmt` and `clippy` to known tools, + // We implicitly add `rustfmt`, `clippy`, `diagnostic` to known tools, // but it's not an error to register them explicitly. - let predefined_tools = [sym::clippy, sym::rustfmt]; + let predefined_tools = [sym::clippy, sym::rustfmt, sym::diagnostic]; registered_tools.extend(predefined_tools.iter().cloned().map(Ident::with_dummy_span)); registered_tools } @@ -595,6 +597,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } + if res == Res::NonMacroAttr(NonMacroAttrKind::Tool) + && path.segments.len() >= 2 + && path.segments[0].ident.name == sym::diagnostic + { + self.tcx.sess.parse_sess.buffer_lint( + UNKNOWN_DIAGNOSTIC_ATTRIBUTES, + path.segments[1].span(), + node_id, + "unknown diagnostic attribute", + ); + } + Ok((ext, res)) } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 54eb7bef5f20..1b426ef20485 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -620,6 +620,7 @@ symbols! { destruct, destructuring_assignment, diagnostic, + diagnostic_namespace, direct, discriminant_kind, discriminant_type, diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index f9a90bf3a005..d1ae88fcd80c 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -13,7 +13,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1893; -const ROOT_ENTRY_LIMIT: usize = 870; +const ROOT_ENTRY_LIMIT: usize = 871; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs b/tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs new file mode 100644 index 000000000000..759c32c84533 --- /dev/null +++ b/tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs @@ -0,0 +1,12 @@ +// force-host +// no-prefer-dynamic +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn diagnostic(i: TokenStream, _: TokenStream) -> TokenStream { + i +} diff --git a/tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs b/tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs new file mode 100644 index 000000000000..08b4d68779c1 --- /dev/null +++ b/tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs @@ -0,0 +1,13 @@ +// check-pass + +mod diagnostic {} + +macro_rules! diagnostic{ + () => {} +} + +#[allow(non_upper_case_globals)] +const diagnostic: () = (); + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/existing_proc_macros.rs b/tests/ui/diagnostic_namespace/existing_proc_macros.rs new file mode 100644 index 000000000000..d6d1fb014962 --- /dev/null +++ b/tests/ui/diagnostic_namespace/existing_proc_macros.rs @@ -0,0 +1,24 @@ +#![feature(diagnostic_namespace)] +// check-pass +// aux-build:proc-macro-helper.rs + +extern crate proc_macro_helper; + +mod test1 { + use proc_macro_helper::diagnostic; + + #[diagnostic] + struct Foo; + +} + +mod test2 { + mod diagnostic { + pub use proc_macro_helper::diagnostic as on_unimplemented; + } + + #[diagnostic::on_unimplemented] + trait Foo {} +} + +fn main() {} diff --git a/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs new file mode 100644 index 000000000000..a686ed9c84ef --- /dev/null +++ b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs @@ -0,0 +1,13 @@ +#[diagnostic::non_existing_attribute] +//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658] +//~|WARNING unknown diagnostic attribute [unknown_diagnostic_attributes] +pub trait Bar { +} + +#[diagnostic::non_existing_attribute(with_option = "foo")] +//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658] +//~|WARNING unknown diagnostic attribute [unknown_diagnostic_attributes] +struct Foo; + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr new file mode 100644 index 000000000000..45c95cbb3c7e --- /dev/null +++ b/tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr @@ -0,0 +1,35 @@ +error[E0658]: `#[diagnostic]` attribute name space is experimental + --> $DIR/feature-gate-diagnostic_namespace.rs:1:3 + | +LL | #[diagnostic::non_existing_attribute] + | ^^^^^^^^^^ + | + = note: see issue #94785 for more information + = help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable + +error[E0658]: `#[diagnostic]` attribute name space is experimental + --> $DIR/feature-gate-diagnostic_namespace.rs:7:3 + | +LL | #[diagnostic::non_existing_attribute(with_option = "foo")] + | ^^^^^^^^^^ + | + = note: see issue #94785 for more information + = help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable + +warning: unknown diagnostic attribute + --> $DIR/feature-gate-diagnostic_namespace.rs:1:15 + | +LL | #[diagnostic::non_existing_attribute] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unknown_diagnostic_attributes)]` on by default + +warning: unknown diagnostic attribute + --> $DIR/feature-gate-diagnostic_namespace.rs:7:15 + | +LL | #[diagnostic::non_existing_attribute(with_option = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors; 2 warnings emitted + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs new file mode 100644 index 000000000000..677bd5a7343f --- /dev/null +++ b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs @@ -0,0 +1,13 @@ +#![feature(diagnostic_namespace)] +// check-pass +#[diagnostic::non_existing_attribute] +//~^WARN unknown diagnostic attribute +pub trait Bar { +} + +#[diagnostic::non_existing_attribute(with_option = "foo")] +//~^WARN unknown diagnostic attribute +struct Foo; + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr new file mode 100644 index 000000000000..4f9b7ba2bcf3 --- /dev/null +++ b/tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr @@ -0,0 +1,16 @@ +warning: unknown diagnostic attribute + --> $DIR/non_existing_attributes_accepted.rs:3:15 + | +LL | #[diagnostic::non_existing_attribute] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unknown_diagnostic_attributes)]` on by default + +warning: unknown diagnostic attribute + --> $DIR/non_existing_attributes_accepted.rs:8:15 + | +LL | #[diagnostic::non_existing_attribute(with_option = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: 2 warnings emitted + diff --git a/tests/ui/diagnostic_namespace/requires_path.rs b/tests/ui/diagnostic_namespace/requires_path.rs new file mode 100644 index 000000000000..e8d6ca73ad0c --- /dev/null +++ b/tests/ui/diagnostic_namespace/requires_path.rs @@ -0,0 +1,9 @@ +#![feature(diagnostic_namespace)] + +#[diagnostic] +//~^ERROR cannot find attribute `diagnostic` in this scope +pub struct Bar; + + +fn main() { +} diff --git a/tests/ui/diagnostic_namespace/requires_path.stderr b/tests/ui/diagnostic_namespace/requires_path.stderr new file mode 100644 index 000000000000..ce867621daaf --- /dev/null +++ b/tests/ui/diagnostic_namespace/requires_path.stderr @@ -0,0 +1,8 @@ +error: cannot find attribute `diagnostic` in this scope + --> $DIR/requires_path.rs:3:3 + | +LL | #[diagnostic] + | ^^^^^^^^^^ + +error: aborting due to previous error + From b996e5e95b45c040d22c20b7b5f6968c29bfbea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 27 Jul 2023 21:31:06 +0200 Subject: [PATCH 122/150] Change LLVM BOLT flags --- src/bootstrap/bolt.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/bolt.rs b/src/bootstrap/bolt.rs index 5384181ea687..017c4602d436 100644 --- a/src/bootstrap/bolt.rs +++ b/src/bootstrap/bolt.rs @@ -49,6 +49,8 @@ pub fn optimize_with_bolt(path: &Path, profile_path: &Path, output_path: &Path) .arg("-icf=1") // Update DWARF debug info in the final binary .arg("-update-debug-sections") + // Try to reuse old text segments to reduce binary size + .arg("--use-old-text") // Print optimization statistics .arg("-dyno-stats") .status() From 9454916c84301a2f0a6de98e6ad5374a366dab75 Mon Sep 17 00:00:00 2001 From: Raoul Strackx Date: Fri, 28 Jul 2023 13:53:28 +0200 Subject: [PATCH 123/150] Fix switch-stdout test for none unix/windows platforms --- library/std/tests/switch-stdout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/tests/switch-stdout.rs b/library/std/tests/switch-stdout.rs index 28ce6dfccd35..2605664d2897 100644 --- a/library/std/tests/switch-stdout.rs +++ b/library/std/tests/switch-stdout.rs @@ -1,4 +1,4 @@ -#[cfg(any(target_family = "unix", target_family = "windows"))] +#![cfg(any(target_family = "unix", target_family = "windows"))] use std::fs::File; use std::io::{Read, Write}; From 85779214c845c4e21b97e7d37d50466d49231155 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 28 Jul 2023 14:24:56 +0200 Subject: [PATCH 124/150] btree/map.rs: remove "Basic usage" text Not useful, for there is just a single example --- library/alloc/src/collections/btree/map.rs | 54 ---------------------- 1 file changed, 54 deletions(-) diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index ff908ec12ec8..29e9423bb436 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -613,8 +613,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -636,8 +634,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -661,8 +657,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// # #![feature(allocator_api)] /// # #![feature(btreemap_alloc)] @@ -688,8 +682,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -744,8 +736,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -830,8 +820,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -917,8 +905,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -943,8 +929,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -982,8 +966,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1017,8 +999,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(map_try_insert)] /// @@ -1051,8 +1031,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1078,8 +1056,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1208,8 +1184,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// use std::ops::Bound::Included; @@ -1251,8 +1225,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1283,8 +1255,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -1336,8 +1306,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2388,8 +2356,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2420,8 +2386,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2453,8 +2417,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2474,8 +2436,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2495,8 +2455,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2521,8 +2479,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2546,8 +2502,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::collections::BTreeMap; /// @@ -2578,8 +2532,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// @@ -2619,8 +2571,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// @@ -2673,8 +2623,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// @@ -2714,8 +2662,6 @@ impl BTreeMap { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// #![feature(btree_cursors)] /// From 0457eda673b5b27f4740ff3b50bf90c8f2870e2d Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 28 Jul 2023 14:46:17 +0200 Subject: [PATCH 125/150] doc: replace wrong punctuation mark --- library/core/src/borrow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/borrow.rs b/library/core/src/borrow.rs index efc9ada3891a..bc026d0a4463 100644 --- a/library/core/src/borrow.rs +++ b/library/core/src/borrow.rs @@ -22,7 +22,7 @@ /// Types express that they can be borrowed as some type `T` by implementing /// `Borrow`, providing a reference to a `T` in the trait’s /// [`borrow`] method. A type is free to borrow as several different types. -/// If it wishes to mutably borrow as the type – allowing the underlying data +/// If it wishes to mutably borrow as the type, allowing the underlying data /// to be modified, it can additionally implement [`BorrowMut`]. /// /// Further, when providing implementations for additional traits, it needs From 8548689af21e916b17fa96b00d742717c3c51a5e Mon Sep 17 00:00:00 2001 From: Raoul Strackx Date: Fri, 28 Jul 2023 14:17:35 +0200 Subject: [PATCH 126/150] Fix issue_15149 test for the SGX target --- library/std/tests/process_spawning.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/tests/process_spawning.rs b/library/std/tests/process_spawning.rs index 52e5b55fb9d4..46dc9ff00bd0 100644 --- a/library/std/tests/process_spawning.rs +++ b/library/std/tests/process_spawning.rs @@ -1,3 +1,5 @@ +#![cfg(not(target_env="sgx"))] + use std::env; use std::fs; use std::process; From e051a323110d438c337f3f893d171fade7d2d1a6 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 26 Jul 2023 16:51:40 +0100 Subject: [PATCH 127/150] privacy: no nominal visibility for assoc fns When `staged_api` is enabled, effective visibilities are computed earlier and this can trigger an ICE in some cases. In particular, if a impl of a trait method has a visibility then an error will be reported for that, but when privacy invariants are being checked, the effective visibility will still be greater than the nominal visbility and that will trigger a `span_bug!`. However, this invariant - that effective visibilites are limited to nominal visibility - doesn't make sense for associated functions. Signed-off-by: David Wood --- compiler/rustc_middle/src/middle/privacy.rs | 9 +++- tests/ui/privacy/issue-113860-1.rs | 16 +++++++ tests/ui/privacy/issue-113860-1.stderr | 49 +++++++++++++++++++++ tests/ui/privacy/issue-113860-2.rs | 16 +++++++ tests/ui/privacy/issue-113860-2.stderr | 49 +++++++++++++++++++++ tests/ui/privacy/issue-113860.rs | 16 +++++++ tests/ui/privacy/issue-113860.stderr | 49 +++++++++++++++++++++ 7 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 tests/ui/privacy/issue-113860-1.rs create mode 100644 tests/ui/privacy/issue-113860-1.stderr create mode 100644 tests/ui/privacy/issue-113860-2.rs create mode 100644 tests/ui/privacy/issue-113860-2.stderr create mode 100644 tests/ui/privacy/issue-113860.rs create mode 100644 tests/ui/privacy/issue-113860.stderr diff --git a/compiler/rustc_middle/src/middle/privacy.rs b/compiler/rustc_middle/src/middle/privacy.rs index 5baeb1ee0cf7..1913421f54c9 100644 --- a/compiler/rustc_middle/src/middle/privacy.rs +++ b/compiler/rustc_middle/src/middle/privacy.rs @@ -178,7 +178,12 @@ impl EffectiveVisibilities { // All effective visibilities except `reachable_through_impl_trait` are limited to // nominal visibility. For some items nominal visibility doesn't make sense so we // don't check this condition for them. - if !matches!(tcx.def_kind(def_id), DefKind::Impl { .. }) { + let is_impl = matches!(tcx.def_kind(def_id), DefKind::Impl { .. }); + let is_associated_item_in_trait_impl = tcx + .impl_of_method(def_id.to_def_id()) + .and_then(|impl_id| tcx.trait_id_of_impl(impl_id)) + .is_some(); + if !is_impl && !is_associated_item_in_trait_impl { let nominal_vis = tcx.visibility(def_id); if !nominal_vis.is_at_least(ev.reachable, tcx) { span_bug!( @@ -186,7 +191,7 @@ impl EffectiveVisibilities { "{:?}: reachable {:?} > nominal {:?}", def_id, ev.reachable, - nominal_vis + nominal_vis, ); } } diff --git a/tests/ui/privacy/issue-113860-1.rs b/tests/ui/privacy/issue-113860-1.rs new file mode 100644 index 000000000000..86ccca41f379 --- /dev/null +++ b/tests/ui/privacy/issue-113860-1.rs @@ -0,0 +1,16 @@ +#![feature(staged_api)] +//~^ ERROR module has missing stability attribute + +pub trait Trait { + //~^ ERROR trait has missing stability attribute + fn fun() {} + //~^ ERROR associated function has missing stability attribute +} + +impl Trait for u8 { + //~^ ERROR implementation has missing stability attribute + pub(self) fn fun() {} + //~^ ERROR visibility qualifiers are not permitted here [E0449] +} + +fn main() {} diff --git a/tests/ui/privacy/issue-113860-1.stderr b/tests/ui/privacy/issue-113860-1.stderr new file mode 100644 index 000000000000..c33ce26f0f6e --- /dev/null +++ b/tests/ui/privacy/issue-113860-1.stderr @@ -0,0 +1,49 @@ +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/issue-113860-1.rs:12:5 + | +LL | pub(self) fn fun() {} + | ^^^^^^^^^ + | + = note: trait items always share the visibility of their trait + +error: module has missing stability attribute + --> $DIR/issue-113860-1.rs:1:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | +LL | | pub trait Trait { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: trait has missing stability attribute + --> $DIR/issue-113860-1.rs:4:1 + | +LL | / pub trait Trait { +LL | | +LL | | fn fun() {} +LL | | +LL | | } + | |_^ + +error: implementation has missing stability attribute + --> $DIR/issue-113860-1.rs:10:1 + | +LL | / impl Trait for u8 { +LL | | +LL | | pub(self) fn fun() {} +LL | | +LL | | } + | |_^ + +error: associated function has missing stability attribute + --> $DIR/issue-113860-1.rs:6:5 + | +LL | fn fun() {} + | ^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/tests/ui/privacy/issue-113860-2.rs b/tests/ui/privacy/issue-113860-2.rs new file mode 100644 index 000000000000..59be19d88a01 --- /dev/null +++ b/tests/ui/privacy/issue-113860-2.rs @@ -0,0 +1,16 @@ +#![feature(staged_api)] +//~^ ERROR module has missing stability attribute + +pub trait Trait { + //~^ ERROR trait has missing stability attribute + type X; + //~^ ERROR associated type has missing stability attribute +} + +impl Trait for u8 { + //~^ ERROR implementation has missing stability attribute + pub(self) type X = Self; + //~^ ERROR visibility qualifiers are not permitted here [E0449] +} + +fn main() {} diff --git a/tests/ui/privacy/issue-113860-2.stderr b/tests/ui/privacy/issue-113860-2.stderr new file mode 100644 index 000000000000..6748bc276684 --- /dev/null +++ b/tests/ui/privacy/issue-113860-2.stderr @@ -0,0 +1,49 @@ +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/issue-113860-2.rs:12:5 + | +LL | pub(self) type X = Self; + | ^^^^^^^^^ + | + = note: trait items always share the visibility of their trait + +error: module has missing stability attribute + --> $DIR/issue-113860-2.rs:1:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | +LL | | pub trait Trait { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: trait has missing stability attribute + --> $DIR/issue-113860-2.rs:4:1 + | +LL | / pub trait Trait { +LL | | +LL | | type X; +LL | | +LL | | } + | |_^ + +error: implementation has missing stability attribute + --> $DIR/issue-113860-2.rs:10:1 + | +LL | / impl Trait for u8 { +LL | | +LL | | pub(self) type X = Self; +LL | | +LL | | } + | |_^ + +error: associated type has missing stability attribute + --> $DIR/issue-113860-2.rs:6:5 + | +LL | type X; + | ^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/tests/ui/privacy/issue-113860.rs b/tests/ui/privacy/issue-113860.rs new file mode 100644 index 000000000000..b94c14fac4e1 --- /dev/null +++ b/tests/ui/privacy/issue-113860.rs @@ -0,0 +1,16 @@ +#![feature(staged_api)] +//~^ ERROR module has missing stability attribute + +pub trait Trait { + //~^ ERROR trait has missing stability attribute + const X: u32; + //~^ ERROR associated constant has missing stability attribute +} + +impl Trait for u8 { + //~^ ERROR implementation has missing stability attribute + pub(self) const X: u32 = 3; + //~^ ERROR visibility qualifiers are not permitted here [E0449] +} + +fn main() {} diff --git a/tests/ui/privacy/issue-113860.stderr b/tests/ui/privacy/issue-113860.stderr new file mode 100644 index 000000000000..3204f4ff9162 --- /dev/null +++ b/tests/ui/privacy/issue-113860.stderr @@ -0,0 +1,49 @@ +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/issue-113860.rs:12:5 + | +LL | pub(self) const X: u32 = 3; + | ^^^^^^^^^ + | + = note: trait items always share the visibility of their trait + +error: module has missing stability attribute + --> $DIR/issue-113860.rs:1:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | +LL | | pub trait Trait { +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: trait has missing stability attribute + --> $DIR/issue-113860.rs:4:1 + | +LL | / pub trait Trait { +LL | | +LL | | const X: u32; +LL | | +LL | | } + | |_^ + +error: implementation has missing stability attribute + --> $DIR/issue-113860.rs:10:1 + | +LL | / impl Trait for u8 { +LL | | +LL | | pub(self) const X: u32 = 3; +LL | | +LL | | } + | |_^ + +error: associated constant has missing stability attribute + --> $DIR/issue-113860.rs:6:5 + | +LL | const X: u32; + | ^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0449`. From ce4a48f41f4555ad56be404e2e28c86ed4fea4c6 Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Fri, 28 Jul 2023 09:46:16 -0400 Subject: [PATCH 128/150] Use i1 instead of bool --- compiler/rustc_codegen_llvm/src/intrinsic.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 187214a93dd7..623c08ce86b8 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -2104,9 +2104,16 @@ fn generic_simd_intrinsic<'ll, 'tcx>( ); return Ok(if matches!(name, sym::simd_ctlz | sym::simd_cttz) { - let fn_ty = bx.type_func(&[vec_ty, bx.type_bool()], vec_ty); + let fn_ty = bx.type_func(&[vec_ty, bx.type_i1()], vec_ty); let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty); - bx.call(fn_ty, None, None, f, &[args[0].immediate(), bx.const_bool(false)], None) + bx.call( + fn_ty, + None, + None, + f, + &[args[0].immediate(), bx.const_int(bx.type_i1(), 0)], + None, + ) } else { let fn_ty = bx.type_func(&[vec_ty], vec_ty); let f = bx.declare_cfn(llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty); From cac0bd0bef0661948f558592f43908221e52e2a0 Mon Sep 17 00:00:00 2001 From: bohan Date: Wed, 26 Jul 2023 22:46:49 +0800 Subject: [PATCH 129/150] fix(resolve): update the ambiguity glob binding as warning recursively --- compiler/rustc_errors/src/lib.rs | 16 +++ compiler/rustc_lint/src/context.rs | 3 + compiler/rustc_lint_defs/src/builtin.rs | 44 +++++++ compiler/rustc_lint_defs/src/lib.rs | 18 +++ .../rustc_resolve/src/build_reduced_graph.rs | 4 +- compiler/rustc_resolve/src/diagnostics.rs | 73 +++++++---- compiler/rustc_resolve/src/ident.rs | 2 + compiler/rustc_resolve/src/imports.rs | 114 +++++++++++++++--- compiler/rustc_resolve/src/lib.rs | 26 +++- tests/ui/imports/ambiguous-1.rs | 30 +++++ tests/ui/imports/ambiguous-1.stderr | 36 ++++++ tests/ui/imports/ambiguous-10.rs | 19 +++ tests/ui/imports/ambiguous-10.stderr | 25 ++++ tests/ui/imports/ambiguous-11.rs | 14 +++ tests/ui/imports/ambiguous-11.stderr | 23 ++++ tests/ui/imports/ambiguous-12.rs | 25 ++++ tests/ui/imports/ambiguous-12.stderr | 25 ++++ tests/ui/imports/ambiguous-13.rs | 22 ++++ tests/ui/imports/ambiguous-13.stderr | 25 ++++ tests/ui/imports/ambiguous-14.rs | 26 ++++ tests/ui/imports/ambiguous-14.stderr | 25 ++++ tests/ui/imports/ambiguous-15.rs | 27 +++++ tests/ui/imports/ambiguous-15.stderr | 25 ++++ tests/ui/imports/ambiguous-16.rs | 27 +++++ tests/ui/imports/ambiguous-16.stderr | 25 ++++ tests/ui/imports/ambiguous-17.rs | 29 +++++ tests/ui/imports/ambiguous-17.stderr | 35 ++++++ tests/ui/imports/ambiguous-2.rs | 9 ++ tests/ui/imports/ambiguous-3.rs | 21 ++++ tests/ui/imports/ambiguous-3.stderr | 25 ++++ tests/ui/imports/ambiguous-4-extern.rs | 26 ++++ tests/ui/imports/ambiguous-4-extern.stderr | 35 ++++++ tests/ui/imports/ambiguous-4.rs | 9 ++ tests/ui/imports/ambiguous-5.rs | 24 ++++ tests/ui/imports/ambiguous-5.stderr | 25 ++++ tests/ui/imports/ambiguous-6.rs | 20 +++ tests/ui/imports/ambiguous-6.stderr | 25 ++++ tests/ui/imports/ambiguous-7.rs | 18 +++ tests/ui/imports/ambiguous-7.stderr | 23 ++++ tests/ui/imports/ambiguous-8.rs | 14 +++ tests/ui/imports/ambiguous-8.stderr | 23 ++++ tests/ui/imports/ambiguous-9.rs | 29 +++++ tests/ui/imports/ambiguous-9.stderr | 65 ++++++++++ .../imports/auxiliary/ambiguous-11-extern.rs | 6 + .../imports/auxiliary/ambiguous-8-extern.rs | 12 ++ .../extern-with-ambiguous-1-extern.rs | 4 + .../extern-with-ambiguous-2-extern.rs | 9 ++ .../extern-with-ambiguous-3-extern.rs | 14 +++ tests/ui/imports/duplicate.rs | 2 + tests/ui/imports/duplicate.stderr | 37 ++++-- tests/ui/imports/extern-with-ambiguous-1.rs | 19 +++ .../ui/imports/extern-with-ambiguous-1.stderr | 23 ++++ tests/ui/imports/extern-with-ambiguous-2.rs | 16 +++ tests/ui/imports/extern-with-ambiguous-3.rs | 17 +++ .../ui/imports/import-after-macro-expand-1.rs | 19 +++ .../ui/imports/import-after-macro-expand-2.rs | 27 +++++ .../ui/imports/import-after-macro-expand-3.rs | 24 ++++ .../ui/imports/import-after-macro-expand-4.rs | 30 +++++ .../import-after-macro-expand-4.stderr | 53 ++++++++ .../ui/imports/import-after-macro-expand-5.rs | 31 +++++ .../ui/imports/import-after-macro-expand-6.rs | 24 ++++ .../ui/imports/import-after-macro-expand-7.rs | 21 ++++ .../ui/imports/import-after-macro-expand-8.rs | 22 ++++ .../{issue-112831.rs => derive-macro-1.rs} | 6 +- tests/ui/resolve/derive-macro-2.rs | 18 +++ 65 files changed, 1532 insertions(+), 56 deletions(-) create mode 100644 tests/ui/imports/ambiguous-1.rs create mode 100644 tests/ui/imports/ambiguous-1.stderr create mode 100644 tests/ui/imports/ambiguous-10.rs create mode 100644 tests/ui/imports/ambiguous-10.stderr create mode 100644 tests/ui/imports/ambiguous-11.rs create mode 100644 tests/ui/imports/ambiguous-11.stderr create mode 100644 tests/ui/imports/ambiguous-12.rs create mode 100644 tests/ui/imports/ambiguous-12.stderr create mode 100644 tests/ui/imports/ambiguous-13.rs create mode 100644 tests/ui/imports/ambiguous-13.stderr create mode 100644 tests/ui/imports/ambiguous-14.rs create mode 100644 tests/ui/imports/ambiguous-14.stderr create mode 100644 tests/ui/imports/ambiguous-15.rs create mode 100644 tests/ui/imports/ambiguous-15.stderr create mode 100644 tests/ui/imports/ambiguous-16.rs create mode 100644 tests/ui/imports/ambiguous-16.stderr create mode 100644 tests/ui/imports/ambiguous-17.rs create mode 100644 tests/ui/imports/ambiguous-17.stderr create mode 100644 tests/ui/imports/ambiguous-2.rs create mode 100644 tests/ui/imports/ambiguous-3.rs create mode 100644 tests/ui/imports/ambiguous-3.stderr create mode 100644 tests/ui/imports/ambiguous-4-extern.rs create mode 100644 tests/ui/imports/ambiguous-4-extern.stderr create mode 100644 tests/ui/imports/ambiguous-4.rs create mode 100644 tests/ui/imports/ambiguous-5.rs create mode 100644 tests/ui/imports/ambiguous-5.stderr create mode 100644 tests/ui/imports/ambiguous-6.rs create mode 100644 tests/ui/imports/ambiguous-6.stderr create mode 100644 tests/ui/imports/ambiguous-7.rs create mode 100644 tests/ui/imports/ambiguous-7.stderr create mode 100644 tests/ui/imports/ambiguous-8.rs create mode 100644 tests/ui/imports/ambiguous-8.stderr create mode 100644 tests/ui/imports/ambiguous-9.rs create mode 100644 tests/ui/imports/ambiguous-9.stderr create mode 100644 tests/ui/imports/auxiliary/ambiguous-11-extern.rs create mode 100644 tests/ui/imports/auxiliary/ambiguous-8-extern.rs create mode 100644 tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs create mode 100644 tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs create mode 100644 tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs create mode 100644 tests/ui/imports/extern-with-ambiguous-1.rs create mode 100644 tests/ui/imports/extern-with-ambiguous-1.stderr create mode 100644 tests/ui/imports/extern-with-ambiguous-2.rs create mode 100644 tests/ui/imports/extern-with-ambiguous-3.rs create mode 100644 tests/ui/imports/import-after-macro-expand-1.rs create mode 100644 tests/ui/imports/import-after-macro-expand-2.rs create mode 100644 tests/ui/imports/import-after-macro-expand-3.rs create mode 100644 tests/ui/imports/import-after-macro-expand-4.rs create mode 100644 tests/ui/imports/import-after-macro-expand-4.stderr create mode 100644 tests/ui/imports/import-after-macro-expand-5.rs create mode 100644 tests/ui/imports/import-after-macro-expand-6.rs create mode 100644 tests/ui/imports/import-after-macro-expand-7.rs create mode 100644 tests/ui/imports/import-after-macro-expand-8.rs rename tests/ui/resolve/{issue-112831.rs => derive-macro-1.rs} (82%) create mode 100644 tests/ui/resolve/derive-macro-2.rs diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index e01e80939cad..80f20fddf551 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1871,6 +1871,22 @@ pub fn add_elided_lifetime_in_path_suggestion( }); } +pub fn report_ambiguity_error<'a, G: EmissionGuarantee>( + db: &mut DiagnosticBuilder<'a, G>, + ambiguity: rustc_lint_defs::AmbiguityErrorDiag, +) { + db.span_label(ambiguity.label_span, ambiguity.label_msg); + db.note(ambiguity.note_msg); + db.span_note(ambiguity.b1_span, ambiguity.b1_note_msg); + for help_msg in ambiguity.b1_help_msgs { + db.help(help_msg); + } + db.span_note(ambiguity.b2_span, ambiguity.b2_note_msg); + for help_msg in ambiguity.b2_help_msgs { + db.help(help_msg); + } +} + #[derive(Clone, Copy, PartialEq, Hash, Debug)] pub enum TerminalUrl { No, diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 65c56bff8410..f7e56b305530 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -946,6 +946,9 @@ pub trait LintContext: Sized { Applicability::MachineApplicable, ); } + BuiltinLintDiagnostics::AmbiguousGlobImports { diag } => { + rustc_errors::report_ambiguity_error(db, diag); + } BuiltinLintDiagnostics::AmbiguousGlobReexports { name, namespace, first_reexport_span, duplicate_reexport_span } => { db.span_label(first_reexport_span, format!("the name `{name}` in the {namespace} namespace is first re-exported here")); db.span_label(duplicate_reexport_span, format!("but the name `{name}` in the {namespace} namespace is also re-exported here")); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index f1765d653b09..7e3b6e9e218c 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3316,6 +3316,7 @@ declare_lint_pass! { // tidy-alphabetical-start ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, AMBIGUOUS_ASSOCIATED_ITEMS, + AMBIGUOUS_GLOB_IMPORTS, AMBIGUOUS_GLOB_REEXPORTS, ARITHMETIC_OVERFLOW, ASM_SUB_REGISTER, @@ -4405,3 +4406,46 @@ declare_lint! { Warn, "unrecognized diagnostic attribute" } + +declare_lint! { + /// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity + /// errors, but previously didn't do that due to rustc bugs. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// + /// #![deny(ambiguous_glob_imports)] + /// pub fn foo() -> u32 { + /// use sub::*; + /// C + /// } + /// + /// mod sub { + /// mod mod1 { pub const C: u32 = 1; } + /// mod mod2 { pub const C: u32 = 2; } + /// + /// pub use mod1::*; + /// pub use mod2::*; + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Previous versions of Rust compile it successfully because it + /// had lost the ambiguity error when resolve `use sub::mod2::*`. + /// + /// This is a [future-incompatible] lint to transition this to a + /// hard error in the future. + /// + /// [future-incompatible]: ../index.md#future-incompatible-lints + pub AMBIGUOUS_GLOB_IMPORTS, + Warn, + "detects certain glob imports that require reporting an ambiguity error", + @future_incompatible = FutureIncompatibleInfo { + reason: FutureIncompatibilityReason::FutureReleaseError, + reference: "issue #114095 ", + }; +} diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 10ebe29dfce6..f350957f72f1 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -467,6 +467,21 @@ impl ToStableHashKey for LintId { } } +#[derive(Debug)] +pub struct AmbiguityErrorDiag { + pub msg: String, + pub span: Span, + pub label_span: Span, + pub label_msg: String, + pub note_msg: String, + pub b1_span: Span, + pub b1_note_msg: String, + pub b1_help_msgs: Vec, + pub b2_span: Span, + pub b2_note_msg: String, + pub b2_help_msgs: Vec, +} + // This could be a closure, but then implementing derive trait // becomes hacky (and it gets allocated). #[derive(Debug)] @@ -530,6 +545,9 @@ pub enum BuiltinLintDiagnostics { vis_span: Span, ident_span: Span, }, + AmbiguousGlobImports { + diag: AmbiguityErrorDiag, + }, AmbiguousGlobReexports { /// The name for which collision(s) have occurred. name: String, diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index ff63e4e33cb9..5814e3d6c13a 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -41,6 +41,7 @@ impl<'a, Id: Into> ToNameBinding<'a> arenas.alloc_name_binding(NameBindingData { kind: NameBindingKind::Module(self.0), ambiguity: None, + warn_ambiguity: false, vis: self.1.to_def_id(), span: self.2, expansion: self.3, @@ -53,6 +54,7 @@ impl<'a, Id: Into> ToNameBinding<'a> for (Res, ty::Visibility, Span, arenas.alloc_name_binding(NameBindingData { kind: NameBindingKind::Res(self.0), ambiguity: None, + warn_ambiguity: false, vis: self.1.to_def_id(), span: self.2, expansion: self.3, @@ -69,7 +71,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { { let binding = def.to_name_binding(self.arenas); let key = self.new_disambiguated_key(ident, ns); - if let Err(old_binding) = self.try_define(parent, key, binding) { + if let Err(old_binding) = self.try_define(parent, key, binding, false) { self.report_conflict(parent, ident, ns, old_binding, binding); } } diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 73cd596c0769..97ac6891d82c 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -5,10 +5,8 @@ use rustc_ast::{self as ast, Crate, ItemKind, ModKind, NodeId, Path, CRATE_NODE_ use rustc_ast::{MetaItemKind, NestedMetaItem}; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{ - pluralize, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, -}; -use rustc_errors::{struct_span_err, SuggestionStyle}; +use rustc_errors::{pluralize, report_ambiguity_error, struct_span_err, SuggestionStyle}; +use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan}; use rustc_feature::BUILTIN_ATTRIBUTES; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind, PerNS}; @@ -17,8 +15,9 @@ use rustc_hir::PrimTy; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE; +use rustc_session::lint::builtin::AMBIGUOUS_GLOB_IMPORTS; use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS; -use rustc_session::lint::BuiltinLintDiagnostics; +use rustc_session::lint::{AmbiguityErrorDiag, BuiltinLintDiagnostics}; use rustc_session::Session; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edition::Edition; @@ -135,7 +134,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } for ambiguity_error in &self.ambiguity_errors { - self.report_ambiguity_error(ambiguity_error); + let diag = self.ambiguity_diagnostics(ambiguity_error); + if ambiguity_error.warning { + let NameBindingKind::Import { import, .. } = ambiguity_error.b1.0.kind else { + unreachable!() + }; + self.lint_buffer.buffer_lint_with_diagnostic( + AMBIGUOUS_GLOB_IMPORTS, + import.root_id, + ambiguity_error.ident.span, + diag.msg.to_string(), + BuiltinLintDiagnostics::AmbiguousGlobImports { diag }, + ); + } else { + let mut err = struct_span_err!(self.tcx.sess, diag.span, E0659, "{}", &diag.msg); + report_ambiguity_error(&mut err, diag); + err.emit(); + } } let mut reported_spans = FxHashSet::default(); @@ -1540,20 +1555,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } - fn report_ambiguity_error(&self, ambiguity_error: &AmbiguityError<'_>) { - let AmbiguityError { kind, ident, b1, b2, misc1, misc2 } = *ambiguity_error; + fn ambiguity_diagnostics(&self, ambiguity_error: &AmbiguityError<'_>) -> AmbiguityErrorDiag { + let AmbiguityError { kind, ident, b1, b2, misc1, misc2, .. } = *ambiguity_error; let (b1, b2, misc1, misc2, swapped) = if b2.span.is_dummy() && !b1.span.is_dummy() { // We have to print the span-less alternative first, otherwise formatting looks bad. (b2, b1, misc2, misc1, true) } else { (b1, b2, misc1, misc2, false) }; - - let mut err = struct_span_err!(self.tcx.sess, ident.span, E0659, "`{ident}` is ambiguous"); - err.span_label(ident.span, "ambiguous name"); - err.note(format!("ambiguous because of {}", kind.descr())); - - let mut could_refer_to = |b: NameBinding<'_>, misc: AmbiguityErrorMisc, also: &str| { + let could_refer_to = |b: NameBinding<'_>, misc: AmbiguityErrorMisc, also: &str| { let what = self.binding_description(b, ident, misc == AmbiguityErrorMisc::FromPrelude); let note_msg = format!("`{ident}` could{also} refer to {what}"); @@ -1579,16 +1589,35 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { AmbiguityErrorMisc::FromPrelude | AmbiguityErrorMisc::None => {} } - err.span_note(b.span, note_msg); - for (i, help_msg) in help_msgs.iter().enumerate() { - let or = if i == 0 { "" } else { "or " }; - err.help(format!("{}{}", or, help_msg)); - } + ( + b.span, + note_msg, + help_msgs + .iter() + .enumerate() + .map(|(i, help_msg)| { + let or = if i == 0 { "" } else { "or " }; + format!("{}{}", or, help_msg) + }) + .collect::>(), + ) }; + let (b1_span, b1_note_msg, b1_help_msgs) = could_refer_to(b1, misc1, ""); + let (b2_span, b2_note_msg, b2_help_msgs) = could_refer_to(b2, misc2, " also"); - could_refer_to(b1, misc1, ""); - could_refer_to(b2, misc2, " also"); - err.emit(); + AmbiguityErrorDiag { + msg: format!("`{ident}` is ambiguous"), + span: ident.span, + label_span: ident.span, + label_msg: "ambiguous name".to_string(), + note_msg: format!("ambiguous because of {}", kind.descr()), + b1_span, + b1_note_msg, + b1_help_msgs, + b2_span, + b2_note_msg, + b2_help_msgs, + } } /// If the binding refers to a tuple struct constructor with fields, diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index de4314447698..00282df700b0 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -677,6 +677,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ident: orig_ident, b1: innermost_binding, b2: binding, + warning: false, misc1: misc(innermost_flags), misc2: misc(flags), }); @@ -905,6 +906,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ident, b1: binding, b2: shadowed_glob, + warning: false, misc1: AmbiguityErrorMisc::None, misc2: AmbiguityErrorMisc::None, }); diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index f3cf61c5b932..e1dae57d34f4 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -284,6 +284,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.arenas.alloc_name_binding(NameBindingData { kind: NameBindingKind::Import { binding, import, used: Cell::new(false) }, ambiguity: None, + warn_ambiguity: false, span: import.span, vis, expansion: import.parent_scope.expansion, @@ -291,16 +292,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } /// Define the name or return the existing binding if there is a collision. + /// `update` indicates if the definition is a redefinition of an existing binding. pub(crate) fn try_define( &mut self, module: Module<'a>, key: BindingKey, binding: NameBinding<'a>, + warn_ambiguity: bool, ) -> Result<(), NameBinding<'a>> { let res = binding.res(); self.check_reserved_macro_name(key.ident, res); self.set_binding_parent_module(binding, module); - self.update_resolution(module, key, |this, resolution| { + self.update_resolution(module, key, warn_ambiguity, |this, resolution| { if let Some(old_binding) = resolution.binding { if res == Res::Err && old_binding.res() != Res::Err { // Do not override real bindings with `Res::Err`s from error recovery. @@ -308,15 +311,42 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } match (old_binding.is_glob_import(), binding.is_glob_import()) { (true, true) => { - if res != old_binding.res() { - resolution.binding = Some(this.ambiguity( - AmbiguityKind::GlobVsGlob, - old_binding, - binding, - )); + // FIXME: remove `!binding.is_ambiguity()` after delete the warning ambiguity. + if !binding.is_ambiguity() + && let NameBindingKind::Import { import: old_import, .. } = old_binding.kind + && let NameBindingKind::Import { import, .. } = binding.kind + && old_import == import { + // We should replace the `old_binding` with `binding` regardless + // of whether they has same resolution or not when they are + // imported from the same glob-import statement. + // However we currently using `Some(old_binding)` for back compact + // purposes. + // This case can be removed after once `Undetermined` is prepared + // for glob-imports. + } else if res != old_binding.res() { + let binding = if warn_ambiguity { + this.warn_ambiguity( + AmbiguityKind::GlobVsGlob, + old_binding, + binding, + ) + } else { + this.ambiguity( + AmbiguityKind::GlobVsGlob, + old_binding, + binding, + ) + }; + resolution.binding = Some(binding); } else if !old_binding.vis.is_at_least(binding.vis, this.tcx) { // We are glob-importing the same item but with greater visibility. resolution.binding = Some(binding); + } else if binding.is_ambiguity() { + resolution.binding = + Some(self.arenas.alloc_name_binding(NameBindingData { + warn_ambiguity: true, + ..(*binding).clone() + })); } } (old_glob @ true, false) | (old_glob @ false, true) => { @@ -374,29 +404,52 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { }) } + fn warn_ambiguity( + &self, + kind: AmbiguityKind, + primary_binding: NameBinding<'a>, + secondary_binding: NameBinding<'a>, + ) -> NameBinding<'a> { + self.arenas.alloc_name_binding(NameBindingData { + ambiguity: Some((secondary_binding, kind)), + warn_ambiguity: true, + ..(*primary_binding).clone() + }) + } + // Use `f` to mutate the resolution of the name in the module. // If the resolution becomes a success, define it in the module's glob importers. - fn update_resolution(&mut self, module: Module<'a>, key: BindingKey, f: F) -> T + fn update_resolution( + &mut self, + module: Module<'a>, + key: BindingKey, + warn_ambiguity: bool, + f: F, + ) -> T where F: FnOnce(&mut Resolver<'a, 'tcx>, &mut NameResolution<'a>) -> T, { // Ensure that `resolution` isn't borrowed when defining in the module's glob importers, // during which the resolution might end up getting re-defined via a glob cycle. - let (binding, t) = { + let (binding, t, warn_ambiguity) = { let resolution = &mut *self.resolution(module, key).borrow_mut(); let old_binding = resolution.binding(); let t = f(self, resolution); - if old_binding.is_none() && let Some(binding) = resolution.binding() { - (binding, t) + if let Some(binding) = resolution.binding() && old_binding != Some(binding) { + (binding, t, warn_ambiguity || old_binding.is_some()) } else { return t; } }; - // Define `binding` in `module`s glob importers. - for import in module.glob_importers.borrow_mut().iter() { + let Ok(glob_importers) = module.glob_importers.try_borrow_mut() else { + return t; + }; + + // Define or update `binding` in `module`s glob importers. + for import in glob_importers.iter() { let mut ident = key.ident; let scope = match ident.span.reverse_glob_adjust(module.expansion, import.span) { Some(Some(def)) => self.expn_def_scope(def), @@ -406,7 +459,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { if self.is_accessible_from(binding.vis, scope) { let imported_binding = self.import(binding, *import); let key = BindingKey { ident, ..key }; - let _ = self.try_define(import.parent_scope.module, key, imported_binding); + let _ = self.try_define( + import.parent_scope.module, + key, + imported_binding, + warn_ambiguity, + ); } } @@ -425,7 +483,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let dummy_binding = self.import(dummy_binding, import); self.per_ns(|this, ns| { let key = BindingKey::new(target, ns); - let _ = this.try_define(import.parent_scope.module, key, dummy_binding); + let _ = this.try_define(import.parent_scope.module, key, dummy_binding, false); }); self.record_use(target, dummy_binding, false); } else if import.imported_module.get().is_none() { @@ -700,7 +758,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { Segment::names_to_string(&import.module_path), module_to_string(import.parent_scope.module).unwrap_or_else(|| "???".to_string()), ); - let module = if let Some(module) = import.imported_module.get() { module } else { @@ -773,7 +830,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { .emit(); } let key = BindingKey::new(target, ns); - this.update_resolution(parent, key, |_, resolution| { + this.update_resolution(parent, key, false, |_, resolution| { resolution.single_imports.remove(&import); }); } @@ -989,7 +1046,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { initial_binding.res() }); let res = binding.res(); - if res == Res::Err || !this.ambiguity_errors.is_empty() { + let has_ambiguity_error = this + .ambiguity_errors + .iter() + .filter(|error| !error.warning) + .next() + .is_some(); + if res == Res::Err || has_ambiguity_error { this.tcx .sess .delay_span_bug(import.span, "some error happened for an import"); @@ -1338,7 +1401,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { }; if self.is_accessible_from(binding.vis, scope) { let imported_binding = self.import(binding, import); - let _ = self.try_define(import.parent_scope.module, key, imported_binding); + let warn_ambiguity = self + .resolution(import.parent_scope.module, key) + .borrow() + .binding() + .is_some_and(|binding| binding.is_warn_ambiguity()); + let _ = self.try_define( + import.parent_scope.module, + key, + imported_binding, + warn_ambiguity, + ); } } @@ -1357,7 +1430,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { module.for_each_child(self, |this, ident, _, binding| { let res = binding.res().expect_non_local(); - if res != def::Res::Err && !binding.is_ambiguity() { + let error_ambiguity = binding.is_ambiguity() && !binding.warn_ambiguity; + if res != def::Res::Err && !error_ambiguity { let mut reexport_chain = SmallVec::new(); let mut next_binding = binding; while let NameBindingKind::Import { binding, import, .. } = next_binding.kind { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index faa672db59cc..91d89f44dbf2 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -658,6 +658,7 @@ impl<'a> fmt::Debug for Module<'a> { struct NameBindingData<'a> { kind: NameBindingKind<'a>, ambiguity: Option<(NameBinding<'a>, AmbiguityKind)>, + warn_ambiguity: bool, expansion: LocalExpnId, span: Span, vis: ty::Visibility, @@ -767,6 +768,7 @@ struct AmbiguityError<'a> { b2: NameBinding<'a>, misc1: AmbiguityErrorMisc, misc2: AmbiguityErrorMisc, + warning: bool, } impl<'a> NameBindingData<'a> { @@ -794,6 +796,14 @@ impl<'a> NameBindingData<'a> { } } + fn is_warn_ambiguity(&self) -> bool { + self.warn_ambiguity + || match self.kind { + NameBindingKind::Import { binding, .. } => binding.is_warn_ambiguity(), + _ => false, + } + } + fn is_possibly_imported_variant(&self) -> bool { match self.kind { NameBindingKind::Import { binding, .. } => binding.is_possibly_imported_variant(), @@ -1322,6 +1332,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { dummy_binding: arenas.alloc_name_binding(NameBindingData { kind: NameBindingKind::Res(Res::Err), ambiguity: None, + warn_ambiguity: false, expansion: LocalExpnId::ROOT, span: DUMMY_SP, vis: ty::Visibility::Public, @@ -1685,6 +1696,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } fn record_use(&mut self, ident: Ident, used_binding: NameBinding<'a>, is_lexical_scope: bool) { + self.record_use_inner(ident, used_binding, is_lexical_scope, used_binding.warn_ambiguity); + } + + fn record_use_inner( + &mut self, + ident: Ident, + used_binding: NameBinding<'a>, + is_lexical_scope: bool, + warn_ambiguity: bool, + ) { if let Some((b2, kind)) = used_binding.ambiguity { let ambiguity_error = AmbiguityError { kind, @@ -1693,9 +1714,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { b2, misc1: AmbiguityErrorMisc::None, misc2: AmbiguityErrorMisc::None, + warning: warn_ambiguity, }; if !self.matches_previous_ambiguity_error(&ambiguity_error) { - // avoid duplicated span information to be emitt out + // avoid duplicated span information to be emit out self.ambiguity_errors.push(ambiguity_error); } } @@ -1715,7 +1737,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.used_imports.insert(id); } self.add_to_glob_map(import, ident); - self.record_use(ident, binding, false); + self.record_use_inner(ident, binding, false, warn_ambiguity || binding.warn_ambiguity); } } diff --git a/tests/ui/imports/ambiguous-1.rs b/tests/ui/imports/ambiguous-1.rs new file mode 100644 index 000000000000..2c9815864f01 --- /dev/null +++ b/tests/ui/imports/ambiguous-1.rs @@ -0,0 +1,30 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 + +macro_rules! m { + () => { + pub fn id() {} + }; +} + +mod openssl { + pub use self::evp::*; + //~^ WARNING ambiguous glob re-exports + pub use self::handwritten::*; + + mod evp { + m!(); + } + + mod handwritten { + m!(); + } +} + +pub use openssl::*; + +fn main() { + id(); + //~^ WARNING `id` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-1.stderr b/tests/ui/imports/ambiguous-1.stderr new file mode 100644 index 000000000000..61b3077c354e --- /dev/null +++ b/tests/ui/imports/ambiguous-1.stderr @@ -0,0 +1,36 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-1.rs:11:13 + | +LL | pub use self::evp::*; + | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here +LL | +LL | pub use self::handwritten::*; + | -------------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `id` is ambiguous + --> $DIR/ambiguous-1.rs:27:5 + | +LL | id(); + | ^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `id` could refer to the function imported here + --> $DIR/ambiguous-1.rs:11:13 + | +LL | pub use self::evp::*; + | ^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate +note: `id` could also refer to the function imported here + --> $DIR/ambiguous-1.rs:13:13 + | +LL | pub use self::handwritten::*; + | ^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 2 warnings emitted + diff --git a/tests/ui/imports/ambiguous-10.rs b/tests/ui/imports/ambiguous-10.rs new file mode 100644 index 000000000000..5078b734b472 --- /dev/null +++ b/tests/ui/imports/ambiguous-10.rs @@ -0,0 +1,19 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +mod a { + pub enum Token {} +} + +mod b { + use crate::a::*; + #[derive(Debug)] + pub enum Token {} +} + +use crate::a::*; +use crate::b::*; +fn c(_: Token) {} +//~^ WARNING `Token` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +fn main() { } diff --git a/tests/ui/imports/ambiguous-10.stderr b/tests/ui/imports/ambiguous-10.stderr new file mode 100644 index 000000000000..704af616b438 --- /dev/null +++ b/tests/ui/imports/ambiguous-10.stderr @@ -0,0 +1,25 @@ +warning: `Token` is ambiguous + --> $DIR/ambiguous-10.rs:16:9 + | +LL | fn c(_: Token) {} + | ^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Token` could refer to the enum imported here + --> $DIR/ambiguous-10.rs:14:5 + | +LL | use crate::a::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Token` to disambiguate +note: `Token` could also refer to the enum imported here + --> $DIR/ambiguous-10.rs:15:5 + | +LL | use crate::b::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Token` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-11.rs b/tests/ui/imports/ambiguous-11.rs new file mode 100644 index 000000000000..0565b9d22acd --- /dev/null +++ b/tests/ui/imports/ambiguous-11.rs @@ -0,0 +1,14 @@ +// aux-build: ambiguous-11-extern.rs + +extern crate ambiguous_11_extern; + +mod s { + pub trait Error {} +} + +use s::*; +use ambiguous_11_extern::*; +fn a(_: E) {} +//~^ ERROR `Error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/ambiguous-11.stderr b/tests/ui/imports/ambiguous-11.stderr new file mode 100644 index 000000000000..765d6afa8d7e --- /dev/null +++ b/tests/ui/imports/ambiguous-11.stderr @@ -0,0 +1,23 @@ +error[E0659]: `Error` is ambiguous + --> $DIR/ambiguous-11.rs:11:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-11.rs:9:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-11.rs:10:5 + | +LL | use ambiguous_11_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-12.rs b/tests/ui/imports/ambiguous-12.rs new file mode 100644 index 000000000000..6259c13572c7 --- /dev/null +++ b/tests/ui/imports/ambiguous-12.rs @@ -0,0 +1,25 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +macro_rules! m { + () => { + pub fn b() {} + }; +} + +pub mod ciphertext { + m!(); +} +pub mod public { + use crate::ciphertext::*; + m!(); +} + +use crate::ciphertext::*; +use crate::public::*; + +fn main() { + b(); + //~^ WARNING `b` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-12.stderr b/tests/ui/imports/ambiguous-12.stderr new file mode 100644 index 000000000000..4725c38849c2 --- /dev/null +++ b/tests/ui/imports/ambiguous-12.stderr @@ -0,0 +1,25 @@ +warning: `b` is ambiguous + --> $DIR/ambiguous-12.rs:22:5 + | +LL | b(); + | ^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `b` could refer to the function imported here + --> $DIR/ambiguous-12.rs:18:5 + | +LL | use crate::ciphertext::*; + | ^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `b` to disambiguate +note: `b` could also refer to the function imported here + --> $DIR/ambiguous-12.rs:19:5 + | +LL | use crate::public::*; + | ^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `b` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-13.rs b/tests/ui/imports/ambiguous-13.rs new file mode 100644 index 000000000000..82f933c49ac2 --- /dev/null +++ b/tests/ui/imports/ambiguous-13.rs @@ -0,0 +1,22 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +pub mod object { + #[derive(Debug)] + pub struct Rect; +} + +pub mod content { + use crate::object::*; + + #[derive(Debug)] + pub struct Rect; +} + +use crate::object::*; +use crate::content::*; + +fn a(_: Rect) {} +//~^ WARNING `Rect` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +fn main() { } diff --git a/tests/ui/imports/ambiguous-13.stderr b/tests/ui/imports/ambiguous-13.stderr new file mode 100644 index 000000000000..3e78100b658f --- /dev/null +++ b/tests/ui/imports/ambiguous-13.stderr @@ -0,0 +1,25 @@ +warning: `Rect` is ambiguous + --> $DIR/ambiguous-13.rs:19:9 + | +LL | fn a(_: Rect) {} + | ^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Rect` could refer to the struct imported here + --> $DIR/ambiguous-13.rs:16:5 + | +LL | use crate::object::*; + | ^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Rect` to disambiguate +note: `Rect` could also refer to the struct imported here + --> $DIR/ambiguous-13.rs:17:5 + | +LL | use crate::content::*; + | ^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Rect` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-14.rs b/tests/ui/imports/ambiguous-14.rs new file mode 100644 index 000000000000..5e880b48c36f --- /dev/null +++ b/tests/ui/imports/ambiguous-14.rs @@ -0,0 +1,26 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/98467 + +mod a { + pub fn foo() {} +} + +mod b { + pub fn foo() {} +} + +mod f { + pub use a::*; + pub use b::*; +} + +mod g { + pub use a::*; + pub use f::*; +} + +fn main() { + g::foo(); + //~^ WARNING `foo` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-14.stderr b/tests/ui/imports/ambiguous-14.stderr new file mode 100644 index 000000000000..bece58536682 --- /dev/null +++ b/tests/ui/imports/ambiguous-14.stderr @@ -0,0 +1,25 @@ +warning: `foo` is ambiguous + --> $DIR/ambiguous-14.rs:23:8 + | +LL | g::foo(); + | ^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `foo` could refer to the function imported here + --> $DIR/ambiguous-14.rs:13:13 + | +LL | pub use a::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the function imported here + --> $DIR/ambiguous-14.rs:14:13 + | +LL | pub use b::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-15.rs b/tests/ui/imports/ambiguous-15.rs new file mode 100644 index 000000000000..8c75c393a416 --- /dev/null +++ b/tests/ui/imports/ambiguous-15.rs @@ -0,0 +1,27 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +mod t2 { + #[derive(Debug)] + pub enum Error {} + + mod s { + pub use std::fmt::*; + pub trait Error: Sized {} + } + + use self::s::*; +} + +pub use t2::*; + +mod t3 { + pub trait Error {} +} + +use self::t3::*; +fn a(_: E) {} +//~^ WARNING `Error` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +fn main() {} diff --git a/tests/ui/imports/ambiguous-15.stderr b/tests/ui/imports/ambiguous-15.stderr new file mode 100644 index 000000000000..838256752d0c --- /dev/null +++ b/tests/ui/imports/ambiguous-15.stderr @@ -0,0 +1,25 @@ +warning: `Error` is ambiguous + --> $DIR/ambiguous-15.rs:23:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-15.rs:22:5 + | +LL | use self::t3::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-15.rs:16:9 + | +LL | pub use t2::*; + | ^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-16.rs b/tests/ui/imports/ambiguous-16.rs new file mode 100644 index 000000000000..e51e30e3ed50 --- /dev/null +++ b/tests/ui/imports/ambiguous-16.rs @@ -0,0 +1,27 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099 + +mod framing { + mod public_message { + use super::*; + + #[derive(Debug)] + pub struct ConfirmedTranscriptHashInput; + } + + mod public_message_in { + use super::*; + + #[derive(Debug)] + pub struct ConfirmedTranscriptHashInput; + } + + pub use self::public_message::*; + pub use self::public_message_in::*; +} + +use crate::framing::ConfirmedTranscriptHashInput; +//~^ WARNING `ConfirmedTranscriptHashInput` is ambiguous +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +fn main() { } diff --git a/tests/ui/imports/ambiguous-16.stderr b/tests/ui/imports/ambiguous-16.stderr new file mode 100644 index 000000000000..7366cabc47a6 --- /dev/null +++ b/tests/ui/imports/ambiguous-16.stderr @@ -0,0 +1,25 @@ +warning: `ConfirmedTranscriptHashInput` is ambiguous + --> $DIR/ambiguous-16.rs:23:21 + | +LL | use crate::framing::ConfirmedTranscriptHashInput; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `ConfirmedTranscriptHashInput` could refer to the struct imported here + --> $DIR/ambiguous-16.rs:19:13 + | +LL | pub use self::public_message::*; + | ^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate +note: `ConfirmedTranscriptHashInput` could also refer to the struct imported here + --> $DIR/ambiguous-16.rs:20:13 + | +LL | pub use self::public_message_in::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-17.rs b/tests/ui/imports/ambiguous-17.rs new file mode 100644 index 000000000000..7d01404ce07a --- /dev/null +++ b/tests/ui/imports/ambiguous-17.rs @@ -0,0 +1,29 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +pub use evp::*; //~ WARNING ambiguous glob re-exports +pub use handwritten::*; + +macro_rules! m { + () => { + pub fn id() {} + }; +} +mod evp { + use *; + m!(); +} + +mod handwritten { + pub use handwritten::evp::*; + mod evp { + use *; + m!(); + } +} + +fn main() { + id(); + //~^ WARNING `id` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-17.stderr b/tests/ui/imports/ambiguous-17.stderr new file mode 100644 index 000000000000..55bc01095c7b --- /dev/null +++ b/tests/ui/imports/ambiguous-17.stderr @@ -0,0 +1,35 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-17.rs:4:9 + | +LL | pub use evp::*; + | ^^^^^^ the name `id` in the value namespace is first re-exported here +LL | pub use handwritten::*; + | -------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `id` is ambiguous + --> $DIR/ambiguous-17.rs:26:5 + | +LL | id(); + | ^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `id` could refer to the function imported here + --> $DIR/ambiguous-17.rs:4:9 + | +LL | pub use evp::*; + | ^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate +note: `id` could also refer to the function imported here + --> $DIR/ambiguous-17.rs:5:9 + | +LL | pub use handwritten::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 2 warnings emitted + diff --git a/tests/ui/imports/ambiguous-2.rs b/tests/ui/imports/ambiguous-2.rs new file mode 100644 index 000000000000..7b38f3006b10 --- /dev/null +++ b/tests/ui/imports/ambiguous-2.rs @@ -0,0 +1,9 @@ +// check-pass +// aux-build: ../ambiguous-1.rs +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396 + +extern crate ambiguous_1; + +fn main() { + ambiguous_1::id(); +} diff --git a/tests/ui/imports/ambiguous-3.rs b/tests/ui/imports/ambiguous-3.rs new file mode 100644 index 000000000000..61a5b6b83fbb --- /dev/null +++ b/tests/ui/imports/ambiguous-3.rs @@ -0,0 +1,21 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/47525 + +fn main() { + use a::*; + x(); + //~^ WARNING `x` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +mod a { + mod b { + pub fn x() { println!(module_path!()); } + } + mod c { + pub fn x() { println!(module_path!()); } + } + + pub use self::b::*; + pub use self::c::*; +} diff --git a/tests/ui/imports/ambiguous-3.stderr b/tests/ui/imports/ambiguous-3.stderr new file mode 100644 index 000000000000..f019f6d89574 --- /dev/null +++ b/tests/ui/imports/ambiguous-3.stderr @@ -0,0 +1,25 @@ +warning: `x` is ambiguous + --> $DIR/ambiguous-3.rs:6:5 + | +LL | x(); + | ^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `x` could refer to the function imported here + --> $DIR/ambiguous-3.rs:19:13 + | +LL | pub use self::b::*; + | ^^^^^^^^^^ + = help: consider adding an explicit import of `x` to disambiguate +note: `x` could also refer to the function imported here + --> $DIR/ambiguous-3.rs:20:13 + | +LL | pub use self::c::*; + | ^^^^^^^^^^ + = help: consider adding an explicit import of `x` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-4-extern.rs b/tests/ui/imports/ambiguous-4-extern.rs new file mode 100644 index 000000000000..02546768e0e5 --- /dev/null +++ b/tests/ui/imports/ambiguous-4-extern.rs @@ -0,0 +1,26 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 + +macro_rules! m { + () => { + pub fn id() {} + }; +} + +pub use evp::*; //~ WARNING ambiguous glob re-exports +pub use handwritten::*; + +mod evp { + use *; + m! {} +} +mod handwritten { + use *; + m! {} +} + +fn main() { + id(); + //~^ WARNING `id` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-4-extern.stderr b/tests/ui/imports/ambiguous-4-extern.stderr new file mode 100644 index 000000000000..0011973212bc --- /dev/null +++ b/tests/ui/imports/ambiguous-4-extern.stderr @@ -0,0 +1,35 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-4-extern.rs:10:9 + | +LL | pub use evp::*; + | ^^^^^^ the name `id` in the value namespace is first re-exported here +LL | pub use handwritten::*; + | -------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `id` is ambiguous + --> $DIR/ambiguous-4-extern.rs:23:5 + | +LL | id(); + | ^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `id` could refer to the function imported here + --> $DIR/ambiguous-4-extern.rs:10:9 + | +LL | pub use evp::*; + | ^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate +note: `id` could also refer to the function imported here + --> $DIR/ambiguous-4-extern.rs:11:9 + | +LL | pub use handwritten::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `id` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 2 warnings emitted + diff --git a/tests/ui/imports/ambiguous-4.rs b/tests/ui/imports/ambiguous-4.rs new file mode 100644 index 000000000000..10f883339c31 --- /dev/null +++ b/tests/ui/imports/ambiguous-4.rs @@ -0,0 +1,9 @@ +// check-pass +// aux-build: ../ambiguous-4-extern.rs + +extern crate ambiguous_4_extern; + +fn main() { + ambiguous_4_extern::id(); + // `warning_ambiguous` had been lost at metadata. +} diff --git a/tests/ui/imports/ambiguous-5.rs b/tests/ui/imports/ambiguous-5.rs new file mode 100644 index 000000000000..56092246ab3a --- /dev/null +++ b/tests/ui/imports/ambiguous-5.rs @@ -0,0 +1,24 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1637022296 + +mod a { + pub struct Class(u16); +} + +use a::Class; + +mod gpos { + use super::gsubgpos::*; + use super::*; + struct MarkRecord(Class); + //~^ WARNING `Class` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +mod gsubgpos { + use super::*; + #[derive(Clone)] + pub struct Class; +} + +fn main() { } diff --git a/tests/ui/imports/ambiguous-5.stderr b/tests/ui/imports/ambiguous-5.stderr new file mode 100644 index 000000000000..4bc35f86d3ad --- /dev/null +++ b/tests/ui/imports/ambiguous-5.stderr @@ -0,0 +1,25 @@ +warning: `Class` is ambiguous + --> $DIR/ambiguous-5.rs:13:23 + | +LL | struct MarkRecord(Class); + | ^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Class` could refer to the struct imported here + --> $DIR/ambiguous-5.rs:12:9 + | +LL | use super::*; + | ^^^^^^^^ + = help: consider adding an explicit import of `Class` to disambiguate +note: `Class` could also refer to the struct imported here + --> $DIR/ambiguous-5.rs:11:9 + | +LL | use super::gsubgpos::*; + | ^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Class` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-6.rs b/tests/ui/imports/ambiguous-6.rs new file mode 100644 index 000000000000..ba2623bf48a6 --- /dev/null +++ b/tests/ui/imports/ambiguous-6.rs @@ -0,0 +1,20 @@ +// check-pass +// edition: 2021 +// https://github.com/rust-lang/rust/issues/112713 + +pub fn foo() -> u32 { + use sub::*; + C + //~^ WARNING `C` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +mod sub { + mod mod1 { pub const C: u32 = 1; } + mod mod2 { pub const C: u32 = 2; } + + pub use mod1::*; + pub use mod2::*; +} + +fn main() {} diff --git a/tests/ui/imports/ambiguous-6.stderr b/tests/ui/imports/ambiguous-6.stderr new file mode 100644 index 000000000000..d7871a0b8cbe --- /dev/null +++ b/tests/ui/imports/ambiguous-6.stderr @@ -0,0 +1,25 @@ +warning: `C` is ambiguous + --> $DIR/ambiguous-6.rs:7:5 + | +LL | C + | ^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `C` could refer to the constant imported here + --> $DIR/ambiguous-6.rs:16:13 + | +LL | pub use mod1::*; + | ^^^^^^^ + = help: consider adding an explicit import of `C` to disambiguate +note: `C` could also refer to the constant imported here + --> $DIR/ambiguous-6.rs:17:13 + | +LL | pub use mod2::*; + | ^^^^^^^ + = help: consider adding an explicit import of `C` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/imports/ambiguous-7.rs b/tests/ui/imports/ambiguous-7.rs new file mode 100644 index 000000000000..5148ff4cc339 --- /dev/null +++ b/tests/ui/imports/ambiguous-7.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +mod t2 { + #[derive(Debug)] + pub enum Error {} +} + +pub use t2::*; + +mod t3 { + pub trait Error {} +} + +use self::t3::*; +fn a(_: E) {} +//~^ ERROR `Error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/ambiguous-7.stderr b/tests/ui/imports/ambiguous-7.stderr new file mode 100644 index 000000000000..2c6b56c61fd4 --- /dev/null +++ b/tests/ui/imports/ambiguous-7.stderr @@ -0,0 +1,23 @@ +error[E0659]: `Error` is ambiguous + --> $DIR/ambiguous-7.rs:15:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-7.rs:14:5 + | +LL | use self::t3::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-7.rs:8:9 + | +LL | pub use t2::*; + | ^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-8.rs b/tests/ui/imports/ambiguous-8.rs new file mode 100644 index 000000000000..d44cd9587acf --- /dev/null +++ b/tests/ui/imports/ambiguous-8.rs @@ -0,0 +1,14 @@ +// aux-build: ambiguous-8-extern.rs + +extern crate ambiguous_8_extern; + +mod s { + pub trait Error {} +} + +use s::*; +use ambiguous_8_extern::*; +fn a(_: E) {} +//~^ ERROR `Error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/ambiguous-8.stderr b/tests/ui/imports/ambiguous-8.stderr new file mode 100644 index 000000000000..32056fba69f9 --- /dev/null +++ b/tests/ui/imports/ambiguous-8.stderr @@ -0,0 +1,23 @@ +error[E0659]: `Error` is ambiguous + --> $DIR/ambiguous-8.rs:11:9 + | +LL | fn a(_: E) {} + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Error` could refer to the trait imported here + --> $DIR/ambiguous-8.rs:9:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `Error` to disambiguate +note: `Error` could also refer to the enum imported here + --> $DIR/ambiguous-8.rs:10:5 + | +LL | use ambiguous_8_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `Error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-9.rs b/tests/ui/imports/ambiguous-9.rs new file mode 100644 index 000000000000..9da2467ad9d2 --- /dev/null +++ b/tests/ui/imports/ambiguous-9.rs @@ -0,0 +1,29 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1638206152 + +pub mod dsl { + mod range { + pub fn date_range() {} + } + pub use self::range::*; //~ WARNING ambiguous glob re-exports + use super::prelude::*; +} + +pub mod prelude { + mod t { + pub fn date_range() {} + } + pub use self::t::*; //~ WARNING ambiguous glob re-exports + pub use super::dsl::*; +} + +use dsl::*; +use prelude::*; + +fn main() { + date_range(); + //~^ WARNING `date_range` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| WARNING `date_range` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} diff --git a/tests/ui/imports/ambiguous-9.stderr b/tests/ui/imports/ambiguous-9.stderr new file mode 100644 index 000000000000..6c7d79174daf --- /dev/null +++ b/tests/ui/imports/ambiguous-9.stderr @@ -0,0 +1,65 @@ +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:8:13 + | +LL | pub use self::range::*; + | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | use super::prelude::*; + | ----------------- but the name `date_range` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: `date_range` is ambiguous + --> $DIR/ambiguous-9.rs:24:5 + | +LL | date_range(); + | ^^^^^^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `date_range` could refer to the function imported here + --> $DIR/ambiguous-9.rs:8:13 + | +LL | pub use self::range::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate +note: `date_range` could also refer to the function imported here + --> $DIR/ambiguous-9.rs:9:9 + | +LL | use super::prelude::*; + | ^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:16:13 + | +LL | pub use self::t::*; + | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | pub use super::dsl::*; + | ------------- but the name `date_range` in the value namespace is also re-exported here + +warning: `date_range` is ambiguous + --> $DIR/ambiguous-9.rs:24:5 + | +LL | date_range(); + | ^^^^^^^^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `date_range` could refer to the function imported here + --> $DIR/ambiguous-9.rs:20:5 + | +LL | use dsl::*; + | ^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate +note: `date_range` could also refer to the function imported here + --> $DIR/ambiguous-9.rs:21:5 + | +LL | use prelude::*; + | ^^^^^^^^^^ + = help: consider adding an explicit import of `date_range` to disambiguate + +warning: 4 warnings emitted + diff --git a/tests/ui/imports/auxiliary/ambiguous-11-extern.rs b/tests/ui/imports/auxiliary/ambiguous-11-extern.rs new file mode 100644 index 000000000000..e679bc3dc458 --- /dev/null +++ b/tests/ui/imports/auxiliary/ambiguous-11-extern.rs @@ -0,0 +1,6 @@ +mod t2 { + #[derive(Debug)] + pub enum Error {} +} + +pub use t2::*; diff --git a/tests/ui/imports/auxiliary/ambiguous-8-extern.rs b/tests/ui/imports/auxiliary/ambiguous-8-extern.rs new file mode 100644 index 000000000000..c7bf1bae038f --- /dev/null +++ b/tests/ui/imports/auxiliary/ambiguous-8-extern.rs @@ -0,0 +1,12 @@ +mod t2 { + #[derive(Debug)] + pub enum Error {} + + mod t { + pub trait Error: Sized {} + } + + use self::t::*; +} + +pub use t2::*; diff --git a/tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs b/tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs new file mode 100644 index 000000000000..5cd102122811 --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-with-ambiguous-1-extern.rs @@ -0,0 +1,4 @@ +mod a { + pub mod error {} +} +pub use a::*; diff --git a/tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs b/tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs new file mode 100644 index 000000000000..37899676892f --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-with-ambiguous-2-extern.rs @@ -0,0 +1,9 @@ +mod a { + pub mod error {} +} +pub use a::*; + +mod b { + pub mod error {} +} +pub use b::*; diff --git a/tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs b/tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs new file mode 100644 index 000000000000..ad4e04804930 --- /dev/null +++ b/tests/ui/imports/auxiliary/extern-with-ambiguous-3-extern.rs @@ -0,0 +1,14 @@ +mod a { + pub mod error {} +} +pub use a::*; + +mod b { + pub mod error {} +} +pub use b::*; + +mod c { + pub mod error {} +} +pub use c::*; diff --git a/tests/ui/imports/duplicate.rs b/tests/ui/imports/duplicate.rs index db6538969ec7..0c5a376da386 100644 --- a/tests/ui/imports/duplicate.rs +++ b/tests/ui/imports/duplicate.rs @@ -34,6 +34,8 @@ fn main() { e::foo(); f::foo(); //~ ERROR `foo` is ambiguous g::foo(); + //~^ WARNING `foo` is ambiguous + //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod ambiguous_module_errors { diff --git a/tests/ui/imports/duplicate.stderr b/tests/ui/imports/duplicate.stderr index 997a2741b382..d7a7dfce921f 100644 --- a/tests/ui/imports/duplicate.stderr +++ b/tests/ui/imports/duplicate.stderr @@ -9,20 +9,20 @@ LL | use a::foo; = note: `foo` must be defined only once in the value namespace of this module error[E0659]: `foo` is ambiguous - --> $DIR/duplicate.rs:46:15 + --> $DIR/duplicate.rs:48:15 | LL | use self::foo::bar; | ^^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the module imported here - --> $DIR/duplicate.rs:43:9 + --> $DIR/duplicate.rs:45:9 | LL | use self::m1::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the module imported here - --> $DIR/duplicate.rs:44:9 + --> $DIR/duplicate.rs:46:9 | LL | use self::m2::*; | ^^^^^^^^^^^ @@ -49,26 +49,49 @@ LL | pub use b::*; = help: consider adding an explicit import of `foo` to disambiguate error[E0659]: `foo` is ambiguous - --> $DIR/duplicate.rs:49:9 + --> $DIR/duplicate.rs:51:9 | LL | foo::bar(); | ^^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `foo` could refer to the module imported here - --> $DIR/duplicate.rs:43:9 + --> $DIR/duplicate.rs:45:9 | LL | use self::m1::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the module imported here - --> $DIR/duplicate.rs:44:9 + --> $DIR/duplicate.rs:46:9 | LL | use self::m2::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate -error: aborting due to 4 previous errors +warning: `foo` is ambiguous + --> $DIR/duplicate.rs:36:8 + | +LL | g::foo(); + | ^^^ ambiguous name + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #114095 + = note: ambiguous because of multiple glob imports of a name in the same module +note: `foo` could refer to the function imported here + --> $DIR/duplicate.rs:24:13 + | +LL | pub use a::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the function imported here + --> $DIR/duplicate.rs:25:13 + | +LL | pub use b::*; + | ^^^^ + = help: consider adding an explicit import of `foo` to disambiguate + = note: `#[warn(ambiguous_glob_imports)]` on by default + +error: aborting due to 4 previous errors; 1 warning emitted Some errors have detailed explanations: E0252, E0659. For more information about an error, try `rustc --explain E0252`. diff --git a/tests/ui/imports/extern-with-ambiguous-1.rs b/tests/ui/imports/extern-with-ambiguous-1.rs new file mode 100644 index 000000000000..42c3c20686b3 --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-1.rs @@ -0,0 +1,19 @@ +// edition: 2021 +// aux-build: extern-with-ambiguous-1-extern.rs + +// `extern-with-ambiguous-1-extern.rs` doesn't has +// ambiguous, just for compare. + +extern crate extern_with_ambiguous_1_extern; + +mod s { + pub mod error { + use extern_with_ambiguous_1_extern::*; + } +} +use s::*; +use extern_with_ambiguous_1_extern::*; +use error::*; +//~^ ERROR `error` is ambiguous + +fn main() {} diff --git a/tests/ui/imports/extern-with-ambiguous-1.stderr b/tests/ui/imports/extern-with-ambiguous-1.stderr new file mode 100644 index 000000000000..dca2b4ebee7b --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-1.stderr @@ -0,0 +1,23 @@ +error[E0659]: `error` is ambiguous + --> $DIR/extern-with-ambiguous-1.rs:16:5 + | +LL | use error::*; + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `error` could refer to the module imported here + --> $DIR/extern-with-ambiguous-1.rs:14:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `error` to disambiguate +note: `error` could also refer to the module imported here + --> $DIR/extern-with-ambiguous-1.rs:15:5 + | +LL | use extern_with_ambiguous_1_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `error` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/extern-with-ambiguous-2.rs b/tests/ui/imports/extern-with-ambiguous-2.rs new file mode 100644 index 000000000000..68c623c1c4a6 --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-2.rs @@ -0,0 +1,16 @@ +// check-pass +// edition: 2021 +// aux-build: extern-with-ambiguous-2-extern.rs + +extern crate extern_with_ambiguous_2_extern; + +mod s { + pub mod error { + use extern_with_ambiguous_2_extern::*; + } +} +use s::*; +use extern_with_ambiguous_2_extern::*; +use error::*; + +fn main() {} diff --git a/tests/ui/imports/extern-with-ambiguous-3.rs b/tests/ui/imports/extern-with-ambiguous-3.rs new file mode 100644 index 000000000000..282c1d569b0c --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-3.rs @@ -0,0 +1,17 @@ +// check-pass +// edition: 2021 +// aux-build: extern-with-ambiguous-3-extern.rs +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1643974121 + +extern crate extern_with_ambiguous_3_extern; + +mod s { + pub mod error { + use extern_with_ambiguous_3_extern::*; + } +} +use s::*; +use extern_with_ambiguous_3_extern::*; +use error::*; + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-1.rs b/tests/ui/imports/import-after-macro-expand-1.rs new file mode 100644 index 000000000000..d7a8aaf2f2e2 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-1.rs @@ -0,0 +1,19 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/56593#issue-388659456 + +struct Foo; + +mod foo { + use super::*; + + #[derive(Debug)] + pub struct Foo; +} + +mod bar { + use super::foo::*; + + fn bar(_: Foo) {} +} + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-2.rs b/tests/ui/imports/import-after-macro-expand-2.rs new file mode 100644 index 000000000000..b3996d48840d --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-2.rs @@ -0,0 +1,27 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/56593#issuecomment-1133174514 + +use thing::*; + +#[derive(Debug)] +pub enum Thing { + Foo +} + +mod tests { + use super::*; + + fn test_thing() { + let thing: crate::thing::Thing = Thing::Bar; + // FIXME: `thing` should refer to `crate::Thing`, + // FIXME: but doesn't currently refer to it due to backward compatibility + } +} + +mod thing { + pub enum Thing { + Bar + } +} + +fn main() { } diff --git a/tests/ui/imports/import-after-macro-expand-3.rs b/tests/ui/imports/import-after-macro-expand-3.rs new file mode 100644 index 000000000000..3babe1470fc1 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-3.rs @@ -0,0 +1,24 @@ +// check-pass +// similar with `import-after-macro-expand-2.rs` + +use thing::*; + +pub enum Thing { + Foo +} + +mod tests { + use super::*; + + fn test_thing() { + let thing: crate::Thing = Thing::Foo; + } +} + +mod thing { + pub enum Thing { + Bar + } +} + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-4.rs b/tests/ui/imports/import-after-macro-expand-4.rs new file mode 100644 index 000000000000..02cc3f01af93 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-4.rs @@ -0,0 +1,30 @@ +// https://github.com/rust-lang/rust/pull/113242#issuecomment-1616034904 +// similar with `import-after-macro-expand-2.rs` + +mod a { + pub trait P {} +} + +pub use a::*; + +mod c { + use crate::*; + pub struct S(Vec

); + //~^ ERROR the size for values of type + //~| WARNING trait objects without an explicit + //~| WARNING this is accepted in the current edition + //~| WARNING trait objects without an explicit + //~| WARNING this is accepted in the current edition + //~| WARNING trait objects without an explicit + //~| WARNING this is accepted in the current edition + + // FIXME: should works, but doesn't currently refer + // to it due to backward compatibility +} + +#[derive(Clone)] +pub enum P { + A +} + +fn main() {} diff --git a/tests/ui/imports/import-after-macro-expand-4.stderr b/tests/ui/imports/import-after-macro-expand-4.stderr new file mode 100644 index 000000000000..01f70cfc5bff --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-4.stderr @@ -0,0 +1,53 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/import-after-macro-expand-4.rs:12:22 + | +LL | pub struct S(Vec

); + | ^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see + = note: `#[warn(bare_trait_objects)]` on by default +help: use `dyn` + | +LL | pub struct S(Vec); + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/import-after-macro-expand-4.rs:12:22 + | +LL | pub struct S(Vec

); + | ^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see +help: use `dyn` + | +LL | pub struct S(Vec); + | +++ + +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/import-after-macro-expand-4.rs:12:22 + | +LL | pub struct S(Vec

); + | ^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see +help: use `dyn` + | +LL | pub struct S(Vec); + | +++ + +error[E0277]: the size for values of type `(dyn a::P + 'static)` cannot be known at compilation time + --> $DIR/import-after-macro-expand-4.rs:12:18 + | +LL | pub struct S(Vec

); + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn a::P + 'static)` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to previous error; 3 warnings emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/imports/import-after-macro-expand-5.rs b/tests/ui/imports/import-after-macro-expand-5.rs new file mode 100644 index 000000000000..ba28b6deac7c --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-5.rs @@ -0,0 +1,31 @@ +// edition: 2021 +// check-pass +// https://github.com/rust-lang/rust/issues/105235#issue-1474295873 + +mod abc { + pub struct Beeblebrox; + pub struct Zaphod; +} + +mod foo { + pub mod bar { + use crate::abc::*; + + #[derive(Debug)] + pub enum Zaphod { + Whale, + President, + } + } + pub use bar::*; +} + +mod baz { + pub fn do_something() { + println!("{:?}", crate::foo::Zaphod::Whale); + } +} + +fn main() { + baz::do_something(); +} diff --git a/tests/ui/imports/import-after-macro-expand-6.rs b/tests/ui/imports/import-after-macro-expand-6.rs new file mode 100644 index 000000000000..ab5bb37a175f --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-6.rs @@ -0,0 +1,24 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396 + +pub mod a { + pub use crate::b::*; +} + +mod b { + pub mod http { + pub struct HeaderMap; + } + + pub use self::http::*; + #[derive(Debug)] + pub struct HeaderMap; +} + +use crate::a::HeaderMap; + +fn main() { + let h: crate::b::http::HeaderMap = HeaderMap; + // FIXME: should refer to `crate::b::HeaderMap`, + // FIXME: but doesn't currently refer to it due to backward compatibility +} diff --git a/tests/ui/imports/import-after-macro-expand-7.rs b/tests/ui/imports/import-after-macro-expand-7.rs new file mode 100644 index 000000000000..0402dfdfda70 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-7.rs @@ -0,0 +1,21 @@ +// check-pass +// a compared case for `import-after-macro-expand-6.rs` + +pub mod a { + pub use crate::b::*; +} + +mod b { + mod http { + pub struct HeaderMap; + } + + pub use self::http::*; + pub struct HeaderMap; +} + +use crate::a::HeaderMap; + +fn main() { + let h: crate::b::HeaderMap = HeaderMap; +} diff --git a/tests/ui/imports/import-after-macro-expand-8.rs b/tests/ui/imports/import-after-macro-expand-8.rs new file mode 100644 index 000000000000..e11d65effdf7 --- /dev/null +++ b/tests/ui/imports/import-after-macro-expand-8.rs @@ -0,0 +1,22 @@ +// check-pass +// https://github.com/rust-lang/rust/pull/113242#issuecomment-1616034904 + +mod a { + pub trait P {} +} +pub use a::*; + +mod b { + #[derive(Clone)] + pub enum P { + A + } +} +pub use b::P; + +mod c { + use crate::*; + pub struct S(Vec

); +} + +fn main() {} diff --git a/tests/ui/resolve/issue-112831.rs b/tests/ui/resolve/derive-macro-1.rs similarity index 82% rename from tests/ui/resolve/issue-112831.rs rename to tests/ui/resolve/derive-macro-1.rs index ffd83ea8bc10..90cbd903ad67 100644 --- a/tests/ui/resolve/issue-112831.rs +++ b/tests/ui/resolve/derive-macro-1.rs @@ -1,19 +1,17 @@ // check-pass // aux-build:issue-112831-aux.rs -mod zeroable { +mod z { pub trait Zeroable {} } -use zeroable::*; +use z::*; mod pod { use super::*; pub trait Pod: Zeroable {} } -use pod::*; - extern crate issue_112831_aux; use issue_112831_aux::Zeroable; diff --git a/tests/ui/resolve/derive-macro-2.rs b/tests/ui/resolve/derive-macro-2.rs new file mode 100644 index 000000000000..7cecdd9e38e7 --- /dev/null +++ b/tests/ui/resolve/derive-macro-2.rs @@ -0,0 +1,18 @@ +// check-pass +// aux-build:issue-112831-aux.rs + +extern crate issue_112831_aux; +use issue_112831_aux::Zeroable; + +mod z { + pub trait Zeroable {} +} + +use z::*; + +mod pod { + use super::*; + pub trait Pod: Zeroable {} +} + +fn main() {} From 771c832338d57390018d41458a3223bc18eacedc Mon Sep 17 00:00:00 2001 From: bohan Date: Fri, 28 Jul 2023 22:24:28 +0800 Subject: [PATCH 130/150] library: allow `ambiguous_glob_reexports` for `core_arch` --- library/core/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 741de3221ee8..37216d6a7210 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -399,7 +399,8 @@ pub mod primitive; missing_debug_implementations, dead_code, unused_imports, - unsafe_op_in_unsafe_fn + unsafe_op_in_unsafe_fn, + ambiguous_glob_reexports )] #[allow(rustdoc::bare_urls)] // FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is From afd009a8d8a8fea07cfee279817c75427b707778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Thu, 4 May 2023 16:08:33 +0200 Subject: [PATCH 131/150] Parse generic const items --- compiler/rustc_ast/src/ast.rs | 2 + compiler/rustc_ast/src/mut_visit.rs | 3 +- compiler/rustc_ast/src/visit.rs | 11 +- compiler/rustc_ast_passes/src/feature_gate.rs | 1 + .../rustc_ast_pretty/src/pprust/state/item.rs | 35 +++-- compiler/rustc_builtin_macros/src/test.rs | 1 + compiler/rustc_expand/src/build.rs | 11 +- compiler/rustc_feature/src/active.rs | 2 + compiler/rustc_parse/messages.ftl | 8 + compiler/rustc_parse/src/errors.rs | 31 ++++ compiler/rustc_parse/src/parser/item.rs | 148 +++++++++++++++--- compiler/rustc_span/src/symbol.rs | 1 + 12 files changed, 220 insertions(+), 34 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 17b73468a311..dd4321bea1b2 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2947,6 +2947,7 @@ pub struct StaticItem { #[derive(Clone, Encodable, Decodable, Debug)] pub struct ConstItem { pub defaultness: Defaultness, + pub generics: Generics, pub ty: P, pub expr: Option>, } @@ -3058,6 +3059,7 @@ impl ItemKind { match self { Self::Fn(box Fn { generics, .. }) | Self::TyAlias(box TyAlias { generics, .. }) + | Self::Const(box ConstItem { generics, .. }) | Self::Enum(_, generics) | Self::Struct(_, generics) | Self::Union(_, generics) diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 53a9c9a046ea..84b56efd3259 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1149,10 +1149,11 @@ pub fn noop_flat_map_assoc_item( } fn visit_const_item( - ConstItem { defaultness, ty, expr }: &mut ConstItem, + ConstItem { defaultness, generics, ty, expr }: &mut ConstItem, visitor: &mut T, ) { visit_defaultness(defaultness, visitor); + visitor.visit_generics(generics); visitor.visit_ty(ty); visit_opt(expr, |expr| visitor.visit_expr(expr)); } diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index d9de5b8e197d..aed24e11c4e2 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -308,8 +308,12 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { match &item.kind { ItemKind::ExternCrate(_) => {} ItemKind::Use(use_tree) => visitor.visit_use_tree(use_tree, item.id, false), - ItemKind::Static(box StaticItem { ty, mutability: _, expr }) - | ItemKind::Const(box ConstItem { ty, expr, .. }) => { + ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => { + visitor.visit_ty(ty); + walk_list!(visitor, visit_expr, expr); + } + ItemKind::Const(box ConstItem { defaultness: _, generics, ty, expr }) => { + visitor.visit_generics(generics); visitor.visit_ty(ty); walk_list!(visitor, visit_expr, expr); } @@ -677,7 +681,8 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem, visitor.visit_ident(ident); walk_list!(visitor, visit_attribute, attrs); match kind { - AssocItemKind::Const(box ConstItem { ty, expr, .. }) => { + AssocItemKind::Const(box ConstItem { defaultness: _, generics, ty, expr }) => { + visitor.visit_generics(generics); visitor.visit_ty(ty); walk_list!(visitor, visit_expr, expr); } diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index c0d2e76f310a..c4efad7caf26 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -569,6 +569,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) { gate_all!(const_closures, "const closures are experimental"); gate_all!(builtin_syntax, "`builtin #` syntax is unstable"); gate_all!(explicit_tail_calls, "`become` expression is experimental"); + gate_all!(generic_const_items, "generic const items are experimental"); if !visitor.features.negative_bounds { for &span in spans.get(&sym::negative_bounds).iter().copied().flatten() { diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index 5c01b7ea70a1..d27a44f1206d 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -30,10 +30,15 @@ impl<'a> State<'a> { ast::ForeignItemKind::Fn(box ast::Fn { defaultness, sig, generics, body }) => { self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs); } - ast::ForeignItemKind::Static(ty, mutbl, body) => { - let def = ast::Defaultness::Final; - self.print_item_const(ident, Some(*mutbl), ty, body.as_deref(), vis, def); - } + ast::ForeignItemKind::Static(ty, mutbl, body) => self.print_item_const( + ident, + Some(*mutbl), + &ast::Generics::default(), + ty, + body.as_deref(), + vis, + ast::Defaultness::Final, + ), ast::ForeignItemKind::TyAlias(box ast::TyAlias { defaultness, generics, @@ -67,6 +72,7 @@ impl<'a> State<'a> { &mut self, ident: Ident, mutbl: Option, + generics: &ast::Generics, ty: &ast::Ty, body: Option<&ast::Expr>, vis: &ast::Visibility, @@ -82,6 +88,7 @@ impl<'a> State<'a> { }; self.word_space(leading); self.print_ident(ident); + self.print_generic_params(&generics.params); self.word_space(":"); self.print_type(ty); if body.is_some() { @@ -92,6 +99,7 @@ impl<'a> State<'a> { self.word_space("="); self.print_expr(body); } + self.print_where_clause(&generics.where_clause); self.word(";"); self.end(); // end the outer cbox } @@ -158,20 +166,21 @@ impl<'a> State<'a> { self.word(";"); } ast::ItemKind::Static(box StaticItem { ty, mutability: mutbl, expr: body }) => { - let def = ast::Defaultness::Final; self.print_item_const( item.ident, Some(*mutbl), + &ast::Generics::default(), ty, body.as_deref(), &item.vis, - def, + ast::Defaultness::Final, ); } - ast::ItemKind::Const(box ast::ConstItem { defaultness, ty, expr }) => { + ast::ItemKind::Const(box ast::ConstItem { defaultness, generics, ty, expr }) => { self.print_item_const( item.ident, None, + generics, ty, expr.as_deref(), &item.vis, @@ -515,8 +524,16 @@ impl<'a> State<'a> { ast::AssocItemKind::Fn(box ast::Fn { defaultness, sig, generics, body }) => { self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs); } - ast::AssocItemKind::Const(box ast::ConstItem { defaultness, ty, expr }) => { - self.print_item_const(ident, None, ty, expr.as_deref(), vis, *defaultness); + ast::AssocItemKind::Const(box ast::ConstItem { defaultness, generics, ty, expr }) => { + self.print_item_const( + ident, + None, + generics, + ty, + expr.as_deref(), + vis, + *defaultness, + ); } ast::AssocItemKind::Type(box ast::TyAlias { defaultness, diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 6bc4f6fc1fcf..1580a6f6dd3c 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -255,6 +255,7 @@ pub fn expand_test_or_bench( ast::ItemKind::Const( ast::ConstItem { defaultness: ast::Defaultness::Final, + generics: ast::Generics::default(), ty: cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))), // test::TestDescAndFn { expr: Some( diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index 264f30fb10a1..7de46994434c 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -643,7 +643,16 @@ impl<'a> ExtCtxt<'a> { span, name, AttrVec::new(), - ast::ItemKind::Const(ast::ConstItem { defaultness, ty, expr: Some(expr) }.into()), + ast::ItemKind::Const( + ast::ConstItem { + defaultness, + // FIXME(generic_const_items): Pass the generics as a parameter. + generics: ast::Generics::default(), + ty, + expr: Some(expr), + } + .into(), + ), ) } diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index c03789f500a7..22380a521044 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -424,6 +424,8 @@ declare_features! ( (incomplete, generic_associated_types_extended, "1.61.0", Some(95451), None), /// Allows non-trivial generic constants which have to have wfness manually propagated to callers (incomplete, generic_const_exprs, "1.56.0", Some(76560), None), + /// Allows generic parameters and where-clauses on free & associated const items. + (incomplete, generic_const_items, "CURRENT_RUSTC_VERSION", Some(113521), None), /// Allows using `..=X` as a patterns in slices. (active, half_open_range_patterns_in_slices, "1.66.0", Some(67264), None), /// Allows `if let` guard in match arms. diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 9787d98c1a49..4f1d282fe7dd 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -690,6 +690,8 @@ parse_single_colon_import_path = expected `::`, found `:` parse_single_colon_struct_type = found single colon in a struct field type path .suggestion = write a path separator here +parse_static_with_generics = static items may not have generic parameters + parse_struct_literal_body_without_path = struct literal body without path .suggestion = you might have forgotten to add the struct literal inside the block @@ -847,6 +849,12 @@ parse_visibility_not_followed_by_item = visibility `{$vis}` is not followed by a .label = the visibility .help = you likely meant to define an item, e.g., `{$vis} fn foo() {"{}"}` +parse_where_clause_before_const_body = where clauses are not allowed before const item bodies + .label = unexpected where clause + .name_label = while parsing this const item + .body_label = the item body + .suggestion = move the body before the where clause + parse_where_clause_before_tuple_struct_body = where clauses are not allowed before tuple struct bodies .label = unexpected where clause .name_label = while parsing this tuple struct diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 96e1c0e3c6d9..5456a7088982 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -2692,3 +2692,34 @@ pub(crate) struct ExpectedBuiltinIdent { #[primary_span] pub span: Span, } + +#[derive(Diagnostic)] +#[diag(parse_static_with_generics)] +pub(crate) struct StaticWithGenerics { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] +#[diag(parse_where_clause_before_const_body)] +pub(crate) struct WhereClauseBeforeConstBody { + #[primary_span] + #[label] + pub span: Span, + #[label(parse_name_label)] + pub name: Span, + #[label(parse_body_label)] + pub body: Span, + #[subdiagnostic] + pub sugg: Option, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")] +pub(crate) struct WhereClauseBeforeConstBodySugg { + #[suggestion_part(code = "= {snippet} ")] + pub left: Span, + pub snippet: String, + #[suggestion_part(code = "")] + pub right: Span, +} diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 1470180dea71..1301ed3e3882 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -226,9 +226,9 @@ impl<'a> Parser<'a> { } else if self.is_static_global() { // STATIC ITEM self.bump(); // `static` - let m = self.parse_mutability(); - let (ident, ty, expr) = self.parse_item_global(Some(m))?; - (ident, ItemKind::Static(Box::new(StaticItem { ty, mutability: m, expr }))) + let mutability = self.parse_mutability(); + let (ident, item) = self.parse_static_item(mutability)?; + (ident, ItemKind::Static(Box::new(item))) } else if let Const::Yes(const_span) = self.parse_constness(Case::Sensitive) { // CONST ITEM if self.token.is_keyword(kw::Impl) { @@ -236,8 +236,16 @@ impl<'a> Parser<'a> { self.recover_const_impl(const_span, attrs, def_())? } else { self.recover_const_mut(const_span); - let (ident, ty, expr) = self.parse_item_global(None)?; - (ident, ItemKind::Const(Box::new(ConstItem { defaultness: def_(), ty, expr }))) + let (ident, generics, ty, expr) = self.parse_const_item()?; + ( + ident, + ItemKind::Const(Box::new(ConstItem { + defaultness: def_(), + generics, + ty, + expr, + })), + ) } } else if self.check_keyword(kw::Trait) || self.check_auto_or_unsafe_trait_item() { // TRAIT ITEM @@ -878,6 +886,7 @@ impl<'a> Parser<'a> { self.sess.emit_err(errors::AssociatedStaticItemNotAllowed { span }); AssocItemKind::Const(Box::new(ConstItem { defaultness: Defaultness::Final, + generics: Generics::default(), ty, expr, })) @@ -892,7 +901,7 @@ impl<'a> Parser<'a> { /// Parses a `type` alias with the following grammar: /// ```ebnf - /// TypeAlias = "type" Ident Generics {":" GenericBounds}? {"=" Ty}? ";" ; + /// TypeAlias = "type" Ident Generics (":" GenericBounds)? WhereClause ("=" Ty)? WhereClause ";" ; /// ``` /// The `"type"` has already been eaten. fn parse_type_alias(&mut self, defaultness: Defaultness) -> PResult<'a, ItemInfo> { @@ -1220,33 +1229,132 @@ impl<'a> Parser<'a> { Ok(impl_info) } - /// Parse `["const" | ("static" "mut"?)] $ident ":" $ty (= $expr)?` with - /// `["const" | ("static" "mut"?)]` already parsed and stored in `m`. + /// Parse a static item with the prefix `"static" "mut"?` already parsed and stored in `mutability`. /// - /// When `m` is `"const"`, `$ident` may also be `"_"`. - fn parse_item_global( - &mut self, - m: Option, - ) -> PResult<'a, (Ident, P, Option>)> { - let id = if m.is_none() { self.parse_ident_or_underscore() } else { self.parse_ident() }?; + /// ```ebnf + /// Static = "static" "mut"? $ident ":" $ty (= $expr)? ";" ; + /// ``` + fn parse_static_item(&mut self, mutability: Mutability) -> PResult<'a, (Ident, StaticItem)> { + let ident = self.parse_ident()?; - // Parse the type of a `const` or `static mut?` item. - // That is, the `":" $ty` fragment. + if self.token.kind == TokenKind::Lt && self.may_recover() { + let generics = self.parse_generics()?; + self.sess.emit_err(errors::StaticWithGenerics { span: generics.span }); + } + + // Parse the type of a static item. That is, the `":" $ty` fragment. + // FIXME: This could maybe benefit from `.may_recover()`? let ty = match (self.eat(&token::Colon), self.check(&token::Eq) | self.check(&token::Semi)) { - // If there wasn't a `:` or the colon was followed by a `=` or `;` recover a missing type. (true, false) => self.parse_ty()?, - (colon, _) => self.recover_missing_const_type(colon, m), + // If there wasn't a `:` or the colon was followed by a `=` or `;`, recover a missing type. + (colon, _) => self.recover_missing_global_item_type(colon, Some(mutability)), }; let expr = if self.eat(&token::Eq) { Some(self.parse_expr()?) } else { None }; + self.expect_semi()?; - Ok((id, ty, expr)) + + Ok((ident, StaticItem { ty, mutability, expr })) + } + + /// Parse a constant item with the prefix `"const"` already parsed. + /// + /// ```ebnf + /// Const = "const" ($ident | "_") Generics ":" $ty (= $expr)? WhereClause ";" ; + /// ``` + fn parse_const_item(&mut self) -> PResult<'a, (Ident, Generics, P, Option>)> { + let ident = self.parse_ident_or_underscore()?; + + let mut generics = self.parse_generics()?; + + // Check the span for emptiness instead of the list of parameters in order to correctly + // recognize and subsequently flag empty parameter lists (`<>`) as unstable. + if !generics.span.is_empty() { + self.sess.gated_spans.gate(sym::generic_const_items, generics.span); + } + + // Parse the type of a constant item. That is, the `":" $ty` fragment. + // FIXME: This could maybe benefit from `.may_recover()`? + let ty = match ( + self.eat(&token::Colon), + self.check(&token::Eq) | self.check(&token::Semi) | self.check_keyword(kw::Where), + ) { + (true, false) => self.parse_ty()?, + // If there wasn't a `:` or the colon was followed by a `=`, `;` or `where`, recover a missing type. + (colon, _) => self.recover_missing_global_item_type(colon, None), + }; + + // Proactively parse a where-clause to be able to provide a good error message in case we + // encounter the item body following it. + let before_where_clause = + if self.may_recover() { self.parse_where_clause()? } else { WhereClause::default() }; + + let expr = if self.eat(&token::Eq) { Some(self.parse_expr()?) } else { None }; + + let after_where_clause = self.parse_where_clause()?; + + // Provide a nice error message if the user placed a where-clause before the item body. + // Users may be tempted to write such code if they are still used to the deprecated + // where-clause location on type aliases and associated types. See also #89122. + if before_where_clause.has_where_token && let Some(expr) = &expr { + self.sess.emit_err(errors::WhereClauseBeforeConstBody { + span: before_where_clause.span, + name: ident.span, + body: expr.span, + sugg: if !after_where_clause.has_where_token { + self.sess.source_map().span_to_snippet(expr.span).ok().map(|body| { + errors::WhereClauseBeforeConstBodySugg { + left: before_where_clause.span.shrink_to_lo(), + snippet: body, + right: before_where_clause.span.shrink_to_hi().to(expr.span), + } + }) + } else { + // FIXME(generic_const_items): Provide a structured suggestion to merge the first + // where-clause into the second one. + None + }, + }); + } + + // Merge the predicates of both where-clauses since either one can be relevant. + // If we didn't parse a body (which is valid for associated consts in traits) and we were + // allowed to recover, `before_where_clause` contains the predicates, otherwise they are + // in `after_where_clause`. Further, both of them might contain predicates iff two + // where-clauses were provided which is syntactically ill-formed but we want to recover from + // it and treat them as one large where-clause. + let mut predicates = before_where_clause.predicates; + predicates.extend(after_where_clause.predicates); + let where_clause = WhereClause { + has_where_token: before_where_clause.has_where_token + || after_where_clause.has_where_token, + predicates, + span: if after_where_clause.has_where_token { + after_where_clause.span + } else { + before_where_clause.span + }, + }; + + if where_clause.has_where_token { + self.sess.gated_spans.gate(sym::generic_const_items, where_clause.span); + } + + generics.where_clause = where_clause; + + self.expect_semi()?; + + Ok((ident, generics, ty, expr)) } /// We were supposed to parse `":" $ty` but the `:` or the type was missing. /// This means that the type is missing. - fn recover_missing_const_type(&mut self, colon_present: bool, m: Option) -> P { + fn recover_missing_global_item_type( + &mut self, + colon_present: bool, + m: Option, + ) -> P { // Construct the error and stash it away with the hope // that typeck will later enrich the error with a type. let kind = match m { diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 1b426ef20485..8122fe96a5c1 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -783,6 +783,7 @@ symbols! { generic_associated_types, generic_associated_types_extended, generic_const_exprs, + generic_const_items, generic_param_attrs, get_context, global_allocator, From 9213aec76231149a6e03252e4a26ea46962bc1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Thu, 4 May 2023 16:40:57 +0200 Subject: [PATCH 132/150] Lower generic const items to HIR --- compiler/rustc_ast_lowering/src/item.rs | 55 +++++++++++++------ compiler/rustc_hir/src/hir.rs | 23 +++++--- compiler/rustc_hir/src/intravisit.rs | 8 ++- .../rustc_hir_analysis/src/collect/type_of.rs | 2 +- .../rustc_hir_analysis/src/hir_wf_check.rs | 2 +- compiler/rustc_hir_pretty/src/lib.rs | 12 ++-- compiler/rustc_hir_typeck/src/expr.rs | 2 +- compiler/rustc_hir_typeck/src/lib.rs | 2 +- compiler/rustc_hir_typeck/src/pat.rs | 3 +- .../src/infer/error_reporting/mod.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 3 +- compiler/rustc_middle/src/hir/map/mod.rs | 2 +- compiler/rustc_mir_build/src/build/mod.rs | 2 +- compiler/rustc_passes/src/reachable.rs | 2 +- .../src/traits/error_reporting/suggestions.rs | 2 + src/librustdoc/clean/mod.rs | 3 +- 16 files changed, 84 insertions(+), 41 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 2f58f566c81c..5a0474dbc01d 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -231,9 +231,15 @@ impl<'hir> LoweringContext<'_, 'hir> { let (ty, body_id) = self.lower_const_item(t, span, e.as_deref()); hir::ItemKind::Static(ty, *m, body_id) } - ItemKind::Const(box ast::ConstItem { ty, expr, .. }) => { - let (ty, body_id) = self.lower_const_item(ty, span, expr.as_deref()); - hir::ItemKind::Const(ty, body_id) + ItemKind::Const(box ast::ConstItem { generics, ty, expr, .. }) => { + let (generics, (ty, body_id)) = self.lower_generics( + generics, + Const::No, + id, + &ImplTraitContext::Disallowed(ImplTraitPosition::Generic), + |this| this.lower_const_item(ty, span, expr.as_deref()), + ); + hir::ItemKind::Const(ty, generics, body_id) } ItemKind::Fn(box Fn { sig: FnSig { decl, header, span: fn_sig_span }, @@ -715,11 +721,23 @@ impl<'hir> LoweringContext<'_, 'hir> { let trait_item_def_id = hir_id.expect_owner(); let (generics, kind, has_default) = match &i.kind { - AssocItemKind::Const(box ConstItem { ty, expr, .. }) => { - let ty = - self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy)); - let body = expr.as_ref().map(|x| self.lower_const_body(i.span, Some(x))); - (hir::Generics::empty(), hir::TraitItemKind::Const(ty, body), body.is_some()) + AssocItemKind::Const(box ConstItem { generics, ty, expr, .. }) => { + let (generics, kind) = self.lower_generics( + &generics, + Const::No, + i.id, + &ImplTraitContext::Disallowed(ImplTraitPosition::Generic), + |this| { + let ty = this.lower_ty( + ty, + &ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy), + ); + let body = expr.as_ref().map(|x| this.lower_const_body(i.span, Some(x))); + + hir::TraitItemKind::Const(ty, body) + }, + ); + (generics, kind, expr.is_some()) } AssocItemKind::Fn(box Fn { sig, generics, body: None, .. }) => { let asyncness = sig.header.asyncness; @@ -817,14 +835,19 @@ impl<'hir> LoweringContext<'_, 'hir> { self.lower_attrs(hir_id, &i.attrs); let (generics, kind) = match &i.kind { - AssocItemKind::Const(box ConstItem { ty, expr, .. }) => { - let ty = - self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy)); - ( - hir::Generics::empty(), - hir::ImplItemKind::Const(ty, self.lower_const_body(i.span, expr.as_deref())), - ) - } + AssocItemKind::Const(box ConstItem { generics, ty, expr, .. }) => self.lower_generics( + &generics, + Const::No, + i.id, + &ImplTraitContext::Disallowed(ImplTraitPosition::Generic), + |this| { + let ty = this + .lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy)); + let body = this.lower_const_body(i.span, expr.as_deref()); + + hir::ImplItemKind::Const(ty, body) + }, + ), AssocItemKind::Fn(box Fn { sig, generics, body, .. }) => { self.current_item = Some(i.span); let asyncness = sig.header.asyncness; diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 3663c450ba64..6b76e16825f7 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3130,9 +3130,9 @@ impl<'hir> Item<'hir> { } /// Expect an [`ItemKind::Const`] or panic. #[track_caller] - pub fn expect_const(&self) -> (&'hir Ty<'hir>, BodyId) { - let ItemKind::Const(ty, body) = self.kind else { self.expect_failed("a constant") }; - (ty, body) + pub fn expect_const(&self) -> (&'hir Ty<'hir>, &'hir Generics<'hir>, BodyId) { + let ItemKind::Const(ty, gen, body) = self.kind else { self.expect_failed("a constant") }; + (ty, gen, body) } /// Expect an [`ItemKind::Fn`] or panic. #[track_caller] @@ -3319,7 +3319,7 @@ pub enum ItemKind<'hir> { /// A `static` item. Static(&'hir Ty<'hir>, Mutability, BodyId), /// A `const` item. - Const(&'hir Ty<'hir>, BodyId), + Const(&'hir Ty<'hir>, &'hir Generics<'hir>, BodyId), /// A function declaration. Fn(FnSig<'hir>, &'hir Generics<'hir>, BodyId), /// A MBE macro definition (`macro_rules!` or `macro`). @@ -3372,6 +3372,7 @@ impl ItemKind<'_> { Some(match *self { ItemKind::Fn(_, ref generics, _) | ItemKind::TyAlias(_, ref generics) + | ItemKind::Const(_, ref generics, _) | ItemKind::OpaqueTy(OpaqueTy { ref generics, .. }) | ItemKind::Enum(_, ref generics) | ItemKind::Struct(_, ref generics) @@ -3567,7 +3568,9 @@ impl<'hir> OwnerNode<'hir> { match self { OwnerNode::Item(Item { kind: - ItemKind::Static(_, _, body) | ItemKind::Const(_, body) | ItemKind::Fn(_, _, body), + ItemKind::Static(_, _, body) + | ItemKind::Const(_, _, body) + | ItemKind::Fn(_, _, body), .. }) | OwnerNode::TraitItem(TraitItem { @@ -3770,9 +3773,9 @@ impl<'hir> Node<'hir> { pub fn ty(self) -> Option<&'hir Ty<'hir>> { match self { Node::Item(it) => match it.kind { - ItemKind::TyAlias(ty, _) | ItemKind::Static(ty, _, _) | ItemKind::Const(ty, _) => { - Some(ty) - } + ItemKind::TyAlias(ty, _) + | ItemKind::Static(ty, _, _) + | ItemKind::Const(ty, _, _) => Some(ty), _ => None, }, Node::TraitItem(it) => match it.kind { @@ -3800,7 +3803,9 @@ impl<'hir> Node<'hir> { match self { Node::Item(Item { kind: - ItemKind::Static(_, _, body) | ItemKind::Const(_, body) | ItemKind::Fn(_, _, body), + ItemKind::Static(_, _, body) + | ItemKind::Const(_, _, body) + | ItemKind::Fn(_, _, body), .. }) | Node::TraitItem(TraitItem { diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 347c1f4637f1..a8a94e6a4768 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -467,11 +467,17 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) { ItemKind::Use(ref path, _) => { visitor.visit_use(path, item.hir_id()); } - ItemKind::Static(ref typ, _, body) | ItemKind::Const(ref typ, body) => { + ItemKind::Static(ref typ, _, body) => { visitor.visit_id(item.hir_id()); visitor.visit_ty(typ); visitor.visit_nested_body(body); } + ItemKind::Const(ref typ, ref generics, body) => { + visitor.visit_id(item.hir_id()); + visitor.visit_ty(typ); + visitor.visit_generics(generics); + visitor.visit_nested_body(body); + } ItemKind::Fn(ref sig, ref generics, body_id) => { visitor.visit_id(item.hir_id()); visitor.visit_fn( diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index a9ef791077ee..2bbdbe3a1f62 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -404,7 +404,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder { + ItemKind::Const(ty, _, body_id) => { if is_suggestable_infer_ty(ty) { infer_placeholder_type( tcx, def_id, body_id, ty.span, item.ident, "constant", diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index f1765174d79d..ca7679cfba06 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -130,7 +130,7 @@ fn diagnostic_hir_wf_check<'tcx>( hir::Node::Item(item) => match item.kind { hir::ItemKind::TyAlias(ty, _) | hir::ItemKind::Static(ty, _, _) - | hir::ItemKind::Const(ty, _) => vec![ty], + | hir::ItemKind::Const(ty, _, _) => vec![ty], hir::ItemKind::Impl(impl_) => match &impl_.of_trait { Some(t) => t .path diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index a699cd6c942e..2d8b956771bb 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -420,12 +420,13 @@ impl<'a> State<'a> { fn print_associated_const( &mut self, ident: Ident, + generics: &hir::Generics<'_>, ty: &hir::Ty<'_>, default: Option, ) { - self.head(""); self.word_space("const"); self.print_ident(ident); + self.print_generic_params(generics.params); self.word_space(":"); self.print_type(ty); if let Some(expr) = default { @@ -433,6 +434,7 @@ impl<'a> State<'a> { self.word_space("="); self.ann.nested(self, Nested::Body(expr)); } + self.print_where_clause(generics); self.word(";") } @@ -532,9 +534,10 @@ impl<'a> State<'a> { self.word(";"); self.end(); // end the outer cbox } - hir::ItemKind::Const(ty, expr) => { + hir::ItemKind::Const(ty, generics, expr) => { self.head("const"); self.print_ident(item.ident); + self.print_generic_params(generics.params); self.word_space(":"); self.print_type(ty); self.space(); @@ -542,6 +545,7 @@ impl<'a> State<'a> { self.word_space("="); self.ann.nested(self, Nested::Body(expr)); + self.print_where_clause(generics); self.word(";"); self.end(); // end the outer cbox } @@ -836,7 +840,7 @@ impl<'a> State<'a> { self.print_outer_attributes(self.attrs(ti.hir_id())); match ti.kind { hir::TraitItemKind::Const(ty, default) => { - self.print_associated_const(ti.ident, ty, default); + self.print_associated_const(ti.ident, ti.generics, ty, default); } hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(arg_names)) => { self.print_method_sig(ti.ident, sig, ti.generics, arg_names, None); @@ -865,7 +869,7 @@ impl<'a> State<'a> { match ii.kind { hir::ImplItemKind::Const(ty, expr) => { - self.print_associated_const(ii.ident, ty, Some(expr)); + self.print_associated_const(ii.ident, ii.generics, ty, Some(expr)); } hir::ImplItemKind::Fn(ref sig, body) => { self.head(""); diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 3f1f10f2f003..8f5737dd4ad1 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -1394,7 +1394,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let Some(( _, hir::Node::Local(hir::Local { ty: Some(ty), .. }) - | hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(ty, _), .. }), + | hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(ty, _, _), .. }), )) = parent_node else { return; diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 864308267bba..c4d3cbc9faab 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -101,7 +101,7 @@ fn primary_body_of( ) -> Option<(hir::BodyId, Option<&hir::Ty<'_>>, Option<&hir::FnSig<'_>>)> { match node { Node::Item(item) => match item.kind { - hir::ItemKind::Const(ty, body) | hir::ItemKind::Static(ty, _, body) => { + hir::ItemKind::Const(ty, _, body) | hir::ItemKind::Static(ty, _, body) => { Some((body, Some(ty), None)) } hir::ItemKind::Fn(ref sig, .., body) => Some((body, None, Some(sig))), diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 6ffa3b0a0b34..4d236a86dda1 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -924,7 +924,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match opt_def_id { Some(def_id) => match self.tcx.hir().get_if_local(def_id) { Some(hir::Node::Item(hir::Item { - kind: hir::ItemKind::Const(_, body_id), .. + kind: hir::ItemKind::Const(_, _, body_id), + .. })) => match self.tcx.hir().get(body_id.hir_id) { hir::Node::Expr(expr) => { if hir::is_range_literal(expr) { diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index d3978e242a85..c000f988aa23 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2068,7 +2068,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { visitor.visit_body(body); visitor.result.map(|r| &r.peel_refs().kind) } - Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(ty, _), .. })) => { + Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(ty, _, _), .. })) => { Some(&ty.peel_refs().kind) } _ => None, diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index cf6e7f16f071..ba05622bf371 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1529,9 +1529,10 @@ declare_lint_pass!( impl<'tcx> LateLintPass<'tcx> for UnusedBrokenConst { fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) { match it.kind { - hir::ItemKind::Const(_, body_id) => { + hir::ItemKind::Const(_, _, body_id) => { let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id(); // trigger the query once for all constants since that will already report the errors + // FIXME(generic_const_items): Does this work properly with generic const items? cx.tcx.ensure().const_eval_poly(def_id); } hir::ItemKind::Static(_, _, body_id) => { diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 1fd68dc5cb28..b167364f6800 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -24,7 +24,7 @@ pub fn associated_body(node: Node<'_>) -> Option<(LocalDefId, BodyId)> { match node { Node::Item(Item { owner_id, - kind: ItemKind::Const(_, body) | ItemKind::Static(.., body) | ItemKind::Fn(.., body), + kind: ItemKind::Const(_, _, body) | ItemKind::Static(.., body) | ItemKind::Fn(.., body), .. }) | Node::TraitItem(TraitItem { diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 1ae8031ef3c5..c66eba5520e1 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -570,7 +570,7 @@ fn construct_const<'a, 'tcx>( // Figure out what primary body this item has. let (span, const_ty_span) = match tcx.hir().get(hir_id) { Node::Item(hir::Item { - kind: hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _), + kind: hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _, _), span, .. }) diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs index 160528e4074d..7dec5b0acc88 100644 --- a/compiler/rustc_passes/src/reachable.rs +++ b/compiler/rustc_passes/src/reachable.rs @@ -236,7 +236,7 @@ impl<'tcx> ReachableContext<'tcx> { // Reachable constants will be inlined into other crates // unconditionally, so we need to make sure that their // contents are also reachable. - hir::ItemKind::Const(_, init) | hir::ItemKind::Static(_, _, init) => { + hir::ItemKind::Const(_, _, init) | hir::ItemKind::Static(_, _, init) => { self.visit_nested_body(init); } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index ff7854d51d91..38d6f1cb23d8 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -655,6 +655,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { | hir::ItemKind::Impl(hir::Impl { generics, .. }) | hir::ItemKind::Fn(_, generics, _) | hir::ItemKind::TyAlias(_, generics) + | hir::ItemKind::Const(_, generics, _) | hir::ItemKind::TraitAlias(generics, _) | hir::ItemKind::OpaqueTy(hir::OpaqueTy { generics, .. }), .. @@ -720,6 +721,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { | hir::ItemKind::Impl(hir::Impl { generics, .. }) | hir::ItemKind::Fn(_, generics, _) | hir::ItemKind::TyAlias(_, generics) + | hir::ItemKind::Const(_, generics, _) | hir::ItemKind::TraitAlias(generics, _) | hir::ItemKind::OpaqueTy(hir::OpaqueTy { generics, .. }), .. diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index aeae1dd05702..a26eb222c18e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2603,7 +2603,8 @@ fn clean_maybe_renamed_item<'tcx>( ItemKind::Static(ty, mutability, body_id) => { StaticItem(Static { type_: clean_ty(ty, cx), mutability, expr: Some(body_id) }) } - ItemKind::Const(ty, body_id) => ConstantItem(Constant { + // FIXME(fmease): rustdoc integration + ItemKind::Const(ty, _generics, body_id) => ConstantItem(Constant { type_: clean_ty(ty, cx), kind: ConstantKind::Local { body: body_id, def_id }, }), From da17134be044c1d317cb4eccb56e9498e46d8bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sun, 2 Jul 2023 18:48:24 +0200 Subject: [PATCH 133/150] Resolve generic const items --- compiler/rustc_resolve/src/late.rs | 170 +++++++++++------- .../rustc_resolve/src/late/diagnostics.rs | 8 + 2 files changed, 109 insertions(+), 69 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index aab71494fd31..6872b1b24a95 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -337,6 +337,7 @@ enum LifetimeBinderKind { PolyTrait, WhereBound, Item, + ConstItem, Function, Closure, ImplBlock, @@ -349,7 +350,7 @@ impl LifetimeBinderKind { BareFnType => "type", PolyTrait => "bound", WhereBound => "bound", - Item => "item", + Item | ConstItem => "item", ImplBlock => "impl block", Function => "function", Closure => "closure", @@ -2404,30 +2405,44 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { }); } - ItemKind::Static(box ast::StaticItem { ref ty, ref expr, .. }) - | ItemKind::Const(box ast::ConstItem { ref ty, ref expr, .. }) => { + ItemKind::Static(box ast::StaticItem { ref ty, ref expr, .. }) => { self.with_static_rib(|this| { this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Static), |this| { this.visit_ty(ty); }); - this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { + if let Some(expr) = expr { + // We already forbid generic params because of the above item rib, + // so it doesn't matter whether this is a trivial constant. + this.resolve_const_body(expr, Some((item.ident, ConstantItemKind::Static))); + } + }); + } + + ItemKind::Const(box ast::ConstItem { ref generics, ref ty, ref expr, .. }) => { + self.with_generic_param_rib( + &generics.params, + RibKind::Item(HasGenericParams::Yes(generics.span)), + LifetimeRibKind::Generics { + binder: item.id, + kind: LifetimeBinderKind::ConstItem, + span: generics.span, + }, + |this| { + this.visit_generics(generics); + + this.with_lifetime_rib( + LifetimeRibKind::Elided(LifetimeRes::Static), + |this| this.visit_ty(ty), + ); + if let Some(expr) = expr { - let constant_item_kind = match item.kind { - ItemKind::Const(..) => ConstantItemKind::Const, - ItemKind::Static(..) => ConstantItemKind::Static, - _ => unreachable!(), - }; - // We already forbid generic params because of the above item rib, - // so it doesn't matter whether this is a trivial constant. - this.with_constant_rib( - IsRepeatExpr::No, - ConstantHasGenerics::Yes, - Some((item.ident, constant_item_kind)), - |this| this.visit_expr(expr), + this.resolve_const_body( + expr, + Some((item.ident, ConstantItemKind::Const)), ); } - }); - }); + }, + ); } ItemKind::Use(ref use_tree) => { @@ -2700,28 +2715,31 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { for item in trait_items { self.resolve_doc_links(&item.attrs, MaybeExported::Ok(item.id)); match &item.kind { - AssocItemKind::Const(box ast::ConstItem { ty, expr, .. }) => { - self.visit_ty(ty); - // Only impose the restrictions of `ConstRibKind` for an - // actual constant expression in a provided default. - if let Some(expr) = expr { - // We allow arbitrary const expressions inside of associated consts, - // even if they are potentially not const evaluatable. - // - // Type parameters can already be used and as associated consts are - // not used as part of the type system, this is far less surprising. - self.with_lifetime_rib( - LifetimeRibKind::Elided(LifetimeRes::Infer), - |this| { - this.with_constant_rib( - IsRepeatExpr::No, - ConstantHasGenerics::Yes, - None, - |this| this.visit_expr(expr), - ) - }, - ); - } + AssocItemKind::Const(box ast::ConstItem { generics, ty, expr, .. }) => { + self.with_generic_param_rib( + &generics.params, + RibKind::AssocItem, + LifetimeRibKind::Generics { + binder: item.id, + span: generics.span, + kind: LifetimeBinderKind::ConstItem, + }, + |this| { + this.visit_generics(generics); + this.visit_ty(ty); + + // Only impose the restrictions of `ConstRibKind` for an + // actual constant expression in a provided default. + if let Some(expr) = expr { + // We allow arbitrary const expressions inside of associated consts, + // even if they are potentially not const evaluatable. + // + // Type parameters can already be used and as associated consts are + // not used as part of the type system, this is far less surprising. + this.resolve_const_body(expr, None); + } + }, + ); } AssocItemKind::Fn(box Fn { generics, .. }) => { walk_assoc_item(self, generics, LifetimeBinderKind::Function, item); @@ -2876,36 +2894,42 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { use crate::ResolutionError::*; self.resolve_doc_links(&item.attrs, MaybeExported::ImplItem(trait_id.ok_or(&item.vis))); match &item.kind { - AssocItemKind::Const(box ast::ConstItem { ty, expr, .. }) => { + AssocItemKind::Const(box ast::ConstItem { generics, ty, expr, .. }) => { debug!("resolve_implementation AssocItemKind::Const"); - // If this is a trait impl, ensure the const - // exists in trait - self.check_trait_item( - item.id, - item.ident, - &item.kind, - ValueNS, - item.span, - seen_trait_items, - |i, s, c| ConstNotMemberOfTrait(i, s, c), - ); - self.visit_ty(ty); - if let Some(expr) = expr { - // We allow arbitrary const expressions inside of associated consts, - // even if they are potentially not const evaluatable. - // - // Type parameters can already be used and as associated consts are - // not used as part of the type system, this is far less surprising. - self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { - this.with_constant_rib( - IsRepeatExpr::No, - ConstantHasGenerics::Yes, - None, - |this| this.visit_expr(expr), - ) - }); - } + self.with_generic_param_rib( + &generics.params, + RibKind::AssocItem, + LifetimeRibKind::Generics { + binder: item.id, + span: generics.span, + kind: LifetimeBinderKind::ConstItem, + }, + |this| { + // If this is a trait impl, ensure the const + // exists in trait + this.check_trait_item( + item.id, + item.ident, + &item.kind, + ValueNS, + item.span, + seen_trait_items, + |i, s, c| ConstNotMemberOfTrait(i, s, c), + ); + + this.visit_generics(generics); + this.visit_ty(ty); + if let Some(expr) = expr { + // We allow arbitrary const expressions inside of associated consts, + // even if they are potentially not const evaluatable. + // + // Type parameters can already be used and as associated consts are + // not used as part of the type system, this is far less surprising. + this.resolve_const_body(expr, None); + } + }, + ); } AssocItemKind::Fn(box Fn { generics, .. }) => { debug!("resolve_implementation AssocItemKind::Fn"); @@ -3063,6 +3087,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { ); } + fn resolve_const_body(&mut self, expr: &'ast Expr, item: Option<(Ident, ConstantItemKind)>) { + self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { + this.with_constant_rib(IsRepeatExpr::No, ConstantHasGenerics::Yes, item, |this| { + this.visit_expr(expr) + }); + }) + } + fn resolve_params(&mut self, params: &'ast [Param]) { let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())]; self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { @@ -4448,6 +4480,7 @@ impl<'ast> Visitor<'ast> for LifetimeCountVisitor<'_, '_, '_> { fn visit_item(&mut self, item: &'ast Item) { match &item.kind { ItemKind::TyAlias(box TyAlias { ref generics, .. }) + | ItemKind::Const(box ConstItem { ref generics, .. }) | ItemKind::Fn(box Fn { ref generics, .. }) | ItemKind::Enum(_, ref generics) | ItemKind::Struct(_, ref generics) @@ -4467,7 +4500,6 @@ impl<'ast> Visitor<'ast> for LifetimeCountVisitor<'_, '_, '_> { ItemKind::Mod(..) | ItemKind::ForeignMod(..) | ItemKind::Static(..) - | ItemKind::Const(..) | ItemKind::Use(..) | ItemKind::ExternCrate(..) | ItemKind::MacroDef(..) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 753a1adc66d7..072fa864f4ef 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2348,6 +2348,14 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { let mut should_continue = true; match rib.kind { LifetimeRibKind::Generics { binder: _, span, kind } => { + // Avoid suggesting placing lifetime parameters on constant items unless the relevant + // feature is enabled. Suggest the parent item as a possible location if applicable. + if let LifetimeBinderKind::ConstItem = kind + && !self.r.tcx().features().generic_const_items + { + continue; + } + if !span.can_be_used_for_suggestions() && suggest_note && let Some(name) = name { suggest_note = false; // Avoid displaying the same help multiple times. err.span_label( From 8c390286e4de59ddfff6bd7c7fdea10827f89b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sun, 2 Jul 2023 18:48:43 +0200 Subject: [PATCH 134/150] Type-check generic const items --- .../src/check/compare_impl_item.rs | 110 +++++++++++------ .../src/collect/generics_of.rs | 1 + .../src/collect/predicates_of.rs | 2 + .../src/collect/resolve_bound_vars.rs | 112 +++++++----------- 4 files changed, 122 insertions(+), 103 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 919092ecb164..75c45868b900 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -76,7 +76,7 @@ fn check_method_is_structurally_compatible<'tcx>( Ok(()) } -/// This function is best explained by example. Consider a trait with it's implementation: +/// This function is best explained by example. Consider a trait with its implementation: /// /// ```rust /// trait Trait<'t, T> { @@ -120,7 +120,7 @@ fn check_method_is_structurally_compatible<'tcx>( /// types: /// /// ```rust,ignore (pseudo-Rust) -/// <'b> fn(t: &'i0 U0, m: &'b) -> Foo +/// <'b> fn(t: &'i0 U0, m: &'b N0) -> Foo /// ``` /// /// We now want to extract and substitute the type of the *trait* @@ -137,7 +137,7 @@ fn check_method_is_structurally_compatible<'tcx>( /// Applying this to the trait method type yields: /// /// ```rust,ignore (pseudo-Rust) -/// <'a> fn(t: &'i0 U0, m: &'a) -> Foo +/// <'a> fn(t: &'i0 U0, m: &'a N0) -> Foo /// ``` /// /// This type is also the same but the name of the bound region (`'a` @@ -258,8 +258,6 @@ fn compare_method_predicate_entailment<'tcx>( // type. // Compute placeholder form of impl and trait method tys. - let tcx = infcx.tcx; - let mut wf_tys = FxIndexSet::default(); let unnormalized_impl_sig = infcx.instantiate_binder_with_fresh_vars( @@ -1668,19 +1666,19 @@ fn compare_synthetic_generics<'tcx>( /// ```rust,ignore (pseudo-Rust) /// trait Foo { /// fn foo(); -/// type bar; +/// type Bar; /// fn baz(); -/// type blah; +/// type Blah; /// } /// /// impl Foo for () { /// fn foo() {} /// //~^ error -/// type bar {} +/// type Bar = (); /// //~^ error /// fn baz() {} /// //~^ error -/// type blah = u32; +/// type Blah = u32; /// //~^ error /// } /// ``` @@ -1769,36 +1767,82 @@ pub(super) fn compare_impl_const_raw( let trait_const_item = tcx.associated_item(trait_const_item_def); let impl_trait_ref = tcx.impl_trait_ref(impl_const_item.container_id(tcx)).unwrap().instantiate_identity(); - debug!("compare_const_impl(impl_trait_ref={:?})", impl_trait_ref); - let impl_c_span = tcx.def_span(impl_const_item_def.to_def_id()); + debug!("compare_impl_const(impl_trait_ref={:?})", impl_trait_ref); - let infcx = tcx.infer_ctxt().build(); - let param_env = tcx.param_env(impl_const_item_def.to_def_id()); - let ocx = ObligationCtxt::new(&infcx); + compare_number_of_generics(tcx, impl_const_item, trait_const_item, false)?; + compare_generic_param_kinds(tcx, impl_const_item, trait_const_item, false)?; + compare_const_predicate_entailment(tcx, impl_const_item, trait_const_item, impl_trait_ref) +} + +/// The equivalent of [compare_method_predicate_entailment], but for associated constants +/// instead of associated functions. +// FIXME(generic_const_items): If possible extract the common parts of `compare_{type,const}_predicate_entailment`. +fn compare_const_predicate_entailment<'tcx>( + tcx: TyCtxt<'tcx>, + impl_ct: ty::AssocItem, + trait_ct: ty::AssocItem, + impl_trait_ref: ty::TraitRef<'tcx>, +) -> Result<(), ErrorGuaranteed> { + let impl_ct_def_id = impl_ct.def_id.expect_local(); + let impl_ct_span = tcx.def_span(impl_ct_def_id); // The below is for the most part highly similar to the procedure // for methods above. It is simpler in many respects, especially // because we shouldn't really have to deal with lifetimes or // predicates. In fact some of this should probably be put into // shared functions because of DRY violations... - let trait_to_impl_args = impl_trait_ref.args; + let impl_args = GenericArgs::identity_for_item(tcx, impl_ct.def_id); + let trait_to_impl_args = + impl_args.rebase_onto(tcx, impl_ct.container_id(tcx), impl_trait_ref.args); // Create a parameter environment that represents the implementation's // method. // Compute placeholder form of impl and trait const tys. - let impl_ty = tcx.type_of(impl_const_item_def.to_def_id()).instantiate_identity(); - let trait_ty = tcx.type_of(trait_const_item_def).instantiate(tcx, trait_to_impl_args); - let mut cause = ObligationCause::new( - impl_c_span, - impl_const_item_def, - ObligationCauseCode::CompareImplItemObligation { - impl_item_def_id: impl_const_item_def, - trait_item_def_id: trait_const_item_def, - kind: impl_const_item.kind, - }, + let impl_ty = tcx.type_of(impl_ct_def_id).instantiate_identity(); + + let trait_ty = tcx.type_of(trait_ct.def_id).instantiate(tcx, trait_to_impl_args); + let code = ObligationCauseCode::CompareImplItemObligation { + impl_item_def_id: impl_ct_def_id, + trait_item_def_id: trait_ct.def_id, + kind: impl_ct.kind, + }; + let mut cause = ObligationCause::new(impl_ct_span, impl_ct_def_id, code.clone()); + + let impl_ct_predicates = tcx.predicates_of(impl_ct.def_id); + let trait_ct_predicates = tcx.predicates_of(trait_ct.def_id); + + check_region_bounds_on_impl_item(tcx, impl_ct, trait_ct, false)?; + + // The predicates declared by the impl definition, the trait and the + // associated const in the trait are assumed. + let impl_predicates = tcx.predicates_of(impl_ct_predicates.parent.unwrap()); + let mut hybrid_preds = impl_predicates.instantiate_identity(tcx); + hybrid_preds.predicates.extend( + trait_ct_predicates + .instantiate_own(tcx, trait_to_impl_args) + .map(|(predicate, _)| predicate), ); + let param_env = ty::ParamEnv::new(tcx.mk_clauses(&hybrid_preds.predicates), Reveal::UserFacing); + let param_env = traits::normalize_param_env_or_error( + tcx, + param_env, + ObligationCause::misc(impl_ct_span, impl_ct_def_id), + ); + + let infcx = tcx.infer_ctxt().build(); + let ocx = ObligationCtxt::new(&infcx); + + let impl_ct_own_bounds = impl_ct_predicates.instantiate_own(tcx, impl_args); + for (predicate, span) in impl_ct_own_bounds { + let cause = ObligationCause::misc(span, impl_ct_def_id); + let predicate = ocx.normalize(&cause, param_env, predicate); + + let cause = ObligationCause::new(span, impl_ct_def_id, code.clone()); + ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, predicate)); + } + // There is no "body" here, so just pass dummy id. let impl_ty = ocx.normalize(&cause, param_env, impl_ty); @@ -1817,7 +1861,7 @@ pub(super) fn compare_impl_const_raw( ); // Locate the Span containing just the type of the offending impl - let (ty, _) = tcx.hir().expect_impl_item(impl_const_item_def).expect_const(); + let (ty, _) = tcx.hir().expect_impl_item(impl_ct_def_id).expect_const(); cause.span = ty.span; let mut diag = struct_span_err!( @@ -1825,12 +1869,12 @@ pub(super) fn compare_impl_const_raw( cause.span, E0326, "implemented const `{}` has an incompatible type for trait", - trait_const_item.name + trait_ct.name ); - let trait_c_span = trait_const_item_def.as_local().map(|trait_c_def_id| { + let trait_c_span = trait_ct.def_id.as_local().map(|trait_ct_def_id| { // Add a label to the Span containing just the type of the const - let (ty, _) = tcx.hir().expect_trait_item(trait_c_def_id).expect_const(); + let (ty, _) = tcx.hir().expect_trait_item(trait_ct_def_id).expect_const(); ty.span }); @@ -1857,7 +1901,7 @@ pub(super) fn compare_impl_const_raw( } let outlives_env = OutlivesEnvironment::new(param_env); - ocx.resolve_regions_and_report_errors(impl_const_item_def, &outlives_env) + ocx.resolve_regions_and_report_errors(impl_ct_def_id, &outlives_env) } pub(super) fn compare_impl_ty<'tcx>( @@ -1899,7 +1943,7 @@ fn compare_type_predicate_entailment<'tcx>( return Ok(()); } - // This `HirId` should be used for the `body_id` field on each + // This `DefId` should be used for the `body_id` field on each // `ObligationCause` (and the `FnCtxt`). This is what // `regionck_item` expects. let impl_ty_def_id = impl_ty.def_id.expect_local(); @@ -1918,7 +1962,7 @@ fn compare_type_predicate_entailment<'tcx>( debug!("compare_type_predicate_entailment: bounds={:?}", hybrid_preds); let impl_ty_span = tcx.def_span(impl_ty_def_id); - let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id); + let normalize_cause = ObligationCause::misc(impl_ty_span, impl_ty_def_id); let param_env = ty::ParamEnv::new(tcx.mk_clauses(&hybrid_preds.predicates), Reveal::UserFacing); let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause); let infcx = tcx.infer_ctxt().build(); @@ -1963,7 +2007,7 @@ fn compare_type_predicate_entailment<'tcx>( /// /// trait X { type Y: Copy } impl X for T { type Y = S; } /// -/// We are able to normalize `::U` to `S`, and so when we check the +/// We are able to normalize `::Y` to `S`, and so when we check the /// impl is well-formed we have to prove `S: Copy`. /// /// For default associated types the normalization is not possible (the value diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index edcb9527fe2f..6e1762c54f21 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -209,6 +209,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { | ItemKind::Struct(..) | ItemKind::OpaqueTy(..) | ItemKind::Union(..) => (None, Defaults::Allowed), + ItemKind::Const(..) => (None, Defaults::Deny), _ => (None, Defaults::FutureCompatDisallowed), } } diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 979b101e7fe2..ab3b2dde0780 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -156,6 +156,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen } ItemKind::Fn(.., generics, _) | ItemKind::TyAlias(_, generics) + | ItemKind::Const(_, generics, _) | ItemKind::Enum(_, generics) | ItemKind::Struct(_, generics) | ItemKind::Union(_, generics) => generics, @@ -762,6 +763,7 @@ pub(super) fn type_param_predicates( ItemKind::Fn(.., generics, _) | ItemKind::Impl(&hir::Impl { generics, .. }) | ItemKind::TyAlias(_, generics) + | ItemKind::Const(_, generics, _) | ItemKind::OpaqueTy(&OpaqueTy { generics, origin: hir::OpaqueTyOrigin::TyAlias { .. }, diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index eb93817e823a..3cc6f574aecc 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -518,7 +518,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { | hir::ItemKind::Mod(..) | hir::ItemKind::ForeignMod { .. } | hir::ItemKind::Static(..) - | hir::ItemKind::Const(..) | hir::ItemKind::GlobalAsm(..) => { // These sorts of items have no lifetime parameters at all. intravisit::walk_item(self, item); @@ -583,6 +582,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { }) } hir::ItemKind::TyAlias(_, generics) + | hir::ItemKind::Const(_, generics, _) | hir::ItemKind::Enum(_, generics) | hir::ItemKind::Struct(_, generics) | hir::ItemKind::Union(_, generics) @@ -590,21 +590,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { | hir::ItemKind::TraitAlias(generics, ..) | hir::ItemKind::Impl(&hir::Impl { generics, .. }) => { // These kinds of items have only early-bound lifetime parameters. - let bound_vars = generics.params.iter().map(ResolvedArg::early).collect(); - self.record_late_bound_vars(item.hir_id(), vec![]); - let scope = Scope::Binder { - hir_id: item.hir_id(), - bound_vars, - scope_type: BinderScopeType::Normal, - s: self.scope, - where_bound_origin: None, - }; - self.with(scope, |this| { - let scope = Scope::TraitRefBoundary { s: this.scope }; - this.with(scope, |this| { - intravisit::walk_item(this, item); - }); - }); + self.visit_early(item.hir_id(), generics, |this| intravisit::walk_item(this, item)); } } } @@ -777,39 +763,24 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { use self::hir::TraitItemKind::*; match trait_item.kind { Fn(_, _) => { - self.visit_early_late(trait_item.hir_id(), &trait_item.generics, |this| { + self.visit_early_late(trait_item.hir_id(), trait_item.generics, |this| { intravisit::walk_trait_item(this, trait_item) }); } Type(bounds, ty) => { - let generics = &trait_item.generics; - let bound_vars = generics.params.iter().map(ResolvedArg::early).collect(); - self.record_late_bound_vars(trait_item.hir_id(), vec![]); - let scope = Scope::Binder { - hir_id: trait_item.hir_id(), - bound_vars, - s: self.scope, - scope_type: BinderScopeType::Normal, - where_bound_origin: None, - }; - self.with(scope, |this| { - let scope = Scope::TraitRefBoundary { s: this.scope }; - this.with(scope, |this| { - this.visit_generics(generics); - for bound in bounds { - this.visit_param_bound(bound); - } - if let Some(ty) = ty { - this.visit_ty(ty); - } - }) - }); - } - Const(_, _) => { - // Only methods and types support generics. - assert!(trait_item.generics.params.is_empty()); - intravisit::walk_trait_item(self, trait_item); + self.visit_early(trait_item.hir_id(), trait_item.generics, |this| { + this.visit_generics(&trait_item.generics); + for bound in bounds { + this.visit_param_bound(bound); + } + if let Some(ty) = ty { + this.visit_ty(ty); + } + }) } + Const(_, _) => self.visit_early(trait_item.hir_id(), trait_item.generics, |this| { + intravisit::walk_trait_item(this, trait_item) + }), } } @@ -817,34 +788,16 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) { use self::hir::ImplItemKind::*; match impl_item.kind { - Fn(..) => self.visit_early_late(impl_item.hir_id(), &impl_item.generics, |this| { + Fn(..) => self.visit_early_late(impl_item.hir_id(), impl_item.generics, |this| { + intravisit::walk_impl_item(this, impl_item) + }), + Type(ty) => self.visit_early(impl_item.hir_id(), impl_item.generics, |this| { + this.visit_generics(impl_item.generics); + this.visit_ty(ty); + }), + Const(_, _) => self.visit_early(impl_item.hir_id(), impl_item.generics, |this| { intravisit::walk_impl_item(this, impl_item) }), - Type(ty) => { - let generics = &impl_item.generics; - let bound_vars: FxIndexMap = - generics.params.iter().map(ResolvedArg::early).collect(); - self.record_late_bound_vars(impl_item.hir_id(), vec![]); - let scope = Scope::Binder { - hir_id: impl_item.hir_id(), - bound_vars, - s: self.scope, - scope_type: BinderScopeType::Normal, - where_bound_origin: None, - }; - self.with(scope, |this| { - let scope = Scope::TraitRefBoundary { s: this.scope }; - this.with(scope, |this| { - this.visit_generics(generics); - this.visit_ty(ty); - }) - }); - } - Const(_, _) => { - // Only methods and types support generics. - assert!(impl_item.generics.params.is_empty()); - intravisit::walk_impl_item(self, impl_item); - } } } @@ -1180,6 +1133,25 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { self.with(scope, walk); } + fn visit_early(&mut self, hir_id: hir::HirId, generics: &'tcx hir::Generics<'tcx>, walk: F) + where + F: for<'b, 'c> FnOnce(&'b mut BoundVarContext<'c, 'tcx>), + { + let bound_vars = generics.params.iter().map(ResolvedArg::early).collect(); + self.record_late_bound_vars(hir_id, vec![]); + let scope = Scope::Binder { + hir_id, + bound_vars, + s: self.scope, + scope_type: BinderScopeType::Normal, + where_bound_origin: None, + }; + self.with(scope, |this| { + let scope = Scope::TraitRefBoundary { s: this.scope }; + this.with(scope, walk) + }); + } + #[instrument(level = "debug", skip(self))] fn resolve_lifetime_ref( &mut self, From 59bb77c7fe67596f438e5ce17b2212c7bf011335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sun, 2 Jul 2023 23:21:36 +0200 Subject: [PATCH 135/150] Make Clippy understand generic const items --- src/tools/clippy/clippy_lints/src/large_const_arrays.rs | 6 +++++- src/tools/clippy/clippy_lints/src/non_copy_const.rs | 2 +- src/tools/clippy/clippy_lints/src/types/mod.rs | 2 +- src/tools/clippy/clippy_utils/src/ast_utils.rs | 8 ++++++-- src/tools/clippy/clippy_utils/src/consts.rs | 2 +- src/tools/clippy/clippy_utils/src/lib.rs | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/large_const_arrays.rs b/src/tools/clippy/clippy_lints/src/large_const_arrays.rs index 4dc750c03b48..9b26c3573e18 100644 --- a/src/tools/clippy/clippy_lints/src/large_const_arrays.rs +++ b/src/tools/clippy/clippy_lints/src/large_const_arrays.rs @@ -50,7 +50,11 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { if_chain! { if !item.span.from_expansion(); - if let ItemKind::Const(hir_ty, _) = &item.kind; + if let ItemKind::Const(hir_ty, generics, _) = &item.kind; + // Since static items may not have generics, skip generic const items. + // FIXME(generic_const_items): I don't think checking `generics.hwcp` suffices as it + // doesn't account for empty where-clauses that only consist of keyword `where` IINM. + if generics.params.is_empty() && !generics.has_where_clause_predicates; let ty = hir_ty_to_ty(cx.tcx, hir_ty); if let ty::Array(element_type, cst) = ty.kind(); if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind(); diff --git a/src/tools/clippy/clippy_lints/src/non_copy_const.rs b/src/tools/clippy/clippy_lints/src/non_copy_const.rs index 87699fd0ca6e..8bb2fa925856 100644 --- a/src/tools/clippy/clippy_lints/src/non_copy_const.rs +++ b/src/tools/clippy/clippy_lints/src/non_copy_const.rs @@ -302,7 +302,7 @@ declare_lint_pass!(NonCopyConst => [DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTER impl<'tcx> LateLintPass<'tcx> for NonCopyConst { fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx Item<'_>) { - if let ItemKind::Const(hir_ty, body_id) = it.kind { + if let ItemKind::Const(hir_ty, _generics, body_id) = it.kind { let ty = hir_ty_to_ty(cx.tcx, hir_ty); if !ignored_macro(cx, it) && is_unfrozen(cx, ty) && is_value_unfrozen_poly(cx, body_id, ty) { lint(cx, Source::Item { item: it.span }); diff --git a/src/tools/clippy/clippy_lints/src/types/mod.rs b/src/tools/clippy/clippy_lints/src/types/mod.rs index 3c873a5901d4..79f9d45d597e 100644 --- a/src/tools/clippy/clippy_lints/src/types/mod.rs +++ b/src/tools/clippy/clippy_lints/src/types/mod.rs @@ -349,7 +349,7 @@ impl<'tcx> LateLintPass<'tcx> for Types { let is_exported = cx.effective_visibilities.is_exported(item.owner_id.def_id); match item.kind { - ItemKind::Static(ty, _, _) | ItemKind::Const(ty, _) => self.check_ty( + ItemKind::Static(ty, _, _) | ItemKind::Const(ty, _, _) => self.check_ty( cx, ty, CheckTyContext { diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs index 8cc01f1ef974..7e42924603a4 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs @@ -301,15 +301,17 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { ( Const(box ast::ConstItem { defaultness: ld, + generics: lg, ty: lt, expr: le, }), Const(box ast::ConstItem { defaultness: rd, + generics: rg, ty: rt, expr: re, }), - ) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re), + ) => eq_defaultness(*ld, *rd) && eq_generics(lg, rg) && eq_ty(lt, rt) && eq_expr_opt(le, re), ( Fn(box ast::Fn { defaultness: ld, @@ -476,15 +478,17 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { ( Const(box ast::ConstItem { defaultness: ld, + generics: lg, ty: lt, expr: le, }), Const(box ast::ConstItem { defaultness: rd, + generics: rg, ty: rt, expr: re, }), - ) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re), + ) => eq_defaultness(*ld, *rd) && eq_generics(lg, rg) && eq_ty(lt, rt) && eq_expr_opt(le, re), ( Fn(box ast::Fn { defaultness: ld, diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs index 061086c4fc20..f19e09a18ec5 100644 --- a/src/tools/clippy/clippy_utils/src/consts.rs +++ b/src/tools/clippy/clippy_utils/src/consts.rs @@ -461,7 +461,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { // Check if this constant is based on `cfg!(..)`, // which is NOT constant for our purposes. if let Some(node) = self.lcx.tcx.hir().get_if_local(def_id) - && let Node::Item(Item { kind: ItemKind::Const(_, body_id), .. }) = node + && let Node::Item(Item { kind: ItemKind::Const(.., body_id), .. }) = node && let Node::Expr(Expr { kind: ExprKind::Lit(_), span, .. }) = self.lcx .tcx .hir() diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 035511e89125..45b99df46b01 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -2380,7 +2380,7 @@ fn with_test_item_names(tcx: TyCtxt<'_>, module: LocalDefId, f: impl Fn(&[Symbol for id in tcx.hir().module_items(module) { if matches!(tcx.def_kind(id.owner_id), DefKind::Const) && let item = tcx.hir().item(id) - && let ItemKind::Const(ty, _body) = item.kind { + && let ItemKind::Const(ty, _generics, _body) = item.kind { if let TyKind::Path(QPath::Resolved(_, path)) = ty.kind { // We could also check for the type name `test::TestDescAndFn` if let Res::Def(DefKind::Struct, _) = path.res { From a011dd9dacef28a53c868fa537c45fe81415c733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Mon, 3 Jul 2023 00:48:06 +0200 Subject: [PATCH 136/150] Render generic const items in rustdoc --- src/librustdoc/clean/inline.rs | 5 ++ src/librustdoc/clean/mod.rs | 66 ++++++++++-------------- src/librustdoc/clean/simplify.rs | 35 +++++++++++++ src/librustdoc/clean/types.rs | 16 +++--- src/librustdoc/html/render/mod.rs | 48 ++++++++++------- src/librustdoc/html/render/print_item.rs | 4 +- src/librustdoc/html/render/span_map.rs | 2 +- src/librustdoc/json/conversions.rs | 9 +++- 8 files changed, 116 insertions(+), 69 deletions(-) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 1c4149fd545e..c31d104f8cbe 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -644,6 +644,10 @@ pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String { } fn build_const(cx: &mut DocContext<'_>, def_id: DefId) -> clean::Constant { + let mut generics = + clean_ty_generics(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_predicates_of(def_id)); + clean::simplify::move_bounds_to_generic_parameters(&mut generics); + clean::Constant { type_: clean_middle_ty( ty::Binder::dummy(cx.tcx.type_of(def_id).instantiate_identity()), @@ -651,6 +655,7 @@ fn build_const(cx: &mut DocContext<'_>, def_id: DefId) -> clean::Constant { Some(def_id), None, ), + generics: Box::new(generics), kind: clean::ConstantKind::Extern { def_id }, } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a26eb222c18e..9839b82d7d7f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -273,6 +273,7 @@ pub(crate) fn clean_const<'tcx>(constant: &hir::ConstArg, cx: &mut DocContext<'t Some(def_id), None, ), + generics: Box::new(Generics::default()), kind: ConstantKind::Anonymous { body: constant.value.body }, } } @@ -284,6 +285,7 @@ pub(crate) fn clean_middle_const<'tcx>( // FIXME: instead of storing the stringified expression, store `self` directly instead. Constant { type_: clean_middle_ty(constant.map_bound(|c| c.ty()), cx, None, None), + generics: Box::new(Generics::default()), kind: ConstantKind::TyConst { expr: constant.skip_binder().to_string().into() }, } } @@ -1188,11 +1190,18 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext let local_did = trait_item.owner_id.to_def_id(); cx.with_param_env(local_did, |cx| { let inner = match trait_item.kind { - hir::TraitItemKind::Const(ty, Some(default)) => AssocConstItem( - clean_ty(ty, cx), - ConstantKind::Local { def_id: local_did, body: default }, - ), - hir::TraitItemKind::Const(ty, None) => TyAssocConstItem(clean_ty(ty, cx)), + hir::TraitItemKind::Const(ty, Some(default)) => { + let generics = enter_impl_trait(cx, |cx| clean_generics(trait_item.generics, cx)); + AssocConstItem( + Box::new(generics), + clean_ty(ty, cx), + ConstantKind::Local { def_id: local_did, body: default }, + ) + } + hir::TraitItemKind::Const(ty, None) => { + let generics = enter_impl_trait(cx, |cx| clean_generics(trait_item.generics, cx)); + TyAssocConstItem(Box::new(generics), clean_ty(ty, cx)) + } hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => { let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Body(body)); MethodItem(m, None) @@ -1237,8 +1246,9 @@ pub(crate) fn clean_impl_item<'tcx>( cx.with_param_env(local_did, |cx| { let inner = match impl_.kind { hir::ImplItemKind::Const(ty, expr) => { + let generics = clean_generics(impl_.generics, cx); let default = ConstantKind::Local { def_id: local_did, body: expr }; - AssocConstItem(clean_ty(ty, cx), default) + AssocConstItem(Box::new(generics), clean_ty(ty, cx), default) } hir::ImplItemKind::Fn(ref sig, body) => { let m = clean_function(cx, sig, impl_.generics, FunctionArgs::Body(body)); @@ -1279,14 +1289,21 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( None, ); + let mut generics = Box::new(clean_ty_generics( + cx, + tcx.generics_of(assoc_item.def_id), + tcx.explicit_predicates_of(assoc_item.def_id), + )); + simplify::move_bounds_to_generic_parameters(&mut generics); + let provided = match assoc_item.container { ty::ImplContainer => true, ty::TraitContainer => tcx.defaultness(assoc_item.def_id).has_value(), }; if provided { - AssocConstItem(ty, ConstantKind::Extern { def_id: assoc_item.def_id }) + AssocConstItem(generics, ty, ConstantKind::Extern { def_id: assoc_item.def_id }) } else { - TyAssocConstItem(ty) + TyAssocConstItem(generics, ty) } } ty::AssocKind::Fn => { @@ -1379,34 +1396,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( tcx.generics_of(assoc_item.def_id), ty::GenericPredicates { parent: None, predicates }, ); - // Move bounds that are (likely) directly attached to the parameters of the - // (generic) associated type from the where clause to the respective parameter. - // There is no guarantee that this is what the user actually wrote but we have - // no way of knowing. - let mut where_predicates = ThinVec::new(); - for mut pred in generics.where_predicates { - if let WherePredicate::BoundPredicate { ty: Generic(arg), bounds, .. } = &mut pred - && let Some(GenericParamDef { - kind: GenericParamDefKind::Type { bounds: param_bounds, .. }, - .. - }) = generics.params.iter_mut().find(|param| ¶m.name == arg) - { - param_bounds.append(bounds); - } else if let WherePredicate::RegionPredicate { lifetime: Lifetime(arg), bounds } = &mut pred - && let Some(GenericParamDef { - kind: GenericParamDefKind::Lifetime { outlives: param_bounds }, - .. - }) = generics.params.iter_mut().find(|param| ¶m.name == arg) - { - param_bounds.extend(bounds.drain(..).map(|bound| match bound { - GenericBound::Outlives(lifetime) => lifetime, - _ => unreachable!(), - })); - } else { - where_predicates.push(pred); - } - } - generics.where_predicates = where_predicates; + simplify::move_bounds_to_generic_parameters(&mut generics); if let ty::TraitContainer = assoc_item.container { // Move bounds that are (likely) directly attached to the associated type @@ -2603,9 +2593,9 @@ fn clean_maybe_renamed_item<'tcx>( ItemKind::Static(ty, mutability, body_id) => { StaticItem(Static { type_: clean_ty(ty, cx), mutability, expr: Some(body_id) }) } - // FIXME(fmease): rustdoc integration - ItemKind::Const(ty, _generics, body_id) => ConstantItem(Constant { + ItemKind::Const(ty, generics, body_id) => ConstantItem(Constant { type_: clean_ty(ty, cx), + generics: Box::new(clean_generics(generics, cx)), kind: ConstantKind::Local { body: body_id, def_id }, }), ItemKind::OpaqueTy(ref ty) => OpaqueTyItem(OpaqueTy { diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index d53b038019b7..7b8f20326ed4 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -138,3 +138,38 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId) }) .any(|did| trait_is_same_or_supertrait(cx, did, trait_)) } + +/// Move bounds that are (likely) directly attached to generic parameters from the where-clause to +/// the respective parameter. +/// +/// There is no guarantee that this is what the user actually wrote but we have no way of knowing. +// FIXME(fmease): It'd make a lot of sense to just incorporate this logic into `clean_ty_generics` +// making every of its users benefit from it. +pub(crate) fn move_bounds_to_generic_parameters(generics: &mut clean::Generics) { + use clean::types::*; + + let mut where_predicates = ThinVec::new(); + for mut pred in generics.where_predicates.drain(..) { + if let WherePredicate::BoundPredicate { ty: Generic(arg), bounds, .. } = &mut pred + && let Some(GenericParamDef { + kind: GenericParamDefKind::Type { bounds: param_bounds, .. }, + .. + }) = generics.params.iter_mut().find(|param| ¶m.name == arg) + { + param_bounds.append(bounds); + } else if let WherePredicate::RegionPredicate { lifetime: Lifetime(arg), bounds } = &mut pred + && let Some(GenericParamDef { + kind: GenericParamDefKind::Lifetime { outlives: param_bounds }, + .. + }) = generics.params.iter_mut().find(|param| ¶m.name == arg) + { + param_bounds.extend(bounds.drain(..).map(|bound| match bound { + GenericBound::Outlives(lifetime) => lifetime, + _ => unreachable!(), + })); + } else { + where_predicates.push(pred); + } + } + generics.where_predicates = where_predicates; +} diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6eec01771f36..cb089ddd09a3 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -824,9 +824,9 @@ pub(crate) enum ItemKind { ProcMacroItem(ProcMacro), PrimitiveItem(PrimitiveType), /// A required associated constant in a trait declaration. - TyAssocConstItem(Type), + TyAssocConstItem(Box, Type), /// An associated constant in a trait impl or a provided one in a trait declaration. - AssocConstItem(Type, ConstantKind), + AssocConstItem(Box, Type, ConstantKind), /// A required associated type in a trait declaration. /// /// The bounds may be non-empty if there is a `where` clause. @@ -871,8 +871,8 @@ impl ItemKind { | MacroItem(_) | ProcMacroItem(_) | PrimitiveItem(_) - | TyAssocConstItem(_) - | AssocConstItem(_, _) + | TyAssocConstItem(..) + | AssocConstItem(..) | TyAssocTypeItem(..) | AssocTypeItem(..) | StrippedItem(_) @@ -1278,7 +1278,7 @@ impl Lifetime { } } -#[derive(Clone, Debug)] +#[derive(Clone, PartialEq, Eq, Hash, Debug)] pub(crate) enum WherePredicate { BoundPredicate { ty: Type, bounds: Vec, bound_params: Vec }, RegionPredicate { lifetime: Lifetime, bounds: Vec }, @@ -1348,7 +1348,7 @@ impl GenericParamDef { } // maybe use a Generic enum and use Vec? -#[derive(Clone, Debug, Default)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, Default)] pub(crate) struct Generics { pub(crate) params: ThinVec, pub(crate) where_predicates: ThinVec, @@ -2266,6 +2266,7 @@ pub(crate) struct Static { #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub(crate) struct Constant { pub(crate) type_: Type, + pub(crate) generics: Box, pub(crate) kind: ConstantKind, } @@ -2515,7 +2516,8 @@ mod size_asserts { static_assert_size!(GenericParamDef, 56); static_assert_size!(Generics, 16); static_assert_size!(Item, 56); - static_assert_size!(ItemKind, 64); + // FIXME(generic_const_items): Further reduce the size. + static_assert_size!(ItemKind, 72); static_assert_size!(PathSegment, 40); static_assert_size!(Type, 32); // tidy-alphabetical-end diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 2fcf61d00490..a6200654ffa5 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -748,20 +748,22 @@ fn assoc_href_attr(it: &clean::Item, link: AssocItemLink<'_>, cx: &Context<'_>) fn assoc_const( w: &mut Buffer, it: &clean::Item, + generics: &clean::Generics, ty: &clean::Type, default: Option<&clean::ConstantKind>, link: AssocItemLink<'_>, - extra: &str, + indent: usize, cx: &Context<'_>, ) { let tcx = cx.tcx(); write!( w, - "{extra}{vis}const {name}: {ty}", - extra = extra, + "{indent}{vis}const {name}{generics}: {ty}", + indent = " ".repeat(indent), vis = visibility_print_with_space(it.visibility(tcx), it.item_id, cx), href = assoc_href_attr(it, link, cx), name = it.name.as_ref().unwrap(), + generics = generics.print(cx), ty = ty.print(cx), ); if let Some(default) = default { @@ -774,6 +776,7 @@ fn assoc_const( // Find a way to print constants here without all that jazz. write!(w, "{}", Escape(&default.value(tcx).unwrap_or_else(|| default.expr(tcx)))); } + write!(w, "{}", print_where_clause(generics, cx, indent, Ending::NoNewline)); } fn assoc_type( @@ -986,19 +989,22 @@ fn render_assoc_item( clean::MethodItem(m, _) => { assoc_method(w, item, &m.generics, &m.decl, link, parent, cx, render_mode) } - kind @ (clean::TyAssocConstItem(ty) | clean::AssocConstItem(ty, _)) => assoc_const( - w, - item, - ty, - match kind { - clean::TyAssocConstItem(_) => None, - clean::AssocConstItem(_, default) => Some(default), - _ => unreachable!(), - }, - link, - if parent == ItemType::Trait { " " } else { "" }, - cx, - ), + kind @ (clean::TyAssocConstItem(generics, ty) | clean::AssocConstItem(generics, ty, _)) => { + assoc_const( + w, + item, + generics, + ty, + match kind { + clean::TyAssocConstItem(..) => None, + clean::AssocConstItem(.., default) => Some(default), + _ => unreachable!(), + }, + link, + if parent == ItemType::Trait { 4 } else { 0 }, + cx, + ) + } clean::TyAssocTypeItem(ref generics, ref bounds) => assoc_type( w, item, @@ -1565,7 +1571,8 @@ fn render_impl( w.write_str(""); } } - kind @ (clean::TyAssocConstItem(ty) | clean::AssocConstItem(ty, _)) => { + kind @ (clean::TyAssocConstItem(generics, ty) + | clean::AssocConstItem(generics, ty, _)) => { let source_id = format!("{}.{}", item_type, name); let id = cx.derive_id(source_id.clone()); write!(w, "

", id, item_type, in_trait_class); @@ -1578,14 +1585,15 @@ fn render_impl( assoc_const( w, item, + generics, ty, match kind { - clean::TyAssocConstItem(_) => None, - clean::AssocConstItem(_, default) => Some(default), + clean::TyAssocConstItem(..) => None, + clean::AssocConstItem(.., default) => Some(default), _ => unreachable!(), }, link.anchor(if trait_.is_some() { &source_id } else { &id }), - "", + 0, cx, ); w.write_str(""); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 383e3c170881..e363e75f5656 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1543,10 +1543,12 @@ fn item_constant(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, c: &cle write!( w, - "{vis}const {name}: {typ}", + "{vis}const {name}{generics}: {typ}{where_clause}", vis = visibility_print_with_space(it.visibility(tcx), it.item_id, cx), name = it.name.unwrap(), + generics = c.generics.print(cx), typ = c.type_.print(cx), + where_clause = print_where_clause(&c.generics, cx, 0, Ending::NoNewline), ); // FIXME: The code below now prints diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index ac587bf6008d..5f130f1875aa 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -219,7 +219,7 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> { fn visit_item(&mut self, item: &'tcx Item<'tcx>) { match item.kind { ItemKind::Static(_, _, _) - | ItemKind::Const(_, _) + | ItemKind::Const(_, _, _) | ItemKind::Fn(_, _, _) | ItemKind::Macro(_, _) | ItemKind::TyAlias(_, _) diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 91cd55b1113a..8673138f6496 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -171,6 +171,7 @@ impl FromWithTcx for GenericArg { } impl FromWithTcx for Constant { + // FIXME(generic_const_items): Add support for generic const items. fn from_tcx(constant: clean::Constant, tcx: TyCtxt<'_>) -> Self { let expr = constant.expr(tcx); let value = constant.value(tcx); @@ -321,8 +322,12 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum { impls: Vec::new(), // Added in JsonRenderer::item }) } - TyAssocConstItem(ty) => ItemEnum::AssocConst { type_: ty.into_tcx(tcx), default: None }, - AssocConstItem(ty, default) => { + // FIXME(generic_const_items): Add support for generic associated consts. + TyAssocConstItem(_generics, ty) => { + ItemEnum::AssocConst { type_: ty.into_tcx(tcx), default: None } + } + // FIXME(generic_const_items): Add support for generic associated consts. + AssocConstItem(_generics, ty, default) => { ItemEnum::AssocConst { type_: ty.into_tcx(tcx), default: Some(default.expr(tcx)) } } TyAssocTypeItem(g, b) => ItemEnum::AssocType { From 6636916b666d067277ee31c1eab1970912b6eb8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Mon, 10 Jul 2023 03:10:03 +0200 Subject: [PATCH 137/150] Add UI tests for generic const items --- src/tools/tidy/src/ui_tests.rs | 2 +- .../associated-const-equality.rs | 22 ++++++ tests/ui/generic-const-items/basic.rs | 61 +++++++++++++++ .../generic-const-items/compare-impl-item.rs | 30 ++++++++ .../compare-impl-item.stderr | 66 ++++++++++++++++ .../generic-const-items/const-trait-impl.rs | 24 ++++++ .../duplicate-where-clause.rs | 27 +++++++ .../duplicate-where-clause.stderr | 27 +++++++ .../generic-const-items/elided-lifetimes.rs | 18 +++++ .../elided-lifetimes.stderr | 35 +++++++++ .../generic-const-items/evaluatable-bounds.rs | 31 ++++++++ .../evaluatable-bounds.unconstrained.stderr | 10 +++ .../feature-gate-generic_const_items.rs | 37 +++++++++ .../feature-gate-generic_const_items.stderr | 77 +++++++++++++++++++ .../generic-const-items/inference-failure.rs | 15 ++++ .../inference-failure.stderr | 20 +++++ .../misplaced-where-clause.fixed | 18 +++++ .../misplaced-where-clause.rs | 20 +++++ .../misplaced-where-clause.stderr | 36 +++++++++ .../generic-const-items/parameter-defaults.rs | 14 ++++ .../parameter-defaults.stderr | 8 ++ tests/ui/generic-const-items/recursive.rs | 12 +++ .../trivially-unsatisfied-bounds-0.rs | 12 +++ .../trivially-unsatisfied-bounds-0.stderr | 18 +++++ .../trivially-unsatisfied-bounds-1.rs | 12 +++ .../trivially-unsatisfied-bounds-1.stderr | 11 +++ .../generic-const-items/unsatisfied-bounds.rs | 34 ++++++++ .../unsatisfied-bounds.stderr | 62 +++++++++++++++ .../unsatisfied-evaluatable-bounds.rs | 12 +++ .../unsatisfied-evaluatable-bounds.stderr | 9 +++ .../unsatisfied-outlives-bounds.rs | 17 ++++ .../unsatisfied-outlives-bounds.stderr | 18 +++++ tests/ui/parser/generic-statics.rs | 4 + tests/ui/parser/generic-statics.stderr | 8 ++ 34 files changed, 826 insertions(+), 1 deletion(-) create mode 100644 tests/ui/generic-const-items/associated-const-equality.rs create mode 100644 tests/ui/generic-const-items/basic.rs create mode 100644 tests/ui/generic-const-items/compare-impl-item.rs create mode 100644 tests/ui/generic-const-items/compare-impl-item.stderr create mode 100644 tests/ui/generic-const-items/const-trait-impl.rs create mode 100644 tests/ui/generic-const-items/duplicate-where-clause.rs create mode 100644 tests/ui/generic-const-items/duplicate-where-clause.stderr create mode 100644 tests/ui/generic-const-items/elided-lifetimes.rs create mode 100644 tests/ui/generic-const-items/elided-lifetimes.stderr create mode 100644 tests/ui/generic-const-items/evaluatable-bounds.rs create mode 100644 tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr create mode 100644 tests/ui/generic-const-items/feature-gate-generic_const_items.rs create mode 100644 tests/ui/generic-const-items/feature-gate-generic_const_items.stderr create mode 100644 tests/ui/generic-const-items/inference-failure.rs create mode 100644 tests/ui/generic-const-items/inference-failure.stderr create mode 100644 tests/ui/generic-const-items/misplaced-where-clause.fixed create mode 100644 tests/ui/generic-const-items/misplaced-where-clause.rs create mode 100644 tests/ui/generic-const-items/misplaced-where-clause.stderr create mode 100644 tests/ui/generic-const-items/parameter-defaults.rs create mode 100644 tests/ui/generic-const-items/parameter-defaults.stderr create mode 100644 tests/ui/generic-const-items/recursive.rs create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs create mode 100644 tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr create mode 100644 tests/ui/generic-const-items/unsatisfied-bounds.rs create mode 100644 tests/ui/generic-const-items/unsatisfied-bounds.stderr create mode 100644 tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs create mode 100644 tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr create mode 100644 tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs create mode 100644 tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr create mode 100644 tests/ui/parser/generic-statics.rs create mode 100644 tests/ui/parser/generic-statics.stderr diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index ecbd2f79e36c..6cc7fbcacaf9 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1893; -const ROOT_ENTRY_LIMIT: usize = 871; +const ROOT_ENTRY_LIMIT: usize = 872; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/generic-const-items/associated-const-equality.rs b/tests/ui/generic-const-items/associated-const-equality.rs new file mode 100644 index 000000000000..785d3aa5018c --- /dev/null +++ b/tests/ui/generic-const-items/associated-const-equality.rs @@ -0,0 +1,22 @@ +// check-pass + +#![feature(generic_const_items, associated_const_equality)] +#![allow(incomplete_features)] + +trait Owner { + const C: u32; + const K: u32; +} + +impl Owner for () { + const C: u32 = N; + const K: u32 = N + 1; +} + +fn take0(_: impl Owner = { N }>) {} +fn take1(_: impl Owner = 100>) {} + +fn main() { + take0::<128>(()); + take1(()); +} diff --git a/tests/ui/generic-const-items/basic.rs b/tests/ui/generic-const-items/basic.rs new file mode 100644 index 000000000000..73bfa803acd2 --- /dev/null +++ b/tests/ui/generic-const-items/basic.rs @@ -0,0 +1,61 @@ +// check-pass + +// Basic usage patterns of free & associated generic const items. + +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +fn main() { + const NULL: Option = None::; + const NOTHING: Option = None; // arg inferred + + let _ = NOTHING::; + let _: Option = NULL; // arg inferred + + const IDENTITY: u64 = X; + + const COUNT: u64 = IDENTITY::<48>; + const AMOUNT: u64 = IDENTITY::; + const NUMBER: u64 = IDENTITY::<{ AMOUNT * 2 }>; + let _ = NUMBER; + let _ = IDENTITY::<0>; + + let _ = match 0 { + IDENTITY::<1> => 2, + IDENTITY::<{ 1 + 1 }> => 4, + _ => 0, + }; + + const CREATE: I = I::PROOF; + let _ = CREATE::; + let _: u64 = CREATE; // arg inferred + + let _ = <() as Main>::MAKE::; + let _: (u64, u64) = <()>::MAKE; // args inferred +} + +pub fn usage<'any>() { + const REGION_POLY<'a>: &'a () = &(); + + let _: &'any () = REGION_POLY::<'any>; + let _: &'any () = REGION_POLY::<'_>; + let _: &'static () = REGION_POLY; +} + +trait Main { + type Output; + const MAKE: Self::Output; +} + +impl Main for () { + type Output = (O, I); + const MAKE: Self::Output = (O::PROOF, I::PROOF); +} + +trait Inhabited { + const PROOF: Self; +} + +impl Inhabited for u64 { + const PROOF: Self = 512; +} diff --git a/tests/ui/generic-const-items/compare-impl-item.rs b/tests/ui/generic-const-items/compare-impl-item.rs new file mode 100644 index 000000000000..01e4477c698d --- /dev/null +++ b/tests/ui/generic-const-items/compare-impl-item.rs @@ -0,0 +1,30 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +trait Trait

{ + const A: (); + const B: u64; + const C: T; + const D: usize; + + const E: usize; + const F: (); +} + +impl

Trait

for () { + const A: () = (); + //~^ ERROR const `A` has 1 type parameter but its trait declaration has 0 type parameters + const B: u64 = 0; + //~^ ERROR const `B` has 1 const parameter but its trait declaration has 2 const parameters + const C<'a>: &'a str = ""; + //~^ ERROR const `C` has 0 type parameters but its trait declaration has 1 type parameter + const D: u16 = N; + //~^ ERROR const `D` has an incompatible generic parameter for trait `Trait` + + const E: usize = 1024 + where + P: Copy; //~ ERROR impl has stricter requirements than trait + const F: () = (); //~ ERROR impl has stricter requirements than trait +} + +fn main() {} diff --git a/tests/ui/generic-const-items/compare-impl-item.stderr b/tests/ui/generic-const-items/compare-impl-item.stderr new file mode 100644 index 000000000000..8610d8cba000 --- /dev/null +++ b/tests/ui/generic-const-items/compare-impl-item.stderr @@ -0,0 +1,66 @@ +error[E0049]: const `A` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/compare-impl-item.rs:15:13 + | +LL | const A: (); + | - expected 0 type parameters +... +LL | const A: () = (); + | ^ found 1 type parameter + +error[E0049]: const `B` has 1 const parameter but its trait declaration has 2 const parameters + --> $DIR/compare-impl-item.rs:17:13 + | +LL | const B: u64; + | ------------ ------------ + | | + | expected 2 const parameters +... +LL | const B: u64 = 0; + | ^^^^^^^^^^^^ found 1 const parameter + +error[E0049]: const `C` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/compare-impl-item.rs:19:13 + | +LL | const C: T; + | - expected 1 type parameter +... +LL | const C<'a>: &'a str = ""; + | ^^ found 0 type parameters + +error[E0053]: const `D` has an incompatible generic parameter for trait `Trait` + --> $DIR/compare-impl-item.rs:21:13 + | +LL | trait Trait

{ + | ----- +... +LL | const D: usize; + | -------------- expected const parameter of type `usize` +... +LL | impl

Trait

for () { + | ----------------------- +... +LL | const D: u16 = N; + | ^^^^^^^^^^^^ found const parameter of type `u16` + +error[E0276]: impl has stricter requirements than trait + --> $DIR/compare-impl-item.rs:26:12 + | +LL | const E: usize; + | -------------- definition of `E` from trait +... +LL | P: Copy; + | ^^^^ impl has extra requirement `P: Copy` + +error[E0276]: impl has stricter requirements than trait + --> $DIR/compare-impl-item.rs:27:16 + | +LL | const F: (); + | ------------------------- definition of `F` from trait +... +LL | const F: () = (); + | ^^ impl has extra requirement `T: Eq` + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0049, E0053, E0276. +For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/generic-const-items/const-trait-impl.rs b/tests/ui/generic-const-items/const-trait-impl.rs new file mode 100644 index 000000000000..8da1448df4f2 --- /dev/null +++ b/tests/ui/generic-const-items/const-trait-impl.rs @@ -0,0 +1,24 @@ +// check-pass + +// Test that we can call methods from const trait impls inside of generic const items. + +#![feature(generic_const_items, const_trait_impl)] +#![allow(incomplete_features)] +#![crate_type = "lib"] + +// FIXME(generic_const_items): Interpret `~const` as always-const. +const CREATE: T = T::create(); + +pub const K0: i32 = CREATE::; +pub const K1: i32 = CREATE; // arg inferred + +#[const_trait] +trait Create { + fn create() -> Self; +} + +impl const Create for i32 { + fn create() -> i32 { + 4096 + } +} diff --git a/tests/ui/generic-const-items/duplicate-where-clause.rs b/tests/ui/generic-const-items/duplicate-where-clause.rs new file mode 100644 index 000000000000..68da4073fc1f --- /dev/null +++ b/tests/ui/generic-const-items/duplicate-where-clause.rs @@ -0,0 +1,27 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +trait Tr

{ + const K: () + where + P: Copy + where + P: Eq; + //~^ ERROR cannot define duplicate `where` clauses on an item +} + +// Test that we error on the first where-clause but also that we don't suggest to swap it with the +// body as it would conflict with the second where-clause. +// FIXME(generic_const_items): We should provide a structured sugg to merge the 1st into the 2nd WC. + +impl

Tr

for () { + const K: () + where + P: Eq + = () + where + P: Copy; + //~^^^^^ ERROR where clauses are not allowed before const item bodies +} + +fn main() {} diff --git a/tests/ui/generic-const-items/duplicate-where-clause.stderr b/tests/ui/generic-const-items/duplicate-where-clause.stderr new file mode 100644 index 000000000000..5fa61b01ee9d --- /dev/null +++ b/tests/ui/generic-const-items/duplicate-where-clause.stderr @@ -0,0 +1,27 @@ +error: cannot define duplicate `where` clauses on an item + --> $DIR/duplicate-where-clause.rs:9:9 + | +LL | P: Copy + | - previous `where` clause starts here +LL | where +LL | P: Eq; + | ^ + | +help: consider joining the two `where` clauses into one + | +LL | P: Copy, + | ~ + +error: where clauses are not allowed before const item bodies + --> $DIR/duplicate-where-clause.rs:19:5 + | +LL | const K: () + | - while parsing this const item +LL | / where +LL | | P: Eq + | |_____________^ unexpected where clause +LL | = () + | -- the item body + +error: aborting due to 2 previous errors + diff --git a/tests/ui/generic-const-items/elided-lifetimes.rs b/tests/ui/generic-const-items/elided-lifetimes.rs new file mode 100644 index 000000000000..cca73e2e81e8 --- /dev/null +++ b/tests/ui/generic-const-items/elided-lifetimes.rs @@ -0,0 +1,18 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Check that we forbid elided lifetimes inside the generics of const items. + +const K: () = () +where + &T: Copy; //~ ERROR `&` without an explicit lifetime name cannot be used here + +const I: &str = ""; +//~^ ERROR `&` without an explicit lifetime name cannot be used here +//~| ERROR `&str` is forbidden as the type of a const generic parameter + +const B>: () = (); //~ ERROR `'_` cannot be used here + +trait Trait<'a> {} + +fn main() {} diff --git a/tests/ui/generic-const-items/elided-lifetimes.stderr b/tests/ui/generic-const-items/elided-lifetimes.stderr new file mode 100644 index 000000000000..8cd3f9ee7a91 --- /dev/null +++ b/tests/ui/generic-const-items/elided-lifetimes.stderr @@ -0,0 +1,35 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/elided-lifetimes.rs:8:5 + | +LL | &T: Copy; + | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here + | +LL | for<'a> &'a T: Copy; + | +++++++ ++ + +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/elided-lifetimes.rs:10:18 + | +LL | const I: &str = ""; + | ^ explicit lifetime name needed here + +error[E0637]: `'_` cannot be used here + --> $DIR/elided-lifetimes.rs:14:18 + | +LL | const B>: () = (); + | ^^ `'_` is a reserved lifetime name + +error: `&str` is forbidden as the type of a const generic parameter + --> $DIR/elided-lifetimes.rs:10:18 + | +LL | const I: &str = ""; + | ^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/generic-const-items/evaluatable-bounds.rs b/tests/ui/generic-const-items/evaluatable-bounds.rs new file mode 100644 index 000000000000..cdcfcf9188a6 --- /dev/null +++ b/tests/ui/generic-const-items/evaluatable-bounds.rs @@ -0,0 +1,31 @@ +// This is a regression test for issue #104400. + +// revisions: unconstrained constrained +//[constrained] check-pass + +// Test that we can constrain generic const items that appear inside associated consts by +// adding a (makeshift) "evaluatable"-bound to the item. + +#![feature(generic_const_items, generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait { + const LEN: usize; + + #[cfg(unconstrained)] + const ARRAY: [i32; Self::LEN]; //[unconstrained]~ ERROR unconstrained generic constant + + #[cfg(constrained)] + const ARRAY: [i32; Self::LEN] + where + [(); Self::LEN]:; +} + +impl Trait for () { + const LEN: usize = 2; + const ARRAY: [i32; Self::LEN] = [360, 720]; +} + +fn main() { + let [_, _] = <() as Trait>::ARRAY; +} diff --git a/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr new file mode 100644 index 000000000000..930080f7c378 --- /dev/null +++ b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/evaluatable-bounds.rs:16:5 + | +LL | const ARRAY: [i32; Self::LEN]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); Self::LEN]:` + +error: aborting due to previous error + diff --git a/tests/ui/generic-const-items/feature-gate-generic_const_items.rs b/tests/ui/generic-const-items/feature-gate-generic_const_items.rs new file mode 100644 index 000000000000..5c241f256ebd --- /dev/null +++ b/tests/ui/generic-const-items/feature-gate-generic_const_items.rs @@ -0,0 +1,37 @@ +pub trait Trait { + const ONE: i32; + //~^ ERROR generic const items are experimental + + const TWO: () + where + A: Copy; + //~^^ ERROR generic const items are experimental +} + +const CONST: i32 = 0; +//~^ ERROR generic const items are experimental + +const EMPTY<>: i32 = 0; +//~^ ERROR generic const items are experimental + +const TRUE: () = () +where + String: Clone; +//~^^ ERROR generic const items are experimental + +// Ensure that we flag generic const items inside macro calls as well: + +macro_rules! discard { + ($item:item) => {} +} + +discard! { const FREE: () = (); } +//~^ ERROR generic const items are experimental + +discard! { impl () { const ASSOC: () = (); } } +//~^ ERROR generic const items are experimental + +discard! { impl () { const ASSOC: i32 = 0 where String: Copy; } } +//~^ ERROR generic const items are experimental + +fn main() {} diff --git a/tests/ui/generic-const-items/feature-gate-generic_const_items.stderr b/tests/ui/generic-const-items/feature-gate-generic_const_items.stderr new file mode 100644 index 000000000000..a1fdf5f6ef33 --- /dev/null +++ b/tests/ui/generic-const-items/feature-gate-generic_const_items.stderr @@ -0,0 +1,77 @@ +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:2:14 + | +LL | const ONE: i32; + | ^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:6:5 + | +LL | / where +LL | | A: Copy; + | |_______________^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:11:12 + | +LL | const CONST: i32 = 0; + | ^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:14:12 + | +LL | const EMPTY<>: i32 = 0; + | ^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:18:1 + | +LL | / where +LL | | String: Clone; + | |_________________^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:28:22 + | +LL | discard! { const FREE: () = (); } + | ^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:31:33 + | +LL | discard! { impl () { const ASSOC: () = (); } } + | ^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error[E0658]: generic const items are experimental + --> $DIR/feature-gate-generic_const_items.rs:34:43 + | +LL | discard! { impl () { const ASSOC: i32 = 0 where String: Copy; } } + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 for more information + = help: add `#![feature(generic_const_items)]` to the crate attributes to enable + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/generic-const-items/inference-failure.rs b/tests/ui/generic-const-items/inference-failure.rs new file mode 100644 index 000000000000..fd4f424dd977 --- /dev/null +++ b/tests/ui/generic-const-items/inference-failure.rs @@ -0,0 +1,15 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +const NONE: Option = None::; +const IGNORE: () = (); + +fn none() { + let _ = NONE; //~ ERROR type annotations needed +} + +fn ignore() { + let _ = IGNORE; //~ ERROR type annotations needed +} + +fn main() {} diff --git a/tests/ui/generic-const-items/inference-failure.stderr b/tests/ui/generic-const-items/inference-failure.stderr new file mode 100644 index 000000000000..22ff1b9ba7f4 --- /dev/null +++ b/tests/ui/generic-const-items/inference-failure.stderr @@ -0,0 +1,20 @@ +error[E0282]: type annotations needed for `Option` + --> $DIR/inference-failure.rs:8:9 + | +LL | let _ = NONE; + | ^ + | +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | let _: Option = NONE; + | +++++++++++ + +error[E0282]: type annotations needed + --> $DIR/inference-failure.rs:12:13 + | +LL | let _ = IGNORE; + | ^^^^^^ cannot infer type for type parameter `T` declared on the constant `IGNORE` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/generic-const-items/misplaced-where-clause.fixed b/tests/ui/generic-const-items/misplaced-where-clause.fixed new file mode 100644 index 000000000000..bff470c28832 --- /dev/null +++ b/tests/ui/generic-const-items/misplaced-where-clause.fixed @@ -0,0 +1,18 @@ +// run-rustfix + +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +const K: u64 += T::K where + T: Tr<()>; +//~^^^ ERROR where clauses are not allowed before const item bodies + +trait Tr

{ + const K: u64 + = 0 where + P: Copy; + //~^^^ ERROR where clauses are not allowed before const item bodies +} + +fn main() {} diff --git a/tests/ui/generic-const-items/misplaced-where-clause.rs b/tests/ui/generic-const-items/misplaced-where-clause.rs new file mode 100644 index 000000000000..b14c6d594a52 --- /dev/null +++ b/tests/ui/generic-const-items/misplaced-where-clause.rs @@ -0,0 +1,20 @@ +// run-rustfix + +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +const K: u64 +where + T: Tr<()> += T::K; +//~^^^ ERROR where clauses are not allowed before const item bodies + +trait Tr

{ + const K: u64 + where + P: Copy + = 0; + //~^^^ ERROR where clauses are not allowed before const item bodies +} + +fn main() {} diff --git a/tests/ui/generic-const-items/misplaced-where-clause.stderr b/tests/ui/generic-const-items/misplaced-where-clause.stderr new file mode 100644 index 000000000000..431741d8724b --- /dev/null +++ b/tests/ui/generic-const-items/misplaced-where-clause.stderr @@ -0,0 +1,36 @@ +error: where clauses are not allowed before const item bodies + --> $DIR/misplaced-where-clause.rs:7:1 + | +LL | const K: u64 + | - while parsing this const item +LL | / where +LL | | T: Tr<()> + | |_____________^ unexpected where clause +LL | = T::K; + | ---- the item body + | +help: move the body before the where clause + | +LL ~ = T::K where +LL ~ T: Tr<()>; + | + +error: where clauses are not allowed before const item bodies + --> $DIR/misplaced-where-clause.rs:14:5 + | +LL | const K: u64 + | - while parsing this const item +LL | / where +LL | | P: Copy + | |_______________^ unexpected where clause +LL | = 0; + | - the item body + | +help: move the body before the where clause + | +LL ~ = 0 where +LL ~ P: Copy; + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/generic-const-items/parameter-defaults.rs b/tests/ui/generic-const-items/parameter-defaults.rs new file mode 100644 index 000000000000..a6f82c249feb --- /dev/null +++ b/tests/ui/generic-const-items/parameter-defaults.rs @@ -0,0 +1,14 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Check that we emit a *hard* error (not just a lint warning or error for example) for generic +// parameter defaults on free const items since we are not limited by backward compatibility. +#![allow(invalid_type_param_default)] // Should have no effect here. + +// FIXME(default_type_parameter_fallback): Consider reallowing them once they work properly. + +const NONE: Option = None::; //~ ERROR defaults for type parameters are only allowed + +fn main() { + let _ = NONE; +} diff --git a/tests/ui/generic-const-items/parameter-defaults.stderr b/tests/ui/generic-const-items/parameter-defaults.stderr new file mode 100644 index 000000000000..62da45e55d6b --- /dev/null +++ b/tests/ui/generic-const-items/parameter-defaults.stderr @@ -0,0 +1,8 @@ +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/parameter-defaults.rs:10:12 + | +LL | const NONE: Option = None::; + | ^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/generic-const-items/recursive.rs b/tests/ui/generic-const-items/recursive.rs new file mode 100644 index 000000000000..3266b37d3809 --- /dev/null +++ b/tests/ui/generic-const-items/recursive.rs @@ -0,0 +1,12 @@ +// FIXME(generic_const_items): This leads to a stack overflow in the compiler! +// known-bug: unknown +// ignore-test + +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +const RECUR: () = RECUR::<(T,)>; + +fn main() { + let _ = RECUR::<()>; +} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs new file mode 100644 index 000000000000..dd00b327d2d2 --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_items, trivial_bounds)] +#![allow(incomplete_features)] + +// Ensure that we check if trivial bounds on const items hold or not. + +const UNUSABLE: () = () +where + String: Copy; + +fn main() { + let _ = UNUSABLE; //~ ERROR the trait bound `String: Copy` is not satisfied +} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr new file mode 100644 index 000000000000..c3ef94529a49 --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/trivially-unsatisfied-bounds-0.rs:11:13 + | +LL | let _ = UNUSABLE; + | ^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `UNUSABLE` + --> $DIR/trivially-unsatisfied-bounds-0.rs:8:13 + | +LL | const UNUSABLE: () = () + | -------- required by a bound in this constant +LL | where +LL | String: Copy; + | ^^^^ required by this bound in `UNUSABLE` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs new file mode 100644 index 000000000000..9243deac8704 --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_items, trivial_bounds)] +#![allow(incomplete_features, dead_code, trivial_bounds)] + +// FIXME(generic_const_items): This looks like a bug to me. I expected that we wouldn't emit any +// errors. I thought we'd skip the evaluation of consts whose bounds don't hold. + +const UNUSED: () = () +where + String: Copy; +//~^^^ ERROR evaluation of constant value failed + +fn main() {} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr new file mode 100644 index 000000000000..a68400798d81 --- /dev/null +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr @@ -0,0 +1,11 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/trivially-unsatisfied-bounds-1.rs:7:1 + | +LL | / const UNUSED: () = () +LL | | where +LL | | String: Copy; + | |_________________^ entering unreachable code + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.rs b/tests/ui/generic-const-items/unsatisfied-bounds.rs new file mode 100644 index 000000000000..058799001725 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-bounds.rs @@ -0,0 +1,34 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Ensure that we check if bounds on const items hold or not. + +use std::convert::Infallible; + +const C: () = (); + +const K: () = () +where + Infallible: From; + +trait Trait

{ + const A: u32 + where + P: Copy; + + const B: u32 + where + Infallible: From; +} + +impl

Trait

for () { + const A: u32 = 0; + const B: u32 = 1; +} + +fn main() { + let () = C::; //~ ERROR the trait bound `String: Copy` is not satisfied + let () = K::<()>; //~ ERROR the trait bound `Infallible: From<()>` is not satisfied + let _ = <() as Trait>>::A; //~ ERROR the trait bound `Vec: Copy` is not satisfied + let _ = <() as Trait<&'static str>>::B::<()>; //~ ERROR the trait bound `Infallible: From<()>` is not satisfied +} diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-bounds.stderr new file mode 100644 index 000000000000..1fda460372a5 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-bounds.stderr @@ -0,0 +1,62 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/unsatisfied-bounds.rs:30:18 + | +LL | let () = C::; + | ^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `C` + --> $DIR/unsatisfied-bounds.rs:8:12 + | +LL | const C: () = (); + | ^^^^ required by this bound in `C` + +error[E0277]: the trait bound `Infallible: From<()>` is not satisfied + --> $DIR/unsatisfied-bounds.rs:31:18 + | +LL | let () = K::<()>; + | ^^ the trait `From<()>` is not implemented for `Infallible` + | + = help: the trait `From` is implemented for `Infallible` +note: required by a bound in `K` + --> $DIR/unsatisfied-bounds.rs:12:17 + | +LL | const K: () = () + | - required by a bound in this constant +LL | where +LL | Infallible: From; + | ^^^^^^^ required by this bound in `K` + +error[E0277]: the trait bound `Vec: Copy` is not satisfied + --> $DIR/unsatisfied-bounds.rs:32:13 + | +LL | let _ = <() as Trait>>::A; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Vec` + | +note: required by a bound in `Trait::A` + --> $DIR/unsatisfied-bounds.rs:17:12 + | +LL | const A: u32 + | - required by a bound in this associated constant +LL | where +LL | P: Copy; + | ^^^^ required by this bound in `Trait::A` + +error[E0277]: the trait bound `Infallible: From<()>` is not satisfied + --> $DIR/unsatisfied-bounds.rs:33:46 + | +LL | let _ = <() as Trait<&'static str>>::B::<()>; + | ^^ the trait `From<()>` is not implemented for `Infallible` + | + = help: the trait `From` is implemented for `Infallible` +note: required by a bound in `Trait::B` + --> $DIR/unsatisfied-bounds.rs:21:21 + | +LL | const B: u32 + | - required by a bound in this associated constant +LL | where +LL | Infallible: From; + | ^^^^^^^ required by this bound in `Trait::B` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs new file mode 100644 index 000000000000..961e5b4aeeb8 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_items, generic_const_exprs)] +#![allow(incomplete_features)] + +// Ensure that we check if (makeshift) "evaluatable"-bounds on const items hold or not. + +const POSITIVE: usize = N +where + [(); N - 1]:; //~ ERROR evaluation of `POSITIVE::<0>::{constant#0}` failed + +fn main() { + let _ = POSITIVE::<0>; +} diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr new file mode 100644 index 000000000000..bed213b0caa7 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of `POSITIVE::<0>::{constant#0}` failed + --> $DIR/unsatisfied-evaluatable-bounds.rs:8:10 + | +LL | [(); N - 1]:; + | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs new file mode 100644 index 000000000000..204cf9def368 --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.rs @@ -0,0 +1,17 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// Ensure that we check if outlives-bounds on const items hold or not. + +const C<'a, T: 'a>: () = (); +const K<'a, 'b: 'a>: () = (); + +fn parametrized0<'any>() { + let () = C::<'static, &'any ()>; //~ ERROR lifetime may not live long enough +} + +fn parametrized1<'any>() { + let () = K::<'static, 'any>; //~ ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr new file mode 100644 index 000000000000..72e4265b3d7f --- /dev/null +++ b/tests/ui/generic-const-items/unsatisfied-outlives-bounds.stderr @@ -0,0 +1,18 @@ +error: lifetime may not live long enough + --> $DIR/unsatisfied-outlives-bounds.rs:10:14 + | +LL | fn parametrized0<'any>() { + | ---- lifetime `'any` defined here +LL | let () = C::<'static, &'any ()>; + | ^^^^^^^^^^^^^^^^^^^^^^ requires that `'any` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/unsatisfied-outlives-bounds.rs:14:14 + | +LL | fn parametrized1<'any>() { + | ---- lifetime `'any` defined here +LL | let () = K::<'static, 'any>; + | ^^^^^^^^^^^^^^^^^^ requires that `'any` must outlive `'static` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/generic-statics.rs b/tests/ui/parser/generic-statics.rs new file mode 100644 index 000000000000..2fb8781fdffb --- /dev/null +++ b/tests/ui/parser/generic-statics.rs @@ -0,0 +1,4 @@ +static S: i32 = 0; +//~^ ERROR static items may not have generic parameters + +fn main() {} diff --git a/tests/ui/parser/generic-statics.stderr b/tests/ui/parser/generic-statics.stderr new file mode 100644 index 000000000000..c757232b061c --- /dev/null +++ b/tests/ui/parser/generic-statics.stderr @@ -0,0 +1,8 @@ +error: static items may not have generic parameters + --> $DIR/generic-statics.rs:1:9 + | +LL | static S: i32 = 0; + | ^^^ + +error: aborting due to previous error + From 55aba32ac5a1b81ad815d633304ba5e94b2ef7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Mon, 10 Jul 2023 07:10:20 +0200 Subject: [PATCH 138/150] Update existing UI tests --- tests/ui/object-safety/assoc_const_bounds.rs | 9 +++- .../object-safety/assoc_const_bounds.stderr | 15 ------ .../object-safety/assoc_const_bounds_sized.rs | 9 +++- .../assoc_const_bounds_sized.stderr | 15 ------ ...fetime-in-assoc-const-type.default.stderr} | 8 ++-- ...ssoc-const-type.generic_const_items.stderr | 47 +++++++++++++++++++ .../missing-lifetime-in-assoc-const-type.rs | 4 ++ 7 files changed, 69 insertions(+), 38 deletions(-) delete mode 100644 tests/ui/object-safety/assoc_const_bounds.stderr delete mode 100644 tests/ui/object-safety/assoc_const_bounds_sized.stderr rename tests/ui/suggestions/{missing-lifetime-in-assoc-const-type.stderr => missing-lifetime-in-assoc-const-type.default.stderr} (86%) create mode 100644 tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr diff --git a/tests/ui/object-safety/assoc_const_bounds.rs b/tests/ui/object-safety/assoc_const_bounds.rs index 94b1f63165ba..bfa21fd9aeac 100644 --- a/tests/ui/object-safety/assoc_const_bounds.rs +++ b/tests/ui/object-safety/assoc_const_bounds.rs @@ -1,7 +1,12 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +// check-pass + trait Foo { const BAR: bool - where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - Self: Sized; + where + Self: Sized; } trait Cake {} diff --git a/tests/ui/object-safety/assoc_const_bounds.stderr b/tests/ui/object-safety/assoc_const_bounds.stderr deleted file mode 100644 index 09bc11e178a4..000000000000 --- a/tests/ui/object-safety/assoc_const_bounds.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - --> $DIR/assoc_const_bounds.rs:3:9 - | -LL | trait Foo { - | - while parsing this item list starting here -LL | const BAR: bool - | - expected one of 7 possible tokens -LL | where - | ^^^^^ unexpected token -LL | Self: Sized; -LL | } - | - the item list ends here - -error: aborting due to previous error - diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.rs b/tests/ui/object-safety/assoc_const_bounds_sized.rs index 2a76e5dce2b4..87d1f06f0363 100644 --- a/tests/ui/object-safety/assoc_const_bounds_sized.rs +++ b/tests/ui/object-safety/assoc_const_bounds_sized.rs @@ -1,7 +1,12 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features, dead_code)] + +// check-pass + trait Foo { const BAR: bool - where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - Self: Sized; + where + Self: Sized; } fn foo(_: &dyn Foo) {} diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.stderr b/tests/ui/object-safety/assoc_const_bounds_sized.stderr deleted file mode 100644 index e1f57f677956..000000000000 --- a/tests/ui/object-safety/assoc_const_bounds_sized.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` - --> $DIR/assoc_const_bounds_sized.rs:3:9 - | -LL | trait Foo { - | - while parsing this item list starting here -LL | const BAR: bool - | - expected one of 7 possible tokens -LL | where - | ^^^^^ unexpected token -LL | Self: Sized; -LL | } - | - the item list ends here - -error: aborting due to previous error - diff --git a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.default.stderr similarity index 86% rename from tests/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr rename to tests/ui/suggestions/missing-lifetime-in-assoc-const-type.default.stderr index 233f1bc5a86e..24e2e0a0f7a2 100644 --- a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.stderr +++ b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.default.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-in-assoc-const-type.rs:2:14 + --> $DIR/missing-lifetime-in-assoc-const-type.rs:6:14 | LL | const A: &str = ""; | ^ expected named lifetime parameter @@ -11,7 +11,7 @@ LL ~ const A: &'a str = ""; | error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-in-assoc-const-type.rs:3:14 + --> $DIR/missing-lifetime-in-assoc-const-type.rs:7:14 | LL | const B: S = S { s: &() }; | ^ expected named lifetime parameter @@ -24,7 +24,7 @@ LL ~ const B: S<'a> = S { s: &() }; | error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-in-assoc-const-type.rs:4:15 + --> $DIR/missing-lifetime-in-assoc-const-type.rs:8:15 | LL | const C: &'_ str = ""; | ^^ expected named lifetime parameter @@ -38,7 +38,7 @@ LL ~ const C: &'a str = ""; | error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-in-assoc-const-type.rs:5:14 + --> $DIR/missing-lifetime-in-assoc-const-type.rs:9:14 | LL | const D: T = T { a: &(), b: &() }; | ^ expected 2 lifetime parameters diff --git a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr new file mode 100644 index 000000000000..a97ffe7da79e --- /dev/null +++ b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.generic_const_items.stderr @@ -0,0 +1,47 @@ +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:6:14 + | +LL | const A: &str = ""; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | const A<'a>: &'a str = ""; + | ++++ ++ + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:7:14 + | +LL | const B: S = S { s: &() }; + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | const B<'a>: S<'a> = S { s: &() }; + | ++++ ++++ + +error[E0106]: missing lifetime specifier + --> $DIR/missing-lifetime-in-assoc-const-type.rs:8:15 + | +LL | const C: &'_ str = ""; + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | const C<'a>: &'a str = ""; + | ++++ ~~ + +error[E0106]: missing lifetime specifiers + --> $DIR/missing-lifetime-in-assoc-const-type.rs:9:14 + | +LL | const D: T = T { a: &(), b: &() }; + | ^ expected 2 lifetime parameters + | +help: consider introducing a named lifetime parameter + | +LL | const D<'a>: T<'a, 'a> = T { a: &(), b: &() }; + | ++++ ++++++++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs index 38332627f4c8..2a8b4c3c0447 100644 --- a/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs +++ b/tests/ui/suggestions/missing-lifetime-in-assoc-const-type.rs @@ -1,3 +1,7 @@ +// revisions: default generic_const_items + +#![cfg_attr(generic_const_items, feature(generic_const_items), allow(incomplete_features))] + trait ZstAssert: Sized { const A: &str = ""; //~ ERROR missing lifetime specifier const B: S = S { s: &() }; //~ ERROR missing lifetime specifier From 203d4006688521b0e4e193a18b37d8fae7758d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Mon, 10 Jul 2023 03:10:24 +0200 Subject: [PATCH 139/150] Add rustdoc tests for generic const items --- tests/rustdoc/generic-const-items.rs | 38 +++++++++++++++++++ .../auxiliary/generic-const-items.rs | 22 +++++++++++ .../inline_cross/generic-const-items.rs | 26 +++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/rustdoc/generic-const-items.rs create mode 100644 tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs create mode 100644 tests/rustdoc/inline_cross/generic-const-items.rs diff --git a/tests/rustdoc/generic-const-items.rs b/tests/rustdoc/generic-const-items.rs new file mode 100644 index 000000000000..e2c6a027afa0 --- /dev/null +++ b/tests/rustdoc/generic-const-items.rs @@ -0,0 +1,38 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +// @has 'generic_const_items/constant.K.html' +// @has - '//*[@class="rust item-decl"]//code' \ +// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ +// where \ +// String: From;" +pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None +where + String: From; + +// @has generic_const_items/trait.Trait.html +pub trait Trait { + // @has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a T \ + // where \ + // T: 'a + Eq" + const C<'a>: &'a T + where + T: 'a + Eq; +} + +pub struct Implementor; + +// @has generic_const_items/struct.Implementor.html +// @has - '//h3[@class="code-header"]' 'impl Trait for Implementor' +impl Trait for Implementor { + // @has - '//*[@id="associatedconstant.C"]' \ + // "const C<'a>: &'a str = \"C\" \ + // where \ + // str: 'a" + const C<'a>: &'a str = "C" + // In real code we could've left off this bound but adding it explicitly allows us to test if + // we render where-clauses on associated consts inside impl blocks correctly. + where + str: 'a; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs b/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs new file mode 100644 index 000000000000..0fc7a7aaea2e --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/generic-const-items.rs @@ -0,0 +1,22 @@ +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None +where + String: From; + +pub trait Trait { + const C<'a>: &'a T + where + T: 'a + Eq; +} + +pub struct Implementor; + +impl Trait for Implementor { + const C<'a>: &'a str = "C" + // In real code we could've left off this bound but adding it explicitly allows us to test if + // we render where-clauses on associated consts inside impl blocks correctly. + where + str: 'a; +} diff --git a/tests/rustdoc/inline_cross/generic-const-items.rs b/tests/rustdoc/inline_cross/generic-const-items.rs new file mode 100644 index 000000000000..70cf7af888ee --- /dev/null +++ b/tests/rustdoc/inline_cross/generic-const-items.rs @@ -0,0 +1,26 @@ +#![crate_name = "user"] + +// aux-crate:generic_const_items=generic-const-items.rs +// edition:2021 + +// @has 'user/constant.K.html' +// @has - '//*[@class="rust item-decl"]//code' \ +// "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ +// where \ +// String: From;" +pub use generic_const_items::K; + +// @has user/trait.Trait.html +// @has - '//*[@id="associatedconstant.C"]' \ +// "const C<'a>: &'a T \ +// where \ +// T: 'a + Eq" +pub use generic_const_items::Trait; + +// @has user/struct.Implementor.html +// @has - '//h3[@class="code-header"]' 'impl Trait for Implementor' +// @has - '//*[@id="associatedconstant.C"]' \ +// "const C<'a>: &'a str = \"C\" \ +// where \ +// str: 'a" +pub use generic_const_items::Implementor; From 349a2372ed2ad8989a663f05c7efd23e879bfbb9 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 14 Jul 2023 18:37:12 +0000 Subject: [PATCH 140/150] Take RPITITs inherit the assumed_wf_types of their parent fn --- .../rustc_hir_analysis/src/check/wfcheck.rs | 99 +++---------------- compiler/rustc_ty_utils/src/implied_bounds.rs | 37 +++++++ compiler/rustc_ty_utils/src/lib.rs | 1 + .../in-trait/async-generics-and-bounds.stderr | 8 +- .../in-trait/async-generics.stderr | 8 +- tests/ui/impl-trait/in-trait/wf-bounds.stderr | 4 - 6 files changed, 57 insertions(+), 100 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 0e99df4f5813..4df572f61998 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -284,6 +284,17 @@ fn check_trait_item(tcx: TyCtxt<'_>, trait_item: &hir::TraitItem<'_>) { }; check_object_unsafe_self_trait_by_name(tcx, trait_item); check_associated_item(tcx, def_id, span, method_sig); + + if matches!(trait_item.kind, hir::TraitItemKind::Fn(..)) { + for &assoc_ty_def_id in tcx.associated_types_for_impl_traits_in_associated_fn(def_id) { + check_associated_item( + tcx, + assoc_ty_def_id.expect_local(), + tcx.def_span(assoc_ty_def_id), + None, + ); + } + } } /// Require that the user writes where clauses on GATs for the implicit @@ -1466,13 +1477,6 @@ fn check_fn_or_method<'tcx>( check_where_clauses(wfcx, span, def_id); - check_return_position_impl_trait_in_trait_bounds( - wfcx, - def_id, - sig.output(), - hir_decl.output.span(), - ); - if sig.abi == Abi::RustCall { let span = tcx.def_span(def_id); let has_implicit_self = hir_decl.implicit_self != hir::ImplicitSelfKind::None; @@ -1507,87 +1511,6 @@ fn check_fn_or_method<'tcx>( } } -/// Basically `check_associated_type_bounds`, but separated for now and should be -/// deduplicated when RPITITs get lowered into real associated items. -#[tracing::instrument(level = "trace", skip(wfcx))] -fn check_return_position_impl_trait_in_trait_bounds<'tcx>( - wfcx: &WfCheckingCtxt<'_, 'tcx>, - fn_def_id: LocalDefId, - fn_output: Ty<'tcx>, - span: Span, -) { - let tcx = wfcx.tcx(); - let Some(assoc_item) = tcx.opt_associated_item(fn_def_id.to_def_id()) else { - return; - }; - if assoc_item.container != ty::AssocItemContainer::TraitContainer { - return; - } - fn_output.visit_with(&mut ImplTraitInTraitFinder { - wfcx, - fn_def_id, - depth: ty::INNERMOST, - seen: FxHashSet::default(), - }); -} - -// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): Even with the new lowering -// strategy, we can't just call `check_associated_item` on the new RPITITs, -// because tests like `tests/ui/async-await/in-trait/implied-bounds.rs` will fail. -// That's because we need to check that the bounds of the RPITIT hold using -// the special args that we create during opaque type lowering, otherwise we're -// getting a bunch of early bound and free regions mixed up... Haven't looked too -// deep into this, though. -struct ImplTraitInTraitFinder<'a, 'tcx> { - wfcx: &'a WfCheckingCtxt<'a, 'tcx>, - fn_def_id: LocalDefId, - depth: ty::DebruijnIndex, - seen: FxHashSet, -} -impl<'tcx> TypeVisitor> for ImplTraitInTraitFinder<'_, 'tcx> { - type BreakTy = !; - - fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { - let tcx = self.wfcx.tcx(); - if let ty::Alias(ty::Opaque, unshifted_opaque_ty) = *ty.kind() - && self.seen.insert(unshifted_opaque_ty.def_id) - && let Some(opaque_def_id) = unshifted_opaque_ty.def_id.as_local() - && let origin = tcx.opaque_type_origin(opaque_def_id) - && let hir::OpaqueTyOrigin::FnReturn(source) | hir::OpaqueTyOrigin::AsyncFn(source) = origin - && source == self.fn_def_id - { - let opaque_ty = tcx.fold_regions(unshifted_opaque_ty, |re, _depth| { - match re.kind() { - ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReError(_) | ty::ReStatic => re, - r => bug!("unexpected region: {r:?}"), - } - }); - for (bound, bound_span) in tcx - .explicit_item_bounds(opaque_ty.def_id) - .iter_instantiated_copied(tcx, opaque_ty.args) - { - let bound = self.wfcx.normalize(bound_span, None, bound); - self.wfcx.register_obligations(traits::wf::predicate_obligations( - self.wfcx.infcx, - self.wfcx.param_env, - self.wfcx.body_def_id, - bound.as_predicate(), - bound_span, - )); - // Set the debruijn index back to innermost here, since we already eagerly - // shifted the args that we use to generate these bounds. This is unfortunately - // subtly different behavior than the `ImplTraitInTraitFinder` we use in `param_env`, - // but that function doesn't actually need to normalize the bound it's visiting - // (whereas we have to do so here)... - let old_depth = std::mem::replace(&mut self.depth, ty::INNERMOST); - bound.visit_with(self); - self.depth = old_depth; - } - } - ty.super_visit_with(self) - } -} - const HELP_FOR_SELF_TYPE: &str = "consider changing to `self`, `&self`, `&mut self`, `self: Box`, \ `self: Rc`, `self: Arc`, or `self: Pin

` (where P is one \ of the previous types except `Self`)"; diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index fa1976510cf2..2c1687f10cc4 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -1,6 +1,8 @@ +use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; +use rustc_middle::middle::resolve_bound_vars as rbv; use rustc_middle::query::Providers; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::Span; @@ -42,6 +44,41 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' let mut impl_spans = impl_spans(tcx, def_id); tcx.arena.alloc_from_iter(tys.into_iter().map(|ty| (ty, impl_spans.next().unwrap()))) } + DefKind::AssocTy if let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id }) = tcx.opt_rpitit_info(def_id.to_def_id()) => { + let hir::OpaqueTy { lifetime_mapping, .. } = + *tcx.hir().expect_item(opaque_def_id.expect_local()).expect_opaque_ty(); + let mut mapping = FxHashMap::default(); + let generics = tcx.generics_of(def_id); + for &(lifetime, new_early_bound_def_id) in lifetime_mapping { + if let Some(rbv::ResolvedArg::LateBound(_, _, def_id)) = + tcx.named_bound_var(lifetime.hir_id) + { + let name = tcx.hir().name(lifetime.hir_id); + let index = generics + .param_def_id_to_index(tcx, new_early_bound_def_id.to_def_id()) + .unwrap(); + mapping.insert( + ty::Region::new_free( + tcx, + fn_def_id, + ty::BoundRegionKind::BrNamed(def_id, name), + ), + ty::Region::new_early_bound( + tcx, + ty::EarlyBoundRegion { + def_id: new_early_bound_def_id.to_def_id(), + index, + name, + }, + ), + ); + } + } + let a = tcx.fold_regions(tcx.assumed_wf_types(fn_def_id.expect_local()).to_vec(), |re, _| { + if let Some(re) = mapping.get(&re) { *re } else { re } + }); + tcx.arena.alloc_from_iter(a) + } DefKind::AssocConst | DefKind::AssocTy => tcx.assumed_wf_types(tcx.local_parent(def_id)), DefKind::OpaqueTy => match tcx.def_kind(tcx.local_parent(def_id)) { DefKind::TyAlias => ty::List::empty(), diff --git a/compiler/rustc_ty_utils/src/lib.rs b/compiler/rustc_ty_utils/src/lib.rs index 55b8857ed391..147b600f7ba5 100644 --- a/compiler/rustc_ty_utils/src/lib.rs +++ b/compiler/rustc_ty_utils/src/lib.rs @@ -8,6 +8,7 @@ #![feature(assert_matches)] #![feature(iterator_try_collect)] #![feature(let_chains)] +#![feature(if_let_guard)] #![feature(never_type)] #![feature(box_patterns)] #![recursion_limit = "256"] diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr index f1f0d7e5907d..5c8d64fc6cb4 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr @@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | -note: the parameter type `U` must be valid for the anonymous lifetime defined here... +note: the parameter type `U` must be valid for the anonymous lifetime as defined here... --> $DIR/async-generics-and-bounds.rs:12:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^ + | ^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics-and-bounds.rs:12:28 | @@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... +note: the parameter type `T` must be valid for the anonymous lifetime as defined here... --> $DIR/async-generics-and-bounds.rs:12:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^ + | ^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics-and-bounds.rs:12:28 | diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.stderr index 2f05564564cd..6ae73d9e3a60 100644 --- a/tests/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.stderr @@ -4,11 +4,11 @@ error[E0311]: the parameter type `U` may not live long enough LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | -note: the parameter type `U` must be valid for the anonymous lifetime defined here... +note: the parameter type `U` must be valid for the anonymous lifetime as defined here... --> $DIR/async-generics.rs:9:18 | LL | async fn foo(&self) -> &(T, U); - | ^^^^^ + | ^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics.rs:9:28 | @@ -21,11 +21,11 @@ error[E0311]: the parameter type `T` may not live long enough LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... +note: the parameter type `T` must be valid for the anonymous lifetime as defined here... --> $DIR/async-generics.rs:9:18 | LL | async fn foo(&self) -> &(T, U); - | ^^^^^ + | ^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at --> $DIR/async-generics.rs:9:28 | diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.stderr index beac6620911b..4d60b1330484 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.stderr @@ -47,10 +47,6 @@ note: required by a bound in `NeedsDisplay` | LL | struct NeedsDisplay(T); | ^^^^^^^ required by this bound in `NeedsDisplay` -help: consider restricting type parameter `T` - | -LL | fn nya4() -> impl Wf>; - | +++++++++++++++++++ error: aborting due to 4 previous errors From 50d21091ee39319b4819b2c7e8ea6e8e78c75fb9 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 17 Jul 2023 18:12:49 +0000 Subject: [PATCH 141/150] Implement assumed_wf_types for RPITITs' implementations --- .../src/rmeta/decoder/cstore_impl.rs | 1 + compiler/rustc_metadata/src/rmeta/encoder.rs | 6 ++ compiler/rustc_metadata/src/rmeta/mod.rs | 1 + compiler/rustc_middle/src/query/mod.rs | 7 ++ compiler/rustc_ty_utils/src/implied_bounds.rs | 91 ++++++++++++------- .../in-trait/assumed-wf-bounds-in-impl.rs | 29 ++++++ 6 files changed, 102 insertions(+), 33 deletions(-) create mode 100644 tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index a8815ee0908d..7dbfe0e0cb04 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -246,6 +246,7 @@ provide! { tcx, def_id, other, cdata, debug_assert_eq!(tcx.def_kind(def_id), DefKind::OpaqueTy); cdata.root.tables.is_type_alias_impl_trait.get(cdata, def_id.index) } + assumed_wf_types_for_rpitit => { table } collect_return_position_impl_trait_in_trait_tys => { Ok(cdata .root diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 8f065dd6b580..0025dc9033c5 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1560,6 +1560,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } if let Some(rpitit_info) = item.opt_rpitit_info { record!(self.tables.opt_rpitit_info[def_id] <- rpitit_info); + if matches!(rpitit_info, ty::ImplTraitInTraitData::Trait { .. }) { + record_array!( + self.tables.assumed_wf_types_for_rpitit[def_id] + <- self.tcx.assumed_wf_types_for_rpitit(def_id) + ); + } } } diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 0bc16fc64ff7..09e21fd44556 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -457,6 +457,7 @@ define_tables! { trait_impl_trait_tys: Table>>>>, doc_link_resolutions: Table>, doc_link_traits_in_scope: Table>, + assumed_wf_types_for_rpitit: Table, Span)>>, } #[derive(TyEncodable, TyDecodable)] diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index fb7965873529..0cdb77147296 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -885,6 +885,13 @@ rustc_queries! { desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) } } + /// We need to store the assumed_wf_types for an RPITIT so that impls of foreign + /// traits with return-position impl trait in traits can inherit the right wf types. + query assumed_wf_types_for_rpitit(key: DefId) -> &'tcx [(Ty<'tcx>, Span)] { + desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) } + separate_provide_extern + } + /// Computes the signature of the function. query fn_sig(key: DefId) -> ty::EarlyBinder> { desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) } diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index 2c1687f10cc4..815550a49e1a 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -9,7 +9,11 @@ use rustc_span::Span; use std::iter; pub fn provide(providers: &mut Providers) { - *providers = Providers { assumed_wf_types, ..*providers }; + *providers = Providers { + assumed_wf_types, + assumed_wf_types_for_rpitit: |tcx, def_id| tcx.assumed_wf_types(def_id), + ..*providers + }; } fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'tcx>, Span)] { @@ -44,41 +48,62 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' let mut impl_spans = impl_spans(tcx, def_id); tcx.arena.alloc_from_iter(tys.into_iter().map(|ty| (ty, impl_spans.next().unwrap()))) } - DefKind::AssocTy if let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id }) = tcx.opt_rpitit_info(def_id.to_def_id()) => { - let hir::OpaqueTy { lifetime_mapping, .. } = - *tcx.hir().expect_item(opaque_def_id.expect_local()).expect_opaque_ty(); - let mut mapping = FxHashMap::default(); - let generics = tcx.generics_of(def_id); - for &(lifetime, new_early_bound_def_id) in lifetime_mapping { - if let Some(rbv::ResolvedArg::LateBound(_, _, def_id)) = - tcx.named_bound_var(lifetime.hir_id) + DefKind::AssocTy if let Some(data) = tcx.opt_rpitit_info(def_id.to_def_id()) => match data { + ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id } => { + let hir::OpaqueTy { lifetime_mapping, .. } = + *tcx.hir().expect_item(opaque_def_id.expect_local()).expect_opaque_ty(); + let mut mapping = FxHashMap::default(); + let generics = tcx.generics_of(def_id); + for &(lifetime, new_early_bound_def_id) in + lifetime_mapping.expect("expected lifetime mapping for RPITIT") { - let name = tcx.hir().name(lifetime.hir_id); - let index = generics - .param_def_id_to_index(tcx, new_early_bound_def_id.to_def_id()) - .unwrap(); - mapping.insert( - ty::Region::new_free( - tcx, - fn_def_id, - ty::BoundRegionKind::BrNamed(def_id, name), - ), - ty::Region::new_early_bound( - tcx, - ty::EarlyBoundRegion { - def_id: new_early_bound_def_id.to_def_id(), - index, - name, - }, - ), - ); + if let Some(rbv::ResolvedArg::LateBound(_, _, def_id)) = + tcx.named_bound_var(lifetime.hir_id) + { + let name = tcx.hir().name(lifetime.hir_id); + let index = generics + .param_def_id_to_index(tcx, new_early_bound_def_id.to_def_id()) + .unwrap(); + mapping.insert( + ty::Region::new_free( + tcx, + fn_def_id, + ty::BoundRegionKind::BrNamed(def_id, name), + ), + ty::Region::new_early_bound( + tcx, + ty::EarlyBoundRegion { + def_id: new_early_bound_def_id.to_def_id(), + index, + name, + }, + ), + ); + } } + let a = tcx.fold_regions( + tcx.assumed_wf_types(fn_def_id.expect_local()).to_vec(), + |re, _| { + if let Some(re) = mapping.get(&re) { *re } else { re } + }, + ); + tcx.arena.alloc_from_iter(a) } - let a = tcx.fold_regions(tcx.assumed_wf_types(fn_def_id.expect_local()).to_vec(), |re, _| { - if let Some(re) = mapping.get(&re) { *re } else { re } - }); - tcx.arena.alloc_from_iter(a) - } + ty::ImplTraitInTraitData::Impl { .. } => { + let impl_def_id = tcx.local_parent(def_id); + let rpitit_def_id = tcx.associated_item(def_id).trait_item_def_id.unwrap(); + let args = ty::GenericArgs::identity_for_item(tcx, def_id).rebase_onto( + tcx, + impl_def_id.to_def_id(), + tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity().args, + ); + tcx.arena.alloc_from_iter( + ty::EarlyBinder::bind(tcx.assumed_wf_types_for_rpitit(rpitit_def_id)) + .iter_instantiated_copied(tcx, args) + .chain(tcx.assumed_wf_types(impl_def_id).into_iter().copied()), + ) + } + }, DefKind::AssocConst | DefKind::AssocTy => tcx.assumed_wf_types(tcx.local_parent(def_id)), DefKind::OpaqueTy => match tcx.def_kind(tcx.local_parent(def_id)) { DefKind::TyAlias => ty::List::empty(), diff --git a/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs new file mode 100644 index 000000000000..2a61c5cc8dff --- /dev/null +++ b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs @@ -0,0 +1,29 @@ +// check-pass +// edition: 2021 +// issue: 113796 + +#![feature(async_fn_in_trait)] + +trait AsyncLendingIterator { + type Item<'a> + where + Self: 'a; + + async fn next(&mut self) -> Option>; +} + +struct Lend(I); +impl AsyncLendingIterator for Lend { + type Item<'a> = &'a I + where + Self: 'a; + + // Checking that the synthetic `::next()` GAT + // is well-formed requires being able to assume the WF types of `next`. + + async fn next(&mut self) -> Option> { + todo!() + } +} + +fn main() {} From 744e7709396cba216400b5d5d78d25aa0663399b Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 27 Jul 2023 18:23:42 +0000 Subject: [PATCH 142/150] some nits, bless test --- compiler/rustc_ty_utils/src/implied_bounds.rs | 32 ++++++++++++++++--- .../in-trait/bad-item-bound-within-rpitit.rs | 1 - .../bad-item-bound-within-rpitit.stderr | 17 ++-------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index 815550a49e1a..7eb1042d2f8b 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -11,7 +11,10 @@ use std::iter; pub fn provide(providers: &mut Providers) { *providers = Providers { assumed_wf_types, - assumed_wf_types_for_rpitit: |tcx, def_id| tcx.assumed_wf_types(def_id), + assumed_wf_types_for_rpitit: |tcx, def_id| { + assert!(tcx.is_impl_trait_in_trait(def_id.to_def_id())); + tcx.assumed_wf_types(def_id) + }, ..*providers }; } @@ -52,6 +55,15 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id } => { let hir::OpaqueTy { lifetime_mapping, .. } = *tcx.hir().expect_item(opaque_def_id.expect_local()).expect_opaque_ty(); + // We need to remap all of the late-bound lifetimes in theassumed wf types + // of the fn (which are represented as ReFree) to the early-bound lifetimes + // of the RPITIT (which are represented by ReEarlyBound owned by the opaque). + // Luckily, this is very easy to do because we already have that mapping + // stored in the HIR of this RPITIT. + // + // Side-note: We don't really need to do this remapping for early-bound + // lifetimes because they're already "linked" by the bidirectional outlives + // predicates we insert in the `explicit_predicates_of` query for RPITITs. let mut mapping = FxHashMap::default(); let generics = tcx.generics_of(def_id); for &(lifetime, new_early_bound_def_id) in @@ -81,14 +93,24 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' ); } } - let a = tcx.fold_regions( + // FIXME: This could use a real folder, I guess. + let remapped_wf_tys = tcx.fold_regions( tcx.assumed_wf_types(fn_def_id.expect_local()).to_vec(), - |re, _| { - if let Some(re) = mapping.get(&re) { *re } else { re } + |region, _| { + // If `region` is a `ReFree` that is captured by the + // opaque, remap it to its corresponding the early- + // bound region. + if let Some(remapped_region) = mapping.get(®ion) { + *remapped_region + } else { + region + } }, ); - tcx.arena.alloc_from_iter(a) + tcx.arena.alloc_from_iter(remapped_wf_tys) } + // Assumed wf types for RPITITs in an impl just inherit (and instantiate) + // the assumed wf types of the trait's RPITIT GAT. ty::ImplTraitInTraitData::Impl { .. } => { let impl_def_id = tcx.local_parent(def_id); let rpitit_def_id = tcx.associated_item(def_id).trait_item_def_id.unwrap(); diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs index 8b97336fe0c6..ff7ad4bf3894 100644 --- a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs @@ -17,7 +17,6 @@ impl<'a, I: 'a + Iterable> Iterable for &'a I { //~^ ERROR impl has stricter requirements than trait fn iter(&self) -> impl 'a + Iterator> { - //~^ ERROR the type `&'a I` does not fulfill the required lifetime (*self).iter() } } diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr index 54a08c5b516c..106b8a7c8047 100644 --- a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr +++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr @@ -12,19 +12,6 @@ help: copy the `where` clause predicates from the trait LL | where Self: 'b; | ~~~~~~~~~~~~~~ -error[E0477]: the type `&'a I` does not fulfill the required lifetime - --> $DIR/bad-item-bound-within-rpitit.rs:19:23 - | -LL | fn iter(&self) -> impl 'a + Iterator> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: type must outlive the anonymous lifetime as defined here - --> $DIR/bad-item-bound-within-rpitit.rs:10:28 - | -LL | fn iter(&self) -> impl '_ + Iterator>; - | ^^ +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0276, E0477. -For more information about an error, try `rustc --explain E0276`. +For more information about this error, try `rustc --explain E0276`. From 8ddc72eca4bbb6412639cd52db5d51b9840f3011 Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Sun, 30 Jul 2023 05:36:38 +0000 Subject: [PATCH 143/150] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 1d5dd4d3f635..dde8d8676551 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -d150dbb067e66f351a0b33a54e7d4b464ef51e47 +fb53384c94b87adebceb6048865c9fe305e71b92 From 049c728c60f7c950b7185f0f277609694a8e2a16 Mon Sep 17 00:00:00 2001 From: Mu001999 Date: Tue, 1 Aug 2023 23:30:40 +0800 Subject: [PATCH 144/150] Suggests turbofish in patterns --- compiler/rustc_parse/messages.ftl | 2 ++ compiler/rustc_parse/src/errors.rs | 14 ++++++++ compiler/rustc_parse/src/parser/pat.rs | 1 + compiler/rustc_parse/src/parser/path.rs | 10 +++++- tests/ui/did_you_mean/issue-114112.rs | 11 +++++++ tests/ui/did_you_mean/issue-114112.stderr | 13 ++++++++ tests/ui/parser/issues/issue-22647.rs | 2 +- tests/ui/parser/issues/issue-22647.stderr | 9 ++++-- tests/ui/parser/issues/issue-22712.rs | 2 +- tests/ui/parser/issues/issue-22712.stderr | 9 ++++-- tests/ui/parser/pat-lt-bracket-3.rs | 3 +- tests/ui/parser/pat-lt-bracket-3.stderr | 9 ++++-- tests/ui/parser/pat-lt-bracket-4.rs | 2 +- tests/ui/parser/pat-lt-bracket-4.stderr | 9 ++++-- tests/ui/span/issue-34264.rs | 2 +- tests/ui/span/issue-34264.stderr | 15 +++------ tests/ui/suggestions/issue-64252-self-type.rs | 6 ++-- .../suggestions/issue-64252-self-type.stderr | 32 +++++++------------ 18 files changed, 101 insertions(+), 50 deletions(-) create mode 100644 tests/ui/did_you_mean/issue-114112.rs create mode 100644 tests/ui/did_you_mean/issue-114112.stderr diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 83d96ad8e766..6a9a5a239e48 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -270,6 +270,8 @@ parse_found_expr_would_be_stmt = expected expression, found `{$token}` parse_function_body_equals_expr = function body cannot be `= expression;` .suggestion = surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;` +parse_generic_args_in_pat_require_turbofish_syntax = generic args in patterns require the turbofish syntax + parse_generic_parameters_without_angle_brackets = generic parameters without surrounding angle brackets .suggestion = surround the type parameters with angle brackets diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 06c099607273..3184ca777cef 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -2731,3 +2731,17 @@ pub(crate) struct WhereClauseBeforeConstBodySugg { #[suggestion_part(code = "")] pub right: Span, } + +#[derive(Diagnostic)] +#[diag(parse_generic_args_in_pat_require_turbofish_syntax)] +pub(crate) struct GenericArgsInPatRequireTurbofishSyntax { + #[primary_span] + pub span: Span, + #[suggestion( + parse_sugg_turbofish_syntax, + style = "verbose", + code = "::", + applicability = "maybe-incorrect" + )] + pub suggest_turbofish: Span, +} diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 14891c45d81a..e0539c4ac04d 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -805,6 +805,7 @@ impl<'a> Parser<'a> { | token::DotDotDot | token::DotDotEq | token::DotDot // A range pattern. | token::ModSep // A tuple / struct variant pattern. | token::Not)) // A macro expanding to a pattern. + && !(self.look_ahead(1, |t| t.kind == token::Lt) && self.look_ahead(2, |t| t.can_begin_type())) // May suggest the turbofish syntax for generics, only valid for recoveries. } /// Parses `ident` or `ident @ pat`. diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index feb7e829caf6..4fe8a5aa6260 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -1,6 +1,6 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; -use crate::errors::PathSingleColon; +use crate::errors::{GenericArgsInPatRequireTurbofishSyntax, PathSingleColon}; use crate::{errors, maybe_whole}; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; @@ -382,6 +382,14 @@ impl<'a> Parser<'a> { }; PathSegment { ident, args: Some(args), id: ast::DUMMY_NODE_ID } + } else if style == PathStyle::Pat + && self.check_noexpect(&token::Lt) + && self.look_ahead(1, |t| t.can_begin_type()) + { + return Err(self.sess.create_err(GenericArgsInPatRequireTurbofishSyntax { + span: self.token.span, + suggest_turbofish: self.token.span.shrink_to_lo(), + })); } else { // Generic arguments are not found. PathSegment::from_ident(ident) diff --git a/tests/ui/did_you_mean/issue-114112.rs b/tests/ui/did_you_mean/issue-114112.rs new file mode 100644 index 000000000000..0fde12ecd788 --- /dev/null +++ b/tests/ui/did_you_mean/issue-114112.rs @@ -0,0 +1,11 @@ +enum E { + A(T) +} + +fn main() { + match E::::A(1) { + E::A(v) => { //~ ERROR generic args in patterns require the turbofish syntax + println!("{v:?}"); + }, + } +} diff --git a/tests/ui/did_you_mean/issue-114112.stderr b/tests/ui/did_you_mean/issue-114112.stderr new file mode 100644 index 000000000000..d76b5f72e30c --- /dev/null +++ b/tests/ui/did_you_mean/issue-114112.stderr @@ -0,0 +1,13 @@ +error: generic args in patterns require the turbofish syntax + --> $DIR/issue-114112.rs:7:10 + | +LL | E::A(v) => { + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | E::::A(v) => { + | ++ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-22647.rs b/tests/ui/parser/issues/issue-22647.rs index a6861410682c..163cbc69ddd6 100644 --- a/tests/ui/parser/issues/issue-22647.rs +++ b/tests/ui/parser/issues/issue-22647.rs @@ -1,5 +1,5 @@ fn main() { - let caller = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<` + let caller = |f: F| //~ ERROR generic args in patterns require the turbofish syntax where F: Fn() -> i32 { let x = f(); diff --git a/tests/ui/parser/issues/issue-22647.stderr b/tests/ui/parser/issues/issue-22647.stderr index 89b454d1973d..585e70266619 100644 --- a/tests/ui/parser/issues/issue-22647.stderr +++ b/tests/ui/parser/issues/issue-22647.stderr @@ -1,8 +1,13 @@ -error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/issue-22647.rs:2:15 | LL | let caller = |f: F| - | ^ expected one of `:`, `;`, `=`, `@`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | let caller:: = |f: F| + | ++ error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-22712.rs b/tests/ui/parser/issues/issue-22712.rs index 774de9c7e644..92b12b8e1934 100644 --- a/tests/ui/parser/issues/issue-22712.rs +++ b/tests/ui/parser/issues/issue-22712.rs @@ -3,7 +3,7 @@ struct Foo { } fn bar() { - let Foo> //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<` + let Foo> //~ ERROR generic args in patterns require the turbofish syntax } fn main() {} diff --git a/tests/ui/parser/issues/issue-22712.stderr b/tests/ui/parser/issues/issue-22712.stderr index 30fabac65640..7f9d99d8edfa 100644 --- a/tests/ui/parser/issues/issue-22712.stderr +++ b/tests/ui/parser/issues/issue-22712.stderr @@ -1,8 +1,13 @@ -error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/issue-22712.rs:6:12 | LL | let Foo> - | ^ expected one of `:`, `;`, `=`, `@`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | let Foo::> + | ++ error: aborting due to previous error diff --git a/tests/ui/parser/pat-lt-bracket-3.rs b/tests/ui/parser/pat-lt-bracket-3.rs index a8bdfd3fa181..bd83fe8db4b5 100644 --- a/tests/ui/parser/pat-lt-bracket-3.rs +++ b/tests/ui/parser/pat-lt-bracket-3.rs @@ -3,8 +3,7 @@ struct Foo(T, T); impl Foo { fn foo(&self) { match *self { - Foo(x, y) => { - //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + Foo(x, y) => { //~ ERROR generic args in patterns require the turbofish syntax println!("Goodbye, World!") } } diff --git a/tests/ui/parser/pat-lt-bracket-3.stderr b/tests/ui/parser/pat-lt-bracket-3.stderr index bacf868e3c4e..afdf1e9a5576 100644 --- a/tests/ui/parser/pat-lt-bracket-3.stderr +++ b/tests/ui/parser/pat-lt-bracket-3.stderr @@ -1,8 +1,13 @@ -error: expected one of `=>`, `@`, `if`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/pat-lt-bracket-3.rs:6:16 | LL | Foo(x, y) => { - | ^ expected one of `=>`, `@`, `if`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | Foo::(x, y) => { + | ++ error: aborting due to previous error diff --git a/tests/ui/parser/pat-lt-bracket-4.rs b/tests/ui/parser/pat-lt-bracket-4.rs index de314f6c6412..6d348b68cd66 100644 --- a/tests/ui/parser/pat-lt-bracket-4.rs +++ b/tests/ui/parser/pat-lt-bracket-4.rs @@ -5,7 +5,7 @@ enum BtNode { fn main() { let y = match 10 { - Foo::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + Foo::A(value) => value, //~ ERROR generic args in patterns require the turbofish syntax Foo::B => 7, }; } diff --git a/tests/ui/parser/pat-lt-bracket-4.stderr b/tests/ui/parser/pat-lt-bracket-4.stderr index 911c276b9319..b71a5ad939e5 100644 --- a/tests/ui/parser/pat-lt-bracket-4.stderr +++ b/tests/ui/parser/pat-lt-bracket-4.stderr @@ -1,8 +1,13 @@ -error: expected one of `=>`, `@`, `if`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/pat-lt-bracket-4.rs:8:12 | LL | Foo::A(value) => value, - | ^ expected one of `=>`, `@`, `if`, or `|` + | ^ + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | Foo::::A(value) => value, + | ++ error: aborting due to previous error diff --git a/tests/ui/span/issue-34264.rs b/tests/ui/span/issue-34264.rs index 9227ee482dfa..c7a8440f2840 100644 --- a/tests/ui/span/issue-34264.rs +++ b/tests/ui/span/issue-34264.rs @@ -1,5 +1,5 @@ fn foo(Option, String) {} //~ ERROR expected one of -//~^ ERROR expected one of +//~^ ERROR generic args in patterns require the turbofish syntax fn bar(x, y: usize) {} //~ ERROR expected one of fn main() { diff --git a/tests/ui/span/issue-34264.stderr b/tests/ui/span/issue-34264.stderr index f0dea66f6128..1874d7f85337 100644 --- a/tests/ui/span/issue-34264.stderr +++ b/tests/ui/span/issue-34264.stderr @@ -1,18 +1,13 @@ -error: expected one of `:`, `@`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/issue-34264.rs:1:14 | LL | fn foo(Option, String) {} - | ^ expected one of `:`, `@`, or `|` + | ^ | - = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: if this is a `self` type, give it a parameter name +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | -LL | fn foo(self: Option, String) {} - | +++++ -help: if this is a type, explicitly ignore the parameter name - | -LL | fn foo(_: Option, String) {} - | ++ +LL | fn foo(Option::, String) {} + | ++ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/issue-34264.rs:1:27 diff --git a/tests/ui/suggestions/issue-64252-self-type.rs b/tests/ui/suggestions/issue-64252-self-type.rs index 128d5e85c22c..ad25d334507f 100644 --- a/tests/ui/suggestions/issue-64252-self-type.rs +++ b/tests/ui/suggestions/issue-64252-self-type.rs @@ -1,14 +1,12 @@ // This test checks that a suggestion to add a `self: ` parameter name is provided // to functions where this is applicable. -pub fn foo(Box) { } -//~^ ERROR expected one of `:`, `@`, or `|`, found `<` +pub fn foo(Box) { } //~ ERROR generic args in patterns require the turbofish syntax struct Bar; impl Bar { - fn bar(Box) { } - //~^ ERROR expected one of `:`, `@`, or `|`, found `<` + fn bar(Box) { } //~ ERROR generic args in patterns require the turbofish syntax } fn main() { } diff --git a/tests/ui/suggestions/issue-64252-self-type.stderr b/tests/ui/suggestions/issue-64252-self-type.stderr index c3418dab0e8a..ba5c2da24150 100644 --- a/tests/ui/suggestions/issue-64252-self-type.stderr +++ b/tests/ui/suggestions/issue-64252-self-type.stderr @@ -1,34 +1,24 @@ -error: expected one of `:`, `@`, or `|`, found `<` +error: generic args in patterns require the turbofish syntax --> $DIR/issue-64252-self-type.rs:4:15 | LL | pub fn foo(Box) { } - | ^ expected one of `:`, `@`, or `|` + | ^ | - = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: if this is a `self` type, give it a parameter name +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | -LL | pub fn foo(self: Box) { } - | +++++ -help: if this is a type, explicitly ignore the parameter name - | -LL | pub fn foo(_: Box) { } - | ++ +LL | pub fn foo(Box::) { } + | ++ -error: expected one of `:`, `@`, or `|`, found `<` - --> $DIR/issue-64252-self-type.rs:10:15 +error: generic args in patterns require the turbofish syntax + --> $DIR/issue-64252-self-type.rs:9:15 | LL | fn bar(Box) { } - | ^ expected one of `:`, `@`, or `|` + | ^ | - = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: if this is a `self` type, give it a parameter name +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | -LL | fn bar(self: Box) { } - | +++++ -help: if this is a type, explicitly ignore the parameter name - | -LL | fn bar(_: Box) { } - | ++ +LL | fn bar(Box::) { } + | ++ error: aborting due to 2 previous errors From 89b2fe7750eb251c2b621bad1f8d86477d7a1f91 Mon Sep 17 00:00:00 2001 From: Mu001999 Date: Thu, 3 Aug 2023 00:00:56 +0800 Subject: [PATCH 145/150] Keep the suggestion for wrong arbitrary self types --- compiler/rustc_parse/src/parser/attr.rs | 4 +- .../rustc_parse/src/parser/diagnostics.rs | 26 +++++++++---- compiler/rustc_parse/src/parser/expr.rs | 10 ++--- compiler/rustc_parse/src/parser/item.rs | 6 +-- compiler/rustc_parse/src/parser/mod.rs | 6 +-- .../rustc_parse/src/parser/nonterminal.rs | 4 +- compiler/rustc_parse/src/parser/pat.rs | 36 ++++++++++------- compiler/rustc_parse/src/parser/path.rs | 39 ++++++++++++------- compiler/rustc_parse/src/parser/stmt.rs | 2 +- compiler/rustc_parse/src/parser/ty.rs | 6 +-- .../anon-params-denied-2018.stderr | 20 +++++++--- tests/ui/span/issue-34264.rs | 2 +- tests/ui/span/issue-34264.stderr | 15 ++++--- tests/ui/suggestions/issue-64252-self-type.rs | 5 +-- .../suggestions/issue-64252-self-type.stderr | 32 +++++++++------ 15 files changed, 133 insertions(+), 80 deletions(-) diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index ee0abba1c175..1271bce799d5 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -260,7 +260,7 @@ impl<'a> Parser<'a> { item } else { let do_parse = |this: &mut Self| { - let path = this.parse_path(PathStyle::Mod)?; + let path = this.parse_path(PathStyle::Mod, None)?; let args = this.parse_attr_args()?; Ok(ast::AttrItem { path, args, tokens: None }) }; @@ -387,7 +387,7 @@ impl<'a> Parser<'a> { } let lo = self.token.span; - let path = self.parse_path(PathStyle::Mod)?; + let path = self.parse_path(PathStyle::Mod, None)?; let kind = self.parse_meta_item_kind()?; let span = lo.to(self.prev_token.span); Ok(ast::MetaItem { path, kind, span }) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 7d04a335c9e0..8bc4433a9653 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1579,7 +1579,7 @@ impl<'a> Parser<'a> { self.expect(&token::ModSep)?; let mut path = ast::Path { segments: ThinVec::new(), span: DUMMY_SP, tokens: None }; - self.parse_path_segments(&mut path.segments, T::PATH_STYLE, None)?; + self.parse_path_segments(&mut path.segments, T::PATH_STYLE, None, None)?; path.span = ty_span.to(self.prev_token.span); let ty_str = self.span_to_snippet(ty_span).unwrap_or_else(|_| pprust::ty_to_string(&ty)); @@ -2019,7 +2019,7 @@ impl<'a> Parser<'a> { { let rfc_note = "anonymous parameters are removed in the 2018 edition (see RFC 1685)"; - let (ident, self_sugg, param_sugg, type_sugg, self_span, param_span, type_span) = + let (ident, self_sugg, param_sugg, type_sugg, self_span, param_span, type_span, maybe_name) = match pat.kind { PatKind::Ident(_, ident, _) => ( ident, @@ -2029,6 +2029,7 @@ impl<'a> Parser<'a> { pat.span.shrink_to_lo(), pat.span.shrink_to_hi(), pat.span.shrink_to_lo(), + true, ), // Also catches `fn foo(&a)`. PatKind::Ref(ref inner_pat, mutab) @@ -2045,11 +2046,22 @@ impl<'a> Parser<'a> { pat.span.shrink_to_lo(), pat.span, pat.span.shrink_to_lo(), + true, ) } _ => unreachable!(), } - } + }, + PatKind::Path(_, ref path) if let Some(segment) = path.segments.last() => ( + segment.ident, + "self: ", + ": TypeName".to_string(), + "_: ", + pat.span.shrink_to_lo(), + pat.span.shrink_to_hi(), + pat.span.shrink_to_lo(), + path.segments.len() == 1, // Avoid suggesting that `fn foo(a::b)` is fixed with a change to `fn foo(a::b: TypeName)`. + ), _ => { // Otherwise, try to get a type and emit a suggestion. if let Some(ty) = pat.to_ty() { @@ -2077,7 +2089,7 @@ impl<'a> Parser<'a> { } // Avoid suggesting that `fn foo(HashMap)` is fixed with a change to // `fn foo(HashMap: TypeName)`. - if self.token != token::Lt { + if self.token != token::Lt && maybe_name { err.span_suggestion( param_span, "if this is a parameter name, give it a type", @@ -2100,7 +2112,7 @@ impl<'a> Parser<'a> { } pub(super) fn recover_arg_parse(&mut self) -> PResult<'a, (P, P)> { - let pat = self.parse_pat_no_top_alt(Some(Expected::ArgumentName))?; + let pat = self.parse_pat_no_top_alt(Some(Expected::ArgumentName), None)?; self.expect(&token::Colon)?; let ty = self.parse_ty()?; @@ -2508,7 +2520,7 @@ impl<'a> Parser<'a> { // Skip the `:`. snapshot_pat.bump(); snapshot_type.bump(); - match snapshot_pat.parse_pat_no_top_alt(expected) { + match snapshot_pat.parse_pat_no_top_alt(expected, None) { Err(inner_err) => { inner_err.cancel(); } @@ -2772,7 +2784,7 @@ impl<'a> Parser<'a> { /// sequence of patterns until `)` is reached. fn skip_pat_list(&mut self) -> PResult<'a, ()> { while !self.check(&token::CloseDelim(Delimiter::Parenthesis)) { - self.parse_pat_no_top_alt(None)?; + self.parse_pat_no_top_alt(None, None)?; if !self.eat(&token::Comma) { return Ok(()); } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index b54cb8c5a0c1..6dafb8b999b2 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -775,7 +775,7 @@ impl<'a> Parser<'a> { _ => {} } - match self.parse_path(PathStyle::Expr) { + match self.parse_path(PathStyle::Expr, None) { Ok(path) => { let span_after_type = parser_snapshot_after_type.token.span; let expr = mk_expr( @@ -1314,7 +1314,7 @@ impl<'a> Parser<'a> { } let fn_span_lo = self.token.span; - let mut seg = self.parse_path_segment(PathStyle::Expr, None)?; + let mut seg = self.parse_path_segment(PathStyle::Expr, None, None)?; self.check_trailing_angle_brackets(&seg, &[&token::OpenDelim(Delimiter::Parenthesis)]); self.check_turbofish_missing_angle_brackets(&mut seg); @@ -1544,7 +1544,7 @@ impl<'a> Parser<'a> { })?; (Some(qself), path) } else { - (None, self.parse_path(PathStyle::Expr)?) + (None, self.parse_path(PathStyle::Expr, None)?) }; // `!`, as an operator, is prefix, so we know this isn't that. @@ -2338,7 +2338,7 @@ impl<'a> Parser<'a> { let lo = self.token.span; let attrs = self.parse_outer_attributes()?; self.collect_tokens_trailing_token(attrs, ForceCollect::No, |this, attrs| { - let pat = this.parse_pat_no_top_alt(Some(Expected::ParameterName))?; + let pat = this.parse_pat_no_top_alt(Some(Expected::ParameterName), None)?; let ty = if this.eat(&token::Colon) { this.parse_ty()? } else { @@ -2781,7 +2781,7 @@ impl<'a> Parser<'a> { return None; } let pre_pat_snapshot = self.create_snapshot_for_diagnostic(); - match self.parse_pat_no_top_alt(None) { + match self.parse_pat_no_top_alt(None, None) { Ok(_pat) => { if self.token.kind == token::FatArrow { // Reached arm end. diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 1301ed3e3882..d3f756139def 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -452,7 +452,7 @@ impl<'a> Parser<'a> { /// Parses an item macro, e.g., `item!();`. fn parse_item_macro(&mut self, vis: &Visibility) -> PResult<'a, MacCall> { - let path = self.parse_path(PathStyle::Mod)?; // `foo::bar` + let path = self.parse_path(PathStyle::Mod, None)?; // `foo::bar` self.expect(&token::Not)?; // `!` match self.parse_delim_args() { // `( .. )` or `[ .. ]` (followed by `;`), or `{ .. }`. @@ -976,7 +976,7 @@ impl<'a> Parser<'a> { self.parse_use_tree_glob_or_nested()? } else { // `use path::*;` or `use path::{...};` or `use path;` or `use path as bar;` - prefix = self.parse_path(PathStyle::Mod)?; + prefix = self.parse_path(PathStyle::Mod, None)?; if self.eat(&token::ModSep) { self.parse_use_tree_glob_or_nested()? @@ -987,7 +987,7 @@ impl<'a> Parser<'a> { .emit_err(errors::SingleColonImportPath { span: self.prev_token.span }); // We parse the rest of the path and append it to the original prefix. - self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None)?; + self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None, None)?; prefix.span = lo.to(self.prev_token.span); } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 37b4c371c94b..2af0caa1bdaf 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1413,7 +1413,7 @@ impl<'a> Parser<'a> { // Parse `pub(in path)`. self.bump(); // `(` self.bump(); // `in` - let path = self.parse_path(PathStyle::Mod)?; // `path` + let path = self.parse_path(PathStyle::Mod, None)?; // `path` self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` let vis = VisibilityKind::Restricted { path: P(path), @@ -1430,7 +1430,7 @@ impl<'a> Parser<'a> { { // Parse `pub(crate)`, `pub(self)`, or `pub(super)`. self.bump(); // `(` - let path = self.parse_path(PathStyle::Mod)?; // `crate`/`super`/`self` + let path = self.parse_path(PathStyle::Mod, None)?; // `crate`/`super`/`self` self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` let vis = VisibilityKind::Restricted { path: P(path), @@ -1456,7 +1456,7 @@ impl<'a> Parser<'a> { /// Recovery for e.g. `pub(something) fn ...` or `struct X { pub(something) y: Z }` fn recover_incorrect_vis_restriction(&mut self) -> PResult<'a, ()> { self.bump(); // `(` - let path = self.parse_path(PathStyle::Mod)?; + let path = self.parse_path(PathStyle::Mod, None)?; self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` let path_str = pprust::path_to_string(&path); diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index adb0d372a40d..a09c1e4d7fde 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -131,7 +131,7 @@ impl<'a> Parser<'a> { }, NonterminalKind::PatParam { .. } | NonterminalKind::PatWithOr { .. } => { token::NtPat(self.collect_tokens_no_attrs(|this| match kind { - NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None), + NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None, None), NonterminalKind::PatWithOr { .. } => this.parse_pat_allow_top_alt( None, RecoverComma::No, @@ -168,7 +168,7 @@ impl<'a> Parser<'a> { }.into_diagnostic(&self.sess.span_diagnostic)); } NonterminalKind::Path => token::NtPath( - P(self.collect_tokens_no_attrs(|this| this.parse_path(PathStyle::Type))?), + P(self.collect_tokens_no_attrs(|this| this.parse_path(PathStyle::Type, None))?), ), NonterminalKind::Meta => token::NtMeta(P(self.parse_attr_item(true)?)), NonterminalKind::Vis => token::NtVis( diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index e0539c4ac04d..615ef28db085 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -80,7 +80,8 @@ enum EatOrResult { } /// The syntax location of a given pattern. Used for diagnostics. -pub(super) enum PatternLocation { +#[derive(Clone, Copy)] +pub enum PatternLocation { LetBinding, FunctionParameter, } @@ -91,8 +92,12 @@ impl<'a> Parser<'a> { /// Corresponds to `pat` in RFC 2535 and does not admit or-patterns /// at the top level. Used when parsing the parameters of lambda expressions, /// functions, function pointers, and `pat` macro fragments. - pub fn parse_pat_no_top_alt(&mut self, expected: Option) -> PResult<'a, P> { - self.parse_pat_with_range_pat(true, expected) + pub fn parse_pat_no_top_alt( + &mut self, + expected: Option, + syntax_loc: Option, + ) -> PResult<'a, P> { + self.parse_pat_with_range_pat(true, expected, syntax_loc) } /// Parses a pattern. @@ -110,7 +115,7 @@ impl<'a> Parser<'a> { ra: RecoverColon, rt: CommaRecoveryMode, ) -> PResult<'a, P> { - self.parse_pat_allow_top_alt_inner(expected, rc, ra, rt).map(|(pat, _)| pat) + self.parse_pat_allow_top_alt_inner(expected, rc, ra, rt, None).map(|(pat, _)| pat) } /// Returns the pattern and a bool indicating whether we recovered from a trailing vert (true = @@ -121,6 +126,7 @@ impl<'a> Parser<'a> { rc: RecoverComma, ra: RecoverColon, rt: CommaRecoveryMode, + syntax_loc: Option, ) -> PResult<'a, (P, bool)> { // Keep track of whether we recovered from a trailing vert so that we can avoid duplicated // suggestions (which bothers rustfix). @@ -133,7 +139,7 @@ impl<'a> Parser<'a> { }; // Parse the first pattern (`p_0`). - let mut first_pat = self.parse_pat_no_top_alt(expected)?; + let mut first_pat = self.parse_pat_no_top_alt(expected, syntax_loc.clone())?; if rc == RecoverComma::Yes { self.maybe_recover_unexpected_comma(first_pat.span, rt)?; } @@ -172,7 +178,7 @@ impl<'a> Parser<'a> { break; } } - let pat = self.parse_pat_no_top_alt(expected).map_err(|mut err| { + let pat = self.parse_pat_no_top_alt(expected, syntax_loc).map_err(|mut err| { err.span_label(lo, WHILE_PARSING_OR_MSG); err })?; @@ -208,6 +214,7 @@ impl<'a> Parser<'a> { rc, RecoverColon::No, CommaRecoveryMode::LikelyTuple, + Some(syntax_loc), )?; let colon = self.eat(&token::Colon); @@ -319,6 +326,7 @@ impl<'a> Parser<'a> { &mut self, allow_range_pat: bool, expected: Option, + syntax_loc: Option, ) -> PResult<'a, P> { maybe_recover_from_interpolated_ty_qpath!(self, true); maybe_whole!(self, NtPat, |x| x); @@ -393,7 +401,7 @@ impl<'a> Parser<'a> { (Some(qself), path) } else { // Parse an unqualified path - (None, self.parse_path(PathStyle::Pat)?) + (None, self.parse_path(PathStyle::Pat, syntax_loc)?) }; let span = lo.to(self.prev_token.span); @@ -485,7 +493,7 @@ impl<'a> Parser<'a> { // At this point we attempt to parse `@ $pat_rhs` and emit an error. self.bump(); // `@` - let mut rhs = self.parse_pat_no_top_alt(None)?; + let mut rhs = self.parse_pat_no_top_alt(None, None)?; let whole_span = lhs.span.to(rhs.span); if let PatKind::Ident(_, _, sub @ None) = &mut rhs.kind { @@ -541,7 +549,7 @@ impl<'a> Parser<'a> { } let mutbl = self.parse_mutability(); - let subpat = self.parse_pat_with_range_pat(false, expected)?; + let subpat = self.parse_pat_with_range_pat(false, expected, None)?; Ok(PatKind::Ref(subpat, mutbl)) } @@ -584,7 +592,7 @@ impl<'a> Parser<'a> { } // Parse the pattern we hope to be an identifier. - let mut pat = self.parse_pat_no_top_alt(Some(Expected::Identifier))?; + let mut pat = self.parse_pat_no_top_alt(Some(Expected::Identifier), None)?; // If we don't have `mut $ident (@ pat)?`, error. if let PatKind::Ident(BindingAnnotation(ByRef::No, m @ Mutability::Not), ..) = &mut pat.kind @@ -776,7 +784,7 @@ impl<'a> Parser<'a> { (Some(qself), path) } else { // Parse an unqualified path - (None, self.parse_path(PathStyle::Pat)?) + (None, self.parse_path(PathStyle::Pat, None)?) }; let hi = self.prev_token.span; Ok(self.mk_expr(lo.to(hi), ExprKind::Path(qself, path))) @@ -814,7 +822,7 @@ impl<'a> Parser<'a> { fn parse_pat_ident(&mut self, binding_annotation: BindingAnnotation) -> PResult<'a, PatKind> { let ident = self.parse_ident()?; let sub = if self.eat(&token::At) { - Some(self.parse_pat_no_top_alt(Some(Expected::BindingPattern))?) + Some(self.parse_pat_no_top_alt(Some(Expected::BindingPattern), None)?) } else { None }; @@ -903,14 +911,14 @@ impl<'a> Parser<'a> { // We cannot use `parse_pat_ident()` since it will complain `box` // is not an identifier. let sub = if self.eat(&token::At) { - Some(self.parse_pat_no_top_alt(Some(Expected::BindingPattern))?) + Some(self.parse_pat_no_top_alt(Some(Expected::BindingPattern), None)?) } else { None }; Ok(PatKind::Ident(BindingAnnotation::NONE, Ident::new(kw::Box, box_span), sub)) } else { - let pat = self.parse_pat_with_range_pat(false, None)?; + let pat = self.parse_pat_with_range_pat(false, None, None)?; self.sess.gated_spans.gate(sym::box_patterns, box_span.to(self.prev_token.span)); Ok(PatKind::Box(pat)) } diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 4fe8a5aa6260..0d5f48e424e2 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -1,3 +1,4 @@ +use super::pat::PatternLocation; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; use crate::errors::{GenericArgsInPatRequireTurbofishSyntax, PathSingleColon}; @@ -79,7 +80,7 @@ impl<'a> Parser<'a> { let (mut path, path_span); if self.eat_keyword(kw::As) { let path_lo = self.token.span; - path = self.parse_path(PathStyle::Type)?; + path = self.parse_path(PathStyle::Type, None)?; path_span = path_lo.to(self.prev_token.span); } else { path_span = self.token.span.to(self.token.span); @@ -98,7 +99,7 @@ impl<'a> Parser<'a> { } let qself = P(QSelf { ty, path_span, position: path.segments.len() }); - self.parse_path_segments(&mut path.segments, style, None)?; + self.parse_path_segments(&mut path.segments, style, None, None)?; Ok(( qself, @@ -139,8 +140,12 @@ impl<'a> Parser<'a> { true } - pub(super) fn parse_path(&mut self, style: PathStyle) -> PResult<'a, Path> { - self.parse_path_inner(style, None) + pub(super) fn parse_path( + &mut self, + style: PathStyle, + syntax_loc: Option, + ) -> PResult<'a, Path> { + self.parse_path_inner(style, None, syntax_loc) } /// Parses simple paths. @@ -157,6 +162,7 @@ impl<'a> Parser<'a> { &mut self, style: PathStyle, ty_generics: Option<&Generics>, + syntax_loc: Option, ) -> PResult<'a, Path> { let reject_generics_if_mod_style = |parser: &Parser<'_>, path: &Path| { // Ensure generic arguments don't end up in attribute paths, such as: @@ -201,7 +207,7 @@ impl<'a> Parser<'a> { if self.eat(&token::ModSep) { segments.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt))); } - self.parse_path_segments(&mut segments, style, ty_generics)?; + self.parse_path_segments(&mut segments, style, ty_generics, syntax_loc)?; Ok(Path { segments, span: lo.to(self.prev_token.span), tokens: None }) } @@ -210,9 +216,10 @@ impl<'a> Parser<'a> { segments: &mut ThinVec, style: PathStyle, ty_generics: Option<&Generics>, + syntax_loc: Option, ) -> PResult<'a, ()> { loop { - let segment = self.parse_path_segment(style, ty_generics)?; + let segment = self.parse_path_segment(style, ty_generics, syntax_loc)?; if style.has_generic_ambiguity() { // In order to check for trailing angle brackets, we must have finished // recursing (`parse_path_segment` can indirectly call this function), @@ -267,6 +274,7 @@ impl<'a> Parser<'a> { &mut self, style: PathStyle, ty_generics: Option<&Generics>, + syntax_loc: Option, ) -> PResult<'a, PathSegment> { let ident = self.parse_path_segment_ident()?; let is_args_start = |token: &Token| { @@ -286,6 +294,17 @@ impl<'a> Parser<'a> { is_args_start(&this.token) }; + if let Some(PatternLocation::FunctionParameter) = syntax_loc { + } else if style == PathStyle::Pat + && self.check_noexpect(&token::Lt) + && self.look_ahead(1, |t| t.can_begin_type()) + { + return Err(self.sess.create_err(GenericArgsInPatRequireTurbofishSyntax { + span: self.token.span, + suggest_turbofish: self.token.span.shrink_to_lo(), + })); + } + Ok( if style == PathStyle::Type && check_args_start(self) || style != PathStyle::Mod @@ -382,14 +401,6 @@ impl<'a> Parser<'a> { }; PathSegment { ident, args: Some(args), id: ast::DUMMY_NODE_ID } - } else if style == PathStyle::Pat - && self.check_noexpect(&token::Lt) - && self.look_ahead(1, |t| t.can_begin_type()) - { - return Err(self.sess.create_err(GenericArgsInPatRequireTurbofishSyntax { - span: self.token.span, - suggest_turbofish: self.token.span.shrink_to_lo(), - })); } else { // Generic arguments are not found. PathSegment::from_ident(ident) diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 9fcf51a04ec0..2c08e984be57 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -149,7 +149,7 @@ impl<'a> Parser<'a> { fn parse_stmt_path_start(&mut self, lo: Span, attrs: AttrWrapper) -> PResult<'a, Stmt> { let stmt = self.collect_tokens_trailing_token(attrs, ForceCollect::No, |this, attrs| { - let path = this.parse_path(PathStyle::Expr)?; + let path = this.parse_path(PathStyle::Expr, None)?; if this.eat(&token::Not) { let stmt_mac = this.parse_stmt_mac(lo, attrs, path)?; diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 3bb50b05aa34..8be84c7d4622 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -289,7 +289,7 @@ impl<'a> Parser<'a> { recover_return_sign, )? } else { - let path = self.parse_path(PathStyle::Type)?; + let path = self.parse_path(PathStyle::Type, None)?; let parse_plus = allow_plus == AllowPlus::Yes && self.check_plus(); self.parse_remaining_bounds_path(lifetime_defs, path, lo, parse_plus)? } @@ -649,7 +649,7 @@ impl<'a> Parser<'a> { ty_generics: Option<&Generics>, ) -> PResult<'a, TyKind> { // Simple path - let path = self.parse_path_inner(PathStyle::Type, ty_generics)?; + let path = self.parse_path_inner(PathStyle::Type, ty_generics, None)?; if self.eat(&token::Not) { // Macro invocation in type position Ok(TyKind::MacCall(P(MacCall { path, args: self.parse_delim_args()? }))) @@ -865,7 +865,7 @@ impl<'a> Parser<'a> { path } else { - self.parse_path(PathStyle::Type)? + self.parse_path(PathStyle::Type, None)? }; if self.may_recover() && self.token == TokenKind::OpenDelim(Delimiter::Parenthesis) { diff --git a/tests/ui/anon-params/anon-params-denied-2018.stderr b/tests/ui/anon-params/anon-params-denied-2018.stderr index bb60c898e812..ede0e70cd710 100644 --- a/tests/ui/anon-params/anon-params-denied-2018.stderr +++ b/tests/ui/anon-params/anon-params-denied-2018.stderr @@ -45,10 +45,14 @@ LL | fn foo_with_qualified_path(::Baz); | ^ expected one of 8 possible tokens | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: explicitly ignore the parameter name +help: if this is a `self` type, give it a parameter name + | +LL | fn foo_with_qualified_path(self: ::Baz); + | +++++ +help: if this is a type, explicitly ignore the parameter name | LL | fn foo_with_qualified_path(_: ::Baz); - | ~~~~~~~~~~~~~~~~~~ + | ++ error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:15:56 @@ -69,10 +73,14 @@ LL | fn foo_with_multiple_qualified_paths(::Baz, ::Baz); | ^ expected one of 8 possible tokens | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: explicitly ignore the parameter name +help: if this is a `self` type, give it a parameter name + | +LL | fn foo_with_multiple_qualified_paths(self: ::Baz, ::Baz); + | +++++ +help: if this is a type, explicitly ignore the parameter name | LL | fn foo_with_multiple_qualified_paths(_: ::Baz, ::Baz); - | ~~~~~~~~~~~~~~~~~~ + | ++ error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:18:74 @@ -81,10 +89,10 @@ LL | fn foo_with_multiple_qualified_paths(::Baz, ::Baz); | ^ expected one of 8 possible tokens | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: explicitly ignore the parameter name +help: if this is a type, explicitly ignore the parameter name | LL | fn foo_with_multiple_qualified_paths(::Baz, _: ::Baz); - | ~~~~~~~~~~~~~~~~~~ + | ++ error: expected one of `:`, `@`, or `|`, found `,` --> $DIR/anon-params-denied-2018.rs:22:36 diff --git a/tests/ui/span/issue-34264.rs b/tests/ui/span/issue-34264.rs index c7a8440f2840..9227ee482dfa 100644 --- a/tests/ui/span/issue-34264.rs +++ b/tests/ui/span/issue-34264.rs @@ -1,5 +1,5 @@ fn foo(Option, String) {} //~ ERROR expected one of -//~^ ERROR generic args in patterns require the turbofish syntax +//~^ ERROR expected one of fn bar(x, y: usize) {} //~ ERROR expected one of fn main() { diff --git a/tests/ui/span/issue-34264.stderr b/tests/ui/span/issue-34264.stderr index 1874d7f85337..8c639d5513b5 100644 --- a/tests/ui/span/issue-34264.stderr +++ b/tests/ui/span/issue-34264.stderr @@ -1,13 +1,18 @@ -error: generic args in patterns require the turbofish syntax +error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `<` --> $DIR/issue-34264.rs:1:14 | LL | fn foo(Option, String) {} - | ^ + | ^ expected one of 9 possible tokens | -help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name | -LL | fn foo(Option::, String) {} - | ++ +LL | fn foo(self: Option, String) {} + | +++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn foo(_: Option, String) {} + | ++ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/issue-34264.rs:1:27 diff --git a/tests/ui/suggestions/issue-64252-self-type.rs b/tests/ui/suggestions/issue-64252-self-type.rs index ad25d334507f..ea76dc8742b9 100644 --- a/tests/ui/suggestions/issue-64252-self-type.rs +++ b/tests/ui/suggestions/issue-64252-self-type.rs @@ -1,12 +1,11 @@ // This test checks that a suggestion to add a `self: ` parameter name is provided // to functions where this is applicable. -pub fn foo(Box) { } //~ ERROR generic args in patterns require the turbofish syntax - +pub fn foo(Box) { } //~ ERROR expected one of struct Bar; impl Bar { - fn bar(Box) { } //~ ERROR generic args in patterns require the turbofish syntax + fn bar(Box) { } //~ ERROR expected one of } fn main() { } diff --git a/tests/ui/suggestions/issue-64252-self-type.stderr b/tests/ui/suggestions/issue-64252-self-type.stderr index ba5c2da24150..dd83d6a1cb29 100644 --- a/tests/ui/suggestions/issue-64252-self-type.stderr +++ b/tests/ui/suggestions/issue-64252-self-type.stderr @@ -1,24 +1,34 @@ -error: generic args in patterns require the turbofish syntax +error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `<` --> $DIR/issue-64252-self-type.rs:4:15 | LL | pub fn foo(Box) { } - | ^ + | ^ expected one of 9 possible tokens | -help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name | -LL | pub fn foo(Box::) { } - | ++ +LL | pub fn foo(self: Box) { } + | +++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | pub fn foo(_: Box) { } + | ++ -error: generic args in patterns require the turbofish syntax - --> $DIR/issue-64252-self-type.rs:9:15 +error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `<` + --> $DIR/issue-64252-self-type.rs:8:15 | LL | fn bar(Box) { } - | ^ + | ^ expected one of 9 possible tokens | -help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name | -LL | fn bar(Box::) { } - | ++ +LL | fn bar(self: Box) { } + | +++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn bar(_: Box) { } + | ++ error: aborting due to 2 previous errors From f5243d2bfc9c8982523d443e960f8b8c54f6cd73 Mon Sep 17 00:00:00 2001 From: Mu001999 Date: Thu, 3 Aug 2023 00:13:41 +0800 Subject: [PATCH 146/150] Fix rustfmt dep --- src/tools/rustfmt/src/parse/macros/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rustfmt/src/parse/macros/mod.rs b/src/tools/rustfmt/src/parse/macros/mod.rs index 67f3985926e2..7a802f7a88e0 100644 --- a/src/tools/rustfmt/src/parse/macros/mod.rs +++ b/src/tools/rustfmt/src/parse/macros/mod.rs @@ -56,7 +56,7 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option { ); parse_macro_arg!( Pat, - |parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_pat_no_top_alt(None), + |parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_pat_no_top_alt(None, None), |x: ptr::P| Some(x) ); // `parse_item` returns `Option>`. From 41e85c3d2369ebc44c19c6009a061b64d43672ee Mon Sep 17 00:00:00 2001 From: r0cky Date: Thu, 3 Aug 2023 05:18:19 +0000 Subject: [PATCH 147/150] Apply suggestions --- compiler/rustc_parse/src/parser/pat.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 615ef28db085..5803d0c1c052 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -139,7 +139,7 @@ impl<'a> Parser<'a> { }; // Parse the first pattern (`p_0`). - let mut first_pat = self.parse_pat_no_top_alt(expected, syntax_loc.clone())?; + let mut first_pat = self.parse_pat_no_top_alt(expected, syntax_loc)?; if rc == RecoverComma::Yes { self.maybe_recover_unexpected_comma(first_pat.span, rt)?; } @@ -813,7 +813,9 @@ impl<'a> Parser<'a> { | token::DotDotDot | token::DotDotEq | token::DotDot // A range pattern. | token::ModSep // A tuple / struct variant pattern. | token::Not)) // A macro expanding to a pattern. - && !(self.look_ahead(1, |t| t.kind == token::Lt) && self.look_ahead(2, |t| t.can_begin_type())) // May suggest the turbofish syntax for generics, only valid for recoveries. + // May suggest the turbofish syntax for generics, only valid for recoveries. + && !(self.look_ahead(1, |t| t.kind == token::Lt) + && self.look_ahead(2, |t| t.can_begin_type())) } /// Parses `ident` or `ident @ pat`. From 8c8af6cf99d6a54ece11d21c15e909aef2b60552 Mon Sep 17 00:00:00 2001 From: r0cky Date: Thu, 3 Aug 2023 08:56:31 +0000 Subject: [PATCH 148/150] Avoid too many expected symbols and reduce `None`s --- compiler/rustc_parse/src/parser/attr.rs | 4 +- .../rustc_parse/src/parser/diagnostics.rs | 2 +- compiler/rustc_parse/src/parser/expr.rs | 6 +-- compiler/rustc_parse/src/parser/item.rs | 6 +-- compiler/rustc_parse/src/parser/mod.rs | 6 +-- .../rustc_parse/src/parser/nonterminal.rs | 2 +- compiler/rustc_parse/src/parser/pat.rs | 43 ++++++++++++------- compiler/rustc_parse/src/parser/path.rs | 33 +++----------- compiler/rustc_parse/src/parser/stmt.rs | 2 +- compiler/rustc_parse/src/parser/ty.rs | 6 +-- tests/ui/span/issue-34264.stderr | 4 +- .../suggestions/issue-64252-self-type.stderr | 8 ++-- 12 files changed, 58 insertions(+), 64 deletions(-) diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index 1271bce799d5..ee0abba1c175 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -260,7 +260,7 @@ impl<'a> Parser<'a> { item } else { let do_parse = |this: &mut Self| { - let path = this.parse_path(PathStyle::Mod, None)?; + let path = this.parse_path(PathStyle::Mod)?; let args = this.parse_attr_args()?; Ok(ast::AttrItem { path, args, tokens: None }) }; @@ -387,7 +387,7 @@ impl<'a> Parser<'a> { } let lo = self.token.span; - let path = self.parse_path(PathStyle::Mod, None)?; + let path = self.parse_path(PathStyle::Mod)?; let kind = self.parse_meta_item_kind()?; let span = lo.to(self.prev_token.span); Ok(ast::MetaItem { path, kind, span }) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 8bc4433a9653..5fa4f7902d62 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1579,7 +1579,7 @@ impl<'a> Parser<'a> { self.expect(&token::ModSep)?; let mut path = ast::Path { segments: ThinVec::new(), span: DUMMY_SP, tokens: None }; - self.parse_path_segments(&mut path.segments, T::PATH_STYLE, None, None)?; + self.parse_path_segments(&mut path.segments, T::PATH_STYLE, None)?; path.span = ty_span.to(self.prev_token.span); let ty_str = self.span_to_snippet(ty_span).unwrap_or_else(|_| pprust::ty_to_string(&ty)); diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 6dafb8b999b2..0e19a67a8413 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -775,7 +775,7 @@ impl<'a> Parser<'a> { _ => {} } - match self.parse_path(PathStyle::Expr, None) { + match self.parse_path(PathStyle::Expr) { Ok(path) => { let span_after_type = parser_snapshot_after_type.token.span; let expr = mk_expr( @@ -1314,7 +1314,7 @@ impl<'a> Parser<'a> { } let fn_span_lo = self.token.span; - let mut seg = self.parse_path_segment(PathStyle::Expr, None, None)?; + let mut seg = self.parse_path_segment(PathStyle::Expr, None)?; self.check_trailing_angle_brackets(&seg, &[&token::OpenDelim(Delimiter::Parenthesis)]); self.check_turbofish_missing_angle_brackets(&mut seg); @@ -1544,7 +1544,7 @@ impl<'a> Parser<'a> { })?; (Some(qself), path) } else { - (None, self.parse_path(PathStyle::Expr, None)?) + (None, self.parse_path(PathStyle::Expr)?) }; // `!`, as an operator, is prefix, so we know this isn't that. diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index d3f756139def..1301ed3e3882 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -452,7 +452,7 @@ impl<'a> Parser<'a> { /// Parses an item macro, e.g., `item!();`. fn parse_item_macro(&mut self, vis: &Visibility) -> PResult<'a, MacCall> { - let path = self.parse_path(PathStyle::Mod, None)?; // `foo::bar` + let path = self.parse_path(PathStyle::Mod)?; // `foo::bar` self.expect(&token::Not)?; // `!` match self.parse_delim_args() { // `( .. )` or `[ .. ]` (followed by `;`), or `{ .. }`. @@ -976,7 +976,7 @@ impl<'a> Parser<'a> { self.parse_use_tree_glob_or_nested()? } else { // `use path::*;` or `use path::{...};` or `use path;` or `use path as bar;` - prefix = self.parse_path(PathStyle::Mod, None)?; + prefix = self.parse_path(PathStyle::Mod)?; if self.eat(&token::ModSep) { self.parse_use_tree_glob_or_nested()? @@ -987,7 +987,7 @@ impl<'a> Parser<'a> { .emit_err(errors::SingleColonImportPath { span: self.prev_token.span }); // We parse the rest of the path and append it to the original prefix. - self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None, None)?; + self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None)?; prefix.span = lo.to(self.prev_token.span); } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 2af0caa1bdaf..37b4c371c94b 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1413,7 +1413,7 @@ impl<'a> Parser<'a> { // Parse `pub(in path)`. self.bump(); // `(` self.bump(); // `in` - let path = self.parse_path(PathStyle::Mod, None)?; // `path` + let path = self.parse_path(PathStyle::Mod)?; // `path` self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` let vis = VisibilityKind::Restricted { path: P(path), @@ -1430,7 +1430,7 @@ impl<'a> Parser<'a> { { // Parse `pub(crate)`, `pub(self)`, or `pub(super)`. self.bump(); // `(` - let path = self.parse_path(PathStyle::Mod, None)?; // `crate`/`super`/`self` + let path = self.parse_path(PathStyle::Mod)?; // `crate`/`super`/`self` self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` let vis = VisibilityKind::Restricted { path: P(path), @@ -1456,7 +1456,7 @@ impl<'a> Parser<'a> { /// Recovery for e.g. `pub(something) fn ...` or `struct X { pub(something) y: Z }` fn recover_incorrect_vis_restriction(&mut self) -> PResult<'a, ()> { self.bump(); // `(` - let path = self.parse_path(PathStyle::Mod, None)?; + let path = self.parse_path(PathStyle::Mod)?; self.expect(&token::CloseDelim(Delimiter::Parenthesis))?; // `)` let path_str = pprust::path_to_string(&path); diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index a09c1e4d7fde..f5681532b3af 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -168,7 +168,7 @@ impl<'a> Parser<'a> { }.into_diagnostic(&self.sess.span_diagnostic)); } NonterminalKind::Path => token::NtPath( - P(self.collect_tokens_no_attrs(|this| this.parse_path(PathStyle::Type, None))?), + P(self.collect_tokens_no_attrs(|this| this.parse_path(PathStyle::Type))?), ), NonterminalKind::Meta => token::NtMeta(P(self.parse_attr_item(true)?)), NonterminalKind::Vis => token::NtVis( diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 5803d0c1c052..8d68a3a50aca 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -2,10 +2,11 @@ use super::{ForceCollect, Parser, PathStyle, TrailingToken}; use crate::errors::{ self, AmbiguousRangePattern, DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed, DotDotDotRestPattern, EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt, - ExpectedCommaAfterPatternField, InclusiveRangeExtraEquals, InclusiveRangeMatchArrow, - InclusiveRangeNoEnd, InvalidMutInPattern, PatternOnWrongSideOfAt, RefMutOrderIncorrect, - RemoveLet, RepeatedMutInPattern, TopLevelOrPatternNotAllowed, TopLevelOrPatternNotAllowedSugg, - TrailingVertNotAllowed, UnexpectedLifetimeInPattern, UnexpectedVertVertBeforeFunctionParam, + ExpectedCommaAfterPatternField, GenericArgsInPatRequireTurbofishSyntax, + InclusiveRangeExtraEquals, InclusiveRangeMatchArrow, InclusiveRangeNoEnd, InvalidMutInPattern, + PatternOnWrongSideOfAt, RefMutOrderIncorrect, RemoveLet, RepeatedMutInPattern, + TopLevelOrPatternNotAllowed, TopLevelOrPatternNotAllowedSugg, TrailingVertNotAllowed, + UnexpectedLifetimeInPattern, UnexpectedVertVertBeforeFunctionParam, UnexpectedVertVertInPattern, }; use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; @@ -366,11 +367,11 @@ impl<'a> Parser<'a> { // Parse _ PatKind::Wild } else if self.eat_keyword(kw::Mut) { - self.parse_pat_ident_mut()? + self.parse_pat_ident_mut(syntax_loc)? } else if self.eat_keyword(kw::Ref) { // Parse ref ident @ pat / ref mut ident @ pat let mutbl = self.parse_mutability(); - self.parse_pat_ident(BindingAnnotation(ByRef::Yes, mutbl))? + self.parse_pat_ident(BindingAnnotation(ByRef::Yes, mutbl), syntax_loc)? } else if self.eat_keyword(kw::Box) { self.parse_pat_box()? } else if self.check_inline_const(0) { @@ -392,7 +393,7 @@ impl<'a> Parser<'a> { // Parse `ident @ pat` // This can give false positives and parse nullary enums, // they are dealt with later in resolve. - self.parse_pat_ident(BindingAnnotation::NONE)? + self.parse_pat_ident(BindingAnnotation::NONE, syntax_loc)? } else if self.is_start_of_pat_with_path() { // Parse pattern starting with a path let (qself, path) = if self.eat_lt() { @@ -401,7 +402,7 @@ impl<'a> Parser<'a> { (Some(qself), path) } else { // Parse an unqualified path - (None, self.parse_path(PathStyle::Pat, syntax_loc)?) + (None, self.parse_path(PathStyle::Pat)?) }; let span = lo.to(self.prev_token.span); @@ -574,12 +575,12 @@ impl<'a> Parser<'a> { } /// Parse a mutable binding with the `mut` token already eaten. - fn parse_pat_ident_mut(&mut self) -> PResult<'a, PatKind> { + fn parse_pat_ident_mut(&mut self, syntax_loc: Option) -> PResult<'a, PatKind> { let mut_span = self.prev_token.span; if self.eat_keyword(kw::Ref) { self.sess.emit_err(RefMutOrderIncorrect { span: mut_span.to(self.prev_token.span) }); - return self.parse_pat_ident(BindingAnnotation::REF_MUT); + return self.parse_pat_ident(BindingAnnotation::REF_MUT, syntax_loc); } self.recover_additional_muts(); @@ -784,7 +785,7 @@ impl<'a> Parser<'a> { (Some(qself), path) } else { // Parse an unqualified path - (None, self.parse_path(PathStyle::Pat, None)?) + (None, self.parse_path(PathStyle::Pat)?) }; let hi = self.prev_token.span; Ok(self.mk_expr(lo.to(hi), ExprKind::Path(qself, path))) @@ -813,16 +814,28 @@ impl<'a> Parser<'a> { | token::DotDotDot | token::DotDotEq | token::DotDot // A range pattern. | token::ModSep // A tuple / struct variant pattern. | token::Not)) // A macro expanding to a pattern. - // May suggest the turbofish syntax for generics, only valid for recoveries. - && !(self.look_ahead(1, |t| t.kind == token::Lt) - && self.look_ahead(2, |t| t.can_begin_type())) } /// Parses `ident` or `ident @ pat`. /// Used by the copy foo and ref foo patterns to give a good /// error message when parsing mistakes like `ref foo(a, b)`. - fn parse_pat_ident(&mut self, binding_annotation: BindingAnnotation) -> PResult<'a, PatKind> { + fn parse_pat_ident( + &mut self, + binding_annotation: BindingAnnotation, + syntax_loc: Option, + ) -> PResult<'a, PatKind> { let ident = self.parse_ident()?; + + if !matches!(syntax_loc, Some(PatternLocation::FunctionParameter)) + && self.check_noexpect(&token::Lt) + && self.look_ahead(1, |t| t.can_begin_type()) + { + return Err(self.sess.create_err(GenericArgsInPatRequireTurbofishSyntax { + span: self.token.span, + suggest_turbofish: self.token.span.shrink_to_lo(), + })); + } + let sub = if self.eat(&token::At) { Some(self.parse_pat_no_top_alt(Some(Expected::BindingPattern), None)?) } else { diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 0d5f48e424e2..feb7e829caf6 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -1,7 +1,6 @@ -use super::pat::PatternLocation; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; -use crate::errors::{GenericArgsInPatRequireTurbofishSyntax, PathSingleColon}; +use crate::errors::PathSingleColon; use crate::{errors, maybe_whole}; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; @@ -80,7 +79,7 @@ impl<'a> Parser<'a> { let (mut path, path_span); if self.eat_keyword(kw::As) { let path_lo = self.token.span; - path = self.parse_path(PathStyle::Type, None)?; + path = self.parse_path(PathStyle::Type)?; path_span = path_lo.to(self.prev_token.span); } else { path_span = self.token.span.to(self.token.span); @@ -99,7 +98,7 @@ impl<'a> Parser<'a> { } let qself = P(QSelf { ty, path_span, position: path.segments.len() }); - self.parse_path_segments(&mut path.segments, style, None, None)?; + self.parse_path_segments(&mut path.segments, style, None)?; Ok(( qself, @@ -140,12 +139,8 @@ impl<'a> Parser<'a> { true } - pub(super) fn parse_path( - &mut self, - style: PathStyle, - syntax_loc: Option, - ) -> PResult<'a, Path> { - self.parse_path_inner(style, None, syntax_loc) + pub(super) fn parse_path(&mut self, style: PathStyle) -> PResult<'a, Path> { + self.parse_path_inner(style, None) } /// Parses simple paths. @@ -162,7 +157,6 @@ impl<'a> Parser<'a> { &mut self, style: PathStyle, ty_generics: Option<&Generics>, - syntax_loc: Option, ) -> PResult<'a, Path> { let reject_generics_if_mod_style = |parser: &Parser<'_>, path: &Path| { // Ensure generic arguments don't end up in attribute paths, such as: @@ -207,7 +201,7 @@ impl<'a> Parser<'a> { if self.eat(&token::ModSep) { segments.push(PathSegment::path_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt))); } - self.parse_path_segments(&mut segments, style, ty_generics, syntax_loc)?; + self.parse_path_segments(&mut segments, style, ty_generics)?; Ok(Path { segments, span: lo.to(self.prev_token.span), tokens: None }) } @@ -216,10 +210,9 @@ impl<'a> Parser<'a> { segments: &mut ThinVec, style: PathStyle, ty_generics: Option<&Generics>, - syntax_loc: Option, ) -> PResult<'a, ()> { loop { - let segment = self.parse_path_segment(style, ty_generics, syntax_loc)?; + let segment = self.parse_path_segment(style, ty_generics)?; if style.has_generic_ambiguity() { // In order to check for trailing angle brackets, we must have finished // recursing (`parse_path_segment` can indirectly call this function), @@ -274,7 +267,6 @@ impl<'a> Parser<'a> { &mut self, style: PathStyle, ty_generics: Option<&Generics>, - syntax_loc: Option, ) -> PResult<'a, PathSegment> { let ident = self.parse_path_segment_ident()?; let is_args_start = |token: &Token| { @@ -294,17 +286,6 @@ impl<'a> Parser<'a> { is_args_start(&this.token) }; - if let Some(PatternLocation::FunctionParameter) = syntax_loc { - } else if style == PathStyle::Pat - && self.check_noexpect(&token::Lt) - && self.look_ahead(1, |t| t.can_begin_type()) - { - return Err(self.sess.create_err(GenericArgsInPatRequireTurbofishSyntax { - span: self.token.span, - suggest_turbofish: self.token.span.shrink_to_lo(), - })); - } - Ok( if style == PathStyle::Type && check_args_start(self) || style != PathStyle::Mod diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 2c08e984be57..9fcf51a04ec0 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -149,7 +149,7 @@ impl<'a> Parser<'a> { fn parse_stmt_path_start(&mut self, lo: Span, attrs: AttrWrapper) -> PResult<'a, Stmt> { let stmt = self.collect_tokens_trailing_token(attrs, ForceCollect::No, |this, attrs| { - let path = this.parse_path(PathStyle::Expr, None)?; + let path = this.parse_path(PathStyle::Expr)?; if this.eat(&token::Not) { let stmt_mac = this.parse_stmt_mac(lo, attrs, path)?; diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 8be84c7d4622..3bb50b05aa34 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -289,7 +289,7 @@ impl<'a> Parser<'a> { recover_return_sign, )? } else { - let path = self.parse_path(PathStyle::Type, None)?; + let path = self.parse_path(PathStyle::Type)?; let parse_plus = allow_plus == AllowPlus::Yes && self.check_plus(); self.parse_remaining_bounds_path(lifetime_defs, path, lo, parse_plus)? } @@ -649,7 +649,7 @@ impl<'a> Parser<'a> { ty_generics: Option<&Generics>, ) -> PResult<'a, TyKind> { // Simple path - let path = self.parse_path_inner(PathStyle::Type, ty_generics, None)?; + let path = self.parse_path_inner(PathStyle::Type, ty_generics)?; if self.eat(&token::Not) { // Macro invocation in type position Ok(TyKind::MacCall(P(MacCall { path, args: self.parse_delim_args()? }))) @@ -865,7 +865,7 @@ impl<'a> Parser<'a> { path } else { - self.parse_path(PathStyle::Type, None)? + self.parse_path(PathStyle::Type)? }; if self.may_recover() && self.token == TokenKind::OpenDelim(Delimiter::Parenthesis) { diff --git a/tests/ui/span/issue-34264.stderr b/tests/ui/span/issue-34264.stderr index 8c639d5513b5..f0dea66f6128 100644 --- a/tests/ui/span/issue-34264.stderr +++ b/tests/ui/span/issue-34264.stderr @@ -1,8 +1,8 @@ -error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `<` +error: expected one of `:`, `@`, or `|`, found `<` --> $DIR/issue-34264.rs:1:14 | LL | fn foo(Option, String) {} - | ^ expected one of 9 possible tokens + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name diff --git a/tests/ui/suggestions/issue-64252-self-type.stderr b/tests/ui/suggestions/issue-64252-self-type.stderr index dd83d6a1cb29..dbef39faeadf 100644 --- a/tests/ui/suggestions/issue-64252-self-type.stderr +++ b/tests/ui/suggestions/issue-64252-self-type.stderr @@ -1,8 +1,8 @@ -error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `<` +error: expected one of `:`, `@`, or `|`, found `<` --> $DIR/issue-64252-self-type.rs:4:15 | LL | pub fn foo(Box) { } - | ^ expected one of 9 possible tokens + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name @@ -14,11 +14,11 @@ help: if this is a type, explicitly ignore the parameter name LL | pub fn foo(_: Box) { } | ++ -error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `<` +error: expected one of `:`, `@`, or `|`, found `<` --> $DIR/issue-64252-self-type.rs:8:15 | LL | fn bar(Box) { } - | ^ expected one of 9 possible tokens + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name From dce7e87b1646fd5f4f7908fcd0aa1060c5189d44 Mon Sep 17 00:00:00 2001 From: r0cky Date: Thu, 3 Aug 2023 10:34:57 +0000 Subject: [PATCH 149/150] Reduce arbitrary self type suggestions --- .../rustc_parse/src/parser/diagnostics.rs | 18 +++-------------- .../anon-params-denied-2018.stderr | 20 ++++++------------- tests/ui/suggestions/issue-64252-self-type.rs | 7 +++++-- .../suggestions/issue-64252-self-type.stderr | 2 +- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 5fa4f7902d62..00ffa7de2ff6 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -2019,7 +2019,7 @@ impl<'a> Parser<'a> { { let rfc_note = "anonymous parameters are removed in the 2018 edition (see RFC 1685)"; - let (ident, self_sugg, param_sugg, type_sugg, self_span, param_span, type_span, maybe_name) = + let (ident, self_sugg, param_sugg, type_sugg, self_span, param_span, type_span) = match pat.kind { PatKind::Ident(_, ident, _) => ( ident, @@ -2029,7 +2029,6 @@ impl<'a> Parser<'a> { pat.span.shrink_to_lo(), pat.span.shrink_to_hi(), pat.span.shrink_to_lo(), - true, ), // Also catches `fn foo(&a)`. PatKind::Ref(ref inner_pat, mutab) @@ -2046,22 +2045,11 @@ impl<'a> Parser<'a> { pat.span.shrink_to_lo(), pat.span, pat.span.shrink_to_lo(), - true, ) } _ => unreachable!(), } - }, - PatKind::Path(_, ref path) if let Some(segment) = path.segments.last() => ( - segment.ident, - "self: ", - ": TypeName".to_string(), - "_: ", - pat.span.shrink_to_lo(), - pat.span.shrink_to_hi(), - pat.span.shrink_to_lo(), - path.segments.len() == 1, // Avoid suggesting that `fn foo(a::b)` is fixed with a change to `fn foo(a::b: TypeName)`. - ), + } _ => { // Otherwise, try to get a type and emit a suggestion. if let Some(ty) = pat.to_ty() { @@ -2089,7 +2077,7 @@ impl<'a> Parser<'a> { } // Avoid suggesting that `fn foo(HashMap)` is fixed with a change to // `fn foo(HashMap: TypeName)`. - if self.token != token::Lt && maybe_name { + if self.token != token::Lt { err.span_suggestion( param_span, "if this is a parameter name, give it a type", diff --git a/tests/ui/anon-params/anon-params-denied-2018.stderr b/tests/ui/anon-params/anon-params-denied-2018.stderr index ede0e70cd710..bb60c898e812 100644 --- a/tests/ui/anon-params/anon-params-denied-2018.stderr +++ b/tests/ui/anon-params/anon-params-denied-2018.stderr @@ -45,14 +45,10 @@ LL | fn foo_with_qualified_path(::Baz); | ^ expected one of 8 possible tokens | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: if this is a `self` type, give it a parameter name - | -LL | fn foo_with_qualified_path(self: ::Baz); - | +++++ -help: if this is a type, explicitly ignore the parameter name +help: explicitly ignore the parameter name | LL | fn foo_with_qualified_path(_: ::Baz); - | ++ + | ~~~~~~~~~~~~~~~~~~ error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:15:56 @@ -73,14 +69,10 @@ LL | fn foo_with_multiple_qualified_paths(::Baz, ::Baz); | ^ expected one of 8 possible tokens | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: if this is a `self` type, give it a parameter name - | -LL | fn foo_with_multiple_qualified_paths(self: ::Baz, ::Baz); - | +++++ -help: if this is a type, explicitly ignore the parameter name +help: explicitly ignore the parameter name | LL | fn foo_with_multiple_qualified_paths(_: ::Baz, ::Baz); - | ++ + | ~~~~~~~~~~~~~~~~~~ error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:18:74 @@ -89,10 +81,10 @@ LL | fn foo_with_multiple_qualified_paths(::Baz, ::Baz); | ^ expected one of 8 possible tokens | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: if this is a type, explicitly ignore the parameter name +help: explicitly ignore the parameter name | LL | fn foo_with_multiple_qualified_paths(::Baz, _: ::Baz); - | ++ + | ~~~~~~~~~~~~~~~~~~ error: expected one of `:`, `@`, or `|`, found `,` --> $DIR/anon-params-denied-2018.rs:22:36 diff --git a/tests/ui/suggestions/issue-64252-self-type.rs b/tests/ui/suggestions/issue-64252-self-type.rs index ea76dc8742b9..128d5e85c22c 100644 --- a/tests/ui/suggestions/issue-64252-self-type.rs +++ b/tests/ui/suggestions/issue-64252-self-type.rs @@ -1,11 +1,14 @@ // This test checks that a suggestion to add a `self: ` parameter name is provided // to functions where this is applicable. -pub fn foo(Box) { } //~ ERROR expected one of +pub fn foo(Box) { } +//~^ ERROR expected one of `:`, `@`, or `|`, found `<` + struct Bar; impl Bar { - fn bar(Box) { } //~ ERROR expected one of + fn bar(Box) { } + //~^ ERROR expected one of `:`, `@`, or `|`, found `<` } fn main() { } diff --git a/tests/ui/suggestions/issue-64252-self-type.stderr b/tests/ui/suggestions/issue-64252-self-type.stderr index dbef39faeadf..c3418dab0e8a 100644 --- a/tests/ui/suggestions/issue-64252-self-type.stderr +++ b/tests/ui/suggestions/issue-64252-self-type.stderr @@ -15,7 +15,7 @@ LL | pub fn foo(_: Box) { } | ++ error: expected one of `:`, `@`, or `|`, found `<` - --> $DIR/issue-64252-self-type.rs:8:15 + --> $DIR/issue-64252-self-type.rs:10:15 | LL | fn bar(Box) { } | ^ expected one of `:`, `@`, or `|` From a4bfcbe4d3f2a1080a70c15c1f681b9f341c882e Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Sun, 30 Jul 2023 05:45:01 +0000 Subject: [PATCH 150/150] fmt --- src/tools/miri/tests/compiletest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index fa17923446fd..8d82e6b8f9c6 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -72,7 +72,7 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> program.args.push(flag); } - let bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v !="0"); + let bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0"); let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some(); let output_conflict_handling = match (bless, skip_ui_checks) {