Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add future_prelude_collision lint #85707

Merged
merged 25 commits into from
Jun 22, 2021
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
79388aa
Add future_prelude_collision lint
jam1garner May 26, 2021
01bdb8e
Disable `future_prelude_collision` for 2021 edition
jam1garner May 26, 2021
a9dc234
Add docs for FnCtxt::resolve_ufcs
jam1garner May 27, 2021
1626e19
Add support for associated functions to `future_prelude_collision` lint
jam1garner May 27, 2021
c341d5b
Improve documentation for `future_prelude_collision` lint
jam1garner May 27, 2021
35af383
Add UI tests for `future_prelude_collision` lint
jam1garner May 27, 2021
c41a157
Fix incorrect argument description on FnCtxt::resolve_ufcs
jam1garner May 27, 2021
327697a
Fix autoderef and autoref for `future_prelude_collision` lint
jam1garner May 27, 2021
eb5e0af
Add autoderef and autoref tests for `future_prelude_collision` lint
jam1garner May 27, 2021
93c60f2
Fix missing generic parameters from `future_prelude_collision` lint s…
jam1garner May 27, 2021
cb49992
Fix `future_prelude_collision` lint breaking for pointer mutabilty co…
jam1garner May 28, 2021
4a21a0b
Fix `future_prelude_collision` not maintaining type aliases
jam1garner May 28, 2021
64c61a3
Fix `future_prelude_collision` adding unneeded generic arguments
jam1garner May 28, 2021
32408cf
move test to rust-2021 directory
nikomatsakis Jun 4, 2021
19ba219
add inherent-method-collision test
nikomatsakis Jun 4, 2021
8d42f3d
don't warn for fully qual inherent methods
nikomatsakis Jun 14, 2021
17ab9c0
extract Rust 2021 prelude logic to its own module
nikomatsakis Jun 14, 2021
3efa5b4
Emit additional arguments in `future_prelude_collision` lint
jam1garner Jun 15, 2021
56108f6
Add future_prelude_collision to 2021 compat group
jam1garner Jun 15, 2021
dbc9da7
WIP: Find the imports that were used to reach a method
nikomatsakis Jun 17, 2021
9bee7f0
WIP: identify the case where we need to serialize path
nikomatsakis Jun 18, 2021
b18704d
Fix future_prelude_collision for object calls and use as _
jam1garner Jun 19, 2021
3dc47e2
do not run rustfix for future-prelude-collision-shadow
nikomatsakis Jun 21, 2021
186c09a
add test for `dyn` collisions
nikomatsakis Jun 21, 2021
aa3580b
introduce helper function
nikomatsakis Jun 21, 2021
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
Fix autoderef and autoref for future_prelude_collision lint
  • Loading branch information
jam1garner authored and nikomatsakis committed Jun 14, 2021
commit 327697a540cfab44c7d9c9c7c62948f8f9667fc5
14 changes: 13 additions & 1 deletion compiler/rustc_typeck/src/check/method/mod.rs
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ pub use self::CandidateSource::*;
pub use self::MethodError::*;

use crate::check::FnCtxt;
use rustc_ast::ast::Mutability;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir;
@@ -222,12 +223,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Ok(self_expr) =
self.sess().source_map().span_to_snippet(self_expr.span)
{
let derefs = "*".repeat(pick.autoderefs);
let self_adjusted = match pick.autoref_or_ptr_adjustment {
Some(probe::AutorefOrPtrAdjustment::Autoref {
mutbl: Mutability::Mut, ..
}) => format!("&mut {}{}", derefs, self_expr),
Some(probe::AutorefOrPtrAdjustment::Autoref {
mutbl: Mutability::Not, ..
}) => format!("&{}{}", derefs, self_expr),
Some(probe::AutorefOrPtrAdjustment::ToConstPtr) | None
jam1garner marked this conversation as resolved.
Show resolved Hide resolved
=> format!("{}{}", derefs, self_expr),
};
lint.span_suggestion(
sp,
"disambiguate the associated function",
format!(
"{}::{}({})",
trait_name, segment.ident.name, self_expr,
trait_name, segment.ident.name, self_adjusted,
),
Applicability::MachineApplicable,
);