Skip to content

Commit 23c2723

Browse files
committed
Auto merge of rust-lang#92003 - matthiaskrgr:rollup-obgv0rt, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#91172 (Warn when a `#[test]`-like built-in attribute macro is present multiple times.) - rust-lang#91796 (Fix since attribute for const_manually_drop feature) - rust-lang#91879 (Remove `in_band_lifetimes` from `rustc_borrowck`) - rust-lang#91947 (Add `io::Error::other`) - rust-lang#91967 (Pull in libdevstat on FreeBSD) - rust-lang#91987 (Add module documentation for rustdoc passes) - rust-lang#92001 (Fix default_method_body_is_const when used across crates) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5531927 + a97384d commit 23c2723

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+250
-42
lines changed

Diff for: Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3688,6 +3688,7 @@ dependencies = [
36883688
"rustc_expand",
36893689
"rustc_feature",
36903690
"rustc_lexer",
3691+
"rustc_lint_defs",
36913692
"rustc_parse",
36923693
"rustc_parse_format",
36933694
"rustc_session",

Diff for: compiler/rustc_borrowck/src/borrow_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub enum LocalsStateAtExit {
8484
}
8585

8686
impl LocalsStateAtExit {
87-
fn build(
87+
fn build<'tcx>(
8888
locals_are_invalidated_at_exit: bool,
8989
body: &Body<'tcx>,
9090
move_data: &MoveData<'tcx>,

Diff for: compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum UniverseInfoInner<'tcx> {
3131
Other,
3232
}
3333

34-
impl UniverseInfo<'tcx> {
34+
impl<'tcx> UniverseInfo<'tcx> {
3535
crate fn other() -> UniverseInfo<'tcx> {
3636
UniverseInfo(UniverseInfoInner::Other)
3737
}
@@ -191,7 +191,7 @@ struct PredicateQuery<'tcx> {
191191
base_universe: ty::UniverseIndex,
192192
}
193193

194-
impl TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
194+
impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
195195
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
196196
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
197197
err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate));
@@ -231,7 +231,7 @@ struct NormalizeQuery<'tcx, T> {
231231
base_universe: ty::UniverseIndex,
232232
}
233233

234-
impl<T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T>
234+
impl<'tcx, T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T>
235235
where
236236
T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx,
237237
{
@@ -291,7 +291,7 @@ struct AscribeUserTypeQuery<'tcx> {
291291
base_universe: ty::UniverseIndex,
292292
}
293293

294-
impl TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
294+
impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
295295
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
296296
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
297297
// and is only the fallback when the nice error fails. Consider improving this some more.

Diff for: compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15981598
location: Location,
15991599
mpi: MovePathIndex,
16001600
) -> (Vec<MoveSite>, Vec<Location>) {
1601-
fn predecessor_locations(
1602-
body: &'a mir::Body<'tcx>,
1601+
fn predecessor_locations<'a>(
1602+
body: &'a mir::Body<'_>,
16031603
location: Location,
16041604
) -> impl Iterator<Item = Location> + 'a {
16051605
if location.statement_index == 0 {

Diff for: compiler/rustc_borrowck/src/diagnostics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
409409
/// Add a note that a type does not implement `Copy`
410410
pub(super) fn note_type_does_not_implement_copy(
411411
&self,
412-
err: &mut DiagnosticBuilder<'a>,
412+
err: &mut DiagnosticBuilder<'_>,
413413
place_desc: &str,
414414
ty: Ty<'tcx>,
415415
span: Option<Span>,
@@ -733,7 +733,7 @@ pub(super) enum BorrowedContentSource<'tcx> {
733733
OverloadedIndex(Ty<'tcx>),
734734
}
735735

736-
impl BorrowedContentSource<'tcx> {
736+
impl<'tcx> BorrowedContentSource<'tcx> {
737737
pub(super) fn describe_for_unnamed_place(&self, tcx: TyCtxt<'_>) -> String {
738738
match *self {
739739
BorrowedContentSource::DerefRawPointer => "a raw pointer".to_string(),

Diff for: compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
747747
HirId, ImplItem, ImplItemKind, Item, ItemKind,
748748
};
749749

750-
fn maybe_body_id_of_fn(hir_map: &Map<'tcx>, id: HirId) -> Option<BodyId> {
750+
fn maybe_body_id_of_fn(hir_map: &Map<'_>, id: HirId) -> Option<BodyId> {
751751
match hir_map.find(id) {
752752
Some(Node::Item(Item { kind: ItemKind::Fn(_, _, body_id), .. }))
753753
| Some(Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })) => {
@@ -1066,7 +1066,7 @@ fn is_closure_or_generator(ty: Ty<'_>) -> bool {
10661066
/// LL | s: &'a String
10671067
/// | ---------- use `&'a mut String` here to make mutable
10681068
/// ```
1069-
fn annotate_struct_field(
1069+
fn annotate_struct_field<'tcx>(
10701070
tcx: TyCtxt<'tcx>,
10711071
ty: Ty<'tcx>,
10721072
field: &mir::Field,

Diff for: compiler/rustc_borrowck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(bool_to_option)]
44
#![feature(box_patterns)]
55
#![feature(crate_visibility_modifier)]
6-
#![feature(in_band_lifetimes)]
76
#![feature(let_else)]
87
#![feature(min_specialization)]
98
#![feature(stmt_expr_attributes)]

Diff for: compiler/rustc_borrowck/src/member_constraints.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ rustc_index::newtype_index! {
5353
}
5454
}
5555

56-
impl Default for MemberConstraintSet<'tcx, ty::RegionVid> {
56+
impl Default for MemberConstraintSet<'_, ty::RegionVid> {
5757
fn default() -> Self {
5858
Self {
5959
first_constraints: Default::default(),
@@ -97,7 +97,7 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
9797
}
9898
}
9999

100-
impl<R1> MemberConstraintSet<'tcx, R1>
100+
impl<'tcx, R1> MemberConstraintSet<'tcx, R1>
101101
where
102102
R1: Copy + Hash + Eq,
103103
{
@@ -140,7 +140,7 @@ where
140140
}
141141
}
142142

143-
impl<R> MemberConstraintSet<'tcx, R>
143+
impl<R> MemberConstraintSet<'_, R>
144144
where
145145
R: Copy + Hash + Eq,
146146
{

Diff for: compiler/rustc_borrowck/src/path_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub(super) fn borrow_of_local_data(place: Place<'_>) -> bool {
141141
/// then returns the index of the field being projected. Note that this closure will always
142142
/// be `self` in the current MIR, because that is the only time we directly access the fields
143143
/// of a closure type.
144-
pub(crate) fn is_upvar_field_projection(
144+
pub(crate) fn is_upvar_field_projection<'tcx>(
145145
tcx: TyCtxt<'tcx>,
146146
upvars: &[Upvar<'tcx>],
147147
place_ref: PlaceRef<'tcx>,

Diff for: compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ crate struct CreateResult<'tcx> {
5858
crate normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>,
5959
}
6060

61-
crate fn create(
61+
crate fn create<'tcx>(
6262
infcx: &InferCtxt<'_, 'tcx>,
6363
param_env: ty::ParamEnv<'tcx>,
6464
implicit_region_bound: Option<ty::Region<'tcx>>,
@@ -81,7 +81,7 @@ crate fn create(
8181
.create()
8282
}
8383

84-
impl UniversalRegionRelations<'tcx> {
84+
impl UniversalRegionRelations<'_> {
8585
/// Records in the `outlives_relation` (and
8686
/// `inverse_outlives_relation`) that `fr_a: fr_b`. Invoked by the
8787
/// builder below.
@@ -110,7 +110,7 @@ impl UniversalRegionRelations<'tcx> {
110110
/// outlives `fr` and (b) is not local.
111111
///
112112
/// (*) If there are multiple competing choices, we return all of them.
113-
crate fn non_local_upper_bounds(&'a self, fr: &'a RegionVid) -> Vec<&'a RegionVid> {
113+
crate fn non_local_upper_bounds<'a>(&'a self, fr: &'a RegionVid) -> Vec<&'a RegionVid> {
114114
debug!("non_local_upper_bound(fr={:?})", fr);
115115
let res = self.non_local_bounds(&self.inverse_outlives, fr);
116116
assert!(!res.is_empty(), "can't find an upper bound!?");
@@ -232,7 +232,7 @@ struct UniversalRegionRelationsBuilder<'this, 'tcx> {
232232
region_bound_pairs: RegionBoundPairs<'tcx>,
233233
}
234234

235-
impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
235+
impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
236236
crate fn create(mut self) -> CreateResult<'tcx> {
237237
let unnormalized_input_output_tys = self
238238
.universal_regions

Diff for: compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl LocalUseMapBuild<'_> {
152152
}
153153
}
154154

155-
impl Visitor<'tcx> for LocalUseMapBuild<'_> {
155+
impl Visitor<'_> for LocalUseMapBuild<'_> {
156156
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
157157
if self.locals_with_use_data[local] {
158158
match def_use::categorize(context) {

Diff for: compiler/rustc_borrowck/src/type_check/liveness/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub(super) fn generate<'mir, 'tcx>(
7474
// to compute whether a variable `X` is live if that variable contains
7575
// some region `R` in its type where `R` is not known to outlive a free
7676
// region (i.e., where `R` may be valid for just a subset of the fn body).
77-
fn compute_live_locals(
77+
fn compute_live_locals<'tcx>(
7878
tcx: TyCtxt<'tcx>,
7979
free_regions: &FxHashSet<RegionVid>,
8080
body: &Body<'tcx>,
@@ -104,7 +104,7 @@ fn compute_live_locals(
104104
/// regions. For these regions, we do not need to compute
105105
/// liveness, since the outlives constraints will ensure that they
106106
/// are live over the whole fn body anyhow.
107-
fn regions_that_outlive_free_regions(
107+
fn regions_that_outlive_free_regions<'tcx>(
108108
num_region_vars: usize,
109109
universal_regions: &UniversalRegions<'tcx>,
110110
constraint_set: &OutlivesConstraintSet<'tcx>,

Diff for: compiler/rustc_borrowck/src/type_check/liveness/polonius.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl UseFactsExtractor<'_> {
5353
}
5454
}
5555

56-
impl Visitor<'tcx> for UseFactsExtractor<'_> {
56+
impl Visitor<'_> for UseFactsExtractor<'_> {
5757
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
5858
match def_use::categorize(context) {
5959
Some(DefUse::Def) => self.insert_def(local, location),
@@ -63,7 +63,7 @@ impl Visitor<'tcx> for UseFactsExtractor<'_> {
6363
}
6464
}
6565

66-
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
66+
fn visit_place(&mut self, place: &Place<'_>, context: PlaceContext, location: Location) {
6767
self.super_place(place, context, location);
6868
match context {
6969
PlaceContext::NonMutatingUse(_) => {
@@ -82,7 +82,7 @@ impl Visitor<'tcx> for UseFactsExtractor<'_> {
8282
}
8383
}
8484

85-
pub(super) fn populate_access_facts(
85+
pub(super) fn populate_access_facts<'tcx>(
8686
typeck: &mut TypeChecker<'_, 'tcx>,
8787
body: &Body<'tcx>,
8888
location_table: &LocationTable,
@@ -123,7 +123,7 @@ pub(super) fn populate_access_facts(
123123

124124
// For every potentially drop()-touched region `region` in `local`'s type
125125
// (`kind`), emit a Polonius `use_of_var_derefs_origin(local, origin)` fact.
126-
pub(super) fn add_drop_of_var_derefs_origin(
126+
pub(super) fn add_drop_of_var_derefs_origin<'tcx>(
127127
typeck: &mut TypeChecker<'_, 'tcx>,
128128
local: Local,
129129
kind: &GenericArg<'tcx>,

Diff for: compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::{
3434
/// DROP-LIVE set are to the liveness sets for regions found in the
3535
/// `dropck_outlives` result of the variable's type (in particular,
3636
/// this respects `#[may_dangle]` annotations).
37-
pub(super) fn trace(
37+
pub(super) fn trace<'mir, 'tcx>(
3838
typeck: &mut TypeChecker<'_, 'tcx>,
3939
body: &Body<'tcx>,
4040
elements: &Rc<RegionValueElements>,
@@ -119,7 +119,7 @@ struct LivenessResults<'me, 'typeck, 'flow, 'tcx> {
119119
stack: Vec<PointIndex>,
120120
}
121121

122-
impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
122+
impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
123123
fn new(cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>) -> Self {
124124
let num_points = cx.elements.num_points();
125125
LivenessResults {
@@ -418,7 +418,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
418418
}
419419
}
420420

421-
impl LivenessContext<'_, '_, '_, 'tcx> {
421+
impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
422422
/// Returns `true` if the local variable (or some part of it) is initialized at the current
423423
/// cursor position. Callers should call one of the `seek` methods immediately before to point
424424
/// the cursor to the desired location.

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ crate struct MirTypeckRegionConstraints<'tcx> {
945945
crate type_tests: Vec<TypeTest<'tcx>>,
946946
}
947947

948-
impl MirTypeckRegionConstraints<'tcx> {
948+
impl<'tcx> MirTypeckRegionConstraints<'tcx> {
949949
fn placeholder_region(
950950
&mut self,
951951
infcx: &InferCtxt<'_, 'tcx>,

Diff for: compiler/rustc_borrowck/src/type_check/relate_tys.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
5151
universe_info: UniverseInfo<'tcx>,
5252
}
5353

54-
impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
54+
impl<'me, 'bccx, 'tcx> NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
5555
fn new(
5656
type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
5757
locations: Locations,
@@ -62,7 +62,7 @@ impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
6262
}
6363
}
6464

65-
impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
65+
impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
6666
fn param_env(&self) -> ty::ParamEnv<'tcx> {
6767
self.type_checker.param_env
6868
}

Diff for: compiler/rustc_builtin_macros/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rustc_data_structures = { path = "../rustc_data_structures" }
1515
rustc_errors = { path = "../rustc_errors" }
1616
rustc_feature = { path = "../rustc_feature" }
1717
rustc_lexer = { path = "../rustc_lexer" }
18+
rustc_lint_defs = { path = "../rustc_lint_defs" }
1819
rustc_parse = { path = "../rustc_parse" }
1920
rustc_target = { path = "../rustc_target" }
2021
rustc_session = { path = "../rustc_session" }

Diff for: compiler/rustc_builtin_macros/src/cfg_eval.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::util::check_builtin_macro_attribute;
1+
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
22

33
use rustc_ast as ast;
44
use rustc_ast::mut_visit::MutVisitor;
@@ -25,6 +25,7 @@ crate fn expand(
2525
annotatable: Annotatable,
2626
) -> Vec<Annotatable> {
2727
check_builtin_macro_attribute(ecx, meta_item, sym::cfg_eval);
28+
warn_on_duplicate_attribute(&ecx, &annotatable, sym::cfg_eval);
2829
vec![cfg_eval(ecx.sess, ecx.ecfg.features, annotatable)]
2930
}
3031

Diff for: compiler/rustc_builtin_macros/src/test.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// The expansion from a test function to the appropriate test struct for libtest
22
/// Ideally, this code would be in libtest but for efficiency and error messages it lives here.
3-
use crate::util::check_builtin_macro_attribute;
3+
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
44

55
use rustc_ast as ast;
66
use rustc_ast::attr;
@@ -27,6 +27,7 @@ pub fn expand_test_case(
2727
anno_item: Annotatable,
2828
) -> Vec<Annotatable> {
2929
check_builtin_macro_attribute(ecx, meta_item, sym::test_case);
30+
warn_on_duplicate_attribute(&ecx, &anno_item, sym::test_case);
3031

3132
if !ecx.ecfg.should_test {
3233
return vec![];
@@ -55,6 +56,7 @@ pub fn expand_test(
5556
item: Annotatable,
5657
) -> Vec<Annotatable> {
5758
check_builtin_macro_attribute(cx, meta_item, sym::test);
59+
warn_on_duplicate_attribute(&cx, &item, sym::test);
5860
expand_test_or_bench(cx, attr_sp, item, false)
5961
}
6062

@@ -65,6 +67,7 @@ pub fn expand_bench(
6567
item: Annotatable,
6668
) -> Vec<Annotatable> {
6769
check_builtin_macro_attribute(cx, meta_item, sym::bench);
70+
warn_on_duplicate_attribute(&cx, &item, sym::bench);
6871
expand_test_or_bench(cx, attr_sp, item, true)
6972
}
7073

Diff for: compiler/rustc_builtin_macros/src/util.rs

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use rustc_ast::MetaItem;
2-
use rustc_expand::base::ExtCtxt;
1+
use rustc_ast::{Attribute, MetaItem};
2+
use rustc_expand::base::{Annotatable, ExtCtxt};
33
use rustc_feature::AttributeTemplate;
4+
use rustc_lint_defs::builtin::DUPLICATE_MACRO_ATTRIBUTES;
45
use rustc_parse::validate_attr;
56
use rustc_span::Symbol;
67

@@ -10,3 +11,33 @@ pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, na
1011
let attr = ecx.attribute(meta_item.clone());
1112
validate_attr::check_builtin_attribute(&ecx.sess.parse_sess, &attr, name, template);
1213
}
14+
15+
/// Emit a warning if the item is annotated with the given attribute. This is used to diagnose when
16+
/// an attribute may have been mistakenly duplicated.
17+
pub fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable, name: Symbol) {
18+
let attrs: Option<&[Attribute]> = match item {
19+
Annotatable::Item(item) => Some(&item.attrs),
20+
Annotatable::TraitItem(item) => Some(&item.attrs),
21+
Annotatable::ImplItem(item) => Some(&item.attrs),
22+
Annotatable::ForeignItem(item) => Some(&item.attrs),
23+
Annotatable::Expr(expr) => Some(&expr.attrs),
24+
Annotatable::Arm(arm) => Some(&arm.attrs),
25+
Annotatable::ExprField(field) => Some(&field.attrs),
26+
Annotatable::PatField(field) => Some(&field.attrs),
27+
Annotatable::GenericParam(param) => Some(&param.attrs),
28+
Annotatable::Param(param) => Some(&param.attrs),
29+
Annotatable::FieldDef(def) => Some(&def.attrs),
30+
Annotatable::Variant(variant) => Some(&variant.attrs),
31+
_ => None,
32+
};
33+
if let Some(attrs) = attrs {
34+
if let Some(attr) = ecx.sess.find_by_name(attrs, name) {
35+
ecx.parse_sess().buffer_lint(
36+
DUPLICATE_MACRO_ATTRIBUTES,
37+
attr.span,
38+
ecx.current_expansion.lint_node_id,
39+
"duplicated attribute",
40+
);
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)