Skip to content

Rollup of 9 pull requests #107311

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f920008
Improve proc macro attribute diagnostics
Jan 3, 2023
a8e3abd
Address feedback
Jan 8, 2023
2d82420
Teach parser to understand fake anonymous enum syntax
estebank Jan 15, 2023
c847a01
Emit fewer errors on patterns with possible type ascription
estebank Jan 17, 2023
12d18e4
Ensure macros are not affected
estebank Jan 17, 2023
8e43414
Fix proc macro tests
mejrs Jan 19, 2023
d3cfe97
Custom MIR: Support binary and unary operations
tmiasko Jan 19, 2023
96f8f99
rustc_abi: remove Primitive::{is_float,is_int}
erikdesjardins Jan 23, 2023
009192b
abi: add `AddressSpace` field to `Primitive::Pointer`
erikdesjardins Jan 23, 2023
bed3bb5
Don't resolve type var roots in point_at_expr_source_of_inferred_type
compiler-errors Jan 21, 2023
9f933b5
Hack to suppress bad labels in type mismatch inference deduction code
compiler-errors Jan 21, 2023
020cca8
review comment: Remove AST AnonTy
estebank Jan 23, 2023
72117ab
Print PID holding bootstrap build lock on Linux
clubby789 Jan 19, 2023
adc1890
create and use GlobalAlloc::address_space
erikdesjardins Jan 25, 2023
8b12d5f
suggest qualifying bare associated constants
euclio Jan 22, 2023
b3f0085
Implement ObjectSafe and WF in the new solver
compiler-errors Jan 24, 2023
02b80d2
Don't normalize obligations in WF goal for the new solver
compiler-errors Jan 24, 2023
a274046
Report the right fulfillment errors
compiler-errors Jan 24, 2023
b5f893b
Implement Generator and Future
compiler-errors Jan 24, 2023
9b86d54
Rollup merge of #106407 - mejrs:attr_check, r=compiler-errors
matthiaskrgr Jan 25, 2023
ce52f5d
Rollup merge of #106960 - estebank:parse-anon-enums, r=cjgillot
matthiaskrgr Jan 25, 2023
8e25863
Rollup merge of #107085 - tmiasko:custom-mir-operators, r=oli-obk
matthiaskrgr Jan 25, 2023
d73aba8
Rollup merge of #107086 - clubby789:bootstrap-lock-pid-linux, r=alber…
matthiaskrgr Jan 25, 2023
ebbe6d1
Rollup merge of #107175 - compiler-errors:bad-types-in-vec-push, r=es…
matthiaskrgr Jan 25, 2023
3c8ae7e
Rollup merge of #107204 - euclio:assoc-const-suggestion, r=petrochenkov
matthiaskrgr Jan 25, 2023
6bf0e73
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
matthiaskrgr Jan 25, 2023
cfce51d
Rollup merge of #107272 - compiler-errors:new-solver-more-predicates,…
matthiaskrgr Jan 25, 2023
efca03b
Rollup merge of #107285 - compiler-errors:new-solver-future-and-gener…
matthiaskrgr Jan 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
suggest qualifying bare associated constants
  • Loading branch information
euclio committed Jan 25, 2023
commit 8b12d5f42f98f50e5e47156eea343ea6d32b10db
17 changes: 12 additions & 5 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,27 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
&& let Some(FnCtxt::Assoc(_)) = fn_kind.ctxt()
&& let Some(items) = self.diagnostic_metadata.current_impl_items
&& let Some(item) = items.iter().find(|i| {
if let AssocItemKind::Fn(_) = &i.kind && i.ident.name == item_str.name
if let AssocItemKind::Fn(..) | AssocItemKind::Const(..) = &i.kind
&& i.ident.name == item_str.name
{
debug!(?item_str.name);
return true
}
false
})
&& let AssocItemKind::Fn(fn_) = &item.kind
{
debug!(?fn_);
let self_sugg = if fn_.sig.decl.has_self() { "self." } else { "Self::" };
let self_sugg = match &item.kind {
AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => "self.",
_ => "Self::",
};

Some((
item_span.shrink_to_lo(),
"consider using the associated function",
match &item.kind {
AssocItemKind::Fn(..) => "consider using the associated function",
AssocItemKind::Const(..) => "consider using the associated constant",
_ => unreachable!("item kind was filtered above"),
},
self_sugg.to_string()
))
} else {
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/suggestions/assoc-const-without-self.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
struct Foo;

impl Foo {
const A_CONST: usize = 1;

fn foo() -> usize {
A_CONST //~ ERROR cannot find value `A_CONST` in this scope
}
}

fn main() {}
14 changes: 14 additions & 0 deletions tests/ui/suggestions/assoc-const-without-self.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0425]: cannot find value `A_CONST` in this scope
--> $DIR/assoc-const-without-self.rs:7:9
|
LL | A_CONST
| ^^^^^^^ not found in this scope
|
help: consider using the associated constant
|
LL | Self::A_CONST
| ++++++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.