summary refs log tree commit diff
path: root/compiler/rustc_passes/src/check_const.rs
AgeCommit message (Collapse)AuthorLines
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-2/+2
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-03-21Use local key in providersMichael Goulet-3/+1
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-2/+2
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-12Expand format_args!() in rust_ast_lowering.Mara Bos-1/+1
2022-10-07Remove code that was removed in master, and the corresponding diagnosticNathan Stocks-21/+1
2022-10-07migrate check_const.rs to translateable diagnosticsNathan Stocks-4/+29
2022-10-04Merge the `~const` and `impl const` checks and add some explanatory notesOli Scherer-26/+0
2022-09-30Use let chains instead of let elsefee1-dead-1/+1
2022-09-27Fix ICE in const_trait check codeDeadbeef-1/+1
This fixes #102156.
2022-09-16Require `#[const_trait]` for `const` `impl`sDeadbeef-0/+22
2022-08-01Remove trait_of_item query.Camille GILLOT-1/+1
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-1/+1
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-07Reword comments and rename HIR visiting methods.Camille GILLOT-1/+1
2022-05-30Remove `#[default..]` and add `#[const_trait]`Deadbeef-62/+0
2022-05-14allocate string only when error will be emittedMiguel Guarniz-2/+7
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13change back to using tcx.hir() visit-item methodMiguel Guarniz-29/+7
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13replace hir().def_kind for def_kind query in rustc_passesMiguel Guarniz-1/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13replace usage of visit_item_likes_in_modules with hir_module_items queryMiguel Guarniz-2/+20
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13Remove CheckConstTraitVisitorMiguel Guarniz-68/+54
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-10only_local: always check for misuselcnr-4/+6
2022-03-30Spellchecking compiler commentsYuri Astrakhan-1/+1
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-22use `format-args-capture` and remove unnecessary nested if blocks in some ↵Takayuki Maeda-3/+1
parts of rustc_passes break before the `&&` Update compiler/rustc_passes/src/check_const.rs Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-1/+3
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-5/+5
2022-01-07Add query to avoid name comparison in `leaf_def`Matthew Jasper-5/+8
2021-12-15Remove `in_band_lifetimes` for `rustc_passes`Peter Jaszkowiak-4/+4
2021-11-24Allow features like const_try in d_m_b_i_cDeadbeef-0/+6
2021-11-07more clippy fixesMatthias Krüger-3/+3
2021-10-11Use Ancestory to check default fn in const impl instead of comparing identsGary Guo-18/+26
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-7/+2
2021-07-29Add feature gates for `for` and `?` in constsJonas Schievink-4/+5
2021-07-10Applied suggestionsDeadbeef-11/+6
2021-07-10Add #[default_method_body_is_const]Deadbeef-18/+31
2021-07-01Do the check even when the feature is not enabledDeadbeef-3/+6
2021-06-23deny using default function in impl const TraitDeadbeef-0/+59
2021-02-21remove redundant wrapping of return types of allow_internal_unstable() and ↵Matthias Krüger-1/+1
rustc_allow_const_fn_unstable()
2021-02-17replace if-let and while-let with `if let` and `while let`Takayuki Maeda-1/+1
2021-01-21Add loop head span to hirEsteban Küber-1/+1
2021-01-07Reintroduce hir::ExprKind::IfCaio-3/+1
2020-12-06Implement lowering of if-let guards to MIRLeSeulArtichaut-0/+2
2020-11-07Allow making `RUSTC_BOOTSTRAP` conditional on the crate nameJoshua Nelson-2/+1
The main change is that `UnstableOptions::from_environment` now requires an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how. Other major changes: - Added `Session::is_nightly_build()`, which uses the `crate_name` of the session - Added `nightly_options::match_is_nightly_build`, a convenience method for looking up `--crate-name` from CLI arguments. `Session::is_nightly_build()`should be preferred where possible, since it will take into account `#![crate_name]` (I think). - Added `unstable_features` to `rustdoc::RenderOptions` There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no longer active nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway. - Add tests Check against `Cheat`, not whether nightly features are allowed. Nightly features are always allowed on the nightly channel. - Only call `is_nightly_build()` once within a function - Use booleans consistently for rustc_incremental Sessions can't be passed through threads, so `read_file` couldn't take a session. To be consistent, also take a boolean in `write_file_header`.
2020-10-21switch allow_internal_unstable const fns to rustc_allow_const_fn_unstableFlorian Warzecha-3/+3
2020-08-30mv compiler to compiler/mark-0/+227