Skip to content

Commit 1e5719b

Browse files
committed
Auto merge of #131196 - matthiaskrgr:rollup-3it3zqp, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #130419 (Streamline `HirCollector`) - #131163 (Add `get_line` confusable to `Stdin::read_line()`) - #131173 (Fix `target_abi` in SOLID targets) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f7c8928 + 35ff9e2 commit 1e5719b

8 files changed

Lines changed: 44 additions & 38 deletions

File tree

‎compiler/rustc_ast_passes/src/ast_validation.rs‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl TraitOrTraitImpl {
6363
}
6464

6565
structAstValidator<'a>{
66-
session:&'aSession,
66+
sess:&'aSession,
6767
features:&'aFeatures,
6868

6969
/// The span of the `extern` in an `extern { ... }` block, if any.
@@ -267,7 +267,7 @@ impl<'a> AstValidator<'a> {
267267
}
268268

269269
fndcx(&self) -> DiagCtxtHandle<'a>{
270-
self.session.dcx()
270+
self.sess.dcx()
271271
}
272272

273273
fnvisibility_not_permitted(&self,vis:&Visibility,note: errors::VisibilityNotPermittedNote){
@@ -359,7 +359,7 @@ impl<'a> AstValidator<'a> {
359359
in_impl:matches!(parent,TraitOrTraitImpl::TraitImpl{ .. }),
360360
const_context_label: parent_constness,
361361
remove_const_sugg:(
362-
self.session.source_map().span_extend_while_whitespace(span),
362+
self.sess.source_map().span_extend_while_whitespace(span),
363363
match parent_constness {
364364
Some(_) => rustc_errors::Applicability::MachineApplicable,
365365
None => rustc_errors::Applicability::MaybeIncorrect,
@@ -472,15 +472,15 @@ impl<'a> AstValidator<'a> {
472472

473473
fncheck_defaultness(&self,span:Span,defaultness:Defaultness){
474474
ifletDefaultness::Default(def_span) = defaultness {
475-
let span = self.session.source_map().guess_head_span(span);
475+
let span = self.sess.source_map().guess_head_span(span);
476476
self.dcx().emit_err(errors::ForbiddenDefault{ span, def_span });
477477
}
478478
}
479479

480480
/// If `sp` ends with a semicolon, returns it as a `Span`
481481
/// Otherwise, returns `sp.shrink_to_hi()`
482482
fnending_semi_or_hi(&self,sp:Span) -> Span{
483-
let source_map = self.session.source_map();
483+
let source_map = self.sess.source_map();
484484
let end = source_map.end_point(sp);
485485

486486
if source_map.span_to_snippet(end).is_ok_and(|s| s == ";"){
@@ -552,7 +552,7 @@ impl<'a> AstValidator<'a> {
552552
}
553553

554554
fncurrent_extern_span(&self) -> Span{
555-
self.session.source_map().guess_head_span(self.extern_mod.unwrap())
555+
self.sess.source_map().guess_head_span(self.extern_mod.unwrap())
556556
}
557557

558558
/// An `fn` in `extern { ... }` cannot have qualifiers, e.g. `async fn`.
@@ -648,7 +648,7 @@ impl<'a> AstValidator<'a> {
648648
if ident.name.as_str().is_ascii(){
649649
return;
650650
}
651-
let span = self.session.source_map().guess_head_span(item_span);
651+
let span = self.sess.source_map().guess_head_span(item_span);
652652
self.dcx().emit_err(errors::NoMangleAscii{ span });
653653
}
654654

@@ -753,7 +753,7 @@ impl<'a> AstValidator<'a> {
753753
self.dcx().emit_err(errors::PatternFnPointer{ span });
754754
});
755755
ifletExtern::Implicit(_) = bfty.ext{
756-
let sig_span = self.session.source_map().next_point(ty.span.shrink_to_lo());
756+
let sig_span = self.sess.source_map().next_point(ty.span.shrink_to_lo());
757757
self.maybe_lint_missing_abi(sig_span, ty.id);
758758
}
759759
}
@@ -795,7 +795,7 @@ impl<'a> AstValidator<'a> {
795795
// FIXME(davidtwco): This is a hack to detect macros which produce spans of the
796796
// call site which do not have a macro backtrace. See #61963.
797797
ifself
798-
.session
798+
.sess
799799
.source_map()
800800
.span_to_snippet(span)
801801
.is_ok_and(|snippet| !snippet.starts_with("#["))
@@ -885,7 +885,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
885885

886886
impl<'a>Visitor<'a>forAstValidator<'a>{
887887
fnvisit_attribute(&mutself,attr:&Attribute){
888-
validate_attr::check_attr(&self.session.psess, attr);
888+
validate_attr::check_attr(&self.sess.psess, attr);
889889
}
890890

891891
fnvisit_ty(&mutself,ty:&'aTy){
@@ -1192,7 +1192,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11921192
}elseif where_clauses.after.has_where_token{
11931193
self.dcx().emit_err(errors::WhereClauseAfterTypeAlias{
11941194
span: where_clauses.after.span,
1195-
help:self.session.is_nightly_build(),
1195+
help:self.sess.is_nightly_build(),
11961196
});
11971197
}
11981198
}
@@ -1328,7 +1328,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13281328
(BoundKind::SuperTraits,BoundConstness::Never,BoundPolarity::Maybe(_))
13291329
if !self.features.more_maybe_bounds =>
13301330
{
1331-
self.session
1331+
self.sess
13321332
.create_feature_err(
13331333
errors::OptionalTraitSupertrait{
13341334
span: trait_ref.span,
@@ -1341,7 +1341,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13411341
(BoundKind::TraitObject,BoundConstness::Never,BoundPolarity::Maybe(_))
13421342
if !self.features.more_maybe_bounds =>
13431343
{
1344-
self.session
1344+
self.sess
13451345
.create_feature_err(
13461346
errors::OptionalTraitObject{span: trait_ref.span},
13471347
sym::more_maybe_bounds,
@@ -1752,13 +1752,13 @@ fn deny_equality_constraints(
17521752
}
17531753

17541754
pubfncheck_crate(
1755-
session:&Session,
1755+
sess:&Session,
17561756
features:&Features,
17571757
krate:&Crate,
17581758
lints:&mutLintBuffer,
17591759
) -> bool{
17601760
letmut validator = AstValidator{
1761-
session,
1761+
sess,
17621762
features,
17631763
extern_mod:None,
17641764
outer_trait_or_trait_impl:None,

‎compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabi.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
1414
data_layout:"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
1515
arch:"arm".into(),
1616
options:TargetOptions{
17+
abi:"eabi".into(),
1718
linker:Some("arm-kmc-eabi-gcc".into()),
1819
features:"+v7,+soft-float,+thumb2,-neon".into(),
1920
relocation_model:RelocModel::Static,

‎compiler/rustc_target/src/spec/targets/armv7a_kmc_solid_asp3_eabihf.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub(crate) fn target() -> Target {
1414
data_layout:"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
1515
arch:"arm".into(),
1616
options:TargetOptions{
17+
abi:"eabihf".into(),
1718
linker:Some("arm-kmc-eabi-gcc".into()),
1819
features:"+v7,+vfp3,-d32,+thumb2,-neon".into(),
1920
relocation_model:RelocModel::Static,

‎library/std/src/io/stdio.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ impl Stdin {
394394
/// in which case it will wait for the Enter key to be pressed before
395395
/// continuing
396396
#[stable(feature = "rust1", since = "1.0.0")]
397+
#[rustc_confusables("get_line")]
397398
pubfnread_line(&self,buf:&mutString) -> io::Result<usize>{
398399
self.lock().read_line(buf)
399400
}

‎src/librustdoc/doctest.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ pub(crate) fn run(
186186

187187
letmut collector = CreateRunnableDocTests::new(options, opts);
188188
let hir_collector = HirCollector::new(
189-
&compiler.sess,
190-
tcx.hir(),
191189
ErrorCodes::from(compiler.sess.opts.unstable_features.is_nightly_build()),
192190
enable_per_target_ignores,
193191
tcx,

‎src/librustdoc/doctest/rust.rs‎

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use rustc_data_structures::fx::FxHashSet;
66
use rustc_data_structures::sync::Lrc;
77
use rustc_hir::def_id::{CRATE_DEF_ID,LocalDefId};
88
use rustc_hir::{selfas hir,CRATE_HIR_ID, intravisit};
9-
use rustc_middle::hir::map::Map;
109
use rustc_middle::hir::nested_filter;
1110
use rustc_middle::ty::TyCtxt;
1211
use rustc_resolve::rustdoc::span_of_fragments;
13-
use rustc_session::Session;
1412
use rustc_span::source_map::SourceMap;
1513
use rustc_span::{BytePos,DUMMY_SP,FileName,Pos,Span};
1614

@@ -63,30 +61,22 @@ impl DocTestVisitor for RustCollector {
6361
fnvisit_header(&mutself,_name:&str,_level:u32){}
6462
}
6563

66-
pub(super)structHirCollector<'a,'tcx>{
67-
sess:&'aSession,
68-
map:Map<'tcx>,
64+
pub(super)structHirCollector<'tcx>{
6965
codes:ErrorCodes,
7066
tcx:TyCtxt<'tcx>,
7167
enable_per_target_ignores:bool,
7268
collector:RustCollector,
7369
}
7470

75-
impl<'a,'tcx>HirCollector<'a,'tcx>{
76-
pubfnnew(
77-
sess:&'aSession,
78-
map:Map<'tcx>,
79-
codes:ErrorCodes,
80-
enable_per_target_ignores:bool,
81-
tcx:TyCtxt<'tcx>,
82-
) -> Self{
71+
impl<'tcx>HirCollector<'tcx>{
72+
pubfnnew(codes:ErrorCodes,enable_per_target_ignores:bool,tcx:TyCtxt<'tcx>) -> Self{
8373
let collector = RustCollector{
84-
source_map: sess.psess.clone_source_map(),
74+
source_map:tcx.sess.psess.clone_source_map(),
8575
cur_path:vec![],
8676
position:DUMMY_SP,
8777
tests:vec![],
8878
};
89-
Self{sess, map,codes, enable_per_target_ignores, tcx, collector }
79+
Self{ codes, enable_per_target_ignores, tcx, collector }
9080
}
9181

9282
pubfncollect_crate(mutself) -> Vec<ScrapedDocTest>{
@@ -98,7 +88,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
9888
}
9989
}
10090

101-
impl<'a,'tcx>HirCollector<'a,'tcx>{
91+
impl<'tcx>HirCollector<'tcx>{
10292
fnvisit_testable<F:FnOnce(&mutSelf)>(
10393
&mutself,
10494
name:String,
@@ -108,7 +98,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
10898
){
10999
let ast_attrs = self.tcx.hir().attrs(self.tcx.local_def_id_to_hir_id(def_id));
110100
ifletSome(ref cfg) = ast_attrs.cfg(self.tcx,&FxHashSet::default()){
111-
if !cfg.matches(&self.sess.psess,Some(self.tcx.features())){
101+
if !cfg.matches(&self.tcx.sess.psess,Some(self.tcx.features())){
112102
return;
113103
}
114104
}
@@ -141,17 +131,17 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
141131
}
142132
}
143133

144-
impl<'a,'tcx> intravisit::Visitor<'tcx>forHirCollector<'a,'tcx>{
134+
impl<'tcx> intravisit::Visitor<'tcx>forHirCollector<'tcx>{
145135
typeNestedFilter = nested_filter::All;
146136

147137
fnnested_visit_map(&mutself) -> Self::Map{
148-
self.map
138+
self.tcx.hir()
149139
}
150140

151141
fnvisit_item(&mutself,item:&'tcx hir::Item<'_>){
152142
let name = match&item.kind{
153143
hir::ItemKind::Impl(impl_) => {
154-
rustc_hir_pretty::id_to_string(&self.map, impl_.self_ty.hir_id)
144+
rustc_hir_pretty::id_to_string(&self.tcx.hir(), impl_.self_ty.hir_id)
155145
}
156146
_ => item.ident.to_string(),
157147
};

‎tests/ui/attributes/rustc_confusables_std_cases.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ fn main() {
2323
//~^ HELP you might have meant to use `push_str`
2424
String::new().append("");//~ ERROR E0599
2525
//~^ HELP you might have meant to use `push_str`
26+
letmut buffer = String::new();
27+
let stdin = std::io::stdin();
28+
stdin.get_line(&mut buffer).unwrap();//~ ERROR E0599
29+
//~^ HELP you might have meant to use `read_line`
2630
}

‎tests/ui/attributes/rustc_confusables_std_cases.stderr‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,18 @@ help: you might have meant to use `push_str`
106106
LL | String::new().push_str("");
107107
| ~~~~~~~~
108108

109-
error: aborting due to 8 previous errors
109+
error[E0599]: no method named `get_line` found for struct `Stdin` in the current scope
110+
--> $DIR/rustc_confusables_std_cases.rs:28:11
111+
|
112+
LL | stdin.get_line(&mut buffer).unwrap();
113+
| ^^^^^^^^ method not found in `Stdin`
114+
|
115+
help: you might have meant to use `read_line`
116+
|
117+
LL | stdin.read_line(&mut buffer).unwrap();
118+
| ~~~~~~~~~
119+
120+
error: aborting due to 9 previous errors
110121

111122
Some errors have detailed explanations: E0308, E0599.
112123
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)