summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2023-03-03Match unmatched backticks in comments in compiler/est31-1/+1
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-1/+1
2023-02-27Rollup merge of #108486 - cjgillot:owner-ditem, r=NilstriebMatthias Krüger-46/+33
Merge diagnostic_items duplicate diagnostics To deduplicate how we diagnose duplication.
2023-02-26Rollup merge of #108379 - compiler-errors:hir-error-guaranteed, r=cjgillotMatthias Krüger-4/+4
Add `ErrorGuaranteed` to `hir::{Expr,Ty}Kind::Err` variants First step in making the `Err` variants of `ExprKind` and `TyKind` require an `ErrorGuaranteed` during parsing. Making the corresponding AST versions require `ErrorGuaranteed` is a bit harder, whereas it was pretty easy to do this for HIR, so let's do that first. The only weird thing about this PR is that `ErrorGuaranteed` is moved to `rustc_span`. This is *certainly* not the right place to put it, but `rustc_hir` cannot depend on `rustc_error` because the latter already depends on the former. Should I just pull out some of the error machinery from `rustc_error` into an even more minimal crate that `rustc_hir` can depend on? Advice would be appreciated.
2023-02-26Merge the two diagnostics.Camille GILLOT-27/+17
2023-02-26Simplify diagnostic_items.Camille GILLOT-33/+30
2023-02-26Auto merge of #108473 - matthiaskrgr:rollup-qjyae58, r=matthiaskrgrbors-1/+4
Rollup of 8 pull requests Successful merges: - #107062 (Do some cleanup of doc/index.md) - #107890 (Lint against `Iterator::map` receiving a callable that returns `()`) - #108431 (Add regression test for #107918) - #108432 (test: drop unused deps) - #108436 (make "proc macro panicked" translatable) - #108444 (docs/test: add UI test and docs for `E0476`) - #108449 (Do not lint ineffective unstable trait impl for unresolved trait) - #108456 (Complete migrating `ast_passes` to derive diagnostics) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-26Rollup merge of #108449 - fee1-dead-contrib:do_not_lint_unresolved, ↵Matthias Krüger-1/+4
r=compiler-errors Do not lint ineffective unstable trait impl for unresolved trait
2023-02-25Rollup merge of #107911 - blyxyas:issue-107231-fix, r=compiler-errorsMichael Goulet-4/+39
Add check for invalid #[macro_export] arguments Resolves #107231 Sorry if I made something wrong, this is my first contribution to the repo.
2023-02-25Add ErrorGuaranteed to HIR ExprKind::ErrMichael Goulet-4/+4
2023-02-25Do not lint unresolved trait for ineffective unstable trait implDeadbeef-1/+4
2023-02-23Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, ↵bors-4/+4
r=compiler-errors,davidtwco,estebank,oli-obk diagnostics: if AssocFn has self argument, describe as method Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods. For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods> > Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation. In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-22Add check for invalid \`#[macro_export]\` argumentsblyxyas-4/+39
2023-02-22Rollup merge of #108315 - clubby789:dead-code-in-closure, r=compiler-errorsMatthias Krüger-0/+3
Lint dead code in closures and generators Fixes #108296 I think this might be a potentially breaking change, but restores the behaviour of pre-1.64. `@rustbot` label +A-lint
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-4/+4
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-22Lint dead code in closuresclubby789-0/+3
2023-02-22errors: generate typed identifiers in each crateDavid Wood-52/+54
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-19Auto merge of #108128 - clubby789:builtin-derived-attr, r=jackh726bors-2/+2
Properly check for builtin derived code Fixes #108122
2023-02-17Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwUbors-4/+4
Switch to `EarlyBinder` for `type_of` query Part of the work to finish #105779 and implement https://github.com/rust-lang/types-team/issues/78. Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`. r? `@lcnr`
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-4/+4
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-4/+4
2023-02-17Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillotMatthias Krüger-1/+1
Implement partial support for non-lifetime binders This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed. Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged. Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`) cc rust-lang/types-team#81 r? `@ghost`
2023-02-16Properly check for builtin derivesclubby789-2/+2
2023-02-16Replace some `then`s with some `then_some`sMaybe Waffle-1/+1
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-6/+3
2023-02-16Rename some region-specific stuffMichael Goulet-1/+1
2023-02-15Auto merge of #108006 - cjgillot:def-impl, r=oli-obkbors-23/+18
Avoid accessing HIR when it can be avoided Experiment to see if it helps some incremental cases. Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged. r? `@ghost`
2023-02-14Do not fetch HIR for reachable.Camille GILLOT-16/+13
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-7/+5
2023-02-14add a `#[rustc_coinductive]` attributelcnr-0/+15
2023-02-05rustc_passes: remove huge error importsest31-56/+57
2023-02-03Auto merge of #107569 - petrochenkov:optattr, r=nnethercotebors-3/+2
ast: Optimize list and value extraction primitives for attributes It's not necessary to convert the whole attribute into a meta item to extract something specific.
2023-02-02Rollup merge of #107515 - Swatinem:hirvalidator, r=compiler-errorsMatthias Krüger-25/+14
Improve pretty-printing of `HirIdValidator` errors This now uses `node_to_string` for both missing and seen Ids, which includes the snippet of code for which the Id was allocated. Also removes the duplicated printing of `HirId`, as `node_to_string` also includes that.
2023-02-01Improve pretty-printing of `HirIdValidator` errorsArpad Borsos-25/+14
This now uses `node_to_string` for both missing and seen Ids, which includes the snippet of code for which the Id was allocated. Also removes the duplicated printing of `HirId`, as `node_to_string` includes that already. Similarly, changes all other users of `node_to_string` that do so, and changes the output of `node_to_string`, which is now "$hirid ($what `$span` in $path)".
2023-02-01ast: Optimize list and value extraction primitives for attributesVadim Petrochenkov-3/+2
It's not necessary to convert the whole attribute into a meta item to extract something specific
2023-02-01Auto merge of #107257 - inquisitivecrystal:ffi-attr, r=davidtwcobors-0/+63
Strengthen validation of FFI attributes Previously, `codegen_attrs` validated the attributes `#[ffi_pure]`, `#[ffi_const]`, and `#[ffi_returns_twice]` to make sure that they were only used on foreign functions. However, this validation was insufficient in two ways: 1. `codegen_attrs` only sees items for which code must be generated, so it was unable to raise errors when the attribute was incorrectly applied to macros and the like. 2. the validation code only checked that the item with the attr was foreign, but not that it was a foreign function, allowing these attributes to be applied to foreign statics as well. This PR moves the validation to `check_attr`, which sees all items. It additionally changes the validation to ensure that the attribute's target is `Target::ForeignFunction`, only allowing the attributes on foreign functions and not foreign statics. Because these attributes are unstable, there is no risk for backwards compatibility. The changes also ending up making the code much easier to read. This PR is best reviewed commit by commit. Additionally, I was considering moving the tests to the `attribute` subdirectory, to get them out of the general UI directory. I could do that as part of this PR or a follow-up, as the reviewer prefers. CC: #58328, #58329
2023-01-31Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obkGuillaume Gomez-27/+33
Improve enum checks Some light refactoring.
2023-01-31Auto merge of #100754 - davidtwco:translation-incremental, r=compiler-errorsbors-2/+9
incremental: migrate diagnostics - Apply the diagnostic migration lints to more functions on `Session`, namely: `span_warn`, `span_warn_with_code`, `warn` `note_without_error`, `span_note_without_error`, `struct_note_without_error`. - Add impls of `IntoDiagnosticArg` for `std::io::Error`, `std::path::Path` and `std::path::PathBuf`. - Migrate the `rustc_incremental` crate's diagnostics to translatable diagnostic structs. r? `@compiler-errors` cc #100717
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-2/+9
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30Replace some `_ == _ || _ == _`s with `matches!(_, _ | _)`sMaybe Waffle-1/+1
2023-01-30Replace enum `==`s with `match`es where it makes senseMaybe Waffle-26/+32
2023-01-30Consider `#[allow(dead_code)]` before lang itemsMaybe Waffle-2/+2
2023-01-30Split `has_allow_dead_code_or_lang_attr` into sub functionsMaybe Waffle-16/+18
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-41/+33
2023-01-28Take a LocalDefId in hir::Visitor::visit_fn.Camille GILLOT-1/+2
2023-01-26fixup new usages of fn_sig, bound_fn_sig after rebasingKyle Matsuda-1/+2
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-2/+2
Move format_args!() into AST (and expand it during AST lowering) Implements https://github.com/rust-lang/compiler-team/issues/541 This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier. This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`. This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-26Rollup merge of #106407 - mejrs:attr_check, r=compiler-errorsMatthias Krüger-6/+190
Improve proc macro attribute diagnostics Closes https://github.com/rust-lang/rust/issues/102923
2023-01-24Make sure FFI attrs aren't used on foreign staticsinquisitivecrystal-9/+9
Previously, we verified that FFI attrs were used on foreign items, but this allowed them on both foreign functions and foreign statics. This change only allows them on foreign functions.
2023-01-24Move FFI attribute validation to `check_attr`inquisitivecrystal-0/+63