Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #120662

Closed
wants to merge 34 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4272f1b
get rid of nontrivial_structural_match lint and custom_eq const qualif
RalfJung Jan 27, 2024
32e4862
show indirect_structural_match and pointer_structural_match in future…
RalfJung Jan 27, 2024
0808691
update the tracking issue for structural match violations
RalfJung Jan 27, 2024
efbfb04
merge the accepted-structural-match tests into one
RalfJung Jan 28, 2024
c367983
Suggest name value cfg when only value is used for check-cfg
chenyukang Jan 28, 2024
0213c87
limit the names_possiblilities to less than 3
chenyukang Jan 30, 2024
ca243e7
add testcase for more than 3 cfg names
chenyukang Jan 30, 2024
d34b0fa
Add test for method on unbounded type parameter receiver
estebank Jan 26, 2024
20b1c2a
Account for unbounded type param receiver in suggestions
estebank Jan 26, 2024
9ccc770
fix rebase
estebank Jan 30, 2024
5c41409
Account for non-overlapping unmet trait bounds in suggestion
estebank Jan 30, 2024
0f55e1b
Simplify `impl_zeroable_primitive` macro.
reitermarkus Jan 31, 2024
a5042de
Make `NonZero` constructors generic.
reitermarkus Jan 22, 2024
3cc601a
Switch OwnedStore handle count to AtomicU32
GnomedDev Jan 31, 2024
a2a3c61
Already poison the `type_of` result of the anon const used in the `ty…
oli-obk Feb 1, 2024
009f970
inline a function that is only used in clippy
oli-obk Feb 1, 2024
0c4d089
Taint borrowck results without running any borrowck if the MIR body w…
oli-obk Feb 1, 2024
0f3976b
Continue to borrowck even if there were previous errors
oli-obk Feb 1, 2024
e8c3cbf
Make `Diagnostic::is_error` return false for `Level::FailureNote`.
nnethercote Jan 30, 2024
5dd0431
Tighten the assertion in `downgrade_to_delayed_bug`.
nnethercote Jan 31, 2024
c367386
Refactor `emit_diagnostic`.
nnethercote Jan 31, 2024
59e0bc2
Split `Level::DelayedBug` in two.
nnethercote Jan 31, 2024
6fb1566
Simplify codegen diagnostic handling.
nnethercote Feb 2, 2024
4c038bd
Remove `SharedEmitterMessage::AbortIfErrors`.
nnethercote Feb 2, 2024
f4dce1e
Make `Emitter::emit_diagnostic` consuming.
nnethercote Feb 2, 2024
93fb121
Rollup merge of #120396 - estebank:method-on-unbounded-type-param, r=…
matthiaskrgr Feb 5, 2024
36ff82b
Rollup merge of #120423 - RalfJung:indirect-structural-match, r=petro…
matthiaskrgr Feb 5, 2024
f42ce1b
Rollup merge of #120435 - chenyukang:yukang-fix-120427-cfg-name, r=Ur…
matthiaskrgr Feb 5, 2024
92ec67d
Rollup merge of #120507 - estebank:issue-108428, r=davidtwco
matthiaskrgr Feb 5, 2024
3c9f069
Rollup merge of #120520 - nnethercote:rename-good-path, r=oli-obk
matthiaskrgr Feb 5, 2024
25ffdcc
Rollup merge of #120521 - reitermarkus:generic-nonzero-constructors, …
matthiaskrgr Feb 5, 2024
cc48aae
Rollup merge of #120527 - GnomedDev:atomicu32-handle, r=petrochenkov
matthiaskrgr Feb 5, 2024
635d820
Rollup merge of #120550 - oli-obk:track_errors8, r=estebank
matthiaskrgr Feb 5, 2024
c28b4a0
Rollup merge of #120575 - nnethercote:simplify-codegen-diag-handling,…
matthiaskrgr Feb 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Already poison the type_of result of the anon const used in the `ty…
…peof` expression
  • Loading branch information
oli-obk committed Feb 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a2a3c6107cbb501e525df5020e13dfdcff8304fa
22 changes: 4 additions & 18 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use crate::astconv::errors::prohibit_assoc_ty_binding;
use crate::astconv::generics::{check_generic_arg_count, create_args_for_parent_generic_args};
use crate::bounds::Bounds;
use crate::collect::HirPlaceholderCollector;
use crate::errors::{AmbiguousLifetimeBound, TypeofReservedKeywordUsed};
use crate::errors::AmbiguousLifetimeBound;
use crate::middle::resolve_bound_vars as rbv;
use crate::require_c_abi_if_c_variadic;
use rustc_ast::TraitObjectSyntax;
@@ -30,8 +30,8 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::ObligationCause;
use rustc_middle::middle::stability::AllowUnstable;
use rustc_middle::ty::{
self, Const, GenericArgKind, GenericArgsRef, GenericParamDefKind, IsSuggestable, ParamEnv, Ty,
TyCtxt, TypeVisitableExt,
self, Const, GenericArgKind, GenericArgsRef, GenericParamDefKind, ParamEnv, Ty, TyCtxt,
TypeVisitableExt,
};
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc_span::edit_distance::find_best_match_for_name;
@@ -2537,21 +2537,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {

Ty::new_array_with_const_len(tcx, self.ast_ty_to_ty(ty), length)
}
hir::TyKind::Typeof(e) => {
let ty_erased = tcx.type_of(e.def_id).instantiate_identity();
let ty = tcx.fold_regions(ty_erased, |r, _| {
if r.is_erased() { tcx.lifetimes.re_static } else { r }
});
let span = ast_ty.span;
let (ty, opt_sugg) = if let Some(ty) = ty.make_suggestable(tcx, false) {
(ty, Some((span, Applicability::MachineApplicable)))
} else {
(ty, None)
};
tcx.dcx().emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });

ty
}
hir::TyKind::Typeof(e) => tcx.type_of(e.def_id).instantiate_identity(),
hir::TyKind::Infer => {
// Infer also appears as the type of arguments or return
// values in an ExprKind::Closure, or as
16 changes: 14 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ use rustc_middle::ty::{self, ImplTraitInTraitData, IsSuggestable, Ty, TyCtxt, Ty
use rustc_span::symbol::Ident;
use rustc_span::{Span, DUMMY_SP};

use crate::errors::TypeofReservedKeywordUsed;

use super::bad_placeholder;
use super::ItemCtxt;
pub use opaque::test_opaque_hidden_types;
@@ -39,8 +41,18 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
{
return tcx.types.usize;
}
Node::Ty(&hir::Ty { kind: TyKind::Typeof(ref e), .. }) if e.hir_id == hir_id => {
return tcx.typeck(def_id).node_type(e.hir_id);
Node::Ty(&hir::Ty { kind: TyKind::Typeof(ref e), span, .. }) if e.hir_id == hir_id => {
let ty = tcx.typeck(def_id).node_type(e.hir_id);
let ty = tcx.fold_regions(ty, |r, _| {
if r.is_erased() { ty::Region::new_error_misc(tcx) } else { r }
});
let (ty, opt_sugg) = if let Some(ty) = ty.make_suggestable(tcx, false) {
(ty, Some((span, Applicability::MachineApplicable)))
} else {
(ty, None)
};
tcx.dcx().emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });
return ty;
}
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
4 changes: 2 additions & 2 deletions tests/rustdoc-ui/issues/issue-102986.stderr
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ LL | y: (typeof("hey"),),
|
help: consider replacing `typeof(...)` with an actual type
|
LL | y: (&'static str,),
| ~~~~~~~~~~~~
LL | y: (&str,),
| ~~~~

error: aborting due to 1 previous error