| author | bors <bors@rust-lang.org> 2025-04-02 14:17:11 UTC |
| committer | bors <bors@rust-lang.org> 2025-04-02 14:17:11 UTC |
| log | 4f0de4c81d80121ac7b576bc68d8016064f4d261 |
| tree | 42b49e29b715aee68185f5fd028d62632e0d1b8d |
| parent | ae9173d7dd4a31806c950c90dcc331f1508b4d17 |
| parent | abcfc3e39055ffa03ee03dd2ab7b0887656f8292 |
Rollup of 5 pull requests
Successful merges:
- #139178 (Remove cjgillot from automated review assignment)
- #139184 (Add unstable `--print=crate-root-lint-levels`)
- #139215 (Add `opt-level = "s"` for more std symbolication crates)
- #139232 (Move methods from `Map` to `TyCtxt`, part 5.)
- #139239 (Remove `aux_build` run-make rustc helpers)
r? `@ghost`
`@rustbot` modify labels: rollup96 files changed, 397 insertions(+), 238 deletions(-)
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs+1-1| ... | ... | @@ -1364,7 +1364,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { |
| 1364 | 1364 | } |
| 1365 | 1365 | // Try to find predicates on *generic params* that would allow copying `ty` |
| 1366 | 1366 | let mut suggestion = |
| 1367 | if let Some(symbol) = tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1367 | if let Some(symbol) = tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1368 | 1368 | format!(": {symbol}.clone()") |
| 1369 | 1369 | } else { |
| 1370 | 1370 | ".clone()".to_owned() |
compiler/rustc_borrowck/src/diagnostics/move_errors.rs+1-1| ... | ... | @@ -502,7 +502,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { |
| 502 | 502 | let upvar = &self.upvars[upvar_field.unwrap().index()]; |
| 503 | 503 | let upvar_hir_id = upvar.get_root_variable(); |
| 504 | 504 | let upvar_name = upvar.to_string(tcx); |
| 505 | let upvar_span = tcx.hir().span(upvar_hir_id); | |
| 505 | let upvar_span = tcx.hir_span(upvar_hir_id); | |
| 506 | 506 | |
| 507 | 507 | let place_name = self.describe_any_place(move_place.as_ref()); |
| 508 | 508 |
compiler/rustc_borrowck/src/diagnostics/region_errors.rs+1-1| ... | ... | @@ -628,7 +628,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { |
| 628 | 628 | |
| 629 | 629 | if let Some(def_hir) = defined_hir { |
| 630 | 630 | let upvars_map = self.infcx.tcx.upvars_mentioned(def_id).unwrap(); |
| 631 | let upvar_def_span = self.infcx.tcx.hir().span(def_hir); | |
| 631 | let upvar_def_span = self.infcx.tcx.hir_span(def_hir); | |
| 632 | 632 | let upvar_span = upvars_map.get(&def_hir).unwrap().span; |
| 633 | 633 | diag.subdiagnostic(VarHereDenote::Defined { span: upvar_def_span }); |
| 634 | 634 | diag.subdiagnostic(VarHereDenote::Captured { span: upvar_span }); |
compiler/rustc_borrowck/src/diagnostics/region_name.rs+2-2| ... | ... | @@ -291,7 +291,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { |
| 291 | 291 | match *error_region { |
| 292 | 292 | ty::ReEarlyParam(ebr) => ebr.has_name().then(|| { |
| 293 | 293 | let def_id = tcx.generics_of(self.mir_def_id()).region_param(ebr, tcx).def_id; |
| 294 | let span = tcx.hir().span_if_local(def_id).unwrap_or(DUMMY_SP); | |
| 294 | let span = tcx.hir_span_if_local(def_id).unwrap_or(DUMMY_SP); | |
| 295 | 295 | RegionName { name: ebr.name, source: RegionNameSource::NamedEarlyParamRegion(span) } |
| 296 | 296 | }), |
| 297 | 297 | |
| ... | ... | @@ -302,7 +302,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { |
| 302 | 302 | ty::ReLateParam(late_param) => match late_param.kind { |
| 303 | 303 | ty::LateParamRegionKind::Named(region_def_id, name) => { |
| 304 | 304 | // Get the span to point to, even if we don't use the name. |
| 305 | let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP); | |
| 305 | let span = tcx.hir_span_if_local(region_def_id).unwrap_or(DUMMY_SP); | |
| 306 | 306 | debug!( |
| 307 | 307 | "bound region named: {:?}, is_named: {:?}", |
| 308 | 308 | name, |
compiler/rustc_borrowck/src/diagnostics/var_name.rs+1-1| ... | ... | @@ -70,7 +70,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { |
| 70 | 70 | debug!("get_upvar_name_and_span_for_region: upvar_hir_id={upvar_hir_id:?}"); |
| 71 | 71 | |
| 72 | 72 | let upvar_name = tcx.hir_name(upvar_hir_id); |
| 73 | let upvar_span = tcx.hir().span(upvar_hir_id); | |
| 73 | let upvar_span = tcx.hir_span(upvar_hir_id); | |
| 74 | 74 | debug!( |
| 75 | 75 | "get_upvar_name_and_span_for_region: upvar_name={upvar_name:?} upvar_span={upvar_span:?}", |
| 76 | 76 | ); |
compiler/rustc_const_eval/src/const_eval/valtrees.rs+1-1| ... | ... | @@ -256,7 +256,7 @@ pub(crate) fn eval_to_valtree<'tcx>( |
| 256 | 256 | Err(err) => { |
| 257 | 257 | let did = cid.instance.def_id(); |
| 258 | 258 | let global_const_id = cid.display(tcx); |
| 259 | let span = tcx.hir().span_if_local(did); | |
| 259 | let span = tcx.hir_span_if_local(did); | |
| 260 | 260 | match err { |
| 261 | 261 | ValTreeCreationError::NodesOverflow => { |
| 262 | 262 | let handled = |
compiler/rustc_driver_impl/src/lib.rs+28| ... | ... | @@ -691,6 +691,34 @@ fn print_crate_info( |
| 691 | 691 | }; |
| 692 | 692 | println_info!("{}", passes::get_crate_name(sess, attrs)); |
| 693 | 693 | } |
| 694 | CrateRootLintLevels => { | |
| 695 | let Some(attrs) = attrs.as_ref() else { | |
| 696 | // no crate attributes, print out an error and exit | |
| 697 | return Compilation::Continue; | |
| 698 | }; | |
| 699 | let crate_name = passes::get_crate_name(sess, attrs); | |
| 700 | let lint_store = crate::unerased_lint_store(sess); | |
| 701 | let registered_tools = rustc_resolve::registered_tools_ast(sess.dcx(), attrs); | |
| 702 | let features = rustc_expand::config::features(sess, attrs, crate_name); | |
| 703 | let lint_levels = rustc_lint::LintLevelsBuilder::crate_root( | |
| 704 | sess, | |
| 705 | &features, | |
| 706 | true, | |
| 707 | lint_store, | |
| 708 | &registered_tools, | |
| 709 | attrs, | |
| 710 | ); | |
| 711 | for lint in lint_store.get_lints() { | |
| 712 | if let Some(feature_symbol) = lint.feature_gate | |
| 713 | && !features.enabled(feature_symbol) | |
| 714 | { | |
| 715 | // lint is unstable and feature gate isn't active, don't print | |
| 716 | continue; | |
| 717 | } | |
| 718 | let level = lint_levels.lint_level(lint).0; | |
| 719 | println_info!("{}={}", lint.name_lower(), level.as_str()); | |
| 720 | } | |
| 721 | } | |
| 694 | 722 | Cfg => { |
| 695 | 723 | let mut cfgs = sess |
| 696 | 724 | .psess |
compiler/rustc_hir/src/hir.rs+1-1| ... | ... | @@ -2123,7 +2123,7 @@ pub type Lit = Spanned<LitKind>; |
| 2123 | 2123 | /// explicit discriminant values for enum variants. |
| 2124 | 2124 | /// |
| 2125 | 2125 | /// You can check if this anon const is a default in a const param |
| 2126 | /// `const N: usize = { ... }` with `tcx.hir().opt_const_param_default_param_def_id(..)` | |
| 2126 | /// `const N: usize = { ... }` with `tcx.hir_opt_const_param_default_param_def_id(..)` | |
| 2127 | 2127 | #[derive(Copy, Clone, Debug, HashStable_Generic)] |
| 2128 | 2128 | pub struct AnonConst { |
| 2129 | 2129 | #[stable_hasher(ignore)] |
compiler/rustc_hir_analysis/src/check/check.rs+5-7| ... | ... | @@ -578,10 +578,8 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe |
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | 580 | _ => { |
| 581 | tcx.dcx().span_delayed_bug( | |
| 582 | tcx.hir().span(hir_id), | |
| 583 | "parameter should have been resolved", | |
| 584 | ); | |
| 581 | tcx.dcx() | |
| 582 | .span_delayed_bug(tcx.hir_span(hir_id), "parameter should have been resolved"); | |
| 585 | 583 | } |
| 586 | 584 | } |
| 587 | 585 | } |
| ... | ... | @@ -1049,7 +1047,7 @@ fn check_impl_items_against_trait<'tcx>( |
| 1049 | 1047 | leaf_def.as_ref().is_some_and(|node_item| !node_item.defining_node.is_from_trait()); |
| 1050 | 1048 | |
| 1051 | 1049 | if !is_implemented_here { |
| 1052 | let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id)); | |
| 1050 | let full_impl_span = tcx.hir_span_with_body(tcx.local_def_id_to_hir_id(impl_id)); | |
| 1053 | 1051 | match tcx.eval_default_body_stability(trait_item_id, full_impl_span) { |
| 1054 | 1052 | EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable( |
| 1055 | 1053 | tcx, |
| ... | ... | @@ -1105,7 +1103,7 @@ fn check_impl_items_against_trait<'tcx>( |
| 1105 | 1103 | } |
| 1106 | 1104 | |
| 1107 | 1105 | if !missing_items.is_empty() { |
| 1108 | let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id)); | |
| 1106 | let full_impl_span = tcx.hir_span_with_body(tcx.local_def_id_to_hir_id(impl_id)); | |
| 1109 | 1107 | missing_items_err(tcx, impl_id, &missing_items, full_impl_span); |
| 1110 | 1108 | } |
| 1111 | 1109 | |
| ... | ... | @@ -1321,7 +1319,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) |
| 1321 | 1319 | let typing_env = ty::TypingEnv::non_body_analysis(tcx, field.did); |
| 1322 | 1320 | let layout = tcx.layout_of(typing_env.as_query_input(ty)); |
| 1323 | 1321 | // We are currently checking the type this field came from, so it must be local |
| 1324 | let span = tcx.hir().span_if_local(field.did).unwrap(); | |
| 1322 | let span = tcx.hir_span_if_local(field.did).unwrap(); | |
| 1325 | 1323 | let trivial = layout.is_ok_and(|layout| layout.is_1zst()); |
| 1326 | 1324 | if !trivial { |
| 1327 | 1325 | return (span, trivial, None); |
compiler/rustc_hir_analysis/src/check/compare_impl_item.rs+6-6| ... | ... | @@ -1208,7 +1208,7 @@ fn extract_spans_for_error_reporting<'tcx>( |
| 1208 | 1208 | TypeError::ArgumentMutability(i) | TypeError::ArgumentSorts(ExpectedFound { .. }, i) => { |
| 1209 | 1209 | (impl_args.nth(i).unwrap(), trait_args.and_then(|mut args| args.nth(i))) |
| 1210 | 1210 | } |
| 1211 | _ => (cause.span, tcx.hir().span_if_local(trait_m.def_id)), | |
| 1211 | _ => (cause.span, tcx.hir_span_if_local(trait_m.def_id)), | |
| 1212 | 1212 | } |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| ... | ... | @@ -1261,7 +1261,7 @@ fn compare_self_type<'tcx>( |
| 1261 | 1261 | self_descr |
| 1262 | 1262 | ); |
| 1263 | 1263 | err.span_label(impl_m_span, format!("`{self_descr}` used in impl")); |
| 1264 | if let Some(span) = tcx.hir().span_if_local(trait_m.def_id) { | |
| 1264 | if let Some(span) = tcx.hir_span_if_local(trait_m.def_id) { | |
| 1265 | 1265 | err.span_label(span, format!("trait method declared without `{self_descr}`")); |
| 1266 | 1266 | } else { |
| 1267 | 1267 | err.note_trait_signature(trait_m.name, trait_m.signature(tcx)); |
| ... | ... | @@ -1281,7 +1281,7 @@ fn compare_self_type<'tcx>( |
| 1281 | 1281 | self_descr |
| 1282 | 1282 | ); |
| 1283 | 1283 | err.span_label(impl_m_span, format!("expected `{self_descr}` in impl")); |
| 1284 | if let Some(span) = tcx.hir().span_if_local(trait_m.def_id) { | |
| 1284 | if let Some(span) = tcx.hir_span_if_local(trait_m.def_id) { | |
| 1285 | 1285 | err.span_label(span, format!("`{self_descr}` used in trait")); |
| 1286 | 1286 | } else { |
| 1287 | 1287 | err.note_trait_signature(trait_m.name, trait_m.signature(tcx)); |
| ... | ... | @@ -1389,7 +1389,7 @@ fn compare_number_of_generics<'tcx>( |
| 1389 | 1389 | .collect(); |
| 1390 | 1390 | (Some(arg_spans), impl_trait_spans) |
| 1391 | 1391 | } else { |
| 1392 | let trait_span = tcx.hir().span_if_local(trait_.def_id); | |
| 1392 | let trait_span = tcx.hir_span_if_local(trait_.def_id); | |
| 1393 | 1393 | (trait_span.map(|s| vec![s]), vec![]) |
| 1394 | 1394 | }; |
| 1395 | 1395 | |
| ... | ... | @@ -1481,7 +1481,7 @@ fn compare_number_of_method_arguments<'tcx>( |
| 1481 | 1481 | } |
| 1482 | 1482 | }) |
| 1483 | 1483 | }) |
| 1484 | .or_else(|| tcx.hir().span_if_local(trait_m.def_id)); | |
| 1484 | .or_else(|| tcx.hir_span_if_local(trait_m.def_id)); | |
| 1485 | 1485 | |
| 1486 | 1486 | let (impl_m_sig, _) = &tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).expect_fn(); |
| 1487 | 1487 | let pos = impl_number_args.saturating_sub(1); |
| ... | ... | @@ -2366,7 +2366,7 @@ fn try_report_async_mismatch<'tcx>( |
| 2366 | 2366 | return Err(tcx.sess.dcx().emit_err(MethodShouldReturnFuture { |
| 2367 | 2367 | span: tcx.def_span(impl_m.def_id), |
| 2368 | 2368 | method_name: tcx.item_ident(impl_m.def_id), |
| 2369 | trait_item_span: tcx.hir().span_if_local(trait_m.def_id), | |
| 2369 | trait_item_span: tcx.hir_span_if_local(trait_m.def_id), | |
| 2370 | 2370 | })); |
| 2371 | 2371 | } |
| 2372 | 2372 | } |
compiler/rustc_hir_analysis/src/check/mod.rs+2-2| ... | ... | @@ -243,7 +243,7 @@ fn missing_items_err( |
| 243 | 243 | tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity(), |
| 244 | 244 | )); |
| 245 | 245 | let code = format!("{padding}{snippet}\n{padding}"); |
| 246 | if let Some(span) = tcx.hir().span_if_local(trait_item.def_id) { | |
| 246 | if let Some(span) = tcx.hir_span_if_local(trait_item.def_id) { | |
| 247 | 247 | missing_trait_item_label |
| 248 | 248 | .push(errors::MissingTraitItemLabel { span, item: trait_item.name }); |
| 249 | 249 | missing_trait_item.push(errors::MissingTraitItemSuggestion { |
| ... | ... | @@ -534,7 +534,7 @@ fn bad_variant_count<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>, sp: Span, d |
| 534 | 534 | let variant_spans: Vec<_> = adt |
| 535 | 535 | .variants() |
| 536 | 536 | .iter() |
| 537 | .map(|variant| tcx.hir().span_if_local(variant.def_id).unwrap()) | |
| 537 | .map(|variant| tcx.hir_span_if_local(variant.def_id).unwrap()) | |
| 538 | 538 | .collect(); |
| 539 | 539 | let (mut spans, mut many) = (Vec::new(), None); |
| 540 | 540 | if let [start @ .., end] = &*variant_spans { |
compiler/rustc_hir_analysis/src/collect/generics_of.rs+1-2| ... | ... | @@ -116,8 +116,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { |
| 116 | 116 | { |
| 117 | 117 | // enum variant discriminants are not allowed to use any kind of generics |
| 118 | 118 | None |
| 119 | } else if let Some(param_id) = | |
| 120 | tcx.hir().opt_const_param_default_param_def_id(hir_id) | |
| 119 | } else if let Some(param_id) = tcx.hir_opt_const_param_default_param_def_id(hir_id) | |
| 121 | 120 | { |
| 122 | 121 | // If the def_id we are calling generics_of on is an anon ct default i.e: |
| 123 | 122 | // |
compiler/rustc_hir_analysis/src/collect/predicates_of.rs+1-1| ... | ... | @@ -508,7 +508,7 @@ pub(super) fn explicit_predicates_of<'tcx>( |
| 508 | 508 | if matches!(def_kind, DefKind::AnonConst) |
| 509 | 509 | && tcx.features().generic_const_exprs() |
| 510 | 510 | && let Some(defaulted_param_def_id) = |
| 511 | tcx.hir().opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id)) | |
| 511 | tcx.hir_opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id)) | |
| 512 | 512 | { |
| 513 | 513 | // In `generics_of` we set the generics' parent to be our parent's parent which means that |
| 514 | 514 | // we lose out on the predicates of our actual parent if we dont return those predicates here. |
compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs+4-4| ... | ... | @@ -1529,7 +1529,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { |
| 1529 | 1529 | if let ResolvedArg::LateBound(..) = def |
| 1530 | 1530 | && let Some(what) = crossed_late_boundary |
| 1531 | 1531 | { |
| 1532 | let use_span = self.tcx.hir().span(hir_id); | |
| 1532 | let use_span = self.tcx.hir_span(hir_id); | |
| 1533 | 1533 | let def_span = self.tcx.def_span(param_def_id); |
| 1534 | 1534 | let guar = match self.tcx.def_kind(param_def_id) { |
| 1535 | 1535 | DefKind::ConstParam => { |
| ... | ... | @@ -1576,11 +1576,11 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { |
| 1576 | 1576 | } => { |
| 1577 | 1577 | let guar = self.tcx.dcx().emit_err(match self.tcx.def_kind(param_def_id) { |
| 1578 | 1578 | DefKind::TyParam => errors::LateBoundInApit::Type { |
| 1579 | span: self.tcx.hir().span(hir_id), | |
| 1579 | span: self.tcx.hir_span(hir_id), | |
| 1580 | 1580 | param_span: self.tcx.def_span(param_def_id), |
| 1581 | 1581 | }, |
| 1582 | 1582 | DefKind::ConstParam => errors::LateBoundInApit::Const { |
| 1583 | span: self.tcx.hir().span(hir_id), | |
| 1583 | span: self.tcx.hir_span(hir_id), | |
| 1584 | 1584 | param_span: self.tcx.def_span(param_def_id), |
| 1585 | 1585 | }, |
| 1586 | 1586 | kind => { |
| ... | ... | @@ -1605,7 +1605,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { |
| 1605 | 1605 | |
| 1606 | 1606 | self.tcx |
| 1607 | 1607 | .dcx() |
| 1608 | .span_bug(self.tcx.hir().span(hir_id), format!("could not resolve {param_def_id:?}")); | |
| 1608 | .span_bug(self.tcx.hir_span(hir_id), format!("could not resolve {param_def_id:?}")); | |
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | 1611 | #[instrument(level = "debug", skip(self))] |
compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs+1-1| ... | ... | @@ -684,7 +684,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 684 | 684 | return Err(self.dcx().emit_err(crate::errors::ReturnTypeNotationOnNonRpitit { |
| 685 | 685 | span: path_span, |
| 686 | 686 | ty: tcx.liberate_late_bound_regions(item_def_id, output), |
| 687 | fn_span: tcx.hir().span_if_local(item_def_id), | |
| 687 | fn_span: tcx.hir_span_if_local(item_def_id), | |
| 688 | 688 | note: (), |
| 689 | 689 | })); |
| 690 | 690 | }; |
compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs+1-1| ... | ... | @@ -32,7 +32,7 @@ pub(crate) fn validate_cmse_abi<'tcx>( |
| 32 | 32 | span, |
| 33 | 33 | .. |
| 34 | 34 | }) => *span, |
| 35 | _ => tcx.hir().span(hir_id), | |
| 35 | _ => tcx.hir_span(hir_id), | |
| 36 | 36 | }; |
| 37 | 37 | struct_span_code_err!( |
| 38 | 38 | tcx.dcx(), |
compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs+2-2| ... | ... | @@ -882,7 +882,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 882 | 882 | |
| 883 | 883 | let rename_message = if is_shadowed { ", consider renaming it" } else { "" }; |
| 884 | 884 | |
| 885 | if let Some(sp) = tcx.hir().span_if_local(item.def_id) { | |
| 885 | if let Some(sp) = tcx.hir_span_if_local(item.def_id) { | |
| 886 | 886 | err.span_label( |
| 887 | 887 | sp, |
| 888 | 888 | format!("`{}{}` defined here{}", prefix, item.name, rename_message), |
| ... | ... | @@ -1381,7 +1381,7 @@ pub(crate) fn fn_trait_to_string( |
| 1381 | 1381 | .find_map(|c| { |
| 1382 | 1382 | if c.ident.name == sym::Output |
| 1383 | 1383 | && let Some(ty) = c.ty() |
| 1384 | && ty.span != tcx.hir().span(trait_segment.hir_id) | |
| 1384 | && ty.span != tcx.hir_span(trait_segment.hir_id) | |
| 1385 | 1385 | { |
| 1386 | 1386 | tcx.sess.source_map().span_to_snippet(ty.span).ok() |
| 1387 | 1387 | } else { |
compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs+1-1| ... | ... | @@ -92,7 +92,7 @@ fn generic_arg_mismatch_err( |
| 92 | 92 | GenericArg::Type(hir::Ty { kind: hir::TyKind::Array(_, len), .. }), |
| 93 | 93 | GenericParamDefKind::Const { .. }, |
| 94 | 94 | ) if tcx.type_of(param.def_id).skip_binder() == tcx.types.usize => { |
| 95 | let snippet = sess.source_map().span_to_snippet(tcx.hir().span(len.hir_id)); | |
| 95 | let snippet = sess.source_map().span_to_snippet(tcx.hir_span(len.hir_id)); | |
| 96 | 96 | if let Ok(snippet) = snippet { |
| 97 | 97 | err.span_suggestion( |
| 98 | 98 | arg.span(), |
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs+2-2| ... | ... | @@ -1066,7 +1066,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 1066 | 1066 | let bound_span = tcx |
| 1067 | 1067 | .associated_items(bound_id) |
| 1068 | 1068 | .find_by_name_and_kind(tcx, assoc_name, assoc_kind, bound_id) |
| 1069 | .and_then(|item| tcx.hir().span_if_local(item.def_id)); | |
| 1069 | .and_then(|item| tcx.hir_span_if_local(item.def_id)); | |
| 1070 | 1070 | |
| 1071 | 1071 | if let Some(bound_span) = bound_span { |
| 1072 | 1072 | err.span_label( |
| ... | ... | @@ -1400,7 +1400,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 1400 | 1400 | ); |
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | if let Some(sp) = tcx.hir().span_if_local(adt_def.did()) { | |
| 1403 | if let Some(sp) = tcx.hir_span_if_local(adt_def.did()) { | |
| 1404 | 1404 | err.span_label(sp, format!("variant `{assoc_ident}` not found here")); |
| 1405 | 1405 | } |
| 1406 | 1406 |
compiler/rustc_hir_analysis/src/hir_wf_check.rs+1-1| ... | ... | @@ -170,7 +170,7 @@ fn diagnostic_hir_wf_check<'tcx>( |
| 170 | 170 | .. |
| 171 | 171 | }) => vec![*ty], |
| 172 | 172 | hir::Node::AnonConst(_) => { |
| 173 | if let Some(const_param_id) = tcx.hir().opt_const_param_default_param_def_id(hir_id) | |
| 173 | if let Some(const_param_id) = tcx.hir_opt_const_param_default_param_def_id(hir_id) | |
| 174 | 174 | && let hir::Node::GenericParam(hir::GenericParam { |
| 175 | 175 | kind: hir::GenericParamKind::Const { ty, .. }, |
| 176 | 176 | .. |
compiler/rustc_hir_analysis/src/outlives/mod.rs+1-1| ... | ... | @@ -25,7 +25,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau |
| 25 | 25 | } |
| 26 | 26 | DefKind::AnonConst if tcx.features().generic_const_exprs() => { |
| 27 | 27 | let id = tcx.local_def_id_to_hir_id(item_def_id); |
| 28 | if tcx.hir().opt_const_param_default_param_def_id(id).is_some() { | |
| 28 | if tcx.hir_opt_const_param_default_param_def_id(id).is_some() { | |
| 29 | 29 | // In `generics_of` we set the generics' parent to be our parent's parent which means that |
| 30 | 30 | // we lose out on the predicates of our actual parent if we dont return those predicates here. |
| 31 | 31 | // (See comment in `generics_of` for more information on why the parent shenanigans is necessary) |
compiler/rustc_hir_typeck/src/callee.rs+2-2| ... | ... | @@ -771,7 +771,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 771 | 771 | format!("this {descr} returns an unsized value `{output_ty}`, so it cannot be called") |
| 772 | 772 | ); |
| 773 | 773 | if let DefIdOrName::DefId(def_id) = maybe_def |
| 774 | && let Some(def_span) = self.tcx.hir().span_if_local(def_id) | |
| 774 | && let Some(def_span) = self.tcx.hir_span_if_local(def_id) | |
| 775 | 775 | { |
| 776 | 776 | err.span_label(def_span, "the callable type is defined here"); |
| 777 | 777 | } |
| ... | ... | @@ -780,7 +780,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | if let Some(span) = self.tcx.hir().res_span(def) { | |
| 783 | if let Some(span) = self.tcx.hir_res_span(def) { | |
| 784 | 784 | let callee_ty = callee_ty.to_string(); |
| 785 | 785 | let label = match (unit_variant, inner_callee_path) { |
| 786 | 786 | (Some((_, kind, path)), _) => { |
compiler/rustc_hir_typeck/src/closure.rs+1-1| ... | ... | @@ -970,7 +970,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 970 | 970 | self.typeck_results.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result); |
| 971 | 971 | |
| 972 | 972 | // Normalize only after registering in `user_provided_sigs`. |
| 973 | self.normalize(self.tcx.hir().span(hir_id), result) | |
| 973 | self.normalize(self.tcx.hir_span(hir_id), result) | |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /// Invoked when we are translating the coroutine that results |
compiler/rustc_hir_typeck/src/demand.rs+2-4| ... | ... | @@ -999,10 +999,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 999 | 999 | let container = with_no_trimmed_paths!(self.tcx.def_path_str(container_id)); |
| 1000 | 1000 | for def_id in pick.import_ids { |
| 1001 | 1001 | let hir_id = self.tcx.local_def_id_to_hir_id(def_id); |
| 1002 | path_span.push_span_label( | |
| 1003 | self.tcx.hir().span(hir_id), | |
| 1004 | format!("`{container}` imported here"), | |
| 1005 | ); | |
| 1002 | path_span | |
| 1003 | .push_span_label(self.tcx.hir_span(hir_id), format!("`{container}` imported here")); | |
| 1006 | 1004 | } |
| 1007 | 1005 | let tail = with_no_trimmed_paths!(match &other_methods_in_scope[..] { |
| 1008 | 1006 | [] => return, |
compiler/rustc_hir_typeck/src/expr.rs+1-1| ... | ... | @@ -3239,7 +3239,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 3239 | 3239 | Some(x) => self.tcx.local_def_id_to_hir_id(x), |
| 3240 | 3240 | None => return, |
| 3241 | 3241 | }; |
| 3242 | let param_span = self.tcx.hir().span(param_hir_id); | |
| 3242 | let param_span = self.tcx.hir_span(param_hir_id); | |
| 3243 | 3243 | let param_name = self.tcx.hir_ty_param_name(param_def_id.expect_local()); |
| 3244 | 3244 | |
| 3245 | 3245 | err.span_label(param_span, format!("type parameter '{param_name}' declared here")); |
compiler/rustc_hir_typeck/src/expr_use_visitor.rs+4-12| ... | ... | @@ -1182,9 +1182,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx |
| 1182 | 1182 | self.cx.error_reported_in_ty(ty)?; |
| 1183 | 1183 | if ty.is_ty_var() { |
| 1184 | 1184 | debug!("resolve_type_vars_or_bug: infer var from {:?}", ty); |
| 1185 | Err(self | |
| 1186 | .cx | |
| 1187 | .report_bug(self.cx.tcx().hir().span(id), "encountered type variable")) | |
| 1185 | Err(self.cx.report_bug(self.cx.tcx().hir_span(id), "encountered type variable")) | |
| 1188 | 1186 | } else { |
| 1189 | 1187 | Ok(ty) |
| 1190 | 1188 | } |
| ... | ... | @@ -1509,10 +1507,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx |
| 1509 | 1507 | if node_ty != place_ty |
| 1510 | 1508 | && self |
| 1511 | 1509 | .cx |
| 1512 | .try_structurally_resolve_type( | |
| 1513 | self.cx.tcx().hir().span(base_place.hir_id), | |
| 1514 | place_ty, | |
| 1515 | ) | |
| 1510 | .try_structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), place_ty) | |
| 1516 | 1511 | .is_impl_trait() |
| 1517 | 1512 | { |
| 1518 | 1513 | projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty }); |
| ... | ... | @@ -1551,17 +1546,14 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx |
| 1551 | 1546 | let base_curr_ty = base_place.place.ty(); |
| 1552 | 1547 | let deref_ty = match self |
| 1553 | 1548 | .cx |
| 1554 | .try_structurally_resolve_type( | |
| 1555 | self.cx.tcx().hir().span(base_place.hir_id), | |
| 1556 | base_curr_ty, | |
| 1557 | ) | |
| 1549 | .try_structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), base_curr_ty) | |
| 1558 | 1550 | .builtin_deref(true) |
| 1559 | 1551 | { |
| 1560 | 1552 | Some(ty) => ty, |
| 1561 | 1553 | None => { |
| 1562 | 1554 | debug!("explicit deref of non-derefable type: {:?}", base_curr_ty); |
| 1563 | 1555 | return Err(self.cx.report_bug( |
| 1564 | self.cx.tcx().hir().span(node), | |
| 1556 | self.cx.tcx().hir_span(node), | |
| 1565 | 1557 | "explicit deref of non-derefable type", |
| 1566 | 1558 | )); |
| 1567 | 1559 | } |
compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs+2-2| ... | ... | @@ -157,7 +157,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 157 | 157 | // Lots of that diagnostics code relies on subtle effects of re-lowering, so we'll |
| 158 | 158 | // let it keep doing that and just ensure that compilation won't succeed. |
| 159 | 159 | self.dcx().span_delayed_bug( |
| 160 | self.tcx.hir().span(id), | |
| 160 | self.tcx.hir_span(id), | |
| 161 | 161 | format!("`{prev}` overridden by `{ty}` for {id:?} in {:?}", self.body_id), |
| 162 | 162 | ); |
| 163 | 163 | } |
| ... | ... | @@ -532,7 +532,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 532 | 532 | let ct = self.lowerer().lower_const_arg(const_arg, feed); |
| 533 | 533 | self.register_wf_obligation( |
| 534 | 534 | ct.into(), |
| 535 | self.tcx.hir().span(const_arg.hir_id), | |
| 535 | self.tcx.hir_span(const_arg.hir_id), | |
| 536 | 536 | ObligationCauseCode::WellFormed(None), |
| 537 | 537 | ); |
| 538 | 538 | ct |
compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs+13-14| ... | ... | @@ -351,7 +351,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 351 | 351 | |
| 352 | 352 | if self.suggest_fn_call(err, expr, found, |output| self.may_coerce(output, expected)) |
| 353 | 353 | && let ty::FnDef(def_id, ..) = *found.kind() |
| 354 | && let Some(sp) = self.tcx.hir().span_if_local(def_id) | |
| 354 | && let Some(sp) = self.tcx.hir_span_if_local(def_id) | |
| 355 | 355 | { |
| 356 | 356 | let name = self.tcx.item_name(def_id); |
| 357 | 357 | let kind = self.tcx.def_kind(def_id); |
| ... | ... | @@ -407,7 +407,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 407 | 407 | vec![(expr.span.shrink_to_hi(), format!(".{}()", conversion_method.name))] |
| 408 | 408 | }; |
| 409 | 409 | let struct_pat_shorthand_field = |
| 410 | self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr); | |
| 410 | self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr); | |
| 411 | 411 | if let Some(name) = struct_pat_shorthand_field { |
| 412 | 412 | sugg.insert(0, (expr.span.shrink_to_lo(), format!("{name}: "))); |
| 413 | 413 | } |
| ... | ... | @@ -449,7 +449,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 449 | 449 | }); |
| 450 | 450 | |
| 451 | 451 | let prefix_wrap = |sugg: &str| { |
| 452 | if let Some(name) = self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 452 | if let Some(name) = self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 453 | 453 | format!(": {}{}", name, sugg) |
| 454 | 454 | } else { |
| 455 | 455 | sugg.to_string() |
| ... | ... | @@ -671,7 +671,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 671 | 671 | } |
| 672 | 672 | _ => { |
| 673 | 673 | let prefix = if let Some(name) = |
| 674 | self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) | |
| 674 | self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) | |
| 675 | 675 | { |
| 676 | 676 | format!("{}: ", name) |
| 677 | 677 | } else { |
| ... | ... | @@ -1153,7 +1153,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1153 | 1153 | }; |
| 1154 | 1154 | if can_return |
| 1155 | 1155 | && let Some(span) = expr.span.find_ancestor_inside( |
| 1156 | self.tcx.hir().span_with_body(self.tcx.local_def_id_to_hir_id(fn_id)), | |
| 1156 | self.tcx.hir_span_with_body(self.tcx.local_def_id_to_hir_id(fn_id)), | |
| 1157 | 1157 | ) |
| 1158 | 1158 | { |
| 1159 | 1159 | // When the expr is in a match arm's body, we shouldn't add semicolon ';' at the end. |
| ... | ... | @@ -1275,7 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1275 | 1275 | ) |
| 1276 | 1276 | .must_apply_modulo_regions() |
| 1277 | 1277 | { |
| 1278 | let suggestion = match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1278 | let suggestion = match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1279 | 1279 | Some(ident) => format!(": {ident}.clone()"), |
| 1280 | 1280 | None => ".clone()".to_string(), |
| 1281 | 1281 | }; |
| ... | ... | @@ -1381,7 +1381,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1381 | 1381 | (span.shrink_to_hi(), ").into()".to_owned()), |
| 1382 | 1382 | ] |
| 1383 | 1383 | }; |
| 1384 | if let Some(name) = self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1384 | if let Some(name) = self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1385 | 1385 | sugg.insert(0, (expr.span.shrink_to_lo(), format!("{}: ", name))); |
| 1386 | 1386 | } |
| 1387 | 1387 | diag.multipart_suggestion( |
| ... | ... | @@ -1436,7 +1436,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1436 | 1436 | return false; |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | let suggestion = match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1439 | let suggestion = match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 1440 | 1440 | Some(ident) => format!(": {ident}.is_some()"), |
| 1441 | 1441 | None => ".is_some()".to_string(), |
| 1442 | 1442 | }; |
| ... | ... | @@ -2032,7 +2032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2032 | 2032 | ) |
| 2033 | 2033 | }; |
| 2034 | 2034 | |
| 2035 | let sugg = match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 2035 | let sugg = match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 2036 | 2036 | Some(ident) => format!(": {ident}{sugg}"), |
| 2037 | 2037 | None => sugg.to_string(), |
| 2038 | 2038 | }; |
| ... | ... | @@ -2289,7 +2289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2289 | 2289 | // Unroll desugaring, to make sure this works for `for` loops etc. |
| 2290 | 2290 | loop { |
| 2291 | 2291 | parent = self.tcx.parent_hir_id(id); |
| 2292 | let parent_span = self.tcx.hir().span(parent); | |
| 2292 | let parent_span = self.tcx.hir_span(parent); | |
| 2293 | 2293 | if parent_span.find_ancestor_inside(expr.span).is_some() { |
| 2294 | 2294 | // The parent node is part of the same span, so is the result of the |
| 2295 | 2295 | // same expansion/desugaring and not the 'real' parent node. |
| ... | ... | @@ -2378,7 +2378,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2378 | 2378 | .collect(); |
| 2379 | 2379 | |
| 2380 | 2380 | let suggestions_for = |variant: &_, ctor_kind, field_name| { |
| 2381 | let prefix = match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 2381 | let prefix = match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 2382 | 2382 | Some(ident) => format!("{ident}: "), |
| 2383 | 2383 | None => String::new(), |
| 2384 | 2384 | }; |
| ... | ... | @@ -2700,8 +2700,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2700 | 2700 | )); |
| 2701 | 2701 | } |
| 2702 | 2702 | |
| 2703 | let prefix = match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) | |
| 2704 | { | |
| 2703 | let prefix = match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 2705 | 2704 | Some(ident) => format!("{ident}: "), |
| 2706 | 2705 | None => String::new(), |
| 2707 | 2706 | }; |
| ... | ... | @@ -2911,7 +2910,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2911 | 2910 | }; |
| 2912 | 2911 | |
| 2913 | 2912 | let prefix = |
| 2914 | match self.tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) { | |
| 2913 | match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) { | |
| 2915 | 2914 | Some(ident) => format!("{ident}: "), |
| 2916 | 2915 | None => String::new(), |
| 2917 | 2916 | }; |
compiler/rustc_hir_typeck/src/intrinsicck.rs+1-1| ... | ... | @@ -45,7 +45,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 45 | 45 | pub(crate) fn check_transmute(&self, from: Ty<'tcx>, to: Ty<'tcx>, hir_id: HirId) { |
| 46 | 46 | let tcx = self.tcx; |
| 47 | 47 | let dl = &tcx.data_layout; |
| 48 | let span = tcx.hir().span(hir_id); | |
| 48 | let span = tcx.hir_span(hir_id); | |
| 49 | 49 | let normalize = |ty| { |
| 50 | 50 | let ty = self.resolve_vars_if_possible(ty); |
| 51 | 51 | if let Ok(ty) = |
compiler/rustc_hir_typeck/src/lib.rs+1-1| ... | ... | @@ -117,7 +117,7 @@ fn typeck_with_inspect<'tcx>( |
| 117 | 117 | |
| 118 | 118 | let id = tcx.local_def_id_to_hir_id(def_id); |
| 119 | 119 | let node = tcx.hir_node(id); |
| 120 | let span = tcx.hir().span(id); | |
| 120 | let span = tcx.hir_span(id); | |
| 121 | 121 | |
| 122 | 122 | // Figure out what primary body this item has. |
| 123 | 123 | let body_id = node.body_id().unwrap_or_else(|| { |
compiler/rustc_hir_typeck/src/method/suggest.rs+4-7| ... | ... | @@ -254,11 +254,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 254 | 254 | item_name |
| 255 | 255 | ); |
| 256 | 256 | err.span_label(item_name.span, format!("private {kind}")); |
| 257 | let sp = self | |
| 258 | .tcx | |
| 259 | .hir() | |
| 260 | .span_if_local(def_id) | |
| 261 | .unwrap_or_else(|| self.tcx.def_span(def_id)); | |
| 257 | let sp = | |
| 258 | self.tcx.hir_span_if_local(def_id).unwrap_or_else(|| self.tcx.def_span(def_id)); | |
| 262 | 259 | err.span_label(sp, format!("private {kind} defined here")); |
| 263 | 260 | if let Some(within_macro_span) = within_macro_span { |
| 264 | 261 | err.span_label(within_macro_span, "due to this macro variable"); |
| ... | ... | @@ -566,7 +563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 566 | 563 | span.push_span_label(sugg_let.span, |
| 567 | 564 | format!("`{rcvr_name}` of type `{self_ty}` that has method `{method_name}` defined earlier here")); |
| 568 | 565 | span.push_span_label( |
| 569 | self.tcx.hir().span(recv_id), | |
| 566 | self.tcx.hir_span(recv_id), | |
| 570 | 567 | format!( |
| 571 | 568 | "earlier `{rcvr_name}` shadowed here with type `{ty_str_reported}`" |
| 572 | 569 | ), |
| ... | ... | @@ -2561,7 +2558,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2561 | 2558 | ExprKind::Path(QPath::Resolved(_, path)) => { |
| 2562 | 2559 | // local binding |
| 2563 | 2560 | if let hir::def::Res::Local(hir_id) = path.res { |
| 2564 | let span = tcx.hir().span(hir_id); | |
| 2561 | let span = tcx.hir_span(hir_id); | |
| 2565 | 2562 | let filename = tcx.sess.source_map().span_to_filename(span); |
| 2566 | 2563 | |
| 2567 | 2564 | let parent_node = self.tcx.parent_hir_node(hir_id); |
compiler/rustc_hir_typeck/src/pat.rs+3-4| ... | ... | @@ -944,10 +944,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 944 | 944 | ) { |
| 945 | 945 | let var_ty = self.local_ty(span, var_id); |
| 946 | 946 | if let Err(mut err) = self.demand_eqtype_pat_diag(span, var_ty, ty, ti) { |
| 947 | let hir = self.tcx.hir(); | |
| 948 | 947 | let var_ty = self.resolve_vars_if_possible(var_ty); |
| 949 | 948 | let msg = format!("first introduced with type `{var_ty}` here"); |
| 950 | err.span_label(hir.span(var_id), msg); | |
| 949 | err.span_label(self.tcx.hir_span(var_id), msg); | |
| 951 | 950 | let in_match = self.tcx.hir_parent_iter(var_id).any(|(_, n)| { |
| 952 | 951 | matches!( |
| 953 | 952 | n, |
| ... | ... | @@ -1255,7 +1254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1255 | 1254 | })) => match self.tcx.hir_node(body_id.hir_id) { |
| 1256 | 1255 | hir::Node::Expr(expr) => { |
| 1257 | 1256 | if hir::is_range_literal(expr) { |
| 1258 | let span = self.tcx.hir().span(body_id.hir_id); | |
| 1257 | let span = self.tcx.hir_span(body_id.hir_id); | |
| 1259 | 1258 | if let Ok(snip) = self.tcx.sess.source_map().span_to_snippet(span) { |
| 1260 | 1259 | e.span_suggestion_verbose( |
| 1261 | 1260 | ident.span, |
| ... | ... | @@ -1286,7 +1285,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1286 | 1285 | pat_ty: Ty<'tcx>, |
| 1287 | 1286 | segments: &'tcx [hir::PathSegment<'tcx>], |
| 1288 | 1287 | ) { |
| 1289 | if let Some(span) = self.tcx.hir().res_span(pat_res) { | |
| 1288 | if let Some(span) = self.tcx.hir_res_span(pat_res) { | |
| 1290 | 1289 | e.span_label(span, format!("{} defined here", res.descr())); |
| 1291 | 1290 | if let [hir::PathSegment { ident, .. }] = &*segments { |
| 1292 | 1291 | e.span_label( |
compiler/rustc_hir_typeck/src/upvar.rs+14-16| ... | ... | @@ -635,7 +635,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 635 | 635 | let (place, capture_kind) = truncate_capture_for_optimization(place, capture_kind); |
| 636 | 636 | |
| 637 | 637 | let usage_span = if let Some(usage_expr) = capture_info.path_expr_id { |
| 638 | self.tcx.hir().span(usage_expr) | |
| 638 | self.tcx.hir_span(usage_expr) | |
| 639 | 639 | } else { |
| 640 | 640 | unreachable!() |
| 641 | 641 | }; |
| ... | ... | @@ -986,7 +986,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 986 | 986 | for lint_note in diagnostics_info.iter() { |
| 987 | 987 | match &lint_note.captures_info { |
| 988 | 988 | UpvarMigrationInfo::CapturingPrecise { source_expr: Some(capture_expr_id), var_name: captured_name } => { |
| 989 | let cause_span = self.tcx.hir().span(*capture_expr_id); | |
| 989 | let cause_span = self.tcx.hir_span(*capture_expr_id); | |
| 990 | 990 | lint.span_label(cause_span, format!("in Rust 2018, this closure captures all of `{}`, but in Rust 2021, it will only capture `{}`", |
| 991 | 991 | self.tcx.hir_name(*var_hir_id), |
| 992 | 992 | captured_name, |
| ... | ... | @@ -1047,13 +1047,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1047 | 1047 | "add a dummy let to cause {migrated_variables_concat} to be fully captured" |
| 1048 | 1048 | ); |
| 1049 | 1049 | |
| 1050 | let closure_span = self.tcx.hir().span_with_body(closure_hir_id); | |
| 1050 | let closure_span = self.tcx.hir_span_with_body(closure_hir_id); | |
| 1051 | 1051 | let mut closure_body_span = { |
| 1052 | 1052 | // If the body was entirely expanded from a macro |
| 1053 | 1053 | // invocation, i.e. the body is not contained inside the |
| 1054 | 1054 | // closure span, then we walk up the expansion until we |
| 1055 | 1055 | // find the span before the expansion. |
| 1056 | let s = self.tcx.hir().span_with_body(body_id.hir_id); | |
| 1056 | let s = self.tcx.hir_span_with_body(body_id.hir_id); | |
| 1057 | 1057 | s.find_ancestor_inside(closure_span).unwrap_or(s) |
| 1058 | 1058 | }; |
| 1059 | 1059 | |
| ... | ... | @@ -1752,8 +1752,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1752 | 1752 | let capture_str = construct_capture_info_string(self.tcx, place, capture_info); |
| 1753 | 1753 | let output_str = format!("Capturing {capture_str}"); |
| 1754 | 1754 | |
| 1755 | let span = | |
| 1756 | capture_info.path_expr_id.map_or(closure_span, |e| self.tcx.hir().span(e)); | |
| 1755 | let span = capture_info.path_expr_id.map_or(closure_span, |e| self.tcx.hir_span(e)); | |
| 1757 | 1756 | diag.span_note(span, output_str); |
| 1758 | 1757 | } |
| 1759 | 1758 | diag.emit(); |
| ... | ... | @@ -1780,10 +1779,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1780 | 1779 | if capture.info.path_expr_id != capture.info.capture_kind_expr_id { |
| 1781 | 1780 | let path_span = capture_info |
| 1782 | 1781 | .path_expr_id |
| 1783 | .map_or(closure_span, |e| self.tcx.hir().span(e)); | |
| 1782 | .map_or(closure_span, |e| self.tcx.hir_span(e)); | |
| 1784 | 1783 | let capture_kind_span = capture_info |
| 1785 | 1784 | .capture_kind_expr_id |
| 1786 | .map_or(closure_span, |e| self.tcx.hir().span(e)); | |
| 1785 | .map_or(closure_span, |e| self.tcx.hir_span(e)); | |
| 1787 | 1786 | |
| 1788 | 1787 | let mut multi_span: MultiSpan = |
| 1789 | 1788 | MultiSpan::from_spans(vec![path_span, capture_kind_span]); |
| ... | ... | @@ -1799,7 +1798,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1799 | 1798 | } else { |
| 1800 | 1799 | let span = capture_info |
| 1801 | 1800 | .path_expr_id |
| 1802 | .map_or(closure_span, |e| self.tcx.hir().span(e)); | |
| 1801 | .map_or(closure_span, |e| self.tcx.hir_span(e)); | |
| 1803 | 1802 | |
| 1804 | 1803 | diag.span_note(span, output_str); |
| 1805 | 1804 | }; |
| ... | ... | @@ -1828,8 +1827,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1828 | 1827 | let mut is_mutbl = bm.1; |
| 1829 | 1828 | |
| 1830 | 1829 | for pointer_ty in place.deref_tys() { |
| 1831 | match self.structurally_resolve_type(self.tcx.hir().span(var_hir_id), pointer_ty).kind() | |
| 1832 | { | |
| 1830 | match self.structurally_resolve_type(self.tcx.hir_span(var_hir_id), pointer_ty).kind() { | |
| 1833 | 1831 | // We don't capture derefs of raw ptrs |
| 1834 | 1832 | ty::RawPtr(_, _) => unreachable!(), |
| 1835 | 1833 | |
| ... | ... | @@ -1844,7 +1842,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1844 | 1842 | ty::Adt(def, ..) if def.is_box() => {} |
| 1845 | 1843 | |
| 1846 | 1844 | unexpected_ty => span_bug!( |
| 1847 | self.tcx.hir().span(var_hir_id), | |
| 1845 | self.tcx.hir_span(var_hir_id), | |
| 1848 | 1846 | "deref of unexpected pointer type {:?}", |
| 1849 | 1847 | unexpected_ty |
| 1850 | 1848 | ), |
| ... | ... | @@ -1975,14 +1973,14 @@ fn drop_location_span(tcx: TyCtxt<'_>, hir_id: HirId) -> Span { |
| 1975 | 1973 | let owner_node = tcx.hir_node(owner_id); |
| 1976 | 1974 | let owner_span = match owner_node { |
| 1977 | 1975 | hir::Node::Item(item) => match item.kind { |
| 1978 | hir::ItemKind::Fn { body: owner_id, .. } => tcx.hir().span(owner_id.hir_id), | |
| 1976 | hir::ItemKind::Fn { body: owner_id, .. } => tcx.hir_span(owner_id.hir_id), | |
| 1979 | 1977 | _ => { |
| 1980 | 1978 | bug!("Drop location span error: need to handle more ItemKind '{:?}'", item.kind); |
| 1981 | 1979 | } |
| 1982 | 1980 | }, |
| 1983 | hir::Node::Block(block) => tcx.hir().span(block.hir_id), | |
| 1984 | hir::Node::TraitItem(item) => tcx.hir().span(item.hir_id()), | |
| 1985 | hir::Node::ImplItem(item) => tcx.hir().span(item.hir_id()), | |
| 1981 | hir::Node::Block(block) => tcx.hir_span(block.hir_id), | |
| 1982 | hir::Node::TraitItem(item) => tcx.hir_span(item.hir_id()), | |
| 1983 | hir::Node::ImplItem(item) => tcx.hir_span(item.hir_id()), | |
| 1986 | 1984 | _ => { |
| 1987 | 1985 | bug!("Drop location span error: need to handle more Node '{:?}'", owner_node); |
| 1988 | 1986 | } |
compiler/rustc_hir_typeck/src/writeback.rs+2-2| ... | ... | @@ -491,7 +491,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { |
| 491 | 491 | |
| 492 | 492 | if let ty::UserTypeKind::TypeOf(_, user_args) = c_ty.value.kind { |
| 493 | 493 | // This is a unit-testing mechanism. |
| 494 | let span = self.tcx().hir().span(hir_id); | |
| 494 | let span = self.tcx().hir_span(hir_id); | |
| 495 | 495 | // We need to buffer the errors in order to guarantee a consistent |
| 496 | 496 | // order when emitting them. |
| 497 | 497 | let err = |
| ... | ... | @@ -775,7 +775,7 @@ impl Locatable for Span { |
| 775 | 775 | |
| 776 | 776 | impl Locatable for HirId { |
| 777 | 777 | fn to_span(&self, tcx: TyCtxt<'_>) -> Span { |
| 778 | tcx.hir().span(*self) | |
| 778 | tcx.hir_span(*self) | |
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 |
compiler/rustc_lint/src/impl_trait_overcaptures.rs+1-1| ... | ... | @@ -392,7 +392,7 @@ where |
| 392 | 392 | } |
| 393 | 393 | _ => { |
| 394 | 394 | self.tcx.dcx().span_delayed_bug( |
| 395 | self.tcx.hir().span(arg.hir_id()), | |
| 395 | self.tcx.hir_span(arg.hir_id()), | |
| 396 | 396 | "no valid for captured arg", |
| 397 | 397 | ); |
| 398 | 398 | } |
compiler/rustc_lint/src/levels.rs+13| ... | ... | @@ -450,6 +450,19 @@ impl<'s> LintLevelsBuilder<'s, TopDown> { |
| 450 | 450 | builder |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | pub fn crate_root( | |
| 454 | sess: &'s Session, | |
| 455 | features: &'s Features, | |
| 456 | lint_added_lints: bool, | |
| 457 | store: &'s LintStore, | |
| 458 | registered_tools: &'s RegisteredTools, | |
| 459 | crate_attrs: &[ast::Attribute], | |
| 460 | ) -> Self { | |
| 461 | let mut builder = Self::new(sess, features, lint_added_lints, store, registered_tools); | |
| 462 | builder.add(crate_attrs, true, None); | |
| 463 | builder | |
| 464 | } | |
| 465 | ||
| 453 | 466 | fn process_command_line(&mut self) { |
| 454 | 467 | self.provider.cur = self |
| 455 | 468 | .provider |
compiler/rustc_lint/src/lib.rs+1| ... | ... | @@ -130,6 +130,7 @@ pub use context::{ |
| 130 | 130 | }; |
| 131 | 131 | pub use early::{EarlyCheckNode, check_ast_node}; |
| 132 | 132 | pub use late::{check_crate, late_lint_mod, unerased_lint_store}; |
| 133 | pub use levels::LintLevelsBuilder; | |
| 133 | 134 | pub use passes::{EarlyLintPass, LateLintPass}; |
| 134 | 135 | pub use rustc_session::lint::Level::{self, *}; |
| 135 | 136 | pub use rustc_session::lint::{ |
compiler/rustc_lint/src/types.rs+1-1| ... | ... | @@ -1403,7 +1403,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { |
| 1403 | 1403 | CItemKind::Definition => "fn", |
| 1404 | 1404 | }; |
| 1405 | 1405 | let span_note = if let ty::Adt(def, _) = ty.kind() |
| 1406 | && let Some(sp) = self.cx.tcx.hir().span_if_local(def.did()) | |
| 1406 | && let Some(sp) = self.cx.tcx.hir_span_if_local(def.did()) | |
| 1407 | 1407 | { |
| 1408 | 1408 | Some(sp) |
| 1409 | 1409 | } else { |
compiler/rustc_metadata/src/rmeta/encoder.rs+1-3| ... | ... | @@ -1890,8 +1890,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { |
| 1890 | 1890 | let is_proc_macro = self.tcx.crate_types().contains(&CrateType::ProcMacro); |
| 1891 | 1891 | if is_proc_macro { |
| 1892 | 1892 | let tcx = self.tcx; |
| 1893 | let hir = tcx.hir(); | |
| 1894 | ||
| 1895 | 1893 | let proc_macro_decls_static = tcx.proc_macro_decls_static(()).unwrap().local_def_index; |
| 1896 | 1894 | let stability = tcx.lookup_stability(CRATE_DEF_ID); |
| 1897 | 1895 | let macros = |
| ... | ... | @@ -1924,7 +1922,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { |
| 1924 | 1922 | let id = proc_macro; |
| 1925 | 1923 | let proc_macro = tcx.local_def_id_to_hir_id(proc_macro); |
| 1926 | 1924 | let mut name = tcx.hir_name(proc_macro); |
| 1927 | let span = hir.span(proc_macro); | |
| 1925 | let span = tcx.hir_span(proc_macro); | |
| 1928 | 1926 | // Proc-macros may have attributes like `#[allow_internal_unstable]`, |
| 1929 | 1927 | // so downstream crates need access to them. |
| 1930 | 1928 | let attrs = tcx.hir_attrs(proc_macro); |
compiler/rustc_middle/src/hir/map.rs+24-26| ... | ... | @@ -22,6 +22,7 @@ use crate::ty::TyCtxt; |
| 22 | 22 | // only serves as "namespace" for HIR-related methods, and can be |
| 23 | 23 | // removed if all the methods are reasonably renamed and moved to tcx |
| 24 | 24 | // (https://github.com/rust-lang/rust/pull/118256#issuecomment-1826442834). |
| 25 | #[allow(unused)] // FIXME: temporary | |
| 25 | 26 | #[derive(Copy, Clone)] |
| 26 | 27 | pub struct Map<'hir> { |
| 27 | 28 | pub(super) tcx: TyCtxt<'hir>, |
| ... | ... | @@ -273,7 +274,7 @@ impl<'tcx> TyCtxt<'tcx> { |
| 273 | 274 | self.hir_maybe_body_owned_by(id).unwrap_or_else(|| { |
| 274 | 275 | let hir_id = self.local_def_id_to_hir_id(id); |
| 275 | 276 | span_bug!( |
| 276 | self.hir().span(hir_id), | |
| 277 | self.hir_span(hir_id), | |
| 277 | 278 | "body_owned_by: {} has no associated body", |
| 278 | 279 | self.hir_id_to_string(hir_id) |
| 279 | 280 | ); |
| ... | ... | @@ -677,9 +678,8 @@ impl<'tcx> TyCtxt<'tcx> { |
| 677 | 678 | pub fn hir_id_to_string(self, id: HirId) -> String { |
| 678 | 679 | let path_str = |def_id: LocalDefId| self.def_path_str(def_id); |
| 679 | 680 | |
| 680 | let span_str = || { | |
| 681 | self.sess.source_map().span_to_snippet(Map { tcx: self }.span(id)).unwrap_or_default() | |
| 682 | }; | |
| 681 | let span_str = | |
| 682 | || self.sess.source_map().span_to_snippet(self.hir_span(id)).unwrap_or_default(); | |
| 683 | 683 | let node_str = |prefix| format!("{id} ({prefix} `{}`)", span_str()); |
| 684 | 684 | |
| 685 | 685 | match self.hir_node(id) { |
| ... | ... | @@ -875,12 +875,10 @@ impl<'tcx> TyCtxt<'tcx> { |
| 875 | 875 | pub fn hir_attrs(self, id: HirId) -> &'tcx [Attribute] { |
| 876 | 876 | self.hir_attr_map(id.owner).get(id.local_id) |
| 877 | 877 | } |
| 878 | } | |
| 879 | 878 | |
| 880 | impl<'hir> Map<'hir> { | |
| 881 | 879 | /// Gets the span of the definition of the specified HIR node. |
| 882 | 880 | /// This is used by `tcx.def_span`. |
| 883 | pub fn span(self, hir_id: HirId) -> Span { | |
| 881 | pub fn hir_span(self, hir_id: HirId) -> Span { | |
| 884 | 882 | fn until_within(outer: Span, end: Span) -> Span { |
| 885 | 883 | if let Some(end) = end.find_ancestor_inside(outer) { |
| 886 | 884 | outer.with_hi(end.hi()) |
| ... | ... | @@ -900,7 +898,7 @@ impl<'hir> Map<'hir> { |
| 900 | 898 | span |
| 901 | 899 | } |
| 902 | 900 | |
| 903 | let span = match self.tcx.hir_node(hir_id) { | |
| 901 | let span = match self.hir_node(hir_id) { | |
| 904 | 902 | // Function-like. |
| 905 | 903 | Node::Item(Item { kind: ItemKind::Fn { sig, .. }, span: outer_span, .. }) |
| 906 | 904 | | Node::TraitItem(TraitItem { |
| ... | ... | @@ -980,7 +978,7 @@ impl<'hir> Map<'hir> { |
| 980 | 978 | Node::Variant(variant) => named_span(variant.span, variant.ident, None), |
| 981 | 979 | Node::ImplItem(item) => named_span(item.span, item.ident, Some(item.generics)), |
| 982 | 980 | Node::ForeignItem(item) => named_span(item.span, item.ident, None), |
| 983 | Node::Ctor(_) => return self.span(self.tcx.parent_hir_id(hir_id)), | |
| 981 | Node::Ctor(_) => return self.hir_span(self.parent_hir_id(hir_id)), | |
| 984 | 982 | Node::Expr(Expr { |
| 985 | 983 | kind: ExprKind::Closure(Closure { fn_decl_span, .. }), |
| 986 | 984 | span, |
| ... | ... | @@ -989,16 +987,16 @@ impl<'hir> Map<'hir> { |
| 989 | 987 | // Ensure that the returned span has the item's SyntaxContext. |
| 990 | 988 | fn_decl_span.find_ancestor_inside(*span).unwrap_or(*span) |
| 991 | 989 | } |
| 992 | _ => self.span_with_body(hir_id), | |
| 990 | _ => self.hir_span_with_body(hir_id), | |
| 993 | 991 | }; |
| 994 | debug_assert_eq!(span.ctxt(), self.span_with_body(hir_id).ctxt()); | |
| 992 | debug_assert_eq!(span.ctxt(), self.hir_span_with_body(hir_id).ctxt()); | |
| 995 | 993 | span |
| 996 | 994 | } |
| 997 | 995 | |
| 998 | /// Like `hir.span()`, but includes the body of items | |
| 996 | /// Like `hir_span()`, but includes the body of items | |
| 999 | 997 | /// (instead of just the item header) |
| 1000 | pub fn span_with_body(self, hir_id: HirId) -> Span { | |
| 1001 | match self.tcx.hir_node(hir_id) { | |
| 998 | pub fn hir_span_with_body(self, hir_id: HirId) -> Span { | |
| 999 | match self.hir_node(hir_id) { | |
| 1002 | 1000 | Node::Param(param) => param.span, |
| 1003 | 1001 | Node::Item(item) => item.span, |
| 1004 | 1002 | Node::ForeignItem(foreign_item) => foreign_item.span, |
| ... | ... | @@ -1007,7 +1005,7 @@ impl<'hir> Map<'hir> { |
| 1007 | 1005 | Node::Variant(variant) => variant.span, |
| 1008 | 1006 | Node::Field(field) => field.span, |
| 1009 | 1007 | Node::AnonConst(constant) => constant.span, |
| 1010 | Node::ConstBlock(constant) => self.tcx.hir_body(constant.body).value.span, | |
| 1008 | Node::ConstBlock(constant) => self.hir_body(constant.body).value.span, | |
| 1011 | 1009 | Node::ConstArg(const_arg) => const_arg.span(), |
| 1012 | 1010 | Node::Expr(expr) => expr.span, |
| 1013 | 1011 | Node::ExprField(field) => field.span, |
| ... | ... | @@ -1027,7 +1025,7 @@ impl<'hir> Map<'hir> { |
| 1027 | 1025 | Node::PatExpr(lit) => lit.span, |
| 1028 | 1026 | Node::Arm(arm) => arm.span, |
| 1029 | 1027 | Node::Block(block) => block.span, |
| 1030 | Node::Ctor(..) => self.span_with_body(self.tcx.parent_hir_id(hir_id)), | |
| 1028 | Node::Ctor(..) => self.hir_span_with_body(self.parent_hir_id(hir_id)), | |
| 1031 | 1029 | Node::Lifetime(lifetime) => lifetime.ident.span, |
| 1032 | 1030 | Node::GenericParam(param) => param.span, |
| 1033 | 1031 | Node::Infer(i) => i.span, |
| ... | ... | @@ -1040,23 +1038,23 @@ impl<'hir> Map<'hir> { |
| 1040 | 1038 | } |
| 1041 | 1039 | } |
| 1042 | 1040 | |
| 1043 | pub fn span_if_local(self, id: DefId) -> Option<Span> { | |
| 1044 | id.is_local().then(|| self.tcx.def_span(id)) | |
| 1041 | pub fn hir_span_if_local(self, id: DefId) -> Option<Span> { | |
| 1042 | id.is_local().then(|| self.def_span(id)) | |
| 1045 | 1043 | } |
| 1046 | 1044 | |
| 1047 | pub fn res_span(self, res: Res) -> Option<Span> { | |
| 1045 | pub fn hir_res_span(self, res: Res) -> Option<Span> { | |
| 1048 | 1046 | match res { |
| 1049 | 1047 | Res::Err => None, |
| 1050 | Res::Local(id) => Some(self.span(id)), | |
| 1051 | res => self.span_if_local(res.opt_def_id()?), | |
| 1048 | Res::Local(id) => Some(self.hir_span(id)), | |
| 1049 | res => self.hir_span_if_local(res.opt_def_id()?), | |
| 1052 | 1050 | } |
| 1053 | 1051 | } |
| 1054 | 1052 | |
| 1055 | 1053 | /// Returns the HirId of `N` in `struct Foo<const N: usize = { ... }>` when |
| 1056 | 1054 | /// called with the HirId for the `{ ... }` anon const |
| 1057 | pub fn opt_const_param_default_param_def_id(self, anon_const: HirId) -> Option<LocalDefId> { | |
| 1058 | let const_arg = self.tcx.parent_hir_id(anon_const); | |
| 1059 | match self.tcx.parent_hir_node(const_arg) { | |
| 1055 | pub fn hir_opt_const_param_default_param_def_id(self, anon_const: HirId) -> Option<LocalDefId> { | |
| 1056 | let const_arg = self.parent_hir_id(anon_const); | |
| 1057 | match self.parent_hir_node(const_arg) { | |
| 1060 | 1058 | Node::GenericParam(GenericParam { |
| 1061 | 1059 | def_id: param_id, |
| 1062 | 1060 | kind: GenericParamKind::Const { .. }, |
| ... | ... | @@ -1066,7 +1064,7 @@ impl<'hir> Map<'hir> { |
| 1066 | 1064 | } |
| 1067 | 1065 | } |
| 1068 | 1066 | |
| 1069 | pub fn maybe_get_struct_pattern_shorthand_field(&self, expr: &Expr<'_>) -> Option<Symbol> { | |
| 1067 | pub fn hir_maybe_get_struct_pattern_shorthand_field(self, expr: &Expr<'_>) -> Option<Symbol> { | |
| 1070 | 1068 | let local = match expr { |
| 1071 | 1069 | Expr { |
| 1072 | 1070 | kind: |
| ... | ... | @@ -1081,7 +1079,7 @@ impl<'hir> Map<'hir> { |
| 1081 | 1079 | _ => None, |
| 1082 | 1080 | }?; |
| 1083 | 1081 | |
| 1084 | match self.tcx.parent_hir_node(expr.hir_id) { | |
| 1082 | match self.parent_hir_node(expr.hir_id) { | |
| 1085 | 1083 | Node::ExprField(field) => { |
| 1086 | 1084 | if field.ident.name == local.name && field.is_shorthand { |
| 1087 | 1085 | return Some(local.name); |
compiler/rustc_middle/src/hir/mod.rs+2-3| ... | ... | @@ -210,13 +210,12 @@ pub fn provide(providers: &mut Providers) { |
| 210 | 210 | providers.hir_attr_map = |tcx, id| { |
| 211 | 211 | tcx.hir_crate(()).owners[id.def_id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs) |
| 212 | 212 | }; |
| 213 | providers.def_span = |tcx, def_id| tcx.hir().span(tcx.local_def_id_to_hir_id(def_id)); | |
| 213 | providers.def_span = |tcx, def_id| tcx.hir_span(tcx.local_def_id_to_hir_id(def_id)); | |
| 214 | 214 | providers.def_ident_span = |tcx, def_id| { |
| 215 | 215 | let hir_id = tcx.local_def_id_to_hir_id(def_id); |
| 216 | 216 | tcx.hir_opt_ident_span(hir_id) |
| 217 | 217 | }; |
| 218 | 218 | providers.fn_arg_names = |tcx, def_id| { |
| 219 | let hir = tcx.hir(); | |
| 220 | 219 | if let Some(body_id) = tcx.hir_node_by_def_id(def_id).body_id() { |
| 221 | 220 | tcx.arena.alloc_from_iter(tcx.hir_body_param_names(body_id)) |
| 222 | 221 | } else if let Node::TraitItem(&TraitItem { |
| ... | ... | @@ -231,7 +230,7 @@ pub fn provide(providers: &mut Providers) { |
| 231 | 230 | idents |
| 232 | 231 | } else { |
| 233 | 232 | span_bug!( |
| 234 | hir.span(tcx.local_def_id_to_hir_id(def_id)), | |
| 233 | tcx.hir_span(tcx.local_def_id_to_hir_id(def_id)), | |
| 235 | 234 | "fn_arg_names: unexpected item {:?}", |
| 236 | 235 | def_id |
| 237 | 236 | ); |
compiler/rustc_middle/src/middle/region.rs+1-1| ... | ... | @@ -175,7 +175,7 @@ impl Scope { |
| 175 | 175 | let Some(hir_id) = self.hir_id(scope_tree) else { |
| 176 | 176 | return DUMMY_SP; |
| 177 | 177 | }; |
| 178 | let span = tcx.hir().span(hir_id); | |
| 178 | let span = tcx.hir_span(hir_id); | |
| 179 | 179 | if let ScopeData::Remainder(first_statement_index) = self.data { |
| 180 | 180 | if let Node::Block(blk) = tcx.hir_node(hir_id) { |
| 181 | 181 | // Want span for scope starting after the |
compiler/rustc_middle/src/query/keys.rs+2-2| ... | ... | @@ -586,7 +586,7 @@ impl Key for HirId { |
| 586 | 586 | type Cache<V> = DefaultCache<Self, V>; |
| 587 | 587 | |
| 588 | 588 | fn default_span(&self, tcx: TyCtxt<'_>) -> Span { |
| 589 | tcx.hir().span(*self) | |
| 589 | tcx.hir_span(*self) | |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | #[inline(always)] |
| ... | ... | @@ -599,7 +599,7 @@ impl Key for (LocalDefId, HirId) { |
| 599 | 599 | type Cache<V> = DefaultCache<Self, V>; |
| 600 | 600 | |
| 601 | 601 | fn default_span(&self, tcx: TyCtxt<'_>) -> Span { |
| 602 | tcx.hir().span(self.1) | |
| 602 | tcx.hir_span(self.1) | |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | #[inline(always)] |
compiler/rustc_middle/src/ty/closure.rs+4-4| ... | ... | @@ -150,9 +150,9 @@ impl<'tcx> CapturedPlace<'tcx> { |
| 150 | 150 | /// Return span pointing to use that resulted in selecting the captured path |
| 151 | 151 | pub fn get_path_span(&self, tcx: TyCtxt<'tcx>) -> Span { |
| 152 | 152 | if let Some(path_expr_id) = self.info.path_expr_id { |
| 153 | tcx.hir().span(path_expr_id) | |
| 153 | tcx.hir_span(path_expr_id) | |
| 154 | 154 | } else if let Some(capture_kind_expr_id) = self.info.capture_kind_expr_id { |
| 155 | tcx.hir().span(capture_kind_expr_id) | |
| 155 | tcx.hir_span(capture_kind_expr_id) | |
| 156 | 156 | } else { |
| 157 | 157 | // Fallback on upvars mentioned if neither path or capture expr id is captured |
| 158 | 158 | |
| ... | ... | @@ -166,9 +166,9 @@ impl<'tcx> CapturedPlace<'tcx> { |
| 166 | 166 | /// Return span pointing to use that resulted in selecting the current capture kind |
| 167 | 167 | pub fn get_capture_kind_span(&self, tcx: TyCtxt<'tcx>) -> Span { |
| 168 | 168 | if let Some(capture_kind_expr_id) = self.info.capture_kind_expr_id { |
| 169 | tcx.hir().span(capture_kind_expr_id) | |
| 169 | tcx.hir_span(capture_kind_expr_id) | |
| 170 | 170 | } else if let Some(path_expr_id) = self.info.path_expr_id { |
| 171 | tcx.hir().span(path_expr_id) | |
| 171 | tcx.hir_span(path_expr_id) | |
| 172 | 172 | } else { |
| 173 | 173 | // Fallback on upvars mentioned if neither path or capture expr id is captured |
| 174 | 174 |
compiler/rustc_middle/src/ty/instance.rs+2-2| ... | ... | @@ -720,7 +720,7 @@ impl<'tcx> Instance<'tcx> { |
| 720 | 720 | ty::TypingEnv::fully_monomorphized(), |
| 721 | 721 | def_id, |
| 722 | 722 | args, |
| 723 | ty.ty_adt_def().and_then(|adt| tcx.hir().span_if_local(adt.did())).unwrap_or(DUMMY_SP), | |
| 723 | ty.ty_adt_def().and_then(|adt| tcx.hir_span_if_local(adt.did())).unwrap_or(DUMMY_SP), | |
| 724 | 724 | ) |
| 725 | 725 | } |
| 726 | 726 | |
| ... | ... | @@ -732,7 +732,7 @@ impl<'tcx> Instance<'tcx> { |
| 732 | 732 | ty::TypingEnv::fully_monomorphized(), |
| 733 | 733 | def_id, |
| 734 | 734 | args, |
| 735 | ty.ty_adt_def().and_then(|adt| tcx.hir().span_if_local(adt.did())).unwrap_or(DUMMY_SP), | |
| 735 | ty.ty_adt_def().and_then(|adt| tcx.hir_span_if_local(adt.did())).unwrap_or(DUMMY_SP), | |
| 736 | 736 | ) |
| 737 | 737 | } |
| 738 | 738 |
compiler/rustc_mir_build/src/builder/expr/as_place.rs+1-1| ... | ... | @@ -258,7 +258,7 @@ impl<'tcx> PlaceBuilder<'tcx> { |
| 258 | 258 | self.projection |
| 259 | 259 | ), |
| 260 | 260 | PlaceBase::Upvar { var_hir_id, closure_def_id: _ } => span_bug!( |
| 261 | cx.tcx.hir().span(var_hir_id.0), | |
| 261 | cx.tcx.hir_span(var_hir_id.0), | |
| 262 | 262 | "could not resolve upvar: {var_hir_id:?} + {:?}", |
| 263 | 263 | self.projection |
| 264 | 264 | ), |
compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs+1-1| ... | ... | @@ -416,7 +416,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 416 | 416 | if let Some(mir_place) = place_builder.try_to_place(this) { |
| 417 | 417 | this.cfg.push_fake_read( |
| 418 | 418 | block, |
| 419 | this.source_info(this.tcx.hir().span(*hir_id)), | |
| 419 | this.source_info(this.tcx.hir_span(*hir_id)), | |
| 420 | 420 | *cause, |
| 421 | 421 | mir_place, |
| 422 | 422 | ); |
compiler/rustc_mir_build/src/builder/mod.rs+1-1| ... | ... | @@ -457,7 +457,7 @@ fn construct_fn<'tcx>( |
| 457 | 457 | |
| 458 | 458 | // Figure out what primary body this item has. |
| 459 | 459 | let body = tcx.hir_body_owned_by(fn_def); |
| 460 | let span_with_body = tcx.hir().span_with_body(fn_id); | |
| 460 | let span_with_body = tcx.hir_span_with_body(fn_id); | |
| 461 | 461 | let return_ty_span = tcx |
| 462 | 462 | .hir_fn_decl_by_hir_id(fn_id) |
| 463 | 463 | .unwrap_or_else(|| span_bug!(span, "can't build MIR for {:?}", fn_def)) |
compiler/rustc_mir_build/src/check_unsafety.rs+1-1| ... | ... | @@ -943,7 +943,7 @@ impl UnsafeOpKind { |
| 943 | 943 | } |
| 944 | 944 | }); |
| 945 | 945 | let unsafe_not_inherited_note = if let Some((id, _)) = note_non_inherited { |
| 946 | let span = tcx.hir().span(id); | |
| 946 | let span = tcx.hir_span(id); | |
| 947 | 947 | let span = tcx.sess.source_map().guess_head_span(span); |
| 948 | 948 | Some(UnsafeNotInheritedNote { span }) |
| 949 | 949 | } else { |
compiler/rustc_mir_build/src/thir/pattern/check_match.rs+1-1| ... | ... | @@ -1174,7 +1174,7 @@ fn report_arm_reachability<'p, 'tcx>( |
| 1174 | 1174 | for (arm, is_useful) in report.arm_usefulness.iter() { |
| 1175 | 1175 | if let Usefulness::Redundant(explanation) = is_useful { |
| 1176 | 1176 | let hir_id = arm.arm_data; |
| 1177 | let arm_span = cx.tcx.hir().span(hir_id); | |
| 1177 | let arm_span = cx.tcx.hir_span(hir_id); | |
| 1178 | 1178 | let whole_arm_span = if is_match_arm { |
| 1179 | 1179 | // If the arm is followed by a comma, extend the span to include it. |
| 1180 | 1180 | let with_whitespace = sm.span_extend_while_whitespace(arm_span); |
compiler/rustc_passes/src/check_attr.rs+3-3| ... | ... | @@ -1157,7 +1157,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1157 | 1157 | errors::DocInlineOnlyUse { |
| 1158 | 1158 | attr_span: meta.span(), |
| 1159 | 1159 | item_span: (attr.style() == AttrStyle::Outer) |
| 1160 | .then(|| self.tcx.hir().span(hir_id)), | |
| 1160 | .then(|| self.tcx.hir_span(hir_id)), | |
| 1161 | 1161 | }, |
| 1162 | 1162 | ); |
| 1163 | 1163 | } |
| ... | ... | @@ -1179,7 +1179,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1179 | 1179 | errors::DocMaskedOnlyExternCrate { |
| 1180 | 1180 | attr_span: meta.span(), |
| 1181 | 1181 | item_span: (attr.style() == AttrStyle::Outer) |
| 1182 | .then(|| self.tcx.hir().span(hir_id)), | |
| 1182 | .then(|| self.tcx.hir_span(hir_id)), | |
| 1183 | 1183 | }, |
| 1184 | 1184 | ); |
| 1185 | 1185 | return; |
| ... | ... | @@ -1193,7 +1193,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1193 | 1193 | errors::DocMaskedNotExternCrateSelf { |
| 1194 | 1194 | attr_span: meta.span(), |
| 1195 | 1195 | item_span: (attr.style() == AttrStyle::Outer) |
| 1196 | .then(|| self.tcx.hir().span(hir_id)), | |
| 1196 | .then(|| self.tcx.hir_span(hir_id)), | |
| 1197 | 1197 | }, |
| 1198 | 1198 | ); |
| 1199 | 1199 | } |
compiler/rustc_passes/src/diagnostic_items.rs+2-2| ... | ... | @@ -41,8 +41,8 @@ fn report_duplicate_item( |
| 41 | 41 | original_def_id: DefId, |
| 42 | 42 | item_def_id: DefId, |
| 43 | 43 | ) { |
| 44 | let orig_span = tcx.hir().span_if_local(original_def_id); | |
| 45 | let duplicate_span = tcx.hir().span_if_local(item_def_id); | |
| 44 | let orig_span = tcx.hir_span_if_local(original_def_id); | |
| 45 | let duplicate_span = tcx.hir_span_if_local(item_def_id); | |
| 46 | 46 | tcx.dcx().emit_err(DuplicateDiagnosticItemInCrate { |
| 47 | 47 | duplicate_span, |
| 48 | 48 | orig_span, |
compiler/rustc_passes/src/stability.rs+2-2| ... | ... | @@ -726,7 +726,7 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index { |
| 726 | 726 | |
| 727 | 727 | annotator.annotate( |
| 728 | 728 | CRATE_DEF_ID, |
| 729 | tcx.hir().span(CRATE_HIR_ID), | |
| 729 | tcx.hir_span(CRATE_HIR_ID), | |
| 730 | 730 | None, |
| 731 | 731 | AnnotationKind::Required, |
| 732 | 732 | InheritDeprecation::Yes, |
| ... | ... | @@ -1099,7 +1099,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) { |
| 1099 | 1099 | if is_staged_api { |
| 1100 | 1100 | let effective_visibilities = &tcx.effective_visibilities(()); |
| 1101 | 1101 | let mut missing = MissingStabilityAnnotations { tcx, effective_visibilities }; |
| 1102 | missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID)); | |
| 1102 | missing.check_missing_stability(CRATE_DEF_ID, tcx.hir_span(CRATE_HIR_ID)); | |
| 1103 | 1103 | tcx.hir_walk_toplevel_module(&mut missing); |
| 1104 | 1104 | tcx.hir_visit_all_item_likes_in_crate(&mut missing); |
| 1105 | 1105 | } |
compiler/rustc_resolve/src/lib.rs+2| ... | ... | @@ -88,6 +88,8 @@ mod late; |
| 88 | 88 | mod macros; |
| 89 | 89 | pub mod rustdoc; |
| 90 | 90 | |
| 91 | pub use macros::registered_tools_ast; | |
| 92 | ||
| 91 | 93 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
| 92 | 94 | |
| 93 | 95 | #[derive(Debug)] |
compiler/rustc_resolve/src/macros.rs+11-4| ... | ... | @@ -10,7 +10,7 @@ use rustc_ast::{self as ast, Crate, NodeId, attr}; |
| 10 | 10 | use rustc_ast_pretty::pprust; |
| 11 | 11 | use rustc_attr_parsing::{AttributeKind, StabilityLevel, find_attr}; |
| 12 | 12 | use rustc_data_structures::intern::Interned; |
| 13 | use rustc_errors::{Applicability, StashKey}; | |
| 13 | use rustc_errors::{Applicability, DiagCtxtHandle, StashKey}; | |
| 14 | 14 | use rustc_expand::base::{ |
| 15 | 15 | DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, SyntaxExtensionKind, |
| 16 | 16 | }; |
| ... | ... | @@ -124,14 +124,21 @@ fn fast_print_path(path: &ast::Path) -> Symbol { |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools { |
| 127 | let mut registered_tools = RegisteredTools::default(); | |
| 128 | 127 | let (_, pre_configured_attrs) = &*tcx.crate_for_resolver(()).borrow(); |
| 128 | registered_tools_ast(tcx.dcx(), pre_configured_attrs) | |
| 129 | } | |
| 130 | ||
| 131 | pub fn registered_tools_ast( | |
| 132 | dcx: DiagCtxtHandle<'_>, | |
| 133 | pre_configured_attrs: &[ast::Attribute], | |
| 134 | ) -> RegisteredTools { | |
| 135 | let mut registered_tools = RegisteredTools::default(); | |
| 129 | 136 | for attr in attr::filter_by_name(pre_configured_attrs, sym::register_tool) { |
| 130 | 137 | for meta_item_inner in attr.meta_item_list().unwrap_or_default() { |
| 131 | 138 | match meta_item_inner.ident() { |
| 132 | 139 | Some(ident) => { |
| 133 | 140 | if let Some(old_ident) = registered_tools.replace(ident) { |
| 134 | tcx.dcx().emit_err(errors::ToolWasAlreadyRegistered { | |
| 141 | dcx.emit_err(errors::ToolWasAlreadyRegistered { | |
| 135 | 142 | span: ident.span, |
| 136 | 143 | tool: ident, |
| 137 | 144 | old_ident_span: old_ident.span, |
| ... | ... | @@ -139,7 +146,7 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools { |
| 139 | 146 | } |
| 140 | 147 | } |
| 141 | 148 | None => { |
| 142 | tcx.dcx().emit_err(errors::ToolOnlyAcceptsIdentifiers { | |
| 149 | dcx.emit_err(errors::ToolOnlyAcceptsIdentifiers { | |
| 143 | 150 | span: meta_item_inner.span(), |
| 144 | 151 | tool: sym::register_tool, |
| 145 | 152 | }); |
compiler/rustc_session/src/config.rs+3| ... | ... | @@ -50,6 +50,7 @@ pub const PRINT_KINDS: &[(&str, PrintKind)] = &[ |
| 50 | 50 | ("check-cfg", PrintKind::CheckCfg), |
| 51 | 51 | ("code-models", PrintKind::CodeModels), |
| 52 | 52 | ("crate-name", PrintKind::CrateName), |
| 53 | ("crate-root-lint-levels", PrintKind::CrateRootLintLevels), | |
| 53 | 54 | ("deployment-target", PrintKind::DeploymentTarget), |
| 54 | 55 | ("file-names", PrintKind::FileNames), |
| 55 | 56 | ("host-tuple", PrintKind::HostTuple), |
| ... | ... | @@ -881,6 +882,7 @@ pub enum PrintKind { |
| 881 | 882 | CheckCfg, |
| 882 | 883 | CodeModels, |
| 883 | 884 | CrateName, |
| 885 | CrateRootLintLevels, | |
| 884 | 886 | DeploymentTarget, |
| 885 | 887 | FileNames, |
| 886 | 888 | HostTuple, |
| ... | ... | @@ -2067,6 +2069,7 @@ fn check_print_request_stability( |
| 2067 | 2069 | match print_kind { |
| 2068 | 2070 | PrintKind::AllTargetSpecsJson |
| 2069 | 2071 | | PrintKind::CheckCfg |
| 2072 | | PrintKind::CrateRootLintLevels | |
| 2070 | 2073 | | PrintKind::SupportedCrateTypes |
| 2071 | 2074 | | PrintKind::TargetSpecJson |
| 2072 | 2075 | if !unstable_opts.unstable_options => |
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs+3-3| ... | ... | @@ -1051,7 +1051,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { |
| 1051 | 1051 | None? |
| 1052 | 1052 | } |
| 1053 | 1053 | let args = self.node_args_opt(expr.hir_id)?; |
| 1054 | let span = tcx.hir().span(segment.hir_id); | |
| 1054 | let span = tcx.hir_span(segment.hir_id); | |
| 1055 | 1055 | let insert_span = segment.ident.span.shrink_to_hi().with_hi(span.hi()); |
| 1056 | 1056 | InsertableGenericArgs { |
| 1057 | 1057 | insert_span, |
| ... | ... | @@ -1110,7 +1110,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { |
| 1110 | 1110 | if generics.has_impl_trait() { |
| 1111 | 1111 | return None; |
| 1112 | 1112 | } |
| 1113 | let span = tcx.hir().span(segment.hir_id); | |
| 1113 | let span = tcx.hir_span(segment.hir_id); | |
| 1114 | 1114 | let insert_span = segment.ident.span.shrink_to_hi().with_hi(span.hi()); |
| 1115 | 1115 | Some(InsertableGenericArgs { |
| 1116 | 1116 | insert_span, |
| ... | ... | @@ -1144,7 +1144,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { |
| 1144 | 1144 | if !segment.infer_args || generics.has_impl_trait() { |
| 1145 | 1145 | do yeet (); |
| 1146 | 1146 | } |
| 1147 | let span = tcx.hir().span(segment.hir_id); | |
| 1147 | let span = tcx.hir_span(segment.hir_id); | |
| 1148 | 1148 | let insert_span = segment.ident.span.shrink_to_hi().with_hi(span.hi()); |
| 1149 | 1149 | InsertableGenericArgs { |
| 1150 | 1150 | insert_span, |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs+1-2| ... | ... | @@ -51,7 +51,6 @@ pub fn find_param_with_region<'tcx>( |
| 51 | 51 | _ => return None, // not a free region |
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | let hir = &tcx.hir(); | |
| 55 | 54 | let def_id = id.as_local()?; |
| 56 | 55 | |
| 57 | 56 | // FIXME: use def_kind |
| ... | ... | @@ -93,7 +92,7 @@ pub fn find_param_with_region<'tcx>( |
| 93 | 92 | }); |
| 94 | 93 | found_anon_region.then(|| { |
| 95 | 94 | let ty_hir_id = fn_decl.inputs[index].hir_id; |
| 96 | let param_ty_span = hir.span(ty_hir_id); | |
| 95 | let param_ty_span = tcx.hir_span(ty_hir_id); | |
| 97 | 96 | let is_first = index == 0; |
| 98 | 97 | AnonymousParamInfo { param, param_ty: new_param_ty, param_ty_span, kind, is_first } |
| 99 | 98 | }) |
compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs+3-4| ... | ... | @@ -1236,7 +1236,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 1236 | 1236 | ); |
| 1237 | 1237 | // Only suggest derive if this isn't a derived obligation, |
| 1238 | 1238 | // and the struct is local. |
| 1239 | if let Some(span) = self.tcx.hir().span_if_local(def.did()) | |
| 1239 | if let Some(span) = self.tcx.hir_span_if_local(def.did()) | |
| 1240 | 1240 | && obligation.cause.code().parent().is_none() |
| 1241 | 1241 | { |
| 1242 | 1242 | if ty.is_structural_eq_shallow(self.tcx) { |
| ... | ... | @@ -2943,7 +2943,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 2943 | 2943 | }; |
| 2944 | 2944 | |
| 2945 | 2945 | let found_node = found_did.and_then(|did| self.tcx.hir_get_if_local(did)); |
| 2946 | let found_span = found_did.and_then(|did| self.tcx.hir().span_if_local(did)); | |
| 2946 | let found_span = found_did.and_then(|did| self.tcx.hir_span_if_local(did)); | |
| 2947 | 2947 | |
| 2948 | 2948 | if !self.reported_signature_mismatch.borrow_mut().insert((span, found_span)) { |
| 2949 | 2949 | // We check closures twice, with obligations flowing in different directions, |
| ... | ... | @@ -3030,7 +3030,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 3030 | 3030 | node: Node<'_>, |
| 3031 | 3031 | ) -> Option<(Span, Option<Span>, Vec<ArgKind>)> { |
| 3032 | 3032 | let sm = self.tcx.sess.source_map(); |
| 3033 | let hir = self.tcx.hir(); | |
| 3034 | 3033 | Some(match node { |
| 3035 | 3034 | Node::Expr(&hir::Expr { |
| 3036 | 3035 | kind: hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, fn_arg_span, .. }), |
| ... | ... | @@ -3086,7 +3085,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 3086 | 3085 | .collect::<Vec<ArgKind>>(), |
| 3087 | 3086 | ), |
| 3088 | 3087 | Node::Ctor(variant_data) => { |
| 3089 | let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| hir.span(id)); | |
| 3088 | let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| self.tcx.hir_span(id)); | |
| 3090 | 3089 | (span, None, vec![ArgKind::empty(); variant_data.fields().len()]) |
| 3091 | 3090 | } |
| 3092 | 3091 | _ => panic!("non-FnLike node found: {node:?}"), |
compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs+1-1| ... | ... | @@ -398,7 +398,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 398 | 398 | ); |
| 399 | 399 | |
| 400 | 400 | if !self.tcx.is_impl_trait_in_trait(trait_item_def_id) { |
| 401 | if let Some(span) = self.tcx.hir().span_if_local(trait_item_def_id) { | |
| 401 | if let Some(span) = self.tcx.hir_span_if_local(trait_item_def_id) { | |
| 402 | 402 | let item_name = self.tcx.item_name(impl_item_def_id.to_def_id()); |
| 403 | 403 | err.span_label(span, format!("definition of `{item_name}` from trait")); |
| 404 | 404 | } |
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs+5-5| ... | ... | @@ -1193,7 +1193,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 1193 | 1193 | // FIXME(compiler-errors): This is kind of a mess, but required for obligations |
| 1194 | 1194 | // that come from a path expr to affect the *call* expr. |
| 1195 | 1195 | c @ ObligationCauseCode::WhereClauseInExpr(_, _, hir_id, _) |
| 1196 | if self.tcx.hir().span(*hir_id).lo() == span.lo() => | |
| 1196 | if self.tcx.hir_span(*hir_id).lo() == span.lo() => | |
| 1197 | 1197 | { |
| 1198 | 1198 | c |
| 1199 | 1199 | } |
| ... | ... | @@ -4481,7 +4481,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 4481 | 4481 | Obligation::new(self.tcx, obligation.cause.clone(), obligation.param_env, trait_ref); |
| 4482 | 4482 | |
| 4483 | 4483 | if self.predicate_must_hold_modulo_regions(&obligation) { |
| 4484 | let arg_span = self.tcx.hir().span(*arg_hir_id); | |
| 4484 | let arg_span = self.tcx.hir_span(*arg_hir_id); | |
| 4485 | 4485 | err.multipart_suggestion_verbose( |
| 4486 | 4486 | format!("use a unary tuple instead"), |
| 4487 | 4487 | vec![(arg_span.shrink_to_lo(), "(".into()), (arg_span.shrink_to_hi(), ",)".into())], |
| ... | ... | @@ -4521,7 +4521,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 4521 | 4521 | parent_code: _, |
| 4522 | 4522 | } = cause.code() |
| 4523 | 4523 | { |
| 4524 | let arg_span = self.tcx.hir().span(*arg_hir_id); | |
| 4524 | let arg_span = self.tcx.hir_span(*arg_hir_id); | |
| 4525 | 4525 | let mut sp: MultiSpan = arg_span.into(); |
| 4526 | 4526 | |
| 4527 | 4527 | sp.push_span_label( |
| ... | ... | @@ -4530,7 +4530,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 4530 | 4530 | generic types that should be inferred from this argument", |
| 4531 | 4531 | ); |
| 4532 | 4532 | sp.push_span_label( |
| 4533 | self.tcx.hir().span(*call_hir_id), | |
| 4533 | self.tcx.hir_span(*call_hir_id), | |
| 4534 | 4534 | "add turbofish arguments to this call to \ |
| 4535 | 4535 | specify the types manually, even if it's redundant", |
| 4536 | 4536 | ); |
| ... | ... | @@ -4939,7 +4939,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 4939 | 4939 | .type_implements_trait(pred.def_id(), [rhs_ty, lhs_ty], param_env) |
| 4940 | 4940 | .must_apply_modulo_regions() |
| 4941 | 4941 | { |
| 4942 | let lhs_span = tcx.hir().span(lhs_hir_id); | |
| 4942 | let lhs_span = tcx.hir_span(lhs_hir_id); | |
| 4943 | 4943 | let sm = tcx.sess.source_map(); |
| 4944 | 4944 | if let Ok(rhs_snippet) = sm.span_to_snippet(rhs_span) |
| 4945 | 4945 | && let Ok(lhs_snippet) = sm.span_to_snippet(lhs_span) |
library/Cargo.toml+3| ... | ... | @@ -38,8 +38,11 @@ adler2.debug = 0 |
| 38 | 38 | gimli.debug = 0 |
| 39 | 39 | gimli.opt-level = "s" |
| 40 | 40 | miniz_oxide.debug = 0 |
| 41 | miniz_oxide.opt-level = "s" | |
| 42 | # `opt-level = "s"` for `object` led to a size regression when tried previously | |
| 41 | 43 | object.debug = 0 |
| 42 | 44 | rustc-demangle.debug = 0 |
| 45 | rustc-demangle.opt-level = "s" | |
| 43 | 46 | |
| 44 | 47 | [patch.crates-io] |
| 45 | 48 | # See comments in `library/rustc-std-workspace-core/README.md` for what's going on |
src/doc/unstable-book/src/compiler-flags/print-crate-root-lint-levels.md created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | # `print=crate-root-lint-levels` | |
| 2 | ||
| 3 | The tracking issue for this feature is: [#139180](https://github.com/rust-lang/rust/issues/139180). | |
| 4 | ||
| 5 | ------------------------ | |
| 6 | ||
| 7 | This option of the `--print` flag print the list of lints with print out all the lints and their associated levels (`allow`, `warn`, `deny`, `forbid`) based on the regular Rust rules at crate root, that is *(roughly)*: | |
| 8 | - command line args (`-W`, `-A`, `--force-warn`, `--cap-lints`, ...) | |
| 9 | - crate root attributes (`#![allow]`, `#![warn]`, `#[expect]`, ...) | |
| 10 | - *the special `warnings` lint group* | |
| 11 | - the default lint level | |
| 12 | ||
| 13 | The output format is `LINT_NAME=LINT_LEVEL`, e.g.: | |
| 14 | ```text | |
| 15 | unknown_lint=warn | |
| 16 | arithmetic_overflow=deny | |
| 17 | ``` | |
| 18 | ||
| 19 | To be used like this: | |
| 20 | ||
| 21 | ```bash | |
| 22 | rustc --print=crate-root-lint-levels -Zunstable-options lib.rs | |
| 23 | ``` |
src/librustdoc/clean/types.rs+1-4| ... | ... | @@ -367,10 +367,7 @@ impl fmt::Debug for Item { |
| 367 | 367 | pub(crate) fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span { |
| 368 | 368 | Span::new(def_id.as_local().map_or_else( |
| 369 | 369 | || tcx.def_span(def_id), |
| 370 | |local| { | |
| 371 | let hir = tcx.hir(); | |
| 372 | hir.span_with_body(tcx.local_def_id_to_hir_id(local)) | |
| 373 | }, | |
| 370 | |local| tcx.hir_span_with_body(tcx.local_def_id_to_hir_id(local)), | |
| 374 | 371 | )) |
| 375 | 372 | } |
| 376 | 373 |
src/librustdoc/doctest/rust.rs+1-1| ... | ... | @@ -80,7 +80,7 @@ impl<'tcx> HirCollector<'tcx> { |
| 80 | 80 | |
| 81 | 81 | pub fn collect_crate(mut self) -> Vec<ScrapedDocTest> { |
| 82 | 82 | let tcx = self.tcx; |
| 83 | self.visit_testable(None, CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID), |this| { | |
| 83 | self.visit_testable(None, CRATE_DEF_ID, tcx.hir_span(CRATE_HIR_ID), |this| { | |
| 84 | 84 | tcx.hir_walk_toplevel_module(this) |
| 85 | 85 | }); |
| 86 | 86 | self.collector.tests |
src/librustdoc/html/render/span_map.rs+1-1| ... | ... | @@ -95,7 +95,7 @@ impl SpanMapVisitor<'_> { |
| 95 | 95 | .unwrap_or(path.span); |
| 96 | 96 | self.matches.insert(span, link); |
| 97 | 97 | } |
| 98 | Res::Local(_) if let Some(span) = self.tcx.hir().res_span(path.res) => { | |
| 98 | Res::Local(_) if let Some(span) = self.tcx.hir_res_span(path.res) => { | |
| 99 | 99 | self.matches.insert(path.span, LinkFromSrc::Local(clean::Span::new(span))); |
| 100 | 100 | } |
| 101 | 101 | Res::PrimTy(p) => { |
src/librustdoc/scrape_examples.rs+1-2| ... | ... | @@ -176,8 +176,7 @@ where |
| 176 | 176 | |
| 177 | 177 | // If the enclosing item has a span coming from a proc macro, then we also don't want to |
| 178 | 178 | // include the example. |
| 179 | let enclosing_item_span = | |
| 180 | tcx.hir().span_with_body(tcx.hir_get_parent_item(ex.hir_id).into()); | |
| 179 | let enclosing_item_span = tcx.hir_span_with_body(tcx.hir_get_parent_item(ex.hir_id).into()); | |
| 181 | 180 | if enclosing_item_span.from_expansion() { |
| 182 | 181 | trace!("Rejecting expr ({call_span:?}) from macro item: {enclosing_item_span:?}"); |
| 183 | 182 | return; |
src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs+1-1| ... | ... | @@ -143,7 +143,7 @@ pub(super) fn check<'tcx>( |
| 143 | 143 | |
| 144 | 144 | if cast_from.kind() == cast_to.kind() && !expr.span.in_external_macro(cx.sess().source_map()) { |
| 145 | 145 | if let Some(id) = path_to_local(cast_expr) |
| 146 | && !cx.tcx.hir().span(id).eq_ctxt(cast_expr.span) | |
| 146 | && !cx.tcx.hir_span(id).eq_ctxt(cast_expr.span) | |
| 147 | 147 | { |
| 148 | 148 | // Binding context is different than the identifiers context. |
| 149 | 149 | // Weird macro wizardry could be involved here. |
src/tools/clippy/clippy_lints/src/derive.rs+2-2| ... | ... | @@ -254,7 +254,7 @@ fn check_hash_peq<'tcx>( |
| 254 | 254 | |diag| { |
| 255 | 255 | if let Some(local_def_id) = impl_id.as_local() { |
| 256 | 256 | let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id); |
| 257 | diag.span_note(cx.tcx.hir().span(hir_id), "`PartialEq` implemented here"); | |
| 257 | diag.span_note(cx.tcx.hir_span(hir_id), "`PartialEq` implemented here"); | |
| 258 | 258 | } |
| 259 | 259 | }, |
| 260 | 260 | ); |
| ... | ... | @@ -298,7 +298,7 @@ fn check_ord_partial_ord<'tcx>( |
| 298 | 298 | span_lint_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, span, mess, |diag| { |
| 299 | 299 | if let Some(local_def_id) = impl_id.as_local() { |
| 300 | 300 | let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id); |
| 301 | diag.span_note(cx.tcx.hir().span(hir_id), "`PartialOrd` implemented here"); | |
| 301 | diag.span_note(cx.tcx.hir_span(hir_id), "`PartialOrd` implemented here"); | |
| 302 | 302 | } |
| 303 | 303 | }); |
| 304 | 304 | } |
src/tools/clippy/clippy_lints/src/escape.rs+1-1| ... | ... | @@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal { |
| 120 | 120 | cx, |
| 121 | 121 | BOXED_LOCAL, |
| 122 | 122 | node, |
| 123 | cx.tcx.hir().span(node), | |
| 123 | cx.tcx.hir_span(node), | |
| 124 | 124 | "local variable doesn't need to be boxed here", |
| 125 | 125 | ); |
| 126 | 126 | } |
src/tools/clippy/clippy_lints/src/index_refutable_slice.rs+1-1| ... | ... | @@ -248,7 +248,7 @@ impl<'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'_, 'tcx> { |
| 248 | 248 | { |
| 249 | 249 | use_info |
| 250 | 250 | .index_use |
| 251 | .push((index_value, cx.tcx.hir().span(parent_expr.hir_id))); | |
| 251 | .push((index_value, cx.tcx.hir_span(parent_expr.hir_id))); | |
| 252 | 252 | return; |
| 253 | 253 | } |
| 254 | 254 |
src/tools/clippy/clippy_lints/src/loops/mut_range_bound.rs+4-4| ... | ... | @@ -85,10 +85,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> { |
| 85 | 85 | if bk == ty::BorrowKind::Mutable { |
| 86 | 86 | if let PlaceBase::Local(id) = cmt.place.base { |
| 87 | 87 | if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) { |
| 88 | self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)); | |
| 88 | self.span_low = Some(self.cx.tcx.hir_span(diag_expr_id)); | |
| 89 | 89 | } |
| 90 | 90 | if Some(id) == self.hir_id_high && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) { |
| 91 | self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)); | |
| 91 | self.span_high = Some(self.cx.tcx.hir_span(diag_expr_id)); | |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
| ... | ... | @@ -97,10 +97,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> { |
| 97 | 97 | fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) { |
| 98 | 98 | if let PlaceBase::Local(id) = cmt.place.base { |
| 99 | 99 | if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) { |
| 100 | self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)); | |
| 100 | self.span_low = Some(self.cx.tcx.hir_span(diag_expr_id)); | |
| 101 | 101 | } |
| 102 | 102 | if Some(id) == self.hir_id_high && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) { |
| 103 | self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)); | |
| 103 | self.span_high = Some(self.cx.tcx.hir_span(diag_expr_id)); | |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } |
src/tools/clippy/clippy_lints/src/macro_metavars_in_unsafe.rs+1-1| ... | ... | @@ -253,7 +253,7 @@ impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe { |
| 253 | 253 | // Remove the syntax context to hide "in this macro invocation" in the diagnostic. |
| 254 | 254 | // The invocation doesn't matter. Also we want to dedupe by the unsafe block and not by anything |
| 255 | 255 | // related to the callsite. |
| 256 | let span = cx.tcx.hir().span(id); | |
| 256 | let span = cx.tcx.hir_span(id); | |
| 257 | 257 | |
| 258 | 258 | (id, Span::new(span.lo(), span.hi(), SyntaxContext::root(), None)) |
| 259 | 259 | }) |
src/tools/clippy/clippy_lints/src/misc.rs+1-1| ... | ... | @@ -329,7 +329,7 @@ fn used_underscore_binding<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { |
| 329 | 329 | let name = ident.name.as_str(); |
| 330 | 330 | if name.starts_with('_') |
| 331 | 331 | && !name.starts_with("__") |
| 332 | && let definition_span = cx.tcx.hir().span(definition_hir_id) | |
| 332 | && let definition_span = cx.tcx.hir_span(definition_hir_id) | |
| 333 | 333 | && !definition_span.from_expansion() |
| 334 | 334 | && !fulfill_or_allowed(cx, USED_UNDERSCORE_BINDING, [expr.hir_id, definition_hir_id]) |
| 335 | 335 | { |
src/tools/clippy/clippy_lints/src/needless_pass_by_ref_mut.rs+1-1| ... | ... | @@ -280,7 +280,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> { |
| 280 | 280 | diag.span_suggestion( |
| 281 | 281 | sp, |
| 282 | 282 | "consider changing to".to_string(), |
| 283 | format!("&{}", snippet(cx, cx.tcx.hir().span(inner_ty.ty.hir_id), "_"),), | |
| 283 | format!("&{}", snippet(cx, cx.tcx.hir_span(inner_ty.ty.hir_id), "_"),), | |
| 284 | 284 | Applicability::Unspecified, |
| 285 | 285 | ); |
| 286 | 286 | if cx.effective_visibilities.is_exported(*fn_def_id) { |
src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs+1-1| ... | ... | @@ -198,7 +198,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { |
| 198 | 198 | // Dereference suggestion |
| 199 | 199 | let sugg = |diag: &mut Diag<'_, ()>| { |
| 200 | 200 | if let ty::Adt(def, ..) = ty.kind() { |
| 201 | if let Some(span) = cx.tcx.hir().span_if_local(def.did()) { | |
| 201 | if let Some(span) = cx.tcx.hir_span_if_local(def.did()) { | |
| 202 | 202 | if type_allowed_to_implement_copy( |
| 203 | 203 | cx.tcx, |
| 204 | 204 | cx.param_env, |
src/tools/clippy/clippy_lints/src/operators/arithmetic_side_effects.rs+2-2| ... | ... | @@ -354,7 +354,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects { |
| 354 | 354 | |
| 355 | 355 | let body_owner_kind = cx.tcx.hir_body_owner_kind(body_owner_def_id); |
| 356 | 356 | if let hir::BodyOwnerKind::Const { .. } | hir::BodyOwnerKind::Static(_) = body_owner_kind { |
| 357 | let body_span = cx.tcx.hir().span_with_body(body_owner); | |
| 357 | let body_span = cx.tcx.hir_span_with_body(body_owner); | |
| 358 | 358 | if let Some(span) = self.const_span |
| 359 | 359 | && span.contains(body_span) |
| 360 | 360 | { |
| ... | ... | @@ -366,7 +366,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects { |
| 366 | 366 | |
| 367 | 367 | fn check_body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) { |
| 368 | 368 | let body_owner = cx.tcx.hir_body_owner(body.id()); |
| 369 | let body_span = cx.tcx.hir().span(body_owner); | |
| 369 | let body_span = cx.tcx.hir_span(body_owner); | |
| 370 | 370 | if let Some(span) = self.const_span |
| 371 | 371 | && span.contains(body_span) |
| 372 | 372 | { |
src/tools/clippy/clippy_lints/src/operators/numeric_arithmetic.rs+2-2| ... | ... | @@ -73,7 +73,7 @@ impl Context { |
| 73 | 73 | |
| 74 | 74 | match cx.tcx.hir_body_owner_kind(body_owner_def_id) { |
| 75 | 75 | hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const { .. } => { |
| 76 | let body_span = cx.tcx.hir().span_with_body(body_owner); | |
| 76 | let body_span = cx.tcx.hir_span_with_body(body_owner); | |
| 77 | 77 | |
| 78 | 78 | if let Some(span) = self.const_span { |
| 79 | 79 | if span.contains(body_span) { |
| ... | ... | @@ -88,7 +88,7 @@ impl Context { |
| 88 | 88 | |
| 89 | 89 | pub fn body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) { |
| 90 | 90 | let body_owner = cx.tcx.hir_body_owner(body.id()); |
| 91 | let body_span = cx.tcx.hir().span_with_body(body_owner); | |
| 91 | let body_span = cx.tcx.hir_span_with_body(body_owner); | |
| 92 | 92 | |
| 93 | 93 | if let Some(span) = self.const_span { |
| 94 | 94 | if span.contains(body_span) { |
src/tools/clippy/clippy_lints/src/shadow.rs+1-1| ... | ... | @@ -218,7 +218,7 @@ fn lint_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, shadowed: HirId, span: Span) |
| 218 | 218 | }, |
| 219 | 219 | }; |
| 220 | 220 | span_lint_and_then(cx, lint, span, msg, |diag| { |
| 221 | diag.span_note(cx.tcx.hir().span(shadowed), "previous binding is here"); | |
| 221 | diag.span_note(cx.tcx.hir_span(shadowed), "previous binding is here"); | |
| 222 | 222 | }); |
| 223 | 223 | } |
| 224 | 224 |
src/tools/clippy/clippy_lints/src/single_call_fn.rs+1-1| ... | ... | @@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn { |
| 137 | 137 | for (&def_id, usage) in &self.def_id_to_usage { |
| 138 | 138 | if let CallState::Once { call_site } = *usage |
| 139 | 139 | && let fn_hir_id = cx.tcx.local_def_id_to_hir_id(def_id) |
| 140 | && let fn_span = cx.tcx.hir().span_with_body(fn_hir_id) | |
| 140 | && let fn_span = cx.tcx.hir_span_with_body(fn_hir_id) | |
| 141 | 141 | && !self.is_function_allowed(cx, def_id, fn_hir_id, fn_span) |
| 142 | 142 | { |
| 143 | 143 | span_lint_hir_and_then( |
src/tools/clippy/clippy_utils/src/lib.rs+1-1| ... | ... | @@ -2990,7 +2990,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU |
| 2990 | 2990 | { |
| 2991 | 2991 | adjustments = cx.typeck_results().expr_adjustments(e); |
| 2992 | 2992 | } |
| 2993 | same_ctxt &= cx.tcx.hir().span(parent_id).ctxt() == ctxt; | |
| 2993 | same_ctxt &= cx.tcx.hir_span(parent_id).ctxt() == ctxt; | |
| 2994 | 2994 | if let Node::Expr(e) = parent { |
| 2995 | 2995 | match e.kind { |
| 2996 | 2996 | ExprKind::If(e, _, _) | ExprKind::Match(e, _, _) if e.hir_id != child_id => { |
src/tools/clippy/clippy_utils/src/macros.rs+1-2| ... | ... | @@ -178,7 +178,6 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option< |
| 178 | 178 | |
| 179 | 179 | // get the parent node, possibly skipping over a statement |
| 180 | 180 | // if the parent is not found, it is sensible to return `Some(root)` |
| 181 | let hir = cx.tcx.hir(); | |
| 182 | 181 | let mut parent_iter = cx.tcx.hir_parent_iter(node.hir_id()); |
| 183 | 182 | let (parent_id, _) = match parent_iter.next() { |
| 184 | 183 | None => return Some(ExpnId::root()), |
| ... | ... | @@ -190,7 +189,7 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option< |
| 190 | 189 | }; |
| 191 | 190 | |
| 192 | 191 | // get the macro expansion of the parent node |
| 193 | let parent_span = hir.span(parent_id); | |
| 192 | let parent_span = cx.tcx.hir_span(parent_id); | |
| 194 | 193 | let Some(parent_macro_call) = macro_backtrace(parent_span).next() else { |
| 195 | 194 | // the parent node is not in a macro |
| 196 | 195 | return Some(ExpnId::root()); |
src/tools/clippy/clippy_utils/src/sugg.rs+1-2| ... | ... | @@ -839,8 +839,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> { |
| 839 | 839 | |
| 840 | 840 | fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) { |
| 841 | 841 | if let PlaceBase::Local(id) = cmt.place.base { |
| 842 | let map = self.cx.tcx.hir(); | |
| 843 | let span = map.span(cmt.hir_id); | |
| 842 | let span = self.cx.tcx.hir_span(cmt.hir_id); | |
| 844 | 843 | let start_span = Span::new(self.next_pos, span.lo(), span.ctxt(), None); |
| 845 | 844 | let mut start_snip = snippet_with_applicability(self.cx, start_span, "..", &mut self.applicability); |
| 846 | 845 |
src/tools/run-make-support/src/external_deps/rustc.rs-14| ... | ... | @@ -22,12 +22,6 @@ pub fn bare_rustc() -> Rustc { |
| 22 | 22 | Rustc::bare() |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | /// Construct a new `rustc` aux-build invocation. | |
| 26 | #[track_caller] | |
| 27 | pub fn aux_build() -> Rustc { | |
| 28 | Rustc::new_aux_build() | |
| 29 | } | |
| 30 | ||
| 31 | 25 | /// A `rustc` invocation builder. |
| 32 | 26 | #[derive(Debug)] |
| 33 | 27 | #[must_use] |
| ... | ... | @@ -67,14 +61,6 @@ impl Rustc { |
| 67 | 61 | Self { cmd } |
| 68 | 62 | } |
| 69 | 63 | |
| 70 | /// Construct a new `rustc` invocation with `aux_build` preset (setting `--crate-type=lib`). | |
| 71 | #[track_caller] | |
| 72 | pub fn new_aux_build() -> Self { | |
| 73 | let mut cmd = setup_common(); | |
| 74 | cmd.arg("--crate-type=lib"); | |
| 75 | Self { cmd } | |
| 76 | } | |
| 77 | ||
| 78 | 64 | // Argument provider methods |
| 79 | 65 | |
| 80 | 66 | /// Configure the compilation environment. |
src/tools/run-make-support/src/lib.rs+1-1| ... | ... | @@ -68,7 +68,7 @@ pub use llvm::{ |
| 68 | 68 | LlvmFilecheck, LlvmNm, LlvmObjcopy, LlvmObjdump, LlvmProfdata, LlvmReadobj, |
| 69 | 69 | }; |
| 70 | 70 | pub use python::python_command; |
| 71 | pub use rustc::{aux_build, bare_rustc, rustc, rustc_path, Rustc}; | |
| 71 | pub use rustc::{bare_rustc, rustc, rustc_path, Rustc}; | |
| 72 | 72 | pub use rustdoc::{rustdoc, Rustdoc}; |
| 73 | 73 | |
| 74 | 74 | /// [`diff`][mod@diff] is implemented in terms of the [similar] library. |
tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs+2-2| ... | ... | @@ -3,10 +3,10 @@ |
| 3 | 3 | // Check that the `CURRENT_RUSTC_VERSION` placeholder is correctly replaced by the current |
| 4 | 4 | // `rustc` version and the `since` property in feature stability gating is properly respected. |
| 5 | 5 | |
| 6 | use run_make_support::{aux_build, rfs, rustc, source_root}; | |
| 6 | use run_make_support::{rfs, rustc, source_root}; | |
| 7 | 7 | |
| 8 | 8 | fn main() { |
| 9 | aux_build().input("stable.rs").emit("metadata").run(); | |
| 9 | rustc().crate_type("lib").input("stable.rs").emit("metadata").run(); | |
| 10 | 10 | |
| 11 | 11 | let output = |
| 12 | 12 | rustc().input("main.rs").emit("metadata").extern_("stable", "libstable.rmeta").run(); |
tests/run-make/issue-107495-archive-permissions/rmake.rs+2-2| ... | ... | @@ -4,7 +4,7 @@ use std::path::Path; |
| 4 | 4 | |
| 5 | 5 | #[cfg(unix)] |
| 6 | 6 | use run_make_support::libc; |
| 7 | use run_make_support::{aux_build, rfs}; | |
| 7 | use run_make_support::{rfs, rustc}; | |
| 8 | 8 | |
| 9 | 9 | fn main() { |
| 10 | 10 | #[cfg(unix)] |
| ... | ... | @@ -12,7 +12,7 @@ fn main() { |
| 12 | 12 | libc::umask(0o002); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | aux_build().arg("foo.rs").run(); | |
| 15 | rustc().crate_type("lib").arg("foo.rs").run(); | |
| 16 | 16 | verify(Path::new("libfoo.rlib")); |
| 17 | 17 | } |
| 18 | 18 |
tests/run-make/print-crate-root-lint-levels/lib.rs created+5| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | #![allow(unexpected_cfgs)] | |
| 2 | #![expect(unused_mut)] | |
| 3 | ||
| 4 | #[deny(unknown_lints)] | |
| 5 | mod my_mod {} |
tests/run-make/print-crate-root-lint-levels/rmake.rs created+118| ... | ... | @@ -0,0 +1,118 @@ |
| 1 | //! This checks the output of `--print=crate-root-lint-levels` | |
| 2 | ||
| 3 | extern crate run_make_support; | |
| 4 | ||
| 5 | use std::collections::HashSet; | |
| 6 | use std::iter::FromIterator; | |
| 7 | ||
| 8 | use run_make_support::rustc; | |
| 9 | ||
| 10 | struct CrateRootLintLevels { | |
| 11 | args: &'static [&'static str], | |
| 12 | contains: Contains, | |
| 13 | } | |
| 14 | ||
| 15 | struct Contains { | |
| 16 | contains: &'static [&'static str], | |
| 17 | doesnt_contain: &'static [&'static str], | |
| 18 | } | |
| 19 | ||
| 20 | fn main() { | |
| 21 | check(CrateRootLintLevels { | |
| 22 | args: &[], | |
| 23 | contains: Contains { | |
| 24 | contains: &[ | |
| 25 | "unexpected_cfgs=allow", | |
| 26 | "unused_mut=expect", | |
| 27 | "warnings=warn", | |
| 28 | "stable_features=warn", | |
| 29 | "unknown_lints=warn", | |
| 30 | ], | |
| 31 | doesnt_contain: &["unexpected_cfgs=warn", "unused_mut=warn"], | |
| 32 | }, | |
| 33 | }); | |
| 34 | check(CrateRootLintLevels { | |
| 35 | args: &["-Wunexpected_cfgs"], | |
| 36 | contains: Contains { | |
| 37 | contains: &["unexpected_cfgs=allow", "warnings=warn"], | |
| 38 | doesnt_contain: &["unexpected_cfgs=warn"], | |
| 39 | }, | |
| 40 | }); | |
| 41 | check(CrateRootLintLevels { | |
| 42 | args: &["-Dwarnings"], | |
| 43 | contains: Contains { | |
| 44 | contains: &[ | |
| 45 | "unexpected_cfgs=allow", | |
| 46 | "warnings=deny", | |
| 47 | "stable_features=deny", | |
| 48 | "unknown_lints=deny", | |
| 49 | ], | |
| 50 | doesnt_contain: &["warnings=warn"], | |
| 51 | }, | |
| 52 | }); | |
| 53 | check(CrateRootLintLevels { | |
| 54 | args: &["-Dstable_features"], | |
| 55 | contains: Contains { | |
| 56 | contains: &["warnings=warn", "stable_features=deny", "unexpected_cfgs=allow"], | |
| 57 | doesnt_contain: &["warnings=deny"], | |
| 58 | }, | |
| 59 | }); | |
| 60 | check(CrateRootLintLevels { | |
| 61 | args: &["-Dwarnings", "--force-warn=stable_features"], | |
| 62 | contains: Contains { | |
| 63 | contains: &["warnings=deny", "stable_features=force-warn", "unknown_lints=deny"], | |
| 64 | doesnt_contain: &["warnings=warn"], | |
| 65 | }, | |
| 66 | }); | |
| 67 | check(CrateRootLintLevels { | |
| 68 | args: &["-Dwarnings", "--cap-lints=warn"], | |
| 69 | contains: Contains { | |
| 70 | contains: &[ | |
| 71 | "unexpected_cfgs=allow", | |
| 72 | "warnings=warn", | |
| 73 | "stable_features=warn", | |
| 74 | "unknown_lints=warn", | |
| 75 | ], | |
| 76 | doesnt_contain: &["warnings=deny"], | |
| 77 | }, | |
| 78 | }); | |
| 79 | } | |
| 80 | ||
| 81 | #[track_caller] | |
| 82 | fn check(CrateRootLintLevels { args, contains }: CrateRootLintLevels) { | |
| 83 | let output = rustc() | |
| 84 | .input("lib.rs") | |
| 85 | .arg("-Zunstable-options") | |
| 86 | .print("crate-root-lint-levels") | |
| 87 | .args(args) | |
| 88 | .run(); | |
| 89 | ||
| 90 | let stdout = output.stdout_utf8(); | |
| 91 | ||
| 92 | let mut found = HashSet::<String>::new(); | |
| 93 | ||
| 94 | for l in stdout.lines() { | |
| 95 | assert!(l == l.trim()); | |
| 96 | if let Some((left, right)) = l.split_once('=') { | |
| 97 | assert!(!left.contains("\"")); | |
| 98 | assert!(!right.contains("\"")); | |
| 99 | } else { | |
| 100 | assert!(l.contains('=')); | |
| 101 | } | |
| 102 | assert!(found.insert(l.to_string()), "{}", &l); | |
| 103 | } | |
| 104 | ||
| 105 | let Contains { contains, doesnt_contain } = contains; | |
| 106 | ||
| 107 | { | |
| 108 | let should_found = HashSet::<String>::from_iter(contains.iter().map(|s| s.to_string())); | |
| 109 | let diff: Vec<_> = should_found.difference(&found).collect(); | |
| 110 | assert!(diff.is_empty(), "should found: {:?}, didn't found {:?}", &should_found, &diff); | |
| 111 | } | |
| 112 | { | |
| 113 | let should_not_find = | |
| 114 | HashSet::<String>::from_iter(doesnt_contain.iter().map(|s| s.to_string())); | |
| 115 | let diff: Vec<_> = should_not_find.intersection(&found).collect(); | |
| 116 | assert!(diff.is_empty(), "should not find {:?}, did found {:?}", &should_not_find, &diff); | |
| 117 | } | |
| 118 | } |
tests/run-make/rustc-help/help-v.stdout+1-1| ... | ... | @@ -29,7 +29,7 @@ Options: |
| 29 | 29 | --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] |
| 30 | 30 | Comma separated list of types of output for the |
| 31 | 31 | compiler to emit |
| 32 | --print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models] | |
| 32 | --print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models] | |
| 33 | 33 | Compiler information to print on stdout |
| 34 | 34 | -g Equivalent to -C debuginfo=2 |
| 35 | 35 | -O Equivalent to -C opt-level=3 |
tests/run-make/rustc-help/help.stdout+1-1| ... | ... | @@ -29,7 +29,7 @@ Options: |
| 29 | 29 | --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] |
| 30 | 30 | Comma separated list of types of output for the |
| 31 | 31 | compiler to emit |
| 32 | --print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models] | |
| 32 | --print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models] | |
| 33 | 33 | Compiler information to print on stdout |
| 34 | 34 | -g Equivalent to -C debuginfo=2 |
| 35 | 35 | -O Equivalent to -C opt-level=3 |
tests/ui/invalid-compile-flags/print-without-arg.stderr+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error: Argument to option 'print' missing |
| 2 | 2 | Usage: |
| 3 | --print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models] | |
| 3 | --print [all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models] | |
| 4 | 4 | Compiler information to print on stdout |
| 5 | 5 |
tests/ui/invalid-compile-flags/print.stderr+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error: unknown print request: `yyyy` |
| 2 | 2 | | |
| 3 | = help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `host-tuple`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `supported-crate-types`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models` | |
| 3 | = help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `crate-root-lint-levels`, `deployment-target`, `file-names`, `host-tuple`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `supported-crate-types`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models` | |
| 4 | 4 | = help: for more information, see the rustc book: https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information |
| 5 | 5 |
tests/ui/print-request/print-lints-help.stderr+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | error: unknown print request: `lints` |
| 2 | 2 | | |
| 3 | = help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `host-tuple`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `supported-crate-types`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models` | |
| 3 | = help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `crate-root-lint-levels`, `deployment-target`, `file-names`, `host-tuple`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `supported-crate-types`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models` | |
| 4 | 4 | = help: use `-Whelp` to print a list of lints |
| 5 | 5 | = help: for more information, see the rustc book: https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information |
| 6 | 6 |
tests/ui/print-request/stability.rs+4| ... | ... | @@ -18,6 +18,10 @@ |
| 18 | 18 | //@[all_target_specs_json] compile-flags: --print=all-target-specs-json |
| 19 | 19 | //@[all_target_specs_json] error-pattern: the `-Z unstable-options` flag must also be passed |
| 20 | 20 | |
| 21 | //@ revisions: crate_root_lint_levels | |
| 22 | //@[crate_root_lint_levels] compile-flags: --print=crate-root-lint-levels | |
| 23 | //@[crate_root_lint_levels] error-pattern: the `-Z unstable-options` flag must also be passed | |
| 24 | ||
| 21 | 25 | //@ revisions: check_cfg |
| 22 | 26 | //@[check_cfg] compile-flags: --print=check-cfg |
| 23 | 27 | //@[check_cfg] error-pattern: the `-Z unstable-options` flag must also be passed |
triagebot.toml+1-2| ... | ... | @@ -1142,7 +1142,6 @@ compiler_leads = [ |
| 1142 | 1142 | ] |
| 1143 | 1143 | compiler = [ |
| 1144 | 1144 | "@BoxyUwU", |
| 1145 | "@cjgillot", | |
| 1146 | 1145 | "@compiler-errors", |
| 1147 | 1146 | "@davidtwco", |
| 1148 | 1147 | "@estebank", |
| ... | ... | @@ -1197,7 +1196,7 @@ codegen = [ |
| 1197 | 1196 | "@workingjubilee", |
| 1198 | 1197 | ] |
| 1199 | 1198 | query-system = [ |
| 1200 | "@cjgillot", | |
| 1199 | "@oli-obk", | |
| 1201 | 1200 | ] |
| 1202 | 1201 | incremental = [ |
| 1203 | 1202 | "@wesleywiser", |